diff options
author | maf@google.com <maf@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-15 22:42:59 +0000 |
---|---|---|
committer | maf@google.com <maf@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-15 22:42:59 +0000 |
commit | 9543af0553bba7adab97d3a8a358510449dc2e60 (patch) | |
tree | 3eccebdd899ce50369f42b99a46cd04197664ed9 /base/debug_util_posix.cc | |
parent | a52225ef714d58b30cf87e794f0082a1445b6626 (diff) | |
download | chromium_src-9543af0553bba7adab97d3a8a358510449dc2e60.zip chromium_src-9543af0553bba7adab97d3a8a358510449dc2e60.tar.gz chromium_src-9543af0553bba7adab97d3a8a358510449dc2e60.tar.bz2 |
Changes needed for MacOS X 10.4 support.
Add "support_macosx_10_4" option to common.gypi that causes it to change deployment target, and define a new preprocessor symbol on the Mac build. Setting this flag to true is harmless on non Mac builds and has no effect.
Make various changes to source files where they modify their behavior in the presence of the new preprocessor symbol to become 10.4 compatible.
Review URL: http://codereview.chromium.org/201122
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26285 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/debug_util_posix.cc')
-rw-r--r-- | base/debug_util_posix.cc | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/base/debug_util_posix.cc b/base/debug_util_posix.cc index 081f4c4..1768234 100644 --- a/base/debug_util_posix.cc +++ b/base/debug_util_posix.cc @@ -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 @@ void DebugUtil::BreakDebugger() { } 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 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"; + 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"; + } + } else { + (*os) << "Backtrace:\n"; + for (int i = 0; i < count_; ++i) { + (*os) << "\t" << trace_symbols.get()[i] << "\n"; + } } } } |