gdb 调试器
#include <stdio.h> int sum(int); int main(){ printf("the sum of 1-50 is %d\n",sum(50)); } int sum(int n){ int i,sum; for(i = 1,sum = 0; i <= n; ++i){ sum += i; } return sum; }
(gdb) l 1 #include <stdio.h> 2 3 int sum(int); 4 5 int main(){ 6 printf("the sum of 1-50 is %d\n",sum(50)); 7 } 8 9 int sum(int n){ 10 int i,sum; (gdb) 11 for(i = 1,sum = 0; i <= n; ++i){ 12 sum += i; 13 } 14 return sum; 15 } (gdb) Line number 16 out of range; gdbt.c has 15 lines.gdb 列出的源代码中明确地给出了对应的行号,这样就可以大大地方便代码的定位。
原文地址:http://blog.csdn.net/fb408487792/article/details/45290829