From b4fa11fab8a957f7ce6564d4d72bc47097895ee5 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 | 11 ++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Ladybird/CMakeLists.txt b/Ladybird/CMakeLists.txt index 1ebd1040a97ca..c4a6790359d11 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 c0207912e3a7d..eb086237b5407 100755 --- a/Meta/ladybird.sh +++ b/Meta/ladybird.sh @@ -142,6 +142,15 @@ 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 + echo "gdb not found, trying lldb" + 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 +177,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() {