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

Side by Side Diff: runtime/bin/platform_macos.cc

Issue 2514113002: Dump stack trace on segfault in the VM. (Closed)
Patch Set: fix build Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include "bin/platform.h" 8 #include "bin/platform.h"
9 9
10 #if !TARGET_OS_IOS 10 #if !TARGET_OS_IOS
(...skipping 10 matching lines...) Expand all
21 #include "bin/file.h" 21 #include "bin/file.h"
22 22
23 namespace dart { 23 namespace dart {
24 namespace bin { 24 namespace bin {
25 25
26 const char* Platform::executable_name_ = NULL; 26 const char* Platform::executable_name_ = NULL;
27 char* Platform::resolved_executable_name_ = NULL; 27 char* Platform::resolved_executable_name_ = NULL;
28 int Platform::script_index_ = 1; 28 int Platform::script_index_ = 1;
29 char** Platform::argv_ = NULL; 29 char** Platform::argv_ = NULL;
30 30
31
32 static void segv_handler(int signal, siginfo_t* siginfo, void* context) {
33 Dart_DumpNativeStackTrace(context);
34 abort();
35 }
36
31 bool Platform::Initialize() { 37 bool Platform::Initialize() {
32 // Turn off the signal handler for SIGPIPE as it causes the process 38 // Turn off the signal handler for SIGPIPE as it causes the process
33 // to terminate on writing to a closed pipe. Without the signal 39 // to terminate on writing to a closed pipe. Without the signal
34 // handler error EPIPE is set instead. 40 // handler error EPIPE is set instead.
35 struct sigaction act; 41 struct sigaction act;
36 bzero(&act, sizeof(act)); 42 bzero(&act, sizeof(act));
37 act.sa_handler = SIG_IGN; 43 act.sa_handler = SIG_IGN;
38 if (sigaction(SIGPIPE, &act, 0) != 0) { 44 if (sigaction(SIGPIPE, &act, 0) != 0) {
39 perror("Setting signal handler failed"); 45 perror("Setting signal handler failed");
40 return false; 46 return false;
41 } 47 }
48 act.sa_flags = SA_SIGINFO;
49 act.sa_sigaction = &segv_handler;
50 if (sigemptyset(&act.sa_mask) != 0) {
51 perror("sigemptyset() failed.");
52 return false;
53 }
54 if (sigaddset(&act.sa_mask, SIGPROF) != 0) {
55 perror("sigaddset() failed");
56 return false;
57 }
58 if (sigaction(SIGSEGV, &act, NULL) != 0) {
59 perror("sigaction() failed.");
60 return false;
61 }
42 return true; 62 return true;
43 } 63 }
44 64
45 65
46 int Platform::NumberOfProcessors() { 66 int Platform::NumberOfProcessors() {
47 int32_t cpus = -1; 67 int32_t cpus = -1;
48 size_t cpus_length = sizeof(cpus); 68 size_t cpus_length = sizeof(cpus);
49 if (sysctlbyname("hw.logicalcpu", &cpus, &cpus_length, NULL, 0) == 0) { 69 if (sysctlbyname("hw.logicalcpu", &cpus, &cpus_length, NULL, 0) == 0) {
50 return cpus; 70 return cpus;
51 } else { 71 } else {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 151
132 152
133 void Platform::Exit(int exit_code) { 153 void Platform::Exit(int exit_code) {
134 exit(exit_code); 154 exit(exit_code);
135 } 155 }
136 156
137 } // namespace bin 157 } // namespace bin
138 } // namespace dart 158 } // namespace dart
139 159
140 #endif // defined(TARGET_OS_MACOS) 160 #endif // defined(TARGET_OS_MACOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698