Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2615)

Unified Diff: dm/DM.cpp

Issue 1753503002: print stack trace on crash, tweak formatting, _Exit hard (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: oops Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DM.cpp
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 4279ea37eb796eb5177390ccbbea9de212198c09..01902627870f8de661dce1f2be8194a283898a6f 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -165,23 +165,37 @@ static std::atomic<bool> in_signal_handler{false};
}
static void setup_crash_handler() { SetUnhandledExceptionFilter(handler); }
-#else
+#elif !defined(SK_BUILD_FOR_ANDROID)
+ #include <execinfo.h>
#include <signal.h>
+ #include <stdlib.h>
static void setup_crash_handler() {
const int kSignals[] = { SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV };
for (int sig : kSignals) {
signal(sig, [](int sig) {
if (!in_signal_handler.exchange(true)) {
- SkDebugf("\nCaught signal %d [%s].\n", sig, strsignal(sig));
- print_status();
+ SkAutoTAcquire<SkSpinlock> lock(gMutex);
+ SkDebugf("\nCaught signal %d [%s], was running:\n", sig, strsignal(sig));
+ for (auto& task : gRunning) {
+ SkDebugf("\t%s\n", task.c_str());
+ }
+
+ void* stack[64];
+ int count = backtrace(stack, SK_ARRAY_COUNT(stack));
+ char** symbols = backtrace_symbols(stack, count);
+ SkDebugf("\nStack trace:\n");
+ for (int i = 0; i < count; i++) {
+ SkDebugf(" %s\n", symbols[i]);
+ }
}
- // Reraise this signal to the default handler... hopefully, exit.
- signal(sig, SIG_DFL);
- raise(sig);
+ _Exit(sig);
});
}
}
+
+#else // Android
+ static void setup_crash_handler() {}
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698