unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Neil Jerram <neil@ossau.uklinux.net>
Cc: guile-devel@gnu.org
Subject: Re: wrong-type-arg in scm_display_backtrace
Date: 31 Dec 2002 23:42:09 +0000	[thread overview]
Message-ID: <m3el7xoiwe.fsf@laruns.ossau.uklinux.net> (raw)
In-Reply-To: <20021230013149.GB25056@masanjin.net>

>>>>> "William" == William Morgan <wmorgan-gu2@masanjin.net> 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



_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


  reply	other threads:[~2002-12-31 23:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-30  1:31 wrong-type-arg in scm_display_backtrace William Morgan
2002-12-31 23:42 ` Neil Jerram [this message]
2003-01-05  3:57   ` William Morgan
2003-01-06 19:06     ` Neil Jerram
2003-01-07  5:42       ` William Morgan
2003-01-08 20:21         ` Neil Jerram
2003-01-08 22:38           ` William Morgan
2003-01-09 23:42             ` Neil Jerram
2003-01-10 20:31               ` vports from c questions William Morgan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3el7xoiwe.fsf@laruns.ossau.uklinux.net \
    --to=neil@ossau.uklinux.net \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).