Skip to content

Instantly share code, notes, and snippets.

@Trass3r
Last active April 23, 2024 10:59
Show Gist options
  • Save Trass3r/589d07f36fd5a431331c2181731ed51d to your computer and use it in GitHub Desktop.
Save Trass3r/589d07f36fd5a431331c2181731ed51d to your computer and use it in GitHub Desktop.
boost stacktrace enabler
#define BOOST_STACKTRACE_USE_ADDR2LINE 1
//#define BOOST_STACKTRACE_USE_BACKTRACE 1
#include <boost/stacktrace.hpp>
#include <signal.h> // ::signal, ::raise
void my_signal_handler(int signum)
{
::signal(signum, SIG_DFL);
// boost::stacktrace::safe_dump_to("./backtrace.dump");
std::cout << boost::stacktrace::stacktrace();
::raise(SIGABRT);
}
int main(int argc, char* argv[])
{
::signal(SIGSEGV, &my_signal_handler);
::signal(SIGABRT, &my_signal_handler);
pthread_setname_np(pthread_self(), "MainThread");
#target_compile_definitions(${TARGET} PRIVATE BOOST_STACKTRACE_USE_BACKTRACE)
target_link_libraries(${TARGET} PRIVATE dl)
#target_link_libraries(${TARGET} PRIVATE backtrace)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment