GDB a powerful UNIX program debugging tool

Source: Internet
Author: User
Keywords NBSP; GDB program debugging Debugging Tools
Tags custom debugger debugging debugging tools find function gdb gnu

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.