guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I see output from `trace' when I've `load'ed a file?


From: Neil Jerram
Subject: Re: How can I see output from `trace' when I've `load'ed a file?
Date: 28 Nov 2002 21:38:11 +0000
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

>>>>> "Eric" == Eric Hanchrow <address@hidden> writes:

    Eric> Hmm.  I didn't see any output from `trace'.

    Eric> So: I'd like to be able to see the output even when the file was
    Eric> "load"ed from the repl, or run with `guile -s'.  Is there a way to do
    Eric> this?

Yes.

    (use-modules (ice-9 debug))

    (define (foo x)
      (cons x '()))

    (trace foo)

    (trace-stack #t)

    (with-traps (lambda ()
                  (display (foo 'bob))))

    (newline)

To explain, tracing by default requires 2 things, both of which are
set up by the REPL but not for a script:

- traps have to be enabled; fixed above using `with-traps', but you
  could also do (trap-enable 'traps)

- the id of the stack under which the code is executed has to be
  registered with (ice-9 debug), and by default only 'repl-stack is
  registered; the `(trace-stack #t)' above makes tracing apply
  regardless of stack id.

        Neil





reply via email to

[Prev in Thread] Current Thread [Next in Thread]