[gdb/testsuite] Fix .debug_ranges in gdb.mi/dw2-ref-missing-frame-func.c
authorTom de Vries <tdevries@suse.de>
Wed, 22 Apr 2020 12:38:35 +0000 (14:38 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 22 Apr 2020 12:38:35 +0000 (14:38 +0200)
commit54ac3df1adbf7b4b3470a8df08caa0aea4c89616
tree0fea6d898d24b7e8654f38de6a0b9ec389a50070
parent1d934d768573dc3e54f32d21f13e962718fcd47f
[gdb/testsuite] Fix .debug_ranges in gdb.mi/dw2-ref-missing-frame-func.c

While investigating PR25862 (an assertion failure with target board
cc-with-debug-names), I noticed that the .debug_aranges section in
gdb.mi/dw2-ref-missing-frame-func.c contains a hardcoded 0:
...
"      .4byte  0 \n" // .Ldebug_info0 - Offset of Compilation Unit Info
...

So when looking for an address in the range 0x4004a7-0x4004bf, we should find
the CU at 0xc7:
...
  Compilation Unit @ offset 0xc7:
   Length:        0xba (32-bit)
   Version:       2
   Abbrev Offset: 0x64
   Pointer Size:  4
 <0><d2>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <d3>   DW_AT_high_pc     : 0x4004bf
    <d7>   DW_AT_low_pc      : 0x4004a7
    <db>   DW_AT_name        : file1.txt
    <e5>   DW_AT_producer    : GNU C 3.3.3
    <f1>   DW_AT_language    : 1        (ANSI C)
...
but instead the .debug_aranges entry points us to the CU at 0x0:
...
  Length:                   28
  Version:                  2
  Offset into .debug_info:  0x0
  Pointer Size:             4
  Segment Size:             0

    Address    Length
    004004a7 00000018
    00000000 00000000
...

Fix this by using a label to refer to the start of the CU, similar to how
that's done for gdb.dlang/watch-loc.c in the fix for PR24522:
...
"      .4byte  .Lcu1_begin\n" // .Ldebug_info0 - Offset of Compilation Unit Info
...

The label marks the start of the empty .debug_info section for
dw2-ref-missing-frame-func.c, which is supposed to merge with the .debug_info
section in dw2-ref-missing-frame.S, so in order for that to work, we need to
make sure dw2-ref-missing-frame-func.o comes before dw2-ref-missing-frame.o in
the link line.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-04-22  Tom de Vries  <tdevries@suse.de>

* gdb.mi/dw2-ref-missing-frame-func.c (.debug_aranges): Fix
debug_info_offset.
* gdb.mi/dw2-ref-missing-frame.exp: Make sure $objfuncfile comes
before $objsfile in the line line.
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.mi/dw2-ref-missing-frame-func.c
gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp
This page took 0.027512 seconds and 4 git commands to generate.