public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
@ 2020-10-29 17:30 zoran.zaric at amd dot com
  2020-10-29 17:33 ` [Bug symtab/26813] " zoran.zaric at amd dot com
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: zoran.zaric at amd dot com @ 2020-10-29 17:30 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

            Bug ID: 26813
           Summary: DW_FORM_rnglistx and DW_FORM_loclistx not fully
                    supported
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: zoran.zaric at amd dot com
  Target Milestone: ---

Created attachment 12929
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12929&action=edit
Test application and gdb patch

Gdb seems to be reporting an internal error when attributes of either
DW_FORM_rnglistx or DW_FORM_loclistx form are found in DWARF.

Both of these forms are part of the newest DWARF 5 standard, which support was
only recently added to the gdb.

Original problem was found on a application written in HIP language and compile
using a Clang based compiler (version 11 or newer). 

Considering that HIP language and runtime is not everybody's cup of tea, I
tried to find a C++ application that can reproduce an issue. 

I was lucky, and it seems that my old application, written to solving some
logical problem from years ago, exposes the same bug.

The bug will only show up if a compiler used is Clang 11 (or newer) and it
doesn't seem to show up under gcc.

To reproduce the issue, one just need to build the application using a simple
make command. After that it needs to be run under the debugger without any
arguments:

  $ tar -xf MagicPurse.tar.xz
  $ make
  $ gdb ./MagicPurse

The reason I've have not tried to reduce the application is because it exposes
multiple levels of bugs, and it seems useful to have the whole thing to make
sure that we don't miss any unknown issues.

I have debugged the reason behind the internal error and found that both of
these forms are not properly processed when read. The attached archive also
contains a small patch (dwarf-5-fix-WIP.patch) that deals with that problem.

After applying the patch, another issue comes up where the DW_FORM_rnglistx
form is not resolved properly. The problem seems to be in read_rnglist_index
function.

These new forms can have multiple headers inside of .debug_rnglist where the
read_rnglist_index function only ever reads the first one. This results in an
error message:

    DW_FORM_rnglistx index pointing outside of .debug_rnglists offset array ...

My patch is based on 006811bc02fe28060a8557b1f17a129440c975d4 commit and it
makes sense to me, but I am not that familiar with the mechanism behind reading
the dwarf sections.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
@ 2020-10-29 17:33 ` zoran.zaric at amd dot com
  2020-10-29 18:08 ` simark at simark dot ca
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: zoran.zaric at amd dot com @ 2020-10-29 17:33 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #1 from Zoran Zaric <zoran.zaric at amd dot com> ---
Created attachment 12930
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12930&action=edit
patch that solves the internal error issue

Sorry, I didn't have the option to attach multiple files when I submitted the
bug, I should have expected that I can add more files in a later stage.

Here is a small patch of mine that fixes some of the found issues.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
  2020-10-29 17:33 ` [Bug symtab/26813] " zoran.zaric at amd dot com
@ 2020-10-29 18:08 ` simark at simark dot ca
  2020-10-30 14:22 ` tromey at sourceware dot org
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: simark at simark dot ca @ 2020-10-29 18:08 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

Simon Marchi <simark at simark dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simark at simark dot ca

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
  2020-10-29 17:33 ` [Bug symtab/26813] " zoran.zaric at amd dot com
  2020-10-29 18:08 ` simark at simark dot ca
@ 2020-10-30 14:22 ` tromey at sourceware dot org
  2020-10-30 15:03 ` zoran.zaric at amd dot com
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: tromey at sourceware dot org @ 2020-10-30 14:22 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
Hi.  gdb patches aren't usually reviewed in bugzilla.
Instead, please see the contribution checklist:
https://sourceware.org/gdb/wiki/ContributionChecklist

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (2 preceding siblings ...)
  2020-10-30 14:22 ` tromey at sourceware dot org
@ 2020-10-30 15:03 ` zoran.zaric at amd dot com
  2020-10-30 18:21 ` simark at simark dot ca
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: zoran.zaric at amd dot com @ 2020-10-30 15:03 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #3 from Zoran Zaric <zoran.zaric at amd dot com> ---
Hi To,

I didn't want to contribute the patch per se, just wanted to try to speed up
the person who decides to take this on, with my quick understanding about what
is wrong.

If I had more time on my hands at the moment, I would contribute a real
solution with a gdb test included.

Unfortunately, that is not the case and my patch is not in a state to actually
be contributed.

If this is against the procedure, I don't mind if the patch is ignored. 

It might not even be a correct solution anyway, considering that I didn't have
enough time to properly understand the bfd processing mechanism.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (3 preceding siblings ...)
  2020-10-30 15:03 ` zoran.zaric at amd dot com
@ 2020-10-30 18:21 ` simark at simark dot ca
  2020-10-30 18:22 ` simark at simark dot ca
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: simark at simark dot ca @ 2020-10-30 18:21 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

Simon Marchi <simark at simark dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-10-30
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #4 from Simon Marchi <simark at simark dot ca> ---
I started to look into it, there seems to be multiple problems indeed.  I'll
upload the MagicPurse executable that I built (with clang-11), so we can all
look at the same thing.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (4 preceding siblings ...)
  2020-10-30 18:21 ` simark at simark dot ca
@ 2020-10-30 18:22 ` simark at simark dot ca
  2020-10-30 19:03 ` simark at simark dot ca
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: simark at simark dot ca @ 2020-10-30 18:22 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #5 from Simon Marchi <simark at simark dot ca> ---
Created attachment 12936
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12936&action=edit
MagicPurse compiled with clang-11

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (5 preceding siblings ...)
  2020-10-30 18:22 ` simark at simark dot ca
@ 2020-10-30 19:03 ` simark at simark dot ca
  2020-10-30 21:19 ` simark at simark dot ca
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: simark at simark dot ca @ 2020-10-30 19:03 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #6 from Simon Marchi <simark at simark dot ca> ---
I'm focusing on rnglists at the moment, but it all probably applies to loclists
too.  I did the same changes as Zoran to make GDB properly handle the rnglistx
form, then hit some more important issues.

First, read_rnglist_index returns a CORE_ADDR: that's wrong, because a
CORE_ADDR is meant to represent an address in the program.  This function
returns an offset in the .debug_rnglists section, the beginning of the range
list.  It should probably be sect_offset.

The .debug_rnglists section in the executable I uploaded looks like this:

[0x00, 0x0B]: header for CU 1
[0x0C, 0x0F]: list of offsets for CU 1 (1 element)
[0x10, 0x78]: range lists data for CU 1

[0x79, 0x84]: header for CU 2
[0x85, 0xB4]: list of offsets for CU 2 (12 elements)
[0xB5, 0xBD7]: range lists data for CU 2

The DW_AT_rnglists_base for CU 2 points to 0x85, that is the beginning of the
list of offsets for that CU.  That's just past the header.

The DW_AT_ranges value for CU 2 has value 0xb (11).  When read_rnglist_index is
called for that index, it reads the header at the beginning of the
.debug_rnglists section.  That's wrong, because the header at the beginning of
the section is the header for CU 1, and we are reading a range list for CU 2. 
If we wanted to read a header, it should be the header at 0x79.  But since the
link from CU 2 to the .debug_rnglists is DW_AT_rnglists_base, and it points
after its header, I don't think we are expected to read the header to do the
index -> range list conversion.  Since the header is not of constant size, we
can't really just read it by going back from the location pointed by
DW_AT_rnglists_base.

We currently use the header to validate that the index is valid, so
unfortunately I think it means we won't be able to do that.  At least, not
unless we do a first pass to slurp the entire .debug_rnglists section to know
where the various contributions are and how many offsets they have.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (6 preceding siblings ...)
  2020-10-30 19:03 ` simark at simark dot ca
@ 2020-10-30 21:19 ` simark at simark dot ca
  2020-11-02 15:57 ` simark at simark dot ca
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: simark at simark dot ca @ 2020-10-30 21:19 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #7 from Simon Marchi <simark at simark dot ca> ---
Correction: the header size is fixed, I misinterpreted the DWARF text.  It has
a constant size for DWARF32 and another constant size for DWARF64.  So it would
be possible to go read the right header.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (7 preceding siblings ...)
  2020-10-30 21:19 ` simark at simark dot ca
@ 2020-11-02 15:57 ` simark at simark dot ca
  2021-01-20  9:26 ` mliska at suse dot cz
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: simark at simark dot ca @ 2020-11-02 15:57 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #8 from Simon Marchi <simark at simark dot ca> ---
I have a patch series for that, I'll clean it up and send it to the list soon.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (8 preceding siblings ...)
  2020-11-02 15:57 ` simark at simark dot ca
@ 2021-01-20  9:26 ` mliska at suse dot cz
  2021-02-02 15:42 ` cvs-commit at gcc dot gnu.org
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: mliska at suse dot cz @ 2021-01-20  9:26 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

Martin Liska <mliska at suse dot cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mliska at suse dot cz

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (9 preceding siblings ...)
  2021-01-20  9:26 ` mliska at suse dot cz
@ 2021-02-02 15:42 ` cvs-commit at gcc dot gnu.org
  2021-02-02 15:43 ` cvs-commit at gcc dot gnu.org
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-02 15:42 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #9 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Simon Marchi <simark@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b1829e1bf2ee1c973694c802afaa3b7da2ffb4de

commit b1829e1bf2ee1c973694c802afaa3b7da2ffb4de
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Tue Feb 2 10:40:51 2021 -0500

    gdb/dwarf: few fixes for handling DW_FORM_{rng,loc}listx

    We hit an assertion when loading the binary from PR 26813.  When fixing
    it, execution goes a up bit further but then hits another assert, and
    another, and another.  With these fours fixes, I am able to load the
    binary and get to the prompt.  An error is shown (index pointing outside
    of the section), because the DW_FORM_rnglistx attribute is not read
    correctly, but that one is taken care of by the next patch.

    The four fixes are:

    - attribute::form_requires_reprocessing needs to handle forms
      DW_FORM_rnglistx and DW_FORM_loclistx, because set_unsigned_reprocess
      is called for them in read_attribute_value.

    - read_attribute_reprocess must call set_unsigned for them, not
      set_address.  The parameter of set_address is a CORE_ADDR, meaning
      it's for program addresses.  Post-reprocess, DW_FORM_rnglistx and
      DW_FORM_loclistx are offsets into their respective sections
      (.debug_rnglists and .debug_loclists).  set_unsigned is the current
      attribute value setter that fits the best.  But perhaps we should have
      a setter that takes a sect_offset?

    - read_attribute_process must call as_unsigned_reprocess instead of
      as_unsigned to get the pre-reprocess value, otherwise we hit the
      assert inside as_unsigned that makes sure the attribute doesn't need
      reprocessing.

    - attribute::set_unsigned needs to clear the requires_reprocessing flag,
      otherwise it stays set when reprocessing DW_FORM_rnglistx and
      DW_FORM_loclistx attributes.

    There's another assert that we hit once the next patch is applied, but
    since it's in the same vein as the changes in this patch, I included it
    in this patch:

    - attribute::form_is_unsigned must handle form DW_FORM_loclistx,
      otherwise we hit the assert when trying to call set_unsigned for an
      attribute of this form.  DW_FORM_rnglistx is already handled.

    gdb/ChangeLog:

            PR gdb/26813
            * dwarf2/attribute.h (struct attribute) <set_unsigned>: Clear
            requires_reprocessing flag.
            * dwarf2/attribute.c (attribute::form_is_unsigned): Handle
            DW_FORM_loclistx.
            (attribute::form_requires_reprocessing): Handle DW_FORM_rnglistx
            and DW_FORM_loclistx.
            * dwarf2/read.c (read_attribute_reprocess): Use set_unsigned
            instead of set_address for DW_FORM_loclistx and
            DW_FORM_rnglistx.

    Change-Id: I06c156fa3913ca98e4e39085f4ef171645b4bc1e

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (10 preceding siblings ...)
  2021-02-02 15:42 ` cvs-commit at gcc dot gnu.org
@ 2021-02-02 15:43 ` cvs-commit at gcc dot gnu.org
  2021-02-02 15:43 ` cvs-commit at gcc dot gnu.org
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-02 15:43 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #10 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Simon Marchi <simark@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a1c4010369aaa3ead33b7a5c248be9693d51b856

commit a1c4010369aaa3ead33b7a5c248be9693d51b856
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Tue Feb 2 10:40:51 2021 -0500

    gdb/dwarf: read correct rnglist/loclist header in read_{rng,loc}list_index

    When loading the binary from PR 26813 in GDB, we get:

        DW_FORM_rnglistx index pointing outside of .debug_rnglists offset array
[in module /home/simark/build/binutils-gdb/gdb/MagicPurse]

    ... and the symbols fail to load.

    In read_rnglist_index and read_loclist_index, we read the header
    (documented in sections 7.28 and 7.29 of DWARF 5) of the CU's
    contribution to the .debug_rnglists / .debug_loclists sections to
    validate that the index we want to read makes sense.  However, we always
    read the header at the beginning of the section, rather than the header
    for the contribution from which we want to read the index.

    To illustrate, here's what the binary from PR 26813 contains.  There are
    two compile units:

    0x0000000c: DW_TAG_compile_unit 1
                  DW_AT_ranges [DW_FORM_rnglistx]: 0x0
                  DW_AT_rnglists_base [DW_FORM_sec_offset]: 0xC

    0x00003ec9: DW_TAG_compile_unit 2
                  DW_AT_ranges [DW_FORM_rnglistx]: 0xB
                  DW_AT_rnglists_base [DW_FORM_sec_offset]: 0x85

    The layout of the .debug_rnglists is the following:

        [0x00, 0x0B]: header for CU 1's contribution
        [0x0C, 0x0F]: list of offsets for CU 1 (1 element)
        [0x10, 0x78]: range lists data for CU 1

        [0x79, 0x84]: header for CU 2's contribution
        [0x85, 0xB4]: list of offsets for CU 2 (12 elements)
        [0xB5, 0xBD7]: range lists data for CU 2

    The DW_AT_rnglists_base attrbute points to the beginning of the list of
    offsets for that CU, relative to the start of the .debug_rnglists
    section.  That's right after the header for that contribution.

    When we try to read the DW_AT_ranges attribute for CU 2,
    read_rnglist_index reads the header for CU 1 instead of the one for CU
    2.  Since there's only one element in CU 1's offset list, it believes
    (wrongfully) that the index 0xB is out of range.

    Fix it by reading the header just before where DW_AT_rnglists_base
    points to.  With this patch, I am able to load GDB built with clang-11
    and -gdwarf-5 in itself, with and without -readnow.

    gdb/ChangeLog:

            PR gdb/26813
            * dwarf2/read.c (read_loclists_rnglists_header): Add
            header_offset parameter and use it.
            (read_loclist_index): Read header of the current contribution,
            not the one at the beginning of the section.
            (read_rnglist_index): Likewise.

    Change-Id: Ie53ff8251af8c1556f0a83a31aa8572044b79e3d

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (11 preceding siblings ...)
  2021-02-02 15:43 ` cvs-commit at gcc dot gnu.org
