summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authormaf@google.com <maf@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-15 22:42:59 +0000
committermaf@google.com <maf@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-15 22:42:59 +0000
commit9543af0553bba7adab97d3a8a358510449dc2e60 (patch)
tree3eccebdd899ce50369f42b99a46cd04197664ed9 /base
parenta52225ef714d58b30cf87e794f0082a1445b6626 (diff)
downloadchromium_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')
-rw-r--r--base/compat_execinfo.h29
-rw-r--r--base/debug_util_posix.cc48
-rw-r--r--base/file_util_posix.cc3
3 files changed, 59 insertions, 21 deletions
diff --git a/base/compat_execinfo.h b/base/compat_execinfo.h
new file mode 100644
index 0000000..472fa5e
--- /dev/null
+++ b/base/compat_execinfo.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// A file you can include instead of <execinfo.h> if your project might have
+// been compiled with our SUPPORT_MACOSX_10_4 flag defined.
+// If SUPPORT_MACOSX_10_4 is not defined it just includes execinfo.h as normal,
+// otherwise it defines the symbols itself as weak linked imports, which enables
+// launching on 10.4 where they are not defined.
+
+#ifndef BASE_COMPAT_EXECINFO_H
+#define BASE_COMPAT_EXECINFO_H
+
+#ifdef SUPPORT_MACOSX_10_4
+// Manually define these here as weak imports, rather than including execinfo.h.
+// This lets us launch on 10.4 which does not have these calls.
+extern "C" {
+ extern int backtrace(void**, int) __attribute__((weak_import));
+ extern char** backtrace_symbols(void* const*, int)
+ __attribute__((weak_import));
+ extern void backtrace_symbols_fd(void* const*, int, int)
+ __attribute__((weak_import));
+}
+#else
+#include <execinfo.h>
+#endif
+
+#endif // BASE_COMPAT_EXECINFO_H
+
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";
+ }
}
}
}
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 0b7763e..bd18a83 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -32,6 +32,7 @@
#include "base/time.h"
#include "unicode/coll.h"
+
namespace {
class LocaleAwareComparator {
@@ -82,7 +83,7 @@ class LocaleAwareComparator {
namespace file_util {
-#if defined(OS_FREEBSD)
+#if defined(OS_FREEBSD) || defined(SUPPORT_MACOSX_10_4)
typedef struct stat stat_wrapper_t;
static int CallStat(const char *path, stat_wrapper_t *sb) {
return stat(path, sb);