bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/17541] New: addr2line: function names in anonymous namespa


From: toojays at toojays dot net
Subject: [Bug binutils/17541] New: addr2line: function names in anonymous namespaces are incorrectly reported.
Date: Tue, 04 Nov 2014 05:28:53 +0000

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

            Bug ID: 17541
           Summary: addr2line: function names in anonymous namespaces are
                    incorrectly reported.
           Product: binutils
           Version: 2.25
            Status: NEW
          Severity: normal
          Priority: P2
         Component: binutils
          Assignee: unassigned at sourceware dot org
          Reporter: toojays at toojays dot net

When addr2line is asked to print a function name for a C++ method in an
anonymous namespace, it prints only the method name. It does not include the
namespace, class, or method argument list. This occurs regardless of whether
the --demangle argument is given on the command line. This means there is no
way to get the correct mangled name from addr2line.

Testcase:

address@hidden:/tmp$ cat foo.cpp 
#include <stdio.h>
#include <execinfo.h>

namespace ns {
namespace {

class A
{
public:
  A (int x);

private:
  int m_x;
};

A::A (int x) : m_x(x)
{
  void *bt_buffer[10];
  int depth = ::backtrace(bt_buffer, sizeof(bt_buffer)/sizeof(bt_buffer[0]));
  char **bt = ::backtrace_symbols(bt_buffer, depth);
  ::printf("%s\n", *bt);
}

} /* unnamed namespace */
} /* namespace ns */

int main (void)
{
  ns::A a(1);
  return 0;
}
address@hidden:/tmp$ g++ -o foo -g foo.cpp -O0 -Wall -Wextra
address@hidden:/tmp$ ./foo | sed -ne 's/.*\[\(.*\)\].*/\1/p' | addr2line -f 
--exe
./foo -C
A
/tmp/foo.cpp:19



This issue occurs with at least the following versions:
2.25.51.20141103 (git)
GNU addr2line (GNU Binutils for Ubuntu) 2.24
GNU addr2line version 2.23.52.0.1-8.el6 20130226

It does not occur with:
GNU addr2line version 2.20.51.0.2-5.36.el6 20100205

With this version, the above testcase (using the same binary as before, built
with GCC 4.9.1) looks like:

(centos-6)address@hidden:/tmp$ ./foo | sed -ne 's/.*\[\(.*\)\].*/\1/p' |
addr2line -f --exe ./foo -C
ns::(anonymous namespace)::A::A(int)
foo.cpp:0


So it seems that with old binutils, I can get the correct function name, but
the wrong line number. With the new binutils, I can get the correct line
number, but the wrong function name. Any way we can fix it so I can have both?
:)


[If I run my "old" addr2line against a binary built with the corresponding
"old" GCC (4.4.7 on Centos 6), it shows the same wrong behaviour as the "new"
addr2line: correct line number, incorrect function name. Likewise if I build
with GCC 4.9.1, but with -gdwarf-2.]

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]