diff --git a/prospect/ground.rkt b/prospect/ground.rkt index 2a3b6c4..8e34f32 100644 --- a/prospect/ground.rkt +++ b/prospect/ground.rkt @@ -6,6 +6,7 @@ (require racket/match) (require racket/list) (require "core.rkt") +(require "trace.rkt") (require "trace/stderr.rkt") (provide (struct-out external-event) @@ -77,7 +78,10 @@ (current-ground-event-async-channel) (if inert? never-evt idle-handler) (extract-active-events interests)))) - (match (clean-transition (world-handle-event e w)) + (trace-process-step e #f world-handle-event w) + (define resulting-transition (clean-transition (world-handle-event e w))) + (trace-process-step-result e #f world-handle-event w #f resulting-transition) + (match resulting-transition [#f ;; inert (await-interrupt #t w interests)] [(transition w actions) diff --git a/prospect/trace.rkt b/prospect/trace.rkt index 08f2170..2ef29f2 100644 --- a/prospect/trace.rkt +++ b/prospect/trace.rkt @@ -34,25 +34,30 @@ (when (log-level? trace-logger 'info) (log-message trace-logger 'info name "" r #f))) -;; Event PID Process -> Void -(define (trace-process-step e pid beh st) - (record-trace-event 'process-step (list (cons pid (trace-pid-stack)) e beh st))) +(define (cons-pid pid) + (if pid + (cons pid (trace-pid-stack)) + (trace-pid-stack))) -;; Event PID Process (Option Exception) (Option Transition) -> Void +;; Event (Option PID) Process -> Void +(define (trace-process-step e pid beh st) + (record-trace-event 'process-step (list (cons-pid pid) e beh st))) + +;; Event (Option PID) Process (Option Exception) (Option Transition) -> Void (define (trace-process-step-result e pid beh st exn t) (when exn (log-error "Process ~a died with exception:\n~a" - (cons pid (trace-pid-stack)) + (cons-pid pid) (exn->string exn))) - (record-trace-event 'process-step-result (list (cons pid (trace-pid-stack)) e beh st exn t))) + (record-trace-event 'process-step-result (list (cons-pid pid) e beh st exn t))) -;; PID Action World -> Void +;; (Option PID) Action World -> Void (define (trace-internal-action pid a w) - (record-trace-event 'internal-action (list (cons pid (trace-pid-stack)) a w))) + (record-trace-event 'internal-action (list (cons-pid pid) a w))) -;; PID Action World Transition -> Void +;; (Option PID) Action World Transition -> Void (define (trace-internal-action-result pid a w t) - (record-trace-event 'internal-action-result (list (cons pid (trace-pid-stack)) a w t))) + (record-trace-event 'internal-action-result (list (cons-pid pid) a w t))) (define (string-indent amount s) (define pad (make-string amount #\space)) diff --git a/prospect/trace/stderr.rkt b/prospect/trace/stderr.rkt index e859d4b..e4eb6fc 100644 --- a/prospect/trace/stderr.rkt +++ b/prospect/trace/stderr.rkt @@ -33,6 +33,7 @@ (define show-message-actions? #f) (define show-actions? #f) (define show-routing-table? #f) +(define world-is-boring? #t) (define (set-stderr-trace-flags! flags-string) (set! flags (for/set [(c flags-string)] (string->symbol (string c)))) @@ -46,7 +47,8 @@ (set! show-patch-actions? (set-member? flags 'R)) (set! show-message-actions? (set-member? flags 'M)) (set! show-actions? (set-member? flags 'a)) - (set! show-routing-table? (set-member? flags 'g))) + (set! show-routing-table? (set-member? flags 'g)) + (set! world-is-boring? (not (set-member? flags 'W)))) (set-stderr-trace-flags! (or (getenv "MINIMART_TRACE") "")) @@ -75,11 +77,11 @@ (define (output-state state) (cond - [(world? state) (output "#\n")] + [(world? state) (pretty-print-world state)] [else (pretty-write state (current-error-port))])) (define (boring-state? state) - (or (world? state) + (or (and (world? state) world-is-boring?) (void? state))) (define (set-color! c) (when colored-output? (output "\e[0~am" c)))