Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | QtCrashHandler QSegfaultHandler::callback = 0; | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | static void print_backtrace(FILE *outb) | - |
17 | { | - |
18 | void *stack[128]; | - |
19 | int stack_size = backtrace(stack, sizeof(stack) / sizeof(void *)); | - |
20 | char **stack_symbols = backtrace_symbols(stack, stack_size); | - |
21 | fprintf(outb, "Stack [%d]:\n", stack_size); | - |
22 | if(FILE *cppfilt = popen("c++filt", "rw")) { never evaluated: FILE *cppfilt = popen("c++filt", "rw") | 0 |
23 | dup2(fileno(outb), fileno(cppfilt)); | - |
24 | for(int i = stack_size-1; i>=0; --i) | 0 |
25 | fwrite(stack_symbols[i], 1, strlen(stack_symbols[i]), cppfilt); never executed: fwrite(stack_symbols[i], 1, strlen(stack_symbols[i]), cppfilt); | 0 |
26 | pclose(cppfilt); | - |
27 | } else { | 0 |
28 | for(int i = stack_size-1; i>=0; --i) | 0 |
29 | fprintf(outb, "#%d %p [%s]\n", i, stack[i], stack_symbols[i]); never executed: fprintf(outb, "#%d %p [%s]\n", i, stack[i], stack_symbols[i]); | 0 |
30 | } | 0 |
31 | } | - |
32 | static void init_backtrace(char **, int) | - |
33 | { | - |
34 | } | - |
35 | void qt_signal_handler(int sig) | - |
36 | { | - |
37 | signal(sig, ((__sighandler_t) 0)); | - |
38 | if(QSegfaultHandler::callback) { never evaluated: QSegfaultHandler::callback | 0 |
39 | (*QSegfaultHandler::callback)(); | - |
40 | _exit(1); | - |
41 | } | 0 |
42 | FILE *outb = stderr; | - |
43 | if(char *crash_loc = ::getenv("QT_CRASH_OUTPUT")) { never evaluated: char *crash_loc = ::getenv("QT_CRASH_OUTPUT") | 0 |
44 | if(FILE *new_outb = fopen(crash_loc, "w")) { never evaluated: FILE *new_outb = fopen(crash_loc, "w") | 0 |
45 | fprintf(stderr, "Crash (backtrace written to %s)!!!\n", crash_loc); | - |
46 | outb = new_outb; | - |
47 | } | 0 |
48 | } else { | 0 |
49 | fprintf(outb, "Crash!!!\n"); | - |
50 | } | 0 |
51 | print_backtrace(outb); | - |
52 | if(outb != stderr) never evaluated: outb != stderr | 0 |
53 | fclose(outb); never executed: fclose(outb); | 0 |
54 | _exit(1); | - |
55 | } | 0 |
56 | | - |
57 | | - |
58 | void | - |
59 | QSegfaultHandler::initialize(char **argv, int argc) | - |
60 | { | - |
61 | init_backtrace(argv, argc); | - |
62 | | - |
63 | struct sigaction SignalAction; | - |
64 | SignalAction.sa_flags = 0; | - |
65 | SignalAction.__sigaction_handler.sa_handler = qt_signal_handler; | - |
66 | sigemptyset(&SignalAction.sa_mask); | - |
67 | sigaction(11, &SignalAction, __null); | - |
68 | sigaction(7, &SignalAction, __null); | - |
69 | } | 0 |
70 | | - |
71 | | - |
72 | | - |
| | |