[email protected] | 3132e35c | 2011-07-07 20:46:50 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 5858035 | 2010-10-26 04:07:50 | [diff] [blame] | 2 | // 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] | 3132e35c | 2011-07-07 20:46:50 | [diff] [blame] | 6 | #include "base/logging.h" |
[email protected] | ce072a7 | 2010-12-31 20:02:16 | [diff] [blame] | 7 | #include "base/threading/platform_thread.h" |
avi | ebe805c | 2015-12-24 08:20:28 | [diff] [blame] | 8 | #include "build/build_config.h" |
[email protected] | 5858035 | 2010-10-26 04:07:50 | [diff] [blame] | 9 | |
10 | namespace base { | ||||
11 | namespace debug { | ||||
12 | |||||
[email protected] | d028296 | 2011-01-01 16:08:52 | [diff] [blame] | 13 | static bool is_debug_ui_suppressed = false; |
14 | |||||
[email protected] | 5858035 | 2010-10-26 04:07:50 | [diff] [blame] | 15 | bool WaitForDebugger(int wait_seconds, bool silent) { |
[email protected] | 3132e35c | 2011-07-07 20:46:50 | [diff] [blame] | 16 | #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] | a42d463 | 2011-10-26 21:48:00 | [diff] [blame] | 19 | DLOG(INFO) << "DebugUtil::WaitForDebugger(pid=" << static_cast<int>(getpid()) |
20 | << ")"; | ||||
[email protected] | 3132e35c | 2011-07-07 20:46:50 | [diff] [blame] | 21 | #endif |
[email protected] | 5858035 | 2010-10-26 04:07:50 | [diff] [blame] | 22 | for (int i = 0; i < wait_seconds * 10; ++i) { |
23 | if (BeingDebugged()) { | ||||
24 | if (!silent) | ||||
25 | BreakDebugger(); | ||||
26 | return true; | ||||
27 | } | ||||
[email protected] | a1b75b94 | 2011-12-31 22:53:51 | [diff] [blame] | 28 | PlatformThread::Sleep(TimeDelta::FromMilliseconds(100)); |
[email protected] | 5858035 | 2010-10-26 04:07:50 | [diff] [blame] | 29 | } |
30 | return false; | ||||
31 | } | ||||
32 | |||||
[email protected] | d028296 | 2011-01-01 16:08:52 | [diff] [blame] | 33 | void SetSuppressDebugUI(bool suppress) { |
34 | is_debug_ui_suppressed = suppress; | ||||
35 | } | ||||
36 | |||||
37 | bool IsDebugUISuppressed() { | ||||
38 | return is_debug_ui_suppressed; | ||||
39 | } | ||||
40 | |||||
[email protected] | 5858035 | 2010-10-26 04:07:50 | [diff] [blame] | 41 | } // namespace debug |
42 | } // namespace base |