Commit 2ee428f6 authored by sky's avatar sky Committed by Commit bot

Makes wait-for-debugger=content_browser work for mash

This changes the command line switch "n" to "process-service-name" and
makes mash-runner look for it.

BUG=none
TEST=none
R=rockot@chromium.org

Review-Url: https://codereview.chromium.org/2571603002
Cr-Commit-Position: refs/heads/master@{#437999}
parent 378f5a72
...@@ -94,6 +94,7 @@ int ChromeMain(int argc, const char** argv) { ...@@ -94,6 +94,7 @@ int ChromeMain(int argc, const char** argv) {
*base::CommandLine::ForCurrentProcess(); *base::CommandLine::ForCurrentProcess();
if (command_line.HasSwitch("mash")) if (command_line.HasSwitch("mash"))
return MashMain(); return MashMain();
WaitForMashDebuggerIfNecessary();
} }
#endif // BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) #endif // BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/at_exit.h" #include "base/at_exit.h"
#include "base/base_paths.h" #include "base/base_paths.h"
#include "base/base_switches.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/debug/debugger.h" #include "base/debug/debugger.h"
...@@ -16,6 +17,7 @@ ...@@ -16,6 +17,7 @@
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/process/launch.h" #include "base/process/launch.h"
#include "base/process/process.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/task_scheduler/task_scheduler.h" #include "base/task_scheduler/task_scheduler.h"
#include "base/threading/sequenced_worker_pool.h" #include "base/threading/sequenced_worker_pool.h"
...@@ -36,6 +38,7 @@ ...@@ -36,6 +38,7 @@
#include "services/service_manager/public/cpp/service_context.h" #include "services/service_manager/public/cpp/service_context.h"
#include "services/service_manager/public/cpp/standalone_service/standalone_service.h" #include "services/service_manager/public/cpp/standalone_service/standalone_service.h"
#include "services/service_manager/public/interfaces/service_factory.mojom.h" #include "services/service_manager/public/interfaces/service_factory.mojom.h"
#include "services/service_manager/runner/common/client_util.h"
#include "services/service_manager/runner/common/switches.h" #include "services/service_manager/runner/common/switches.h"
#include "services/service_manager/runner/init.h" #include "services/service_manager/runner/init.h"
#include "services/service_manager/standalone/context.h" #include "services/service_manager/standalone/context.h"
...@@ -242,3 +245,23 @@ int MashMain() { ...@@ -242,3 +245,23 @@ int MashMain() {
MashRunner mash_runner; MashRunner mash_runner;
return mash_runner.Run(); return mash_runner.Run();
} }
void WaitForMashDebuggerIfNecessary() {
if (!service_manager::ServiceManagerIsRemote())
return;
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
const std::string service_name =
command_line->GetSwitchValueASCII(switches::kProcessServiceName);
if (service_name !=
command_line->GetSwitchValueASCII(switches::kWaitForDebugger)) {
return;
}
// Include the pid as logging may not have been initialized yet (the pid
// printed out by logging is wrong).
LOG(WARNING) << "waiting for debugger to attach for service " << service_name
<< " pid=" << base::Process::Current().Pid();
base::debug::WaitForDebugger(120, true);
}
...@@ -40,4 +40,8 @@ class MashRunner { ...@@ -40,4 +40,8 @@ class MashRunner {
int MashMain(); int MashMain();
// Called if the command line isn't mash to potentially wait for a debugger
// to attach.
void WaitForMashDebuggerIfNecessary();
#endif // CHROME_APP_MASH_MASH_RUNNER_H_ #endif // CHROME_APP_MASH_MASH_RUNNER_H_
...@@ -18,6 +18,9 @@ const char kEnableSandbox[] = "enable-sandbox"; ...@@ -18,6 +18,9 @@ const char kEnableSandbox[] = "enable-sandbox";
// primordial message pipe to the parent. // primordial message pipe to the parent.
const char kPrimordialPipeToken[] = "primordial-pipe-token"; const char kPrimordialPipeToken[] = "primordial-pipe-token";
// The name of the service the process is starting for.
const char kProcessServiceName[] = "process-service-name";
// Specifies a JSON file from which to read a set of service metadata overrides. // Specifies a JSON file from which to read a set of service metadata overrides.
// This can be used with the standalone mojo_runner to override executable and // This can be used with the standalone mojo_runner to override executable and
// package resolution behavior. // package resolution behavior.
......
...@@ -12,6 +12,7 @@ namespace switches { ...@@ -12,6 +12,7 @@ namespace switches {
extern const char kChildProcess[]; extern const char kChildProcess[];
extern const char kEnableSandbox[]; extern const char kEnableSandbox[];
extern const char kPrimordialPipeToken[]; extern const char kPrimordialPipeToken[];
extern const char kProcessServiceName[];
extern const char kServiceOverrides[]; extern const char kServiceOverrides[];
} // namespace switches } // namespace switches
......
...@@ -81,8 +81,9 @@ mojom::ServicePtr ChildProcessHost::Start( ...@@ -81,8 +81,9 @@ mojom::ServicePtr ChildProcessHost::Start(
child_command_line->AppendArguments(parent_command_line, false); child_command_line->AppendArguments(parent_command_line, false);
child_command_line->AppendSwitchASCII(::switches::kProcessServiceName,
target.name());
#ifndef NDEBUG #ifndef NDEBUG
child_command_line->AppendSwitchASCII("n", target.name());
child_command_line->AppendSwitchASCII("u", target.user_id()); child_command_line->AppendSwitchASCII("u", target.user_id());
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment