From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: William Morgan Newsgroups: gmane.lisp.guile.devel Subject: Re: wrong-type-arg in scm_display_backtrace Date: Sat, 4 Jan 2003 22:57:42 -0500 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <20030105035742.GA29985@masanjin.net> 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 1041738889 25136 80.91.224.249 (5 Jan 2003 03:54:49 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 5 Jan 2003 03:54:49 +0000 (UTC) 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 18V1s8-0006XI-00 for ; Sun, 05 Jan 2003 04:54:48 +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 18V1sr-0004Fi-03 for guile-devel@m.gmane.org; Sat, 04 Jan 2003 22:55:33 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18V1sQ-00045a-00 for guile-devel@gnu.org; Sat, 04 Jan 2003 22:55:06 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18V1sL-0003vC-00 for guile-devel@gnu.org; Sat, 04 Jan 2003 22:55:03 -0500 Original-Received: from h0060976e2b56.ne.client2.attbi.com ([65.96.180.211] helo=lux) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18V1sK-0003ro-00 for guile-devel@gnu.org; Sat, 04 Jan 2003 22:55:00 -0500 Original-Received: from wmorgan by lux with local (Exim 3.35 #1 (Debian)) id 18V1uw-0007oQ-00 for ; Sat, 04 Jan 2003 22:57:42 -0500 Original-To: guile-devel@gnu.org Mail-Followup-To: guile-devel@gnu.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i 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:1851 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:1851 Excerpts (reformatted) from Neil Jerram's mail of 31 Dec 2002 (EST): > Is stack #f on entry to scm_display_backtrace? Indeed, it is #f after all. > 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))) Ok, this is helpful. I am starting to understand exactly what I need to be doing. Unfortunately I am still unsuccesful: >>From perusal of throw.c, it seems that scm_internal_stack_catch is what I want to call, as it sets scm_the_last_stack_fluid_var. However, using, the stack is always #f at the point that I hit the error handler. So what am I doing wrong in the code below? --- snip --- static SCM guile_safe_apply_handler(void *data, SCM tag, SCM throw_args) { SCM port = scm_def_errp; if(scm_ilength(throw_args) >= 3) { SCM stack = scm_fluid_ref(SCM_VARIABLE_REF(scm_the_last_stack_fluid_var)); SCM subr = SCM_CAR(throw_args); SCM message = SCM_CADR(throw_args); SCM args = SCM_CADDR(throw_args); /* So far, I reach this point with non-user-throws exceptions (e.g. undefined variables). But stack is invariably #f. */ scm_display_backtrace(stack, port, SCM_UNDEFINED, SCM_UNDEFINED); return SCM_BOOL_F; } else { /* I reach this point upon user-thrown exceptions. Why? */ scm_puts("uncaught throw to ", port); scm_prin1(tag, port, 0); } return SCM_BOOL_T; } struct guile_body_apply_data { SCM proc; SCM args; }; SCM guile_safe_apply_body(struct guile_body_apply_data* data) { return scm_apply_0(data->proc, data->args); } SCM guile_safe_apply(SCM proc, SCM args) { struct guile_body_apply_data data; data.proc = proc; data.args = args; return scm_internal_stack_catch(SCM_BOOL_T, (scm_t_catch_body)guile_safe_apply_body, (void*)&data, (scm_t_catch_handler)guile_safe_apply_handler, NULL); } --- snip --- Is scm_apply_0 the wrong thing to call in the body? Any further help would be appreciated. Thanks, -- William _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel