Scroom  0.14
Scroom::Utils::Detail Namespace Reference

Classes

class  ErrorSignalHandler
 
class  ProgressStore
 
class  Registration
 

Functions

void assertionFailed (std::string_view type, std::string_view expr, std::string_view function, std::string_view filename, unsigned int line) __attribute__((noreturn))
 
std::string stackTrace (size_t cutoff)
 
void abort () __attribute__((noreturn))
 

Variables

static ErrorSignalHandler errorSignalHandler
 

Function Documentation

◆ abort()

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

Referenced by assertionFailed(), Scroom::TiledBitmap::scheduleLoadingBitmap(), and anonymous_namespace{threadpoolimpl.cc}::ThreadList::wait().

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

◆ assertionFailed()

void Scroom::Utils::Detail::assertionFailed ( std::string_view  type,
std::string_view  expr,
std::string_view  function,
std::string_view  filename,
unsigned int  line 
)

Gets called when an assertion failed

55  {
56  spdlog::critical("PROGRAM DEFECTIVE: {}:{}: {} {} violated in {}", filename, line, type, expr, function);
57  spdlog::critical("Stack trace: {}", stackTrace(1));
58 
59  abort();
60  }
Here is the call graph for this function:

◆ stackTrace()

std::string Scroom::Utils::Detail::stackTrace ( size_t  cutoff)
24  {
25  std::stringstream os;
26 
27 #ifdef _WIN32
28  // Stack traces generated by this are not very informative, they just show the DLLs.
29  // Showing more than then DDLs would probably require an additional dependency
30  os << boost::stacktrace::stacktrace();
31  // Silence the compiler warning for unused variable
32  UNUSED(cutoff);
33 #else
34  os << "stack trace (innermost first):" << std::endl;
35  static const size_t maxTraces = 100;
36  void* array[maxTraces];
37  const size_t nTraces = backtrace(array, maxTraces);
38  char** strings = backtrace_symbols(array, static_cast<int>(nTraces));
39  for(size_t i = cutoff + 1; i < nTraces; i++)
40  {
41  os << '#' << i << " " << strings[i] << std::endl;
42  }
43  free(strings);
44 #endif
45  return os.str();
46  }

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

Here is the caller graph for this function:

Variable Documentation

◆ errorSignalHandler

ErrorSignalHandler Scroom::Utils::Detail::errorSignalHandler
static

Referenced by abort().

UNUSED
#define UNUSED(x)
Definition: unused.hh:10
Scroom::Utils::Detail::stackTrace
std::string stackTrace(size_t cutoff)
Definition: assertions.cc:23
Scroom::Utils::Detail::errorSignalHandler
static ErrorSignalHandler errorSignalHandler
Definition: assertions.cc:124
Scroom::Utils::Detail::abort
void abort() __attribute__((noreturn))
Definition: assertions.cc:126
Scroom::Utils::Detail::ErrorSignalHandler::handler
static void handler(int)
Definition: assertions.cc:75