]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: remove buildsym_compunit::record_block_range
authorAndrew Burgess <aburgess@redhat.com>
Mon, 5 Jan 2026 13:44:59 +0000 (13:44 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Wed, 4 Feb 2026 10:35:46 +0000 (10:35 +0000)
After the last commit I realised that the function
buildsym_compunit::record_block_range is not really needed any more.
This function is basically checking for non-contiguous blocks, and
setting m_pending_addrmap_interesting when a non-contiguous block is
seen.

We can move this check into buildsym_compunit::make_blockvector which
is the only place m_pending_addrmap_interesting is used, we already
loop over all blocks in this function.

This allows us to remove record_block_range and
m_pending_addrmap_interesting from buildsym_compunit.

There is one weird thing in this patch, in dwarf2/read.c, the function
dwarf2_record_single_block_range is now empty, but I've retained this
function.  A later patch in this series adds some code back into this
function, so I don't want to delete it here.

gdb/buildsym.c
gdb/buildsym.h
gdb/dwarf2/read.c

index 5b8f04854bd7268993ce89329d423f30be2a7e0c..aa95889424bd2928fb1b0e14f50a3fda37d91a8e 100644 (file)
@@ -309,23 +309,6 @@ buildsym_compunit::finish_block (struct symbol *symbol,
                                false);
 }
 
-/* Record whether the range START to END_INCLUSIVE fully covers the range
-   of BLOCK.  If not then we will need to use an addrmap for the address
-   to block lookup, record this fact for later.  */
-
-void
-buildsym_compunit::record_block_range (struct block *block,
-                                      CORE_ADDR start,
-                                      CORE_ADDR end_inclusive)
-{
-  /* If this is any different from the range recorded in the block's
-     own BLOCK_START and BLOCK_END, then note that the address map has
-     become interesting.  */
-  if (start != block->start ()
-      || end_inclusive + 1 != block->end ())
-    m_pending_addrmap_interesting = true;
-}
-
 std::unique_ptr<struct blockvector>
 buildsym_compunit::make_blockvector ()
 {
@@ -333,10 +316,17 @@ buildsym_compunit::make_blockvector ()
   std::unique_ptr<struct blockvector> blockvector;
   int i;
 
-  /* Count the length of the list of blocks.  */
+  /* Count the length of the list of blocks.  Also, if any blocks are
+     non-contiguous then we need to make use of the addrmap for mapping
+     addresses to blocks (PENDING_ADDRMAP_INTERESTING is set to true).  If
+     all the blocks are contiguous then we can avoid creating the addrmap,
+     and perform block look up using the blockvector.  */
 
+  bool pending_addrmap_interesting = false;
   for (next = m_pending_blocks, i = 0; next; next = next->next, i++)
     {
+      if (!next->block->is_contiguous ())
+       pending_addrmap_interesting = true;
     }
 
   blockvector = std::make_unique<struct blockvector> (i);
@@ -357,12 +347,12 @@ buildsym_compunit::make_blockvector ()
 
   /* If we needed an address map for this symtab, record it in the
      blockvector.  */
-  if (m_pending_addrmap_interesting)
+  if (pending_addrmap_interesting)
     {
       struct addrmap_mutable pending_addrmap;
       int num_blocks = blockvector->num_blocks ();
 
-      /* If M_PENDING_ADDRMAP_INTERESTING is true then we must have seen
+      /* If PENDING_ADDRMAP_INTERESTING is true then we must have seen
         an interesting block.  If we see one block, then we should at a
         minimum have a global block, and a static block.  */
       gdb_assert (num_blocks > 1);
index cf5eb206dc2085c6896e1438692835ca2b490d42..06d8d3c691ffd576f44926b88b3d1ac41a55cae2 100644 (file)
@@ -170,9 +170,6 @@ struct buildsym_compunit
                              const struct dynamic_prop *static_link,
                              CORE_ADDR start, CORE_ADDR end);
 
-  void record_block_range (struct block *block,
-                          CORE_ADDR start, CORE_ADDR end_inclusive);
-
   /* Start recording information about source code that comes from a source
      file.  This sets the current subfile, creating it if necessary.
 
@@ -339,12 +336,6 @@ private:
 
   struct subfile *m_current_subfile = nullptr;
 
-  /* If there are gaps in the address range of any block associated with
-     this buildsym_compunit, then we need to create an address map, this
-     flag is set true to indicate the addrmap must be created.  If this
-     remains false, then no addrmap will be created.  */
-  bool m_pending_addrmap_interesting = false;
-
   /* An obstack used for allocating pending blocks.  */
   auto_obstack m_pending_block_obstack;
 
index 3f9246fc963357a4fd55eb6be3afe72fbc675b45..a7248c2627e62035c6b12401cee11cb6bffde6e2 100644 (file)
@@ -9253,19 +9253,14 @@ dwarf2_record_block_entry_pc (struct die_info *die, struct block *block,
     }
 }
 
-/* Helper function for dwarf2_record_block_ranges.  This function records
-   the address range for a single BLOCK.  LOW and HIGH are the block's
-   range, these addresses are inclusive, so LOW is the first address in
-   the range, and HIGH is the last address inside the range.  UNREL_HIGH
-   is the unrelocated, exclusive version of HIGH, that is, UNREL_HIGH is
-   the first address outside the range of BLOCK.  */
+/* Nothing for now.  A later patch changes this.  */
 
 static void
 dwarf2_record_single_block_range (struct dwarf2_cu *cu, struct block *block,
                                  CORE_ADDR low, CORE_ADDR high,
                                  unrelocated_addr unrel_high)
 {
-  cu->get_builder ()->record_block_range (block, low, high);
+  /* Nothing for now, a later patch adds code here.  */
 }
 
 /* Record the address ranges for BLOCK, offset by BASEADDR, as given