From: Andrew Burgess <aburgess@redhat.com>
To: simon.marchi@polymtl.ca, gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: Re: [PATCH 1/2] gdb/block: remove block_iterator::d::block, remove union
Date: Fri, 06 Feb 2026 16:35:55 +0000 [thread overview]
Message-ID: <87qzqxde38.fsf@redhat.com> (raw)
In-Reply-To: <20260206025238.3467043-1-simon.marchi@polymtl.ca>
simon.marchi@polymtl.ca writes:
> From: Simon Marchi <simon.marchi@efficios.com>
>
> The block field is never used. The block is only used to grab a
> reference to the mdict, which is stored in the mdict_iterator.
Isn't there a contradiction between these two sentences? Either the
block is not used, or it's used to access the mdict?
Thanks,
Andrew
>
> Remove it and remove the union. Leave the compunit_symtab field, whose
> name unfortunately conflicts with the method.
>
> Change-Id: I09dbc42f937eaba6c70598acca8ff355c4e5bdb9
> ---
> gdb/block.c | 9 +++------
> gdb/block.h | 13 ++++++-------
> 2 files changed, 9 insertions(+), 13 deletions(-)
>
> diff --git a/gdb/block.c b/gdb/block.c
> index 64ca59d44a1d..5aa58545393b 100644
> --- a/gdb/block.c
> +++ b/gdb/block.c
> @@ -407,8 +407,6 @@ initialize_block_iterator (const struct block *block,
> which = STATIC_BLOCK;
> else
> {
> - iter->d.block = block;
> -
> /* A signal value meaning that we're iterating over a single
> block. */
> iter->which = FIRST_LOCAL_BLOCK;
> @@ -428,14 +426,13 @@ initialize_block_iterator (const struct block *block,
> directly. */
> if (cu->includes.empty ())
> {
> - iter->d.block = block;
> /* A signal value meaning that we're iterating over a single
> block. */
> iter->which = FIRST_LOCAL_BLOCK;
> }
> else
> {
> - iter->d.compunit_symtab = cu;
> + iter->compunit_symtab_ = cu;
> iter->which = which;
> }
> }
> @@ -446,9 +443,9 @@ compunit_symtab *
> block_iterator::compunit_symtab () const
> {
> if (this->idx == -1)
> - return this->d.compunit_symtab;
> + return this->compunit_symtab_;
>
> - auto &includes = this->d.compunit_symtab->includes;
> + auto &includes = this->compunit_symtab_->includes;
>
> if (this->idx < includes.size ())
> return includes[this->idx];
> diff --git a/gdb/block.h b/gdb/block.h
> index d9a8c4b6ff89..b84ca12c35a6 100644
> --- a/gdb/block.h
> +++ b/gdb/block.h
> @@ -557,14 +557,13 @@ struct block_iterator
> iterates. Return nullptr if the iteration is finished. */
> struct compunit_symtab *compunit_symtab () const;
>
> - /* If we're iterating over a single block, this holds the block.
> - Otherwise, it holds the canonical compunit. */
> + /* If iterating on a global or static blocks, iteration starts from the
> + top-level CU and then continues with the global or static blocks of all
> + the included CUs. This field holds the compunit of the current block.
>
> - union
> - {
> - struct compunit_symtab *compunit_symtab;
> - const struct block *block;
> - } d;
> + This field is not private because block_iterator must remain trivial,
> + but treat it as private. */
> + struct compunit_symtab *compunit_symtab_;
>
> /* If we're trying to match a name, this will be non-NULL. */
> const lookup_name_info *name;
>
> base-commit: 1d688bb5f48a0feddf3ca3c60af2e91f4147dc36
> --
> 2.52.0
next prev parent reply other threads:[~2026-02-06 16:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-06 2:52 simon.marchi
2026-02-06 2:52 ` [PATCH 2/2] gdb/block: add assert in block_iterator::compunit_symtab simon.marchi
2026-02-06 16:13 ` Guinevere Larsen
2026-02-06 16:36 ` Andrew Burgess
2026-02-06 16:43 ` Tom Tromey
2026-02-06 19:01 ` Simon Marchi
2026-02-06 16:08 ` [PATCH 1/2] gdb/block: remove block_iterator::d::block, remove union Guinevere Larsen
2026-02-06 18:56 ` Simon Marchi
2026-02-06 16:35 ` Andrew Burgess [this message]
2026-02-06 16:45 ` Tom Tromey
2026-02-06 18:57 ` Simon Marchi
2026-02-06 16:42 ` Tom Tromey
2026-02-06 19:01 ` Simon Marchi
2026-02-06 20:23 ` Simon Marchi
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=87qzqxde38.fsf@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
--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