Use of GDB Debugging tools in GCC

Source: Internet
Author: User

First, use GCC to compile the source file when you add the-G option to generate a debug file, for example, to debug a test.c file, enter the command $ gcc-g test.c-o test_gdb generate the Test_gdb file.

Then, run the command $ gdb test_gdb to enter debug mode.

In debug mode, (GDB) indicates that a command can be entered at this point, and the commonly used GDB debug commands are as follows:

GDB Common Commands Format Meaning Shorthand
Break break [line number or function name] Set a breakpoint in the program B
Cd CD Catalog Change the current working directory
Continue Continue [Start, end] Continue execution from Breakpoint C
Delete Delete Breakpoints Breakpoint Number Delete a breakpoint
Display Display variable Name Display parameters
File File File name Loading files
Info Info variable Name List information for variables I
Kill Kill Terminate program run
List List [Start, end] Listing code listings for a file L
Next Next Next line N
Print Print variable Name Print variable Contents P
Pwd Pwd Displays the current working directory
Quit Quit Exit GDB Q
Run Run args Run the program R
Step Step Next step (can be performed inside the function) S
Watch Watch variable name or expression Set a monitoring point for a variable or expression

Use of GDB Debugging tools in GCC

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.