Skip to content

Commit

Permalink
[Debugger] Introducing lldb on for llvm-krun script (#857)
Browse files Browse the repository at this point in the history
Fixes #852 

This simple PR checks if the user is on a `macOS` system before
executing the interpreter in debug mode, and if that's the case, the
debug command is now modified to call `lldb` with the corrected
supported flags instead of calling `gdb`.

It also fixes a bug on `--debug-batch`.

---------

Co-authored-by: rv-jenkins <[email protected]>
  • Loading branch information
Robertorosmaninho and rv-jenkins authored May 15, 2024
1 parent 78cf581 commit 5b5affe
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions bin/llvm-krun
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
set -e
set -x

params=()
pretty=()
Expand All @@ -17,8 +18,8 @@ trap 'cleanup' INT TERM EXIT

initializer="LblinitGeneratedTopCell{}"
dir=.
debug=
debug_command=
debug=()
debug_command=()
depth=-1
verbose=0
binary_input=false
Expand Down Expand Up @@ -164,22 +165,34 @@ do
;;

--debug)
debug="gdb --args "
if [[ "$OSTYPE" == "darwin"* ]]; then
debug=("lldb" "--")
else
debug=("gdb" "--args")
fi
shift;
;;

--debug-command)
debug_command="$2"
if [[ -z $debug ]]; then
debug="gdb -x ${debug_command} --args "
debug_command+=("$2")
if [[ "$OSTYPE" == "darwin"* ]]; then
debug=("lldb" "-s")
else
debug="${debug/--args /} -x ${debug_command} --args "
debug=("gdb" "-x")
fi
debug+=("${debug_command[@]}")
debug+=("--args")
shift;
shift
;;

--debug-batch)
debug="gdb --batch --args "
if [[ "$OSTYPE" == "darwin"* ]]; then
debug=("lldb" "--batch" "--")
else
debug=("gdb" "batch" "--args")
fi
shift
;;

--depth)
Expand Down Expand Up @@ -472,7 +485,7 @@ set +e
if [ "$verbose" -ge 1 ]; then
set -x
fi
$debug "$dir"/interpreter "$expanded_input_file" "$depth" "$output_file" "${interpreter_flags[@]}"
"${debug[@]}" "${dir}/interpreter" "$expanded_input_file" "$depth" "$output_file" "${interpreter_flags[@]}"
)
EXIT=$?
set -e
Expand Down

0 comments on commit 5b5affe

Please sign in to comment.