From 5b5affeeab521925142864c0ec126a3e9edf6caa Mon Sep 17 00:00:00 2001 From: Roberto Rosmaninho Date: Wed, 15 May 2024 07:02:30 -0300 Subject: [PATCH] [Debugger] Introducing lldb on for `llvm-krun` script (#857) 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 --- bin/llvm-krun | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/bin/llvm-krun b/bin/llvm-krun index 2bb9e846a..ee83a6d62 100755 --- a/bin/llvm-krun +++ b/bin/llvm-krun @@ -1,5 +1,6 @@ #!/bin/bash set -e +set -x params=() pretty=() @@ -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 @@ -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) @@ -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