From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.devel Subject: Hook for script debugging Date: Sat, 26 Sep 2009 15:51:38 +0100 Message-ID: <87k4zlhi85.fsf@ossau.uklinux.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1253976715 13601 80.91.229.12 (26 Sep 2009 14:51:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 26 Sep 2009 14:51:55 +0000 (UTC) To: Guile Development Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Sep 26 16:51:48 2009 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MrYcm-0006Mf-DG for guile-devel@m.gmane.org; Sat, 26 Sep 2009 16:51:48 +0200 Original-Received: from localhost ([127.0.0.1]:40209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MrYcl-0002jC-Vv for guile-devel@m.gmane.org; Sat, 26 Sep 2009 10:51:48 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MrYcj-0002j7-PQ for guile-devel@gnu.org; Sat, 26 Sep 2009 10:51:45 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MrYcf-0002is-1A for guile-devel@gnu.org; Sat, 26 Sep 2009 10:51:45 -0400 Original-Received: from [199.232.76.173] (port=42366 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MrYce-0002ip-Ui for guile-devel@gnu.org; Sat, 26 Sep 2009 10:51:40 -0400 Original-Received: from mail3.uklinux.net ([80.84.72.33]:59867) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MrYce-0001GN-Bb for guile-devel@gnu.org; Sat, 26 Sep 2009 10:51:40 -0400 Original-Received: from arudy (host86-147-112-99.range86-147.btcentralplus.com [86.147.112.99]) by mail3.uklinux.net (Postfix) with ESMTP id 768091F6DD9 for ; Sat, 26 Sep 2009 15:51:39 +0100 (BST) Original-Received: from arudy (arudy [127.0.0.1]) by arudy (Postfix) with ESMTP id E0ABA38021 for ; Sat, 26 Sep 2009 15:51:38 +0100 (BST) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:9401 Archived-At: I'd like Guile to support something like the patch below - i.e. some way of being able to execute arbitrary code before a Guile script starts running, so as to be able to set up breakpoints (or whatever other mechanisms are available) to trace or debug the script execution. (And without having to edit the script.) Some possible questions... Is GUILE_BOOT_FORM a good name? Is it too general? Should we instead support a variable GUILE_PRE_SCRIPT_REPL, which causes us to run a normal REPL before loading the script? Or perhaps a more limited or debugging-focussed REPL? I think the generality of GUILE_BOOT_FORM is useful. If the only option is starting a REPL, that makes automated operation less convenient. Also, imagine a build in which there might be several Guile script invocations, and you only want to debug one of them. Then the boot form could include a check of the script name - (car (command-line)) - and only start a REPL (or set a breakpoint, or whatever) for that one. Thoughts? Regards, Neil diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm index a1537d1..86ab725 100644 --- a/module/ice-9/boot-9.scm +++ b/module/ice-9/boot-9.scm @@ -3514,4 +3514,9 @@ module '(ice-9 q) '(make-q q-length))}." (define-module (guile-user) #:autoload (system base compile) (compile)) +(let ((boot-form (getenv "GUILE_BOOT_FORM"))) + (if (and (string? boot-form) + (not (zero? (string-length boot-form)))) + (primitive-eval (with-input-from-string boot-form read)))) + ;;; boot-9.scm ends here