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

Side by Side Diff: base/debug/stack_trace_ios.mm

Issue 136033004: Use posix version of stack_trace on iOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase & remove incorrect comment Created 6 years, 10 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/base.gypi ('k') | 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #import <Foundation/Foundation.h>
6 #include <mach/task.h>
7 #include <stdio.h>
8
9 #include "base/logging.h"
10
11 // This is just enough of a shim to let the support needed by test_support
12 // link.
13
14 namespace base {
15 namespace debug {
16
17 namespace {
18
19 void StackDumpSignalHandler(int signal) {
20 // TODO(phajdan.jr): Fix async-signal unsafety.
21 LOG(ERROR) << "Received signal " << signal;
22 NSArray *stack_symbols = [NSThread callStackSymbols];
23 for (NSString* stack_symbol in stack_symbols) {
24 fprintf(stderr, "\t%s\n", [stack_symbol UTF8String]);
25 }
26 _exit(1);
27 }
28
29 } // namespace
30
31 // TODO(phajdan.jr): Deduplicate, see copy in stack_trace_posix.cc.
32 bool EnableInProcessStackDumping() {
33 // When running in an application, our code typically expects SIGPIPE
34 // to be ignored. Therefore, when testing that same code, it should run
35 // with SIGPIPE ignored as well.
36 struct sigaction action;
37 action.sa_handler = SIG_IGN;
38 action.sa_flags = 0;
39 sigemptyset(&action.sa_mask);
40 bool success = (sigaction(SIGPIPE, &action, NULL) == 0);
41
42 success &= (signal(SIGILL, &StackDumpSignalHandler) != SIG_ERR);
43 success &= (signal(SIGABRT, &StackDumpSignalHandler) != SIG_ERR);
44 success &= (signal(SIGFPE, &StackDumpSignalHandler) != SIG_ERR);
45 success &= (signal(SIGBUS, &StackDumpSignalHandler) != SIG_ERR);
46 success &= (signal(SIGSEGV, &StackDumpSignalHandler) != SIG_ERR);
47 success &= (signal(SIGSYS, &StackDumpSignalHandler) != SIG_ERR);
48
49 return success;
50 }
51
52 } // namespace debug
53 } // namespace base
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/debug/stack_trace_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698