OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "CrashHandler.h" | 8 #include "CrashHandler.h" |
9 #include "DMJsonWriter.h" | 9 #include "DMJsonWriter.h" |
10 #include "DMSrcSink.h" | 10 #include "DMSrcSink.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 158 } |
159 } | 159 } |
160 SkDebugf("\n"); | 160 SkDebugf("\n"); |
161 print_status(); | 161 print_status(); |
162 } | 162 } |
163 // Execute default exception handler... hopefully, exit. | 163 // Execute default exception handler... hopefully, exit. |
164 return EXCEPTION_EXECUTE_HANDLER; | 164 return EXCEPTION_EXECUTE_HANDLER; |
165 } | 165 } |
166 static void setup_crash_handler() { SetUnhandledExceptionFilter(handler); } | 166 static void setup_crash_handler() { SetUnhandledExceptionFilter(handler); } |
167 | 167 |
168 #else | 168 #elif !defined(SK_BUILD_FOR_ANDROID) |
| 169 #include <execinfo.h> |
169 #include <signal.h> | 170 #include <signal.h> |
| 171 #include <stdlib.h> |
170 | 172 |
171 static void setup_crash_handler() { | 173 static void setup_crash_handler() { |
172 const int kSignals[] = { SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV }; | 174 const int kSignals[] = { SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV }; |
173 for (int sig : kSignals) { | 175 for (int sig : kSignals) { |
174 signal(sig, [](int sig) { | 176 signal(sig, [](int sig) { |
175 if (!in_signal_handler.exchange(true)) { | 177 if (!in_signal_handler.exchange(true)) { |
176 SkDebugf("\nCaught signal %d [%s].\n", sig, strsignal(sig)); | 178 SkAutoTAcquire<SkSpinlock> lock(gMutex); |
177 print_status(); | 179 SkDebugf("\nCaught signal %d [%s], was running:\n", sig, str
signal(sig)); |
| 180 for (auto& task : gRunning) { |
| 181 SkDebugf("\t%s\n", task.c_str()); |
| 182 } |
| 183 |
| 184 void* stack[64]; |
| 185 int count = backtrace(stack, SK_ARRAY_COUNT(stack)); |
| 186 char** symbols = backtrace_symbols(stack, count); |
| 187 SkDebugf("\nStack trace:\n"); |
| 188 for (int i = 0; i < count; i++) { |
| 189 SkDebugf(" %s\n", symbols[i]); |
| 190 } |
178 } | 191 } |
179 // Reraise this signal to the default handler... hopefully, exit
. | 192 _Exit(sig); |
180 signal(sig, SIG_DFL); | |
181 raise(sig); | |
182 }); | 193 }); |
183 } | 194 } |
184 } | 195 } |
| 196 |
| 197 #else // Android |
| 198 static void setup_crash_handler() {} |
185 #endif | 199 #endif |
186 | 200 |
187 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 201 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
188 | 202 |
189 struct Gold : public SkString { | 203 struct Gold : public SkString { |
190 Gold() : SkString("") {} | 204 Gold() : SkString("") {} |
191 Gold(const SkString& sink, const SkString& src, | 205 Gold(const SkString& sink, const SkString& src, |
192 const SkString& srcOptions, const SkString& name, | 206 const SkString& srcOptions, const SkString& name, |
193 const SkString& md5) | 207 const SkString& md5) |
194 : SkString("") { | 208 : SkString("") { |
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 Reporter* reporter, | 1394 Reporter* reporter, |
1381 GrContextFactory* fac
tory); | 1395 GrContextFactory* fac
tory); |
1382 } // namespace skiatest | 1396 } // namespace skiatest |
1383 | 1397 |
1384 #if !defined(SK_BUILD_FOR_IOS) | 1398 #if !defined(SK_BUILD_FOR_IOS) |
1385 int main(int argc, char** argv) { | 1399 int main(int argc, char** argv) { |
1386 SkCommandLineFlags::Parse(argc, argv); | 1400 SkCommandLineFlags::Parse(argc, argv); |
1387 return dm_main(); | 1401 return dm_main(); |
1388 } | 1402 } |
1389 #endif | 1403 #endif |
OLD | NEW |