15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2010 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/debug/debugger.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
70529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include <stdlib.h>
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <windows.h>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace base {
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace debug {
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool BeingDebugged() {
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return ::IsDebuggerPresent() != 0;
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void BreakDebugger() {
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (IsDebugUISuppressed())
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    _exit(1);
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  __debugbreak();
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(NDEBUG)
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  _exit(1);
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace debug
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace base
28