]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/block: remove block_iterator::d::block, remove union
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 6 Feb 2026 02:52:30 +0000 (21:52 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Fri, 6 Feb 2026 19:01:47 +0000 (14:01 -0500)
The block union field is never used.  The block is only used at
initialization time to grab a reference to the mdict, which is stored in
the mdict_iterator.  There is no need to store the block in the iterator
itself for future use.

Remove it and remove the union.  Leave the compunit_symtab field, whose
name unfortunately conflicts with the method.

Change-Id: I09dbc42f937eaba6c70598acca8ff355c4e5bdb9
Approved-By: Tom Tromey <tom@tromey.com>
Tested-By: Guinevere Larsen <guinevere@redhat.com>
gdb/block.c
gdb/block.h

index 64ca59d44a1da84b1bdf667a1f8c3837a9801133..5aa58545393bb2c649b161ee4d7dcd7bdee27757 100644 (file)
@@ -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];
index d9a8c4b6ff8929344f42770e3eedcf369b4f2ec1..b84ca12c35a6f834949e61694fee1ca65fc7c606 100644 (file)
@@ -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;