Created
March 11, 2014 23:25
-
-
Save johnbartholomew/9497219 to your computer and use it in GitHub Desktop.
Inserting a breakable call
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Another option which is more reasonable if you're willing to recompile is to insert a call to a trap function | |
* could be __builtin_trap() for GCC, or DebugBreak/__debugbreak for MSVC, or your own function like this: / | |
static void PoorMansBreakpoint() { | |
printf(""); /* stick a breakpoint on this line */ | |
} | |
int fugbug(int a, int b) { | |
return (a + b < 10) | |
? 8 | |
: (PoorMansBreakpoint(), 3); /* the ever-useful comma operator */ | |
} | |
int main(void) { | |
fugbug(5, 2); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment