Mr.SrJenea
Mr.SrJenea

Reputation: 523

gdb examine and print give different values

I am examining the memory in gdb and noticed that print and examine give 2 different values for the same location.

(gdb) x/d $ebp-0x1c 0xffffd10c: 126 (gdb) p *0xffffd10c $1 = 382

Why is this happening ?

UPD:

As pointed in the answer, that could have happened because I didn't explicitly specify the size to print. I've tried to specify, and I've got similar results:

(gdb) p/x *0xffffd110 $5: 0x9c9 (gdb) x/x $ebp-0x18 0xffffd110: 0xc9

Upvotes: 0

Views: 1514

Answers (1)

Ove
Ove

Reputation: 788

The "p" command might implicitly assume a machine word, but "x" remembers the last size you've used with it, which seems to be a character here. To tell it to use a 4-byte word again, you could use "x/wd", for example.

Upvotes: 2

Related Questions