Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

examine command in gdb?

Tags:

c

gdb

A number can also be prepended to the format of the examine command to examine multiple units at the target address.

source: hacking the art of exploration

(gdb) x/2x $eip
0x8048384 <main+16>:   0x00fc45c7 0x83000000

(gdb) x/x $eip
0x8048384 <main+16>:   0x00fc45c7

I know that the second examine command returns the memory address that eip is currently locating. What about the first one which returns two memory address?

like image 631
Henok Tesfaye Avatar asked May 25 '26 10:05

Henok Tesfaye


1 Answers

The examine command of gdb has the following syntax:

x/[n][f][u]

where n, f and u are optional and n is the length, f the format and u the unit size.

Possible formats are:

  • s (null terminated string)
  • i (machine code instruction)
  • x (hexadecimal value)

If no unit size can be one of the following values:

  • b (bytes)
  • h (2 bytes)
  • w (4 bytes)
  • g (8 bytes)

where w is the default.

Therefore x/2x prints 2 hexadecimal values with a size of 4 bytes from your code segment.

like image 82
kalehmann Avatar answered May 28 '26 02:05

kalehmann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!