Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: brobecker@adacore.com (Joel Brobecker)
Cc: gdb-patches@sourceware.org, jan.kratochvil@redhat.com (Jan Kratochvil)
Subject: Re: [RFA] fetch result of locdesc expressions as integer (not address)
Date: Wed, 05 Oct 2011 12:30:00 -0000	[thread overview]
Message-ID: <201110051230.p95CTxEC025115@d06av02.portsmouth.uk.ibm.com> (raw)
In-Reply-To: <20111005010843.GN19246@adacore.com> from "Joel Brobecker" at Oct 04, 2011 06:08:43 PM

Joel Brobecker wrote:
> > Well, maybe they should, but right now they don't, and neither does
> > your patch add any such correction.  The point I was trying to make
> > is that therefore, your patch as it is, while fixing one class of
> > bugs on some targets, may simultaneously introduce a different class
> > of bugs on other targets.  I'm not sure this is a good idea ...
> 
> I understand, but I'm just restoring the previous behavior which,
> I believe was changed unintentionally.

Well, there *is* a change compared to the previous behavior (i.e. before
Jan's patch: http://sourceware.org/ml/gdb-patches/2011-07/msg00762.html).

Consider the typical case for DW_AT_location for a global variable:
just a single DW_OP_addr statement.  This used to be handled previously
via a call to read_address.  Note that read_address attempts to perform
target-specific conversions on the address, in particular it will be
sign-extended if required.

The dwarf_expr_eval machinery, on the other hand, does not use read_address
or otherwise attempt to sign-extend DW_OP_addr addresses.  The thought here
is that performing that step at this point is premature, since subsequent
DWARF operations (e.g. to enforce alignment) may destroy the effect of such
extensions.  Instead, the sign-extension is performed at the very end of
expression evaluation, via the architecture's integer_to_address routine,
if required.

So for example on mips, before Jan's patch, the address of a global variable
would have been sign-extended (in read_address); after Jan's patch, it would
*still* have been sign-extended (via integer_to_address); but after your
patch, it will no longer be.

> It's working fine for instance
> on AVR, where the distinction makes a difference, so we're not doing
> so bad.  Additionally, I tested this patch against the testsuite
> which does include a test for the problem that Jan wanted to fix.

Hmm, looking into this a bit more, I think I understand why this change
doesn't affect testing.  The only caller of decode_locdesc that actually
expects to handle full location descriptions returning an address is
add_partial_symbol when handling a DW_TAG_variable.  However, the address
of a *partial* symbol for a *variable* (as opposed to a function) doesn't
appear to be used for anything; and in fact there is even a comment to
that effect ...

Given that, I withdraw my objection to the patch.  It would still be
preferable IMO to no longer call decode_locdesc from add_partial_symbol
(but instead just handle those cases that this routine cares about,
along the lines of what var_decode_location does).  But that can then
be a follow-on patch.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


  reply	other threads:[~2011-10-05 12:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-03 21:10 Joel Brobecker
2011-10-04 17:16 ` Tom Tromey
2011-10-04 19:32 ` Ulrich Weigand
2011-10-04 19:38   ` Joel Brobecker
2011-10-04 23:06     ` Ulrich Weigand
2011-10-05  1:09       ` Joel Brobecker
2011-10-05 12:30         ` Ulrich Weigand [this message]
2011-10-09 16:35 ` [patch#2] " Jan Kratochvil
2011-10-17  1:56   ` Joel Brobecker
2011-10-17  7:59     ` Tristan Gingold
2011-10-17 13:22       ` [commit] " Jan Kratochvil

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=201110051230.p95CTxEC025115@d06av02.portsmouth.uk.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@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