debugging support
authorRalph Ronnquist <ralph.ronnquist@gmail.com>
Thu, 20 May 2021 10:49:29 +0000 (20:49 +1000)
committerRalph Ronnquist <ralph.ronnquist@gmail.com>
Thu, 20 May 2021 10:49:29 +0000 (20:49 +1000)
debug.sh [new file with mode: 0755]
grepline.sh [new file with mode: 0755]

diff --git a/debug.sh b/debug.sh
new file mode 100755 (executable)
index 0000000..6ecb8ce
--- /dev/null
+++ b/debug.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+PFX='0x[0-9a-f]* rrqforth.asm:[0-9]*[ ]*'
+
+grep "${PFX}do" rrqforth.map | sed 's/ .*//;s/^/break */' > gdbinit
+
+NBR=$(wc -l < gdbinit)
+
+DS="$(grep "${PFX}DS_TOP:" rrqforth.map | sed 's/ .*//')"
+
+cat <<EOF >> gdbinit
+display *(void**)\$rsp@(((void*)$DS-\$rsp)/8)+1
+display (char*)(*(void**)(\$rax-16)+32)
+display (void*)\$rax
+display (void*)\$rsi
+
+define si
+    stepi
+    x/3i \$pc
+    python gdb.execute("shell ./grepline.sh " + str(gdb.parse_and_eval("\$pc")))
+EOF
+
+exec gdb -x gdbinit rrqforth
diff --git a/grepline.sh b/grepline.sh
new file mode 100755 (executable)
index 0000000..677484a
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+#
+grep "^$1 " rrqforth.map