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

Side by Side Diff: base/debug/stack_trace_android.cc

Issue 11280010: Extract SIGPIPE ignoring code to a common place. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: documented return value Created 8 years, 1 month 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 | « no previous file | base/debug/stack_trace_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/debug/stack_trace.h" 5 #include "base/debug/stack_trace.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/process_util.h"
12 13
13 namespace base { 14 namespace base {
14 namespace debug { 15 namespace debug {
15 16
16 bool EnableInProcessStackDumping() { 17 bool EnableInProcessStackDumping() {
17 // When running in an application, our code typically expects SIGPIPE 18 // When running in an application, our code typically expects SIGPIPE
18 // to be ignored. Therefore, when testing that same code, it should run 19 // to be ignored. Therefore, when testing that same code, it should run
19 // with SIGPIPE ignored as well. 20 // with SIGPIPE ignored as well.
20 // TODO(phajdan.jr): De-duplicate this SIGPIPE code. 21 // TODO(phajdan.jr): Ignoring SIGPIPE has nothing to do with stack dumping.
21 struct sigaction action; 22 return base::IgnoreSigPipe();
22 memset(&action, 0, sizeof(action));
23 action.sa_handler = SIG_IGN;
24 sigemptyset(&action.sa_mask);
25 return (sigaction(SIGPIPE, &action, NULL) == 0);
26 } 23 }
27 24
28 StackTrace::StackTrace() { 25 StackTrace::StackTrace() {
29 } 26 }
30 27
31 // Sends fake SIGSTKFLT signals to let the Android linker and debuggerd dump 28 // Sends fake SIGSTKFLT signals to let the Android linker and debuggerd dump
32 // stack. See inlined comments and Android bionic/linker/debugger.c and 29 // stack. See inlined comments and Android bionic/linker/debugger.c and
33 // system/core/debuggerd/debuggerd.c for details. 30 // system/core/debuggerd/debuggerd.c for details.
34 void StackTrace::PrintBacktrace() const { 31 void StackTrace::PrintBacktrace() const {
35 // Get the current handler of SIGSTKFLT for later use. 32 // Get the current handler of SIGSTKFLT for later use.
(...skipping 15 matching lines...) Expand all
51 // Restore the signal handler so that this method can work the next time. 48 // Restore the signal handler so that this method can work the next time.
52 signal(SIGSTKFLT, sig_handler); 49 signal(SIGSTKFLT, sig_handler);
53 } 50 }
54 51
55 void StackTrace::OutputToStream(std::ostream* os) const { 52 void StackTrace::OutputToStream(std::ostream* os) const {
56 NOTIMPLEMENTED(); 53 NOTIMPLEMENTED();
57 } 54 }
58 55
59 } // namespace debug 56 } // namespace debug
60 } // namespace base 57 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/debug/stack_trace_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698