Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH][gdb/symtab] Relocate call_site_htab
Date: Thu, 30 Sep 2021 12:14:53 -0600	[thread overview]
Message-ID: <874ka20w2q.fsf@tromey.com> (raw)
In-Reply-To: <5940137d-6a6f-2309-673f-d9491ed654b5@polymtl.ca> (Simon Marchi's message of "Thu, 30 Sep 2021 10:26:58 -0400")

>> I've submitted an attempt at fixing this before, trying to handle this at all
>> points where the information is used (
>> https://sourceware.org/pipermail/gdb-patches/2019-August/159631.html ).

Simon> Instead of relocating the data structure, isn't the tendency now (to
Simon> make sharing between objfiles easier) to keep the data structure
Simon> unrelocated, and relocate things when looking things up?

Yeah.  That's what the earlier patch did but I guess I never re-reviewed
it.

Here's the final one

https://sourceware.org/pipermail/gdb-patches/2019-August/159822.html

That patch looks pretty reasonable to me.

-	    {
-	      lowpc = gdbarch_adjust_dwarf2_addr (gdbarch, lowpc + baseaddr);
-	      SET_FIELD_PHYSADDR (call_site->target, lowpc);
-	    }
+	    SET_FIELD_PHYSADDR (call_site->target, lowpc);

Normally I think the DWARF reader applies the offset, calls the gdbarch
method, then subtracts the offset.  It's unclear to me if this is truly
needed, it's maybe done just so I didn't need to audit all the gdbarch
implementations for some earlier patch.

Simon> I could imagine a compunit_symtab method called "find_call_site",
Simon> where you pass a relocated PC.  The method internally unrelocates the PC
Simon> to do the lookup in the htab.  call_site would store an unrelocated pc,
Simon> and a call_site::pc method would return the (computed) relocated pc.
Simon> Simiarly, the call_site's target would keep holding an unrelocated pc,
Simon> and it would be computed on the fly.

Simon> See crude patch implementing this at the bottom of this message.

This seemed pretty reasonable to me as well.

Simon>  - In call_site_to_target_addr, when the target is defined using a DWARF
Simon>    expression (FIELD_LOC_KIND_DWARF_BLOCK), is the result of computing
Simon>    that expression relocated or not?  I would presume that it's not
Simon>    relocated.  Do we need to relocate it at that point?  That looks like
Simon>    a bug to me, it would probably be caught by an appropriate test.

I don't know the answer here.

Simon>  - In read_call_site_scope, we do an htab lookup to look for
Simon>    duplicates.  We do:

Simon>      slot = htab_find_slot (cu->call_site_htab, &call_site_local, INSERT);

Simon>    where call_site_local is a call_site object.  However, the htab works
Simon>    using the address as index, it passes core_addr_hash and core_addr_eq
Simon>    as hash/eq functions.  And in call_site_for_pc, the lookup is done
Simon>    by passing a pointer to a CORE_ADDR.  Therefore, the lookup in
Simon>    read_call_site_scope looks wrong to me.  It just works because
Simon>    call_site::pc happens to be the first field of call_site.

IIUC, this is valid in C at least -- you can cast pointer-to-struct to
pointer-to-first-element.  However, it seems better for the code to be
less tricky.

Tom

  reply	other threads:[~2021-09-30 18:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-30  9:56 Tom de Vries via Gdb-patches
2021-09-30 14:26 ` Simon Marchi via Gdb-patches
2021-09-30 18:14   ` Tom Tromey [this message]
2021-09-30 23:47   ` Tom de Vries via Gdb-patches
2021-10-01  1:15     ` Simon Marchi via Gdb-patches
2021-10-01  8:25       ` Tom de Vries via Gdb-patches
2021-10-01 12:37         ` Tom de Vries via Gdb-patches

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=874ka20w2q.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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