Application Debugging Tool GDB

Source: Internet
Author: User

                  The application debugging tool GdB learns to use

I. Introduction of GDB

GDB is a powerful program debugging tool released by GNU. GDB mainly accomplishes the following three functions:

1. Start the program that is being debugged.
2. Let the program being debugged stop at the specified location.
3, when the program is stopped, you can check the program status (such as variable values).

1.1gdb Use Process

1. Compile and build the executable file:
Gcc–g Tst.c-o TST
2. Start GDB
GDB TST (file name)
3. Set a breakpoint at the main function
Break Main
4. Running the program
Run
5. Debug the program with a richer gdb command.

1.2GDB command

1.list (l) View program
2.Break (b) Function name add breakpoint at the entrance of a function
3.Break (b) Line number adds a breakpoint on the specified line
4.Break (b) file name: line number Add a breakpoint on the specified line of the specified file
5. Info Break View all set breakpoints
6. Delete Breakpoint Number Remove Breakpoint
7.Next (N) Single-step program (does not enter sub-functions)
8.Step (s) Single Step Running program (enter sub function)
9.Continue (c) continue to run the program knowing the next power outage
Print (p) Variable name view specified variable value

Set Var=value sets the value of a variable

Quit (q) Exit GDB

Ii. Examples of Use

Application Debugging Tool GDB

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.