title: How to see useful information (filename, line no) in stacktrace of C++ program
body: <p>This is a complicated one since depends on Boost version and platform too.</p>
  
  <p>I'm using <a href="https://www.boost.org/doc/libs/1_69_0/doc/html/stacktrace/configuration_and_build.html" rel="nofollow noreferrer">boost stacktrace</a> 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 <code>BOOST_STACKTRACE_USE_ADDR2LINE</code> or <code>BOOST_STACKTRACE_USE_BACKTRACE</code> - all 3 show just addresses in the call stack for my actual program code - see below a stacktrace from a google-test test:</p>
  
  <pre><code> 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&lt;testing::Test, void&gt;(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
  </code></pre>
  
  <p>What I tried: -rdynamic, -fno-pie and -fPIC, (I'm already on -O0), -ggdb3 instead of the default -g3, <strong>nothing</strong> makes the function names to show up.</p>
  
  <p>Related: <a href="https://stackoverflow.com/questions/40751832/is-there-a-portable-standard-compliant-way-to-get-filenames-and-linenumbers-in-a">this</a>, <a href="https://stackoverflow.com/questions/3899870/print-call-stack-in-c-or-c/54365144#54365144">this</a>.</p>
  
  <p>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)</p>
  
  <hr>
  
  <p>Edit: updated link to latest boost.stacktrace.</p>
  
  <hr>
  
  <p>Edit2: I noticed the boost.stacktrace doc contains this hint</p>
  
  <blockquote>
    <p>Function names from shared libraries may not be decoded due to address space layout randomization. Still better than nothing.</p>
  </blockquote>
  
  <p>... 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 <code>libgtest.so</code> for example. So it's as if there is something wrong with the debug info setting. Any ideas appreciated.</p>