This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: 64bit pointer
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: freindlyuser at hushmail dot com
- Cc: gdb at sourceware dot org
- Date: Thu, 3 Sep 2009 14:33:25 +0200
- Subject: Re: 64bit pointer
- References: <20090903122141.4BD7DB8043@smtp.hushmail.com>
On Thu, 03 Sep 2009 14:21:41 +0200, freindlyuser@hushmail.com wrote:
> (gdb) x/s *($rdi+0x8)
> 0x4210a9b7: <Address 0x4210a9b7 out of bounds>
This syntax is not much recommended, it means the same as:
(gdb) x/s *(int *) ($rdi+0x8)
0x4210a9b7: <Address 0x4210a9b7 out of bounds>
On 64bit arch sizeof (int) == 4 but sizeof (void *) == 8 so you will not fetch
the whole address.
> (gdb) x/x $rdi+0x8
> 0x3a9b4210b7a4: 0x00003a9b4210a9b7
> (gdb) x/s 0x00003a9b4210a9b7
> 0x3a9b4210a9b7: "The string it points to"
Therefore you want one indirection there.
> Should this be happening?
Yes. Until GDB forbids dereferencing numeric arguments as `int *' which IMHO
is more confusing than convenient. [Would a patch be approved?]
> Is there a work around where I can read the data in
> 0x00003a9b4210a9b7 without having to manually copy and paste (ie:
> in the commands that are executed on a breakpoint).
This way it should work:
(gdb) x/s *(void **) ($rdi+0x8)
OR
(gdb) p *(char **) ($rdi+0x8)
Regards,
Jan