From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.devel Subject: Re: wrong-type-arg in scm_display_backtrace Date: 31 Dec 2002 23:42:09 +0000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: References: <20021230013149.GB25056@masanjin.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1041378697 7520 80.91.224.249 (31 Dec 2002 23:51:37 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 31 Dec 2002 23:51:37 +0000 (UTC) Cc: guile-devel@gnu.org Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18TWAZ-0001x1-00 for ; Wed, 01 Jan 2003 00:51:35 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18TWAm-0005tT-03 for guile-devel@m.gmane.org; Tue, 31 Dec 2002 18:51:48 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18TWAU-0005op-00 for guile-devel@gnu.org; Tue, 31 Dec 2002 18:51:30 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18TWAS-0005kb-00 for guile-devel@gnu.org; Tue, 31 Dec 2002 18:51:29 -0500 Original-Received: from mail.uklinux.net ([80.84.72.21] helo=s1.uklinux.net) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18TWAR-0005hQ-00 for guile-devel@gnu.org; Tue, 31 Dec 2002 18:51:27 -0500 Original-Received: from laruns.ossau.uklinux.net (bts-0308.dialup.zetnet.co.uk [194.247.49.52]) by s1.uklinux.net (8.11.6/8.11.6) with ESMTP id gBVNpOP07376; Tue, 31 Dec 2002 23:51:24 GMT Original-Received: from laruns.ossau.uklinux.net.ossau.uklinux.net (localhost [127.0.0.1])ESMTP id C89AFDC4D3; Tue, 31 Dec 2002 23:42:09 +0000 (GMT) Original-To: William Morgan In-Reply-To: <20021230013149.GB25056@masanjin.net> Original-Lines: 40 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:1846 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:1846 >>>>> "William" == William Morgan 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