gdb: Handle multiple base address in debug_ranges data.
authorAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 16 Oct 2015 08:08:19 +0000 (10:08 +0200)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Thu, 10 Dec 2015 09:53:46 +0000 (09:53 +0000)
commit28d2bfb9c3e519a3b7619bbe5d061ebe520750ef
tree6d5d3817360c2c2ae738248ea453e7b1d8b68031
parentc74088593761f7e839aa9a97728df146f3dfb3d6
gdb: Handle multiple base address in debug_ranges data.

It is possible to use multiple base addresses within a single address
range series, within the .debug_ranges section.  The following is a
simplified example for 32-bit addresses:

  .section ".debug_ranges"
  .4byte 0xffffffff
  .4byte BASE_1
  .4byte START_OFFSET_1
  .4byte END_OFFSET_1
  .4byte START_OFFSET_2
  .4byte END_OFFSET_2
  .4byte 0xffffffff
  .4byte BASE_2
  .4byte START_OFFSET_3
  .4byte END_OFFSET_3
  .4byte 0
  .4byte 0

In this example START/END 1 and 2 are relative to BASE_1, while
START/END 3 are relative to BASE_2.

Currently gdb does not correctly parse this DWARF, resulting in
corrupted address range information.  This commit fixes this issue, and
adds a new test to cover this case.

In order to support testing of this feature extensions were made to the
testsuite dwarf assembler, additional functionality was added to the
.debug_line generation function, and a new function for generating the
.debug_ranges section was added.

gdb/ChangeLog:

* dwarf2read.c (dwarf2_ranges_read): Unify and fix base address
reading code.

gdb/testsuite/ChangeLog:

* gdb.dwarf2/dw2-ranges-base.c: New file.
* gdb.dwarf2/dw2-ranges-base.exp: New file.
* lib/dwarf.exp (namespace eval Dwarf): Add new variables to
support additional line table, and debug ranges generation.
(Dwarf::ranges): New function, generate .debug_ranges.
(Dwarf::lines): Support generating simple line table programs.
(Dwarf::assemble): Initialise new namespace variables.
gdb/ChangeLog
gdb/dwarf2read.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.dwarf2/dw2-ranges-base.c [new file with mode: 0644]
gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp [new file with mode: 0644]
gdb/testsuite/lib/dwarf.exp