I’ve already mentioned I’m a fan of Visual Studio. Whenever I think of something development-related I wish it would do, a little bit of investigating shows how it can already do it in some form. A case in point is my current project, which involves 2 separate executables. The first executable watches for and filters file changes and then passes the content to the second executable where it is consumed.
While an argument can be made for combining these two tasks into a single executable, I decided to separate them in the hopes that I would be able to isolate and recover from faults in one without affecting the operation of the other. Of course, this meant that in order to address any bugs, I have to first determine which executable contains the fault. Usually this means observing the system as files enter the filtering engine and eventually get consumed or ignored. Since I have two executables, it means that I ideally want to run a debugger that allows me to debug both executables simultaneously so I can watch the data move through one and out to the other.
Fortunately, Visual Studio makes this as easy as debugging a single executable. All that is needed is a solution containing both projects. To start debugging an executable, simply right-click on its project and select “Debug”->”Start New Instance”. The selected projected will execute with the debugger attached. Do the same thing for any other projects that you wish to debug.
Of course, you can also start each program manually by running their executables and then attaching the debugger to each process. To do that, simply select the “Attach to Process” command in the “Debug” menu. A list of available processes will appear – select all the processes you wish to attach to and press the “Attach” button. The debugger will attach itself to the currently running process, and if the debug symbols are available and the appropriate project is loaded, you can set breakpoints and inspect values just as you would in a “regular” debugging session.
For more information on connecting to multiple processes, check out Microsoft’s help page, which has some more information on how to handle breakpoints and other items of interest.