abcl icon indicating copy to clipboard operation
abcl copied to clipboard

Implementation of STEP

Open easye opened this issue 5 years ago • 4 comments

Request for strategies for implementing cl:step for CL implementations in general, and ABCL in particular.

https://mailman.common-lisp.net/pipermail/armedbear-devel/2020-August/004114.html

easye avatar Aug 02 '20 16:08 easye

My workarounds for not using cl:step when debugging:

For debugging ABCL interactively under SLIME in lieu of STEP implementation, I visit code in a buffer, copy the relevant top-level forms to *slime-scratch*, insert BREAK forms, then evaluate the form with C-u slime-compile-defun. Best when using SLIME 2.25 ff. https://github.com/slime/slime/releases/tag/v2.25 which affords inspection of function call arguments. Perhaps suboptimal, but the best route I have found, as there are a fair number of potential issues with use of cl:step in multi threads of execution which ABCL always has by virtue of being hosted on the JVM.

That and a lot of use of TRACE to figure out where the problem is occurring.

easye avatar Aug 02 '20 16:08 easye

[copy of https://mailman.common-lisp.net/pipermail/armedbear-devel/2020-August/004116.html]

I believe I thought the starting point should be in src/org/armedbear/Lisp.java which hosts what looks like an evaluator. Look for

public static final LispObject eval(final LispObject obj, 
                                     final Environment env,
                                     final LispThread thread)

For instance at "else if (obj instanceof Cons)" it is handling evaluation of a cons, with the first section handling the case where the first element is a symbol and checking for whether it names a function, macro, or special form. Below that it handles the case where there's a lambda in the function position. There's a hook for profiling that counts function calls - presumably that would be one place to hook. You'll need to follow it to see how the special forms etc are processed, etc.

If, in slime you execute e.g. (defun foo (a b &optional c) (and c (+ a b))) and (inspect #'foo), you'll see how ABCL represents evaluated functions.

alanruttenberg avatar Aug 02 '20 23:08 alanruttenberg

@alejandrozf's interpreted implementation https://github.com/armedbear/abcl/pull/596 as presented at ELS 2023 is the first candidate <https://github.com/armedbear/abcl/pull/596>.

I'd like to examine the Java-side augmentations this neeed with reference to other cl:step abstractions.

easye avatar Jun 11 '23 06:06 easye