简体   繁体   中英

Break process without breakpoint in c++

In Visual Studio 2008 MFC application is there a way to stop the debugging without a breakpoint, when I press a button? The problem is, it's a pretty big and shared project, so my code is called by another "module", but I don't know which of my functions are called, so I don't know where to put a breakpoint. My goal would be to break the process, if any of my functions are called.

您可以使用DebugBreak()函数。

You could write a Visual Studio macro that puts a breakpoint on every line in your source code. You could make it a bit smarter and only put breakpoints on each function start, but that would require some parsing. Bind that macro to a key. Run the MFC application and when you want to start breaking on your own code, switch to Visual Studio, press the key and presto, you will break on the first use of your code.

The other option is to make a C++ macro that checks if a global boolean has been set and executes asm { int 3 } when it has. Use this macro at the start of every (high level) function of your code. Add code that sets the global boolean when a certain button is pressed in the MFC application. This will only work in a 32-bit executable, you'll need some intrinsic in a 64-bit executable, which I don't know by head.

Hope this helps.

Cheers,

Sebastiaan

There's a "Pause" button that breaks the execution... Or you can put a breakpoint on all the possible suspects. You don't know which of your functions is called - put a break on all of them. Then you'll achieve your goal.

My goal would be to break the process, if any of my functions are called.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM