[gdb/symtab] Handle DW_AT_ranges with DW_FORM_sec_off in partial DIE
authorTom de Vries <tdevries@suse.de>
Mon, 25 Jan 2021 15:32:31 +0000 (16:32 +0100)
committerTom de Vries <tdevries@suse.de>
Mon, 25 Jan 2021 15:32:31 +0000 (16:32 +0100)
While looking into a failure in gdb.go/package.exp with gcc-11, I noticed that
gdb shows some complaints when loading the executable (also with gcc-10, where
the test-case passes):
...
$ gdb -batch -iex "set complaints 100" package.10 -ex start
During symbol reading: Attribute value is not a constant (DW_FORM_sec_offset)
Temporary breakpoint 1 at 0x402ae6: file gdb.go/package1.go, line 8.
During symbol reading: Attribute value is not a constant (DW_FORM_sec_offset)
During symbol reading: Invalid .debug_rnglists data (no base address)
...

Fix this by using as_unsigned () to read DW_AT_ranges in the partial DIE
reader, similar to how that is done in dwarf2_get_pc_bounds.

Tested on x86_64-linux.

gdb/ChangeLog:

2021-01-25  Bernd Edlinger  <bernd.edlinger@hotmail.de>
    Simon Marchi  <simon.marchi@polymtl.ca>
    Tom de Vries  <tdevries@suse.de>

* dwarf2/read.c (partial_die_info::read): Use as_unsigned () for
DW_AT_ranges.

gdb/testsuite/ChangeLog:

2021-01-25  Tom de Vries  <tdevries@suse.de>

* gdb.dwarf2/dw2-ranges-psym.exp (gdb_load_no_complaints): New proc.
* lib/gdb.exp: Use gdb_load_no_complaints.

gdb/ChangeLog
gdb/dwarf2/read.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp
gdb/testsuite/lib/gdb.exp

index 0c30d7550bd49814b9b069c7b0e9ddec62df25bb..db62ea2832100be0bfd212de51a8920bd98f8af4 100644 (file)
@@ -1,3 +1,10 @@
+2021-01-25  Bernd Edlinger  <bernd.edlinger@hotmail.de>
+           Simon Marchi  <simon.marchi@polymtl.ca>
+           Tom de Vries  <tdevries@suse.de>
+
+       * dwarf2/read.c (partial_die_info::read): Use as_unsigned () for
+       DW_AT_ranges.
+
 2021-01-25  Tom Tromey  <tromey@adacore.com>
 
        * dwarf2/read.c (get_mpz): New function.
index ae95c650f1ea9c8e1335cda2a7bf71311ea4ed45..0a00f89cf6dec93d968b1f3569c4977af05321f9 100644 (file)
@@ -19833,7 +19833,7 @@ partial_die_info::read (const struct die_reader_specs *reader,
            /* It would be nice to reuse dwarf2_get_pc_bounds here,
               but that requires a full DIE, so instead we just
               reimplement it.  */
-           unsigned int ranges_offset = (attr.constant_value (0)
+           unsigned int ranges_offset = (attr.as_unsigned ()
                                          + (need_ranges_base
                                             ? cu->ranges_base
                                             : 0));
index dad00fe5d5278d25cb337e4976e9121a65364df2..aa18b5449a850a3fce4307c4efdd7070a2098cab 100644 (file)
@@ -1,3 +1,8 @@
+2021-01-25  Tom de Vries  <tdevries@suse.de>
+
+       * gdb.dwarf2/dw2-ranges-psym.exp (gdb_load_no_complaints): New proc.
+       * lib/gdb.exp: Use gdb_load_no_complaints.
+
 2021-01-25  Tom Tromey  <tromey@adacore.com>
 
        * gdb.ada/fixed_points.exp: Add regression test.
index 72966aff8204741c20db842b86db7389af2927b2..3ad2d1c567c9a27ef0bec945e5ffe62be5c9681d 100644 (file)
@@ -120,11 +120,14 @@ Dwarf::assemble $asm_file {
     }
 }
 
-if { [prepare_for_testing "failed to prepare" ${testfile} \
+if { [build_executable "failed to prepare" ${testfile} \
          [list $srcfile $srcfile2 $asm_file] {nodebug}] } {
     return -1
 }
 
+clean_restart
+gdb_load_no_complaints $binfile
+
 if ![runto_main] {
     return -1
 }
index 03653ab1a7fce9ee85cae5b38033574c82fa0ebd..2a952c6146f1379d129b8d4b76a82cbdc3c605a8 100644 (file)
@@ -5095,6 +5095,42 @@ proc gdb_load { arg } {
     return 0
 }
 
+#
+# 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
+
+    # Save current setting of complaints.
+    set save ""
+    set show_complaints_re \
+       "Max number of complaints about incorrect symbols is ($decimal)\\."
+    gdb_test_multiple "show complaints" "" {
+       -re -wrap $show_complaints_re {
+           set save $expect_out(1,string)
+       }
+    }
+
+    # Fall back to regular gdb_load if we couldn't get the current setting
+    # of complaints.
+    if { $save == "" } {
+       return gdb_load $arg
+    }
+
+    # Temporarily set complaint to a small non-zero number.
+    gdb_test_no_output "set complaints 5" ""
+
+    gdb_load $arg
+
+    # Verify that there were no complaints.
+    set re "^Reading symbols from \[^\r\n\]*\r\n$gdb_prompt $"
+    gdb_assert {[regexp $re $gdb_file_cmd_msg]} "No complaints"
+
+    # Restore saved setting of complaints.
+    gdb_test_no_output "set complaints $save" ""
+}
+
 # gdb_reload -- load a file into the target.  Called before "running",
 # either the first time or after already starting the program once,
 # for remote targets.  Most files that override gdb_load should now
This page took 0.045999 seconds and 4 git commands to generate.