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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/debug/debugger_posix.cc ('k') | base/logging.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/debug/stack_trace.h"
6
7 #include <signal.h>
8 #include <sys/types.h>
9 #include <unistd.h>
10
11 #include "base/logging.h"
12
13 namespace base {
14 namespace debug {
15
16 StackTrace::StackTrace() {
17 }
18
19 StackTrace::~StackTrace() {
20 }
21
22 const void* const* StackTrace::Addresses(size_t* count) const {
23 NOTIMPLEMENTED();
24 return NULL;
25 }
26
27 // Sends fake SIGSTKFLT signals to let the Android linker and debuggerd dump
28 // stack. See inlined comments and Android bionic/linker/debugger.c and
29 // system/core/debuggerd/debuggerd.c for details.
30 void StackTrace::PrintBacktrace() const {
31 // Get the current handler of SIGSTKFLT for later use.
32 sighandler_t sig_handler = signal(SIGSTKFLT, SIG_DFL);
33 signal(SIGSTKFLT, sig_handler);
34
35 // The Android linker will handle this signal and send a stack dumping request
36 // to debuggerd which will ptrace_attach this process. Before returning from
37 // the signal handler, the linker sets the signal handler to SIG_IGN.
38 kill(gettid(), SIGSTKFLT);
39
40 // Because debuggerd will wait for the process to be stopped by the actual
41 // signal in crashing scenarios, signal is sent again to met the expectation.
42 // Debuggerd will dump stack into the system log and /data/tombstones/ files.
43 // NOTE: If this process runs in the interactive shell, it will be put
44 // in the background. To resume it in the foreground, use 'fg' command.
45 kill(gettid(), SIGSTKFLT);
46
47 // Restore the signal handler so that this method can work the next time.
48 signal(SIGSTKFLT, sig_handler);
49 }
50
51 void StackTrace::OutputToStream(std::ostream* os) const {
52 NOTIMPLEMENTED();
53 }
54
55 } // namespace debug
56 } // namespace base
OLDNEW
« 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