public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/25980] New: Overlapping Dwarf Compile Units with non-overlapping subranges gives incorrect line information
@ 2020-05-12 22:50 mitch at runsafesecurity dot com
  2020-05-13 18:11 ` [Bug symtab/25980] " cbiesinger at google dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mitch at runsafesecurity dot com @ 2020-05-12 22:50 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 25980
           Summary: Overlapping Dwarf Compile Units with non-overlapping
                    subranges gives incorrect line information
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: mitch at runsafesecurity dot com
  Target Milestone: ---

Created attachment 12527
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12527&action=edit
DWARF example & proposed patch

In cases where two compilation units have overlapping ranges (with
non-overlapping subranges), gdb gets a bit confused and reports line positions
from the wrong compilation unit.

Attached out.dwarf is an example testcase.

main.c has a top-level range of 0x1129-0x1253.
i.c has a top-level range of 0x11e5-0x1273.
Though these two ranges overlap, none of their child subprograms overlap. This
should mean that the line numbers for specific addresses are unambigous.

> gdb out.dwarf --batch --ex="set trace-commands on" --command=gdb.cmd
> +symbol-file
> +add-symbol-file -readnow ~/proj/LFR/dwarf/test/out.dwarf
> add symbol table from file "/home/crzysdrs/proj/LFR/dwarf/test/out.dwarf"
> + info line *main
> Line 11 of "i.c" starts at address 0x1210 <f+20> and ends at 0x1265 <d>.
> +info line *a
> Line 3 of "main.c" starts at address 0x1129 <a> and ends at 0x1131 <a+8>.
> +info line *b
> Line 6 of "main.c" starts at address 0x1157 <b> and ends at 0x115f <b+8>.
> +info line *c
> Line 9 of "main.c" starts at address 0x1140 <c> and ends at 0x1148 <c+8>.
> +info line *d
> Line 3 of "i.c" starts at address 0x1265 <d> and ends at 0x126d <d+8>.
> +info line *e
> Line 6 of "i.c" starts at address 0x11e5 <e> and ends at 0x11ed <e+8>.
> +info line *f
> Line 9 of "i.c" starts at address 0x11fc <f> and ends at 0x1204 <f+8>.

As shown above, the line information is mistakenly found in i.c, when it should
in fact be in main.c.

(Corrected)
> +info line *main
> Line 12 of "main.c" starts at address 0x1213 <main> and ends at 0x121b <main+8>.

This appears to be related to mistaken assumption in
symtab.c:find_pc_sect_compunit_symtab where in the absence of a partial symbol
table it tries to find the smallest compilation unit where the address resides
without considering the valid subranges of the compilation unit. If the
compilation unit that matched is the smallest, all future compilation units
containing that address will be ignored.

It should also be noted that removing -readnow for adding the symbol file does
correct the output. Additionally lldb and addr2line report the correct
position.
> $ addr2line -e out.dwarf 0x1213
> /home/crzysdrs/proj/LFR/dwarf/test/main.c:12

A proposed fix (attached) considers these ranges and does not accept
compilation units where no subrange matches.

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

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

* [Bug symtab/25980] Overlapping Dwarf Compile Units with non-overlapping subranges gives incorrect line information
  2020-05-12 22:50 [Bug symtab/25980] New: Overlapping Dwarf Compile Units with non-overlapping subranges gives incorrect line information mitch at runsafesecurity dot com
@ 2020-05-13 18:11 ` cbiesinger at google dot com
  2020-10-21 12:07 ` vries at gcc dot gnu.org
  2020-10-28 20:15 ` vries at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cbiesinger at google dot com @ 2020-05-13 18:11 UTC (permalink / raw)
  To: gdb-prs

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

Christian Biesinger <cbiesinger at google dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cbiesinger at google dot com

--- Comment #1 from Christian Biesinger <cbiesinger at google dot com> ---
Thanks for the patch! Could you send it to gdb-patches following the
instructions at 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] 4+ messages in thread

* [Bug symtab/25980] Overlapping Dwarf Compile Units with non-overlapping subranges gives incorrect line information
  2020-05-12 22:50 [Bug symtab/25980] New: Overlapping Dwarf Compile Units with non-overlapping subranges gives incorrect line information mitch at runsafesecurity dot com
  2020-05-13 18:11 ` [Bug symtab/25980] " cbiesinger at google dot com
@ 2020-10-21 12:07 ` vries at gcc dot gnu.org
  2020-10-28 20:15 ` vries at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-10-21 12:07 UTC (permalink / raw)
  To: gdb-prs

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

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vries at gcc dot gnu.org

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
Patch submitted:
https://sourceware.org/pipermail/gdb-patches/2020-May/168590.html

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

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

* [Bug symtab/25980] Overlapping Dwarf Compile Units with non-overlapping subranges gives incorrect line information
  2020-05-12 22:50 [Bug symtab/25980] New: Overlapping Dwarf Compile Units with non-overlapping subranges gives incorrect line information mitch at runsafesecurity dot com
  2020-05-13 18:11 ` [Bug symtab/25980] " cbiesinger at google dot com
  2020-10-21 12:07 ` vries at gcc dot gnu.org
@ 2020-10-28 20:15 ` vries at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-10-28 20:15 UTC (permalink / raw)
  To: gdb-prs

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

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE
   Target Milestone|---                         |11.1

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
With current trunk we have:
...
$ gdb -batch out.dwarf -ex "info line *main"
Line 12 of "main.c" starts at address 0x1213 <main> and ends at 0x121b
<main+8>.
$ gdb -batch out.dwarf -ex "info line *main" -readnow
Line 12 of "main.c" starts at address 0x1213 <main> and ends at 0x121b
<main+8>.
...

Marking this a duplicate of PR26772.

*** This bug has been marked as a duplicate of bug 26772 ***

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

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

end of thread, other threads:[~2020-10-28 20:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-12 22:50 [Bug symtab/25980] New: Overlapping Dwarf Compile Units with non-overlapping subranges gives incorrect line information mitch at runsafesecurity dot com
2020-05-13 18:11 ` [Bug symtab/25980] " cbiesinger at google dot com
2020-10-21 12:07 ` vries at gcc dot gnu.org
2020-10-28 20:15 ` vries at gcc dot gnu.org

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).