diff options
author | jam <jam@chromium.org> | 2015-05-11 11:11:38 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-11 18:12:46 +0000 |
commit | a30f77e9853d7583ed53f1048ac178194737bf38 (patch) | |
tree | e95f268503d504259ae771d80b9df203c3e1f282 /mojo | |
parent | 71b6c7df348b822b5ed223cb8374d0cfe67f445c (diff) | |
download | chromium_src-a30f77e9853d7583ed53f1048ac178194737bf38.zip chromium_src-a30f77e9853d7583ed53f1048ac178194737bf38.tar.gz chromium_src-a30f77e9853d7583ed53f1048ac178194737bf38.tar.bz2 |
Make --wait-for-debugger work for mandoline launcher process.
If specified without any switch values, it'll make the launcher process wait. Otherwise one can use an app name of "launcher".
Review URL: https://codereview.chromium.org/1140553002
Cr-Commit-Position: refs/heads/master@{#329186}
Diffstat (limited to 'mojo')
-rw-r--r-- | mojo/runner/android/main.cc | 1 | ||||
-rw-r--r-- | mojo/runner/child_process.cc | 14 | ||||
-rw-r--r-- | mojo/runner/child_process_host.cc | 11 | ||||
-rw-r--r-- | mojo/runner/init.cc | 34 | ||||
-rw-r--r-- | mojo/runner/init.h | 3 |
5 files changed, 38 insertions, 25 deletions
diff --git a/mojo/runner/android/main.cc b/mojo/runner/android/main.cc index 82ba0b4..df44e1b 100644 --- a/mojo/runner/android/main.cc +++ b/mojo/runner/android/main.cc @@ -156,6 +156,7 @@ static void Init(JNIEnv* env, g_shell_runner.Get().reset(new MojoShellRunner(parameters)); InitializeLogging(); + mojo::runner::WaitForDebuggerIfNecessary(); InitializeRedirection(); diff --git a/mojo/runner/child_process.cc b/mojo/runner/child_process.cc index 3553193..d16c2d7 100644 --- a/mojo/runner/child_process.cc +++ b/mojo/runner/child_process.cc @@ -8,7 +8,6 @@ #include "base/bind.h" #include "base/callback_helpers.h" #include "base/command_line.h" -#include "base/debug/debugger.h" #include "base/files/file_path.h" #include "base/location.h" #include "base/logging.h" @@ -281,19 +280,6 @@ int ChildProcessMain() { DVLOG(2) << "ChildProcessMain()"; const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); - if (command_line.HasSwitch(switches::kWaitForDebugger)) { - std::string app = command_line.GetSwitchValueASCII(switches::kApp); -#if defined(OS_WIN) - MessageBox(NULL, command_line.GetSwitchValueNative(switches::kApp).c_str(), - command_line.GetSwitchValueNative(switches::kApp).c_str(), - MB_OK | MB_SETFOREGROUND); -#else - LOG(ERROR) << command_line.GetSwitchValueASCII(switches::kApp) - << " waiting for GDB. pid: " << getpid(); - base::debug::WaitForDebugger(60, true); -#endif - } - embedder::ScopedPlatformHandle platform_channel = embedder::PlatformChannelPair::PassClientHandleFromParentProcess( command_line); diff --git a/mojo/runner/child_process_host.cc b/mojo/runner/child_process_host.cc index 0a06992c..316a3a3 100644 --- a/mojo/runner/child_process_host.cc +++ b/mojo/runner/child_process_host.cc @@ -13,8 +13,6 @@ #include "base/message_loop/message_loop.h" #include "base/process/kill.h" #include "base/process/launch.h" -#include "base/stl_util.h" -#include "base/strings/string_split.h" #include "base/task_runner.h" #include "base/task_runner_util.h" #include "mojo/edk/embedder/embedder.h" @@ -102,6 +100,7 @@ bool ChildProcessHost::DoLaunch() { switches::kTraceToConsole, switches::kV, switches::kVModule, + switches::kWaitForDebugger, }; const base::CommandLine* parent_command_line = @@ -111,14 +110,6 @@ bool ChildProcessHost::DoLaunch() { arraysize(kForwardSwitches)); child_command_line.AppendSwitchASCII(switches::kApp, name_); child_command_line.AppendSwitch(switches::kChildProcess); - if (parent_command_line->HasSwitch(switches::kWaitForDebugger)) { - std::vector<std::string> apps_to_debug; - base::SplitString( - parent_command_line->GetSwitchValueASCII(switches::kWaitForDebugger), - ',', &apps_to_debug); - if (apps_to_debug.empty() || ContainsValue(apps_to_debug, name_)) - child_command_line.AppendSwitch(switches::kWaitForDebugger); - } auto args = parent_command_line->GetArgs(); for (const auto& arg : args) diff --git a/mojo/runner/init.cc b/mojo/runner/init.cc index 0656c6e..4a8d700 100644 --- a/mojo/runner/init.cc +++ b/mojo/runner/init.cc @@ -4,7 +4,18 @@ #include "mojo/runner/init.h" +#include "base/base_switches.h" +#include "base/command_line.h" +#include "base/debug/debugger.h" #include "base/logging.h" +#include "base/stl_util.h" +#include "base/strings/string_split.h" +#include "base/strings/utf_string_conversions.h" +#include "mojo/runner/switches.h" + +#if defined(OS_WIN) +#include <windows.h> +#endif namespace mojo { namespace runner { @@ -20,5 +31,28 @@ void InitializeLogging() { false); // Tick count } +void WaitForDebuggerIfNecessary() { + const base::CommandLine* command_line = + base::CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kWaitForDebugger)) { + std::vector<std::string> apps_to_debug; + base::SplitString( + command_line->GetSwitchValueASCII(switches::kWaitForDebugger), ',', + &apps_to_debug); + std::string app = command_line->GetSwitchValueASCII(switches::kApp); + if (app.empty()) + app = "launcher"; // If we're not in a child process look for "launcher". + if (apps_to_debug.empty() || ContainsValue(apps_to_debug, app)) { +#if defined(OS_WIN) + base::string16 appw = base::UTF8ToUTF16(app); + MessageBox(NULL, appw.c_str(), appw.c_str(), MB_OK | MB_SETFOREGROUND); +#else + LOG(ERROR) << app << " waiting for GDB. pid: " << getpid(); + base::debug::WaitForDebugger(60, true); +#endif + } + } +} + } // namespace runner } // namespace mojo diff --git a/mojo/runner/init.h b/mojo/runner/init.h index 4db9896..c4e8abd 100644 --- a/mojo/runner/init.h +++ b/mojo/runner/init.h @@ -9,9 +9,10 @@ namespace mojo { namespace runner { // Initialization routines shared by desktop and Android main functions. - void InitializeLogging(); +void WaitForDebuggerIfNecessary(); + } // namespace runner } // namespace mojo |