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