Bug 77363 - [5 Regression] Missing debug information in DWARF
Summary: [5 Regression] Missing debug information in DWARF
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 5.4.0
: P2 major
Target Milestone: 5.5
Assignee: Jakub Jelinek
URL:
Keywords: wrong-debug
: 80596 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-08-24 08:38 UTC by Jiří Engelthaler
Modified: 2017-05-30 09:13 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.9.4, 5.3.0, 6.2.1, 7.0
Known to fail: 5.4.0, 6.2.0
Last reconfirmed: 2016-08-24 00:00:00


Attachments
example.c (137 bytes, text/plain)
2016-08-24 08:38 UTC, Jiří Engelthaler
Details
gcc7-pr77363.patch (765 bytes, patch)
2016-08-29 16:38 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jiří Engelthaler 2016-08-24 08:38:28 UTC
Created attachment 39489 [details]
example.c

I have found a missing debug information in dwarf for file compiled with g++. Same file compiled with gcc has correct debug information.

I have compiled the file as g++ -c -g example.c
Export debug information as readelf -wi example.o >deb

There is a missing information for type tHash1
 <1><2b>: Abbrev Number: 3 (DW_TAG_typedef)
    <2c>   DW_AT_name        : (indirect string, offset: 0x23): tHash1
    <30>   DW_AT_decl_file   : 1
    <31>   DW_AT_decl_line   : 4

but for the type tHash2 the information is correct
 <1><39>: Abbrev Number: 4 (DW_TAG_typedef)
    <3a>   DW_AT_name        : (indirect string, offset: 0x2a): tHash2
    <3e>   DW_AT_decl_file   : 1
    <3f>   DW_AT_decl_line   : 5
    <40>   DW_AT_type        : <0x44>    <------- OK

I ask someone to confirm the bug.
example.c attached
Comment 1 Richard Biener 2016-08-24 10:39:18 UTC
Confirmed with GCC 6.  The root cause seems to be that we lack a DIE for the
uint8 typedef as well (the uint16 one is IMHO correctly pruned as unused by
both FEs).  It works fine with GCC 4.8 and 4.9 where we also lack the uint8 typedef DIE but at least get

 <1><24>: Abbrev Number: 2 (DW_TAG_base_type)
    <25>   DW_AT_byte_size   : 1
    <26>   DW_AT_encoding    : 8        (unsigned char)
    <27>   DW_AT_name        : (indirect string, offset: 0x72): unsigned char
 <1><2b>: Abbrev Number: 3 (DW_TAG_typedef)
    <2c>   DW_AT_name        : (indirect string, offset: 0x23): tHash1
    <30>   DW_AT_decl_file   : 1
    <31>   DW_AT_decl_line   : 4
    <32>   DW_AT_type        : <0x36>
 <1><36>: Abbrev Number: 4 (DW_TAG_array_type)
    <37>   DW_AT_type        : <0x24>
    <3b>   DW_AT_sibling     : <0x46>
 <2><3f>: Abbrev Number: 5 (DW_TAG_subrange_type)
    <40>   DW_AT_type        : <0x46>
    <44>   DW_AT_upper_bound : 15
Comment 2 Jiří Engelthaler 2016-08-25 08:50:03 UTC
Investigating the bug I found that GCC 5.3.0 is partially correct, same way as 4.8 and 4.9.

The bug was introduced by this revision https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=231673

GIT 0c4341e59b724e51deb033a64e057159f27de7dd
Comment 3 Jiří Engelthaler 2016-08-25 08:52:14 UTC
This pr68162 breaks the function
Comment 4 Jakub Jelinek 2016-08-29 16:38:36 UTC
Created attachment 39513 [details]
gcc7-pr77363.patch

Untested fix.  I believe the bug is that Richard changed just gen_type_die_with_usage, but modified_type_die needs to be in sync in what that function does, otherwise it can't look it up or looks up something different.
Comment 5 Jakub Jelinek 2016-08-30 06:47:10 UTC
Author: jakub
Date: Tue Aug 30 06:46:38 2016
New Revision: 239855

URL: https://gcc.gnu.org/viewcvs?rev=239855&root=gcc&view=rev
Log:
	PR debug/77363
	* dwarf2out.c (modified_type_die): Use lookup_type_die (type)
	instead of lookup_type_die (type_main_variant (type)) even for array
	types.

	* g++.dg/debug/dwarf2/pr77363.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/debug/dwarf2/pr77363.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Jiří Engelthaler 2016-08-30 08:08:27 UTC
Confirmed that the patch fixes my case in GCC 5.4.0.
Please backport the patch to gcc-5 branch.
Comment 7 Jakub Jelinek 2016-08-30 08:14:50 UTC
Still not fixed for 6.3/5.5, so reopening until that happens.
Comment 8 Jakub Jelinek 2016-09-01 11:43:46 UTC
Author: jakub
Date: Thu Sep  1 11:43:15 2016
New Revision: 239930

URL: https://gcc.gnu.org/viewcvs?rev=239930&root=gcc&view=rev
Log:
	Backported from mainline
	2016-08-30  Jakub Jelinek  <jakub@redhat.com>

	PR debug/77363
	* dwarf2out.c (modified_type_die): Use lookup_type_die (type)
	instead of lookup_type_die (type_main_variant (type)) even for array
	types.

	* g++.dg/debug/dwarf2/pr77363.C: New test.

Added:
    branches/gcc-6-branch/gcc/testsuite/g++.dg/debug/dwarf2/pr77363.C
Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/dwarf2out.c
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
Comment 9 Richard Biener 2017-05-03 07:25:50 UTC
*** Bug 80596 has been marked as a duplicate of this bug. ***
Comment 10 Jakub Jelinek 2017-05-30 07:19:10 UTC
Author: jakub
Date: Tue May 30 07:18:37 2017
New Revision: 248602

URL: https://gcc.gnu.org/viewcvs?rev=248602&root=gcc&view=rev
Log:
	Backported from mainline
	2016-08-30  Jakub Jelinek  <jakub@redhat.com>

	PR debug/77363
	* dwarf2out.c (modified_type_die): Use lookup_type_die (type)
	instead of lookup_type_die (type_main_variant (type)) even for array
	types.

	* g++.dg/debug/dwarf2/pr77363.C: New test.

Added:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/debug/dwarf2/pr77363.C
Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/dwarf2out.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
Comment 11 Jakub Jelinek 2017-05-30 09:13:31 UTC
Fixed.