about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-06-11 22:50:40 -0700
committerKartik Agaram <vc@akkartik.com>2019-06-11 23:43:55 -0700
commit5ac0786623f5ebd0b3a4f23fb6c23b72e6e277cb (patch)
tree82009ccce35a7b7d73ed4316d94dc2e56ddbc881
parentf47066a7c2f53796fb252dc187cdcf77834a1157 (diff)
downloadmu-5ac0786623f5ebd0b3a4f23fb6c23b72e6e277cb.tar.gz
new Vim convenience macro
Runs test under cursor and opens its trace.
-rwxr-xr-xsubx/run_one_test.sh7
-rw-r--r--subx/run_one_test.subx30
-rw-r--r--vimrc.vim3
3 files changed, 40 insertions, 0 deletions
diff --git a/subx/run_one_test.sh b/subx/run_one_test.sh
new file mode 100755
index 00000000..4cb82425
--- /dev/null
+++ b/subx/run_one_test.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env zsh
+
+export TEST_NAME=$2
+envsubst '$TEST_NAME' < run_one_test.subx > /tmp/run_one_test.subx
+
+subx --debug translate [0-9]*.subx apps/subx-common.subx $1 /tmp/run_one_test.subx -o /tmp/a.elf
+subx --debug --trace run /tmp/a.elf
diff --git a/subx/run_one_test.subx b/subx/run_one_test.subx
new file mode 100644
index 00000000..43c98fca
--- /dev/null
+++ b/subx/run_one_test.subx
@@ -0,0 +1,30 @@
+# run a single test
+
+== code
+#   instruction                     effective address                                                   register    displacement    immediate
+# . op          subop               mod             rm32          base        index         scale       r32
+# . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
+
+Entry:
+    # Heap = new-segment(64KB)
+    # . . push args
+    68/push  Heap/imm32
+    68/push  0x10000/imm32/64KB
+    # . . call
+    e8/call  new-segment/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    # initialize-trace-stream(256KB)
+    # . . push args
+    68/push  0x40000/imm32/256KB
+    # . . call
+    e8/call  initialize-trace-stream/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+    # for debugging: run a single test
+    e8/call $TEST_NAME/disp32
+    8b/copy                         0/mod/indirect  5/rm32/.disp32            .             .           3/r32/EBX   Num-test-failures/disp32          # copy *Num-test-failures to EBX
+    b8/copy-to-EAX  1/imm32/exit
+    cd/syscall  0x80/imm8
+
+# . . vim:nowrap:textwidth=0
diff --git a/vimrc.vim b/vimrc.vim
index 0c297fef..66defa34 100644
--- a/vimrc.vim
+++ b/vimrc.vim
@@ -76,3 +76,6 @@ endif
 " see https://github.com/akkartik/mu/blob/master/subx/Readme.md#a-few-hints-for-debugging
 " the '-a' is because traces can sometimes contain unprintable characters that bother grep
 command! -nargs=0 L exec "%!grep -a label |grep -v clear-stream:loop"
+
+" run test cursor around cursor, then bring up its trace in a split window
+noremap <Leader>t {j0:exec "!run_one_test.sh ".expand("%")." <C-R><C-W>"<CR>:vert split last_run<CR><C-w>p<C-o>