GDB Debug Program

Source: Internet
Author: User

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

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.