Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@redhat.com>
To: freindlyuser@hushmail.com
Cc: gdb@sourceware.org
Subject: Re: 64bit pointer
Date: Thu, 03 Sep 2009 13:01:00 -0000	[thread overview]
Message-ID: <m3k50g9op1.fsf@hase.home> (raw)
In-Reply-To: <20090903122141.4BD7DB8043@smtp.hushmail.com> 	(freindlyuser@hushmail.com's message of "Thu, 03 Sep 2009 12:21:41 	+0000")

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."


  parent reply	other threads:[~2009-09-03 13:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-03 12:21 freindlyuser
2009-09-03 12:33 ` Jan Kratochvil
2009-09-04 15:47   ` Tom Tromey
2009-09-03 13:01 ` Andreas Schwab [this message]
2009-09-03 13:27 freindlyuser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3k50g9op1.fsf@hase.home \
    --to=schwab@redhat.com \
    --cc=freindlyuser@hushmail.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox