diff options
author | Tom de Vries <tdevries@suse.de> | 2020-03-11 00:30:54 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2020-03-11 00:30:54 +0100 |
commit | 1c33af7764d9f4eabc02e0f6f6df99917fbce0a6 (patch) | |
tree | 81a563a7d86015992a5fe7ba72676fee61eccfef | |
parent | 8c95582da858ac981f689a6f599acacb8c5c490f (diff) | |
download | gdb-1c33af7764d9f4eabc02e0f6f6df99917fbce0a6.zip gdb-1c33af7764d9f4eabc02e0f6f6df99917fbce0a6.tar.gz gdb-1c33af7764d9f4eabc02e0f6f6df99917fbce0a6.tar.bz2 |
[gdb] Fix segv in "maint print symbols" for ada exec
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.
gdb/ChangeLog:
2020-03-11 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-11 Tom de Vries <tdevries@suse.de>
* gdb.ada/access_to_packed_array.exp: Test printing of expanded
symtabs.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/dwarf2/loc.c | 6 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/access_to_packed_array.exp | 10 |
4 files changed, 25 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1013e91..5c3d740 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-03-11 Tom de Vries <tdevries@suse.de> + + * dwarf2/loc.c (dwarf2_evaluate_property): Handle NULL frame in + PROP_LOCLIST handling code. + 2020-03-10 Andrew Burgess <andrew.burgess@embecosm.com> * buildsym-legacy.c (record_line): Pass extra parameter to diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index a5074da..5155cff 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/ChangeLog b/gdb/testsuite/ChangeLog index dca2d30..c5aa0e6 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-03-11 Tom de Vries <tdevries@suse.de> + + * gdb.ada/access_to_packed_array.exp: Test printing of expanded + symtabs. + 2020-03-10 Andrew Burgess <andrew.burgess@embecosm.com> Bernd Edlinger <bernd.edlinger@hotmail.de> diff --git a/gdb/testsuite/gdb.ada/access_to_packed_array.exp b/gdb/testsuite/gdb.ada/access_to_packed_array.exp index 61ad230..0e1532b 100644 --- a/gdb/testsuite/gdb.ada/access_to_packed_array.exp +++ b/gdb/testsuite/gdb.ada/access_to_packed_array.exp @@ -23,6 +23,16 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } clean_restart ${testfile} +# Test that printing symbols does not cause segv. +gdb_test_no_output "maint expand-symtabs" +set file [standard_output_file gdb.txt] +gdb_test_no_output "set logging file $file" "set logging file" +gdb_test_no_output "set logging redirect on" +gdb_test "set logging on" +gdb_test_no_output "maint print symbols" +gdb_test "set logging off" +file delete $file + set bp_location [gdb_get_line_number "BREAK" ${testdir}/foo.adb] runto "foo.adb:$bp_location" |