From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.user Subject: Re: Enabling Debugging Date: Mon, 04 Sep 2006 08:35:37 +0100 Message-ID: <878xl09j92.fsf@ossau.uklinux.net> References: <20060729113034.GA1340@alamut.tdm.local> <873bck9qkv.fsf@unknownlamer.org> <20060731071301.GA1600@alamut.tdm.local> <1154339628.9074.8.camel@localhost.localdomain> <20060801104631.GC1323@alamut.tdm.local> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1157355557 18483 80.91.229.2 (4 Sep 2006 07:39:17 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 4 Sep 2006 07:39:17 +0000 (UTC) Cc: Clinton Ebadi , Guile Users Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Sep 04 09:39:16 2006 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GK932-0007Nm-KL for guile-user@m.gmane.org; Mon, 04 Sep 2006 09:39:12 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GK931-0000gK-OK for guile-user@m.gmane.org; Mon, 04 Sep 2006 03:39:11 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GK92x-0000g8-1g for guile-user@gnu.org; Mon, 04 Sep 2006 03:39:07 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GK92v-0000fr-7t for guile-user@gnu.org; Mon, 04 Sep 2006 03:39:06 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GK92u-0000fm-Vs for guile-user@gnu.org; Mon, 04 Sep 2006 03:39:05 -0400 Original-Received: from [80.84.72.33] (helo=mail3.uklinux.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GK9DO-0004Jh-26 for guile-user@gnu.org; Mon, 04 Sep 2006 03:49:54 -0400 Original-Received: from laruns (host86-129-125-104.range86-129.btcentralplus.com [86.129.125.104]) by mail3.uklinux.net (Postfix) with ESMTP id 3AACB40A167; Mon, 4 Sep 2006 07:37:01 +0000 (UTC) Original-Received: from laruns (laruns [127.0.0.1]) by laruns (Postfix) with ESMTP id 7D0456FF8E; Mon, 4 Sep 2006 08:35:37 +0100 (BST) Original-To: Volkan YAZICI In-Reply-To: <20060801104631.GC1323@alamut.tdm.local> (Volkan YAZICI's message of "Tue, 1 Aug 2006 13:46:31 +0300") User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:5492 Archived-At: Volkan YAZICI writes: > On Jul 31 10:53, dave wrote: >> I had to work through this a while back, and the problem I had was that >> there are two types of error handler callback - one is called before the >> stack is unwound, the other after. If you only set the error callback >> for after the unwind there is no stack to do the debugging... > > Can you send an example working code snippet please? You've probably seen the new doc on this subject that I posted to the guile list a few days ago. This is also now in the CVS reference manual (node "Debug on Error"), and I hope that it answers most of your questions; please let me know if not. > I've considered your "before the stack is unwound and the other after" > explanation and concluded with such a scm_c_catch() call: > > scm_c_catch(SCM_BOOL_T, /* tag */ > (scm_t_catch_body) eval_code, /* body */ > (void *) code, /* body data */ > (scm_t_catch_handler) catch_err, /* handler */ > (void *) code, /* handler data */ > (scm_t_catch_handler) unwind_catch, > (void *) code); > > But scm_backtrace(), that's placed in both catch_err() and > unwind_catch(), still complains that "No backtrace available". Yes; this is because the stack still needs to be captured explicitly by a scm_make_stack call, within unwind_catch. > Doesn't anybody have a working example code snippet? How did ppl achieve > to write so much programs using guile? I personally like to write as much as possible in Scheme, so I'm afraid I don't have a tested example. (In other words, I make a single call out from C to Scheme, using scm_call or scm_apply, then code whatever exception handling I need in Scheme, within the function that was called from C.) > Furthermore, I've another problem: How do we receive information from > tag and args variables passed to exception handlers? I was using > > buf = SCM_STRING_CHARS(tag); > len = SCM_STRING_LENGTH(tag); > while (len-- > 0) > putchar(*buf++); > > method but, in the new 1.8 release it says that I'm using deprecated > functions. So how can get the pointer pointing to the related text > buffer? I cannot use gh_scm2newstr() in this situation, because it > allocates required buffer itself and just dumps an error to stderr > in case of a failure. Actually, I'm working on a shared memory segment > thus I don't want guile to make any memory allocations on its own. > Can I achieve such a functionality? (I want it to use palloc/pfree > instead of recent malloc/free calls.) Can a macro hack like > > #define malloc palloc > #define free pfree > > solve that problem? The tag is actually a symbol. What do you want to do with it? If you want to test it for equality (with scm_misc_error_key, for example), use "scm_is_eq (tag, scm_misc_error_key)". If you want to print it out to the current output port, use "scm_display (tag, SCM_UNDEFINED)". > Moreover, as far as SCM_CONSP(args) says so, the third param (args) > passed to exception handlers is a cons. Despite I've tried some > gh_car(), gh_cdr() tricks, I couldn't manage to figure out how to use > that information too. This - i.e. knowing how to interpret exception args - is an ongoing problem. Please see and contribute to the discussion in another thread. Regards, Neil _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user