Ignoring breakpoints in gdb
If you want to ignore some breakpoints in gdb you can achieve that using “ignore”.
Let’s say we want to analyze following code
/* This is main.c */ #includeint main() { int i; for(i=0;i<1000;i++) { printf("%d\n", i); // we want to analyze 999 call } return 0; }
Compile the code
gcc -g -o main main.c
and then run gdb
gdb main (gdb) list 1 #include2 3 int main() { 4 int i; 5 for(i=0;i<1000;i++) { 6 printf("%d\n", i); // we want to analyze 999 call 7 } 8 return 0; 9 } 10 (gdb) break 6 Breakpoint 1 at 0x100000ef1: file main.c, line 6. (gdb) ignore 1 999 Will ignore next 999 crossings of breakpoint 1. (gdb) run Reading symbols for shared libraries +........................ done 0 1 ... ... ... 998 Breakpoint 1, main () at main.c:6 6 printf("%d\n", i); // we want to analyze 999 call (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 0x0000000100000ef1 in main at main.c:6 breakpoint already hit 1000 times (gdb)
June 23rd, 2013 in
main entries