Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Vrany <jan.vrany@labware.com>
To: gdb-patches@sourceware.org
Cc: Jan Vrany <jan.vrany@labware.com>
Subject: [PATCH 6/7] gdb: remove address map from struct blockvector
Date: Thu, 19 Feb 2026 18:56:37 +0000	[thread overview]
Message-ID: <20260219185638.360694-7-jan.vrany@labware.com> (raw)
In-Reply-To: <20260219185638.360694-1-jan.vrany@labware.com>

This commit removes m_map member and its accessors from struct blockvector
since it is no longer used. It also updates unit test accordingly.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33829
---
 gdb/block-selftests.c | 90 ++++++++++++-------------------------------
 gdb/block.c           | 10 -----
 gdb/block.h           | 13 -------
 3 files changed, 24 insertions(+), 89 deletions(-)

diff --git a/gdb/block-selftests.c b/gdb/block-selftests.c
index d23783d6bdc..77b8d67ded8 100644
--- a/gdb/block-selftests.c
+++ b/gdb/block-selftests.c
@@ -40,35 +40,19 @@ make_block (struct blockvector &bv, struct obstack &ob, CORE_ADDR start,
   return b;
 }
 
-/* A helper to create and set address map given a blockvector.  */
 static void
-make_map (struct blockvector &bv, struct obstack &ob)
+test_blockvector_lookup_contains ()
 {
-  struct addrmap_mutable map;
-
-  for (int i = bv.num_blocks () - 1; i > STATIC_BLOCK; i--)
-    {
-      auto b = bv.block (i);
-      map.set_empty (b->start (), b->end () - 1, b);
-    }
-
-  bv.set_map (new (&ob) addrmap_fixed (&ob, &map));
-}
-
-/* Create and return blockvector with following blocks:
+  /* Create blockvector with following blocks:
 
 	B0    0x1000 - 0x4000   (global block)
 	B1    0x1000 - 0x4000   (static block)
-	 B2   0x1000 - 0x2000
+	  B2  0x1000 - 0x2000
 				(hole)
-	 B3   0x3000 - 0x4000
-
-  If USE_MAP is true, then also set blockvector's address map.
-*/
-static blockvector_up
-make_blockvector (struct obstack &ob, bool use_map)
-{
-  auto bv = std::make_unique<struct blockvector> (0);
+	  B3  0x3000 - 0x4000
+  */
+  auto_obstack ob;
+  blockvector_up bv = std::make_unique<struct blockvector> (0);
 
   auto global_block = make_block (*bv.get (), ob, 0x1000, 0x4000);
   auto static_block = make_block (*bv.get (), ob, 0x1000, 0x4000,
@@ -76,51 +60,25 @@ make_blockvector (struct obstack &ob, bool use_map)
   make_block (*bv.get (), ob, 0x1000, 0x2000, static_block);
   make_block (*bv.get (), ob, 0x3000, 0x4000, static_block);
 
-  if (use_map)
-    make_map (*bv.get (), ob);
+  /* Test address outside global block's range.  */
+  SELF_CHECK (bv->lookup (0x0500) == nullptr);
+  SELF_CHECK (bv->contains (0x0500) == false);
 
-  return bv;
-}
+  /* Test address falling into a block.  */
+  SELF_CHECK (bv->lookup (0x1500) == bv->block (2));
+  SELF_CHECK (bv->contains (0x1500) == true);
 
-static void
-test_blockvector_lookup_contains ()
-{
-  for (bool with_map : { false, true })
-    {
-      /* Test blockvector without an address map.  */
-      auto_obstack ob;
-      blockvector_up bv = make_blockvector (ob, with_map);
-
-      /* Test address outside global block's range.  */
-      SELF_CHECK (bv->lookup (0x0500) == nullptr);
-      SELF_CHECK (bv->contains (0x0500) == false);
-
-      /* Test address falling into a block.  */
-      SELF_CHECK (bv->lookup (0x1500) == bv->block (2));
-      SELF_CHECK (bv->contains (0x1500) == true);
-
-      /* Test address falling into a "hole".  If BV has an address map,
-	 lookup () returns nullptr and contains (). returns false.  If not,
-	 lookup () return static block and contains() returns true.  */
-      if (with_map)
-	{
-	  SELF_CHECK (bv->lookup (0x2500) == nullptr);
-	  SELF_CHECK (bv->contains (0x2500) == false);
-	}
-      else
-	{
-	  SELF_CHECK (bv->lookup (0x2500) == bv->block (STATIC_BLOCK));
-	  SELF_CHECK (bv->contains (0x2500) == true);
-	}
-
-      /* Test address falling into a block above the "hole".  */
-      SELF_CHECK (bv->lookup (0x3500) == bv->block (3));
-      SELF_CHECK (bv->contains (0x3500) == true);
-
-      /* Test address outside global block's range.  */
-      SELF_CHECK (bv->lookup (0x4000) == nullptr);
-      SELF_CHECK (bv->contains (0x4000) == false);
-    }
+  /* Test address falling into a "hole".  */
+  SELF_CHECK (bv->lookup (0x2500) == bv->block (STATIC_BLOCK));
+  SELF_CHECK (bv->contains (0x2500) == true);
+
+  /* Test address falling into a block above the "hole".  */
+  SELF_CHECK (bv->lookup (0x3500) == bv->block (3));
+  SELF_CHECK (bv->contains (0x3500) == true);
+
+  /* Test address outside global block's range.  */
+  SELF_CHECK (bv->lookup (0x4000) == nullptr);
+  SELF_CHECK (bv->contains (0x4000) == false);
 }
 
 } /* namespace selftests */
diff --git a/gdb/block.c b/gdb/block.c
index b964674865b..cd0f60ef3cb 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -842,11 +842,6 @@ blockvector::lookup (CORE_ADDR addr) const
   if (addr < start || end <= addr)
     return nullptr;
 
-  /* If we have an addrmap mapping code addresses to blocks, then use
-     that.  */
-  if (map () != nullptr)
-    return (const struct block *) map ()->find (addr);
-
   /* Otherwise, use binary search to find the last block that starts
      before PC.
      Note: GLOBAL_BLOCK is block 0, STATIC_BLOCK is block 1.
@@ -925,11 +920,6 @@ void
 blockvector::relocate (struct objfile *objfile,
 		       gdb::array_view<const CORE_ADDR> offsets)
 {
-  int block_line_section = SECT_OFF_TEXT (objfile);
-
-  if (m_map != nullptr)
-    m_map->relocate (offsets[block_line_section]);
-
   for (struct block *b : m_blocks)
     b->relocate (objfile, offsets);
 }
diff --git a/gdb/block.h b/gdb/block.h
index f65546792ca..9134cd43d0f 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -492,14 +492,6 @@ struct blockvector
   const struct block *static_block () const
   { return this->block (STATIC_BLOCK); }
 
-  /* Const version of the above.  */
-  const addrmap_fixed *map () const
-  { return m_map; }
-
-  /* Set this blockvector's address -> block map.  */
-  void set_map (addrmap_fixed *map)
-  { m_map = map; }
-
   /* Block comparison function.  Returns true if B1 must be ordered before
      B2 in a blockvector, false otherwise.  */
   static bool block_less_than (const struct block *b1, const struct block *b2);
@@ -526,11 +518,6 @@ struct blockvector
 		 gdb::array_view<const CORE_ADDR> offsets);
 
 private:
-  /* An address map mapping addresses to blocks in this blockvector.
-     This pointer is zero if the blocks' start and end addresses are
-     enough.  */
-  addrmap_fixed *m_map = nullptr;
-
   /* The blocks themselves.  */
   std::vector<struct block *> m_blocks;
 };
-- 
2.51.0


  parent reply	other threads:[~2026-02-19 19:02 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-19 18:56 [PATCH 0/7] Remove addrmap from blockvector Jan Vrany
2026-02-19 18:56 ` [PATCH 1/7] gdb: implement readnow_functions::find_pc_sect_compunit_symtab Jan Vrany
2026-02-19 20:01   ` Tom Tromey
2026-02-20 12:36     ` Jan Vraný
2026-02-20 14:25       ` Tom Tromey
2026-02-20 15:57         ` Jan Vraný
2026-02-19 18:56 ` [PATCH 2/7] gdb: update expanded_symbols_functions::find_pc_sect_compunit_symtab Jan Vrany
2026-02-19 20:02   ` Tom Tromey
2026-02-19 18:56 ` [PATCH 3/7] gdb: simplify find_compunit_symtab_for_pc_sect Jan Vrany
2026-02-19 20:02   ` Tom Tromey
2026-02-20 12:40     ` Jan Vraný
2026-02-20 14:25       ` Tom Tromey
2026-02-26 15:00     ` Jan Vraný
2026-02-19 18:56 ` [PATCH 4/7] gdb: do not set blockvector address map Jan Vrany
2026-02-19 20:03   ` Tom Tromey
2026-02-20 12:42     ` Jan Vraný
2026-02-19 18:56 ` [PATCH 5/7] gdb: update blockvector::lookup to handle non-contiguous blocks Jan Vrany
2026-02-19 20:06   ` Tom Tromey
2026-02-19 20:20   ` Tom Tromey
2026-02-20 13:03     ` Jan Vraný
2026-02-20 16:38       ` Tom Tromey
2026-03-03 11:06         ` Jan Vraný
2026-03-09 15:52         ` Jan Vraný
2026-02-19 18:56 ` Jan Vrany [this message]
2026-02-19 18:56 ` [PATCH 7/7] gdb: add unit test for blockvector::lookup of " Jan Vrany
2026-02-19 20:12   ` 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=20260219185638.360694-7-jan.vrany@labware.com \
    --to=jan.vrany@labware.com \
    --cc=gdb-patches@sourceware.org \
    /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