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 <simon.marchi@efficios.com>
This commit is contained in:
Jan Vrany
2025-11-04 11:18:12 +00:00
parent f29e763e90
commit 628d488652
3 changed files with 12 additions and 12 deletions

View 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)

View 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);

View 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)