Changeset 15558
- Timestamp:
- 02/25/22 20:24:39 (2 years ago)
- Location:
- trunk/abcl/contrib/abcl-introspect
- Files:
-
- 1 added
- 2 edited
-
abcl-introspect.asd (modified) (1 diff)
-
abcl-introspect.lisp (modified) (11 diffs)
-
packages.lisp (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/contrib/abcl-introspect/abcl-introspect.asd
r15464 r15558 4 4 :description "Introspection on compiled function to aid source location and other debugging functions." 5 5 :long-description "<urn:abcl.org/release/1.8.0/contrib/abcl-introspect#>" 6 :version "2. 0.0"6 :version "2.1.0" 7 7 :depends-on (jss) 8 :components ((:file "abcl-introspect") 9 (:file "stacktrace") 10 (:file "util")) 8 :components ((:module package 9 :pathname #p"./" 10 :components ((:file "packages"))) 11 (:module source 12 :pathname #p"./" 13 :components ((:file "abcl-introspect") 14 (:file "stacktrace") 15 (:file "util")))) 11 16 :in-order-to ((test-op (test-op abcl-introspect-test)))) 12 17 -
trunk/abcl/contrib/abcl-introspect/abcl-introspect.lisp
r15555 r15558 130 130 (lambda(top internal) 131 131 (unless (eq (if (symbolp top) (symbol-function top) top) internal) 132 (setf (getf ( function-plist internal) :internal-to-function) (or definer top))132 (setf (getf (sys:function-plist internal) :internal-to-function) (or definer top)) 133 133 )) 134 134 nil … … 174 174 (fast-function (mop::std-method-fast-function method))) 175 175 (when (and method-function (compiled-function-p method-function)) 176 (setf (getf ( function-plist method-function) :method-function) method)176 (setf (getf (sys:function-plist method-function) :method-function) method) 177 177 (annotate-internal-functions (list method-function) method) 178 178 (index-function-class-names (list method-function))) 179 179 (when (and fast-function (compiled-function-p fast-function)) 180 (setf (getf ( function-plist fast-function) :method-fast-function) method)180 (setf (getf (sys:function-plist fast-function) :method-fast-function) method) 181 181 (annotate-internal-functions (list fast-function) method) 182 182 (index-function-class-names (list method-function)))))) … … 291 291 (eq (second internals) (intern "INVOKE-RESTARGS" :jss)) 292 292 (stringp (first internals)) 293 (setf (getf (sys: :function-plist f) :jss-function) (first internals)))))))293 (setf (getf (sys:function-plist f) :jss-function) (first internals))))))) 294 294 295 295 (defun local-function-p (function) … … 297 297 level based on function-plist annotations" 298 298 (and (and (functionp function) (not (typep function 'generic-function))) 299 (let ((plist (sys: :function-plist function)))299 (let ((plist (sys:function-plist function))) 300 300 (or (getf plist :internal-to-function) 301 301 (getf plist :method-function) … … 357 357 358 358 (defmethod mop::add-direct-method :after (class method) 359 (annotate-clos-methods (list method)) 360 ) 361 362 (defmethod mop::ensure-class-using-class :after (class name &key direct-slots 363 direct-default-initargs 364 &allow-other-keys) 359 (annotate-clos-methods (list method))) 360 361 (defmethod mop::ensure-class-using-class :after (class name 362 &key direct-slots 363 direct-default-initargs 364 &allow-other-keys) 365 (declare (ignore direct-slots direct-default-initargs)) 365 366 (annotate-clos-slots (mop::class-direct-slots (find-class name)))) 366 367 … … 371 372 ;; where kind is either :lexical-variable or :lexical-function :special-variable 372 373 373 (defun environment-parts (env)374 (defun environment-parts (env) 374 375 (append 375 376 (loop for binding = (jss:get-java-field env "vars" t) then (jss:get-java-field binding "next" t) … … 439 440 ;; through the iterator, when some other function call is made. 440 441 441 (defun stack-to-list (stack) 442 (coerce (#"toArray" stack) 'list))442 ;; BEGIN use :abcl-introspect/system 443 (in-package :abcl-introspect/system) 443 444 444 445 (defun collapse-locals (thread) 445 (loop for bindings in (mapcar 'sys::environment-parts 446 (stack-to-list (jss:get-java-field thread "envStack" t))) 447 with last-locals 448 with last-function 449 for binding = (car bindings) 450 if (eq (second binding) nil) 451 collect (prog1 452 (list last-function last-locals) 453 (setq last-locals nil) 454 (setq last-function (third binding))) 455 else 456 do (setq last-locals bindings))) 446 (flet ((stack-to-list (stack) 447 (coerce (#"toArray" stack) 'list))) 448 (loop for bindings in (mapcar 'sys::environment-parts 449 (stack-to-list (jss:get-java-field thread "envStack" t))) 450 with last-locals 451 with last-function 452 for binding = (car bindings) 453 if (eq (second binding) nil) 454 collect (prog1 455 (list last-function last-locals) 456 (setq last-locals nil) 457 (setq last-function (third binding))) 458 else 459 do (setq last-locals bindings)))) 457 460 458 461 ;; Now that we have the pairings of function-executing and lexicals we need … … 502 505 ;; find-locals still has debugging code in it which will be removed after 503 506 ;; there has been sufficient testing. 504 505 (defvar *debug-locals* nil) 507 ;;; ME: presumably *debugging-locals-p* can go away now? 508 (defvar *debugging-locals-p* nil 509 "Whether SYS:FIND-LOCALS should be looking for local variables") 506 510 507 511 (defun find-locals (index backtrace) 512 "Return local variable bindings at INDEX in BACKTRACE 513 514 Added by ABCL-INTROSPECT." 508 515 (let ((thread (jss:get-java-field (nth index backtrace) "thread" t))) 509 (and *debug -locals* (print `(:collapse ,thread ,index)))510 (let ((collapsed (collapse-locals thread)))511 (and *debug -locals* (map nil 'print collapsed))516 (and *debugging-locals-p* (print `(:collapse ,thread ,index))) 517 (let ((collapsed (collapse-locals thread))) 518 (and *debugging-locals-p* (map nil 'print collapsed)) 512 519 (let ((alignment 513 520 (loop for function-local-association in (reverse collapsed) 514 with backtrace = (map 'list (if *debug -locals* 'print 'identity) backtrace)521 with backtrace = (map 'list (if *debugging-locals-p* 'print 'identity) backtrace) 515 522 for pos = (position (car function-local-association) backtrace 516 523 :key (lambda(frame) … … 521 528 pos 522 529 (cdr function-local-association))))) 523 (and *debug -locals* (print :erase) (map nil 'print alignment))530 (and *debugging-locals-p* (print :erase) (map nil 'print alignment)) 524 531 ;; first erasure of out of order frames 525 532 (loop for (nil pos) in alignment … … 531 538 if (> pos2 pos) 532 539 do (setf (second pair) nil))) 533 (and *debug -locals* (print :align) (map nil 'print alignment))540 (and *debugging-locals-p* (print :align) (map nil 'print alignment)) 534 541 ;; second erasure of duplicate frame numbers 535 542 (loop for (nil pos) in alignment … … 541 548 if (eql pos2 pos) 542 549 do (setf (second pair) nil))) 543 (and *debug -locals* (map nil 'print alignment))544 (if *debug -locals*550 (and *debugging-locals-p* (map nil 'print alignment)) 551 (if *debugging-locals-p* 545 552 (print `(:find ,(cddr (find index alignment :key 'second :test 'eql))))) 546 553 ;; finally, look up the locals for the given frame index 547 554 (cddr (find index alignment :key 'second :test 'eql)))))) 548 555 ;; END use :abcl-introspect/system 556 (in-package :system) 549 557 550 558 ;; needs to be the last thing. Some interaction with the fasl loader
Note: See TracChangeset
for help on using the changeset viewer.