14#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
15#include <win_printstack.hpp>
21#include <plask/config.hpp>
23#ifdef PRINT_STACKTRACE_ON_EXCEPTION
25#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
27inline void print_current_exception() {
28 std::exception_ptr
p = std::current_exception();
31 std::rethrow_exception (p);
32 }
catch (std::exception&
e) {
33 printf(
"Current exception: %s\n",
e.what());
35 printf(
"%s\n",
"Current exception is not std one.");
38 printf(
"%s\n",
"There is no current exception.");
41const char* sig_name(
int sig_nr) {
43 case SIGABRT:
return "SIGABRT";
44 case SIGSEGV:
return "SIGSEGV";
45 case SIGTERM:
return "SIGTERM";
50void plask_win_signal_handler (
int param) {
51 #pragma omp critical (winbacktrace)
53 printf(
"Signal %s (%d) handler:\n", sig_name(param), param);
54 print_current_exception();
60void plask_win_terminate_handler () {
61 #pragma omp critical (winbacktrace)
63 printf(
"Terminate handler:\n");
64 print_current_exception();
70struct PlaskWinRegisterSignalHandler {
71 PlaskWinRegisterSignalHandler() {
72 signal(SIGABRT, plask_win_signal_handler);
73 signal(SIGSEGV, plask_win_signal_handler);
74 signal(SIGTERM, plask_win_signal_handler);
75 std::set_terminate (plask_win_terminate_handler);
77} __plaskWinRegisterSignalHandler;
81#include <backward.hpp>
83 backward::SignalHandling sh;