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

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

Issue 2632643004: Remove WTFReportAssertionFailure and WTFReportBacktrace. (Closed)
Patch Set: Address review comments Created 3 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
« no previous file with comments | « base/debug/stack_trace.cc ('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
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 <android/log.h> 7 #include <android/log.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <unwind.h> 9 #include <unwind.h>
10
11 #include <algorithm>
10 #include <ostream> 12 #include <ostream>
11 13
12 #include "base/debug/proc_maps_linux.h" 14 #include "base/debug/proc_maps_linux.h"
13 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
14 #include "base/threading/thread_restrictions.h" 16 #include "base/threading/thread_restrictions.h"
15 17
16 #ifdef __LP64__ 18 #ifdef __LP64__
17 #define FMT_ADDR "0x%016lx" 19 #define FMT_ADDR "0x%016lx"
18 #else 20 #else
19 #define FMT_ADDR "0x%08x" 21 #define FMT_ADDR "0x%08x"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // to be ignored. Therefore, when testing that same code, it should run 62 // to be ignored. Therefore, when testing that same code, it should run
61 // with SIGPIPE ignored as well. 63 // with SIGPIPE ignored as well.
62 // TODO(phajdan.jr): De-duplicate this SIGPIPE code. 64 // TODO(phajdan.jr): De-duplicate this SIGPIPE code.
63 struct sigaction action; 65 struct sigaction action;
64 memset(&action, 0, sizeof(action)); 66 memset(&action, 0, sizeof(action));
65 action.sa_handler = SIG_IGN; 67 action.sa_handler = SIG_IGN;
66 sigemptyset(&action.sa_mask); 68 sigemptyset(&action.sa_mask);
67 return (sigaction(SIGPIPE, &action, NULL) == 0); 69 return (sigaction(SIGPIPE, &action, NULL) == 0);
68 } 70 }
69 71
70 StackTrace::StackTrace() { 72 StackTrace::StackTrace(size_t count) {
71 StackCrawlState state(reinterpret_cast<uintptr_t*>(trace_), kMaxTraces); 73 count = std::min(arraysize(trace_), count);
74
75 StackCrawlState state(reinterpret_cast<uintptr_t*>(trace_), count);
72 _Unwind_Backtrace(&TraceStackFrame, &state); 76 _Unwind_Backtrace(&TraceStackFrame, &state);
73 count_ = state.frame_count; 77 count_ = state.frame_count;
74 } 78 }
75 79
76 void StackTrace::Print() const { 80 void StackTrace::Print() const {
77 std::string backtrace = ToString(); 81 std::string backtrace = ToString();
78 __android_log_write(ANDROID_LOG_ERROR, "chromium", backtrace.c_str()); 82 __android_log_write(ANDROID_LOG_ERROR, "chromium", backtrace.c_str());
79 } 83 }
80 84
81 // NOTE: Native libraries in APKs are stripped before installing. Print out the 85 // NOTE: Native libraries in APKs are stripped before installing. Print out the
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } else { 125 } else {
122 *os << "<unknown>"; 126 *os << "<unknown>";
123 } 127 }
124 128
125 *os << "\n"; 129 *os << "\n";
126 } 130 }
127 } 131 }
128 132
129 } // namespace debug 133 } // namespace debug
130 } // namespace base 134 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/stack_trace.cc ('k') | base/debug/stack_trace_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698