summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-22 22:31:00 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-22 22:31:00 +0000
commit7e3edc2280eda8536f0eb414f47fd0ba58b5763c (patch)
treec50fd243dbc2b52e9854de1ba34704ae6bc1d483 /base
parentc69b81767426a0508ca3f7043bd14fae93fde618 (diff)
downloadchromium_src-7e3edc2280eda8536f0eb414f47fd0ba58b5763c.zip
chromium_src-7e3edc2280eda8536f0eb414f47fd0ba58b5763c.tar.gz
chromium_src-7e3edc2280eda8536f0eb414f47fd0ba58b5763c.tar.bz2
[Mac] Log registers with stackdump in debug crashes.
Expand |StackDumpSignalHandler()| to log register contents and part of the stack. BUG=60426 TEST=Bug's crashes get registers logged. Review URL: http://codereview.chromium.org/5243002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67012 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/process_util_posix.cc58
1 files changed, 51 insertions, 7 deletions
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index 07e3125..8a97dcd 100644
--- a/base/process_util_posix.cc
+++ b/base/process_util_posix.cc
@@ -101,9 +101,52 @@ int WaitpidWithTimeout(ProcessHandle handle, int64 wait_milliseconds,
return status;
}
-void StackDumpSignalHandler(int signal) {
+void StackDumpSignalHandler(int signal, siginfo_t* info, ucontext_t* context) {
LOG(ERROR) << "Received signal " << signal;
debug::StackTrace().PrintBacktrace();
+
+ // TODO(shess): Port to Linux.
+#if defined(OS_MACOSX)
+ // TODO(shess): Port to 64-bit.
+#if ARCH_CPU_32_BITS
+ char buf[1024];
+ size_t len;
+
+ // NOTE: Even |snprintf()| is not on the approved list for signal
+ // handlers, but buffered I/O is definitely not on the list due to
+ // potential for |malloc()|.
+ len = static_cast<size_t>(
+ snprintf(buf, sizeof(buf),
+ "ax: %x, bx: %x, cx: %x, dx: %x\n",
+ context->uc_mcontext->__ss.__eax,
+ context->uc_mcontext->__ss.__ebx,
+ context->uc_mcontext->__ss.__ecx,
+ context->uc_mcontext->__ss.__edx));
+ write(STDERR_FILENO, buf, std::min(len, sizeof(buf) - 1));
+
+ len = static_cast<size_t>(
+ snprintf(buf, sizeof(buf),
+ "di: %x, si: %x, bp: %x, sp: %x, ss: %x, flags: %x\n",
+ context->uc_mcontext->__ss.__edi,
+ context->uc_mcontext->__ss.__esi,
+ context->uc_mcontext->__ss.__ebp,
+ context->uc_mcontext->__ss.__esp,
+ context->uc_mcontext->__ss.__ss,
+ context->uc_mcontext->__ss.__eflags));
+ write(STDERR_FILENO, buf, std::min(len, sizeof(buf) - 1));
+
+ len = static_cast<size_t>(
+ snprintf(buf, sizeof(buf),
+ "ip: %x, cs: %x, ds: %x, es: %x, fs: %x, gs: %x\n",
+ context->uc_mcontext->__ss.__eip,
+ context->uc_mcontext->__ss.__cs,
+ context->uc_mcontext->__ss.__ds,
+ context->uc_mcontext->__ss.__es,
+ context->uc_mcontext->__ss.__fs,
+ context->uc_mcontext->__ss.__gs));
+ write(STDERR_FILENO, buf, std::min(len, sizeof(buf) - 1));
+#endif // ARCH_CPU_32_BITS
+#endif // defined(OS_MACOSX)
_exit(1);
}
@@ -571,12 +614,13 @@ bool EnableInProcessStackDumping() {
sigemptyset(&action.sa_mask);
bool success = (sigaction(SIGPIPE, &action, NULL) == 0);
- success &= (signal(SIGILL, &StackDumpSignalHandler) != SIG_ERR);
- success &= (signal(SIGABRT, &StackDumpSignalHandler) != SIG_ERR);
- success &= (signal(SIGFPE, &StackDumpSignalHandler) != SIG_ERR);
- success &= (signal(SIGBUS, &StackDumpSignalHandler) != SIG_ERR);
- success &= (signal(SIGSEGV, &StackDumpSignalHandler) != SIG_ERR);
- success &= (signal(SIGSYS, &StackDumpSignalHandler) != SIG_ERR);
+ sig_t handler = reinterpret_cast<sig_t>(&StackDumpSignalHandler);
+ success &= (signal(SIGILL, handler) != SIG_ERR);
+ success &= (signal(SIGABRT, handler) != SIG_ERR);
+ success &= (signal(SIGFPE, handler) != SIG_ERR);
+ success &= (signal(SIGBUS, handler) != SIG_ERR);
+ success &= (signal(SIGSEGV, handler) != SIG_ERR);
+ success &= (signal(SIGSYS, handler) != SIG_ERR);
return success;
}