From d1fc4379e70ad0c3bb1158413ac0687cc5d8570a Mon Sep 17 00:00:00 2001 From: "mark@chromium.org" Date: Fri, 16 Jan 2009 22:06:19 +0000 Subject: "Port" StackTrace to Mac Review URL: http://codereview.chromium.org/18173 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8229 0039d316-1c4b-4281-b951-d872f2087c98 --- base/debug_util.cc | 6 ++++++ base/debug_util_posix.cc | 28 ++-------------------------- base/debug_util_win.cc | 5 ----- 3 files changed, 8 insertions(+), 31 deletions(-) diff --git a/base/debug_util.cc b/base/debug_util.cc index 497dbe7..2db3aa7 100644 --- a/base/debug_util.cc +++ b/base/debug_util.cc @@ -18,3 +18,9 @@ bool DebugUtil::WaitForDebugger(int wait_seconds, bool silent) { return false; } +const void *const *StackTrace::Addresses(size_t* count) { + *count = trace_.size(); + if (trace_.size()) + return &trace_[0]; + return NULL; +} diff --git a/base/debug_util_posix.cc b/base/debug_util_posix.cc index 5594737..3a25017 100644 --- a/base/debug_util_posix.cc +++ b/base/debug_util_posix.cc @@ -5,13 +5,9 @@ #include "build/build_config.h" #include "base/debug_util.h" -#if defined(OS_LINUX) -#include #include -#endif - -#include #include +#include #include #include #include @@ -98,10 +94,8 @@ void DebugUtil::BreakDebugger() { asm ("int3"); } -#if defined(OS_LINUX) - StackTrace::StackTrace() { - static const unsigned kMaxCallers = 256; + static const int kMaxCallers = 256; void* callers[kMaxCallers]; int count = backtrace(callers, kMaxCallers); @@ -113,21 +107,3 @@ void StackTrace::PrintBacktrace() { fflush(stderr); backtrace_symbols_fd(&trace_[0], trace_.size(), STDERR_FILENO); } - -#elif defined(OS_MACOSX) - -// TODO(port): complete this code -StackTrace::StackTrace() { } - -void StackTrace::PrintBacktrace() { - NOTIMPLEMENTED(); -} - -#endif // defined(OS_MACOSX) - -const void *const *StackTrace::Addresses(size_t* count) { - *count = trace_.size(); - if (trace_.size()) - return &trace_[0]; - return NULL; -} diff --git a/base/debug_util_win.cc b/base/debug_util_win.cc index 922a58b..a41f1b3 100644 --- a/base/debug_util_win.cc +++ b/base/debug_util_win.cc @@ -106,11 +106,6 @@ void DebugUtil::BreakDebugger() { StackTrace::StackTrace() { } -const void *const *StackTrace::Addresses(size_t* count) { - *count = 0; - return NULL; -} - void PrintBacktrace() { NOTIMPLEMENTED(); } -- cgit v1.1