Code:
~/code/irc$ cat trace.scm (define (foo x) x)
(define (bar) (foo 0))
(define (test) (foo 1) (bar))
(trace foo)
(test) ~/code/irc$ gsi trace.scm | > (foo 1) | 1 | > (foo 0) | 0
Problem:
Can I control trace where I can say "trace foo, but not when it's called by bar".
I.e. rather than just saying "trace this function", I would like to be able to say:
(trace foo predicate)
where predicate is a function that takes as input the "stack" frame, and as output creates a #t / #f, which decides whether this particular trace should be printed
On a side note -- all the cool debugging functions in Gambit -- is this part of the 100K LOC scheme or 50K LOC hand written C? (hoping it's the former)
Afficher les réponses par date
Okay, so I almost think I have a solution to this.
Can I have something like "trace", where instead of printing the argument line, it passes it to a function?
Like a function uber-trace
where:
(trace foo) = (uber-trace foo (lambda (args) (pp args)))
On Fri, Feb 20, 2009 at 8:04 PM, lowly coder lowlycoder@huoyanjinjing.comwrote:
Code:
~/code/irc$ cat trace.scm (define (foo x) x)
(define (bar) (foo 0))
(define (test) (foo 1) (bar))
(trace foo)
(test) ~/code/irc$ gsi trace.scm | > (foo 1) | 1 | > (foo 0) | 0
Problem:
Can I control trace where I can say "trace foo, but not when it's called by bar".
I.e. rather than just saying "trace this function", I would like to be able to say:
(trace foo predicate)
where predicate is a function that takes as input the "stack" frame, and as output creates a #t / #f, which decides whether this particular trace should be printed
On a side note -- all the cool debugging functions in Gambit -- is this part of the 100K LOC scheme or 50K LOC hand written C? (hoping it's the former)
hmm, this is in lib/_repl.scm
and I see:
(define-prim (##trace proc)
(define (setup hook) (let ((settings (##closure-ref hook 1))) (##vector-set! settings 1 #t) (if (##not (##memq proc ##trace-list)) (set! ##trace-list (##cons proc ##trace-list)))))
(let ((hook (##interp-procedure-default-entry-hook proc))) (if hook
(setup hook) (let ((new-hook (##make-default-entry-hook))) (##interp-procedure-entry-hook-set! proc new-hook) (setup new-hook)))))
is "##interp-procedure-entry-hook-set!" a function that gets called whenever a function gets hit with 'eval' ?
On Fri, Feb 20, 2009 at 8:21 PM, lowly coder lowlycoder@huoyanjinjing.comwrote:
Okay, so I almost think I have a solution to this.
Can I have something like "trace", where instead of printing the argument line, it passes it to a function?
Like a function uber-trace
where:
(trace foo) = (uber-trace foo (lambda (args) (pp args)))
On Fri, Feb 20, 2009 at 8:04 PM, lowly coder <lowlycoder@huoyanjinjing.com
wrote:
Code:
~/code/irc$ cat trace.scm (define (foo x) x)
(define (bar) (foo 0))
(define (test) (foo 1) (bar))
(trace foo)
(test) ~/code/irc$ gsi trace.scm | > (foo 1) | 1 | > (foo 0) | 0
Problem:
Can I control trace where I can say "trace foo, but not when it's called by bar".
I.e. rather than just saying "trace this function", I would like to be able to say:
(trace foo predicate)
where predicate is a function that takes as input the "stack" frame, and as output creates a #t / #f, which decides whether this particular trace should be printed
On a side note -- all the cool debugging functions in Gambit -- is this part of the 100K LOC scheme or 50K LOC hand written C? (hoping it's the former)
So I'm looking more in lib/_repl.scm, in particular at:
(define-prim (##interp-procedure-default-entry-hook proc) (let ((hook (##interp-procedure-entry-hook proc))) (if (and hook (##closure? hook) (##eq? (##subprocedure-parent (##closure-code hook))
##make-default-entry-hook))
hook
#f)))
and I'm wondering two things:
1) in trace, where is the pp / display / write
2) after the proc is setup by ##interp-procedure-default-entry-hook, where in the interpreter is proc called?
On Fri, Feb 20, 2009 at 8:31 PM, lowly coder lowlycoder@huoyanjinjing.comwrote:
hmm, this is in lib/_repl.scm
and I see:
(define-prim (##trace proc)
(define (setup hook) (let ((settings (##closure-ref hook 1))) (##vector-set! settings 1 #t) (if (##not (##memq proc ##trace-list)) (set! ##trace-list (##cons proc ##trace-list)))))
(let ((hook (##interp-procedure-default-entry-hook proc))) (if hook
(setup
hook) (let ((new-hook (##make-default-entry-hook))) (##interp-procedure-entry-hook-set! proc new-hook) (setup new-hook)))))
is "##interp-procedure-entry-hook-set!" a function that gets called whenever a function gets hit with 'eval' ?
On Fri, Feb 20, 2009 at 8:21 PM, lowly coder <lowlycoder@huoyanjinjing.com
wrote:
Okay, so I almost think I have a solution to this.
Can I have something like "trace", where instead of printing the argument line, it passes it to a function?
Like a function uber-trace
where:
(trace foo) = (uber-trace foo (lambda (args) (pp args)))
On Fri, Feb 20, 2009 at 8:04 PM, lowly coder < lowlycoder@huoyanjinjing.com> wrote:
Code:
~/code/irc$ cat trace.scm (define (foo x) x)
(define (bar) (foo 0))
(define (test) (foo 1) (bar))
(trace foo)
(test) ~/code/irc$ gsi trace.scm | > (foo 1) | 1 | > (foo 0) | 0
Problem:
Can I control trace where I can say "trace foo, but not when it's called by bar".
I.e. rather than just saying "trace this function", I would like to be able to say:
(trace foo predicate)
where predicate is a function that takes as input the "stack" frame, and as output creates a #t / #f, which decides whether this particular trace should be printed
On a side note -- all the cool debugging functions in Gambit -- is this part of the 100K LOC scheme or 50K LOC hand written C? (hoping it's the former)
On 20-Feb-09, at 11:44 PM, lowly coder wrote:
So I'm looking more in lib/_repl.scm, in particular at:
(define-prim (##interp-procedure-default-entry-hook proc) (let ((hook (##interp-procedure-entry-hook proc))) (if (and hook (##closure? hook) (##eq? (##subprocedure-parent (##closure-code hook)) ##make-default-entry-hook)) hook #f)))
and I'm wondering two things:
in trace, where is the pp / display / write
after the proc is setup by ##interp-procedure-default-entry-hook,
where in the interpreter is proc called?
I won't spoil your fun... in only 40 minutes you've learned a lot about Gambit! I'll give you the answer tomorrow night if you can't solve it yourself...
Marc
Okay, so I have what I need, in the sense that I can write an alternative function that gets called during 'trace', as seen in attached "trace.scm"
Here, however, are things I don't get:
1) in adition to proc & args, can I also get the current stack frame?
2) looking at "broken.scm" and "works.scm" -- I just copied/pasted the make-default-entry-hook from lib/_repl.scm -- why does one of them work for tracing and the other does not?
Thanks!
On Fri, Feb 20, 2009 at 9:08 PM, Marc Feeley feeley@iro.umontreal.cawrote:
On 20-Feb-09, at 11:44 PM, lowly coder wrote:
So I'm looking more in lib/_repl.scm, in particular at:
(define-prim (##interp-procedure-default-entry-hook proc) (let ((hook (##interp-procedure-entry-hook proc))) (if (and hook (##closure? hook) (##eq? (##subprocedure-parent (##closure-code hook)) ##make-default-entry-hook)) hook #f)))
and I'm wondering two things:
in trace, where is the pp / display / write
after the proc is setup by ##interp-procedure-default-entry-hook, where
in the interpreter is proc called?
I won't spoil your fun... in only 40 minutes you've learned a lot about Gambit! I'll give you the answer tomorrow night if you can't solve it yourself...
Marc