Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <dirent.h> | 5 #include <dirent.h> |
| 6 #include <errno.h> | 6 #include <errno.h> |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <signal.h> | 8 #include <signal.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <sys/resource.h> | 10 #include <sys/resource.h> |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 | 134 |
| 135 return status; | 135 return status; |
| 136 } | 136 } |
| 137 | 137 |
| 138 // Android has built-in crash handling. | 138 // Android has built-in crash handling. |
| 139 #if !defined(OS_ANDROID) | 139 #if !defined(OS_ANDROID) |
| 140 void StackDumpSignalHandler(int signal, siginfo_t* info, ucontext_t* context) { | 140 void StackDumpSignalHandler(int signal, siginfo_t* info, ucontext_t* context) { |
| 141 if (debug::BeingDebugged()) | 141 if (debug::BeingDebugged()) |
| 142 debug::BreakDebugger(); | 142 debug::BreakDebugger(); |
| 143 | 143 |
| 144 DLOG(ERROR) << "Received signal " << signal; | |
| 145 debug::StackTrace().PrintBacktrace(); | |
| 146 | |
| 147 // TODO(shess): Port to Linux. | |
| 148 #if defined(OS_MACOSX) | |
| 149 // TODO(shess): Port to 64-bit. | |
| 150 #if ARCH_CPU_32_BITS | |
| 151 char buf[1024]; | 144 char buf[1024]; |
| 152 size_t len; | 145 size_t len; |
| 153 | 146 |
| 154 // NOTE: Even |snprintf()| is not on the approved list for signal | 147 // NOTE: Even |snprintf()| is not on the approved list for signal |
| 155 // handlers, but buffered I/O is definitely not on the list due to | 148 // handlers, but buffered I/O is definitely not on the list due to |
| 156 // potential for |malloc()|. | 149 // potential for |malloc()|. |
| 150 len = static_cast<size_t>( | |
| 151 snprintf(buf, sizeof(buf), "Received signal %d\n", signal)); | |
| 152 ignore_result(write(STDERR_FILENO, buf, std::min(len, sizeof(buf) - 1))); | |
| 153 | |
| 154 // TODO(phajdan.jr): Re-enable backtrace printing after fixing the hang. | |
| 155 // debug::StackTrace().PrintBacktrace(); | |
| 156 | |
| 157 // TODO(shess): Port to Linux. | |
| 158 #if defined(OS_MACOSX) | |
|
Scott Hess - ex-Googler
2012/10/30 23:47:59
I would prefer to have the PrintBacktrace() enable
| |
| 159 // TODO(shess): Port to 64-bit. | |
| 160 #if ARCH_CPU_32_BITS | |
| 161 // NOTE: Even |snprintf()| is not on the approved list for signal | |
| 162 // handlers, but buffered I/O is definitely not on the list due to | |
| 163 // potential for |malloc()|. | |
| 157 len = static_cast<size_t>( | 164 len = static_cast<size_t>( |
| 158 snprintf(buf, sizeof(buf), | 165 snprintf(buf, sizeof(buf), |
| 159 "ax: %x, bx: %x, cx: %x, dx: %x\n", | 166 "ax: %x, bx: %x, cx: %x, dx: %x\n", |
| 160 context->uc_mcontext->__ss.__eax, | 167 context->uc_mcontext->__ss.__eax, |
| 161 context->uc_mcontext->__ss.__ebx, | 168 context->uc_mcontext->__ss.__ebx, |
| 162 context->uc_mcontext->__ss.__ecx, | 169 context->uc_mcontext->__ss.__ecx, |
| 163 context->uc_mcontext->__ss.__edx)); | 170 context->uc_mcontext->__ss.__edx)); |
| 164 write(STDERR_FILENO, buf, std::min(len, sizeof(buf) - 1)); | 171 write(STDERR_FILENO, buf, std::min(len, sizeof(buf) - 1)); |
| 165 | 172 |
| 166 len = static_cast<size_t>( | 173 len = static_cast<size_t>( |
| (...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1338 if (IsChildDead(process)) | 1345 if (IsChildDead(process)) |
| 1339 return; | 1346 return; |
| 1340 | 1347 |
| 1341 BackgroundReaper* reaper = new BackgroundReaper(process, 0); | 1348 BackgroundReaper* reaper = new BackgroundReaper(process, 0); |
| 1342 PlatformThread::CreateNonJoinable(0, reaper); | 1349 PlatformThread::CreateNonJoinable(0, reaper); |
| 1343 } | 1350 } |
| 1344 | 1351 |
| 1345 #endif // !defined(OS_MACOSX) | 1352 #endif // !defined(OS_MACOSX) |
| 1346 | 1353 |
| 1347 } // namespace base | 1354 } // namespace base |
| OLD | NEW |