2018-04-09 13:06:02 +00:00
|
|
|
//
|
|
|
|
|
// A stacktrace handler for bitshares
|
|
|
|
|
//
|
2018-04-09 22:29:57 +00:00
|
|
|
#include <ostream>
|
2018-07-24 00:50:54 +00:00
|
|
|
#include <boost/version.hpp>
|
2018-04-09 13:06:02 +00:00
|
|
|
|
2018-11-13 01:57:58 +00:00
|
|
|
// only include stacktrace stuff if boost >= 1.65 and not macOS
|
2018-11-13 21:06:59 +00:00
|
|
|
#if BOOST_VERSION / 100 >= 1065 && !defined(__APPLE__)
|
2018-04-09 22:29:57 +00:00
|
|
|
#include <signal.h>
|
|
|
|
|
#include <fc/log/logger.hpp>
|
2018-04-09 13:06:02 +00:00
|
|
|
#include <boost/stacktrace.hpp>
|
|
|
|
|
|
|
|
|
|
namespace fc
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
static void segfault_signal_handler(int signum)
|
|
|
|
|
{
|
|
|
|
|
::signal(signum, SIG_DFL);
|
|
|
|
|
std::stringstream ss;
|
|
|
|
|
ss << boost::stacktrace::stacktrace();
|
|
|
|
|
elog(ss.str());
|
|
|
|
|
::raise(SIGABRT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void print_stacktrace_on_segfault()
|
|
|
|
|
{
|
|
|
|
|
::signal(SIGSEGV, &segfault_signal_handler);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void print_stacktrace(std::ostream& out)
|
|
|
|
|
{
|
|
|
|
|
out << boost::stacktrace::stacktrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#else
|
2018-04-09 13:59:58 +00:00
|
|
|
// Stacktrace output requires Boost 1.65 or above.
|
|
|
|
|
// Therefore calls to these methods do nothing.
|
2018-04-09 13:06:02 +00:00
|
|
|
namespace fc
|
|
|
|
|
{
|
|
|
|
|
void print_stacktrace_on_segfault() {}
|
|
|
|
|
void print_stacktrace(std::ostream& out) {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|