Meta+CMake: Use lldb on macOS for debugging

This commit is contained in:
Andrew Kaster 2024-06-29 20:05:33 -06:00 committed by Andrew Kaster
parent 72b4d44d07
commit 3cdd4fb769
Notes: sideshowbarker 2024-07-16 17:12:03 +09:00
2 changed files with 20 additions and 5 deletions

View file

@ -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" "$<TARGET_FILE:ladybird>"
USES_TERMINAL
)
if (APPLE)
add_custom_target(debug-ladybird
COMMAND "${CMAKE_COMMAND}" -E env "LADYBIRD_SOURCE_DIR=${LADYBIRD_SOURCE_DIR}" lldb "$<TARGET_BUNDLE_DIR:ladybird>"
USES_TERMINAL
)
else()
add_custom_target(debug-ladybird
COMMAND "${CMAKE_COMMAND}" -E env "LADYBIRD_SOURCE_DIR=${LADYBIRD_SOURCE_DIR}" gdb "$<TARGET_FILE:ladybird>"
USES_TERMINAL
)
endif()
add_subdirectory(ImageDecoder)
add_subdirectory(RequestServer)

View file

@ -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() {