简体   繁体   English

gdb检查并打印出不同的值

[英]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中的内存,并注意到printexamine在同一位置给出了2个不同的值。

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

Why is this happening ? 为什么会这样呢?

UPD: 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. “ p”命令可能会隐式假定一个机器字,但是“ x”会记住您使用的最后一个大小,这里似乎是一个字符。 To tell it to use a 4-byte word again, you could use "x/wd", for example. 要告诉它再次使用4字节字,可以使用“ x / wd”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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