[gdb/testsuite] Fix main high_pc in nonvar-access.exp
authorTom de Vries <tdevries@suse.de>
Tue, 11 Jun 2019 11:22:27 +0000 (13:22 +0200)
committerTom de Vries <tdevries@suse.de>
Tue, 11 Jun 2019 11:22:27 +0000 (13:22 +0200)
When running gdb.dwarf2/nonvar-access.exp with board readnow, we have:
...
FAIL: gdb.dwarf2/nonvar-access.exp: print/x def_implicit_s
...
and 12 more similar failures.

I've tracked this down to the range of main being hardcoded to
[_main, _main+0x10000) in the dwarf assembly:
...
            DW_TAG_subprogram {
                {name main}
                {DW_AT_external 1 flag}
                {low_pc [gdb_target_symbol main] DW_FORM_addr}
{high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
            } {
...
which overlaps with the .debug_info for the elf-init.c CU (containing
__libc_csu_init and __libc_csu_fini).

Fix this by using function_range to find the actual range of main.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-06-11  Tom de Vries  <tdevries@suse.de>

PR testsuite/24521
* gdb.dwarf2/nonvar-access.exp: Fix main high_pc.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.dwarf2/nonvar-access.exp

index 9c7fb0e06601b8664e2b1f73e6b9881d888f3e29..0eaf7bbedead5a2858404b0fc427b2bdd69fa07e 100644 (file)
@@ -1,3 +1,8 @@
+2019-06-11  Tom de Vries  <tdevries@suse.de>
+
+       PR testsuite/24521
+       * gdb.dwarf2/nonvar-access.exp: Fix main high_pc.
+
 2019-06-11  Tom de Vries  <tdevries@suse.de>
 
        * boards/readnow.exp: New file.
index 594f590810224f8cac973106ccb2d041ba625b81..190ad5d764dc4d38801c1e894dcf2df777868164 100644 (file)
@@ -27,6 +27,12 @@ standard_testfile main.c nonvar-access-dw.S
 set asm_file [standard_output_file $srcfile2]
 
 Dwarf::assemble $asm_file {
+    global srcdir subdir srcfile
+
+    set range [function_range main ${srcdir}/${subdir}/${srcfile}]
+    set main_start [lindex $range 0]
+    set main_length [lindex $range 1]
+
     cu {} {
        compile_unit {
            {DW_AT_name main.c}
@@ -98,7 +104,7 @@ Dwarf::assemble $asm_file {
                {name main}
                {DW_AT_external 1 flag}
                {low_pc [gdb_target_symbol main] DW_FORM_addr}
-               {high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
+               {high_pc "$main_start + $main_length" DW_FORM_addr}
            } {
                # Simple variable without location.
                DW_TAG_variable {
This page took 0.032547 seconds and 4 git commands to generate.