Skip to content

Instantly share code, notes, and snippets.

@johnbartholomew
Created March 11, 2014 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnbartholomew/9497219 to your computer and use it in GitHub Desktop.
Save johnbartholomew/9497219 to your computer and use it in GitHub Desktop.
Inserting a breakable call
/* 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