Memory in GDB (x command)

Source: Internet
Author: User

 

Memory in GDB (x command)

You can use the EXAMINE command (abbreviated as X) to view the value in the memory address. The syntax of the X command is as follows:

X/<n/f/u> <ADDR>

N, f, and u are optional parameters.

N is a positive integer that shows the memory length, that is, the content of several addresses is displayed from the current address to the back.

F indicates the display format. See the preceding figure. If the address refers to a string, the format can be S. If location 10 is the instruction address, the format can be I.
X displays variables in hexadecimal format.
D. Display variables in decimal format.
U displays unsigned integers in hexadecimal format.
O display variables in octal format.
T display variables in binary format.
A displays variables in hexadecimal format.
C. Display variables in character format.
F. Display variables in floating point format.

U indicates the number of bytes requested from the current address. If not specified, GDB defaults to four bytes. The U parameter can be replaced by the following characters. B represents a single byte, H represents a double byte, W represents a four byte, and G represents an octal node. When we specify the byte length, GDB reads and writes the specified byte starting from the memory address specified by the memory and takes it as a value.

Bhwg

X/4bt &

--------------------------------
<ADDR> indicates a memory address.
The n/f/U parameters can be used together. For example:

Command: X/3uh 0x54320 indicates that the content is read from the memory address 0x54320, h indicates that the two bytes are used as a unit, 3 indicates three units, and the u table is displayed in hexadecimal format.

Output Format
Generally, GDB outputs the value of a variable based on the type of the variable. However, you can also customize the output format of GDB. For example, you want to output a hexadecimal integer or a binary value to view the bitwise of the integer variable. To do this, you can use the gdb data display format:

X displays variables in hexadecimal format.
D. Display variables in decimal format.
U displays unsigned integers in hexadecimal format.
O display variables in octal format.
T display variables in binary format.
A displays variables in hexadecimal format.
C. Display variables in character format.
F. Display variables in floating point format.
(GDB) p I
$21 = 101

(GDB) P/A I
$22 = 0x65

(GDB) P/C I
$23 = 101 'E'

(GDB) P/F I
$24 = 1.20.31145e-43

(GDB) P/x I
$25 = 0x65

(GDB) P/T I
$26 = 1100101

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.