1 // Copyright Antony Polukhin, 2016-2018.
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 //[getting_started_debug_function
8 #include <signal.h> // ::signal
9 #include <boost/stacktrace/frame.hpp>
10 #include <iostream> // std::cerr
11 #include <cstdlib> // std::exit
13 void print_signal_handler_and_exit() {
14 typedef void(*function_t
)(int);
16 function_t old_signal_function
= ::signal(SIGSEGV
, SIG_DFL
);
17 boost::stacktrace::frame
f(old_signal_function
);
18 std::cout
<< f
<< std::endl
;
24 void my_signal_handler(int /*signum*/) {
29 ::signal(SIGSEGV
, &my_signal_handler
);
30 print_signal_handler_and_exit();