public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64346] New: gcc generates incorrect debug info for ctor/dtor
@ 2014-12-17 23:43 dehao at gcc dot gnu.org
  2014-12-17 23:45 ` [Bug c++/64346] " dehao at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dehao at gcc dot gnu.org @ 2014-12-17 23:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64346
           Summary: gcc generates incorrect debug info for ctor/dtor
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dehao at gcc dot gnu.org

#cat a.cc
#include <iostream>
#include <memory>

class ABC {
public:
 ABC() {printf("abc\n");}
 ~ABC() {printf("xyz\n");}
};

int foo() {
  std::unique_ptr<ABC> a(new ABC());
}

#g++4.8 a.cc -c -O2 -std=c++11 -g -fno-exceptions
#addr2line -e a.o -i -f 0x13
_ZN3ABCC1Ev
/usr/local/google/home/dehao/gcc/gcc-4_9/debug/a.cc:5
_Z3foov
/usr/local/google/home/dehao/gcc/gcc-4_9/debug/a.cc:10

#g++4.9 a.cc -c -O2 -std=c++11 -g -fno-exceptions
#addr2line -e a.o -i -f 0x13
_ZN3ABCC4Ev
/usr/local/google/home/dehao/gcc/gcc-4_9/debug/a.cc:5
_Z3foov
/usr/local/google/home/dehao/gcc/gcc-4_9/debug/a.cc:10

#g++4.9 a.cc -c -O0 -std=c++11 -g -fno-exceptions
#nm a.o |grep ABCC
0000000000000000 W _ZN3ABCC1Ev
0000000000000000 W _ZN3ABCC2Ev
0000000000000000 n _ZN3ABCC5Ev

Note that for the gcc 4.9 version and later, without any optimization
_ZN3ABCC4Ev does not exists in the symbol table. So we expect either
_ZN3ABCC1Ev or _ZN3ABCC2Ev in the addr2line result.


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

* [Bug c++/64346] gcc generates incorrect debug info for ctor/dtor
  2014-12-17 23:43 [Bug c++/64346] New: gcc generates incorrect debug info for ctor/dtor dehao at gcc dot gnu.org
@ 2014-12-17 23:45 ` dehao at gcc dot gnu.org
  2014-12-18  0:01 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: dehao at gcc dot gnu.org @ 2014-12-17 23:45 UTC (permalink / raw)
  To: gcc-bugs

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

dehao at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
                 CC|                            |ccoutant at gcc dot gnu.org,
                   |                            |davidxl at google dot com,
                   |                            |jason at gcc dot gnu.org

--- Comment #1 from dehao at gcc dot gnu.org ---
This may be related to https://gcc.gnu.org/ml/gcc-patches/2013-11/msg02724.html

Jason could you help take a look?


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

* [Bug c++/64346] gcc generates incorrect debug info for ctor/dtor
  2014-12-17 23:43 [Bug c++/64346] New: gcc generates incorrect debug info for ctor/dtor dehao at gcc dot gnu.org
  2014-12-17 23:45 ` [Bug c++/64346] " dehao at gcc dot gnu.org
@ 2014-12-18  0:01 ` pinskia at gcc dot gnu.org
  2014-12-18  0:05 ` dehao at gcc dot gnu.org
  2014-12-19 18:41 ` ccoutant at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-12-18  0:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>_ZN3ABCC4Ev

That is the internal name of the function (it demangles to ABC::ABC() anyways)
and the symbol does not need to be in the symbol table at all.

We are going to run into this more with ICF also.  I think there might have
been a RFC about how to handle the debugging for commoning of functions but it
might be a while before that is implemented.


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

* [Bug c++/64346] gcc generates incorrect debug info for ctor/dtor
  2014-12-17 23:43 [Bug c++/64346] New: gcc generates incorrect debug info for ctor/dtor dehao at gcc dot gnu.org
  2014-12-17 23:45 ` [Bug c++/64346] " dehao at gcc dot gnu.org
  2014-12-18  0:01 ` pinskia at gcc dot gnu.org
@ 2014-12-18  0:05 ` dehao at gcc dot gnu.org
  2014-12-19 18:41 ` ccoutant at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: dehao at gcc dot gnu.org @ 2014-12-18  0:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from dehao at gcc dot gnu.org ---
For AutoFDO, we actually needs symbols from the symbol table because indirect
call promotion needs the symbol name to find the right callee.

You are right, ICF also causes trouble to AutoFDO profile.


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

* [Bug c++/64346] gcc generates incorrect debug info for ctor/dtor
  2014-12-17 23:43 [Bug c++/64346] New: gcc generates incorrect debug info for ctor/dtor dehao at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2014-12-18  0:05 ` dehao at gcc dot gnu.org
@ 2014-12-19 18:41 ` ccoutant at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ccoutant at gcc dot gnu.org @ 2014-12-19 18:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Cary Coutant <ccoutant at gcc dot gnu.org> ---
I think the problem is that the decloning turns the C1 and C2 ctors into
thunks, and GCC doesn't (yet) generate debug info for thunks, so when you
inline the C4 into the C1 or C2, and inline that into foo, all that's left in
the debug info is the inlined call to the C4 ctor.

It looks like -fno-declone-ctors-dtor doesn't work around the problem because
the "need_alias" flag is true, and that forces the decloning in this case.

The most expedient approach might be for you to alias the C4/D4 names to the
official ones when processing the profile data. Is that feasible?


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

end of thread, other threads:[~2014-12-19 18:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-17 23:43 [Bug c++/64346] New: gcc generates incorrect debug info for ctor/dtor dehao at gcc dot gnu.org
2014-12-17 23:45 ` [Bug c++/64346] " dehao at gcc dot gnu.org
2014-12-18  0:01 ` pinskia at gcc dot gnu.org
2014-12-18  0:05 ` dehao at gcc dot gnu.org
2014-12-19 18:41 ` ccoutant 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).