I have to debug multiple dlls each within their own project. There is a parent executable that loads a dll, which serves as a container for the other dlls. My question is how can I debug开发者_如何学编程 the whole 'component' ie: all the dll's involved, using Visual Studio 2005 for C++.
If they're all in the same solution, set a breakpoint in the DLL project where you want to debug, right click on the EXE project, and select Debug > Start new instance.
If they're in separate solutions, open the DLL solution, right click on the project, expand the Configuration Properties node in the tree on the left, select Debugging. Set the Command property to point to the debug build of the EXE in the other project. Then set your breakpoint(s) and hit F5 to start debugging.
Arbitrarily pick one of the DLL projects as the startup project, it doesn't matter which. Right-click + Properties, Debugging. Set the 'Command' setting to the path of a test EXE that will load the DLLs. If you don't have a good one then just write one, might as well add it to the project and make it the startup project.
Pay attention to the Output window while the EXE starts. You'll see notifications for each DLL that gets loaded. As soon as one of the DLLs that's in your solution gets loaded then the debugger jumps in, looks for the .pdb file for the DLL and activates any breakpoints you'd have set in the DLL source code. You cannot debug the DLL unless the EXE loads it.
If that still doesn't enable breakpoints then use Debug + Windows + Modules and locate the DLL in the list. Right-click it and choose Symbol Load Information to find out where the debugger looked for the .pdb file. This doesn't go wrong very often since the DLL contains the path to the .pdb file. The far more typical failure mode is that the EXE simply didn't load the DLL.
精彩评论