guile-devel
[Top][All Lists]
Advanced

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

Re: wrong-type-arg in scm_display_backtrace


From: Neil Jerram
Subject: Re: wrong-type-arg in scm_display_backtrace
Date: 31 Dec 2002 23:42:09 +0000
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

>>>>> "William" == William Morgan <address@hidden> writes:

    William> I need to catch Guile exceptions in my own
    William> handler. However, when I try to display the backtrace, I
    William> invariably get the following message:

    William>    Exception during displaying of backtrace: wrong-type-arg

    William>     scm_display_backtrace (stack, port, SCM_UNDEFINED, 
SCM_UNDEFINED);

Is stack #f on entry to scm_display_backtrace?

The point is that the information displayed by scm_display_backtrace
mainly comes from a representation of the stack that was captured at
the point where the error occurred.  The problem is capturing and
saving the stack at that point.

In the context of the Guile REPL this is done using a `lazy-catch'
(see the reference manual) in:

- error-catching-loop
  - lazy-catch with handler lazy-handler-dispatch
    - default-lazy-handler
      - save-stack,

and it is save-stack that sets the value of `the-last-stack'.

To get scm_display_backtrace to work in your scenario, you essentially
need to replicate the kernel of all this in C, i.e.:

(lazy-catch #t
            thunk
            (lambda (args)
              (fluid-set! the-last-stack (make-stack #t))
              (apply throw args)))

Please say if you need more ...  (And yes, this should all be in the
manual.)

        Neil




reply via email to

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