X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FUtils%2FBacktrace.cc;h=411a33c4366c8328d19f97ef30a5ebfd050cdb56;hb=19ff129ad7beefdf7e79e8ea9da7fb18e8a06aff;hp=3bd09c0e586e76f00481aaccc09862c80ae3d0e4;hpb=6f7f9658177cc8937e5e796eeec0027dd4850966;p=senf.git diff --git a/senf/Utils/Backtrace.cc b/senf/Utils/Backtrace.cc index 3bd09c0..411a33c 100644 --- a/senf/Utils/Backtrace.cc +++ b/senf/Utils/Backtrace.cc @@ -1,6 +1,6 @@ // $Id$ // -// Copyright (C) 2008 +// Copyright (C) 2008 // Fraunhofer Institute for Open Communication Systems (FOKUS) // Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund @@ -27,8 +27,10 @@ //#include "Backtrace.ih" // Custom includes -#ifdef SENF_DEBUG - #include +#include +#ifdef SENF_BACKTRACE + #include + #include #endif #include #include @@ -36,21 +38,25 @@ //#include "Backtrace.mpp" #define prefix_ -///////////////////////////////cc.p//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// -prefix_ void senf::formatBacktrace(std::ostream & os, void ** backtrace, unsigned numEntries) +prefix_ void senf::formatBacktrace(std::ostream & os, void ** backtrace, int numEntries) { -#ifdef SENF_DEBUG +#ifdef SENF_BACKTRACE char ** symbols (::backtrace_symbols(backtrace, numEntries)); + if (symbols == NULL) { + os << "error on translating backtrace addresses with ::backtrace_symbols: " << std::strerror(errno); + return; + } - static boost::regex const backtraceRx + static boost::regex const backtraceRx ("(.*)\\((.*)\\+(0x[0-9a-f]+)\\) \\[(0x[0-9a-f]+)\\]"); enum { File = 1, Symbol = 2, Offset = 3, Address = 4 }; - for (unsigned i=0; i