improved debug support
authorRalph Ronnquist <ralph.ronnquist@gmail.com>
Sun, 23 May 2021 07:23:23 +0000 (17:23 +1000)
committerRalph Ronnquist <ralph.ronnquist@gmail.com>
Sun, 23 May 2021 07:23:23 +0000 (17:23 +1000)
debug.sh
grepline.sh

index 5963b303995439741dd0ee558861382388e1e5b4..12772c22e09d8cc8fd535b12d6da647478bfbc6a 100755 (executable)
--- a/debug.sh
+++ b/debug.sh
@@ -8,17 +8,26 @@ NBR=( $(eval "echo {1..$(wc -l < gdbinit)}") )
 for I in ${NBR[@]} ; do echo disable $I ; done >> gdbinit
 
 DS="$(grep "${PFX}DS_TOP:" rrqforth.map | sed 's/ .*//')"
-
+RS="$(grep "${PFX}RS_TOP:" rrqforth.map | sed 's/ .*//')"
 cat <<EOF >> gdbinit
 display *(void**)\$rsp@(((void*)$DS-\$rsp)/8)+1
-display (char*)(*(void**)(\$rax-16)+32)
+display *(void**)\$rbp@(((void*)$RS-\$rbp)/8)+1
 display (void*)\$rax
 display (void*)\$rsi
 
 define si
     stepi
-    x/3i \$pc
-    python gdb.execute("shell ./grepline.sh " + str(gdb.parse_and_eval("\$pc")))
+    x/2i \$pc
+    python gdb.execute("shell ./grepline.sh rrqforth.map " + str(gdb.parse_and_eval("\$pc")))
+end
+
+define map
+    if \$argc == 1
+        python gdb.execute("shell ./grepline.sh rrqforth.map \$arg0" + " 1 " )
+    else
+       python gdb.execute("shell ./grepline.sh rrqforth.map \$arg0" + " 1 " + "\$arg1" )
+    end
+end
 EOF
 
 exec gdb -x gdbinit rrqforth
index 677484a61f443ccda6a073867fa07ba73397c3aa..bb453da0ceeea9f0be80cb0237524581d22bf3e9 100755 (executable)
@@ -1,3 +1,24 @@
 #!/bin/bash
 #
-grep "^$1 " rrqforth.map
+# This script implements some special commands that are set up for gdb
+# in debug.sh
+
+F=${1-rrqforth.map}
+
+#echo "$*"
+
+case "$3" in
+    1)
+       if [ -n "$4" ] ;then
+           if [ -z "${4%%-*}" ] ; then
+               N=( -B "${4#-}" )
+           else
+               N=( -A ${4} )
+           fi
+       fi
+       grep "${N[@]}" -E "$2" $F
+       ;;
+    *)
+       grep -E "(\\bWORD\\b|^$2) " $F | \
+           awk '$3 == "WORD" {x=$0;next} x!="" {print x; x=""}{ print;}'
+esac