GDB of Linux C

Source: Internet
Author: User

First, GDB's function:

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 status of the program

4, dynamic change the execution environment of the program

Second, the basic use of GDB process:

1. Compile and build the executable file: gdb-g hello.c-o Hello

2. Start Gdb:gdb Hello

3. Set breakpoints somewhere: Break line number or broken function name

4. Running Program: Run

5, the use of more extensive GDB debugging commands for program debugging

iii. Common Debug command options:

Option (abbreviated) command option format description

Run (r) run [parameter 1][parameter 2] ... Run the program, and the argument list that follows is the parameter passed into the Mian function, or it can have no

List (l) list [Start row] [end line] list[line number] list [filename] [line number] [Start row] [end row] Default display 10 rows

Print (p) p (print) [variable name] printing variable name can also be called with the function eg Print Add (3,5)

Break (b) breaking [line number] or breaking [function name] or breaking routine entry set breakpoint

     Delete (d)                        d (delete) [Breakpoint designator]                                                     Delete Breakpoint

      Info b                                                                                                                 View all breakpoints

      next (N)                                                                                                               step execution without entering functions                                           

      Step (s)                                                                                                               Stepping into a function                                            

      Continue (c)                                                                                                        resumes execution of the function until the function ends or encounters a new breakpoint

      set                             set [variable name] =[value]                                                           Set the value of the variable

      whatis                       whatis [variable name]                                                               View types of variables

      finish                                                                                                                 executes the current function and, if there is a return value, prints the return value

      quit (q)                                                                                                                  Exit GDB Debugging

      Help (h)                         format h (Help)  [command name]                                             See how to use the specified command.

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.