GDB is a powerful UNIX program debugging tool released by the GNU Open source organization. Perhaps, you like the graphical interface, such as VC, BCB debugging IDE, but if you are in the UNIX platform to do the software, you will find that the debugging tool GDB is more than VC, BCB graphics debugger more powerful features. The so-called "inch, the ruler is short" is this truth.
In general, GDB mainly helps you complete the following four aspects of the function:
Start your program, and you can run the program as you want to customize it.
Allows the program being debugged to stop at the breakpoint where you specified the adjustment. (Breakpoints can be conditional expressions)
When the program is stopped, you can check what happens in your program at this time.
Dynamically change the execution environment of your program.
From the above, GDB and the general debugging tools are not the same, basically complete these functions, but in detail, you will find GDB this debugging tool is powerful, you may be more accustomed to the graphical debugging tools, but 8630.html "> sometimes, The debug tools on the command line have functions that the graphical tools cannot complete. Let's see it all.
A debugging example
SOURCE program: TST.C
#include <stdio.h>&http://www.aliyun.com/zixun/aggregation/37954.html ">NBSP;
int func (int n)
{
int sum=0,i;
For (I=1 i<=n; i++)
{
Sum+=i;
}
return sum;
}
int main ()
{
int i;
Long result = 0;
For (I=1 i<=100; i++)
{
result = i;
}
printf ("result[1-100] =%ld \ n", result);
printf ("result[1-250] =%d \ n", func (250));
return 0;
}
To compile the build execution file:
$GCC-G-wall tst.c-o TST