From f5fa3219b477748a64c118a194a63bf719fdfb5f Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 13 Jun 2012 15:47:39 +1000 Subject: [PATCH] Use a simple deallocator for backtrace info Clang doesn't like using the array form of unique_ptr with backtrace calls for some reason. Less important to figure this out. --- backtrace_execinfo.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backtrace_execinfo.cpp b/backtrace_execinfo.cpp index a94b6baa..4a15340e 100644 --- a/backtrace_execinfo.cpp +++ b/backtrace_execinfo.cpp @@ -1,6 +1,7 @@ #include "backtrace.hpp" #include "debug.hpp" +#include "types/casts.hpp" #include #include @@ -14,7 +15,7 @@ debug::backtrace::backtrace (void): m_frames (DEFAULT_DEPTH) { int final; - while ((final = ::backtrace (&m_frames[0], m_frames.size ())) == m_frames.size ()) + while ((final = ::backtrace (&m_frames[0], m_frames.size ())) == sign_cast (m_frames.size ())) m_frames.resize (m_frames.size () * 2); CHECK_HARD (final > 0); @@ -26,11 +27,12 @@ ostream& debug::operator <<(ostream &os, const debug::backtrace &rhs) { const auto frames = rhs.frames (); - typedef unique_ptr unique_str; - unique_str names (backtrace_symbols (&frames[0], frames.size ()), std::free); + // We don't use the array form of unique_ptr as clang fails on ambigious constructors + typedef unique_ptr unique_str; + unique_str names (backtrace_symbols (frames.data (), frames.size ()), ::free); for (unsigned int i = 0; i < frames.size (); ++i) - os << frames[i] << "\t" << names[i] << "\n"; + os << frames[i] << "\t" << names.get()[i] << "\n"; return os; }