| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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/debug_on_start.h" |
| 6 |
| 5 #include <windows.h> | 7 #include <windows.h> |
| 6 | 8 |
| 7 #include "base/debug_on_start.h" | |
| 8 | |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/debug/debugger.h" | 11 #include "base/debug/debugger.h" |
| 12 | 12 |
| 13 namespace base { |
| 14 namespace debug { |
| 15 |
| 13 // Minimalist implementation to try to find a command line argument. We can use | 16 // Minimalist implementation to try to find a command line argument. We can use |
| 14 // kernel32 exported functions but not the CRT functions because we're too early | 17 // kernel32 exported functions but not the CRT functions because we're too early |
| 15 // in the process startup. | 18 // in the process startup. |
| 16 // The code is not that bright and will find things like ---argument or | 19 // The code is not that bright and will find things like ---argument or |
| 17 // /-/argument. | 20 // /-/argument. |
| 18 // Note: command_line is non-destructively modified. | 21 // Note: command_line is non-destructively modified. |
| 19 bool DebugOnStart::FindArgument(wchar_t* command_line, const char* argument_c) { | 22 bool DebugOnStart::FindArgument(wchar_t* command_line, const char* argument_c) { |
| 20 wchar_t argument[50]; | 23 wchar_t argument[50]; |
| 21 for (int i = 0; argument_c[i]; ++i) | 24 for (int i = 0; argument_c[i]; ++i) |
| 22 argument[i] = argument_c[i]; | 25 argument[i] = argument_c[i]; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 base::debug::SpawnDebuggerOnProcess(GetCurrentProcessId()); | 62 base::debug::SpawnDebuggerOnProcess(GetCurrentProcessId()); |
| 60 | 63 |
| 61 // Wait for a debugger to come take us. | 64 // Wait for a debugger to come take us. |
| 62 base::debug::WaitForDebugger(60, false); | 65 base::debug::WaitForDebugger(60, false); |
| 63 } else if (FindArgument(GetCommandLine(), switches::kWaitForDebugger)) { | 66 } else if (FindArgument(GetCommandLine(), switches::kWaitForDebugger)) { |
| 64 // Wait for a debugger to come take us. | 67 // Wait for a debugger to come take us. |
| 65 base::debug::WaitForDebugger(60, true); | 68 base::debug::WaitForDebugger(60, true); |
| 66 } | 69 } |
| 67 return 0; | 70 return 0; |
| 68 } | 71 } |
| 72 |
| 73 } // namespace debug |
| 74 } // namespace base |
| OLD | NEW |