From 2092674e7b11b8fd62c224c342d06732c17122a2 Mon Sep 17 00:00:00 2001 From: Alex Gough Date: Thu, 13 May 2021 20:11:30 +0000 Subject: [PATCH] Allow selection of utility sub type in utility-startup-dialog This CL enhances the --utility-startup-dialog switch to now take an optional service sub type, and displays the subtype when waiting for the debugger, or showing the dialog. `chrome --utility-startup-dialog` works as before, prompting/pausing for every utility process. `chrome --utility-startup-dialog=data_decoder.mojom.DataDecoderService` only prompts for the data decoder service. We check for the switch first then interrogate its value to limit any impact on normal startup time. This should make it easier to debug specific utility processes. Tests: manual tested on Windows & Linux Change-Id: I0195432a9f826697a87c687406a30dbdf1bfa378 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2892176 Reviewed-by: Alex Moshchuk Commit-Queue: Alex Gough Cr-Commit-Position: refs/heads/master@{#882668} --- content/utility/utility_main.cc | 11 +++++++++-- docs/linux/debugging.md | 4 ++++ docs/mac/debugging.md | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/content/utility/utility_main.cc b/content/utility/utility_main.cc index 30fd82de7901d6..791ef502d64393 100644 --- a/content/utility/utility_main.cc +++ b/content/utility/utility_main.cc @@ -103,8 +103,15 @@ int UtilityMain(const MainFunctionParams& parameters) { base::SingleThreadTaskExecutor main_thread_task_executor(message_pump_type); base::PlatformThread::SetName("CrUtilityMain"); - if (parameters.command_line.HasSwitch(switches::kUtilityStartupDialog)) - WaitForDebugger("Utility"); + if (parameters.command_line.HasSwitch(switches::kUtilityStartupDialog)) { + auto dialog_match = parameters.command_line.GetSwitchValueASCII( + switches::kUtilityStartupDialog); + auto sub_type = + parameters.command_line.GetSwitchValueASCII(switches::kUtilitySubType); + if (dialog_match.empty() || dialog_match == sub_type) { + WaitForDebugger(sub_type.empty() ? "Utility" : sub_type); + } + } #if defined(OS_LINUX) || defined(OS_CHROMEOS) // Initializes the sandbox before any threads are created. diff --git a/docs/linux/debugging.md b/docs/linux/debugging.md index 9ecefa546cd473..38e4d9603bea2a 100644 --- a/docs/linux/debugging.md +++ b/docs/linux/debugging.md @@ -83,6 +83,10 @@ to debug the renderer code. Go to https://www.chromium.org/blink/getting-started-with-blink-debugging for more information on how this can be done. +For utilities you can use `--utility-startup-dialog` to have all utilities +prompt, or `--utility-startup-dialog=data_decoder.mojom.DataDecoderService` +to debug only a particular service type. + #### Choosing which renderers to debug If you are starting multiple renderers then the above means that multiple gdb's diff --git a/docs/mac/debugging.md b/docs/mac/debugging.md index 8cd36e961c05ee..420faef475523a 100644 --- a/docs/mac/debugging.md +++ b/docs/mac/debugging.md @@ -173,7 +173,7 @@ these startup-dialog switches for the relevant process type: * `--renderer-startup-dialog` * `--utility-startup-dialog` -* `--renderer-startup-dialog` +* `--utility-startup-dialog=data_decoder.mojom.DataDecoderService` After the process launches, it will print a message like this to standard error: