简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM