From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [committed][gdb/symtab] Make find_block_in_blockvector more robust
Date: Thu, 22 Oct 2020 17:24:32 +0200 [thread overview]
Message-ID: <20201022152431.GA13910@delia> (raw)
Hi,
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.
Committed to trunk.
Thanks,
- Tom
[gdb/symtab] Make find_block_in_blockvector more robust
gdb/ChangeLog:
2020-10-22 Tom de Vries <tdevries@suse.de>
* block.c (find_block_in_blockvector): Make sure the returned block
contains pc.
---
gdb/block.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/gdb/block.c b/gdb/block.c
index 597d6d5d87..070d3f7769 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--;
next reply other threads:[~2020-10-22 15:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-22 15:24 Tom de Vries [this message]
2020-10-22 18:56 ` Tom Tromey
2020-10-22 21:21 ` Tom de Vries
2020-10-22 21:42 ` Simon Marchi
2020-10-23 14:08 ` Tom de Vries
2020-10-23 15:42 ` Simon Marchi
2020-10-23 12:42 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201022152431.GA13910@delia \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox