]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove a call to blockvector::map
authorTom Tromey <tom@tromey.com>
Wed, 19 Nov 2025 09:42:34 +0000 (02:42 -0700)
committerTom Tromey <tom@tromey.com>
Sun, 23 Nov 2025 18:28:10 +0000 (11:28 -0700)
block_starting_point_at checks blockvector::map before doing a lookup.

This patch removes this call, a step toward making the blockvector API
a bit more opaque.  It arranges to find the necessary blockvector just
once, in gather_inline_frames, and then uses the 'lookup' method to
find the desired block.

Note that this is a slight change of semantics, in that the old code
looked only in the map while the new code looks in the blockvector,
regardless of whether a map was made.  However, I don't think this
should matter, and furthermore this seems like an abstraction
violation, with the inline-frame code knowing details of how buildsym
decided to create the blockvector.

in the longer run, I think only the 'lookup' method should be provided
by blockvector -- that is, separately checking the map should be
impossible.  The idea here is that eventually, for lazy CU expansion,
we will want to be able to expand the blockvector.  This may be easier
with a different underlying data structure, so perhaps the map will go
away entirely.  After this patch, one such use remains.

Regression tested on x86-64 Fedora 40.

Approved-by: Kevin Buettner <kevinb@redhat.com>
gdb/inline-frame.c

index 5ec18e90547fe9471324b4f343058d58ac9c8d35..649acab579311988b91e8e6254a4ade67931085e 100644 (file)
@@ -283,19 +283,13 @@ const struct frame_unwind_legacy inline_frame_unwind (
 
 /* Return true if BLOCK, an inlined function block containing PC,
    has a group of contiguous instructions starting at PC (but not
-   before it).  */
+   before it).  BV is the blockvector holding BLOCK.  */
 
 static bool
-block_starting_point_at (CORE_ADDR pc, const struct block *block)
+block_starting_point_at (const blockvector *bv, CORE_ADDR pc,
+                        const struct block *block)
 {
-  const struct blockvector *bv;
-  const struct block *new_block;
-
-  bv = blockvector_for_pc (pc, NULL);
-  if (bv->map () == nullptr)
-    return false;
-
-  new_block = (const struct block *) bv->map ()->find (pc - 1);
+  const struct block *new_block = bv->lookup (pc - 1);
   if (new_block == NULL)
     return true;
 
@@ -361,8 +355,9 @@ gather_inline_frames (CORE_ADDR this_pc)
   /* Build the list of inline frames starting at THIS_PC.  After the loop,
      CUR_BLOCK is expected to point at the first function symbol (inlined or
      not) "containing" the inline frames starting at THIS_PC.  */
-  const block *cur_block = block_for_pc (this_pc);
-  if (cur_block == nullptr)
+  const block *cur_block;
+  const blockvector *bv = blockvector_for_pc (this_pc, &cur_block);
+  if (bv == nullptr)
     return {};
 
   std::vector<const symbol *> function_symbols;
@@ -375,7 +370,7 @@ gather_inline_frames (CORE_ADDR this_pc)
          /* See comments in inline_frame_this_id about this use
             of BLOCK_ENTRY_PC.  */
          if (cur_block->entry_pc () == this_pc
-             || block_starting_point_at (this_pc, cur_block))
+             || block_starting_point_at (bv, this_pc, cur_block))
            function_symbols.push_back (cur_block->function ());
          else
            break;