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