public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Zoran Zaric <Zoran.Zaric@amd.com>, gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: Re: [PATCH 07/13] gdb/dwarf: read DW_AT_ranges value as unsigned in partial_die_info::read
Date: Thu, 28 Jan 2021 10:51:53 -0500	[thread overview]
Message-ID: <acb82f89-a3be-df83-b460-9d8fe53de126@polymtl.ca> (raw)
In-Reply-To: <2d20d449-857b-0b1d-aebc-96ff07828342@amd.com>



On 2021-01-28 10:41 a.m., Zoran Zaric wrote:
>> From: Simon Marchi <simon.marchi@efficios.com>
>>
>> While writing a test for this series, I made a function
>> (DW_AT_subprogram) with a DW_AT_ranges attribute using the
>> DW_FORM_rnglistx form:
>>
>> 0x00000012:   DW_TAG_subprogram
>>                  DW_AT_name [DW_FORM_string]     ("foo")
>>                  DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000036
>>                     [0x0000000000004000, 0x0000000000005000))
>>
>> And strangely I couldn't print it:
>>
>>      (gdb) p foo
>>      No symbol "foo" in current context.
>>
>> This is because of the `attr.constant_value (0)` in the DW_AT_ranges
>> handling of partial_die_info::read.  Since DW_FORM_rnglistx is not
>> recognized as a constant value by attribute::constant_value, the default
>> value (0) is returned.  Down the line, this causes
>> dwarf2_rnglists_process to try read a range list at offset 0 in the
>> .debug_rnglists section, which is obviously wrong.  In the end, no
>> symbol is created for foo because we didn't find an address range.
>>
>> Use attr->as_unsigned instead.  This is what is done for the equivalent
>> code in dwarf2_get_pc_bounds.  With this, GDB processes the subprogram
>> DIE and we are able to print the function symbol:
>>
>>      (gdb) p foo
>>      $1 = {void (void)} 0x4000
>>
>> Note that I didn't see an actual compiler use DW_FORM_rnglistx for a
>> subprogram's range.  However, in the binary attached to PR 26813, there
>> are some lexical blocks with it:
>>
>> 0x0000d34a:       DW_TAG_lexical_block
>>                      DW_AT_ranges [DW_FORM_rnglistx]     (indexed (0x2) rangelist = 0x000000d4
>>                         [0x0000000000005db1, 0x0000000000005e36)
>>                         [0x0000000000005e48, 0x0000000000005f3c)
>>                         [0x0000000000006045, 0x0000000000006053))
>>
>> Their ranges are read incorrectly just like the ranges of the
>> subprograms.  With this patch applied, they are read correctly.
>>
> 
> Good find.
> 
> Zoran

Note that an identical change was already merged:

  https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=9f6c202e573b796a9e7328cc5fdab7c0c63776bf

So this patch will probably disappear when I rebase.

Simon

  reply	other threads:[~2021-01-28 15:52 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-20  5:39 [PATCH 00/13] DWARF 5 rnglists & loclists fixes (PR 26813) Simon Marchi
2021-01-20  5:39 ` [PATCH 01/13] gdb/dwarf: change read_loclist_index complaints into errors Simon Marchi
2021-01-28 15:17   ` Zoran Zaric
2021-01-28 15:42     ` Simon Marchi
2021-02-25 19:20       ` Tom Tromey
2021-01-20  5:39 ` [PATCH 02/13] gdb/dwarf: fix bound check in read_rnglist_index Simon Marchi
2021-01-28 15:22   ` Zoran Zaric
2021-01-20  5:39 ` [PATCH 03/13] gdb/dwarf: add missing bound check to read_loclist_index Simon Marchi
2021-01-20  5:39 ` [PATCH 04/13] gdb/dwarf: remove unnecessary check in read_{rng, loc}list_index Simon Marchi
2021-01-20  5:39 ` [PATCH 05/13] gdb/dwarf: few fixes for handling DW_FORM_{rng, loc}listx Simon Marchi
2021-01-28 15:30   ` [PATCH 05/13] gdb/dwarf: few fixes for handling DW_FORM_{rng,loc}listx Zoran Zaric
2021-01-20  5:39 ` [PATCH 06/13] gdb/dwarf: read correct rnglist/loclist header in read_{rng, loc}list_index Simon Marchi
2021-01-28 15:39   ` [PATCH 06/13] gdb/dwarf: read correct rnglist/loclist header in read_{rng,loc}list_index Zoran Zaric
2021-01-28 15:49     ` Simon Marchi
2021-01-28 15:54       ` Zoran Zaric
2021-01-20  5:39 ` [PATCH 07/13] gdb/dwarf: read DW_AT_ranges value as unsigned in partial_die_info::read Simon Marchi
2021-01-28 15:41   ` Zoran Zaric
2021-01-28 15:51     ` Simon Marchi [this message]
2021-01-20  5:39 ` [PATCH 08/13] gdb/testsuite: add .debug_rnglists tests Simon Marchi
2021-01-28 16:24   ` Zoran Zaric
2021-01-20  5:39 ` [PATCH 09/13] gdb/testsuite: DWARF assembler: add context parameters to _location Simon Marchi
2021-01-28 16:30   ` Zoran Zaric
2021-01-20  5:39 ` [PATCH 10/13] gdb/testsuite: add .debug_loclists tests Simon Marchi
2021-01-28 16:52   ` Zoran Zaric
2021-01-28 17:47     ` Simon Marchi
2021-01-29 10:13       ` Zoran Zaric
2021-01-29 15:57         ` Simon Marchi
2021-01-29 16:58           ` Zoran Zaric
2021-01-29 17:37             ` Simon Marchi
2021-01-20  5:39 ` [PATCH 11/13] gdb/dwarf: split dwarf2_cu::ranges_base in two Simon Marchi
2021-01-20  5:39 ` [PATCH 12/13] gdb/dwarf: make read_{loc, rng}list_index return sect_offset Simon Marchi
2021-02-25 19:26   ` Tom Tromey
2021-01-20  5:39 ` [PATCH 13/13] gdb/testsuite: add test for .debug_{rng, loc}lists section without offset array Simon Marchi
2021-02-02 15:43 ` [PATCH 00/13] DWARF 5 rnglists & loclists fixes (PR 26813) Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=acb82f89-a3be-df83-b460-9d8fe53de126@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=Zoran.Zaric@amd.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).