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

Unified Diff: runtime/bin/platform_android.cc

Issue 2985963002: [standalone] Register a segfault handler on Android as already done on Linux. (Closed)
Patch Set: . Created 3 years, 5 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 | runtime/bin/platform_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/platform_android.cc
diff --git a/runtime/bin/platform_android.cc b/runtime/bin/platform_android.cc
index 87ee9aa715f1dcca9aa426452c6e65c3e32d07b7..2ea90778ce2388dbb5ee5e4f18347c5475312aca 100644
--- a/runtime/bin/platform_android.cc
+++ b/runtime/bin/platform_android.cc
@@ -22,6 +22,11 @@ char* Platform::resolved_executable_name_ = NULL;
int Platform::script_index_ = 1;
char** Platform::argv_ = NULL;
+static void segv_handler(int signal, siginfo_t* siginfo, void* context) {
+ Dart_DumpNativeStackTrace(context);
+ abort();
+}
+
bool Platform::Initialize() {
// Turn off the signal handler for SIGPIPE as it causes the process
// to terminate on writing to a closed pipe. Without the signal
@@ -33,6 +38,30 @@ bool Platform::Initialize() {
perror("Setting signal handler failed");
return false;
}
+
+ act.sa_flags = SA_SIGINFO;
+ act.sa_sigaction = &segv_handler;
+ if (sigemptyset(&act.sa_mask) != 0) {
+ perror("sigemptyset() failed.");
+ return false;
+ }
+ if (sigaddset(&act.sa_mask, SIGPROF) != 0) {
+ perror("sigaddset() failed");
+ return false;
+ }
+ if (sigaction(SIGSEGV, &act, NULL) != 0) {
+ perror("sigaction() failed.");
+ return false;
+ }
+ if (sigaction(SIGBUS, &act, NULL) != 0) {
+ perror("sigaction() failed.");
+ return false;
+ }
+ if (sigaction(SIGTRAP, &act, NULL) != 0) {
+ perror("sigaction() failed.");
+ return false;
+ }
+
return true;
}
« no previous file with comments | « no previous file | runtime/bin/platform_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698