GDB Basic Debugging

Source: Internet
Author: User

Gcc-g-wall-o Hello hello.c when debugging

GDB Hello-tui

-G: Generate Debug information

-wall: Compiler warning message

-W: Warning message

When GDB is called, the command line specifies-tui, or ctrl+x+a is used in non-TUI mode.

TUI mode: Upper half source, bottom half input gdb command

Break main: The first line of the main function executable code set breakpoints

Break N: Set breakpoint on nth line

Break if condition: conditional breakpoint, meets condition to pause

Break +offset/-offset: Sets a breakpoint before or after the currently selected stack is executing a line of code

Break *address: Set breakpoints at virtual memory address (e.g. source code or shared library not found)

Clear N: Delete N-line Breakpoint

Clear List_insert: Delete all breakpoints for a function

Clear List.c:list_delet: Delete file: All breakpoints for function

Delete 1 3 4: Delete Breakpoint 1 3 4

Delete 1-4: Delete breakpoints 1 to 4

Disable N: Disabling breakpoints

Enable 1 5: Breakpoint 1 5 Enabled

Enable once 3: Temporarily turn on breakpoint 3

Info break: List all breakpoints

Run: Run Program

Run 12 5 6: Pass Parameters 12, 5, 6 to the program

Next: Travel to the next line

Continue: Resuming execution

Tbreak: Create a breakpoint with a valid number of 1

Until: Get out of the loop and stop.

Finish: Run through the program

Print I: Output i

Watch Z: Monitor Z

Watch (z>5): Find the first position where the z-value is greater than 5 during the execution of a program

Stack frame: The runtime information associated with the call is stored in the memory area that is the stack frame, with the value of the function local variable, the function parameter, and the record that called the function location. Each time a function call is made to create a new frame, the function exits when the frame pops out of the stack and releases.

BackTrace: Displays the entire stack, which is the current collection of all frames

Frame N: The current execution function is numbered 0, the frame is 1, and so on

Up: Bring the next frame to the call stack

Down: In the opposite direction of up

GDB Basic Debugging

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.