custom assert that debugger breaks on
I would like to write my own assert that, instead of exiting the program, causes the debugger to break on the assertion failure. I would like a solution that does not require wrapping everything in try/catch blocks. Does anyone know how to write such a thing?
Thanks
In Windows, triggering an interrupt 3 will break into the debugger. You can do this within inline assembly or your compiler may have functions to do it. Ex: in MSVC, you can use __debugbreak().
If you use __debugbreak() or int 3, the program will still end if you're not using a debugger. What you can do if open up a dialog box or message box with options, such as "Ok" and "Cancel" where one triggers a breakpoint and the other just attempts to continue the application.
In Visual Studio 2008EE, running the debugger will catch the standard library assert() function. There is no need to use something else.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement