kernel/qcrashhandler.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10QtCrashHandler QSegfaultHandler::callback = 0; -
11 -
12 -
13 -
14 -
15 -
16static 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)
never evaluated: i>=0
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 {
never executed: }
0
28 for(int i = stack_size-1; i>=0; --i)
never evaluated: i>=0
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 }
never executed: }
0
31} -
32static void init_backtrace(char **, int) -
33{ -
34} -
35void 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 }
never executed: }
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 }
never executed: }
0
48 } else {
never executed: }
0
49 fprintf(outb, "Crash!!!\n"); -
50 }
never executed: }
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}
never executed: }
0
56 -
57 -
58void -
59QSegfaultHandler::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}
never executed: }
0
70 -
71 -
72 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial