public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17720] New: Function names appear without namespace/class prefixes in backtrace for optimized code
@ 2014-12-17 15:06 martin.galvan at tallertechnologies dot com
  2014-12-17 15:08 ` [Bug c++/17720] " martin.galvan at tallertechnologies dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: martin.galvan at tallertechnologies dot com @ 2014-12-17 15:06 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=17720

            Bug ID: 17720
           Summary: Function names appear without namespace/class prefixes
                    in backtrace for optimized code
           Product: gdb
           Version: 7.8
            Status: NEW
          Severity: normal
          Priority: P2
         Component: c++
          Assignee: unassigned at sourceware dot org
          Reporter: martin.galvan at tallertechnologies dot com

Created attachment 8017
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8017&action=edit
The code I'm testing this bug with

If we have the following code:

#include <stdio.h>

class myClass {
public:
    void method() { puts("Hello world!"); }
};

int main()
{
    myClass instance;
    instance.method();

    return 0;
}

When we compile it with gcc 4.9.2 without optimizations, a backtrace inside
method() will show us this:

(gdb) bt
#0  myClass::method (this=0x7fffffffdcef) at test.cpp:5
#1  0x0000000000400541 in main () at test.cpp:11

However, if we compile it with -O1 and further, backtracing from an instruction
belonging to the (now inlined) method() will show us this:

(gdb) bt
#0  method (this=<synthetic pointer>) at test.cpp:5
#1  main () at test.cpp:11

which doesn't have the class name prefix. The same happens with namespaces.

The debug info emmited by gcc seems to be correct, and it includes the full
name of the method (for any optimization level):

$ objdump --dwarf=info test | c++filt
...
 <2><2a1>: Abbrev Number: 15 (DW_TAG_subprogram)
    <2a2>   DW_AT_external    : 1    
    <2a2>   DW_AT_name        : (indirect string, offset: 0x373e): method    
    <2a6>   DW_AT_decl_file   : 1    
    <2a7>   DW_AT_decl_line   : 5    
    <2a8>   DW_AT_linkage_name: (indirect string, offset: 0x1480):
myClass::method()    
    <2ac>   DW_AT_accessibility: 1    (public)
    <2ad>   DW_AT_declaration : 1    
    <2ad>   DW_AT_object_pointer: <0x2b1>
...

I think the problem may be somewhere inside dwarf2read.c (perhaps in
determine_prefix()?).

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug c++/17720] Function names appear without namespace/class prefixes in backtrace for optimized code
  2014-12-17 15:06 [Bug c++/17720] New: Function names appear without namespace/class prefixes in backtrace for optimized code martin.galvan at tallertechnologies dot com
@ 2014-12-17 15:08 ` martin.galvan at tallertechnologies dot com
  2014-12-17 15:42 ` martin.galvan at tallertechnologies dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: martin.galvan at tallertechnologies dot com @ 2014-12-17 15:08 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=17720

Martin Galvan <martin.galvan at tallertechnologies dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |martin.galvan@tallertechnol
                   |                            |ogies.com

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug c++/17720] Function names appear without namespace/class prefixes in backtrace for optimized code
  2014-12-17 15:06 [Bug c++/17720] New: Function names appear without namespace/class prefixes in backtrace for optimized code martin.galvan at tallertechnologies dot com
  2014-12-17 15:08 ` [Bug c++/17720] " martin.galvan at tallertechnologies dot com
@ 2014-12-17 15:42 ` martin.galvan at tallertechnologies dot com
  2014-12-18 17:48 ` martin.galvan at tallertechnologies dot com
  2020-04-03 16:00 ` ssbssa at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: martin.galvan at tallertechnologies dot com @ 2014-12-17 15:42 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=17720

Martin Galvan <martin.galvan at tallertechnologies dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Build|                            |7.8.50.20141125-cvs

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug c++/17720] Function names appear without namespace/class prefixes in backtrace for optimized code
  2014-12-17 15:06 [Bug c++/17720] New: Function names appear without namespace/class prefixes in backtrace for optimized code martin.galvan at tallertechnologies dot com
  2014-12-17 15:08 ` [Bug c++/17720] " martin.galvan at tallertechnologies dot com
  2014-12-17 15:42 ` martin.galvan at tallertechnologies dot com
@ 2014-12-18 17:48 ` martin.galvan at tallertechnologies dot com
  2020-04-03 16:00 ` ssbssa at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: martin.galvan at tallertechnologies dot com @ 2014-12-18 17:48 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=17720

--- Comment #1 from Martin Galvan <martin.galvan at tallertechnologies dot com> ---
Created attachment 8018
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8018&action=edit
Possible fix

After reading the code and doing some tests I noticed die_needs_namespace was
returning 0 for a DIE whose tag was DW_TAG_inlined_subroutine. This meant that
dwarf2_physname would simply return the DIE's name attribute (which in our case
would be "method"). Therefore, when new_symbol_full called SYMBOL_SET_NAMES,
the linkagename argument wasn't the demangled name as it should have.

What I did was simply adding a case which would return 1 for
DW_TAG_inlined_subroutine in die_needs_namespace. I tested it and it works both
for classes and namespaces.

I should mention I don't have a copyright assignment yet (it's on the works);
however since this patch is fairly small I don't think that's necessary. If it
is let me know and I'll get back to you once the paperwork is done.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug c++/17720] Function names appear without namespace/class prefixes in backtrace for optimized code
  2014-12-17 15:06 [Bug c++/17720] New: Function names appear without namespace/class prefixes in backtrace for optimized code martin.galvan at tallertechnologies dot com
                   ` (2 preceding siblings ...)
  2014-12-18 17:48 ` martin.galvan at tallertechnologies dot com
@ 2020-04-03 16:00 ` ssbssa at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: ssbssa at sourceware dot org @ 2020-04-03 16:00 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=17720

Hannes Domani <ssbssa at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ssbssa at sourceware dot org
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |7.10
         Resolution|---                         |FIXED

--- Comment #2 from Hannes Domani <ssbssa at sourceware dot org> ---
(In reply to Martin Galvan from comment #1)
> Created attachment 8018 [details]
> Possible fix

This fix was applied here:
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=08a76f8ab86efbd5c85c9bd3979c4c06b9e84258

So it is fixed since 7.10.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2020-04-03 16:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-17 15:06 [Bug c++/17720] New: Function names appear without namespace/class prefixes in backtrace for optimized code martin.galvan at tallertechnologies dot com
2014-12-17 15:08 ` [Bug c++/17720] " martin.galvan at tallertechnologies dot com
2014-12-17 15:42 ` martin.galvan at tallertechnologies dot com
2014-12-18 17:48 ` martin.galvan at tallertechnologies dot com
2020-04-03 16:00 ` ssbssa at sourceware dot 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).