diff options
-rw-r--r-- | base/compat_execinfo.h | 29 | ||||
-rw-r--r-- | base/debug_util_posix.cc | 48 | ||||
-rw-r--r-- | base/file_util_posix.cc | 3 | ||||
-rw-r--r-- | build/common.gypi | 22 | ||||
-rw-r--r-- | o3d/DEPS_gyp | 3 |
5 files changed, 82 insertions, 23 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); diff --git a/build/common.gypi b/build/common.gypi index 7b8ad12..757c8c5 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -52,6 +52,16 @@ # Linux-Mac cross compiler distcc farm. 'chromium_mac_pch%': 1, + # We normally expect MacOS X 10.5 at runtime in the product generated. + # Set to 1 to enable MacOS X 10.4 support where possible. + # Harmless to set on other platforms, as it has no effect. + # This is designed so that products such as O3D can use some Chrome source + # without losing 10.4 support. + # Look for support_macosx_10_4 later in the file to see where it turns on + # compile flags, defines SUPPORT_MACOSX_10_4 in the C preprocessor, + # and changes the Xcode deployment target setting. + 'support_macosx_10_4%': 0, + # Set to 1 to enable code coverage. In addition to build changes # (e.g. extra CFLAGS), also creates a new target in the src/chrome # project file called "coverage". @@ -611,7 +621,17 @@ 'WARNING_CFLAGS': ['-Wall', '-Wendif-labels'], 'conditions': [ ['chromium_mac_pch', {'GCC_PRECOMPILE_PREFIX_HEADER': 'YES'}, - {'GCC_PRECOMPILE_PREFIX_HEADER': 'NO'}], + {'GCC_PRECOMPILE_PREFIX_HEADER': 'NO'} + ], + ['support_macosx_10_4', + { + 'OTHER_CFLAGS': ['-D', 'SUPPORT_MACOSX_10_4',], + 'MACOSX_DEPLOYMENT_TARGET': '10.4', # mmacosx-version-min=10.4 + }, + { + 'MACOSX_DEPLOYMENT_TARGET': '10.5', # mmacosx-version-min=10.5 + } + ], ], }, 'target_conditions': [ diff --git a/o3d/DEPS_gyp b/o3d/DEPS_gyp index e792fab..dcf7530 100644 --- a/o3d/DEPS_gyp +++ b/o3d/DEPS_gyp @@ -145,6 +145,7 @@ hooks = [ { # A change to a .gyp, .gypi, or to GYP itself shound run the generator. "pattern": "\\.gypi?$|[/\\\\]src[/\\\\]tools[/\\\\]gyp[/\\\\]|MANIFEST$", - "action": ["python", "tools/gyp/gyp", "o3d/build/all.gyp", "--depth", "."], + "action": ["python", "tools/gyp/gyp", "o3d/build/all.gyp", "--depth", ".", + "-D", "support_macosx_10_4=1"], }, ] |