X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FException.cc;h=737214da96347dc62763ff4750117b18d406902a;hb=fd3a0e8ac95d1158e9ea661ddf9187b67c70169f;hp=f94be754b992e56b8ee7a70c0dd2aa627f18619d;hpb=034f9bec0a66d26314fb6ebc83dedf1618a2c19d;p=senf.git diff --git a/Utils/Exception.cc b/Utils/Exception.cc index f94be75..737214d 100644 --- a/Utils/Exception.cc +++ b/Utils/Exception.cc @@ -27,6 +27,10 @@ //#include "Exception.ih" // Custom includes +#include +#include +#include "../config.hh" +#include "Backtrace.hh" #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// @@ -34,6 +38,23 @@ /////////////////////////////////////////////////////////////////////////// // senf::Exception +#ifdef SENF_DEBUG +prefix_ void senf::ExceptionMixin::addBacktrace() +{ + void * entries[SENF_DEBUG_BACKTRACE_NUMCALLERS]; + unsigned nEntries( ::backtrace(entries, SENF_DEBUG_BACKTRACE_NUMCALLERS) ); + + std::stringstream ss; + ss << "\nException at\n"; + formatBacktrace(ss, entries, nEntries); + ss << "-- \n" << message_; + what_ = ss.str(); +} +#endif + +/////////////////////////////////////////////////////////////////////////// +// senf::Exception + prefix_ senf::Exception::~Exception() throw() {} @@ -41,7 +62,7 @@ prefix_ senf::Exception::~Exception() prefix_ char const * senf::Exception::what() const throw() { - return message_.c_str(); + return what_.c_str(); } ///////////////////////////////////////////////////////////////////////////