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

Unified Diff: base/debug/stack_trace_android.cc

Issue 7238012: Upstream android debug and log related files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove the android guard around ctype.h Created 9 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 | « base/debug/debugger_posix.cc ('k') | base/logging.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/stack_trace_android.cc
diff --git a/base/debug/stack_trace_android.cc b/base/debug/stack_trace_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2ccf406f0faa71355df66f50483407d064eb2d3f
--- /dev/null
+++ b/base/debug/stack_trace_android.cc
@@ -0,0 +1,56 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/debug/stack_trace.h"
+
+#include <signal.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "base/logging.h"
+
+namespace base {
+namespace debug {
+
+StackTrace::StackTrace() {
+}
+
+StackTrace::~StackTrace() {
+}
+
+const void* const* StackTrace::Addresses(size_t* count) const {
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
+// Sends fake SIGSTKFLT signals to let the Android linker and debuggerd dump
+// stack. See inlined comments and Android bionic/linker/debugger.c and
+// system/core/debuggerd/debuggerd.c for details.
+void StackTrace::PrintBacktrace() const {
+ // Get the current handler of SIGSTKFLT for later use.
+ sighandler_t sig_handler = signal(SIGSTKFLT, SIG_DFL);
+ signal(SIGSTKFLT, sig_handler);
+
+ // The Android linker will handle this signal and send a stack dumping request
+ // to debuggerd which will ptrace_attach this process. Before returning from
+ // the signal handler, the linker sets the signal handler to SIG_IGN.
+ kill(gettid(), SIGSTKFLT);
+
+ // Because debuggerd will wait for the process to be stopped by the actual
+ // signal in crashing scenarios, signal is sent again to met the expectation.
+ // Debuggerd will dump stack into the system log and /data/tombstones/ files.
+ // NOTE: If this process runs in the interactive shell, it will be put
+ // in the background. To resume it in the foreground, use 'fg' command.
+ kill(gettid(), SIGSTKFLT);
+
+ // Restore the signal handler so that this method can work the next time.
+ signal(SIGSTKFLT, sig_handler);
+}
+
+void StackTrace::OutputToStream(std::ostream* os) const {
+ NOTIMPLEMENTED();
+}
+
+} // namespace debug
+} // namespace base
« no previous file with comments | « base/debug/debugger_posix.cc ('k') | base/logging.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698