R
R
RokkerRuslan2015-02-20 17:30:35
Programming
RokkerRuslan, 2015-02-20 17:30:35

How to debug a program called by another program?

We have the program main. It is called like this:
main.exe "path/to/child.exe"
Its argument is the path to our child program, which needs to be debugged. The main program redirects I/O to interact with child (i.e. child reads information from main from stdin, writes for main to stdout) The
question is how to debug child's program?
A decision comes to mind, to log information, i.e. just write to a file. But I would like to have a debugger and console output.
I would like to clarify that this form is usually taken by test programs at various programming olympiads. Where the checker runs ours with some arguments and checks the output. Here it is complicated only by the fact that the exchange occurs constantly at runtime. The main program starts "communication", the child program must take action based on what it received from main. The child's response will spawn the next request from main. And we went to interact cyclically.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vinatorul, 2015-02-20
@RokkerRuslan

Well, the first thing that comes to mind is to "hook" to the Child process directly from Visual Studio (Debug-> Attach to the process).
If you also have the sources of this process, then maybe the debugger will also understand and allow you to trace through the code, and not through the disassembler.
In order for the debugger to match the code and the process, the executable file must be built with all the debugging data.

I
Igor Aleksandrovich, 2015-02-20
@tyanigor

And what prevents to debug separately the second program? Cover it with tests...

V
Vladimir Martyanov, 2015-02-20
@vilgeforce

You can change the byte at the entry point in child to 0xCC and the process will be fucked up at startup. At this time, the JIT debugger is called (at least the same studio), the byte is changed back in it and the software is debugged.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question