Sometimes it's impossible to start a process under debugger. Instead, I want the debugger to be started when a process reaches some point.
To cause a debug break from the code, choose any of the following:
- Call DebugBreak() API.
- Call the built-in function __debugbreak().
- __asm int 3;
Why it is not working:
1. If you have Windows 7, go to Control Panel->Action Center->Change Action Center Settings->Problem Report Settings and make sure "Each time a problem occurs, ask me before checking for solutions" is checked (thanks to http://stackoverflow.com/questions/890890/debug-program-option-in-windows-7). Actually this is very important option. If it is not selected, the program crash can be silent, which is terrible for developers and testers.
2. In fact, all these commands cause breakpoint exception. So it is possible to ignore these exceptions with the help of Structured Exception Handling (SEH). For instance, the following code ignores debug break:
_try {
DebugBreak();
} _except(EXCEPTION_EXECUTE_HANDLER) {DebugBreak();
}
(of course, _except block can be located anywhere in call stack).
How to launch the Debugger Automatically when the application with the specified name starts.
It is possible to automatically debug an application of the specified name (for instance make "my_test.exe" always run under debugger). For details, see http://msdn.microsoft.com/en-us/library/a329t4ed%28v=vs.80%29.aspx
No comments:
Post a Comment