* [Bug debug/101431] gcc-generated DWARF5 .debug_line directory entries violate the DWARF5 spec
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 ` roc at ocallahan dot org
2021-07-13 7:23 ` jakub at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: roc at ocallahan dot org @ 2021-07-13 3:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101431
--- Comment #1 from roc at ocallahan dot org <roc at ocallahan dot org> ---
Clang follows the spec (clang 12, -fdebug-default-version=5):
The Directory Table:
0 /tmp/pernosco-submit-test
1 out
The File Name Table
Entry Dir Time Size MD5 Name
0 0 0 0 F596F6F042BF2AD9E2B1C6B62633739A
out/file.c
1 1 0 0 5E2CEC2A6335E978DEB5A35D865C41E2
message.h
So I'm not sure what to do anymore when consuming DWARF5 line number
information.
I guess we could try "treat all relative directory entries as relative to the
DW_AT_comp_dir" and hope that clang's directory entry 0 always matches
DW_AT_comp_dir...
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/101431] gcc-generated DWARF5 .debug_line directory entries violate the DWARF5 spec
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
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-07-13 7:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101431
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
You've omitted the most important information, what binutils version you are
using and what binutils gcc has been configured against, because the line table
is usually (with the exception of -gno-as-loc-support etc.) created by the
assembler with the help of the compiler, not by the compiler itself.
So, depending on what binutils has the compiler been compiled against, the
.debug_line can sometimes be just DWARF 3 or 4 instead of 5 even when other
sections (the compiler emitted ones) are DWARF 5 etc.
When using binutils 2.36.1 against which gcc has been configured I certainly
see
Raw dump of debug contents of section .debug_line:
Offset: 0x0
Length: 79
DWARF Version: 5
...
The Directory Table (offset 0x22, lines 2, columns 1):
Entry Name
0 (indirect line string, offset: 0x10): /tmp
1 (indirect line string, offset: 0x15): out
The File Name Table (offset 0x30, lines 2, columns 2):
Entry Dir Name
0 0 (indirect line string, offset: 0x19): out/test.c
1 1 (indirect line string, offset: 0x24): test.c
and similarly for -gno-as-loc-support on gcc configured against older binutils.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/101431] gcc-generated DWARF5 .debug_line directory entries violate the DWARF5 spec
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
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: roc at ocallahan dot org @ 2021-07-13 7:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101431
--- Comment #3 from roc at ocallahan dot org <roc at ocallahan dot org> ---
This is the Fedora 34 package.
$ gcc --version
gcc (GCC) 11.1.1 20210531 (Red Hat 11.1.1-3)
$ rpm -qa|grep ^gcc-11
gcc-11.1.1-3.fc34.x86_64
$ rpm -qa|grep binutils-2
binutils-2.35.1-41.fc34.x86_64
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/101431] gcc-generated DWARF5 .debug_line directory entries violate the DWARF5 spec
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
` (2 preceding siblings ...)
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
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-13 7:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101431
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
> cat tmp/t.c
void foo(int i) {}
> gcc-11 -g -o tmp/t.o tmp/t.c -c
and the DWARF ends up
<0><c>: Abbrev Number: 1 (DW_TAG_compile_unit)
<d> DW_AT_producer : (indirect string, offset: 0x0): GNU C17 11.1.1
20210428 -mtune=generic -march=x86-64 -g
<11> DW_AT_language : 29 (C11)
<12> DW_AT_name : (indirect line string, offset: 0x0): tmp/t.c
<16> DW_AT_comp_dir : (indirect line string, offset: 0x8): /
<1a> DW_AT_low_pc : 0x0
<22> DW_AT_high_pc : 0xa
<2a> DW_AT_stmt_list : 0x0
...
The Directory Table (offset 0x22, lines 2, columns 1):
Entry Name
0 (indirect line string, offset: 0xa): tmp
1 (indirect line string, offset: 0xe): tmp
The File Name Table (offset 0x30, lines 2, columns 2):
Entry Dir Name
0 0 (indirect line string, offset: 0x12): tmp/t.c
1 1 (indirect line string, offset: 0x1a): t.c
I suspect this is because of how GCC and gas together end up producing
.debug_line - we have
.file "t.c"
.text
...
foo:
.LFB0:
.file 1 "tmp/t.c"
...
.section .debug_line,"",@progbits
.Ldebug_line0:
.file 0 "/" "tmp/t.c"
but this .file 0 ends up taking the place of comp-dir and it also
ends up duplicating the file entry for t.c unnecessarily. I'm not
familiar with how the DWARF5 stuff was set up so I hope somebody
else can have a look.
Note the referenced testcase in github uses -gsplit-dwarf.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/101431] gcc-generated DWARF5 .debug_line directory entries violate the DWARF5 spec
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
` (3 preceding siblings ...)
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
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-13 7:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101431
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #4)
> > cat tmp/t.c
> void foo(int i) {}
> > gcc-11 -g -o tmp/t.o tmp/t.c -c
>
> and the DWARF ends up
>
> <0><c>: Abbrev Number: 1 (DW_TAG_compile_unit)
> <d> DW_AT_producer : (indirect string, offset: 0x0): GNU C17 11.1.1
> 20210428 -mtune=generic -march=x86-64 -g
> <11> DW_AT_language : 29 (C11)
> <12> DW_AT_name : (indirect line string, offset: 0x0): tmp/t.c
> <16> DW_AT_comp_dir : (indirect line string, offset: 0x8): /
> <1a> DW_AT_low_pc : 0x0
> <22> DW_AT_high_pc : 0xa
> <2a> DW_AT_stmt_list : 0x0
>
> ...
> The Directory Table (offset 0x22, lines 2, columns 1):
> Entry Name
> 0 (indirect line string, offset: 0xa): tmp
> 1 (indirect line string, offset: 0xe): tmp
>
> The File Name Table (offset 0x30, lines 2, columns 2):
> Entry Dir Name
> 0 0 (indirect line string, offset: 0x12): tmp/t.c
> 1 1 (indirect line string, offset: 0x1a): t.c
>
> I suspect this is because of how GCC and gas together end up producing
> .debug_line - we have
>
> .file "t.c"
> .text
> ...
> foo:
> .LFB0:
> .file 1 "tmp/t.c"
> ...
> .section .debug_line,"",@progbits
> .Ldebug_line0:
> .file 0 "/" "tmp/t.c"
>
> but this .file 0 ends up taking the place of comp-dir and it also
> ends up duplicating the file entry for t.c unnecessarily. I'm not
> familiar with how the DWARF5 stuff was set up so I hope somebody
> else can have a look.
>
> Note the referenced testcase in github uses -gsplit-dwarf.
This was with binutils 2.36.1 and GCC configured against that.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/101431] gcc-generated DWARF5 .debug_line directory entries violate the DWARF5 spec
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
` (4 preceding siblings ...)
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
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-13 7:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101431
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #5)
> (In reply to Richard Biener from comment #4)
> > > cat tmp/t.c
> > void foo(int i) {}
> > > gcc-11 -g -o tmp/t.o tmp/t.c -c
> >
> > and the DWARF ends up
> >
> > <0><c>: Abbrev Number: 1 (DW_TAG_compile_unit)
> > <d> DW_AT_producer : (indirect string, offset: 0x0): GNU C17 11.1.1
> > 20210428 -mtune=generic -march=x86-64 -g
> > <11> DW_AT_language : 29 (C11)
> > <12> DW_AT_name : (indirect line string, offset: 0x0): tmp/t.c
> > <16> DW_AT_comp_dir : (indirect line string, offset: 0x8): /
> > <1a> DW_AT_low_pc : 0x0
> > <22> DW_AT_high_pc : 0xa
> > <2a> DW_AT_stmt_list : 0x0
> >
> > ...
> > The Directory Table (offset 0x22, lines 2, columns 1):
> > Entry Name
> > 0 (indirect line string, offset: 0xa): tmp
> > 1 (indirect line string, offset: 0xe): tmp
> >
> > The File Name Table (offset 0x30, lines 2, columns 2):
> > Entry Dir Name
> > 0 0 (indirect line string, offset: 0x12): tmp/t.c
> > 1 1 (indirect line string, offset: 0x1a): t.c
> >
> > I suspect this is because of how GCC and gas together end up producing
> > .debug_line - we have
> >
> > .file "t.c"
> > .text
> > ...
> > foo:
> > .LFB0:
> > .file 1 "tmp/t.c"
> > ...
> > .section .debug_line,"",@progbits
> > .Ldebug_line0:
> > .file 0 "/" "tmp/t.c"
> >
> > but this .file 0 ends up taking the place of comp-dir and it also
> > ends up duplicating the file entry for t.c unnecessarily. I'm not
> > familiar with how the DWARF5 stuff was set up so I hope somebody
> > else can have a look.
> >
> > Note the referenced testcase in github uses -gsplit-dwarf.
>
> This was with binutils 2.36.1 and GCC configured against that.
But it looks good (apart from duplicated file entry) with -gno-as-loc-support:
The Directory Table (offset 0x22, lines 2, columns 1):
Entry Name
0 (indirect line string, offset: 0x10): /
1 (indirect line string, offset: 0x0): tmp
The File Name Table (offset 0x30, lines 2, columns 2):
Entry Dir Name
0 0 (indirect line string, offset: 0x4): tmp/t.c
1 1 (indirect line string, offset: 0xc): t.c
it looks like some configury doesn't work as expected? The driver
passes --gdwarf-5 to the assembler.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/101431] gcc-generated DWARF5 .debug_line directory entries violate the DWARF5 spec
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
` (5 preceding siblings ...)
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
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-07-13 8:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101431
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ebotcazou at gcc dot gnu.org
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
With -gsplit-dwarf (and without -gno-as-loc-support) I can reproduce in 11, but
not on the trunk, where it got fixed with
r12-1777-ga21dc9d1529b8a8071e36b22b6e8492fc2ce7d5a
The .file 0 emission in 11 used to be guarded with asm_outputs_debug_line_str
which is false for split dwarf.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/101431] gcc-generated DWARF5 .debug_line directory entries violate the DWARF5 spec
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
` (6 preceding siblings ...)
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
8 siblings, 0 replies; 10+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2021-07-13 9:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101431
--- Comment #8 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> With -gsplit-dwarf (and without -gno-as-loc-support) I can reproduce in 11,
> but not on the trunk, where it got fixed with
> r12-1777-ga21dc9d1529b8a8071e36b22b6e8492fc2ce7d5a
> The .file 0 emission in 11 used to be guarded with asm_outputs_debug_line_str
> which is false for split dwarf.
r12-1777-ga21dc9d1529b8a8071e36b22b6e8492fc2ce7d5a has been backported onto the
11 branch as r11-8650-gf19b20de1b24d6b53479c6815316a5201b22775d.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/101431] gcc-generated DWARF5 .debug_line directory entries violate the DWARF5 spec
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
` (7 preceding siblings ...)
2021-07-13 9:07 ` ebotcazou at gcc dot gnu.org
@ 2021-07-13 9:10 ` jakub at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-07-13 9:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101431
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Then this looks fixed to me...
^ permalink raw reply [flat|nested] 10+ messages in thread