public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/94459] New: Missing c++ debug information for 'auto&' return type
@ 2020-04-02 16:07 ssbssa at yahoo dot de
2020-04-02 17:36 ` [Bug debug/94459] " jakub at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: ssbssa at yahoo dot de @ 2020-04-02 16:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94459
Bug ID: 94459
Summary: Missing c++ debug information for 'auto&' return type
Product: gcc
Version: 9.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
Assignee: unassigned at gcc dot gnu.org
Reporter: ssbssa at yahoo dot de
Target Milestone: ---
For the following example:
template <typename T>
struct MyClass
{
T value;
auto get()
{
return value;
}
auto &get_ref()
{
return value;
}
auto &&get_r_ref()
{
return (T&&)value;
}
const auto c_get()
{
return value;
}
const auto &c_get_ref()
{
return value;
}
const auto &&c_get_r_ref()
{
return (T&&)value;
}
};
int main()
{
MyClass<int> mc{1};
return (mc.get() + mc.get_ref() + mc.get_r_ref()
+ mc.c_get() + mc.c_get_ref() + mc.c_get_r_ref());
}
For the simple 'auto' case, the debugger knows the real return type:
(gdb) pt MyClass<int>::get
type = int (MyClass<int> * const)
But not for the others:
(gdb) pt MyClass<int>::get_ref
type = void &(MyClass<int> * const)
(gdb) pt MyClass<int>::get_r_ref
type = void &&(MyClass<int> * const)
(gdb) pt MyClass<int>::c_get
type = void (MyClass<int> * const)
(gdb) pt MyClass<int>::c_get_ref
type = void &(MyClass<int> * const)
(gdb) pt MyClass<int>::c_get_r_ref
type = void &&(MyClass<int> * const)
For 'auto', extra type information is stored on the definition die, this was
implemented here:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=2e5e7103a39315664f9a625bea42981f5251c27e
So I came up with the following patch:
--- gcc/dwarf2out.c 2020-03-12 12:07:21.000000000 +0100
+++ gcc/dwarf2out.c 2020-04-02 14:54:03.680451100 +0200
@@ -23016,6 +23016,11 @@
if (is_cxx () && debug_info_level > DINFO_LEVEL_TERSE)
{
dw_die_ref die = get_AT_ref (old_die, DW_AT_type);
+ if (die->die_tag == DW_TAG_reference_type
+ || die->die_tag == DW_TAG_rvalue_reference_type)
+ die = get_AT_ref (die, DW_AT_type);
+ if (die->die_tag == DW_TAG_const_type)
+ die = get_AT_ref (die, DW_AT_type);
if (die == auto_die || die == decltype_auto_die)
add_type_attribute (subr_die, TREE_TYPE (TREE_TYPE (decl)),
TYPE_UNQUALIFIED, false, context_die);
This seems to work fine:
(gdb) pt MyClass<int>::get
type = int (MyClass<int> * const)
(gdb) pt MyClass<int>::get_ref
type = int &(MyClass<int> * const)
(gdb) pt MyClass<int>::get_r_ref
type = int &&(MyClass<int> * const)
(gdb) pt MyClass<int>::c_get
type = const int (MyClass<int> * const)
(gdb) pt MyClass<int>::c_get_ref
type = const int &(MyClass<int> * const)
(gdb) pt MyClass<int>::c_get_r_ref
type = const int &&(MyClass<int> * const)
But I can't run the testsuite (I'm on Windows), so I can't be sure that this
would break anything else.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/94459] Missing c++ debug information for 'auto&' return type
2020-04-02 16:07 [Bug debug/94459] New: Missing c++ debug information for 'auto&' return type ssbssa at yahoo dot de
@ 2020-04-02 17:36 ` jakub at gcc dot gnu.org
2020-04-02 17:41 ` ssbssa at yahoo dot de
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-02 17:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94459
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |jason at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Looking through DW_TAG_const_type seems insufficient to me, can't there be
other qualifications (at least DW_TAG_volatile_type, perhaps in various
orders)?
So wouldn't be better a loop as long as die and die->die_tag is one of
dwarf_qual_info[?].t or DW_TAG_{rvalue_}reference, use die = get_AT_ref (die,
DW_AT_type); ?
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/94459] Missing c++ debug information for 'auto&' return type
2020-04-02 16:07 [Bug debug/94459] New: Missing c++ debug information for 'auto&' return type ssbssa at yahoo dot de
2020-04-02 17:36 ` [Bug debug/94459] " jakub at gcc dot gnu.org
@ 2020-04-02 17:41 ` ssbssa at yahoo dot de
2020-04-03 11:34 ` ssbssa at yahoo dot de
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ssbssa at yahoo dot de @ 2020-04-02 17:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94459
--- Comment #2 from Domani Hannes <ssbssa at yahoo dot de> ---
(In reply to Jakub Jelinek from comment #1)
> Looking through DW_TAG_const_type seems insufficient to me, can't there be
> other qualifications (at least DW_TAG_volatile_type, perhaps in various
> orders)?
> So wouldn't be better a loop as long as die and die->die_tag is one of
> dwarf_qual_info[?].t or DW_TAG_{rvalue_}reference, use die = get_AT_ref
> (die, DW_AT_type); ?
You're probably right, I wasn't sure if the use of 'auto' allows e.g.
'volatile' as well, so I just stuck with the ones I knew about.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/94459] Missing c++ debug information for 'auto&' return type
2020-04-02 16:07 [Bug debug/94459] New: Missing c++ debug information for 'auto&' return type ssbssa at yahoo dot de
2020-04-02 17:36 ` [Bug debug/94459] " jakub at gcc dot gnu.org
2020-04-02 17:41 ` ssbssa at yahoo dot de
@ 2020-04-03 11:34 ` ssbssa at yahoo dot de
2020-04-03 16:16 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ssbssa at yahoo dot de @ 2020-04-03 11:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94459
--- Comment #3 from Domani Hannes <ssbssa at yahoo dot de> ---
(In reply to Jakub Jelinek from comment #1)
> Looking through DW_TAG_const_type seems insufficient to me, can't there be
> other qualifications (at least DW_TAG_volatile_type, perhaps in various
> orders)?
> So wouldn't be better a loop as long as die and die->die_tag is one of
> dwarf_qual_info[?].t or DW_TAG_{rvalue_}reference, use die = get_AT_ref
> (die, DW_AT_type); ?
As suggested, I'm now using this:
--- gcc/dwarf2out.c 2020-03-12 12:07:21.000000000 +0100
+++ gcc/dwarf2out.c 2020-04-02 20:10:05.829023900 +0200
@@ -23016,6 +23016,11 @@
if (is_cxx () && debug_info_level > DINFO_LEVEL_TERSE)
{
dw_die_ref die = get_AT_ref (old_die, DW_AT_type);
+ while (die->die_tag == DW_TAG_reference_type
+ || die->die_tag == DW_TAG_rvalue_reference_type
+ || die->die_tag == DW_TAG_const_type
+ || die->die_tag == DW_TAG_volatile_type)
+ die = get_AT_ref (die, DW_AT_type);
if (die == auto_die || die == decltype_auto_die)
add_type_attribute (subr_die, TREE_TYPE (TREE_TYPE (decl)),
TYPE_UNQUALIFIED, false, context_die);
I don't think that restrict/atomic is possible for auto return types, but I may
be wrong about that.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/94459] Missing c++ debug information for 'auto&' return type
2020-04-02 16:07 [Bug debug/94459] New: Missing c++ debug information for 'auto&' return type ssbssa at yahoo dot de
` (2 preceding siblings ...)
2020-04-03 11:34 ` ssbssa at yahoo dot de
@ 2020-04-03 16:16 ` jakub at gcc dot gnu.org
2020-04-04 12:17 ` ssbssa at yahoo dot de
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-03 16:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94459
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-04-03
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 48191
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48191&action=edit
gcc10-pr94459.patch
Full patch I'll be testing. Related to PR53756.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/94459] Missing c++ debug information for 'auto&' return type
2020-04-02 16:07 [Bug debug/94459] New: Missing c++ debug information for 'auto&' return type ssbssa at yahoo dot de
` (3 preceding siblings ...)
2020-04-03 16:16 ` jakub at gcc dot gnu.org
@ 2020-04-04 12:17 ` ssbssa at yahoo dot de
2020-04-04 22:31 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ssbssa at yahoo dot de @ 2020-04-04 12:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94459
--- Comment #5 from Hannes Domani <ssbssa at yahoo dot de> ---
I also should mention that this is a precursor to fix gdb_bug 24154:
https://sourceware.org/bugzilla/show_bug.cgi?id=24154
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/94459] Missing c++ debug information for 'auto&' return type
2020-04-02 16:07 [Bug debug/94459] New: Missing c++ debug information for 'auto&' return type ssbssa at yahoo dot de
` (4 preceding siblings ...)
2020-04-04 12:17 ` ssbssa at yahoo dot de
@ 2020-04-04 22:31 ` cvs-commit at gcc dot gnu.org
2020-04-04 22:35 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-04 22:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94459
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:0be9efad938726721fd8c8c35609b1e1d7d30035
commit r10-7560-g0be9efad938726721fd8c8c35609b1e1d7d30035
Author: Jakub Jelinek <jakub@redhat.com>
Date: Sun Apr 5 00:28:28 2020 +0200
debug: Improve debug info of c++14 deduced return type [PR94459]
On the following testcase, in gdb ptype S<long>::m1 prints long as return
type, but all the other methods show void instead.
PR53756 added code to add_type_attribute if the return type is
auto/decltype(auto), but we actually should look through references,
pointers and qualifiers.
Haven't included there DW_TAG_atomic_type, because I think at least ATM
one can't use that in C++. Not sure about DW_TAG_array_type or what else
could be deduced.
> http://eel.is/c++draft/dcl.spec.auto#3 says it has to appear as a
> decl-specifier.
>
> http://eel.is/c++draft/temp.deduct.type#8 lists the forms where a
template
> argument can be deduced.
>
> Looks like you are missing arrays, pointers to members, and function
return
> types.
2020-04-04 Hannes Domani <ssbssa@yahoo.de>
Jakub Jelinek <jakub@redhat.com>
PR debug/94459
* dwarf2out.c (gen_subprogram_die): Look through references,
pointers,
arrays, pointer-to-members, function types and qualifiers when
checking if in-class DIE had an 'auto' or 'decltype(auto)' return
type
to emit type again on definition.
* g++.dg/debug/pr94459.C: New test.
Co-Authored-By: Hannes Domani <ssbssa@yahoo.de>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/94459] Missing c++ debug information for 'auto&' return type
2020-04-02 16:07 [Bug debug/94459] New: Missing c++ debug information for 'auto&' return type ssbssa at yahoo dot de
` (5 preceding siblings ...)
2020-04-04 22:31 ` cvs-commit at gcc dot gnu.org
@ 2020-04-04 22:35 ` jakub at gcc dot gnu.org
2020-04-07 19:04 ` cvs-commit at gcc dot gnu.org
2020-09-17 17:26 ` jakub at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-04 22:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94459
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/94459] Missing c++ debug information for 'auto&' return type
2020-04-02 16:07 [Bug debug/94459] New: Missing c++ debug information for 'auto&' return type ssbssa at yahoo dot de
` (6 preceding siblings ...)
2020-04-04 22:35 ` jakub at gcc dot gnu.org
@ 2020-04-07 19:04 ` cvs-commit at gcc dot gnu.org
2020-09-17 17:26 ` jakub at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-07 19:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94459
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:b5039b7259e64a92f5c077fe4d023556d6b12550
commit r9-8479-gb5039b7259e64a92f5c077fe4d023556d6b12550
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Apr 7 21:01:40 2020 +0200
debug: Improve debug info of c++14 deduced return type [PR94459]
On the following testcase, in gdb ptype S<long>::m1 prints long as return
type, but all the other methods show void instead.
PR53756 added code to add_type_attribute if the return type is
auto/decltype(auto), but we actually should look through references,
pointers and qualifiers.
Haven't included there DW_TAG_atomic_type, because I think at least ATM
one can't use that in C++. Not sure about DW_TAG_array_type or what else
could be deduced.
> http://eel.is/c++draft/dcl.spec.auto#3 says it has to appear as a
> decl-specifier.
>
> http://eel.is/c++draft/temp.deduct.type#8 lists the forms where a
template
> argument can be deduced.
>
> Looks like you are missing arrays, pointers to members, and function
return
> types.
2020-04-04 Hannes Domani <ssbssa@yahoo.de>
Jakub Jelinek <jakub@redhat.com>
PR debug/94459
* dwarf2out.c (gen_subprogram_die): Look through references,
pointers,
arrays, pointer-to-members, function types and qualifiers when
checking if in-class DIE had an 'auto' or 'decltype(auto)' return
type
to emit type again on definition.
* g++.dg/debug/pr94459.C: New test.
Co-Authored-By: Hannes Domani <ssbssa@yahoo.de>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/94459] Missing c++ debug information for 'auto&' return type
2020-04-02 16:07 [Bug debug/94459] New: Missing c++ debug information for 'auto&' return type ssbssa at yahoo dot de
` (7 preceding siblings ...)
2020-04-07 19:04 ` cvs-commit at gcc dot gnu.org
@ 2020-09-17 17:26 ` jakub at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-09-17 17:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94459
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 8.5 in r8-10481-gbd748b6b448ef47f56922ec67244037915f721c2 and by the
above commit for 9.4+ too.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-09-17 17:26 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-02 16:07 [Bug debug/94459] New: Missing c++ debug information for 'auto&' return type ssbssa at yahoo dot de
2020-04-02 17:36 ` [Bug debug/94459] " jakub at gcc dot gnu.org
2020-04-02 17:41 ` ssbssa at yahoo dot de
2020-04-03 11:34 ` ssbssa at yahoo dot de
2020-04-03 16:16 ` jakub at gcc dot gnu.org
2020-04-04 12:17 ` ssbssa at yahoo dot de
2020-04-04 22:31 ` cvs-commit at gcc dot gnu.org
2020-04-04 22:35 ` jakub at gcc dot gnu.org
2020-04-07 19:04 ` cvs-commit at gcc dot gnu.org
2020-09-17 17:26 ` 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).