add a debug call break point with print commands
authorRalph Ronnquist <ralph.ronnquist@gmail.com>
Mon, 24 May 2021 11:19:18 +0000 (21:19 +1000)
committerRalph Ronnquist <ralph.ronnquist@gmail.com>
Mon, 24 May 2021 11:19:18 +0000 (21:19 +1000)
debug.sh

index 12772c22e09d8cc8fd535b12d6da647478bfbc6a..a665e0249c6b5692df2eae70ded05b5d2dc1b243 100755 (executable)
--- a/debug.sh
+++ b/debug.sh
@@ -2,10 +2,27 @@
 
 PFX='0x[0-9a-f]* rrqforth.asm:[0-9]*[ ]*'
 
+
 grep "${PFX}do" rrqforth.map | sed 's/ .*//;s/^/break */' > gdbinit
-NBR=( $(eval "echo {1..$(wc -l < gdbinit)}") )
 
-for I in ${NBR[@]} ; do echo disable $I ; done >> gdbinit
+NBR=$(wc -l < gdbinit)
+
+I=1
+while [ $I -lt $NBR ] ; do echo disable $I ; I=$((I+1)) ; done >> gdbinit
+
+RET=$(grep -w ret rrqforth.map | sed 's/ .*//')
+echo "break *$RET" >> gdbinit
+#      ;; rax = cfa of called word
+#      ;; rsi = cell* of next forth word
+#      ;; [$rsp] = from where the call was
+
+cat <<EOF >> gdbinit
+commands $((NBR+1))
+print (void*) \$rsp
+print (((char*)(*(((void**)\$rax)-2)))+32)
+print (void*) \$rsi
+end
+EOF
 
 DS="$(grep "${PFX}DS_TOP:" rrqforth.map | sed 's/ .*//')"
 RS="$(grep "${PFX}RS_TOP:" rrqforth.map | sed 's/ .*//')"