简体   繁体   English

GDB,检查指向指针的指针

[英]GDB, examine pointer to pointer

Ok, so I'm trying to learn gdb. 好的,所以我正在尝试学习gdb。 I know most of the basics but I have not been able to figure out how to examine a pointer to a pointer in a oneliner. 我知道大多数基本知识,但我还无法弄清楚如何检查指向单行纸中的指针的指针。 It might be possible by defining a macro/command but I haven't been able to do so. 通过定义宏/命令可能是可行的,但是我还没有做到。

This question began when learning the cdecl calling convention where $esp contained a pointer to a string, passed as an argument to a function. 这个问题是在学习cdecl调用约定时开始的,其中$ esp包含指向字符串的指针,并作为参数传递给函数。 In order to get this out I had to do the following: 为了解决这个问题,我必须执行以下操作:

gdb$ x $esp+0x08
0xbffff6a4: 0x980eb192
gdb$ x/s 0x980eb192
0x980eb192:  "Hello world"

So, the question is. 所以,问题是。 Can this be done in an easier way? 可以用更简单的方式做到这一点吗? Cutting and pasting just feels too slow. 剪切和粘贴感觉太慢了。

Appreciate any hints/ideas! 感谢任何提示/想法!

(gdb) x/s *(char**)($esp+8)可能会成功。

You can reuse results of print in subsequent expressions: 您可以在后续表达式中重复使用print结果:

(gdb) p *(void **)($esp + 4)
$4 = (void *) 0x80aec48
(gdb) x/s $4
0x80aec48:   "alabala"

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

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