improved debug support
[rrq/rrqforth.git] / debug.sh
1 #!/bin/bash
2
3 PFX='0x[0-9a-f]* rrqforth.asm:[0-9]*[ ]*'
4
5 grep "${PFX}do" rrqforth.map | sed 's/ .*//;s/^/break */' > gdbinit
6 NBR=( $(eval "echo {1..$(wc -l < gdbinit)}") )
7
8 for I in ${NBR[@]} ; do echo disable $I ; done >> gdbinit
9
10 DS="$(grep "${PFX}DS_TOP:" rrqforth.map | sed 's/ .*//')"
11 RS="$(grep "${PFX}RS_TOP:" rrqforth.map | sed 's/ .*//')"
12 cat <<EOF >> gdbinit
13 display *(void**)\$rsp@(((void*)$DS-\$rsp)/8)+1
14 display *(void**)\$rbp@(((void*)$RS-\$rbp)/8)+1
15 display (void*)\$rax
16 display (void*)\$rsi
17
18 define si
19     stepi
20     x/2i \$pc
21     python gdb.execute("shell ./grepline.sh rrqforth.map " + str(gdb.parse_and_eval("\$pc")))
22 end
23
24 define map
25     if \$argc == 1
26         python gdb.execute("shell ./grepline.sh rrqforth.map \$arg0" + " 1 " )
27     else
28         python gdb.execute("shell ./grepline.sh rrqforth.map \$arg0" + " 1 " + "\$arg1" )
29     end
30 end
31 EOF
32
33 exec gdb -x gdbinit rrqforth