@ 2021-02-02 15:43 ` cvs-commit at gcc dot gnu.org
  2021-02-02 15:43 ` cvs-commit at gcc dot gnu.org
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-02 15:43 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #11 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Simon Marchi <simark@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=962effa79018f57766d9aee21493f616801778dc

commit 962effa79018f57766d9aee21493f616801778dc
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Tue Feb 2 10:40:52 2021 -0500

    gdb/testsuite: add .debug_rnglists tests

    Add tests for the various issues fixed in the previous patches.

    Add a new "rnglists" procedure to the DWARF assembler, to allow
    generating .debug_rnglists sections.  A trivial change is required to
    support the DWARF 5 CU header layout.

    gdb/testsuite/ChangeLog:

            PR gdb/26813
            * lib/dwarf.exp (_handle_DW_FORM): Handle DW_FORM_rnglistx.
            (cu): Generate header for DWARF 5.
            (rnglists): New proc.
            * gdb.dwarf2/rnglists-multiple-cus.exp: New.
            * gdb.dwarf2/rnglists-sec-offset.exp: New.

    Change-Id: I5b297e59c370c60cf671dec19796a6c3b9a9f632

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (12 preceding siblings ...)
  2021-02-02 15:43 ` cvs-commit at gcc dot gnu.org
@ 2021-02-02 15:43 ` cvs-commit at gcc dot gnu.org
  2021-02-02 15:43 ` simark at simark dot ca
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-02 15:43 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #12 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Simon Marchi <simark@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ecfda20dcc4b658560cd4f0178f6c9cd569d4cad

commit ecfda20dcc4b658560cd4f0178f6c9cd569d4cad
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Tue Feb 2 10:40:52 2021 -0500

    gdb/testsuite: add .debug_loclists tests

    Add tests for the various issues fixed in the previous patches.

    Add a new "loclists" procedure to the DWARF assembler, to allow
    generating .debug_loclists sections.

    gdb/testsuite/ChangeLog:

            PR gdb/26813
            * lib/dwarf.exp (_handle_DW_FORM): Handle DW_FORM_loclistx.
            (loclists): New proc.
            * gdb.dwarf2/loclists-multiple-cus.c: New.
            * gdb.dwarf2/loclists-multiple-cus.exp: New.
            * gdb.dwarf2/loclists-sec-offset.c: New.
            * gdb.dwarf2/loclists-sec-offset.exp: New.

    Change-Id: I209bcb2a9482762ae943e518998d1f7761f76928

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (13 preceding siblings ...)
  2021-02-02 15:43 ` cvs-commit at gcc dot gnu.org
@ 2021-02-02 15:43 ` simark at simark dot ca
  2021-02-03 19:17 ` cvs-commit at gcc dot gnu.org
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: simark at simark dot ca @ 2021-02-02 15:43 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

Simon Marchi <simark at simark dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #13 from Simon Marchi <simark at simark dot ca> ---
This should now be fixed with the patches mentioned above.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (14 preceding siblings ...)
  2021-02-02 15:43 ` simark at simark dot ca
@ 2021-02-03 19:17 ` cvs-commit at gcc dot gnu.org
  2021-02-03 19:17 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-03 19:17 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #14 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-10-branch branch has been updated by Simon Marchi
<simark@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1211342072a78708b43a74dacc0342daffec2574

commit 1211342072a78708b43a74dacc0342daffec2574
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Tue Feb 2 10:40:51 2021 -0500

    gdb/dwarf: read correct rnglist/loclist header in read_{rng,loc}list_index

    When loading the binary from PR 26813 in GDB, we get:

        DW_FORM_rnglistx index pointing outside of .debug_rnglists offset array
[in module /home/simark/build/binutils-gdb/gdb/MagicPurse]

    ... and the symbols fail to load.

    In read_rnglist_index and read_loclist_index, we read the header
    (documented in sections 7.28 and 7.29 of DWARF 5) of the CU's
    contribution to the .debug_rnglists / .debug_loclists sections to
    validate that the index we want to read makes sense.  However, we always
    read the header at the beginning of the section, rather than the header
    for the contribution from which we want to read the index.

    To illustrate, here's what the binary from PR 26813 contains.  There are
    two compile units:

    0x0000000c: DW_TAG_compile_unit 1
                  DW_AT_ranges [DW_FORM_rnglistx]: 0x0
                  DW_AT_rnglists_base [DW_FORM_sec_offset]: 0xC

    0x00003ec9: DW_TAG_compile_unit 2
                  DW_AT_ranges [DW_FORM_rnglistx]: 0xB
                  DW_AT_rnglists_base [DW_FORM_sec_offset]: 0x85

    The layout of the .debug_rnglists is the following:

        [0x00, 0x0B]: header for CU 1's contribution
        [0x0C, 0x0F]: list of offsets for CU 1 (1 element)
        [0x10, 0x78]: range lists data for CU 1

        [0x79, 0x84]: header for CU 2's contribution
        [0x85, 0xB4]: list of offsets for CU 2 (12 elements)
        [0xB5, 0xBD7]: range lists data for CU 2

    The DW_AT_rnglists_base attrbute points to the beginning of the list of
    offsets for that CU, relative to the start of the .debug_rnglists
    section.  That's right after the header for that contribution.

    When we try to read the DW_AT_ranges attribute for CU 2,
    read_rnglist_index reads the header for CU 1 instead of the one for CU
    2.  Since there's only one element in CU 1's offset list, it believes
    (wrongfully) that the index 0xB is out of range.

    Fix it by reading the header just before where DW_AT_rnglists_base
    points to.  With this patch, I am able to load GDB built with clang-11
    and -gdwarf-5 in itself, with and without -readnow.

    gdb/ChangeLog:

            PR gdb/26813
            * dwarf2/read.c (read_loclists_rnglists_header): Add
            header_offset parameter and use it.
            (read_loclist_index): Read header of the current contribution,
            not the one at the beginning of the section.
            (read_rnglist_index): Likewise.

    Change-Id: Ie53ff8251af8c1556f0a83a31aa8572044b79e3d

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (15 preceding siblings ...)
  2021-02-03 19:17 ` cvs-commit at gcc dot gnu.org
@ 2021-02-03 19:17 ` cvs-commit at gcc dot gnu.org
  2021-02-03 19:17 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-03 19:17 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #15 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-10-branch branch has been updated by Simon Marchi
<simark@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=908d9586a68cfbdc0a87895e946716e07ef66904

commit 908d9586a68cfbdc0a87895e946716e07ef66904
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Tue Feb 2 10:40:52 2021 -0500

    gdb/testsuite: add .debug_rnglists tests

    Add tests for the various issues fixed in the previous patches.

    Add a new "rnglists" procedure to the DWARF assembler, to allow
    generating .debug_rnglists sections.  A trivial change is required to
    support the DWARF 5 CU header layout.

    gdb/testsuite/ChangeLog:

            PR gdb/26813
            * lib/dwarf.exp (_handle_DW_FORM): Handle DW_FORM_rnglistx.
            (cu): Generate header for DWARF 5.
            (rnglists): New proc.
            * gdb.dwarf2/rnglists-multiple-cus.exp: New.
            * gdb.dwarf2/rnglists-sec-offset.exp: New.

    Change-Id: I5b297e59c370c60cf671dec19796a6c3b9a9f632

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (16 preceding siblings ...)
  2021-02-03 19:17 ` cvs-commit at gcc dot gnu.org
@ 2021-02-03 19:17 ` cvs-commit at gcc dot gnu.org
  2022-05-15 12:13 ` jeanmichael.celerier at gmail dot com
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-03 19:17 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #16 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-10-branch branch has been updated by Simon Marchi
<simark@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c974ecf55d3f9750fa35b6b7b4644fb2ab19f36f

commit c974ecf55d3f9750fa35b6b7b4644fb2ab19f36f
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Tue Feb 2 10:40:52 2021 -0500

    gdb/testsuite: add .debug_loclists tests

    Add tests for the various issues fixed in the previous patches.

    Add a new "loclists" procedure to the DWARF assembler, to allow
    generating .debug_loclists sections.

    gdb/testsuite/ChangeLog:

            PR gdb/26813
            * lib/dwarf.exp (_handle_DW_FORM): Handle DW_FORM_loclistx.
            (loclists): New proc.
            * gdb.dwarf2/loclists-multiple-cus.c: New.
            * gdb.dwarf2/loclists-multiple-cus.exp: New.
            * gdb.dwarf2/loclists-sec-offset.c: New.
            * gdb.dwarf2/loclists-sec-offset.exp: New.

    Change-Id: I209bcb2a9482762ae943e518998d1f7761f76928

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (17 preceding siblings ...)
  2021-02-03 19:17 ` cvs-commit at gcc dot gnu.org
@ 2022-05-15 12:13 ` jeanmichael.celerier at gmail dot com
  2022-05-15 14:33 ` tromey at sourceware dot org
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: jeanmichael.celerier at gmail dot com @ 2022-05-15 12:13 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

Jean-Michaël Celerier <jeanmichael.celerier at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jeanmichael.celerier@gmail.
                   |                            |com

--- Comment #17 from Jean-Michaël Celerier <jeanmichael.celerier at gmail dot com> ---
Hi, in which version is this fixed ? I am seeing the error with a clang-14 /
libstdc++12 / gdb 12.1 combo.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (18 preceding siblings ...)
  2022-05-15 12:13 ` jeanmichael.celerier at gmail dot com
@ 2022-05-15 14:33 ` tromey at sourceware dot org
  2022-05-15 14:55 ` jeanmichael.celerier at gmail dot com
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: tromey at sourceware dot org @ 2022-05-15 14:33 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #18 from Tom Tromey <tromey at sourceware dot org> ---
>From the notes it looks like gdb 10 has the fixes.
Could you open a new bug with a reproducer?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (19 preceding siblings ...)
  2022-05-15 14:33 ` tromey at sourceware dot org
@ 2022-05-15 14:55 ` jeanmichael.celerier at gmail dot com
  2022-05-15 15:09 ` tromey at sourceware dot org
  2022-05-16  1:12 ` simark at simark dot ca
  22 siblings, 0 replies; 24+ messages in thread
From: jeanmichael.celerier at gmail dot com @ 2022-05-15 14:55 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #19 from Jean-Michaël Celerier <jeanmichael.celerier at gmail dot com> ---
Thanks Tom, do you know if there is a tool I could use to have an idea of where
in the code things go wrong ? e.g. the error I'm getting is:

    DW_FORM_rnglistx index pointing outside of .debug_rnglists offset array 

if I could see at least in which file and ideally which function these
DW_FORM_rnglistx get generated that would be very helpful for making a repro

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (20 preceding siblings ...)
  2022-05-15 14:55 ` jeanmichael.celerier at gmail dot com
@ 2022-05-15 15:09 ` tromey at sourceware dot org
  2022-05-16  1:12 ` simark at simark dot ca
  22 siblings, 0 replies; 24+ messages in thread
From: tromey at sourceware dot org @ 2022-05-15 15:09 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #20 from Tom Tromey <tromey at sourceware dot org> ---
I don't think there's anything pre-canned.
elfutils had a "dwarflint" program, but it languishes on a branch
and I don't know if it checked this case anyway.
You could perhaps modify GDB to print more information about where
the bad data is found.  Then you could track it down by hand
more easily with "readelf" or "objdump".
Otherwise there's just debugging gdb and/or reading debuginfo dumps.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug symtab/26813] DW_FORM_rnglistx and DW_FORM_loclistx not fully supported
  2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
                   ` (21 preceding siblings ...)
  2022-05-15 15:09 ` tromey at sourceware dot org
@ 2022-05-16  1:12 ` simark at simark dot ca
  22 siblings, 0 replies; 24+ messages in thread
From: simark at simark dot ca @ 2022-05-16  1:12 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26813

--- Comment #21 from Simon Marchi <simark at simark dot ca> ---
(In reply to Jean-Michaël Celerier from comment #19)
> Thanks Tom, do you know if there is a tool I could use to have an idea of
> where in the code things go wrong ? e.g. the error I'm getting is:
> 
>     DW_FORM_rnglistx index pointing outside of .debug_rnglists offset array

After this message, there should normally be a "[in module %s]" part telling
you at least in which object file this is.

> if I could see at least in which file and ideally which function these
> DW_FORM_rnglistx get generated that would be very helpful for making a repro

We could include in those messages which CU (DW_AT_compile_unit) GDB was
reading when encountering the problem, and probably the offset of the DIE too. 
Would that help?

It's possible that you encountered some other bug in GDB, or it's possible you
found some compiler bug.  The only way to know is to dig in the DWARF, really. 
As Tom said, can you please file a new bug, with a reproducer?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2022-05-16  1:12 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29 17:30 [Bug symtab/26813] New: DW_FORM_rnglistx and DW_FORM_loclistx not fully supported zoran.zaric at amd dot com
2020-10-29 17:33 ` [Bug symtab/26813] " zoran.zaric at amd dot com
2020-10-29 18:08 ` simark at simark dot ca
2020-10-30 14:22 ` tromey at sourceware dot org
2020-10-30 15:03 ` zoran.zaric at amd dot com
2020-10-30 18:21 ` simark at simark dot ca
2020-10-30 18:22 ` simark at simark dot ca
2020-10-30 19:03 ` simark at simark dot ca
2020-10-30 21:19 ` simark at simark dot ca
2020-11-02 15:57 ` simark at simark dot ca
2021-01-20  9:26 ` mliska at suse dot cz
2021-02-02 15:42 ` cvs-commit at gcc dot gnu.org
2021-02-02 15:43 ` cvs-commit at gcc dot gnu.org
2021-02-02 15:43 ` cvs-commit at gcc dot gnu.org
2021-02-02 15:43 ` cvs-commit at gcc dot gnu.org
2021-02-02 15:43 ` simark at simark dot ca
2021-02-03 19:17 ` cvs-commit at gcc dot gnu.org
2021-02-03 19:17 ` cvs-commit at gcc dot gnu.org
2021-02-03 19:17 ` cvs-commit at gcc dot gnu.org
2022-05-15 12:13 ` jeanmichael.celerier at gmail dot com
2022-05-15 14:33 ` tromey at sourceware dot org
2022-05-15 14:55 ` jeanmichael.celerier at gmail dot com
2022-05-15 15:09 ` tromey at sourceware dot org
2022-05-16  1:12 ` simark at simark dot ca

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).