[Ecls-list] The dreaded embedded debugger

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Tue Feb 22 08:25:12 UTC 2011


On Tue, Feb 22, 2011 at 6:07 AM, <aaron at pageofswords.net> wrote:

> Hi, I am having a lot of trouble figuring out how to prevent the debugger
> becoming active in embedded mode.
>  I have tried:
> + Calling ecl_disable_interrupts(); before cl_eval()
>

Nothing to do with that. These are Unix interrupts


> + And also this: (setf si::*interrupt-enable* nil)
>

See above.


> + Executing the following in ecl: (setf *debugger-hook* #'debug-ignore)
>

What does your *debugger-hook* function do? Just returning? This is not
going to work at all. First try doing it in Common Lisp, then port the stuff
to your program


> Mmm... I want to evaluate something like
> si_safe_eval(3,c_string_to_object("(vvvvformat t \"Hello\")"), Cnil,
> OBJNULL);
>

Problem 1: the expression you are going to evaluate is ill formed. SAFE-EVAL
can not protect you because the error happens _before_ this function is ever
invoked.

Problem 2: your debug-ignore function does not do what is expected to do.
When an error handler is invoked it should either offer an interactive
debugger or perform some transfer of control to an outer point, as in

(block nil (handler-bind ((error #'(lambda (c) (return 2)))) (cos 'a)))

I presume that debug-ignore does not do this: it simply returns and the
debugger just gets invoked again (the error has not been solved).

Alternative: if you know you are going to get ill formed expressions,
convert the READ_CL forms into a standalone function that detects and
ignores errors. Fortunately there is an undocumented function that
c_string_to_object is based on

#define ecl_read_from_cstring(s)
si_string_to_object(1,make_constant_base_string(s))
#define ecl_read_from_cstring_safe(s,v)
si_string_to_object(2,make_constant_base_string(s),(v))

The second version does it safely.

Juanjo

-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20110222/4b9fd622/attachment.html>


More information about the ecl-devel mailing list