How do I use the GDB debug program?

Source: Internet
Author: User

the general meaning of the program is that each array is assigned a value, then output to
The program has been written on the above, let's look at how to produce a compiled file with debugging information, here we want to use the GCC's-g parameter, to add some debugging information in the compilation file.

Found added-G and no plus-G, the resulting file size is not the same!!!! You will find that, with G, the resulting compilation file volume will also increase, so when we do software development, the addition of debugging information should be in the initial design, later, the application to remove these debugging information, of course, if you want to retain the software's own debugging functions, it will be retained.
here are some common gdb debug commands list or L used to list the source program every time a list or L will display 10 lines of source code, or specify the line number listed to view the source program "list line number" When using this parameter, to Make sure the source program is not removed or moved, otherwise it cannot be viewed. Break/b Set breakpoints, you can specify the line number of the breakpoint, or the function name. Info BreakShow breakpoint information Run Run Program Print view the value of the corresponding expression and variables next run the program, but do not enter the function call step to run the program, and make a function callContinueContinue executing the function until the function ends or the next breakpoint

When you run a compiled file using the GDB command, you can see the following information, like other tools with some explanatory text, some copyrights, versions, and other descriptions, and finally (GDB) is its environment prompt, similar to the shell prompt, to alert the user, enter the command later.
The above figure is the result of the program without error! Take the next two. I changed the source program to the array assignment of a statement to scanf ("%d", a[i]); No add & take address character again debugger list can see the code nearby!

How do I use the 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.