On 21-Jul-06, at 4:04 AM, Christian wrote:
I've now tried this:
(define (stepper-init) (set! ##main-stepper (vector (make-vector 7 (lambda args (##continuation-capture (lambda (cont) (set! conts (cons cont conts)))) (apply ##step-handler args))) #f #f #f #f #f #f #f)))
(define (stepper-off) ;; reset to the original handler. (set! ##main-stepper (vector (make-vector 7 ##step-handler) #f #f #f #f #f #f #f)))
(stepper-init)
If I call stepper-init immediately, before loading the code that I want to step into, the issue with stepping being "turned off after a few steps" has gone (I wonder why?).
It is because the value of ##main-stepper is attached to the code when the interpreter "compiles" it (i.e. when a file is loaded or an expression is evaluated at the REPL or by calling eval). So modifying the value of the variable ##main-stepper will only affect the code loaded after the variable is changed. In principle, this allows you to attach a different stepper to different modules, but Gambit does not take advantage of that.
You can get around this by modifying the main stepper vector itself, i.e.:
(define (stepper-init) (vector-set! ##main-stepper 0 (make-vector 7 (lambda args (##continuation-capture (lambda (cont) (set! conts (cons cont conts)))) (apply ##step-handler args)))))
The new handler catches continuations including the ##step-handler call, to make sure I will be able to continue the stepping process, as I hope.
Here's a sequence of commands I'm trying:
(bruse exp-stepper) (use cj-transactionlog) (step) (transactionlog:open '("tmp/bla"))
*** STOPPED IN (stdin)@4.2 1> #||#,s; | > transactionlog:open | #<procedure #2 transactionlog:open> *** STOPPED IN (stdin)@4.22 1> #||#,s; | > '("tmp/bla") | ("tmp/bla") *** STOPPED IN (stdin)@4.1 1> #||#,s; | > (transactionlog:open '("tmp/bla")) *** STOPPED IN transactionlog:open, "cj-transactionlog.scm"@19.4 1> #||#,s; | | > make-transactionlog | | #<procedure #3 make-transactionlog> *** STOPPED IN transactionlog:open, "cj-transactionlog.scm"@19.24 1> #||#,s; | | > list-of-filepaths | | ("tmp/bla") *** STOPPED IN transactionlog:open, "cj-transactionlog.scm"@21.10 1> #||#,s; | | > list-of-filepaths | | ("tmp/bla") *** STOPPED IN transactionlog:open, "cj-transactionlog.scm"@22.10 1> #||#,s; | | > #f | | #f *** STOPPED IN transactionlog:open, "cj-transactionlog.scm"@23.10 1> ,c | #<transactionlog #4 files: ("tmp/bla") curfile: ("tmp/bla") port: #f parser... #<transactionlog #4 files: ("tmp/bla") curfile: ("tmp/bla") port: #f parser: #f>
(stepper-off) conts
(#<continuation #5> #<continuation #6> #<continuation #7> #<continuation #8> #<continuation #9> #<continuation #10> #<continuation #11> #<continuation #12>)
Now:
(##repl-within #11 #f)
*** STOPPED IN (stdin)@36.2 ---> why is single-stepping now being switched on again?
I think this is because continuation #11 calls ##step-handler and the code you are single stepping is attached to the stepper that you created in stepper-init, not the one you created in stepper-off. I think this problem will go away if you mutate the ##main-stepper vector instead of set!-ing the ##main-stepper variable. (I'm sorry for the doubt but I'm not sure what you are trying to do).
Marc