// $Id$
//
-// Copyright (C) 2008
+// Copyright (C) 2008
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Stefan Bund <g0dil@berlios.de>
//#include "Backtrace.ih"
// Custom includes
-#include <execinfo.h>
+#ifdef SENF_DEBUG
+ #include <execinfo.h>
+#endif
#include <cxxabi.h>
#include <boost/regex.hpp>
#include "Buffer.hh"
//#include "Backtrace.mpp"
#define prefix_
-///////////////////////////////cc.p////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
prefix_ void senf::formatBacktrace(std::ostream & os, void ** backtrace, unsigned numEntries)
{
+#ifdef SENF_DEBUG
char ** symbols (::backtrace_symbols(backtrace, numEntries));
- static boost::regex const backtraceRx
+ static boost::regex const backtraceRx
("(.*)\\((.*)\\+(0x[0-9a-f]+)\\) \\[(0x[0-9a-f]+)\\]");
enum { File = 1,
Symbol = 2,
symbol = std::string(demangled);
free(demangled);
}
- os << " " << symbol << " + " << match[Offset]
+ os << " " << symbol << " + " << match[Offset]
<< "\n in " << match[File] << " [" << match[Address] << "]\n";
}
else if (sym == "[0xffffe410]")
os << " " << sym << "\n";
}
free(symbols);
+#endif
+#ifndef SENF_DEBUG
+ os << "no backtrace available please compile SENF without final=1\n";
+#endif
+
}
prefix_ void senf::backtrace(std::ostream & os, unsigned numEntries)
{
- SENF_SCOPED_BUFFER( void*, entries, numEntries);
- unsigned n ( ::backtrace(entries, numEntries) );
- senf::formatBacktrace(os, entries, n);
+#ifdef SENF_DEBUG
+ SENF_SCOPED_BUFFER( void*, entries, numEntries);
+ unsigned n ( ::backtrace(entries, numEntries) );
+ senf::formatBacktrace(os, entries, n);
+#endif
}
-///////////////////////////////cc.e////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
#undef prefix_
//#include "Backtrace.mpp"