[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/slime 34b7e43530 09/43: abcl: implement inspection of loca
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/slime 34b7e43530 09/43: abcl: implement inspection of locals in interpreted frames |
Date: |
Thu, 28 Dec 2023 22:00:28 -0500 (EST) |
branch: elpa/slime
commit 34b7e4353008ed98cd2f6219439b8ea3ab731154
Author: Alan Ruttenberg <alanruttenberg@gmail.com>
Commit: Mark Evenson <evenson.not.org@gmail.com>
abcl: implement inspection of locals in interpreted frames
In order to inspect variables in interpreted frames requires a version
of the as-yet-unreleased abcl-1.8.1 after
<https://github.com/armedbear/abcl/commit/83a5ea85b336a3cd39b3c6b23600fb2bc6b22ff4>
<https://abcl.org/trac/changeset/15558>.
---
swank/abcl.lisp | 113 +++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 92 insertions(+), 21 deletions(-)
diff --git a/swank/abcl.lisp b/swank/abcl.lisp
index c8c956e31f..32cb4d5d19 100644
--- a/swank/abcl.lisp
+++ b/swank/abcl.lisp
@@ -544,31 +544,82 @@
(multiple-value-list
(jvm::parse-lambda-list (ext:arglist operator)))
values))
+
+;; Switch to enable or disable locals functionality
+#+abcl-introspect
+(defvar *enable-locals* t)
+
+#+abcl-introspect
+(defun are-there-locals? (frame index)
+ (and *enable-locals*
+ (fboundp 'abcl-introspect/sys::find-locals)
+ (typep frame 'sys::lisp-stack-frame)
+ (let ((operator (jss::get-java-field (nth-frame index) "operator" t)))
+ (and (function-lambda-expression (if (functionp operator) operator
(symbol-function operator)))
+ (not (member operator '(java::jcall java::jcall-static))) ;;
WTF, length is an interpreted function??
+ (if (symbolp operator)
+ (not (eq (symbol-package operator) (find-package 'cl)))
+ t)))))
+
+#+abcl-introspect
+(defun abcl-introspect/frame-locals (frame index)
+ ;; FIXME introspect locals in SYS::JAVA-STACK-FRAME
+ (or (and (are-there-locals? frame index)
+ (let ((locals (abcl-introspect/sys:find-locals index (backtrace 0
(1+ index)))))
+ (let ((argcount (length (cdr (nth-frame-list index))))
+ (them
+ (let ((operator (jss::get-java-field (nth-frame index)
"operator" t)))
+ (let* ((env (and (jss::jtypep operator 'lisp.closure)
+ (jss::get-java-field operator
"environment" t)))
+ (closed-count (if env (length
(sys::environment-parts env)) 0)))
+ (declare (ignore closed-count))
+ ; FIXME closed-over are in parts but
also in locals
+ ; FIXME closed-over are in compiled
functions to but are value of internal field
+ ; environment is the enviromnet of
+ (loop for (kind symbol value) in (caar locals)
+ when (eq kind :lexical-variable)
+ ; FIXME should I qualify each by
whether arg, closed-over, let-bound?
+ collect (list :name symbol
+ :id 0
+ :value value))))))
+ (declare (ignore argcount))
+ (reverse them))))))
(defimplementation frame-locals (index)
- (let ((frame (nth-frame index)))
- ;; FIXME introspect locals in SYS::JAVA-STACK-FRAME
- (when (typep frame 'sys::lisp-stack-frame)
- (loop
- :for id :upfrom 0
- :with frame = (nth-frame-list index)
- :with operator = (first frame)
- :with values = (rest frame)
- :with arglist = (if (and operator (consp values) (not (null values)))
- (handler-case (match-lambda operator values)
- (jvm::lambda-list-mismatch (e) (declare(ignore
e))
- :lambda-list-mismatch))
- :not-available)
- :for value :in values
- :collecting (list
- :name (if (not (keywordp arglist))
- (first (nth id arglist))
- (format nil "arg~A" id))
- :id id
- :value value)))))
+ (let ((frame (nth-frame index))) ;;(id -1)
+ (let ((frame-locals
+ #+abcl-introspect
+ (abcl-introspect/frame-locals frame index))
+ ;;; We include the arguments to the frame to the list of
+ ;;; locals. TODO: figure out if there is a better place,
+ ;;; and at least decorate arguments differently from locals
+ (frame-arguments
+ (loop
+ :with frame = (nth-frame-list index)
+ :with operator = (first frame)
+ :with values = (rest frame)
+ :with arglist = (if (and operator (consp values) (not (null
values)))
+ (handler-case (match-lambda operator values)
+ (jvm::lambda-list-mismatch (e)
(declare(ignore e))
+ :lambda-list-mismatch))
+ :not-available)
+ :for value :in values
+ :for id from 0
+ :collecting (list
+ :name (if (not (keywordp arglist)) ;; FIXME: WHat
does this do?
+ (format nil "arg-~a" (first (nth id
arglist)))
+ (format nil "arg~A" id))
+ :id 0 ;; FIXME: determine how is :ID supposed to be
used
+ :value value))))
+ (append frame-arguments frame-locals))))
+#+abcl-introspect
(defimplementation frame-var-value (index id)
- (elt (rest (jcall "toLispList" (nth-frame index))) id))
+ (if (are-there-locals? (nth-frame index) index)
+ (third (nth id (reverse (remove :lexical-variable
+ (caar (abcl-introspect/sys:find-locals
index (backtrace 0 (1+ index))))
+ :test-not 'eq :key 'car))))
+ (elt (rest (jcall "toLispList" (nth-frame index))) id)))
#+abcl-introspect
(defimplementation disassemble-frame (index)
@@ -1130,6 +1181,26 @@
(jcall "printStackTrace" (java:java-exception-cause o)
(jnew "java.io.PrintWriter" w))
(jcall "toString" w)))))
+
+
+(defmethod emacs-inspect ((o system::environment))
+ (let ((parts (sys::environment-parts o)))
+ (let ((lexicals (mapcar 'cdr (remove :lexical-variable parts :test-not 'eq
:key 'car)))
+ (specials (mapcar 'cdr (remove :special parts :test-not 'eq :key
'car)))
+ (functions (mapcar 'cdr (remove :lexical-function parts :test-not 'eq
:key 'car))))
+ `(,@(if lexicals
+ (list* '(:label "Lexicals:") '(:newline)
+ (loop for (var value) in lexicals
+ append `(" " (:label ,(format nil "~s" var)) ": "
(:value ,value) (:newline)))))
+ ,@(if functions
+ (list* '(:label "Functions:") '(:newline)
+ (loop for (var value) in functions
+ append `(" "(:label ,(format nil "~s" var)) ": "
(:value ,value) (:newline)))))
+ ,@(if specials
+ (list* '(:label "Specials:") '(:newline)
+ (loop for (var value) in specials
+ append `(" " (:label ,(format nil "~s" var)) ": "
(:value ,value) (:newline)))))))))
+
(defmethod emacs-inspect ((slot mop::slot-definition))
`("Name: "
(:value ,(mop:slot-definition-name slot))
- [nongnu] elpa/slime 2080537746 04/43: Require `xref` as regular dependancy, (continued)
- [nongnu] elpa/slime 2080537746 04/43: Require `xref` as regular dependancy, ELPA Syncer, 2023/12/28
- [nongnu] elpa/slime a4f3471487 42/43: 2.2.8, ELPA Syncer, 2023/12/28
- [nongnu] elpa/slime 1ee576a53f 40/43: slime: slime-print-apropos use buttons for dispay, ELPA Syncer, 2023/12/28
- [nongnu] elpa/slime 3837255e0c 17/43: sbcl: Use file-write-date instead of debug-source-created, ELPA Syncer, 2023/12/28
- [nongnu] elpa/slime c5342a3086 14/43: Properly comment out multiline error messages during printout, ELPA Syncer, 2023/12/28
- [nongnu] elpa/slime 7e08d61fad 31/43: swank-asdf: Fix slime-load-system for systems with dots in the name, ELPA Syncer, 2023/12/28
- [nongnu] elpa/slime 4d540c8fc9 38/43: slime-cl-indent: fix lambda list indentation for single arg keywords, ELPA Syncer, 2023/12/28
- [nongnu] elpa/slime def8408e12 29/43: sexp-ref: accept dotted lists., ELPA Syncer, 2023/12/28
- [nongnu] elpa/slime 9d3d303333 24/43: clasp: Translate logical pathnames in source references, ELPA Syncer, 2023/12/28
- [nongnu] elpa/slime 485aa0ca17 16/43: extract-package, readtable-for-package: Use default readtable, ELPA Syncer, 2023/12/28
- [nongnu] elpa/slime 34b7e43530 09/43: abcl: implement inspection of locals in interpreted frames,
ELPA Syncer <=
- [nongnu] elpa/slime 6ef28864d4 13/43: Handle null characters correctly in the Allegro backend., ELPA Syncer, 2023/12/28
- [nongnu] elpa/slime 649abf2c19 23/43: compute-enriched-decoded-arglist sb-assem:inst: catch NIL., ELPA Syncer, 2023/12/28
- [nongnu] elpa/slime 0a77a989fd 20/43: Fix extract-local-op-arglists for labels., ELPA Syncer, 2023/12/28
- [nongnu] elpa/slime 1f9a95f3a0 18/43: Revert "sbcl: Use file-write-date instead of debug-source-created", ELPA Syncer, 2023/12/28
- [nongnu] elpa/slime 32f5652d6a 15/43: sbcl: Improve inspection of functions and code components., ELPA Syncer, 2023/12/28
- [nongnu] elpa/slime 906900bf05 12/43: Fix #714, ELPA Syncer, 2023/12/28
- [nongnu] elpa/slime 4cc03df108 30/43: Make xref optional., ELPA Syncer, 2023/12/28