Skip to content

Instantly share code, notes, and snippets.

@simark
Created January 21, 2014 21:41
Show Gist options
  • Save simark/8548964 to your computer and use it in GitHub Desktop.
Save simark/8548964 to your computer and use it in GitHub Desktop.
GDB Python finish breakpoint bug reproduction
class EnterBreakpoint(gdb.Breakpoint):
def __init__(self):
super(EnterBreakpoint, self).__init__("hopefully_notinlined")
def stop(self):
FinishBp()
class FinishBp(gdb.FinishBreakpoint):
def stop(self):
print("I am here")
EnterBreakpoint()
// gcc -g test.c -O3
// gdb -x finish.py a.out
#include <stdio.h>
int __attribute__ ((noinline)) hopefully_tailcalled(int n) {
return n * 3;
}
static __attribute__ ((noinline)) int hopefully_notinlined(int n) {
return hopefully_tailcalled(n);
}
static int hopefully_inlined(int n) {
return hopefully_notinlined(n);
}
int main(int argc, char **argv) {
int x;
x = hopefully_inlined(argc);
printf("%d\n", x);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment