Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I stop a C++ application during execution to debug into a dll?

I have an application for which I do not have the code, and a dll for which I do have the code. I need to be able to debug into the dll, but lacking the source for the exe, how do I do this?

The dll code is mfc c++; I believe that the main app is the same thing as well.

I've tried doing a 'set target application' deal, where I set the application that the dll will be called from, and the application crashes a horrible, horrible death when called that way. I don't know if the fault lies with this dll or with the executable for that behavior, and it's just one of the myriad things I'd like to solve.

I'm thinking that there should be some call to allow the dll to spin indefinitely until a debugger is attached to the process, at which point I should be able to debug the dll by attaching to the process. Does that make sense? Is there a better way to do this?

like image 787
mmr Avatar asked Dec 13 '22 04:12

mmr


1 Answers

I used to use the DebugBreak function for this. You could have it called conditionally based on the presence of a particular file, perhaps.

#ifdef DEBUG
if (... file exists...) {
    DebugBreak();
}
#endif

This will halt application execution until you attach a debugger or terminate the app.

like image 100
Matt K Avatar answered Jan 04 '23 23:01

Matt K