• Advertisement
Sign in to follow this  

Custom Debugging

This topic is 4973 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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. ?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement