Cheetah Software  1.0
SegfaultHandler.cpp File Reference
#include "include/Utilities/SegfaultHandler.h"
#include <cstdio>
#include <execinfo.h>
#include <csignal>
#include <cstdlib>
#include <unistd.h>
#include <cstring>
#include <include/Utilities/Utilities_print.h>
+ Include dependency graph for SegfaultHandler.cpp:

Go to the source code of this file.

Functions

static void segfault_handler (int sig)
 
void install_segfault_handler ()
 

Function Documentation

void install_segfault_handler ( )

Definition at line 25 of file SegfaultHandler.cpp.

References segfault_handler().

25  {
26  signal(SIGSEGV, segfault_handler);
27 }
static void segfault_handler(int sig)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void segfault_handler ( int  sig)
static

Segfault handler to print stack trace on crash.

Definition at line 15 of file SegfaultHandler.cpp.

References fprintf_color(), and Red.

15  {
16  void* stack_frames[200];
17  int size = backtrace(stack_frames, 200);
18  fprintf_color(PrintColor::Red, stderr, "CRASH: Caught %d (%s)\n",
19  sig, strsignal(sig));
20  backtrace_symbols_fd(stack_frames, size, STDERR_FILENO);
21  exit(1);
22 }
void fprintf_color(PrintColor color, FILE *stream, const char *fmt,...)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: