backtrace: remove dependency on addr2line
This wasn't functioning in any case so we may as well get rid of it.
This commit is contained in:
parent
2ad86d28a5
commit
9ca093d982
@ -54,15 +54,6 @@ else ()
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
##-----------------------------------------------------------------------------
|
|
||||||
if (NOT WIN32)
|
|
||||||
find_program(ADDR2LINE NAMES addr2line)
|
|
||||||
if (ADDR2LINE)
|
|
||||||
add_definitions(-DADDR2LINE="${ADDR2LINE}")
|
|
||||||
endif()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Platform wrappers
|
# Platform wrappers
|
||||||
if (LINUX)
|
if (LINUX)
|
||||||
|
@ -36,42 +36,23 @@ debug::backtrace::backtrace (void):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
static std::string
|
|
||||||
addr2line (const void *addr)
|
|
||||||
{
|
|
||||||
#if defined(ADDR2LINE)
|
|
||||||
using pstream_t = std::unique_ptr<FILE,decltype(&::pclose)>;
|
|
||||||
|
|
||||||
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<char> (stream.get ());
|
|
||||||
return std::string (data.cbegin (), data.cend ());
|
|
||||||
|
|
||||||
#else
|
|
||||||
return "";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
std::ostream&
|
std::ostream&
|
||||||
debug::operator <<(std::ostream &os, const debug::backtrace &rhs) {
|
debug::operator <<(std::ostream &os, const debug::backtrace &rhs) {
|
||||||
auto const &frames = rhs.frames ();
|
auto const &frames = rhs.frames ();
|
||||||
|
|
||||||
// We don't use the array form of unique_ptr as clang fails on ambigious constructors
|
// We don't use the array form of unique_ptr as clang fails on ambigious constructors
|
||||||
typedef std::unique_ptr<char *, decltype(&std::free)> str_t;
|
using str_t = std::unique_ptr<char *, decltype(&std::free)>;
|
||||||
str_t names (backtrace_symbols (frames.data (), cruft::cast::lossless <int> (frames.size ())), ::free);
|
str_t names (
|
||||||
|
backtrace_symbols (
|
||||||
|
frames.data (),
|
||||||
|
cruft::cast::lossless <int> (frames.size ())
|
||||||
|
),
|
||||||
|
::free
|
||||||
|
);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < frames.size (); ++i)
|
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;
|
return os;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user