Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2141)

Unified Diff: base/debug/stack_trace.h

Issue 3945002: Move debug-related stuff from base to the base/debug directory and use the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/debug/leak_tracker_unittest.cc ('k') | base/debug/stack_trace.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/stack_trace.h
===================================================================
--- base/debug/stack_trace.h (revision 0)
+++ base/debug/stack_trace.h (working copy)
@@ -2,42 +2,44 @@
// 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_
+#ifndef BASE_DEBUG_STACK_TRACE_H_
+#define BASE_DEBUG_STACK_TRACE_H_
#pragma once
#include <iosfwd>
-#include "base/basictypes.h"
+#include "build/build_config.h"
#if defined(OS_WIN)
struct _EXCEPTION_POINTERS;
#endif
+namespace base {
+namespace debug {
+
// 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
+ // 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);
+
+ // Copying and assignment are allowed with the default functions.
+
+ ~StackTrace();
+
+ // Gets an array of instruction pointer values. |*count| will be set to the
+ // number of elements in the returned array.
+ const void* const* Addresses(size_t* count);
+
// Prints a backtrace to stderr
void PrintBacktrace();
@@ -49,48 +51,13 @@
// 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];
+ static const int kMaxTraces = 62;
+
+ void* trace_[kMaxTraces];
int count_;
};
-class DebugUtil {
- public:
- // Starts the registered system-wide JIT debugger to attach it to specified
- // process.
- static bool SpawnDebuggerOnProcess(unsigned process_id);
+} // namespace debug
+} // namespace base
- // 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
- // translates into a long wait until the process actually dies. This call
- // disables Apple Crash Reporter entirely.
- static void DisableOSCrashDumps();
-#endif // defined(OS_MACOSX)
-
- // This should be used only in test code.
- static void SuppressDialogs() {
- suppress_dialogs_ = true;
- }
-
- private:
- // If true, avoid displaying any dialogs that could cause problems
- // in non-interactive environments.
- static bool suppress_dialogs_;
-};
-
-#endif // BASE_DEBUG_UTIL_H_
+#endif // BASE_DEBUG_STACK_TRACE_H_
« no previous file with comments | « base/debug/leak_tracker_unittest.cc ('k') | base/debug/stack_trace.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698