Skip to content

Commit

Permalink
Meta+CMake: Use lldb on macOS for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ADKaster committed Jun 30, 2024
1 parent 8c09b9a commit b4fa11f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
15 changes: 11 additions & 4 deletions Ladybird/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion Meta/ladybird.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
Expand All @@ -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() {
Expand Down

0 comments on commit b4fa11f

Please sign in to comment.