How can I make GDB do extra dereferences in a printing function like
x/s
?
When I try explicit dereferences in x/
I get the error \"Attempt to
d
The solution is to cast the pointers before dereferencing them.
For example, picking up where we left off above:
(gdb) x/s **((char ***) (0xc + $ebp))
0xbfffedc8: "/var/tmp/SO-attempt-to-dereference-generic-pointer/example"
(gdb) x/s *(*((char ***) (0xc + $ebp)) + 1)
0xbfffee03: "first"
(gdb) x/s *(*((char ***) (0xc + $ebp)) + 2)
0xbfffee09: "second"
Note that the stack address 0xc + $ebp
is itself a pointer to the
contents of that stack location, and so we need char ***
and not
char **
.