Ladybird: Add command line flag to wait for debugger in WebContent

This commit is contained in:
Andrew Kaster 2023-12-20 09:52:17 -07:00 committed by Andreas Kling
parent b4a8d2a19f
commit 1e68e484cc
5 changed files with 21 additions and 0 deletions

View file

@ -43,12 +43,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Vector<StringView> raw_urls;
StringView webdriver_content_ipc_path;
bool use_gpu_painting = false;
bool debug_web_content = false;
Core::ArgsParser args_parser;
args_parser.set_general_help("The Ladybird web browser");
args_parser.add_positional_argument(raw_urls, "URLs to open", "url", Core::ArgsParser::Required::No);
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(use_gpu_painting, "Enable GPU painting", "enable-gpu-painting", 0);
args_parser.add_option(debug_web_content, "Wait for debugger to attach to WebContent", "debug-web-content", 0);
args_parser.parse(arguments);
auto sql_server_paths = TRY(get_paths_for_helper_process("SQLServer"sv));
@ -69,6 +71,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Ladybird::WebContentOptions web_content_options {
.enable_gpu_painting = use_gpu_painting ? Ladybird::EnableGPUPainting::Yes : Ladybird::EnableGPUPainting::No,
.use_lagom_networking = Ladybird::UseLagomNetworking::Yes,
.debug_web_content = debug_web_content ? Ladybird::DebugWebContent::Yes : Ladybird::DebugWebContent::No,
};
auto* delegate = [[ApplicationDelegate alloc] init:move(initial_urls)

View file

@ -55,6 +55,8 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(
arguments.append("--use-lagom-networking"sv);
if (web_content_options.enable_gpu_painting == Ladybird::EnableGPUPainting::Yes)
arguments.append("--use-gpu-painting"sv);
if (web_content_options.wait_for_debugger == Ladybird::WaitForDebugger::Yes)
arguments.append("--wait-for-debugger"sv);
result = Core::System::exec(arguments[0], arguments.span(), Core::System::SearchInPath::Yes);
if (!result.is_error())

View file

@ -109,6 +109,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
bool disable_sql_database = false;
bool enable_qt_networking = false;
bool use_gpu_painting = false;
bool debug_web_content = false;
Core::ArgsParser args_parser;
args_parser.set_general_help("The Ladybird web browser :^)");
@ -118,6 +119,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_option(disable_sql_database, "Disable SQL database", "disable-sql-database", 0);
args_parser.add_option(enable_qt_networking, "Enable Qt as the backend networking service", "enable-qt-networking", 0);
args_parser.add_option(use_gpu_painting, "Enable GPU painting", "enable-gpu-painting", 0);
args_parser.add_option(debug_web_content, "Wait for debugger to attach to WebContent", "debug-web-content", 0);
args_parser.parse(arguments);
RefPtr<WebView::Database> database;
@ -145,6 +147,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
.enable_callgrind_profiling = enable_callgrind_profiling ? Ladybird::EnableCallgrindProfiling::Yes : Ladybird::EnableCallgrindProfiling::No,
.enable_gpu_painting = use_gpu_painting ? Ladybird::EnableGPUPainting::Yes : Ladybird::EnableGPUPainting::No,
.use_lagom_networking = enable_qt_networking ? Ladybird::UseLagomNetworking::No : Ladybird::UseLagomNetworking::Yes,
.wait_for_debugger = debug_web_content ? Ladybird::WaitForDebugger::Yes : Ladybird::WaitForDebugger::No,
};
Ladybird::BrowserWindow window(initial_urls, cookie_jar, web_content_options, webdriver_content_ipc_path);

View file

@ -28,11 +28,17 @@ enum class UseLagomNetworking {
Yes
};
enum class WaitForDebugger {
No,
Yes
};
struct WebContentOptions {
EnableCallgrindProfiling enable_callgrind_profiling { EnableCallgrindProfiling::No };
EnableGPUPainting enable_gpu_painting { EnableGPUPainting::No };
IsLayoutTestMode is_layout_test_mode { IsLayoutTestMode::No };
UseLagomNetworking use_lagom_networking { UseLagomNetworking::No };
WaitForDebugger wait_for_debugger { WaitForDebugger::No };
};
}

View file

@ -13,6 +13,7 @@
#include <LibCore/ArgsParser.h>
#include <LibCore/EventLoop.h>
#include <LibCore/LocalServer.h>
#include <LibCore/Process.h>
#include <LibCore/System.h>
#include <LibCore/SystemServerTakeover.h>
#include <LibIPC/ConnectionFromClient.h>
@ -79,15 +80,21 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
bool is_layout_test_mode = false;
bool use_lagom_networking = false;
bool use_gpu_painting = false;
bool wait_for_debugger = false;
Core::ArgsParser args_parser;
args_parser.add_option(webcontent_fd_passing_socket, "File descriptor of the passing socket for the WebContent connection", "webcontent-fd-passing-socket", 'c', "webcontent_fd_passing_socket");
args_parser.add_option(is_layout_test_mode, "Is layout test mode", "layout-test-mode", 0);
args_parser.add_option(use_lagom_networking, "Enable Lagom servers for networking", "use-lagom-networking", 0);
args_parser.add_option(use_gpu_painting, "Enable GPU painting", "use-gpu-painting", 0);
args_parser.add_option(wait_for_debugger, "Wait for debugger", "wait-for-debugger", 0);
args_parser.parse(arguments);
if (wait_for_debugger) {
Core::Process::wait_for_debugger_and_break();
}
if (use_gpu_painting) {
WebContent::PageClient::set_use_gpu_painter();
}