aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2021-02-09 23:28:16 +0100
committerTom de Vries <tdevries@suse.de>2021-02-09 23:28:16 +0100
commitcf2b20752995e6f10d88afc49166e729c33beb48 (patch)
tree3dbd21eb20fb46fbed3ff475aeb1a323580141a2 /gdb/testsuite/lib
parent03642b7189bc0bfdf61354a6d9a3f3e46d82709c (diff)
downloadgdb-cf2b20752995e6f10d88afc49166e729c33beb48.zip
gdb-cf2b20752995e6f10d88afc49166e729c33beb48.tar.gz
gdb-cf2b20752995e6f10d88afc49166e729c33beb48.tar.bz2
[gdb/symtab] Fix element type modification in read_array_type
When running test-case gdb.fortran/function-calls.exp with target board unix/gdb:debug_flags=-gdwarf-5, I run into: ... (gdb) PASS: gdb.fortran/function-calls.exp: \ p derived_types_and_module_calls::pass_cart(c) p derived_types_and_module_calls::pass_cart_nd(c_nd)^M ^M Program received signal SIGSEGV, Segmentation fault.^M 0x0000000000400f73 in derived_types_and_module_calls::pass_cart_nd \ (c=<error reading variable: Cannot access memory at address 0xc>) at \ function-calls.f90:130^M 130 pass_cart_nd = ubound(c%d,1,4)^M The program being debugged was signaled while in a function called from GDB.^M GDB has restored the context to what it was before the call.^M To change this behavior use "set unwindonsignal off".^M Evaluation of the expression containing the function^M (derived_types_and_module_calls::pass_cart_nd) will be abandoned.^M (gdb) FAIL: gdb.fortran/function-calls.exp: p ... The problem originates in read_array_type, when reading a DW_TAG_array_type with a dwarf-5 DW_TAG_generic_subrange child. This is not supported, and the fallout of this is that rather than constructing a new array type, the code proceeds to modify the element type. Fix this conservatively by issuing a complaint and bailing out in read_array_type when not being able to construct an array type, such that we have: ... (gdb) maint expand-symtabs function-calls.f90^M During symbol reading: unable to find array range \ - DIE at 0xe1e [in module function-calls]^M During symbol reading: unable to find array range \ - DIE at 0xe1e [in module function-calls]^M (gdb) KFAIL: gdb.fortran/function-calls.exp: no complaints in srcfile \ (PRMS: symtab/27388) ... Tested on x86_64-linux. gdb/ChangeLog: 2021-02-09 Tom de Vries <tdevries@suse.de> PR symtab/27341 * dwarf2/read.c (read_array_type): Return NULL when not being able to construct an array type. Add assert to ensure that element_type is not being modified. gdb/testsuite/ChangeLog: 2021-02-09 Tom de Vries <tdevries@suse.de> PR symtab/27341 * lib/gdb.exp (with_complaints): New proc, factored out of ... (gdb_load_no_complaints): ... here. * gdb.fortran/function-calls.exp: Add test-case.
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r--gdb/testsuite/lib/gdb.exp43
1 files changed, 33 insertions, 10 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 53ac9f1..1406b91 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5096,11 +5096,11 @@ proc gdb_load { arg } {
}
#
-# gdb_load_no_complaints -- As gdb_load, but in addition verifies that
-# loading caused no symbol reading complaints.
+# with_complaints -- Execute BODY and set complaints temporary to N for the
+# duration.
#
-proc gdb_load_no_complaints { arg } {
- global gdb_prompt gdb_file_cmd_msg decimal
+proc with_complaints { n body } {
+ global decimal
# Save current setting of complaints.
set save ""
@@ -5112,16 +5112,39 @@ proc gdb_load_no_complaints { arg } {
}
}
- # Fall back to regular gdb_load if we couldn't get the current setting
- # of complaints.
if { $save == "" } {
- return gdb_load $arg
+ perror "Did not manage to set complaints"
+ } else {
+ # Set complaints.
+ gdb_test_no_output "set complaints $n" ""
}
- # Temporarily set complaint to a small non-zero number.
- gdb_test_no_output "set complaints 5" ""
+ set code [catch {uplevel 1 $body} result]
+
+ # Restore saved setting of complaints.
+ if { $save != "" } {
+ gdb_test_no_output "set complaints $save" ""
+ }
+
+ if {$code == 1} {
+ global errorInfo errorCode
+ return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
+ } else {
+ return -code $code $result
+ }
+}
+
+#
+# gdb_load_no_complaints -- As gdb_load, but in addition verifies that
+# loading caused no symbol reading complaints.
+#
+proc gdb_load_no_complaints { arg } {
+ global gdb_prompt gdb_file_cmd_msg decimal
- gdb_load $arg
+ # Temporarily set complaint to a small non-zero number.
+ with_complaints 5 {
+ gdb_load $arg
+ }
# Verify that there were no complaints.
set re "^Reading symbols from \[^\r\n\]*\r\n$gdb_prompt $"