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

Unified Diff: base/debug_util_posix.cc

Issue 201122: Changes needed for MacOS X 10.4 support.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/compat_execinfo.h ('k') | base/file_util_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug_util_posix.cc
===================================================================
--- base/debug_util_posix.cc (revision 26269)
+++ base/debug_util_posix.cc (working copy)
@@ -6,7 +6,6 @@
#include "base/debug_util.h"
#include <errno.h>
-#include <execinfo.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
@@ -15,6 +14,7 @@
#include <unistd.h>
#include "base/basictypes.h"
+#include "base/compat_execinfo.h"
#include "base/eintr_wrapper.h"
#include "base/logging.h"
#include "base/scoped_ptr.h"
@@ -116,31 +116,39 @@
}
StackTrace::StackTrace() {
- // Though the backtrace API man page does not list any possible negative
- // return values, we take no chance.
- count_ = std::max(backtrace(trace_, arraysize(trace_)), 0);
+ if (backtrace == NULL) {
+ count_ = 0;
+ } else {
+ // Though the backtrace API man page does not list any possible negative
+ // return values, we take no chance.
+ count_ = std::max(backtrace(trace_, arraysize(trace_)), 0);
+ }
}
void StackTrace::PrintBacktrace() {
- fflush(stderr);
- backtrace_symbols_fd(trace_, count_, STDERR_FILENO);
+ if (backtrace_symbols_fd != NULL) {
+ fflush(stderr);
+ backtrace_symbols_fd(trace_, count_, STDERR_FILENO);
+ }
}
void StackTrace::OutputToStream(std::ostream* os) {
- scoped_ptr_malloc<char*> trace_symbols(backtrace_symbols(trace_, count_));
+ if (backtrace_symbols != NULL) {
+ scoped_ptr_malloc<char*> trace_symbols(backtrace_symbols(trace_, count_));
- // If we can't retrieve the symbols, print an error and just dump the raw
- // addresses.
- if (trace_symbols.get() == NULL) {
- (*os) << "Unable get symbols for backtrace (" << strerror(errno)
- << "). Dumping raw addresses in trace:\n";
- for (int i = 0; i < count_; ++i) {
- (*os) << "\t" << trace_[i] << "\n";
+ // If we can't retrieve the symbols, print an error and just dump the raw
+ // addresses.
+ if (trace_symbols.get() == NULL) {
+ (*os) << "Unable get symbols for backtrace (" << strerror(errno)
+ << "). Dumping raw addresses in trace:\n";
+ for (int i = 0; i < count_; ++i) {
+ (*os) << "\t" << trace_[i] << "\n";
+ }
+ } else {
+ (*os) << "Backtrace:\n";
+ for (int i = 0; i < count_; ++i) {
+ (*os) << "\t" << trace_symbols.get()[i] << "\n";
+ }
}
- } else {
- (*os) << "Backtrace:\n";
- for (int i = 0; i < count_; ++i) {
- (*os) << "\t" << trace_symbols.get()[i] << "\n";
- }
}
}
« no previous file with comments | « base/compat_execinfo.h ('k') | base/file_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698