LibWebView+UI: Allow debugging any helper process

This removes the --debug-web-content flag, and replaces it with a
--debug-process=<process-name> flag. For example:

    ladybird --debug-process=WebContent
    ladybird --debug-process=RequestServer

This allows attaching gdb to any helper process.
This commit is contained in:
Timothy Flynn 2024-08-01 07:03:03 -04:00 committed by Andreas Kling
commit 7106a7bd58
Notes: github-actions[bot] 2024-08-01 13:41:42 +00:00
6 changed files with 35 additions and 12 deletions

View file

@ -38,9 +38,9 @@ void Application::initialize(Main::Arguments const& arguments, URL::URL new_tab_
bool force_new_process = false;
bool allow_popups = false;
bool disable_sql_database = false;
Optional<StringView> debug_process;
Optional<StringView> webdriver_content_ipc_path;
bool enable_callgrind_profiling = false;
bool debug_web_content = false;
bool log_all_js_exceptions = false;
bool enable_idl_tracing = false;
bool enable_http_cache = false;
@ -54,9 +54,9 @@ void Application::initialize(Main::Arguments const& arguments, URL::URL new_tab_
args_parser.add_option(force_new_process, "Force creation of new browser/chrome process", "force-new-process");
args_parser.add_option(allow_popups, "Disable popup blocking by default", "allow-popups");
args_parser.add_option(disable_sql_database, "Disable SQL database", "disable-sql-database");
args_parser.add_option(debug_process, "Wait for a debugger to attach to the given process name (WebContent, RequestServer, etc.)", "debug-process", 0, "process-name");
args_parser.add_option(webdriver_content_ipc_path, "Path to WebDriver IPC for WebContent", "webdriver-content-path", 0, "path", Core::ArgsParser::OptionHideMode::CommandLineAndMarkdown);
args_parser.add_option(enable_callgrind_profiling, "Enable Callgrind profiling", "enable-callgrind-profiling", 'P');
args_parser.add_option(debug_web_content, "Wait for debugger to attach to WebContent", "debug-web-content");
args_parser.add_option(log_all_js_exceptions, "Log all JavaScript exceptions", "log-all-js-exceptions");
args_parser.add_option(enable_idl_tracing, "Enable IDL tracing", "enable-idl-tracing");
args_parser.add_option(enable_http_cache, "Enable HTTP cache", "enable-http-cache");
@ -65,6 +65,10 @@ void Application::initialize(Main::Arguments const& arguments, URL::URL new_tab_
create_platform_arguments(args_parser);
args_parser.parse(arguments);
Optional<ProcessType> debug_process_type;
if (debug_process.has_value())
debug_process_type = process_type_from_name(*debug_process);
m_chrome_options = {
.urls = sanitize_urls(raw_urls, new_tab_page_url),
.raw_urls = move(raw_urls),
@ -74,6 +78,7 @@ void Application::initialize(Main::Arguments const& arguments, URL::URL new_tab_
.force_new_process = force_new_process ? ForceNewProcess::Yes : ForceNewProcess::No,
.allow_popups = allow_popups ? AllowPopups::Yes : AllowPopups::No,
.disable_sql_database = disable_sql_database ? DisableSQLDatabase::Yes : DisableSQLDatabase::No,
.debug_helper_process = move(debug_process_type),
};
if (webdriver_content_ipc_path.has_value())
@ -83,7 +88,6 @@ void Application::initialize(Main::Arguments const& arguments, URL::URL new_tab_
.command_line = MUST(String::join(' ', arguments.strings)),
.executable_path = MUST(String::from_byte_string(MUST(Core::System::current_executable_path()))),
.enable_callgrind_profiling = enable_callgrind_profiling ? EnableCallgrindProfiling::Yes : EnableCallgrindProfiling::No,
.wait_for_debugger = debug_web_content ? WaitForDebugger::Yes : WaitForDebugger::No,
.log_all_js_exceptions = log_all_js_exceptions ? LogAllJSExceptions::Yes : LogAllJSExceptions::No,
.enable_idl_tracing = enable_idl_tracing ? EnableIDLTracing::Yes : EnableIDLTracing::No,
.enable_http_cache = enable_http_cache ? EnableHTTPCache::Yes : EnableHTTPCache::No,