X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=debug.sh;h=9b64b4970021df19eeedde13b0ca9530669bb21b;hb=af617c57b198d0b1e55e77ed2e67c57365007f29;hp=6ecb8ced20b2e1285003d35a38bf16a534db6800;hpb=3f5ae14cc91f1a3fe6a4c39bd4efc6f5f93220c5;p=rrq%2Frrqforth.git diff --git a/debug.sh b/debug.sh index 6ecb8ce..9b64b49 100755 --- a/debug.sh +++ b/debug.sh @@ -2,22 +2,49 @@ 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/ .*//')" +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[0]}" >> gdbinit +# ;; rax = cfa of called word +# ;; rsi = cell* of next forth word +# ;; [$rsp] = from where the call was + +cat <> 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/ .*//')" cat <> 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