Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qcrashhandler.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
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")
| 0 | ||||||
23 | dup2(fileno(outb), fileno(cppfilt)); | - | ||||||
24 | for(int i = stack_size-1; 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 | } never executed: else {end of block | 0 | ||||||
28 | for(int i = stack_size-1; 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: end of block | 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
| 0 | ||||||
39 | (*QSegfaultHandler::callback)(); | - | ||||||
40 | _exit(1); | - | ||||||
41 | } never executed: end of block | 0 | ||||||
42 | FILE *outb = stderr; | - | ||||||
43 | if(char *crash_loc = ::getenv("QT_CRASH_OUTPUT")
| 0 | ||||||
44 | if(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: end of block | 0 | ||||||
48 | } never executed: else {end of block | 0 | ||||||
49 | fprintf(outb, "Crash!!!\n"); | - | ||||||
50 | } never executed: end of block | 0 | ||||||
51 | print_backtrace(outb); | - | ||||||
52 | if(outb != stderr
| 0 | ||||||
53 | fclose(outb); never executed: fclose(outb); | 0 | ||||||
54 | _exit(1); | - | ||||||
55 | } never executed: end of block | 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 | } never executed: end of block | 0 | ||||||
70 | - | |||||||
71 | - | |||||||
Switch to Source code | Preprocessed file |