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: jscott@citra:/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; } jscott@citra:/tmp$ g++ -o foo -g foo.cpp -O0 -Wall -Wextra jscott@citra:/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)jscott@citra:/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. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils