This is a complicated one since depends on Boost version and platform too.
I'm using boost stacktrace to print backtrace where some assertions fail. There are some external compile-time and run-time deps, depending on what mode you use (the link documents ~5 modes). I'd prefer something based on both debug info and exports info (the latter of which I presume would work in production builds too). But I can get to work neither of default mode or BOOST_STACKTRACE_USE_ADDR2LINE
or BOOST_STACKTRACE_USE_BACKTRACE
- all 3 show just addresses in the call stack for my actual program code - see below a stacktrace from a google-test test:
0# 0x000055E47D43BDC2 in Debug/myprog
1# 0x000055E47D489055 in Debug/myprog
2# 0x000055E47D567FDF in Debug/myprog
3# 0x000055E47D560CDE in Debug/myprog
4# void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) in /usr/lib/libgtest.so.1.8.1
5# testing::Test::Run() in /usr/lib/libgtest.so.1.8.1
6# testing::TestInfo::Run() in /usr/lib/libgtest.so.1.8.1
7# testing::TestCase::Run() in /usr/lib/libgtest.so.1.8.1
8# testing::internal::UnitTestImpl::RunAllTests() in /usr/lib/libgtest.so.1.8.1
What I tried: -rdynamic, -fno-pie and -fPIC, (I'm already on -O0), -ggdb3 instead of the default -g3, nothing makes the function names to show up.
I'm on: gcc 8.2, boost 1.69 (header-only mode for the stracktrace lib), Arch Linux (on this system I'd have to manually install libbacktrace which is not packaged so I'd prefer to go with the ADDR2LINE approach)
Edit: updated link to latest boost.stacktrace.
Edit2: I noticed the boost.stacktrace doc contains this hint
Function names from shared libraries may not be decoded due to address space layout randomization. Still better than nothing.
... which sounds helpful but for me it's the other way around, I'm not getting symbols in my own executable but I am for libgtest.so
for example. So it's as if there is something wrong with the debug info setting. Any ideas appreciated.
objdump -CD YOUR_BINARY
? – Meanderobjdump -CD
yes I can see the very symbols I should be seeing in the call stacks. – Overshineaddr2line
needs program address. It works only if program is loaded at 0x0 address, which is not true under some configurations (as in yours). – Curling