Skip to content

Commit 2df2e7c

Browse files
committed
Feat: Support for both lldb and gdb
1 parent 0507d6f commit 2df2e7c

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

build.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ printHelp()
3434
echo "-d or --debug"
3535
echo " Build with debug information."
3636
echo
37-
echo "-g or --gdb"
38-
echo " Run with gdb."
37+
echo "-D or --debugger"
38+
echo " Run with a debugger (prefers LLDB, falls back to GDB)."
3939
echo
4040
echo "-c or --compiler <name>"
4141
echo " Select the compiler."
@@ -74,8 +74,18 @@ buildDefault()
7474
# Run
7575
if [[ "$RUN_AFTER" == "true" ]]; then
7676
echo "---------- Running ----------"
77-
if [[ "$USE_GDB" == "true" ]]; then
78-
gdb -ex r --args bin/atta $PROJECT_TO_RUN
77+
if [[ "$USE_DEBUGGER" == "true" ]]; then
78+
# Detect available debugger (prefer LLDB)
79+
if command -v lldb &> /dev/null; then
80+
echo "Using LLDB for debugging..."
81+
lldb --one-line "run" -- bin/atta -- $PROJECT_TO_RUN
82+
elif command -v gdb &> /dev/null; then
83+
echo "Using GDB for debugging..."
84+
gdb -ex r --args bin/atta $PROJECT_TO_RUN
85+
else
86+
echo "Error: No debugger found (LLDB or GDB). Install one to continue."
87+
exit 1
88+
fi
7989
else
8090
bin/atta $PROJECT_TO_RUN
8191
fi
@@ -131,8 +141,8 @@ while [[ $# -gt 0 ]]; do
131141
BUILD_NAME="debug"
132142
shift # past argument
133143
;;
134-
-g|--gdb)
135-
USE_GDB="true"
144+
-D|--debugger)
145+
USE_DEBUGGER="true"
136146
RUN_AFTER="true"
137147
shift # past argument
138148
;;

0 commit comments

Comments
 (0)