1 | gcc -g eg.c -o eg |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include int wib(int no1, int no2) { int result, diff; diff = no1 - no2; result = no1 / diff; return result; } int main(int argc, char *argv[]) { int value, div, result, i, total; value = 10; div = 6; total = 0; for(i = 0; i < 10; i++) { result = wib(value, div); total += result; div++; value--; } printf("%d wibed by %d equals %d\n", value, div, total); return 0; } |
1 2 3 4 | Program received signal SIGFPE, Arithmetic exception. 0x80483ea in wib (no1=8, no2=8) at eg1.c:7 7 result = no1 / diff; (gdb) |
1 2 3 4 | (gdb) print no1 $5 = 8 (gdb) print diff $2 = 0 |
1 2 3 4 | (gdb) continue Continuing. Program terminated with signal SIGFPE, Arithmetic exception. The program no longer exists. |
1 2 | (gdb) break 21 Breakpoint 1 at 0x8048428: file eg1.c, line 21. |
1 2 | Breakpoint 1, main (argc=1, argv=0xbffff954) at eg1.c:21 21 result = wib(value, div); |
1 2 | (gdb) next 22 total += result; |
1 2 3 4 | (gdb) 23 div++; (gdb) 24 value--; |
1 2 | (gdb) break 21 if value==div Breakpoint 1 at 0x8048428: file eg1.c, line 21. |
1 | (gdb) condition 1 value==div |
1 2 3 4 5 | (gdb) info break Num Type Disp Enb Address What 1 breakpoint keep y 0x08048428 in main at eg1.c:21 stop only if value == div breakpoint already hit 1 time |
1 2 3 4 5 6 | (gdb) break main Breakpoint 1 at 0x8048402: file eg1.c, line 15. (gdb) run ... Breakpoint 1, main (argc=1, argv=0xbffff954) at eg1.c:15 15 value = 10; |
1 2 | (gdb) watch div==value Hardware watchpoint 2: div == value |
1 2 3 4 5 6 7 | (gdb) continue Continuing. Hardware watchpoint 2: div == value Old value = 0 New value = 1 main (argc=1, argv=0xbffff954) at eg1.c:19 19 for(i = 0; i < 10; i++) |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |