Jump to content
  • Advertisement
Sign in to follow this  
Dovyman

Custom Debugging

This topic is 5099 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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!