Skip to content

Commit

Permalink
Allow selection of utility sub type in utility-startup-dialog
Browse files Browse the repository at this point in the history
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 <alexmos@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#882668}
  • Loading branch information
quidity authored and Chromium LUCI CQ committed May 13, 2021
1 parent 65c14a3 commit 2092674
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 9 additions & 2 deletions content/utility/utility_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions docs/linux/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/mac/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit 2092674

Please sign in to comment.