From 5e0237b4fd20f768689c3dbaebf598f7da22f1e8 Mon Sep 17 00:00:00 2001 From: Roberto Rosmaninho Date: Tue, 3 Oct 2023 14:10:05 -0300 Subject: [PATCH 1/3] Introduces `--debugger-command` flag to krun --- k-distribution/src/main/scripts/bin/krun | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/k-distribution/src/main/scripts/bin/krun b/k-distribution/src/main/scripts/bin/krun index 7f684964a01..ecb1b1bbc9c 100755 --- a/k-distribution/src/main/scripts/bin/krun +++ b/k-distribution/src/main/scripts/bin/krun @@ -37,12 +37,14 @@ 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=" -- " else - DBG_CMD="gdb --args " + DBG_EXE="gdb" + DBG_CMD=" --args " fi @@ -112,6 +114,8 @@ $KRUN options: parser. This can be overridden with -p. --debugger Launch the backend in a debugging console. 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 @@ -392,7 +396,16 @@ do ;; --debugger) - cmdprefix="$DBG_CMD" + cmdprefix="$DBG_EXE $DBG_CMD" + ;; + + --debugger-command) + if [[ "$DBG_EXE" == "gdb" ]]; then + cmdprefix="$DBG_EXE -x $2 $DBG_CMD" + else + cmdprefix="$DBG_EXE -s $2 $DBG_CMD" + fi + shift ;; --statistics) From 1d9d6c625293e844a5ad8f95d4d240bafe694fe0 Mon Sep 17 00:00:00 2001 From: Roberto Rosmaninho Date: Tue, 3 Oct 2023 15:04:19 -0300 Subject: [PATCH 2/3] Introducing the `--debugger-batch` flag to `krun` --- k-distribution/src/main/scripts/bin/krun | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/k-distribution/src/main/scripts/bin/krun b/k-distribution/src/main/scripts/bin/krun index ecb1b1bbc9c..06493dcacbd 100755 --- a/k-distribution/src/main/scripts/bin/krun +++ b/k-distribution/src/main/scripts/bin/krun @@ -41,9 +41,11 @@ if [[ "$OSTYPE" == "darwin"* ]]; then else DBG_EXE="lldb" fi - DBG_CMD=" -- " + DBG_CMD=" --" + DBG_FLAG=" -s " else DBG_EXE="gdb" + DBG_FLAG=" -x " DBG_CMD=" --args " fi @@ -400,14 +402,20 @@ do ;; --debugger-command) - if [[ "$DBG_EXE" == "gdb" ]]; then - cmdprefix="$DBG_EXE -x $2 $DBG_CMD" + 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 - cmdprefix="$DBG_EXE -s $2 $DBG_CMD" + DBG_CMD=" --batch $DBG_CMD" fi - shift ;; + --statistics) statistics=true ;; From 079c231d2eab799235ca55ff870a0124064b0e69 Mon Sep 17 00:00:00 2001 From: Roberto Rosmaninho Date: Tue, 3 Oct 2023 15:05:57 -0300 Subject: [PATCH 3/3] Adding a description to `--debugger-batch` --- k-distribution/src/main/scripts/bin/krun | 2 ++ 1 file changed, 2 insertions(+) diff --git a/k-distribution/src/main/scripts/bin/krun b/k-distribution/src/main/scripts/bin/krun index 06493dcacbd..e5e88599fe4 100755 --- a/k-distribution/src/main/scripts/bin/krun +++ b/k-distribution/src/main/scripts/bin/krun @@ -116,6 +116,8 @@ $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"