Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: Re: [RFC] dwarf2_read_address(): sign extend as appropriate
Date: Tue, 24 Apr 2007 18:13:00 -0000	[thread overview]
Message-ID: <20070424110309.58b32205@ironwood.lan> (raw)
In-Reply-To: <jefy6q90g6.fsf@sykes.suse.de>

On Tue, 24 Apr 2007 00:43:05 +0200
Andreas Schwab <schwab@suse.de> wrote:

> Daniel Jacobowitz <drow@false.org> writes:
> 
> > On Mon, Apr 23, 2007 at 09:49:00AM -0700, Kevin Buettner wrote:
> >> We can't use address_from_register() in this instance since
> >> dwarf2_read_address() is not fetching an address from a register, but
> >> rather from some DWARF2 info.
> >
> > How about value_as_address?
> 
> How about extract_typed_address?

I really liked this suggestion when I first saw it because it appears
that it would do the right thing on MIPS and we would avoid creating a
value which we'd immediately take apart again.

However, after further study, I see two issues with using this function:

    1) extract_typed_address() does its conversion using
       POINTER_TO_ADDRESS.  For most architectures, this isn't
       an issue, but I'm not convinced that it will work correctly
       for those which define non-trivial pointer-to-address methods. 

    2) dwarf2_read_address is currently extracting an address which
       is TARGET_ADDR_BIT bits wide.  extract_typed_address() must be
       invoked on a pointer (TYPE_CODE_PTR) or reference (TYPE_CODE_REF)
       type.  If it gets anything else, it generates an internal error.
       If the pointer type passed to extract_typed_address() is created
       via make_pointer_type(), the type width will be TARGET_PTR_BIT
       rather than TARGET_ADDR_BIT.  Thus, I'd expect extract_typed_address()
       to work as expected on architectures for which TARGET_ADDR_BIT
       is the same as TARGET_PTR_BIT, but not otherwise - unless some
       sort of special TARGET_ADDR_BIT width pointer were created for
       just this purpose - but that smells like a hack to me.

Given these problems, I don't think that the use of
extract_typed_address() is suitable for this situation.

That leaves the value_as_address() suggestion.  I don't like that
suggestion, but my only objection is that it is inefficient.  (As far
as I can tell, it would work correctly.)  It seems wasteful (in both
time and space) to create a (struct value *) with the express purpose
of immediately decomposing it, never to be used again.

Kevin


      reply	other threads:[~2007-04-24 18:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-21  3:13 Kevin Buettner
2007-04-23 15:06 ` Ulrich Weigand
2007-04-23 16:57   ` Kevin Buettner
2007-04-23 18:19     ` Daniel Jacobowitz
2007-04-23 21:51       ` Kevin Buettner
2007-04-24 21:34         ` Daniel Jacobowitz
2007-04-27 21:30           ` Kevin Buettner
2007-04-27 22:16             ` Daniel Jacobowitz
2007-04-27 22:47               ` Kevin Buettner
2007-04-28  5:38                 ` Daniel Jacobowitz
2007-04-23 22:51       ` Andreas Schwab
2007-04-24 18:13         ` Kevin Buettner [this message]

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=20070424110309.58b32205@ironwood.lan \
    --to=kevinb@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    /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