diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-02-09 18:29:37 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-02-09 18:29:37 -0800 |
commit | 2fc8f2a947e26d4d14cbbf1ff02dcdcb0825f951 (patch) | |
tree | b9eb59f7f6d9d788b7f9849ce3fcb37e48f6412e | |
parent | 207fc69d2e9a3dc43d75a3224d81b7291605d6f7 (diff) | |
download | mu-2fc8f2a947e26d4d14cbbf1ff02dcdcb0825f951.tar.gz |
727 - start of a trace browser
We can now collapse trace items, and we have a rudimentary event loop.
-rw-r--r-- | trace.mu | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/trace.mu b/trace.mu index f3971dd9..664f5354 100644 --- a/trace.mu +++ b/trace.mu @@ -138,7 +138,7 @@ ($print ((" : " literal))) (i:string-address <- get x:instruction-trace-address/deref instruction:offset) (print-string nil:literal/terminal i:string-address) - ($print (("\n" literal))) + ($print (("\r\n" literal))) ; print children (ch:trace-address-array-address <- get x:instruction-trace-address/deref children:offset) (i:integer <- copy 0:literal) @@ -154,12 +154,40 @@ (t:trace-address <- index ch:trace-address-array-address/deref i:integer) ($print ((" " literal))) (print-trace t:trace-address) - ($print (("\n" literal))) + ($print (("\r\n" literal))) (i:integer <- add i:integer 1:literal) (loop) } ]) +(function print-instruction-trace-collapsed [ + (default-space:space-address <- new space:literal 30:literal) + (x:instruction-trace-address <- next-input) + ($print (("+ " literal))) + ; print call stack + (c:string-address-array-address <- get x:instruction-trace-address/deref call-stack:offset) + (i:integer <- copy 0:literal) + (len:integer <- length c:string-address-array-address/deref) + { begin + (done?:boolean <- greater-or-equal i:integer len:integer) + (break-if done?:boolean) + (s:string-address <- index c:string-address-array-address/deref i:integer) + (print-string nil:literal/terminal s:string-address) + ($print (("/" literal))) + (i:integer <- add i:integer 1:literal) + (loop) + } + ; print pc + ($print ((" " literal))) + (p:string-address <- get x:instruction-trace-address/deref pc:offset) + (print-string nil:literal/terminal p:string-address) + ; print instruction + ($print ((" : " literal))) + (i:string-address <- get x:instruction-trace-address/deref instruction:offset) + (print-string nil:literal/terminal i:string-address) + ($print (("\r\n" literal))) +]) + (function main [ (default-space:space-address <- new space:literal 30:literal/capacity) (x:string-address <- new @@ -182,12 +210,25 @@ schedule: done with routine") ;? ($print (("#traces: " literal))) ;? 1 ;? ($print len:integer) ;? 1 ;? ($print (("\n" literal))) ;? 1 + (cursor-mode) + ; print trace collapsed (i:integer <- copy 0:literal) { begin (done?:boolean <- greater-or-equal i:integer len:integer) (break-if done?:boolean) (tr:instruction-trace-address <- index arr:instruction-trace-address-array-address/deref i:integer) - (print-instruction-trace tr:instruction-trace-address) + (print-instruction-trace-collapsed tr:instruction-trace-address) + (i:integer <- add i:integer 1:literal) + (loop) + } + ; handle key presses + (i:integer <- copy 0:literal) + { begin + (c:character <- read-key nil:literal/keyboard) + (loop-unless c:character) + (quit?:boolean <- equal c:character ((#\q literal))) + (break-if quit?:boolean) + ($print i:integer) (i:integer <- add i:integer 1:literal) (loop) } |