Cheetah Software
1.0
Main Page
Namespaces
Classes
Files
File List
File Members
SegfaultHandler.cpp
Go to the documentation of this file.
1
5
#include "
include/Utilities/SegfaultHandler.h
"
6
#include <cstdio>
7
#include <execinfo.h>
8
#include <csignal>
9
#include <cstdlib>
10
#include <unistd.h>
11
#include <cstring>
12
#include <
include/Utilities/Utilities_print.h
>
13
14
15
static
void
segfault_handler
(
int
sig) {
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
}
23
24
25
void
install_segfault_handler
() {
26
signal(SIGSEGV,
segfault_handler
);
27
}
install_segfault_handler
void install_segfault_handler()
Definition:
SegfaultHandler.cpp:25
segfault_handler
static void segfault_handler(int sig)
Definition:
SegfaultHandler.cpp:15
fprintf_color
void fprintf_color(PrintColor color, FILE *stream, const char *fmt,...)
Definition:
Utilities_print.cpp:13
PrintColor::Red
Utilities_print.h
SegfaultHandler.h
home
dhkim
Public_Repository
Cheetah-Software
common
src
Utilities
SegfaultHandler.cpp
Generated by
1.8.11