mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2026-08-27 00:26:02 -04:00
gdb: remove address map from struct blockvector
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
This commit is contained in:
parent
54ee7aee12
commit
fc59e2a17d
3 changed files with 22 additions and 87 deletions
|
|
@ -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 falling into a "hole". */
|
||||
SELF_CHECK (bv->lookup (0x2500) == bv->block (STATIC_BLOCK));
|
||||
SELF_CHECK (bv->contains (0x2500) == true);
|
||||
|
||||
/* 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 above the "hole". */
|
||||
SELF_CHECK (bv->lookup (0x3500) == bv->block (3));
|
||||
SELF_CHECK (bv->contains (0x3500) == true);
|
||||
|
||||
/* 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 outside global block's range. */
|
||||
SELF_CHECK (bv->lookup (0x4000) == nullptr);
|
||||
SELF_CHECK (bv->contains (0x4000) == false);
|
||||
}
|
||||
|
||||
} /* namespace selftests */
|
||||
|
|
|
|||
10
gdb/block.c
10
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);
|
||||
}
|
||||
|
|
|
|||
13
gdb/block.h
13
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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue