public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/101431] New: gcc-generated DWARF5 .debug_line directory entries violate the DWARF5 spec
@ 2021-07-13  3:45 roc at ocallahan dot org
  2021-07-13  3:58 ` [Bug debug/101431] " roc at ocallahan dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: roc at ocallahan dot org @ 2021-07-13  3:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101431

            Bug ID: 101431
           Summary: gcc-generated DWARF5 .debug_line directory entries
                    violate the DWARF5 spec
           Product: gcc
           Version: 11.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roc at ocallahan dot org
  Target Milestone: ---

For the "Line Number Program Header" "directories" field, the DWARF5 spec says

"The first entry is the current directory of the compilation. Each additional
path entry is either a full path name or is relative to the current directory
of
the compilation."

In a simple testcase (see below) I get the following tables emitted (gcc
11.1.1):

The Directory Table:
  0 out
  1 out
  2 /usr/include

The File Name Table
  Entry Dir     Time    Size    Name
  0     0       0       0       file.c
  1     1       0       0       file.c
  2     1       0       0       message.h
  3     2       0       0       stdio.h

The compilation unit info from .debug_info is

UNIT<header overall offset = 0x0000006a>:
  dwo_id           = 0x6ef97fe679ccccda
< 0><0x00000014>  DW_TAG_skeleton_unit
                    DW_AT_low_pc                0x00201728
                    DW_AT_high_pc               <offset-from-lowpc>21
                    DW_AT_stmt_list             <.debug_line+0x000000bd>
                    DW_AT_dwo_name              out/main.dwo
                    DW_AT_comp_dir              /tmp/pernosco-submit-test
                    DW_AT_GNU_pubnames          yes
                    DW_AT_addr_base             <.debug_addr+0x00000030>

The correct path for 'file.c' is /tmp/pernosco-submit-test/out/file.c.

Clearly, treating directory entry 1 as relative to directory entry 0 would give
the wrong file path (something containing 'out/out'). It looks like gcc intends
all directory entries to be treated as relative to the DW_AT_comp_dir from the
.debug_info unit?

Note that if the latter is true, then that violates the intent of the new
behavior in DWARF5:

> In DWARF Version 5, the current directory is explicitly present in the
directories field. This is needed to support the common practice of stripping
all but the line number sections ( .debug_line and .debug_line_str ) from an
executable.

To reproduce this bug:

git clone --recurse-submodules https://github.com/Pernosco/pernosco-submit-test
cd pernosco-submit-test
./build.sh
dwarfdump -l out/main.debug

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

end of thread, other threads:[~2021-07-13  9:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-13  3:45 [Bug debug/101431] New: gcc-generated DWARF5 .debug_line directory entries violate the DWARF5 spec roc at ocallahan dot org
2021-07-13  3:58 ` [Bug debug/101431] " roc at ocallahan dot org
2021-07-13  7:23 ` jakub at gcc dot gnu.org
2021-07-13  7:29 ` roc at ocallahan dot org
2021-07-13  7:29 ` rguenth at gcc dot gnu.org
2021-07-13  7:31 ` rguenth at gcc dot gnu.org
2021-07-13  7:37 ` rguenth at gcc dot gnu.org
2021-07-13  8:40 ` jakub at gcc dot gnu.org
2021-07-13  9:07 ` ebotcazou at gcc dot gnu.org
2021-07-13  9:10 ` jakub 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).