michael@0: // Copyright (c) 2011 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: // This is a cross platform interface for helper functions related to michael@0: // debuggers. You should use this to test if you're running under a debugger, michael@0: // and if you would like to yield (breakpoint) into the debugger. michael@0: michael@0: #ifndef BASE_DEBUG_DEBUGGER_H michael@0: #define BASE_DEBUG_DEBUGGER_H michael@0: michael@0: #include "base/base_export.h" michael@0: michael@0: namespace base { michael@0: namespace debug { michael@0: michael@0: // Starts the registered system-wide JIT debugger to attach it to specified michael@0: // process. michael@0: BASE_EXPORT bool SpawnDebuggerOnProcess(unsigned process_id); michael@0: michael@0: // Waits wait_seconds seconds for a debugger to attach to the current process. michael@0: // When silent is false, an exception is thrown when a debugger is detected. michael@0: BASE_EXPORT bool WaitForDebugger(int wait_seconds, bool silent); michael@0: michael@0: // Returns true if the given process is being run under a debugger. michael@0: // michael@0: // On OS X, the underlying mechanism doesn't work when the sandbox is enabled. michael@0: // To get around this, this function caches its value. michael@0: // michael@0: // WARNING: Because of this, on OS X, a call MUST be made to this function michael@0: // BEFORE the sandbox is enabled. michael@0: BASE_EXPORT bool BeingDebugged(); michael@0: michael@0: // Break into the debugger, assumes a debugger is present. michael@0: BASE_EXPORT void BreakDebugger(); michael@0: michael@0: // Used in test code, this controls whether showing dialogs and breaking into michael@0: // the debugger is suppressed for debug errors, even in debug mode (normally michael@0: // release mode doesn't do this stuff -- this is controlled separately). michael@0: // Normally UI is not suppressed. This is normally used when running automated michael@0: // tests where we want a crash rather than a dialog or a debugger. michael@0: BASE_EXPORT void SetSuppressDebugUI(bool suppress); michael@0: BASE_EXPORT bool IsDebugUISuppressed(); michael@0: michael@0: } // namespace debug michael@0: } // namespace base michael@0: michael@0: #endif // BASE_DEBUG_DEBUGGER_H