Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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