diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-01-01 11:11:02 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-01-01 11:20:54 -0800 |
commit | ce3518f362743d7a004f952358864748eecf8c0d (patch) | |
tree | cd9677d5d2653d34eeb3094796a50523bf94b66d /mu.arc | |
parent | a03b8aea543689d1fdb8c7b70ffdec9678833db6 (diff) | |
download | mu-ce3518f362743d7a004f952358864748eecf8c0d.tar.gz |
478 - snapshot while debugging chessboard
This took a couple of hours to track down. I had to shrink down to a 2x2 chessboard, isolate a half-move (just a square to clear) that triggered an error, then hard-code the half-move to make it non-interactive, then copy my changes over to the non-cursor version in chessboard.mu, then start debugging trace. And then I found I was using an 'index-address' rather than 'index' to go from a board to a file-address inside 'make-move'. And that was corrupting the array of file pointers. Things I wish I had to help me here: a) a type checker. b) more speed. Are lists slowing down super-linearly? need an arc profiler. c) a side channel for traces even when the program is in cursor mode. I do have that (hence the 'new-trace' before calling main), but for some reason it wasn't convenient. Just had to buckle down, I think. d) the right '#ifdef's to switch between hard-coded move and interactive move, text vs cursor mode, etc. e) just in general better curation of traces to easily see what's going on. But that's just a pipe dream.
Diffstat (limited to 'mu.arc')
-rw-r--r-- | mu.arc | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/mu.arc b/mu.arc index 1993f81e..52697ab9 100644 --- a/mu.arc +++ b/mu.arc @@ -236,6 +236,8 @@ (def run fn-names (freeze function*) (load-system-functions) +;? (write function*) +;? (quit) (= traces* (queue)) (each it fn-names (enq make-routine.it running-routines*)) @@ -368,7 +370,7 @@ (pop-stack routine*) (if empty.routine* (return ninstrs)) (when (pos '<- (body.routine* pc.routine*)) - (die "No results returned: @(body.routine* pc.routine*)")) + (die "No results returned: @(tostring:prn (body.routine* pc.routine*))")) (++ pc.routine*)) (++ curr-cycle*) (trace "run" "-- " int-canon.memory*) @@ -469,6 +471,10 @@ (withs (operand (canonize arg.0) elemtype typeinfo.operand!elem idx (m arg.1)) +;? (write arg.0) +;? (pr " => ") +;? (write operand) +;? (prn) (unless (< -1 idx array-len.operand) (die "@idx is out of bounds of array @operand")) (m `((,(+ v.operand @@ -724,10 +730,16 @@ (++ n)))) (def canonize (operand) +;? (tr "0: @operand") (ret operand +;? (prn "1: " operand) +;? (tr "1: " operand) ; todo: why does this die? (zap absolutize operand) +;? (tr "2: @(tostring write.operand)") (while (pos '(deref) metadata.operand) - (zap deref operand)))) + (zap deref operand) +;? (tr "3: @(tostring write.operand)") + ))) (def array-len (operand) (trace "array-len" operand) @@ -1545,7 +1557,7 @@ ;? (print-primitive ("arg now: " literal)) ;? (print-primitive a:string-address) ;? (print-primitive "@":literal) -;? print-primitive:a:string-address/deref ; todo: test (m on scoped array) +;? (print-primitive a:string-address/deref) ; todo: test (m on scoped array) ;? (print-primitive "\n":literal) ;? ;? (assert nil:literal) ; result-len = result-len + arg.length - 1 (for the 'underscore' being replaced) @@ -1730,6 +1742,7 @@ ;; load all provided files and start at 'main' (reset) +(new-trace "chessboard") ;? (set dump-trace*) (awhen (pos "--" argv) (map add-code:readfile (cut argv (+ it 1))) @@ -1741,6 +1754,7 @@ (run 'main) (if ($.current-charterm) ($.close-charterm)) (prn "\nmemory: " int-canon.memory*) -;? (prn completed-routines*) + (each routine completed-routines* + (aif rep.routine!error (prn "error - " it))) ) (reset) |