[Larceny-users] recursive lists and C-c problems
Ray Racine
ray.racine at gmail.com
Mon Dec 8 17:41:24 EST 2008
http://github.com/GreyLensman/rl3/tree/webserver/rl3/env/debug.sls
Here is another example of establishing your own error handler in ERR5RS
(R6RS kinda sorta) Larceny.
I had it bound to my emacs. When debug was "disabled" the handler prints
the error and leaves you at the top level REPL and not in the debugger. Its
just a simple example. Dave's solution actually give a solution for your
specific concern.
There is some other Larceny ERR5RS sorta/kinda R6RS code there as well.
Unfortunately its not system agnostic and a clean build with
compile-stale-libraries requires a Linux box. Its mostely web oriented.
HTTP, continuation threading, sockets support that works with the R6RS I/O,
SXML, Amazon Cloud client code, a small REST web server, etc...
Unfortunately its not well documented and a bit of mess. I hope to get back
to it early next year.
Ray
On Mon, Dec 8, 2008 at 4:06 PM, David Rush <kumoyuki at gmail.com> wrote:
> 2008/12/8 Marco Maggi <marco.maggi-ipsu at poste.it>
> > "will at ---" wrote:
> > >Marco Maggi wrote:
> >
> > >> After hitting C-c, I see that the debugger is here
> > >> and I can exit it with "q". And I am left with a prompt?
> > >
> > >Yes. It isn't a very useful prompt, since nothing is
> > >in scope, but it's a prompt.
> >
> > Nothing is in scope until I issue "(import (rnrs))",
> > then I do what I want with escalated privileges.
>
> As I said earlier, if you're running setuid, you should have
> *thoroughly* debugged your code. Then you will not hit the prompt.
>
> > It would suffice to have a command line switch that
> > makes the process exit whenever an exception is not
> > blocked.
>
> How about installing your own error-handler that just exits the
> program? There's a really simple API for this. You could minimally
> just use the code:
>
> (error-handler (lambda _ (exit)))
>
> and get your result. Which is not very helpful because is you haven't
> debugged sufficiently that you are still getting errors which
> terminate the program, you generally would like to know what went
> wrong. Hence the following code (which is part of my Larceny standard
> prelude):
>
> (require 'inspect-cont)
> (define (batch/last-chance-handler puts)
> (lambda e
> (define (display-line s)
> (puts (with-output-to-string
> (lambda() (write s)))))
>
> (display-line `(lastchance error handler ,e))
>
> (let* ((error-text
> (call-with-output-string (lambda (p) (decode-error e p))))
> (stacktrace (current-continuation-structure))
> (inspector (make-continuation-inspector stacktrace))
>
> (summarize-frame
> (lambda (count inspector . prefix)
> (let* ((frame (inspector 'get))
> (code (frame 'code))
> (class (code 'class))
> (expr (code 'expression))
> (proc (code 'procedure)))
> (display-line
> `(frame , at prefix ,class
> ,@(case class
> ((system-procedure) '())
> ((interpreted-primitive) (procedure-name
> proc))
> ((interpreted-expression) expr)
> ((compiled-procedure) (procedure-name proc))
> (else '())))
> ))))
>
> (backtrace
> (lambda (count inspector)
> (let loop ((c (inspector 'clone)))
> (let ((f (c 'get)))
> (if (f 'same? (inspector 'get))
> (summarize-frame 0 c "=> ")
> (summarize-frame 0 c " ")))
> (if (c 'down)
> (loop c))
> )))
> )
> (display-line `(decoded error ,error-text))
> (backtrace 0 inspector)
> (exit 0)
> )))
>
> (define (install-lastchance puts)
> (error-handler (batch/last-chance-handler puts))
>
> To use this fragment, call:
>
> (install-lastchance puts-function)
>
> where puts-function takes a string and does something appropriate with it.
>
> david
> --
> GPG Public key at http://cyber-rush.org/drr/gpg-public-key.txt
>
> _______________________________________________
> Larceny-users mailing list
> Larceny-users at lists.ccs.neu.edu
> https://lists.ccs.neu.edu/bin/listinfo/larceny-users
>
-------------- next part --------------
HTML attachment scrubbed and removed
More information about the Larceny-users
mailing list