blob: 55dfb0fc94fd34015c2fdd53f2e369b49c80f2d5 [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Elliott Hughesffe67362011-07-17 12:09:27 -070016
17#include "runtime.h"
18
Elliott Hughes457005c2012-04-16 13:54:25 -070019#include <signal.h>
Elliott Hughes6c1c69e2012-04-23 16:12:51 -070020#include <string.h>
Elliott Hughes058a6de2012-05-24 19:13:02 -070021#include <sys/utsname.h>
Dmitry Petrochenko611c2c32014-02-10 14:48:12 +070022#include <inttypes.h>
Elliott Hughesffe67362011-07-17 12:09:27 -070023
Ian Rogersc7dd2952014-10-21 23:31:19 -070024#include <sstream>
25
26#include "base/dumpable.h"
Elliott Hughes07ed66b2012-12-12 18:34:25 -080027#include "base/logging.h"
Elliott Hughes76b61672012-12-12 17:47:30 -080028#include "base/mutex.h"
Elliott Hughese222ee02012-12-13 14:41:43 -080029#include "base/stringprintf.h"
Ian Rogersb48b9eb2014-02-28 16:20:21 -080030#include "thread-inl.h"
Andreas Gampe038bb222015-01-13 19:48:14 -080031#include "thread_list.h"
Elliott Hughes46e251b2012-05-22 15:10:45 -070032#include "utils.h"
Elliott Hughesffe67362011-07-17 12:09:27 -070033
34namespace art {
35
Mathieu Chartierc2f4d022014-03-03 16:11:42 -080036static constexpr bool kDumpHeapObjectOnSigsevg = false;
Andreas Gampecbfded42015-01-14 18:35:01 -080037static constexpr bool kUseSigRTTimeout = true;
Mathieu Chartierc2f4d022014-03-03 16:11:42 -080038
Elliott Hughes6c1c69e2012-04-23 16:12:51 -070039struct Backtrace {
Andreas Gampe628a61a2015-01-07 22:08:35 -080040 public:
41 explicit Backtrace(void* raw_context) : raw_context_(raw_context) {}
Ian Rogersc7dd2952014-10-21 23:31:19 -070042 void Dump(std::ostream& os) const {
Andreas Gampe628a61a2015-01-07 22:08:35 -080043 DumpNativeStack(os, GetTid(), "\t", nullptr, raw_context_);
Elliott Hughes6c1c69e2012-04-23 16:12:51 -070044 }
Andreas Gampe628a61a2015-01-07 22:08:35 -080045 private:
46 // Stores the context of the signal that was unexpected and will terminate the runtime. The
47 // DumpNativeStack code will take care of casting it to the expected type. This is required
48 // as our signal handler runs on an alternate stack.
49 void* raw_context_;
Elliott Hughes6c1c69e2012-04-23 16:12:51 -070050};
51
Elliott Hughes76160052012-12-12 16:31:20 -080052struct OsInfo {
Ian Rogersc7dd2952014-10-21 23:31:19 -070053 void Dump(std::ostream& os) const {
Elliott Hughes058a6de2012-05-24 19:13:02 -070054 utsname info;
55 uname(&info);
56 // Linux 2.6.38.8-gg784 (x86_64)
57 // Darwin 11.4.0 (x86_64)
58 os << info.sysname << " " << info.release << " (" << info.machine << ")";
59 }
60};
61
Elliott Hughes6c1c69e2012-04-23 16:12:51 -070062static const char* GetSignalName(int signal_number) {
63 switch (signal_number) {
64 case SIGABRT: return "SIGABRT";
65 case SIGBUS: return "SIGBUS";
66 case SIGFPE: return "SIGFPE";
67 case SIGILL: return "SIGILL";
68 case SIGPIPE: return "SIGPIPE";
69 case SIGSEGV: return "SIGSEGV";
Elliott Hughes833770b2012-05-01 15:41:03 -070070#if defined(SIGSTKFLT)
Elliott Hughes6c1c69e2012-04-23 16:12:51 -070071 case SIGSTKFLT: return "SIGSTKFLT";
72#endif
73 case SIGTRAP: return "SIGTRAP";
74 }
75 return "??";
Elliott Hughesffe67362011-07-17 12:09:27 -070076}
77
Elliott Hughes457005c2012-04-16 13:54:25 -070078static const char* GetSignalCodeName(int signal_number, int signal_code) {
79 // Try the signal-specific codes...
80 switch (signal_number) {
81 case SIGILL:
82 switch (signal_code) {
83 case ILL_ILLOPC: return "ILL_ILLOPC";
84 case ILL_ILLOPN: return "ILL_ILLOPN";
85 case ILL_ILLADR: return "ILL_ILLADR";
86 case ILL_ILLTRP: return "ILL_ILLTRP";
87 case ILL_PRVOPC: return "ILL_PRVOPC";
88 case ILL_PRVREG: return "ILL_PRVREG";
89 case ILL_COPROC: return "ILL_COPROC";
90 case ILL_BADSTK: return "ILL_BADSTK";
91 }
92 break;
93 case SIGBUS:
94 switch (signal_code) {
95 case BUS_ADRALN: return "BUS_ADRALN";
96 case BUS_ADRERR: return "BUS_ADRERR";
97 case BUS_OBJERR: return "BUS_OBJERR";
98 }
99 break;
100 case SIGFPE:
101 switch (signal_code) {
102 case FPE_INTDIV: return "FPE_INTDIV";
103 case FPE_INTOVF: return "FPE_INTOVF";
104 case FPE_FLTDIV: return "FPE_FLTDIV";
105 case FPE_FLTOVF: return "FPE_FLTOVF";
106 case FPE_FLTUND: return "FPE_FLTUND";
107 case FPE_FLTRES: return "FPE_FLTRES";
108 case FPE_FLTINV: return "FPE_FLTINV";
109 case FPE_FLTSUB: return "FPE_FLTSUB";
110 }
111 break;
112 case SIGSEGV:
113 switch (signal_code) {
114 case SEGV_MAPERR: return "SEGV_MAPERR";
115 case SEGV_ACCERR: return "SEGV_ACCERR";
116 }
117 break;
118 case SIGTRAP:
119 switch (signal_code) {
120 case TRAP_BRKPT: return "TRAP_BRKPT";
121 case TRAP_TRACE: return "TRAP_TRACE";
122 }
123 break;
124 }
125 // Then the other codes...
126 switch (signal_code) {
127 case SI_USER: return "SI_USER";
Elliott Hughesac8097f2012-04-16 14:59:44 -0700128#if defined(SI_KERNEL)
Elliott Hughes457005c2012-04-16 13:54:25 -0700129 case SI_KERNEL: return "SI_KERNEL";
Elliott Hughesac8097f2012-04-16 14:59:44 -0700130#endif
Elliott Hughes457005c2012-04-16 13:54:25 -0700131 case SI_QUEUE: return "SI_QUEUE";
132 case SI_TIMER: return "SI_TIMER";
133 case SI_MESGQ: return "SI_MESGQ";
134 case SI_ASYNCIO: return "SI_ASYNCIO";
Elliott Hughesac8097f2012-04-16 14:59:44 -0700135#if defined(SI_SIGIO)
Elliott Hughes457005c2012-04-16 13:54:25 -0700136 case SI_SIGIO: return "SI_SIGIO";
Elliott Hughesac8097f2012-04-16 14:59:44 -0700137#endif
138#if defined(SI_TKILL)
Elliott Hughes457005c2012-04-16 13:54:25 -0700139 case SI_TKILL: return "SI_TKILL";
Elliott Hughesac8097f2012-04-16 14:59:44 -0700140#endif
Elliott Hughes457005c2012-04-16 13:54:25 -0700141 }
142 // Then give up...
143 return "?";
144}
145
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700146struct UContext {
Ian Rogersc7dd2952014-10-21 23:31:19 -0700147 explicit UContext(void* raw_context) :
148 context(reinterpret_cast<ucontext_t*>(raw_context)->uc_mcontext) {
149 }
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700150
Ian Rogersc7dd2952014-10-21 23:31:19 -0700151 void Dump(std::ostream& os) const {
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700152 // TODO: support non-x86 hosts (not urgent because this code doesn't run on targets).
Ian Rogersef7d42f2014-01-06 12:55:46 -0800153#if defined(__APPLE__) && defined(__i386__)
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700154 DumpRegister32(os, "eax", context->__ss.__eax);
155 DumpRegister32(os, "ebx", context->__ss.__ebx);
156 DumpRegister32(os, "ecx", context->__ss.__ecx);
157 DumpRegister32(os, "edx", context->__ss.__edx);
158 os << '\n';
159
160 DumpRegister32(os, "edi", context->__ss.__edi);
161 DumpRegister32(os, "esi", context->__ss.__esi);
162 DumpRegister32(os, "ebp", context->__ss.__ebp);
163 DumpRegister32(os, "esp", context->__ss.__esp);
164 os << '\n';
165
166 DumpRegister32(os, "eip", context->__ss.__eip);
Elliott Hughes46e251b2012-05-22 15:10:45 -0700167 os << " ";
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700168 DumpRegister32(os, "eflags", context->__ss.__eflags);
Elliott Hughes46e251b2012-05-22 15:10:45 -0700169 DumpX86Flags(os, context->__ss.__eflags);
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700170 os << '\n';
171
172 DumpRegister32(os, "cs", context->__ss.__cs);
173 DumpRegister32(os, "ds", context->__ss.__ds);
174 DumpRegister32(os, "es", context->__ss.__es);
175 DumpRegister32(os, "fs", context->__ss.__fs);
176 os << '\n';
177 DumpRegister32(os, "gs", context->__ss.__gs);
178 DumpRegister32(os, "ss", context->__ss.__ss);
Ian Rogersef7d42f2014-01-06 12:55:46 -0800179#elif defined(__linux__) && defined(__i386__)
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700180 DumpRegister32(os, "eax", context.gregs[REG_EAX]);
181 DumpRegister32(os, "ebx", context.gregs[REG_EBX]);
182 DumpRegister32(os, "ecx", context.gregs[REG_ECX]);
183 DumpRegister32(os, "edx", context.gregs[REG_EDX]);
184 os << '\n';
185
186 DumpRegister32(os, "edi", context.gregs[REG_EDI]);
187 DumpRegister32(os, "esi", context.gregs[REG_ESI]);
188 DumpRegister32(os, "ebp", context.gregs[REG_EBP]);
189 DumpRegister32(os, "esp", context.gregs[REG_ESP]);
190 os << '\n';
191
192 DumpRegister32(os, "eip", context.gregs[REG_EIP]);
Elliott Hughes46e251b2012-05-22 15:10:45 -0700193 os << " ";
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700194 DumpRegister32(os, "eflags", context.gregs[REG_EFL]);
Elliott Hughes46e251b2012-05-22 15:10:45 -0700195 DumpX86Flags(os, context.gregs[REG_EFL]);
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700196 os << '\n';
197
198 DumpRegister32(os, "cs", context.gregs[REG_CS]);
199 DumpRegister32(os, "ds", context.gregs[REG_DS]);
200 DumpRegister32(os, "es", context.gregs[REG_ES]);
201 DumpRegister32(os, "fs", context.gregs[REG_FS]);
202 os << '\n';
203 DumpRegister32(os, "gs", context.gregs[REG_GS]);
204 DumpRegister32(os, "ss", context.gregs[REG_SS]);
Dmitry Petrochenko611c2c32014-02-10 14:48:12 +0700205#elif defined(__linux__) && defined(__x86_64__)
206 DumpRegister64(os, "rax", context.gregs[REG_RAX]);
207 DumpRegister64(os, "rbx", context.gregs[REG_RBX]);
208 DumpRegister64(os, "rcx", context.gregs[REG_RCX]);
209 DumpRegister64(os, "rdx", context.gregs[REG_RDX]);
210 os << '\n';
211
212 DumpRegister64(os, "rdi", context.gregs[REG_RDI]);
213 DumpRegister64(os, "rsi", context.gregs[REG_RSI]);
214 DumpRegister64(os, "rbp", context.gregs[REG_RBP]);
215 DumpRegister64(os, "rsp", context.gregs[REG_RSP]);
216 os << '\n';
217
218 DumpRegister64(os, "r8 ", context.gregs[REG_R8]);
219 DumpRegister64(os, "r9 ", context.gregs[REG_R9]);
220 DumpRegister64(os, "r10", context.gregs[REG_R10]);
221 DumpRegister64(os, "r11", context.gregs[REG_R11]);
222 os << '\n';
223
224 DumpRegister64(os, "r12", context.gregs[REG_R12]);
225 DumpRegister64(os, "r13", context.gregs[REG_R13]);
226 DumpRegister64(os, "r14", context.gregs[REG_R14]);
227 DumpRegister64(os, "r15", context.gregs[REG_R15]);
228 os << '\n';
229
230 DumpRegister64(os, "rip", context.gregs[REG_RIP]);
231 os << " ";
232 DumpRegister32(os, "eflags", context.gregs[REG_EFL]);
233 DumpX86Flags(os, context.gregs[REG_EFL]);
234 os << '\n';
235
236 DumpRegister32(os, "cs", (context.gregs[REG_CSGSFS]) & 0x0FFFF);
237 DumpRegister32(os, "gs", (context.gregs[REG_CSGSFS] >> 16) & 0x0FFFF);
238 DumpRegister32(os, "fs", (context.gregs[REG_CSGSFS] >> 32) & 0x0FFFF);
239 os << '\n';
Ian Rogersef7d42f2014-01-06 12:55:46 -0800240#else
241 os << "Unknown architecture/word size/OS in ucontext dump";
Elliott Hughesac8097f2012-04-16 14:59:44 -0700242#endif
Elliott Hughes457005c2012-04-16 13:54:25 -0700243 }
244
Ian Rogersc7dd2952014-10-21 23:31:19 -0700245 void DumpRegister32(std::ostream& os, const char* name, uint32_t value) const {
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700246 os << StringPrintf(" %6s: 0x%08x", name, value);
247 }
248
Ian Rogersc7dd2952014-10-21 23:31:19 -0700249 void DumpRegister64(std::ostream& os, const char* name, uint64_t value) const {
Dmitry Petrochenko611c2c32014-02-10 14:48:12 +0700250 os << StringPrintf(" %6s: 0x%016" PRIx64, name, value);
251 }
252
Ian Rogersc7dd2952014-10-21 23:31:19 -0700253 void DumpX86Flags(std::ostream& os, uint32_t flags) const {
Elliott Hughes46e251b2012-05-22 15:10:45 -0700254 os << " [";
255 if ((flags & (1 << 0)) != 0) {
256 os << " CF";
257 }
258 if ((flags & (1 << 2)) != 0) {
259 os << " PF";
260 }
261 if ((flags & (1 << 4)) != 0) {
262 os << " AF";
263 }
264 if ((flags & (1 << 6)) != 0) {
265 os << " ZF";
266 }
267 if ((flags & (1 << 7)) != 0) {
268 os << " SF";
269 }
270 if ((flags & (1 << 8)) != 0) {
271 os << " TF";
272 }
273 if ((flags & (1 << 9)) != 0) {
274 os << " IF";
275 }
276 if ((flags & (1 << 10)) != 0) {
277 os << " DF";
278 }
279 if ((flags & (1 << 11)) != 0) {
280 os << " OF";
281 }
282 os << " ]";
283 }
284
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700285 mcontext_t& context;
286};
287
Andreas Gampecbfded42015-01-14 18:35:01 -0800288// Return the signal number we recognize as timeout. -1 means not active/supported.
Andreas Gampe038bb222015-01-13 19:48:14 -0800289static int GetTimeoutSignal() {
Andreas Gampecbfded42015-01-14 18:35:01 -0800290#if defined(__APPLE__)
291 // Mac does not support realtime signals.
292 return -1;
293#else
294 return kUseSigRTTimeout ? (SIGRTMIN + 2) : -1;
295#endif
Andreas Gampe038bb222015-01-13 19:48:14 -0800296}
297
298static bool IsTimeoutSignal(int signal_number) {
299 return signal_number == GetTimeoutSignal();
300}
301
Brian Carlstromaf1b8922012-11-27 15:19:57 -0800302void HandleUnexpectedSignal(int signal_number, siginfo_t* info, void* raw_context) {
303 static bool handlingUnexpectedSignal = false;
304 if (handlingUnexpectedSignal) {
Ian Rogersc7dd2952014-10-21 23:31:19 -0700305 LogMessage::LogLine(__FILE__, __LINE__, INTERNAL_FATAL, "HandleUnexpectedSignal reentered\n");
Andreas Gampe038bb222015-01-13 19:48:14 -0800306 if (IsTimeoutSignal(signal_number)) {
307 // Ignore a recursive timeout.
308 return;
309 }
Brian Carlstromaf1b8922012-11-27 15:19:57 -0800310 _exit(1);
311 }
312 handlingUnexpectedSignal = true;
313
Nicolas Geoffraydb978712014-12-09 13:33:38 +0000314 gAborting++; // set before taking any locks
Ian Rogers50b35e22012-10-04 10:09:15 -0700315 MutexLock mu(Thread::Current(), *Locks::unexpected_signal_lock_);
Elliott Hughesd06a6c72012-05-30 17:59:06 -0700316
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700317 bool has_address = (signal_number == SIGILL || signal_number == SIGBUS ||
318 signal_number == SIGFPE || signal_number == SIGSEGV);
319
Elliott Hughes76160052012-12-12 16:31:20 -0800320 OsInfo os_info;
Elliott Hughes98eedd82012-06-11 17:52:56 -0700321 const char* cmd_line = GetCmdLine();
322 if (cmd_line == NULL) {
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700323 cmd_line = "<unset>"; // Because no-one called InitLogging.
Elliott Hughes98eedd82012-06-11 17:52:56 -0700324 }
Elliott Hughes289be852012-06-12 13:57:20 -0700325 pid_t tid = GetTid();
326 std::string thread_name(GetThreadName(tid));
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700327 UContext thread_context(raw_context);
Andreas Gampe628a61a2015-01-07 22:08:35 -0800328 Backtrace thread_backtrace(raw_context);
Elliott Hughes8593fdb2012-04-21 20:53:44 -0700329
Elliott Hughes457005c2012-04-16 13:54:25 -0700330 LOG(INTERNAL_FATAL) << "*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n"
331 << StringPrintf("Fatal signal %d (%s), code %d (%s)",
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700332 signal_number, GetSignalName(signal_number),
Elliott Hughes457005c2012-04-16 13:54:25 -0700333 info->si_code,
334 GetSignalCodeName(signal_number, info->si_code))
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700335 << (has_address ? StringPrintf(" fault addr %p", info->si_addr) : "") << "\n"
Elliott Hughes76160052012-12-12 16:31:20 -0800336 << "OS: " << Dumpable<OsInfo>(os_info) << "\n"
Elliott Hughes98eedd82012-06-11 17:52:56 -0700337 << "Cmdline: " << cmd_line << "\n"
Elliott Hughes289be852012-06-12 13:57:20 -0700338 << "Thread: " << tid << " \"" << thread_name << "\"\n"
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700339 << "Registers:\n" << Dumpable<UContext>(thread_context) << "\n"
340 << "Backtrace:\n" << Dumpable<Backtrace>(thread_backtrace);
Mathieu Chartier15d34022014-02-26 17:16:38 -0800341 Runtime* runtime = Runtime::Current();
342 if (runtime != nullptr) {
Andreas Gampe038bb222015-01-13 19:48:14 -0800343 if (IsTimeoutSignal(signal_number)) {
344 // Special timeout signal. Try to dump all threads.
345 runtime->GetThreadList()->DumpForSigQuit(LOG(INTERNAL_FATAL));
346 }
Mathieu Chartier15d34022014-02-26 17:16:38 -0800347 gc::Heap* heap = runtime->GetHeap();
348 LOG(INTERNAL_FATAL) << "Fault message: " << runtime->GetFaultMessage();
Mathieu Chartierc2f4d022014-03-03 16:11:42 -0800349 if (kDumpHeapObjectOnSigsevg && heap != nullptr && info != nullptr) {
Mathieu Chartier15d34022014-02-26 17:16:38 -0800350 LOG(INTERNAL_FATAL) << "Dump heap object at fault address: ";
351 heap->DumpObject(LOG(INTERNAL_FATAL), reinterpret_cast<mirror::Object*>(info->si_addr));
352 }
353 }
Elliott Hughes4909ba42012-06-14 13:33:49 -0700354 if (getenv("debug_db_uid") != NULL || getenv("art_wait_for_gdb_on_crash") != NULL) {
Elliott Hughes2554cb92012-04-18 17:19:26 -0700355 LOG(INTERNAL_FATAL) << "********************************************************\n"
Elliott Hughes289be852012-06-12 13:57:20 -0700356 << "* Process " << getpid() << " thread " << tid << " \"" << thread_name << "\""
357 << " has been suspended while crashing.\n"
358 << "* Attach gdb:\n"
359 << "* gdb -p " << tid << "\n"
Elliott Hughes2554cb92012-04-18 17:19:26 -0700360 << "********************************************************\n";
361 // Wait for debugger to attach.
362 while (true) {
363 }
Elliott Hughes457005c2012-04-16 13:54:25 -0700364 }
Ian Rogersc5f17732014-06-05 20:48:42 -0700365#ifdef __linux__
Elliott Hughesd06a6c72012-05-30 17:59:06 -0700366 // Remove our signal handler for this signal...
367 struct sigaction action;
368 memset(&action, 0, sizeof(action));
369 sigemptyset(&action.sa_mask);
370 action.sa_handler = SIG_DFL;
371 sigaction(signal_number, &action, NULL);
372 // ...and re-raise so we die with the appropriate status.
373 kill(getpid(), signal_number);
Ian Rogersc5f17732014-06-05 20:48:42 -0700374#else
375 exit(EXIT_FAILURE);
376#endif
Elliott Hughes457005c2012-04-16 13:54:25 -0700377}
378
Elliott Hughes457005c2012-04-16 13:54:25 -0700379void Runtime::InitPlatformSignalHandlers() {
380 // On the host, we don't have debuggerd to dump a stack for us when something unexpected happens.
381 struct sigaction action;
382 memset(&action, 0, sizeof(action));
383 sigemptyset(&action.sa_mask);
384 action.sa_sigaction = HandleUnexpectedSignal;
Elliott Hughes6c1c69e2012-04-23 16:12:51 -0700385 // Use the three-argument sa_sigaction handler.
386 action.sa_flags |= SA_SIGINFO;
Elliott Hughesd06a6c72012-05-30 17:59:06 -0700387 // Use the alternate signal stack so we can catch stack overflows.
388 action.sa_flags |= SA_ONSTACK;
Elliott Hughes457005c2012-04-16 13:54:25 -0700389
390 int rc = 0;
Elliott Hughes457005c2012-04-16 13:54:25 -0700391 rc += sigaction(SIGABRT, &action, NULL);
392 rc += sigaction(SIGBUS, &action, NULL);
393 rc += sigaction(SIGFPE, &action, NULL);
Elliott Hughes058a6de2012-05-24 19:13:02 -0700394 rc += sigaction(SIGILL, &action, NULL);
395 rc += sigaction(SIGPIPE, &action, NULL);
396 rc += sigaction(SIGSEGV, &action, NULL);
Elliott Hughesac8097f2012-04-16 14:59:44 -0700397#if defined(SIGSTKFLT)
Elliott Hughes457005c2012-04-16 13:54:25 -0700398 rc += sigaction(SIGSTKFLT, &action, NULL);
Elliott Hughesac8097f2012-04-16 14:59:44 -0700399#endif
Elliott Hughes058a6de2012-05-24 19:13:02 -0700400 rc += sigaction(SIGTRAP, &action, NULL);
Andreas Gampe038bb222015-01-13 19:48:14 -0800401 // Special dump-all timeout.
Andreas Gampecbfded42015-01-14 18:35:01 -0800402 if (GetTimeoutSignal() != -1) {
403 rc += sigaction(GetTimeoutSignal(), &action, NULL);
404 }
Elliott Hughes457005c2012-04-16 13:54:25 -0700405 CHECK_EQ(rc, 0);
406}
407
Elliott Hughesffe67362011-07-17 12:09:27 -0700408} // namespace art