Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 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 | 6 #include "base/logging.h" |
| 7 #include "base/threading/platform_thread.h" | 7 #include "base/threading/platform_thread.h" |
| 8 | 8 |
| 9 namespace base { | 9 namespace base { |
| 10 namespace debug { | 10 namespace debug { |
| 11 | 11 |
| 12 static bool is_debug_ui_suppressed = false; | 12 static bool is_debug_ui_suppressed = false; |
| 13 | 13 |
| 14 bool WaitForDebugger(int wait_seconds, bool silent) { | 14 bool WaitForDebugger(int wait_seconds, bool silent) { |
| 15 | |
| 16 #if defined(OS_ANDROID) | |
|
brettw
2011/06/24 22:23:57
It's not clear why we need a log statement for And
michaelbai
2011/06/24 23:30:44
The pid from which we know which process to attach
brettw
2011/06/29 16:42:28
Can we make the comment say what you just said the
michaelbai
2011/06/29 17:18:46
Done.
| |
| 17 // pid prefix in normal LOG statements can get lost if using ddms. | |
| 18 // Thus we add an explicit pid printout here. | |
| 19 LOG(INFO) << "DebugUtil::WaitForDebugger(pid=" << (int)getpid() << ")"; | |
|
brettw
2011/06/29 16:42:28
We're not supposed to use C-style casts. I think y
michaelbai
2011/06/29 17:18:46
Done.
| |
| 20 #endif | |
| 21 | |
| 15 for (int i = 0; i < wait_seconds * 10; ++i) { | 22 for (int i = 0; i < wait_seconds * 10; ++i) { |
| 16 if (BeingDebugged()) { | 23 if (BeingDebugged()) { |
| 17 if (!silent) | 24 if (!silent) |
| 18 BreakDebugger(); | 25 BreakDebugger(); |
| 19 return true; | 26 return true; |
| 20 } | 27 } |
| 21 PlatformThread::Sleep(100); | 28 PlatformThread::Sleep(100); |
| 22 } | 29 } |
| 23 return false; | 30 return false; |
| 24 } | 31 } |
| 25 | 32 |
| 26 void SetSuppressDebugUI(bool suppress) { | 33 void SetSuppressDebugUI(bool suppress) { |
| 27 is_debug_ui_suppressed = suppress; | 34 is_debug_ui_suppressed = suppress; |
| 28 } | 35 } |
| 29 | 36 |
| 30 bool IsDebugUISuppressed() { | 37 bool IsDebugUISuppressed() { |
| 31 return is_debug_ui_suppressed; | 38 return is_debug_ui_suppressed; |
| 32 } | 39 } |
| 33 | 40 |
| 34 } // namespace debug | 41 } // namespace debug |
| 35 } // namespace base | 42 } // namespace base |
| OLD | NEW |