* 64bit pointer
@ 2009-09-03 12:21 freindlyuser
2009-09-03 12:33 ` Jan Kratochvil
2009-09-03 13:01 ` Andreas Schwab
0 siblings, 2 replies; 5+ messages in thread
From: freindlyuser @ 2009-09-03 12:21 UTC (permalink / raw)
To: gdb
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I didn't know if this was a bug or if I was just doing something
wrong. Basically when I try to use * to get the value pointed to by
something it gives me 32 bits of the pointer which is actually a
64bit address.
(gdb) x/s *($rdi+0x8)
0x4210a9b7: <Address 0x4210a9b7 out of bounds>
(gdb) x/x $rdi+0x8
0x3a9b4210b7a4: 0x00003a9b4210a9b7
(gdb) x/s 0x00003a9b4210a9b7
0x3a9b4210a9b7: "The string it points to"
In the above I wanted to read the string pointed to by the pointer
at $rdi+0x8
Should this be happening?
Should I be using a different command or something different to the
asterisk?
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).
Thank you.
-----BEGIN PGP SIGNATURE-----
Charset: UTF8
Version: Hush 3.0
Note: This signature can be verified at https://www.hushtools.com/verify
wpwEAQMCAAYFAkqftNQACgkQWX1/rrecYT2pBgP/RVbdltSzvOihdHAKfpweEjXQ7U1T
f2xyz8uRhyPZQ2n1w2nA/IyU79LyB3sIUcoZ+CkxX0VPh34W8Kw00XfWYq85C3dSW9vm
ibLw6AIE5CVcvz39wX/68s4qEYS/BdpetltS3sEeKswV7ylCjNajtFwu2h5WIxsVhdop
kkXuBfA=
=l5hi
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 64bit pointer
2009-09-03 12:21 64bit pointer freindlyuser
@ 2009-09-03 12:33 ` Jan Kratochvil
2009-09-04 15:47 ` Tom Tromey
2009-09-03 13:01 ` Andreas Schwab
1 sibling, 1 reply; 5+ messages in thread
From: Jan Kratochvil @ 2009-09-03 12:33 UTC (permalink / raw)
To: freindlyuser; +Cc: gdb
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 64bit pointer
2009-09-03 12:33 ` Jan Kratochvil
@ 2009-09-04 15:47 ` Tom Tromey
0 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2009-09-04 15:47 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: freindlyuser, gdb
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> Yes. Until GDB forbids dereferencing numeric arguments as `int *'
Jan> which IMHO is more confusing than convenient. [Would a patch be
Jan> approved?]
This behavior does seem strange to me.
GDB as a project seems to be somewhat conservative about changing things
like this, though. I don't think I could predict whether anybody would
object, you pretty much have to submit a patch and see who speaks up.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 64bit pointer
2009-09-03 12:21 64bit pointer freindlyuser
2009-09-03 12:33 ` Jan Kratochvil
@ 2009-09-03 13:01 ` Andreas Schwab
1 sibling, 0 replies; 5+ messages in thread
From: Andreas Schwab @ 2009-09-03 13:01 UTC (permalink / raw)
To: freindlyuser; +Cc: gdb
freindlyuser@hushmail.com writes:
> I didn't know if this was a bug or if I was just doing something
> wrong. Basically when I try to use * to get the value pointed to by
> something it gives me 32 bits of the pointer which is actually a
> 64bit address.
>
>
> (gdb) x/s *($rdi+0x8)
> 0x4210a9b7: <Address 0x4210a9b7 out of bounds>
> (gdb) x/x $rdi+0x8
> 0x3a9b4210b7a4: 0x00003a9b4210a9b7
> (gdb) x/s 0x00003a9b4210a9b7
> 0x3a9b4210a9b7: "The string it points to"
>
> In the above I wanted to read the string pointed to by the pointer
> at $rdi+0x8
>
> Should this be happening?
Since the type of $rdi is not a pointer, gdb is just being helpful and
implicitly converts the value to (int *) before applying the indirection
operator.
> Should I be using a different command or something different to the
> asterisk?
> 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).
There are several options:
- Add a cast, {type} is short for *(type *):
(gdb) x/s {char *}($rdi+8)
- Use the $__ convenience variable after examining the address:
(gdb) x/x $rdi+8
(gdb) x/s $__
Andreas.
--
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E
"And now for something completely different."
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 64bit pointer
@ 2009-09-03 13:27 freindlyuser
0 siblings, 0 replies; 5+ messages in thread
From: freindlyuser @ 2009-09-03 13:27 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thu, 03 Sep 2009 12:33:25 +0000 Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
>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
The work around works perfectly.
Thank you.
-----BEGIN PGP SIGNATURE-----
Charset: UTF8
Version: Hush 3.0
Note: This signature can be verified at https://www.hushtools.com/verify
wpwEAQMCAAYFAkqfxDYACgkQWX1/rrecYT2g+gP+J6na4+MXovA7SJRD1oYPKqbZ9Pu1
Ik4vBR5BFt6RLV0zrYXsAnEq1xOXnac1q3r9XNUA0R1jmKtEFYvJjH44KpdzwIwBBRSS
7M7qeaHZZhDEgfJOFUgWS5KUJgjwRo4Rm2lGLNgmaftQVBrgE5HUQxVicwtdwIO9qyhU
i/n0Oas=
=+lL9
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-09-04 15:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-03 12:21 64bit pointer freindlyuser
2009-09-03 12:33 ` Jan Kratochvil
2009-09-04 15:47 ` Tom Tromey
2009-09-03 13:01 ` Andreas Schwab
2009-09-03 13:27 freindlyuser
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox