OLD | NEW |
1 #include "CrashHandler.h" | 1 #include "CrashHandler.h" |
2 | 2 |
3 #include "SkTypes.h" | 3 #include "SkTypes.h" |
4 | 4 |
5 #include <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #if defined(SK_BUILD_FOR_MAC) | 7 #if defined(SK_BUILD_FOR_MAC) |
8 | 8 |
9 // We only use local unwinding, so we can define this to select a faster impleme
ntation. | 9 // We only use local unwinding, so we can define this to select a faster impleme
ntation. |
10 #define UNW_LOCAL_ONLY | 10 #define UNW_LOCAL_ONLY |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 // We'd use libunwind here too, but it's a pain to get installed for both 32 and
64 bit on bots. | 42 // We'd use libunwind here too, but it's a pain to get installed for both 32 and
64 bit on bots. |
43 // Doesn't matter much: catchsegv is best anyway. | 43 // Doesn't matter much: catchsegv is best anyway. |
44 #include <execinfo.h> | 44 #include <execinfo.h> |
45 | 45 |
46 static void handler(int sig) { | 46 static void handler(int sig) { |
47 static const int kMax = 64; | 47 static const int kMax = 64; |
48 void* stack[kMax]; | 48 void* stack[kMax]; |
49 const int count = backtrace(stack, kMax); | 49 const int count = backtrace(stack, kMax); |
50 | 50 |
51 SkDebugf("\nSignal %d:\n", sig); | 51 SkDebugf("\nSignal %d [%s]:\n", sig, strsignal(sig)); |
52 backtrace_symbols_fd(stack, count, 2/*stderr*/); | 52 backtrace_symbols_fd(stack, count, 2/*stderr*/); |
53 | 53 |
54 // Exit NOW. Don't notify other threads, don't call anything registered wit
h atexit(). | 54 // Exit NOW. Don't notify other threads, don't call anything registered wit
h atexit(). |
55 _Exit(sig); | 55 _Exit(sig); |
56 } | 56 } |
57 | 57 |
58 #endif | 58 #endif |
59 | 59 |
60 #if defined(SK_BUILD_FOR_MAC) || (defined(SK_BUILD_FOR_UNIX) && !defined(SK_BUIL
D_FOR_NACL)) | 60 #if defined(SK_BUILD_FOR_MAC) || (defined(SK_BUILD_FOR_UNIX) && !defined(SK_BUIL
D_FOR_NACL)) |
61 #include <signal.h> | 61 #include <signal.h> |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 163 |
164 void SetupCrashHandler() { | 164 void SetupCrashHandler() { |
165 SetUnhandledExceptionFilter(handler); | 165 SetUnhandledExceptionFilter(handler); |
166 } | 166 } |
167 | 167 |
168 #else | 168 #else |
169 | 169 |
170 void SetupCrashHandler() { } | 170 void SetupCrashHandler() { } |
171 | 171 |
172 #endif | 172 #endif |
OLD | NEW |