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

Side by Side Diff: base/debug_util_posix.cc

Issue 214012: Explicitly compare to NULL when looking for weak_import symbols. (Closed)
Patch Set: rebase Created 11 years, 3 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 | « no previous file | no next file » | 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 "build/build_config.h" 5 #include "build/build_config.h"
6 #include "base/debug_util.h" 6 #include "base/debug_util.h"
7 7
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 void DebugUtil::BreakDebugger() { 114 void DebugUtil::BreakDebugger() {
115 #if defined(ARCH_CPU_ARM_FAMILY) 115 #if defined(ARCH_CPU_ARM_FAMILY)
116 asm("bkpt 0"); 116 asm("bkpt 0");
117 #else 117 #else
118 asm("int3"); 118 asm("int3");
119 #endif 119 #endif
120 } 120 }
121 121
122 StackTrace::StackTrace() { 122 StackTrace::StackTrace() {
123 #if defined(OS_MACOSX) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 123 #if defined(OS_MACOSX) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
124 if (!backtrace) { 124 if (backtrace == NULL) {
125 count_ = 0; 125 count_ = 0;
126 return; 126 return;
127 } 127 }
128 #endif 128 #endif
129 // Though the backtrace API man page does not list any possible negative 129 // Though the backtrace API man page does not list any possible negative
130 // return values, we take no chance. 130 // return values, we take no chance.
131 count_ = std::max(backtrace(trace_, arraysize(trace_)), 0); 131 count_ = std::max(backtrace(trace_, arraysize(trace_)), 0);
132 } 132 }
133 133
134 void StackTrace::PrintBacktrace() { 134 void StackTrace::PrintBacktrace() {
135 #if defined(OS_MACOSX) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 135 #if defined(OS_MACOSX) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
136 if (!backtrace_symbols_fd) 136 if (backtrace_symbols_fd == NULL)
137 return; 137 return;
138 #endif 138 #endif
139 fflush(stderr); 139 fflush(stderr);
140 backtrace_symbols_fd(trace_, count_, STDERR_FILENO); 140 backtrace_symbols_fd(trace_, count_, STDERR_FILENO);
141 } 141 }
142 142
143 void StackTrace::OutputToStream(std::ostream* os) { 143 void StackTrace::OutputToStream(std::ostream* os) {
144 #if defined(OS_MACOSX) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 144 #if defined(OS_MACOSX) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
145 if (!backtrace_symbols) 145 if (backtrace_symbols == NULL)
146 return; 146 return;
147 #endif 147 #endif
148 scoped_ptr_malloc<char*> trace_symbols(backtrace_symbols(trace_, count_)); 148 scoped_ptr_malloc<char*> trace_symbols(backtrace_symbols(trace_, count_));
149 149
150 // If we can't retrieve the symbols, print an error and just dump the raw 150 // If we can't retrieve the symbols, print an error and just dump the raw
151 // addresses. 151 // addresses.
152 if (trace_symbols.get() == NULL) { 152 if (trace_symbols.get() == NULL) {
153 (*os) << "Unable get symbols for backtrace (" << strerror(errno) 153 (*os) << "Unable get symbols for backtrace (" << strerror(errno)
154 << "). Dumping raw addresses in trace:\n"; 154 << "). Dumping raw addresses in trace:\n";
155 for (int i = 0; i < count_; ++i) { 155 for (int i = 0; i < count_; ++i) {
156 (*os) << "\t" << trace_[i] << "\n"; 156 (*os) << "\t" << trace_[i] << "\n";
157 } 157 }
158 } else { 158 } else {
159 (*os) << "Backtrace:\n"; 159 (*os) << "Backtrace:\n";
160 for (int i = 0; i < count_; ++i) { 160 for (int i = 0; i < count_; ++i) {
161 (*os) << "\t" << trace_symbols.get()[i] << "\n"; 161 (*os) << "\t" << trace_symbols.get()[i] << "\n";
162 } 162 }
163 } 163 }
164 } 164 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698