[Openmcl-devel] Trying to build a single stepper
73budden .
budden73 at gmail.com
Thu Jan 18 07:41:31 PST 2018
Hi!
I'm trying to build a single stepper for compiled functions in CCL
(vanilla "Visual Basic" like "debugger").
My current idea is to find all function references (subset of
ccl::lfunloop scope) and
replace all of them with function wrappers. E.g. I have a function
which I want to make steppable:
(defun f () (print 'list))
It references PRINT as a symbol.
(lfunloop for v in #'f do (print v)) returns:
LIST
PRINT
F
Then I do:
CCL>(compile (defun my-wrapped-print (&rest args) (break "About to
call print with ~S" args) (apply #'print args)))
MY-WRAPPED-PRINT
And
CCL>(%set-nth-immediate #'f 1 'MY-WRAPPED-PRINT)
Then, when I run (f), debugger is invoked while trying to call
"print". In current example #'f is too trivial and it isn't shown on
the backtrace, but if we make more complex f and put it into the
source file, I can see its source with SWANK debugger.
So the question is: how do I say 'print (which is used as a function)
from 'list (which is used as mere data). If I treat any symbol
reference as a function, this would be obviously wrong.
As far as I can get it, I have to track how symbols are referenced. I
found already that #<acode immediate (PRINT)> is created in the
nx1-call-form, so I think I can extend acode to include the type of
reference. Also I found how info is extracted. So I can add a
bit-vector to a functions data which stores "1" if nth-immediate is a
function and 0 otherwise. But still I'm unable to find where this
immediate is recorded into the generated code, so I don't know how to
extend the set. Can anyone please give a hint?
Also, if my approach is definitely wrong somehow, please let me know.
More information about the Openmcl-devel
mailing list