diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-26 04:07:50 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-26 04:07:50 +0000 |
commit | 58580359a452cb7c3b9580edc0843c3ab3d158df (patch) | |
tree | 964dbcc1505f4b9c2bbb5e7a64720861d604c8f3 /base/debug_util.h | |
parent | 23872906817de5d402b0c2da6d5f7ee6026378e6 (diff) | |
download | chromium_src-58580359a452cb7c3b9580edc0843c3ab3d158df.zip chromium_src-58580359a452cb7c3b9580edc0843c3ab3d158df.tar.gz chromium_src-58580359a452cb7c3b9580edc0843c3ab3d158df.tar.bz2 |
Move debug-related stuff from base to the base/debug directory and use the
base::debug namespace.
This splits apart debug_util into base/debugger and base/stack_trace
There are still two functions in debug_util that I'm not sure what to do with.
Since this uses the base::debug namespace, I removed the functions in
debugger.h from the static class and just made them free functions in the
namespace.
TEST=it compiles
BUG=none
Review URL: http://codereview.chromium.org/3945002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63859 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/debug_util.h')
-rw-r--r-- | base/debug_util.h | 70 |
1 files changed, 5 insertions, 65 deletions
diff --git a/base/debug_util.h b/base/debug_util.h index a7dba3a..a643ccf 100644 --- a/base/debug_util.h +++ b/base/debug_util.h @@ -2,78 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// This is a cross platform interface for helper functions related to debuggers. -// You should use this to test if you're running under a debugger, and if you -// would like to yield (breakpoint) into the debugger. - #ifndef BASE_DEBUG_UTIL_H_ #define BASE_DEBUG_UTIL_H_ #pragma once -#include <iosfwd> - -#include "base/basictypes.h" - -#if defined(OS_WIN) -struct _EXCEPTION_POINTERS; -#endif - -// A stacktrace can be helpful in debugging. For example, you can include a -// stacktrace member in a object (probably around #ifndef NDEBUG) so that you -// can later see where the given object was created from. -class StackTrace { - public: - // Creates a stacktrace from the current location - StackTrace(); - - // Note that the default copy constructor and assignment constructors - // are OK. - -#if defined(OS_WIN) - // Creates a stacktrace for an exception. - // Note: this function will throw an import not found (StackWalk64) exception - // on system without dbghelp 5.1. - StackTrace(_EXCEPTION_POINTERS* exception_pointers); -#endif - // Gets an array of instruction pointer values. - // count: (output) the number of elements in the returned array - const void *const *Addresses(size_t* count); - // Prints a backtrace to stderr - void PrintBacktrace(); - - // Resolves backtrace to symbols and write to stream. - void OutputToStream(std::ostream* os); - - private: - // From http://msdn.microsoft.com/en-us/library/bb204633.aspx, - // the sum of FramesToSkip and FramesToCapture must be less than 63, - // so set it to 62. Even if on POSIX it could be a larger value, it usually - // doesn't give much more information. - static const int MAX_TRACES = 62; - void* trace_[MAX_TRACES]; - int count_; -}; +#include "build/build_config.h" class DebugUtil { public: - // Starts the registered system-wide JIT debugger to attach it to specified - // process. - static bool SpawnDebuggerOnProcess(unsigned process_id); - - // Waits wait_seconds seconds for a debugger to attach to the current process. - // When silent is false, an exception is thrown when a debugger is detected. - static bool WaitForDebugger(int wait_seconds, bool silent); - - // Are we running under a debugger? - // On OS X, the underlying mechanism doesn't work when the sandbox is enabled. - // To get around this, this function caches its value. - // WARNING: Because of this, on OS X, a call MUST be made to this function - // BEFORE the sandbox is enabled. - static bool BeingDebugged(); - - // Break into the debugger, assumes a debugger is present. - static void BreakDebugger(); - #if defined(OS_MACOSX) // On Mac OS X, it can take a really long time for the OS crash handler to // process a Chrome crash when debugging symbols are available. This @@ -87,6 +23,10 @@ class DebugUtil { suppress_dialogs_ = true; } + static bool AreDialogsSuppressed() { + return suppress_dialogs_; + } + private: // If true, avoid displaying any dialogs that could cause problems // in non-interactive environments. |