From 9ca093d98213667a144e455a7cf9662ec0896433 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 12 Sep 2018 14:01:21 +1000 Subject: [PATCH] backtrace: remove dependency on addr2line This wasn't functioning in any case so we may as well get rid of it. --- CMakeLists.txt | 9 --------- backtrace_execinfo.cpp | 37 +++++++++---------------------------- 2 files changed, 9 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2171fee6..e9a249f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,15 +54,6 @@ else () endif () -##----------------------------------------------------------------------------- -if (NOT WIN32) - find_program(ADDR2LINE NAMES addr2line) - if (ADDR2LINE) - add_definitions(-DADDR2LINE="${ADDR2LINE}") - endif() -endif () - - ############################################################################### # Platform wrappers if (LINUX) diff --git a/backtrace_execinfo.cpp b/backtrace_execinfo.cpp index f386aacd..657d1edf 100644 --- a/backtrace_execinfo.cpp +++ b/backtrace_execinfo.cpp @@ -36,42 +36,23 @@ debug::backtrace::backtrace (void): } -/////////////////////////////////////////////////////////////////////////////// -static std::string -addr2line (const void *addr) -{ -#if defined(ADDR2LINE) - using pstream_t = std::unique_ptr; - - std::ostringstream cmd; - cmd << ADDR2LINE << " -e " << cruft::image_path () << ' ' << std::hex << addr; - - pstream_t stream ( - ::popen (cmd.str ().c_str (), "r"), - ::pclose - ); - - // inefficient to copy from vector to string, but it's not a high priority path - auto data = cruft::slurp (stream.get ()); - return std::string (data.cbegin (), data.cend ()); - -#else - return ""; -#endif -} - - /////////////////////////////////////////////////////////////////////////////// std::ostream& debug::operator <<(std::ostream &os, const debug::backtrace &rhs) { auto const &frames = rhs.frames (); // We don't use the array form of unique_ptr as clang fails on ambigious constructors - typedef std::unique_ptr str_t; - str_t names (backtrace_symbols (frames.data (), cruft::cast::lossless (frames.size ())), ::free); + using str_t = std::unique_ptr; + str_t names ( + backtrace_symbols ( + frames.data (), + cruft::cast::lossless (frames.size ()) + ), + ::free + ); for (unsigned int i = 0; i < frames.size (); ++i) - os << frames[i] << '\t' << names.get()[i] << '\t' << addr2line (frames[i]); + os << frames[i] << '\t' << names.get()[i] << '\n'; return os; }