From: tho Date: Mon, 6 Jun 2011 16:32:21 +0000 (+0000) Subject: hopefully fixes for backtrace handling X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=19ff129ad7beefdf7e79e8ea9da7fb18e8a06aff;p=senf.git hopefully fixes for backtrace handling git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1790 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Scheduler/FIFORunner.cc b/senf/Scheduler/FIFORunner.cc index 4368729..295e10e 100644 --- a/senf/Scheduler/FIFORunner.cc +++ b/senf/Scheduler/FIFORunner.cc @@ -294,8 +294,8 @@ prefix_ void senf::scheduler::detail::FIFORunner::watchdogError() static char const hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; static void * entries[SENF_DEBUG_BACKTRACE_NUMCALLERS]; - unsigned nEntries( ::backtrace(entries, SENF_DEBUG_BACKTRACE_NUMCALLERS) ); - for (unsigned i (0); i < nEntries; ++i) { + int nEntries( ::backtrace(entries, SENF_DEBUG_BACKTRACE_NUMCALLERS) ); + for (int i=0; i < nEntries; ++i) { senf::IGNORE( write(1, " 0x", 3) ); for (unsigned j (sizeof(void*)); j > 0; --j) { uintptr_t v ( reinterpret_cast(entries[i]) >> (8*(j-1)) ); @@ -306,7 +306,7 @@ prefix_ void senf::scheduler::detail::FIFORunner::watchdogError() #endif senf::IGNORE( write(1, "\n", 1) ); -#ifdef SENF_DEBUG +#ifdef SENF_BACKTRACE senf::IGNORE( write(1, "Task was initialized at\n", 24) ); senf::IGNORE( write(1, runningBacktrace_.c_str(), runningBacktrace_.size()) ); #endif diff --git a/senf/Scheduler/FIFORunner.cci b/senf/Scheduler/FIFORunner.cci index 8bd6caf..c241335 100644 --- a/senf/Scheduler/FIFORunner.cci +++ b/senf/Scheduler/FIFORunner.cci @@ -43,7 +43,7 @@ prefix_ senf::scheduler::detail::FIFORunner::TaskInfo::TaskInfo(std::string cons { #ifdef SENF_BACKTRACE std::stringstream ss; - backtrace(ss, 32); + senf::backtrace(ss, 32); backtrace_ = ss.str(); #endif } diff --git a/senf/Utils/Backtrace.cc b/senf/Utils/Backtrace.cc index 039cffc..411a33c 100644 --- a/senf/Utils/Backtrace.cc +++ b/senf/Utils/Backtrace.cc @@ -30,6 +30,7 @@ #include #ifdef SENF_BACKTRACE #include + #include #endif #include #include @@ -39,10 +40,14 @@ #define prefix_ //-///////////////////////////////////////////////////////////////////////////////////////////////// -prefix_ void senf::formatBacktrace(std::ostream & os, void ** backtrace, unsigned numEntries) +prefix_ void senf::formatBacktrace(std::ostream & os, void ** backtrace, int numEntries) { #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 ("(.*)\\((.*)\\+(0x[0-9a-f]+)\\) \\[(0x[0-9a-f]+)\\]"); @@ -51,7 +56,7 @@ prefix_ void senf::formatBacktrace(std::ostream & os, void ** backtrace, unsigne Offset = 3, Address = 4 }; - for (unsigned i=0; isi_addr << "\n"; #ifdef SENF_BACKTRACE static void * entries[SENF_DEBUG_BACKTRACE_NUMCALLERS]; - unsigned nEntries( ::backtrace(entries, SENF_DEBUG_BACKTRACE_NUMCALLERS) ); + int nEntries( ::backtrace(entries, SENF_DEBUG_BACKTRACE_NUMCALLERS) ); // Hack the callers address into the backtrace // entries[1] = reinterpret_cast(ucontext->uc_mcontext.gregs[REG_EIP]); diff --git a/senf/Utils/Exception.cc b/senf/Utils/Exception.cc index aeb7aaa..5c90493 100644 --- a/senf/Utils/Exception.cc +++ b/senf/Utils/Exception.cc @@ -43,7 +43,7 @@ prefix_ void senf::ExceptionMixin::addBacktrace() { void * entries[SENF_DEBUG_BACKTRACE_NUMCALLERS]; - unsigned nEntries (::backtrace(entries, SENF_DEBUG_BACKTRACE_NUMCALLERS)); + int nEntries (::backtrace(entries, SENF_DEBUG_BACKTRACE_NUMCALLERS)); std::stringstream ss; ss << "\nException at\n";