This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] gdb: Handle multiple base address in debug_ranges data.
- From: Andrew Burgess <andrew dot burgess at embecosm dot com>
- To: Doug Evans <xdje42 at gmail dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 26 Oct 2015 10:03:17 +0000
- Subject: Re: [PATCH] gdb: Handle multiple base address in debug_ranges data.
- Authentication-results: sourceware.org; auth=none
- References: <81cb8e0b755217ed2ea2afdffb3a5c44421b72cd dot 1444985270 dot git dot andrew dot burgess at embecosm dot com> <86d1w2cryj dot fsf at sspiff dot org>
* Doug Evans <xdje42@gmail.com> [2015-10-26 01:57:08 +0000]:
> Andrew Burgess <andrew.burgess@embecosm.com> writes:
> > 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.
> >
> > gdb/ChangeLog:
> >
> > * dwarf2read.c (dwarf2_ranges_read): Unify and fix base address
> > reading code.
> >
> > gdb/testsuite/ChangeLog:
> >
> > * gdb.arch/amd64-debug-ranges-base.c: New file.
> > * gdb.arch/amd64-debug-ranges-base.exp: New file.
> > * gdb.arch/amd64-debug-ranges-base.s: New file.
>
> Hi.
>
> The code patch is fine with me, nice find.
>
> IWBN to enhance the dwarf assembler (testsuite/lib/dwarf.exp)
> to handle .debug_ranges. The more we get away from checking in
> generated assembler the better.
> Can do?
> If not, I'll volunteer to take that on, but I can't promise to
> get to it this week. .debug_ranges is pretty simple so I think(!)
> this will be easy.
This was absolutely my first thought too, and I even stated working on
exactly this feature.
I got the .debug_ranges table generation to a reasonable state, but
then I needed more features from the .debug_line table generator, but
I ran out of time....
Anyway, you can find the initial work I did here:
https://github.com/T-J-Teru/binutils-gdb/commits/gdb-dwarf-ranges
that branch doesn't contain the fix, just the initial work on writing
a test to expose the bug. Feel free to take any code out of that
branch if it is useful to you.
> [Though if we go with the generated assembler, take out the 3 in -g3.
> I mention this more for completeness sake though, as I'd really like
> to see if we can do this with the dwarf assembler first.]
I'd rather not push the fix without a test, and I don't think you're
approving the current test, so...
I'll hopefully get more time to work on this next month, if I don't
get approval for the current patch before then I'll return to working
on the dwarf assembler style testing.
Thanks for the review,
Andrew