Skip to main content
gamedev.net
🔒 Locked

Custom Debugging

Started by Dovyman 0 replies 400+ views
Original Post
Dovyman
Dovyman
Does anybody know how to set interrupts within C code under the Microsoft compiler? i.e., being able to hard code breakpoints in, but when the code hit them, I could have my own interrupt handler instead of control going to the MS debugger. ?
mattnewport
mattnewport
To hard code a breakpoint in C code on x86 with MSVC use
__asm int 3
As for catching exceptions, you'll want to look into Win32 Structured Exception Handling but I'm not sure how you can catch a breakpoint exception before the debugger gets a hold of it. This test program:

#include <iostream>#include <windows.h>int main(int argc, char* argv[]){    __try    {        __asm int 3    }    __except(GetExceptionCode() == EXCEPTION_BREAKPOINT ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)    {        std::cout << "Hit a breakpoint!\n";    }    return 0;}

Will catch the breakpoint when run outside the debugger but when run inside the debugger it seems the debugger catches it first. I don't know how to get around that, maybe a bit of Googling will help.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.