res = conf.CheckTempBufferStrategy()
# Standard library stuff
+res = conf.CheckCHeader("execinfo.h")
res = conf.FindCHeader("timerfd.h", [ 'sys', 'linux' ])
res = conf.CheckFunc("timerfd_create")
res = conf.CheckSymbolWithExpression(
#include <signal.h>
#include <time.h>
#include <cassert>
-#ifdef SENF_DEBUG
+#ifdef SENF_BACKTRACE
#include <execinfo.h>
#endif
#include <senf/config.hh>
if (task.runnable_) {
task.runnable_ = false;
runningName_ = task.name();
- # ifdef SENF_DEBUG
+# ifdef SENF_BACKTRACE
runningBacktrace_ = task.backtrace_;
- # endif
+# endif
TaskList::iterator i (next_);
++ next_;
tasks_.splice(l, tasks_, i);
senf::IGNORE( write(1, "): ", 3) );
senf::IGNORE( write(1, runningName_.c_str(), runningName_.size()) );
senf::IGNORE( write(1, " at\n ", 3) );
-#ifdef SENF_DEBUG
+#ifdef SENF_BACKTRACE
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];
Priority priority)
: Event(name), runnable_ (false), priority_ (priority)
{
-#ifdef SENF_DEBUG
+#ifdef SENF_BACKTRACE
std::stringstream ss;
backtrace(ss, 32);
backtrace_ = ss.str();
bool runnable_;
Priority priority_;
-# ifdef SENF_DEBUG
+# ifdef SENF_BACKTRACE
std::string backtrace_;
# endif
//#include "Backtrace.ih"
// Custom includes
-#ifdef SENF_DEBUG
+#ifdef SENF_BACKTRACE
#include <execinfo.h>
#endif
#include <cxxabi.h>
prefix_ void senf::formatBacktrace(std::ostream & os, void ** backtrace, unsigned numEntries)
{
-#ifdef SENF_DEBUG
+#ifdef SENF_BACKTRACE
char ** symbols (::backtrace_symbols(backtrace, numEntries));
static boost::regex const backtraceRx
prefix_ void senf::backtrace(std::ostream & os, unsigned numEntries)
{
-#ifdef SENF_DEBUG
+#ifdef SENF_BACKTRACE
SENF_SCOPED_BUFFER( void*, entries, numEntries);
unsigned n ( ::backtrace(entries, numEntries) );
senf::formatBacktrace(os, entries, n);
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
-#ifdef SENF_DEBUG
+#ifdef SENF_BACKTRACE
#include <execinfo.h>
#endif
#include <sstream>
if (sig == SIGSEGV)
std::cerr << "Invalid memory access at " << info->si_addr << "\n";
-
+#ifdef SENF_BACKTRACE
static void * entries[SENF_DEBUG_BACKTRACE_NUMCALLERS];
unsigned nEntries( ::backtrace(entries, SENF_DEBUG_BACKTRACE_NUMCALLERS) );
std::cerr << "Backtrace:\n";
senf::formatBacktrace(std::cerr, entries, nEntries);
std::cerr << "-- \n";
-
+#endif //SENF_BACKTRACE
if (sig != SIGUSR2) {
::signal(sig, SIG_DFL);
::kill(::getpid(), sig);
}
-#endif
+#endif // SENF_DEBUG
namespace {
void sighupHandler(int sig)
//#include "Exception.ih"
// Custom includes
-#ifdef SENF_DEBUG
+#ifdef SENF_BACKTRACE
#include <execinfo.h>
#endif
#include <sstream>
//-/////////////////////////////////////////////////////////////////////////////////////////////////
// senf::Exception
-#ifdef SENF_DEBUG
+#ifdef SENF_BACKTRACE
prefix_ void senf::ExceptionMixin::addBacktrace()
{
void * entries[SENF_DEBUG_BACKTRACE_NUMCALLERS];
prefix_ senf::ExceptionMixin::ExceptionMixin(std::string const & description)
: what_(description)
{
-#ifdef SENF_DEBUG
+#ifdef SENF_BACKTRACE
addBacktrace();
#endif
}
std::string what_;
private:
-#ifdef SENF_DEBUG
+#ifdef SENF_BACKTRACE
void addBacktrace();
+#endif
+#ifdef SENF_DEBUG
std::string::size_type excLen_;
#endif
};
# define SENF_PACKET_ANNOTATION_SLOTSIZE 16
# endif
#
-
+# ifdef SENF_DEBUG
+# ifdef HAVE_EXECINFO_H
+# define SENF_BACKTRACE
+# endif
+# endif
//-/////////////////////////////////////////////////////////////////////////////////////////////////
#endif