From: Jan Vrany Date: Tue, 4 Nov 2025 11:18:12 +0000 (+0000) Subject: gdb: change blockvector_contains_pc to be a method X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=628d488652baa53d445e11a73f2a9559c96aac70;p=thirdparty%2Fbinutils-gdb.git gdb: change blockvector_contains_pc to be a method This changes blockvector_contains_pc() to be a method contains() of struct blockvector. Approved-By: Simon Marchi --- diff --git a/gdb/block.c b/gdb/block.c index 111d0928ad0..c518f6c4f17 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -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) diff --git a/gdb/block.h b/gdb/block.h index 669e3851712..f12e9d16263 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -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); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 802a4550322..79e51943b4d 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -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)