debugger.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. // This is a cross platform interface for helper functions related to
  5. // debuggers. You should use this to test if you're running under a debugger,
  6. // and if you would like to yield (breakpoint) into the debugger.
  7. #ifndef BASE_DEBUG_DEBUGGER_H
  8. #define BASE_DEBUG_DEBUGGER_H
  9. #include "base/base_export.h"
  10. namespace base {
  11. namespace debug {
  12. // Waits wait_seconds seconds for a debugger to attach to the current process.
  13. // When silent is false, an exception is thrown when a debugger is detected.
  14. BASE_EXPORT bool WaitForDebugger(int wait_seconds, bool silent);
  15. // Returns true if the given process is being run under a debugger.
  16. //
  17. // On OS X, the underlying mechanism doesn't work when the sandbox is enabled.
  18. // To get around this, this function caches its value.
  19. //
  20. // WARNING: Because of this, on OS X, a call MUST be made to this function
  21. // BEFORE the sandbox is enabled.
  22. BASE_EXPORT bool BeingDebugged();
  23. // Break into the debugger, assumes a debugger is present.
  24. BASE_EXPORT void BreakDebugger();
  25. // Used in test code, this controls whether showing dialogs and breaking into
  26. // the debugger is suppressed for debug errors, even in debug mode (normally
  27. // release mode doesn't do this stuff -- this is controlled separately).
  28. // Normally UI is not suppressed. This is normally used when running automated
  29. // tests where we want a crash rather than a dialog or a debugger.
  30. BASE_EXPORT void SetSuppressDebugUI(bool suppress);
  31. BASE_EXPORT bool IsDebugUISuppressed();
  32. } // namespace debug
  33. } // namespace base
  34. #endif // BASE_DEBUG_DEBUGGER_H