blob: 77bde0d3675a68e7200df2580e02db058119b048 [file] [log] [blame]
[email protected]58580352010-10-26 04:07:501// Copyright (c) 2010 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
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
9#ifndef BASE_DEBUG_DEBUGGER_H
10#define BASE_DEBUG_DEBUGGER_H
11#pragma once
12
13namespace base {
14namespace debug {
15
16// Starts the registered system-wide JIT debugger to attach it to specified
17// process.
18bool SpawnDebuggerOnProcess(unsigned process_id);
19
20// Waits wait_seconds seconds for a debugger to attach to the current process.
21// When silent is false, an exception is thrown when a debugger is detected.
22bool WaitForDebugger(int wait_seconds, bool silent);
23
24// Returns true if the given process is being run under a debugger.
25//
26// On OS X, the underlying mechanism doesn't work when the sandbox is enabled.
27// To get around this, this function caches its value.
28//
29// WARNING: Because of this, on OS X, a call MUST be made to this function
30// BEFORE the sandbox is enabled.
31bool BeingDebugged();
32
33// Break into the debugger, assumes a debugger is present.
34void BreakDebugger();
35
[email protected]d0282962011-01-01 16:08:5236// Used in test code, this controls whether showing dialogs and breaking into
37// the debugger is suppressed for debug errors, even in debug mode (normally
38// release mode doesn't do this stuff -- this is controlled separately).
39// Normally UI is not suppressed. This is normally used when running automated
40// tests where we want a crash rather than a dialog or a debugger.
41void SetSuppressDebugUI(bool suppress);
42bool IsDebugUISuppressed();
43
[email protected]58580352010-10-26 04:07:5044} // namespace debug
45} // namespace base
46
47#endif // BASE_DEBUG_DEBUGGER_H