diff --git a/Ladybird/AppKit/main.mm b/Ladybird/AppKit/main.mm index 193b354c9c..526aaa98a8 100644 --- a/Ladybird/AppKit/main.mm +++ b/Ladybird/AppKit/main.mm @@ -43,12 +43,14 @@ ErrorOr serenity_main(Main::Arguments arguments) Vector 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 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) diff --git a/Ladybird/HelperProcess.cpp b/Ladybird/HelperProcess.cpp index 21b51936fb..c9f8ad67a4 100644 --- a/Ladybird/HelperProcess.cpp +++ b/Ladybird/HelperProcess.cpp @@ -55,6 +55,8 @@ ErrorOr> 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()) diff --git a/Ladybird/Qt/main.cpp b/Ladybird/Qt/main.cpp index 0e93ebcbac..80b5654be4 100644 --- a/Ladybird/Qt/main.cpp +++ b/Ladybird/Qt/main.cpp @@ -109,6 +109,7 @@ ErrorOr 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 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 database; @@ -145,6 +147,7 @@ ErrorOr 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); diff --git a/Ladybird/Types.h b/Ladybird/Types.h index 13e82dee09..530b3a69fa 100644 --- a/Ladybird/Types.h +++ b/Ladybird/Types.h @@ -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 }; }; } diff --git a/Ladybird/WebContent/main.cpp b/Ladybird/WebContent/main.cpp index c10e12baf4..093bb2118d 100644 --- a/Ladybird/WebContent/main.cpp +++ b/Ladybird/WebContent/main.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -79,15 +80,21 @@ ErrorOr 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(); }