blob: 1ccee1c2c2f8746277a00670bb726c79d5ec6b88 [file] [log] [blame]
[email protected]3132e35c2011-07-07 20:46:501// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]58580352010-10-26 04:07:502// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "base/debug/debugger.h"
[email protected]3132e35c2011-07-07 20:46:506#include "base/logging.h"
[email protected]ce072a72010-12-31 20:02:167#include "base/threading/platform_thread.h"
aviebe805c2015-12-24 08:20:288#include "build/build_config.h"
[email protected]58580352010-10-26 04:07:509
10namespace base {
11namespace debug {
12
[email protected]d0282962011-01-01 16:08:5213static bool is_debug_ui_suppressed = false;
14
[email protected]58580352010-10-26 04:07:5015bool WaitForDebugger(int wait_seconds, bool silent) {
[email protected]3132e35c2011-07-07 20:46:5016#if defined(OS_ANDROID)
17 // The pid from which we know which process to attach to are not output by
18 // android ddms, so we have to print it out explicitly.
[email protected]a42d4632011-10-26 21:48:0019 DLOG(INFO) << "DebugUtil::WaitForDebugger(pid=" << static_cast<int>(getpid())
20 << ")";
[email protected]3132e35c2011-07-07 20:46:5021#endif
[email protected]58580352010-10-26 04:07:5022 for (int i = 0; i < wait_seconds * 10; ++i) {
23 if (BeingDebugged()) {
24 if (!silent)
25 BreakDebugger();
26 return true;
27 }
[email protected]a1b75b942011-12-31 22:53:5128 PlatformThread::Sleep(TimeDelta::FromMilliseconds(100));
[email protected]58580352010-10-26 04:07:5029 }
30 return false;
31}
32
[email protected]d0282962011-01-01 16:08:5233void SetSuppressDebugUI(bool suppress) {
34 is_debug_ui_suppressed = suppress;
35}
36
37bool IsDebugUISuppressed() {
38 return is_debug_ui_suppressed;
39}
40
[email protected]58580352010-10-26 04:07:5041} // namespace debug
42} // namespace base