From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Make blockvector a little more self-contained
Date: Wed, 19 Nov 2025 00:17:05 -0500 [thread overview]
Message-ID: <86f2f3e7-15a5-4752-b2d6-4dc6ff7690a0@simark.ca> (raw)
In-Reply-To: <20251119033033.3538090-1-tom@tromey.com>
On 2025-11-18 22:30, Tom Tromey wrote:
> This patch changes blockvector to be a little more self-contained.
>
> The idea here is that code outside of blockvector shouldn't really
> know how it operates. After this patch, this still doesn't fully
> happen -- a couple spots check the result of map() and make decisions
> based on that -- but this is a step toward making that happen. The
> longer term idea here is that this is needed to enable lazier CU
> expansion.
>
> Meanwhile, this patch seems like a simple cleanup. Relocation is now
> handled by the blockvector itself and the non-const map() method can
> be removed.
Overall, LGTM.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
See minor comments below.
>
> There wasn't a great spot to move the section_offsets typedef. I
> chose defs.h. I've also updated the comment there as it has been out
> of date for a long time. I've also removed an obsolete comment from
> the symbol-relocation code.
I honestly think that this typedef could be removed, that it would be
clearer to see "std::vector<CORE_ADDR>" in the code.
> diff --git a/gdb/block.c b/gdb/block.c
> index 9fb04635975..e959adc968c 100644
> --- a/gdb/block.c
> +++ b/gdb/block.c
> @@ -366,6 +366,28 @@ block::static_link () const
> return (struct dynamic_prop *) objfile_lookup_static_link (objfile, this);
> }
>
> +/* See block.h. */
> +
> +void
> +block::relocate (struct objfile *objfile, const section_offsets &offsets)
> +{
> + int block_line_section = SECT_OFF_TEXT (objfile);
> +
> + set_start (start () + offsets[block_line_section]);
> + set_end (end () + offsets[block_line_section]);
> +
> + for (blockrange &r : ranges ())
> + {
> + r.set_start (r.start () + offsets[block_line_section]);
> + r.set_end (r.end () + offsets[block_line_section]);
> + }
> +
> + /* We only want to iterate over the local symbols, not any
> + symbols in included symtabs. */
> + for (struct symbol *sym : multidict_symbols ())
> + sym->relocate (objfile, offsets);
Do you know what the comment above refers to? What are we doing special
to avoid iterating on the symbols in included symtabs?
> diff --git a/gdb/symtab.h b/gdb/symtab.h
> index 845c49e057d..4f2b88859a5 100644
> --- a/gdb/symtab.h
> +++ b/gdb/symtab.h
> @@ -1458,6 +1458,11 @@ struct symbol : public general_symbol_info, public allocate_on_obstack<symbol>
>
> void set_symtab (struct symtab *symtab);
>
> + /* Relocate this symbol. OBJFILE is the objfile holding this
> + blockvector, and OFFSETS is the relocation offsets to use. */
> +
> + void relocate (struct objfile *objfile, const section_offsets &offsets);
The comment says "this blockvector", looks like a copy-pasto.
Also, a struct symbol already knows its objfile (it has an objfile()
method) if it is objfile-owned, which should be the case here. So it
seems superfluous to pass the objfile here. Actually, the objfile
parameter is not even used in symbol::relocate.
Simon
next prev parent reply other threads:[~2025-11-19 5:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 3:30 Tom Tromey
2025-11-19 5:17 ` Simon Marchi [this message]
2025-11-19 17:42 ` 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=86f2f3e7-15a5-4752-b2d6-4dc6ff7690a0@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.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