From: jmo Date: Thu, 7 Apr 2011 12:35:05 +0000 (+0000) Subject: change for selective Backtrace (SENF_BACKTRACE). Included via autoconf if SENF_DEBUG... X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=e05437de40eb79af1075c5186820d639db42e105;p=senf.git change for selective Backtrace (SENF_BACKTRACE). Included via autoconf if SENF_DEBUG is set. git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1779 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/SConfigure b/SConfigure index 906b0bc..b7f1a2f 100644 --- a/SConfigure +++ b/SConfigure @@ -86,6 +86,7 @@ res = conf.CheckCXXHeader("boost/bimap.hpp"); \ 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( diff --git a/senf/Scheduler/FIFORunner.cc b/senf/Scheduler/FIFORunner.cc index 915d853..2160439 100644 --- a/senf/Scheduler/FIFORunner.cc +++ b/senf/Scheduler/FIFORunner.cc @@ -30,7 +30,7 @@ #include #include #include -#ifdef SENF_DEBUG +#ifdef SENF_BACKTRACE #include #endif #include @@ -229,9 +229,9 @@ prefix_ void senf::scheduler::detail::FIFORunner::run(TaskList::iterator f, Task 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); @@ -291,7 +291,7 @@ prefix_ void senf::scheduler::detail::FIFORunner::watchdogError() 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]; diff --git a/senf/Scheduler/FIFORunner.cci b/senf/Scheduler/FIFORunner.cci index 87b428e..8bd6caf 100644 --- a/senf/Scheduler/FIFORunner.cci +++ b/senf/Scheduler/FIFORunner.cci @@ -41,7 +41,7 @@ prefix_ senf::scheduler::detail::FIFORunner::TaskInfo::TaskInfo(std::string cons Priority priority) : Event(name), runnable_ (false), priority_ (priority) { -#ifdef SENF_DEBUG +#ifdef SENF_BACKTRACE std::stringstream ss; backtrace(ss, 32); backtrace_ = ss.str(); diff --git a/senf/Scheduler/FIFORunner.hh b/senf/Scheduler/FIFORunner.hh index 2820442..6b9e35b 100644 --- a/senf/Scheduler/FIFORunner.hh +++ b/senf/Scheduler/FIFORunner.hh @@ -79,7 +79,7 @@ namespace detail { bool runnable_; Priority priority_; -# ifdef SENF_DEBUG +# ifdef SENF_BACKTRACE std::string backtrace_; # endif diff --git a/senf/Utils/Backtrace.cc b/senf/Utils/Backtrace.cc index 9312f55..f057e6d 100644 --- a/senf/Utils/Backtrace.cc +++ b/senf/Utils/Backtrace.cc @@ -27,7 +27,7 @@ //#include "Backtrace.ih" // Custom includes -#ifdef SENF_DEBUG +#ifdef SENF_BACKTRACE #include #endif #include @@ -40,7 +40,7 @@ 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 @@ -83,7 +83,7 @@ prefix_ void senf::formatBacktrace(std::ostream & os, void ** backtrace, unsigne 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); diff --git a/senf/Utils/Daemon/Daemon.cc b/senf/Utils/Daemon/Daemon.cc index 0923647..f39db19 100644 --- a/senf/Utils/Daemon/Daemon.cc +++ b/senf/Utils/Daemon/Daemon.cc @@ -35,7 +35,7 @@ #include #include #include -#ifdef SENF_DEBUG +#ifdef SENF_BACKTRACE #include #endif #include @@ -520,7 +520,7 @@ namespace { 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) ); @@ -530,7 +530,7 @@ namespace { 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); @@ -539,7 +539,7 @@ namespace { } -#endif +#endif // SENF_DEBUG namespace { void sighupHandler(int sig) diff --git a/senf/Utils/Exception.cc b/senf/Utils/Exception.cc index 39b9503..1104513 100644 --- a/senf/Utils/Exception.cc +++ b/senf/Utils/Exception.cc @@ -27,7 +27,7 @@ //#include "Exception.ih" // Custom includes -#ifdef SENF_DEBUG +#ifdef SENF_BACKTRACE #include #endif #include @@ -40,7 +40,7 @@ //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::Exception -#ifdef SENF_DEBUG +#ifdef SENF_BACKTRACE prefix_ void senf::ExceptionMixin::addBacktrace() { void * entries[SENF_DEBUG_BACKTRACE_NUMCALLERS]; diff --git a/senf/Utils/Exception.cci b/senf/Utils/Exception.cci index d97c9ab..20bcfd8 100644 --- a/senf/Utils/Exception.cci +++ b/senf/Utils/Exception.cci @@ -33,7 +33,7 @@ prefix_ senf::ExceptionMixin::ExceptionMixin(std::string const & description) : what_(description) { -#ifdef SENF_DEBUG +#ifdef SENF_BACKTRACE addBacktrace(); #endif } diff --git a/senf/Utils/Exception.hh b/senf/Utils/Exception.hh index 87d2055..c302003 100644 --- a/senf/Utils/Exception.hh +++ b/senf/Utils/Exception.hh @@ -156,8 +156,10 @@ namespace senf { std::string what_; private: -#ifdef SENF_DEBUG +#ifdef SENF_BACKTRACE void addBacktrace(); +#endif +#ifdef SENF_DEBUG std::string::size_type excLen_; #endif }; diff --git a/senf/config.hh b/senf/config.hh index 5bdf0cf..4e26793 100644 --- a/senf/config.hh +++ b/senf/config.hh @@ -96,7 +96,11 @@ namespace config { # define SENF_PACKET_ANNOTATION_SLOTSIZE 16 # endif # - +# ifdef SENF_DEBUG +# ifdef HAVE_EXECINFO_H +# define SENF_BACKTRACE +# endif +# endif //-///////////////////////////////////////////////////////////////////////////////////////////////// #endif