First, ready the content vim test3.c input as follows.
#include <stdio.h>
int func (int n)
{
int sum=0,i;
for (i=0; i<n; i++)
{
Sum+=i;
}
return sum;
}
Main ()
{
int i;
Long result = 0;
for (I=1; i<=100; i++)
{
result + = i;
}
printf ("result[1-100] =%d/n", result);
printf ("result[1-250] =%d/n", func (250));
}
Second, compiled into
GCC Test3.c-o test3
./TEST3 can view results
GDB test3 Error occurred
GDB list when the following error occurred
No symbol table is loaded. Use the "file" command.
---------------------------------
Solution:
The list command shows no symbol table is loaded. Use the "file" command.
Originally compiled with: gcc-o filename filename.c
solution, compile-time add must be added-g:gcc-o filename-g filename.c
Or for example Gcc-g-o test3 test3.c then gdb test3
GDB List 1 starts with the first line. The default is only 10 lines at a time, the direct enter key under 10 lines of code
GDB Debug Program