X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FException.cc;h=4c74f6cda185694ee17aed1976af5e381748e600;hb=d2459b6c8249291588fd3d0d125ed3d38e003b55;hp=cc87f615d59d9a89546b123d16f2498a0b7ee47f;hpb=553781d9e9bce316dca24ac4f0c42e5613e849e0;p=senf.git diff --git a/Utils/Exception.cc b/Utils/Exception.cc index cc87f61..4c74f6c 100644 --- a/Utils/Exception.cc +++ b/Utils/Exception.cc @@ -1,9 +1,9 @@ // $Id$ // -// Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// Copyright (C) 2006 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -27,28 +27,75 @@ //#include "Exception.ih" // Custom includes -#include +#include #include +#include "../config.hh" +#include "impl/demangle.h" #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -prefix_ void senf::SystemException::init() +/////////////////////////////////////////////////////////////////////////// +// senf::Exception + +#ifdef SENF_DEBUG +prefix_ void senf::ExceptionMixin::addBacktrace() { - // We normallyl don't want to consume memory in an exception, - // however all other solutions to format the message are terribly - // ugly (since thay must use a static and shared buffer ...) - std::stringstream s; - if (where) - s << where << ": "; - s << "(" << err << ") " << std::strerror(err); - buffer_ = s.str(); + 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