2

Ok, so I'm trying to learn 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. 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!

0

2 Answers 2

3

(gdb) x/s *(char**)($esp+8) might do the trick.

Sign up to request clarification or add additional context in comments.

Comments

1

You can reuse results of print in subsequent expressions:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.