X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FException.cc;h=c86dade4de885d53b8ec5e424cef80ae80451efc;hb=8ec0b7ed2df36144b52df5aa40497fc5409c31f7;hp=f94be754b992e56b8ee7a70c0dd2aa627f18619d;hpb=18ebf1e9edb34f1aa8a32173275421a5d54400f7;p=senf.git diff --git a/Utils/Exception.cc b/Utils/Exception.cc index f94be75..c86dade 100644 --- a/Utils/Exception.cc +++ b/Utils/Exception.cc @@ -27,6 +27,10 @@ //#include "Exception.ih" // Custom includes +#include +#include +#include "../config.hh" +#include "impl/demangle.h" #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// @@ -44,6 +48,38 @@ prefix_ char const * senf::Exception::what() return message_.c_str(); } +#ifdef SENF_DEBUG +prefix_ void senf::Exception::addBacktrace() +{ + void * entries[SENF_DEBUG_BACKTRACE_NUMCALLERS]; + unsigned nEntries( ::backtrace(entries, SENF_DEBUG_BACKTRACE_NUMCALLERS) ); + char ** symbols = ::backtrace_symbols(entries, nEntries); + + std::stringstream ss; + ss << "\nException at\n"; + for (unsigned i=0; i