GDB Debugger Steps

Source: Internet
Author: User
Tags gdb debugger

    • Adding debug information During Program A.C compilation: g++-g-o a.debug A.C
    • Start GDB, enter under Terminal: GDB
    • At this point gdb is started, loading the program that needs debugging in GDB, entering command in Terminal: File A.debug
    • Looking at the code in GDB, after adding the-G command with g++, the compiled A.debug program automatically joins the breakpoint, you can use the List command to view the source code and breakpoints, in the terminal input command: List 1, when GDB will display the first breakpoint before the code.
    • Press and hold the Enter key to display the previous code for the next breakpoint, and so on, you can view the breakpoint program.
    • Add a breakpoint to the corresponding line, such as a breakpoint in line sixth, enter a command: Break 6
    • To view breakpoints, you can enter a command: Info breakpoint can display all breakpoints in the program
    • To view the nth breakpoint, to view the second breakpoint, you can enter a command: Info breakpoint 2
    • Run the program, enter the command: Run
    • You can enter next or step or continue and N for debugging:
      • Step can be debugged inside the function
      • Next single-Step commissioning
      • Continue run to the next breakpoint
    • To view a variable, enter the print variable name, if you want to view the value of I, enter: print I
    • Exit program command: Q

GdB Debugger Steps

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.