Scroom  0.14
Scroom::Utils::Detail::ErrorSignalHandler Class Reference
Collaboration diagram for Scroom::Utils::Detail::ErrorSignalHandler:
Collaboration graph

Public Member Functions

 ErrorSignalHandler () noexcept
 

Static Private Member Functions

static void handler (int)
 

Static Private Attributes

static volatile sig_atomic_t isHandlerActive = 0
 

Friends

void abort ()
 

Constructor & Destructor Documentation

◆ ErrorSignalHandler()

Scroom::Utils::Detail::ErrorSignalHandler::ErrorSignalHandler ( )
noexcept
113  {
114  signal(SIGFPE, handler);
115  signal(SIGILL, handler);
116  signal(SIGABRT, handler);
117  signal(SIGSEGV, handler);
118 #ifndef _WIN32
119  signal(SIGBUS, handler);
120  signal(SIGSYS, handler);
121 #endif
122  }
Here is the call graph for this function:

Member Function Documentation

◆ handler()

void Scroom::Utils::Detail::ErrorSignalHandler::handler ( int  sig)
staticprivate
76  {
77  if(!isHandlerActive)
78  {
79  isHandlerActive = 1;
80  std::cerr << __FILE__ << ":" << __LINE__ << ": Entering signal handler" << std::endl;
81 #ifdef _WIN32
82  std::string_view sigName;
83  switch(sig)
84  {
85  case SIGFPE:
86  sigName = "SIGFPE";
87  break;
88  case SIGILL:
89  sigName = "SIGILL";
90  break;
91  case SIGABRT:
92  sigName = "SIGABRT";
93  break;
94  case SIGSEGV:
95  sigName = "SIGSEGV";
96  break;
97  }
98 #else
99  std::string_view const sigName = strsignal(sig); // NOLINT(concurrency-mt-unsafe)
100 #endif
101  std::cerr << "PROGRAM DEFECTIVE (TERMINATED BY SIGNAL): " << sigName << std::endl;
102  std::cerr << stackTrace(1);
103  std::cerr << std::endl;
104  std::cerr << __FILE__ << ":" << __LINE__ << ": Leaving signal handler" << std::endl;
105  std::cerr << std::flush;
106  }
107 
108  signal(sig, SIG_DFL);
109  raise(sig);
110  }

Referenced by Scroom::Utils::Detail::abort(), and ErrorSignalHandler().

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ abort

void abort ( )
friend
127  {
128  signal(SIGABRT, SIG_DFL);
129  ::abort();
130  signal(SIGABRT, errorSignalHandler.handler);
131  }

Referenced by Scroom::Utils::Detail::abort().

Member Data Documentation

◆ isHandlerActive

volatile sig_atomic_t Scroom::Utils::Detail::ErrorSignalHandler::isHandlerActive = 0
staticprivate

Referenced by handler().


The documentation for this class was generated from the following file:
Scroom::Utils::Detail::stackTrace
std::string stackTrace(size_t cutoff)
Definition: assertions.cc:23
Scroom::Utils::Detail::ErrorSignalHandler::isHandlerActive
static volatile sig_atomic_t isHandlerActive
Definition: assertions.cc:66
Scroom::Utils::Detail::ErrorSignalHandler::abort
friend void abort()
Definition: assertions.cc:126
Scroom::Utils::Detail::errorSignalHandler
static ErrorSignalHandler errorSignalHandler
Definition: assertions.cc:124
Scroom::Utils::Detail::ErrorSignalHandler::handler
static void handler(int)
Definition: assertions.cc:75