Jump to content
dummzeuch

debugging an executable started by the one being debugged

Recommended Posts

Following up on 

I am trying to use the 64 bit dll from a 64 bit program that then executes a 32 bit program and controls it via stdin/stdout/stderr redirection.

While this works fine (after I realized that I need to call Flush after each Write call otherwise it might be stuck in the 128 byte internal cache), I wonder how I am going to debug the 32 bit executable. I remember seeing a debugger option to also debug external executables started by the executable being debugged, but I have no idea whether that was in Delphi or some other programming environment I used years ago (Virtual Pascal?) and I can't find it in Delphi. Also I doubt that this would work for 64 bit programs executing 32 bit programs.

 

Just to be clear: I have got a 64 bit Delphi program that starts a 32 bit Delhi program, sends input to it via stdin and receives output from it via stdout and stderr. I want to run that 32 bit Delphi program in the debugger.

 

The only way I currently see would be to attach to that program after it has been executed. But that's rather cumbersome.

 

Hm, maybe I could reverse this: Have the 32 bit programm run in the debugger and have that start the 64 bit program and communicate with it via stdin/out/err ...

Share this post


Link to post
1 hour ago, dummzeuch said:

Hm, maybe I could reverse this: Have the 32 bit programm run in the debugger and have that start the 64 bit program and communicate with it via stdin/out/err ...

This is easier i think, 

 

But 

1 hour ago, dummzeuch said:

The only way I currently see would be to attach to that program after it has been executed. But that's rather cumbersome.

Let the child process check the command line in case of named pipes being passed then child will CreateFile with OPEN_EXISTING then use SetStdHandle to switch, and you are good to go, parent will create them with CreateNamedPipe.

 

In that case parent can switch between standard and named, named can be fixed while you are debugging, parent can be debugged and another debugger will spawn the child on its own with fixed names, 

 

This will work, i used this many times, but and unless there is so many other parameters/commandline then it will revert to cumbersome to adjust the child command by hand, yet again these parameter could be temporarily (in debugging mode) to be used form/within a file created by Parent and signaled by specific command to child to process...

 

I think you got the idea, the performance drop between named and standard is negligible. 

  • Thanks 1

Share this post


Link to post
2 hours ago, dummzeuch said:

I wonder how I am going to debug the 32 bit executable.

Run the 32-bit executable in the debugger while specifying the 64-bit application as the host?

image.thumb.png.bff6c9ed3250f9c270f3b376ac006556.png

Share this post


Link to post
2 minutes ago, Uwe Raabe said:

Isn't that what Attach to process is for?

"The only way I currently see would be to attach to that program after it has been executed. But that's rather cumbersome."

Share this post


Link to post
1 hour ago, Anders Melander said:

Run the 32-bit executable in the debugger while specifying the 64-bit application as the host?

image.thumb.png.bff6c9ed3250f9c270f3b376ac006556.png

Interesting idea ...

[testing it]

... doesn't work though. The 64bit programm configured as host application doesn't get started at all. The debugger starts the 32bit program but without input/output redirection. Maybe this only works for DLLs and packages?

Share this post


Link to post
48 minutes ago, dummzeuch said:

Maybe this only works for DLLs and packages?

Yes, you're probably right.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×