| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/debug/debugger.h" | 5 #include "base/debug/debugger.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/threading/platform_thread.h" | 7 #include "base/threading/platform_thread.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 namespace base { | 10 namespace base { |
| 11 namespace debug { | 11 namespace debug { |
| 12 | 12 |
| 13 static bool is_debug_ui_suppressed = false; | 13 static bool is_debug_ui_suppressed = false; |
| 14 | 14 |
| 15 bool WaitForDebugger(int wait_seconds, bool silent) { | 15 bool WaitForDebugger(int wait_seconds, bool silent) { |
| 16 #if defined(OS_ANDROID) | 16 #if defined(OS_ANDROID) |
| 17 // The pid from which we know which process to attach to are not output by | 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. | 18 // android ddms, so we have to print it out explicitly. |
| 19 DLOG(INFO) << "DebugUtil::WaitForDebugger(pid=" << static_cast<int>(getpid()) | 19 LOG(INFO) << "DebugUtil::WaitForDebugger(pid=" << static_cast<int>(getpid()) |
| 20 << ")"; | 20 << ")"; |
| 21 #endif | 21 #endif |
| 22 for (int i = 0; i < wait_seconds * 10; ++i) { | 22 for (int i = 0; i < wait_seconds * 10; ++i) { |
| 23 if (BeingDebugged()) { | 23 if (BeingDebugged()) { |
| 24 if (!silent) | 24 if (!silent) |
| 25 BreakDebugger(); | 25 BreakDebugger(); |
| 26 return true; | 26 return true; |
| 27 } | 27 } |
| 28 PlatformThread::Sleep(TimeDelta::FromMilliseconds(100)); | 28 PlatformThread::Sleep(TimeDelta::FromMilliseconds(100)); |
| 29 } | 29 } |
| 30 return false; | 30 return false; |
| 31 } | 31 } |
| 32 | 32 |
| 33 void SetSuppressDebugUI(bool suppress) { | 33 void SetSuppressDebugUI(bool suppress) { |
| 34 is_debug_ui_suppressed = suppress; | 34 is_debug_ui_suppressed = suppress; |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool IsDebugUISuppressed() { | 37 bool IsDebugUISuppressed() { |
| 38 return is_debug_ui_suppressed; | 38 return is_debug_ui_suppressed; |
| 39 } | 39 } |
| 40 | 40 |
| 41 } // namespace debug | 41 } // namespace debug |
| 42 } // namespace base | 42 } // namespace base |
| OLD | NEW |