public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Andrew Burgess <aburgess@redhat.com>
Cc: Tom Tromey <tom@tromey.com>,  gdb-patches@sourceware.org
Subject: Re: [PATCH 1/5] Remove call to dwarf2_per_objfile::adjust from ranges readers
Date: Mon, 29 Apr 2024 14:04:50 -0600	[thread overview]
Message-ID: <87y18wdjfh.fsf@tromey.com> (raw)
In-Reply-To: <87cyq8pbnp.fsf@redhat.com> (Andrew Burgess's message of "Mon, 29 Apr 2024 13:59:38 +0100")

>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:

Andrew> So, I don't know the details of the DWARF reader too well, so my
Andrew> attempt to review this patch might be just wasting your time.

Not at all.  Thank you for looking at it.

>> dwarf2_per_objfile::adjust applies gdbarch_adjust_dwarf2_addr to an
>> address, leaving the result unrelocated.  However, this adjustment is
>> only needed for text-section symbols -- it isn't needed for any sort

Andrew> I didn't know if the use of the word 'symbols' here was significant.
Andrew> gdbarch_adjust_dwarf2_addr operates on addresses, and I guess symbol
Andrew> could be a synonym for address in some contexts.  But the addresses here
Andrew> do seem to be .text addresses, so clearly there's some important
Andrew> distinction that I'm not understanding.

The basic idea of this series is to note that gdbarch_adjust_dwarf2_addr
is only really needed when computing the address of a full symbol.  In
other cases, it is just extra work.

Part of this observation is from looking at the sole implementation of
this hook.  This is an abstraction violation, of course, and so maybe
the hook ought to be renamed.  Certainly other arches should not use it
-- in fact, even MIPS shouldn't use it, it's a giant hack, and probably
incorrectly implemented to boot (for example, is it intentional that
minsym lookups here examine all objfiles?  Because they do).

Anyway, the MIPS hook implementation looks to see if a given DWARF
symbol is really a MIPS16 (or MicroMIPS) symbol.

However, this information isn't relevant to the first round of DWARF
scanning.  For one thing, in the scanner, symbols don't have addresses.
So, fixing up the address doesn't matter.  Now, text addresses are
needed a little -- to map an address to a CU.  However, the "un-fixed"
address is perfectly suitable for this as well (and these mappings are
done by ranges anyway).

Andrew> A follow on question.  Looking through gdb/dwarf/ there seem to
Andrew> be several other places where the addrmap_mutable::set_empty is
Andrew> called, and in at least some of those places the addresses are
Andrew> still being adjusted.  E.g.:

Andrew>  dwarf2_ranges_read
Andrew>  cooked_indexer::check_bounds
Andrew>  cooked_indexer::scan_attributes

Andrew> Why do these not need changing?

These are all changed in patch #2.

Andrew> And an additional question.  Are lookups in these maps not done
Andrew> via the two ::find_per_cu functions?  Which are passed, and are
Andrew> documented to expected an un-adjusted (i.e. have
Andrew> text_section_offset removed) address.

Andrew> If we don't add text_section_offset in to begin with doesn't
Andrew> that cause problems?  Or maybe the bit I'm missing is that the
Andrew> two paths you've changed already are adjusted?

Yes, the lookups might be done via find_per_cu.  And yes, this takes an
unrelocated address.

The current code labors under the misapprehension that this gdbarch
transform is meaningful to the index.  IIRC the previous psymtab code
had this same incorrect idea, and so I preserved it in the cooked
indexer without looking too deeply into it.

Whether the addresses are relocated or not is a bit of a red herring.
The 'adjust' method took this into account, by applying the runtime
offset, calling the gdbarch method, and then un-applying the offset.

However, I believe there's just no need to call this arch hook at all in
the indexes -- only for full symbols, where it affects the MIPS ABI.


I hope this helps.  And if not, please let me know and I can try some
more.  I feel like I'm not explaining it very well.

thanks,
Tom

  parent reply	other threads:[~2024-04-29 20:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16 17:05 [PATCH 0/5] Fix race in DWARF reader, 2nd approach Tom Tromey
2024-04-16 17:05 ` [PATCH 1/5] Remove call to dwarf2_per_objfile::adjust from ranges readers Tom Tromey
2024-04-29 12:59   ` Andrew Burgess
2024-04-29 13:16     ` Andrew Burgess
2024-04-29 14:36       ` Andrew Burgess
2024-04-29 20:04     ` Tom Tromey [this message]
2024-05-01 14:56       ` Andrew Burgess
2024-05-04 15:30         ` Tom Tromey
2024-04-16 17:05 ` [PATCH 2/5] Remove more calls to dwarf2_per_objfile::adjust Tom Tromey
2024-04-16 17:05 ` [PATCH 3/5] Remove call to dwarf2_per_objfile::adjust from read_call_site_scope Tom Tromey
2024-04-16 17:05 ` [PATCH 4/5] Remove call to dwarf2_per_objfile::adjust from read_attribute_value Tom Tromey
2024-04-16 17:05 ` [PATCH 5/5] Remove dwarf2_per_objfile::adjust Tom Tromey

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=87y18wdjfh.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).