From 3cdd4fb7698c52e5432f298dcf66ab1cb15ab91f Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sat, 29 Jun 2024 20:05:33 -0600 Subject: [PATCH] Meta+CMake: Use lldb on macOS for debugging --- Ladybird/CMakeLists.txt | 15 +++++++++++---- Meta/ladybird.sh | 10 +++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Ladybird/CMakeLists.txt b/Ladybird/CMakeLists.txt index 1ebd1040a97..c4a6790359d 100644 --- a/Ladybird/CMakeLists.txt +++ b/Ladybird/CMakeLists.txt @@ -107,10 +107,17 @@ add_custom_target(run VERBATIM ) -add_custom_target(debug-ladybird - COMMAND "${CMAKE_COMMAND}" -E env "LADYBIRD_SOURCE_DIR=${LADYBIRD_SOURCE_DIR}" gdb -ex "set follow-fork-mode child" "$" - USES_TERMINAL -) +if (APPLE) + add_custom_target(debug-ladybird + COMMAND "${CMAKE_COMMAND}" -E env "LADYBIRD_SOURCE_DIR=${LADYBIRD_SOURCE_DIR}" lldb "$" + USES_TERMINAL + ) +else() + add_custom_target(debug-ladybird + COMMAND "${CMAKE_COMMAND}" -E env "LADYBIRD_SOURCE_DIR=${LADYBIRD_SOURCE_DIR}" gdb "$" + USES_TERMINAL + ) +endif() add_subdirectory(ImageDecoder) add_subdirectory(RequestServer) diff --git a/Meta/ladybird.sh b/Meta/ladybird.sh index c0207912e3a..96872aad2ed 100755 --- a/Meta/ladybird.sh +++ b/Meta/ladybird.sh @@ -142,6 +142,14 @@ run_gdb() { local GDB_ARGS=() local PASS_ARG_TO_GDB="" local LAGOM_EXECUTABLE="" + local GDB=gdb + if ! command -v "$GDB" > /dev/null 2>&1; then + GDB=lldb + if ! command -v "$GDB" > /dev/null 2>&1; then + die "Please install gdb or lldb!" + fi + fi + for arg in "${CMD_ARGS[@]}"; do if [ "$PASS_ARG_TO_GDB" != "" ]; then GDB_ARGS+=( "$PASS_ARG_TO_GDB" "$arg" ) @@ -168,7 +176,7 @@ run_gdb() { LAGOM_EXECUTABLE="Ladybird" fi fi - gdb "$BUILD_DIR/bin/$LAGOM_EXECUTABLE" "${GDB_ARGS[@]}" + "$GDB" "$BUILD_DIR/bin/$LAGOM_EXECUTABLE" "${GDB_ARGS[@]}" } build_and_run_lagom_target() {