guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PLEASE: debugging embedded guile code


From: Bruce Korb
Subject: Re: PLEASE: debugging embedded guile code
Date: Sat, 26 Apr 2003 09:40:49 -0700

Neil Jerram wrote:
>     >> So: what should I do in order to enable debugging support
>     >> for embedded Guile code? How can I retrieve the location of
>     >> a possible error when calling guile code from the main program?

>     Dale> Here is how I did it in mod-guile:
> 
>     Dale> SCM
>     Dale> mg_lazy_handler(void *data, SCM tag, SCM throw_args)
>     Dale> {
>     Dale>   SCM eport = scm_current_error_port(); [...]
> 
> I'm curious about this because the question of error handling keeps
> popping up and I'm wondering whether our current solution is good
> enough.  (With a strong suspicion that it isn't.)
> 
> One thing I'm not sure I understand is why you want (or perhaps need)
> to do this lazy-catch in C rather than in Scheme, since it would be
> much easier in Scheme.  Can you explain?

The need is to be able to point our clients to problems in the
Scheme code.  We (or, at least, I) know where in our client's
input we are when we hand a string off to Guile for evaluation.
I'd like to be able to tell Guile what the current file name
and line number so that when it emits an error message, Guile
can refer to our client's source file.  As it is, I have to
set an atexit routine.  All it is able to tell is that Guile
called exit(3C) and it must now emit a generic "this is where
we were when Guile called exit" message:

    switch (procState) {
    case PROC_STATE_EMITTING:
    case PROC_STATE_INCLUDING:
        /*
         *  A library (viz., Guile) procedure has called exit(3C).
         *  The AutoGen abort paths all set procState to PROC_STATE_ABORTING.
         */
        if (*pzOopsPrefix != NUL) {
            /*
             *  Emit the CGI page header for an error message.
             */
            fputs( pzOopsPrefix, stderr );
            pzOopsPrefix = "";
        }

        fprintf( stderr, zErr, pCurTemplate->pzFileName, pCurMacro->lineNo );

Of course, I have to do a bunch of magic anyway because if there
is an error exit, I may or may not have to emit a CGI-style preamble:

> static const char zOops[] =
> "Content-type: text/plain\n\n"
> "AutoGen form processing error:\n";

but it would still be nice to have the above file/line woven into
the native Guile message as it is for the interactive guile program.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]