From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.user,gmane.lisp.guile.devel Subject: Re: PLEASE: debugging embedded guile code Date: 28 Apr 2003 21:58:38 +0100 Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: References: <20030225093608.6a8935f8.dsmith@altustech.com> <3EAAB691.6AD935B5@veritas.com> <3EAAE877.7140ECB6@veritas.com> <3EAC5266.23DEEB7F@veritas.com> <3EAD89DB.9B0A1367@veritas.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1051563799 10873 80.91.224.249 (28 Apr 2003 21:03:19 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 28 Apr 2003 21:03:19 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Apr 28 23:03:15 2003 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 19AFmM-0002ov-00 for ; Mon, 28 Apr 2003 23:03:15 +0200 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 19AFma-0004ng-09 for guile-user@m.gmane.org; Mon, 28 Apr 2003 17:03:28 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 19AFlm-0004TD-00 for guile-user@gnu.org; Mon, 28 Apr 2003 17:02:38 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 19AFjA-0003b5-00 for guile-user@gnu.org; Mon, 28 Apr 2003 16:59:57 -0400 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 19AFj5-0003ID-00; Mon, 28 Apr 2003 16:59:51 -0400 Original-Received: from laruns.ossau.uklinux.net (bts-0781.dialup.zetnet.co.uk [194.247.51.13]) by s1.uklinux.net (8.11.6p2/8.11.6) with ESMTP id h3SKxkK22873; Mon, 28 Apr 2003 21:59:47 +0100 Original-Received: from laruns.ossau.uklinux.net.ossau.uklinux.net (localhost [127.0.0.1])ESMTP id 4F068DC4D4; Mon, 28 Apr 2003 21:58:38 +0100 (BST) Original-To: bkorb@veritas.com In-Reply-To: <3EAD89DB.9B0A1367@veritas.com> Original-Lines: 77 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 Original-cc: guile-user@gnu.org X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: General Guile related discussions List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.user:1865 gmane.lisp.guile.devel:2233 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2233 >>>>> "Bruce" == Bruce Korb writes: Bruce> Neil Jerram wrote: >> >> Does this help? Bruce> Yes. A lot. I think I know why I didn't think of it Bruce> before, though. :-) :-) Bruce> except instead of "" I'd supply the name of the Bruce> file I was reading to get the Scheme code. Good idea. You might check out `emacs-load' in (ice-9 emacs) which uses the same trick to set port name and position for code sent to it from Emacs. Bruce> Right near [1] I would want to add the starting line number Bruce> to the evaluator's notion of what the current line number Bruce> is. If I'm on line 100 of my clients input text, it would Bruce> be nice for the display-error code to display a line number Bruce> 99 higher than otherwise. I'd do this by using some of my Bruce> own functions: >> (define (eval-client-input str) >> (stack-catch #t >> (lambda () >> (call-with-input-string str >> (lambda (p) >> (set-port-filename! p (tpl-file)) >> (SET-PORT-FILELINE! p (string->number (tpl-file-line "%2$d"))) >> (list (primitive-eval (read p)))))) >> (lambda (key . args) >> ;; [1] >> (apply display-error (fluid-ref the-last-stack) >> (current-error-port) >> args) >> (set! stack-saved? #f) >> #f))) Exactly (except that set-port-fileline! is actually set-port-line!). >> Note - the code above assumes that `args' has the right >> structure (see doc for display-error), which is true for all >> the exceptions generated by Guile itself. If you want to >> handle exceptions generated by your own or your client's code, >> you need to add code at [1] to identify non-core exceptions and >> turn their throw args into suitable parameters for >> display-error. Bruce> I think I'd want to test for a client error list massaging Bruce> procedure and invoke that if present. Yes, I've been thinking about a mechanism for this, probably GOOPS-based. My thinking now (much advanced by this thread) is that there are 3 points of weakness in the error handling system: 1. No documentation :-) 2. No mechanism for relating the throw or error args at the point where an exception is raised to how they should be interpreted or displayed by the catch handler. 3. The fragile interdependencies of stack-catch, lazy-handler-dispatch, the-last-stack and stack-saved? We can live with 3 for a while longer, but I think it won't be too hard to specify a nice mechanism for 2; so I'd like to do that and then document the whole thing. Bruce> The only places I throw errors, I call scm_wrong_type_arg Bruce> directly. I would guess it would have args set up okay. :) Yes, I believe so. Anything that goes through scm_error will be OK. Neil _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user