From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH][gdb] Fix segv in "maint print symbols" for ada exec
Date: Tue, 10 Mar 2020 15:08:26 +0100 [thread overview]
Message-ID: <20200310140825.GA20400@delia> (raw)
Hi,
When using the executable from test-case gdb.ada/access_to_packed_array.exp
(read-in using -readnow) and printing the symbols using "maint print symbols",
we run into a segv:
...
$ gdb -readnow -batch access_to_packed_array/foo -ex "maint print symbols"
...
info: array (<>) of character; computed at runtime
ptr: range 0 .. 2147483647; computed at runtime
Aborted (core dumped)
...
What happens is that dwarf2_evaluate_property gets called and sets the local
frame variable to the current frame, which happens to be NULL. Subsequently
the PROP_LOCLIST handling code is executed, where get_frame_address_in_block
gets called with argument NULL, and the segv is triggered.
Fix this by handling a NULL frame in the PROP_LOCLIST handling code in
dwarf2_evaluate_property.
Build and reg-tested on x86_64-linux.
OK for trunk?
Thanks,
- Tom
[gdb] Fix segv in "maint print symbols" for ada exec
gdb/ChangeLog:
2020-03-10 Tom de Vries <tdevries@suse.de>
* dwarf2/loc.c (dwarf2_evaluate_property): Handle NULL frame in
PROP_LOCLIST handling code.
gdb/testsuite/ChangeLog:
2020-03-10 Tom de Vries <tdevries@suse.de>
* gdb.ada/access_to_packed_array.exp: Test printing of expanded
symtabs.
---
gdb/dwarf2/loc.c | 6 +++++-
gdb/testsuite/gdb.ada/access_to_packed_array.exp | 6 ++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index a5074da8bf..5155cff60d 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -2511,11 +2511,15 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
{
struct dwarf2_property_baton *baton
= (struct dwarf2_property_baton *) prop->data.baton;
- CORE_ADDR pc = get_frame_address_in_block (frame);
+ CORE_ADDR pc;
const gdb_byte *data;
struct value *val;
size_t size;
+ if (frame == NULL
+ || !get_frame_address_in_block_if_available (frame, &pc))
+ return false;
+
data = dwarf2_find_location_expression (&baton->loclist, &size, pc);
if (data != NULL)
{
diff --git a/gdb/testsuite/gdb.ada/access_to_packed_array.exp b/gdb/testsuite/gdb.ada/access_to_packed_array.exp
index 61ad230ec0..a2a80a1659 100644
--- a/gdb/testsuite/gdb.ada/access_to_packed_array.exp
+++ b/gdb/testsuite/gdb.ada/access_to_packed_array.exp
@@ -22,6 +22,12 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" }
}
clean_restart ${testfile}
+gdb_test_no_output "maint expand-symtabs"
+gdb_test "set logging redirect on"
+gdb_test "set logging on"
+gdb_test "maint print symbols"
+gdb_test "set logging off"
+file delete gdb.txt
set bp_location [gdb_get_line_number "BREAK" ${testdir}/foo.adb]
runto "foo.adb:$bp_location"
next reply other threads:[~2020-03-10 14:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-10 14:08 Tom de Vries [this message]
2020-03-10 16:40 ` 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=20200310140825.GA20400@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