]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: change blockvector_contains_pc to be a method
authorJan Vrany <jan.vrany@labware.com>
Tue, 4 Nov 2025 11:18:12 +0000 (11:18 +0000)
committerJan Vrany <jan.vrany@labware.com>
Tue, 4 Nov 2025 11:18:12 +0000 (11:18 +0000)
This changes blockvector_contains_pc() to be a method contains()
of struct blockvector.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/block.c
gdb/block.h
gdb/dwarf2/read.c

index 111d0928ad014580d61eacc45c16880f4510a1d8..c518f6c4f17faf4cd120276a13e96c27f9ceb928 100644 (file)
@@ -151,14 +151,6 @@ blockvector_for_pc_sect (CORE_ADDR pc, struct obj_section *section,
   return bl;
 }
 
-/* Return true if the blockvector BV contains PC, false otherwise.  */
-
-int
-blockvector_contains_pc (const struct blockvector *bv, CORE_ADDR pc)
-{
-  return bv->lookup (pc) != nullptr;
-}
-
 /* Return call_site for specified PC in GDBARCH.  PC must match exactly, it
    must be the next instruction after call (or after tail call jump).  Throw
    NO_ENTRY_VALUE_ERROR otherwise.  This function never returns NULL.  */
@@ -840,6 +832,14 @@ blockvector::lookup (CORE_ADDR addr) const
   return NULL;
 }
 
+/* See block.h.  */
+
+bool
+blockvector::contains (CORE_ADDR addr) const
+{
+  return lookup (addr) != nullptr;
+}
+
 blockvector::~blockvector ()
 {
   for (struct block *bl : m_blocks)
index 669e3851712ad61cec81d6fb8f1c4933a67c4030..f12e9d162638d34c88f93c23da8ae0446ba847c6 100644 (file)
@@ -506,6 +506,9 @@ struct blockvector
      if there is one, NULL otherwise.  */
   const struct block *lookup (CORE_ADDR addr) const;
 
+  /* Return true if the blockvector contains ADDR, false otherwise.  */
+  bool contains (CORE_ADDR addr) const;
+
 private:
   /* An address map mapping addresses to blocks in this blockvector.
      This pointer is zero if the blocks' start and end addresses are
@@ -525,8 +528,6 @@ extern const struct blockvector *
   blockvector_for_pc_sect (CORE_ADDR, struct obj_section *,
                           const struct block **, struct compunit_symtab *);
 
-extern int blockvector_contains_pc (const struct blockvector *bv, CORE_ADDR pc);
-
 extern struct call_site *call_site_for_pc (struct gdbarch *gdbarch,
                                           CORE_ADDR pc);
 
index 802a4550322d6334e6b0e59b3601c8bc3eefbcb1..79e51943b4daa5fc673e0cf74e7735e66189a394 100644 (file)
@@ -2133,8 +2133,7 @@ recursively_find_pc_sect_compunit_symtab (struct compunit_symtab *cust,
 {
   int i;
 
-  if (cust->blockvector () != nullptr
-      && blockvector_contains_pc (cust->blockvector (), pc))
+  if (cust->blockvector () != nullptr && cust->blockvector ()->contains (pc))
     return cust;
 
   if (cust->includes == NULL)