added trace/break

moved demos around

svn: r106
This commit is contained in:
Jono Spiro 2004-07-19 20:39:35 +00:00
parent 847aa49832
commit 691ab84633

View File

@ -2,7 +2,7 @@
CAN I CATCH FRTIME EXCEPTIONS AND RETHROW THOSE TOO? CAN I CATCH FRTIME EXCEPTIONS AND RETHROW THOSE TOO?
LOOK AT (require (lifted mzscheme random)) in demos/random-xs-test.ss -- there seems to be a problem with requires that do lifting for FrTime in the target program, we need to do requires in the script for some reason. random becomes random3 and throws an exception. When lifting for debugging a frtime program, you cannot lift in the target program, you have to lift in the script itself. Everything else should be as-is/unchecked.
code like code like
(set-running! client (or (elapsed . < . 5) (elapsed . >= . 10))) (set-running! client (or (elapsed . < . 5) (elapsed . >= . 10)))
@ -62,20 +62,14 @@ The script does not tell you something went wrong though, and the solution (as-i
TESTING/CAPABILITIES------------------------------------------------------------------------ TESTING/CAPABILITIES------------------------------------------------------------------------
If you pause after a value = 14000, it doesn't pause until the 14001th iteration. Keep this in mind.
Does user interaction work? Can we step through loops one line at a time waiting for input? GUIs? Does user interaction work? Can we step through loops one line at a time waiting for input? GUIs?
Verify that when killing the debugger, all the memory and bindings that need to be released are released. Verify that when killing the debugger, all the memory and bindings that need to be released are released.
code the heap example and copy the set-running! coolness to it from sine-test.ss code the heap example and copy the set-running! coolness to it from sine-test.ss
Can you duplicate the problem when the program seems to keep running event after killing it?
We want a way to interactively step through code one line at a time when we hit a breakpoint. Provide way to check bindings at the same time -- EVEN IF NOT BOUND USING TRACE/BIND We want a way to interactively step through code one line at a time when we hit a breakpoint. Provide way to check bindings at the same time -- EVEN IF NOT BOUND USING TRACE/BIND
Map kill or pause to the Break button?
trace/bind what kind of interface do we want to dig into frames trace/bind what kind of interface do we want to dig into frames
write a nested syntax for bind so that you can take a first-class function that defines a way to return variables, not just as a list write a nested syntax for bind so that you can take a first-class function that defines a way to return variables, not just as a list
@ -84,38 +78,40 @@ What do we do about binding to a variable and following it EVERYWHERE it goes.
Find a way to bind to the result of ananonymous expression: here->(add1 2) Find a way to bind to the result of ananonymous expression: here->(add1 2)
|# |#
(module mztake mzscheme (module mztake mzscheme
(require (require (lib "match.ss")
(lib "match.ss") (lib "contract.ss")
(lib "contract.ss") (lib "unitsig.ss")
(lib "unitsig.ss") (rename (lib "mred.ss" "mred") make-eventspace make-eventspace)
(rename (lib "mred.ss" "mred") make-eventspace make-eventspace) (rename (lib "mred.ss" "mred") current-eventspace current-eventspace)
(rename (lib "mred.ss" "mred") current-eventspace current-eventspace) (rename (lib "mred.ss" "mred") eventspace-shutdown? eventspace-shutdown?)
(rename (lib "mred.ss" "mred") eventspace-shutdown? eventspace-shutdown?) (rename (lib "mred.ss" "mred") queue-callback queue-callback)
(rename (lib "mred.ss" "mred") queue-callback queue-callback) (lib "debugger-model.ss" "stepper" "private")
(lib "debugger-model.ss" "stepper" "private") (lib "marks.ss" "stepper" "private")
(lib "marks.ss" "stepper" "private") "private/useful-code.ss" ; provides stuff for scripts -- history-b etc...
"private/useful-code.ss" ; provides stuff for scripts -- history-b etc... "private/more-useful-code.ss" ; mostly for hash- bindings
"private/more-useful-code.ss" ; mostly for hash- bindings (prefix frp: (lib "frp.ss" "frtime")))
(prefix frp: (lib "frp.ss" "frtime")))
; Provides come from the script section at the bottom of the code ; Provides come from the script section at the bottom of the code
(provide kill (provide kill
pause pause
trace/bind trace/bind
trace/break
set-running! set-running!
client-exit? client-exit?
start/resume start/resume
create-client create-client
client-exceptions client-exceptions
client-runtime-seconds client-runtime-seconds
client-runtime-milliseconds client-runtime-milliseconds)
(rename script-running? client-running?)) ;(rename script-running? client-running?)) ; disabled until it works
;######################## STRUCTS ######################## ;######################## STRUCTS ########################
(define-struct trace (evnt-rcvr)) ; frp:event-receiver (define-struct trace (evnt-rcvr)) ; frp:event-receiver
(define-struct (break-trace trace) ())
(define-struct (bind-trace trace) (define-struct (bind-trace trace)
(variable-to-bind)) ; symbol (variable-to-bind)) ; symbol
@ -132,11 +128,12 @@ Find a way to bind to the result of ananonymous expression: here->(add1 2)
;#################### STRUCT-BUILDERS ##################### ;#################### STRUCT-BUILDERS #####################
; Creates a trace that binds to the value of a variable in scope ; Creates a trace that binds to the value of a variable in scope
(define/contract create-bind-trace (define (create-bind-trace sym-to-bind) ; ((union (listof symbol?) symbol?) . -> . trace?)
((union (listof symbol?) symbol?) . -> . trace?) (make-bind-trace (frp:event-receiver) sym-to-bind))
(lambda (sym-to-bind)
(make-bind-trace (frp:event-receiver) sym-to-bind)))
; Creates a trace that simply pauses the program
(define (create-break-trace) ; (void? . -> . trace?)
(make-break-trace (frp:event-receiver)))
;####################### CALLBACKS ####################### ;####################### CALLBACKS #######################
@ -210,6 +207,10 @@ Find a way to bind to the result of ananonymous expression: here->(add1 2)
; takes a single trace, looks up what it needs to do, and returns an frp-event to publish ; takes a single trace, looks up what it needs to do, and returns an frp-event to publish
(define (trace->frp-event client event trace) (define (trace->frp-event client event trace)
(match trace (match trace
[($ break-trace evnt-rcvr)
(pause client)
(list evnt-rcvr #t)]
[($ bind-trace evnt-rcvr variable-to-bind) [($ bind-trace evnt-rcvr variable-to-bind)
(let* ([vars (if (list? variable-to-bind) variable-to-bind (let* ([vars (if (list? variable-to-bind) variable-to-bind
(list variable-to-bind))] (list variable-to-bind))]
@ -273,8 +274,8 @@ Find a way to bind to the result of ananonymous expression: here->(add1 2)
(lambda (exn) (lambda (exn)
(frp:send-event (client-exceptions client) exn) (frp:send-event (client-exceptions client) exn)
(client-error (if (exn? exn) (client-error (if (exn? exn)
(format "exception: ~a" (exn-message exn)) (format "exception: ~a" (exn-message exn))
exn)))]) exn)))])
(go)))))]) (go)))))])
(thread (lambda () (thread (lambda ()
(thread-wait evaluation-thread) (thread-wait evaluation-thread)
@ -408,20 +409,24 @@ Find a way to bind to the result of ananonymous expression: here->(add1 2)
(frp:set-cell! (client-exit? client) #t))) (frp:set-cell! (client-exit? client) #t)))
; (client (offset | line column) (symbol | listof symbols) -> (frp:event-receiver) ; (client (offset | line column) (symbol | listof symbols) -> (frp:event-receiver)
(define/contract trace/bind (case-> (define/contract trace/bind (client? number? number? (union symbol? (listof symbol?)) . -> . frp:event?)
(client? number? (union symbol? (listof symbol?)) . -> . frp:event?) (lambda (client line col binding-symbol)
(client? number? number? (union symbol? (listof symbol?)) . -> . frp:event?)) (let ([trace-hash (client-tracepoints client)]
[trace (create-bind-trace binding-symbol)]
(case-lambda [pos ((client-line-col->pos client) line col)])
[(client line col binding-symbol) ; add the trace to the list of traces for that byte-offset
(trace/bind client ((client-line-col->pos client) line col) binding-symbol)] (hash-put! trace-hash pos
(cons trace
[(client pos binding-symbol) (hash-get trace-hash pos (lambda () '()))))
(let ([trace-hash (client-tracepoints client)] (trace-evnt-rcvr trace))))
[trace (create-bind-trace binding-symbol)])
; add the trace to the list of traces for that byte-offset (define/contract trace/break (client? number? number? . -> . frp:event?)
(hash-put! trace-hash pos (lambda (client line col)
(cons trace (let ([trace-hash (client-tracepoints client)]
(hash-get trace-hash pos (lambda () '())))) [trace (create-break-trace)]
(trace-evnt-rcvr trace))])) [pos ((client-line-col->pos client) line col)])
(hash-put! trace-hash pos
(cons trace
(hash-get trace-hash pos (lambda () '()))))
(trace-evnt-rcvr trace))))
) )