diff options
author | Tom de Vries <tdevries@suse.de> | 2020-10-22 17:23:25 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2020-10-22 17:23:25 +0200 |
commit | 5fb4027fae1839cabbea75112c31bd89d46d2af0 (patch) | |
tree | 574eaa3daf329dec86822491ef390c4b739233a0 | |
parent | 4a636814934b4403baeffbf29af44ed3a3cb2962 (diff) | |
download | gdb-5fb4027fae1839cabbea75112c31bd89d46d2af0.zip gdb-5fb4027fae1839cabbea75112c31bd89d46d2af0.tar.gz gdb-5fb4027fae1839cabbea75112c31bd89d46d2af0.tar.bz2 |
[gdb/symtab] Make find_block_in_blockvector more robust
While working on PR25858 I noticed that the following trigger patch:
...
@@ -2918,6 +2918,7 @@ find_pc_sect_compunit_symtab
const struct blockvector *bv;
bv = COMPUNIT_BLOCKVECTOR (cust);
+ (volatile int)blockvector_contains_pc (bv, pc);
b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
if (BLOCK_START (b) <= pc
...
triggers this assert, which checks that the returned block indeed
contains pc:
...
@@ -170,7 +170,10 @@ find_block_in_blockvector
{
b = BLOCKVECTOR_BLOCK (bl, bot);
if (BLOCK_END (b) > pc)
- return b;
+ {
+ gdb_assert (BLOCK_START (b) <= pc);
+ return b;
+ }
bot--;
}
...
when running test-case gdb.ada/bp_c_mixed_case.exp.
It's possible that the trigger patch breaks an undocumented invariant: I've
tried a build and test run without the trigger patch and did not manage to
trigger the assert.
For robustness-sake, fix the assert by bailing out if 'BLOCK_START (b) <= pc'
doesn't hold.
Tested on x86_64-linux.
gdb/ChangeLog:
2020-10-22 Tom de Vries <tdevries@suse.de>
* block.c (find_block_in_blockvector): Make sure the returned block
contains pc.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/block.c | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index bda8883..76c5e9e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-10-22 Tom de Vries <tdevries@suse.de> + + * block.c (find_block_in_blockvector): Make sure the returned block + contains pc. + 2020-10-22 Simon Marchi <simon.marchi@polymtl.ca> PR gdb/26693 diff --git a/gdb/block.c b/gdb/block.c index 597d6d5..070d3f7 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -166,6 +166,8 @@ find_block_in_blockvector (const struct blockvector *bl, CORE_ADDR pc) while (bot >= STATIC_BLOCK) { b = BLOCKVECTOR_BLOCK (bl, bot); + if (!(BLOCK_START (b) <= pc)) + return NULL; if (BLOCK_END (b) > pc) return b; bot--; |