Some of GDB's tricks

Source: Internet
Author: User

View stack Information

Bt

Info stack

View Source Program

List

Foucs (FS) command, which can highlight the execution position of the current statement, and also follow the change in stepping

View Memory

P [email protected] View xxxptr pointer content start continuous n bytes of memory

You can use the Examine command (abbreviated as x) to view the values in the memory address. The syntax for the x command is as follows:

X/<n/f/u> <addr>

    • n indicates the length of the memory, meaning that the contents of several addresses are displayed backwards from the current address.

    • f indicates the format of the display, if it is a string, use S, if it is a number, you can use I.

    • U represents the number of bytes requested from the current address, and the default is 4 bytes. (b single-byte, H-DWORD, w four bytes, g eight bytes)

    • <addr> represents a memory address.

Watch Window

In VisualStudio, you can view the value of a variable dynamically through the Watch window. In GdB, a similar command display is provided, and its syntax is:

Display <expr>
Display/<fmt> <expr>
Display/<fmt> <addr>

Expr is an expression, FMT represents the format shown, and addr represents a memory address. When you set up one or more expressions with display, GDB automatically displays the values of the expressions you set as long as your program is stopped (step-by-trace).

Several related commands are as follows:

    • Undisplay <dnums...> not show dispaly
    • Delete display [dnums] removes auto-displays, removes all auto-displays without the Dnums parameter, and also supports range deletion, such as: Delete Display 1,3-5
    • Disable Display <dnums...> disable display
    • Enable Display <dnums...> Restore display
    • Info Display View display information

Some of GDB's tricks

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.