Skip to content

Commit

Permalink
Introduces --debugger-command flag to krun (#3687)
Browse files Browse the repository at this point in the history
This PR reflects a new modification on the `llvm-krun` from the
llvm-backend.

This new flag enables the user to pass a file with debug commands to its
debugger and run them in a non-interactive mode!

This new flag also allows testing the debugger on our current CI.
  • Loading branch information
Robertorosmaninho authored Oct 4, 2023
1 parent 71a0669 commit 3e7fdeb
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions k-distribution/src/main/scripts/bin/krun
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ filterSubst=
if [[ "$OSTYPE" == "darwin"* ]]; then
LLDB_FILE="$(dirname "$0")/../lib/kllvm/lldb/k_lldb_path"
if [ -f "$LLDB_FILE" ]; then
DBG_CMD="$(cat "$LLDB_FILE") -- "
DBG_EXE="$(cat "$LLDB_FILE")"
else
DBG_CMD="lldb --"
DBG_EXE="lldb"
fi
DBG_CMD=" --"
DBG_FLAG=" -s "
else
DBG_CMD="gdb --args "
DBG_EXE="gdb"
DBG_FLAG=" -x "
DBG_CMD=" --args "
fi


Expand Down Expand Up @@ -112,6 +116,10 @@ $KRUN options:
parser. This can be overridden with -p.
--debugger Launch the backend in a debugging console.
Currently only supported on LLVM backend.
--debugger-batch Launch the backend in a debugging console in batch
mode. Currently only supported on LLVM backend.
--debugger-command FILE Execute GDB commands from FILE to debug program.
Currently only supported on LLVM backend.
-d, --directory DIR [DEPRECATED] Look for a kompiled directory ending in "-kompiled"
under the directory DIR.
--dry-run Do not execute backend, but instead print the
Expand Down Expand Up @@ -392,9 +400,24 @@ do
;;

--debugger)
cmdprefix="$DBG_CMD"
cmdprefix="$DBG_EXE $DBG_CMD"
;;

--debugger-command)
debugCommandFile="$2"
cmdprefix="$DBG_EXE $DBG_FLAG $debugCommandFile $DBG_CMD"
shift
;;

--debugger-batch)
if [[ $cmdprefix == *gdb* || $cmdprefix == *lldb* ]]; then
cmdprefix="$DBG_EXE --batch $DBG_FLAG $debugCommandFile $DBG_CMD"
else
DBG_CMD=" --batch $DBG_CMD"
fi
;;


--statistics)
statistics=true
;;
Expand Down

0 comments on commit 3e7fdeb

Please sign in to comment.