unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Hook for script debugging
@ 2009-09-26 14:51 Neil Jerram
  2009-09-26 21:06 ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Neil Jerram @ 2009-09-26 14:51 UTC (permalink / raw)
  To: Guile Development

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




^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-10-02  8:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-26 14:51 Hook for script debugging Neil Jerram
2009-09-26 21:06 ` Ludovic Courtès
2009-09-27 16:41   ` Neil Jerram
2009-10-02  8:35     ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).