Changeset 6628


Ignore:
Timestamp:
May 29, 2007, 5:37:50 AM (18 years ago)
Author:
Gary Byers
Message:

print-call-history: show frame args and locals by default.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ide-1.0/ccl/lib/backtrace.lisp

    r6618 r6628  
    6161  (terpri)
    6262  (terpri))
     63
     64(defun %show-args-and-locals (p context lfun pc)
     65  (multiple-value-bind (args locals) (arguments-and-locals context p lfun pc)
     66    (format t "~&  ~s" (arglist-from-map lfun))
     67    (let* ((*print-length* *backtrace-print-length*)
     68           (*print-level* *backtrace-print-level*))
     69      (flet ((show-pair (pair prefix)
     70               (destructuring-bind (name . val) pair
     71                 (format t "~&~a~s: " prefix name)
     72                 (if (eq val (%unbound-marker))
     73                   (format t "#<Unavailabe>")
     74                   (format t "~s" val)))))
     75        (dolist (arg args)
     76          (show-pair arg "   "))
     77        (terpri)
     78        (terpri)
     79        (dolist (loc locals)
     80          (show-pair loc "  "))
     81        (terpri)
     82        (terpri)))))
    6383
    6484
     
    119139                      pc)
    120140              (when detailed-p
    121                 (%show-stack-frame p context lfun pc)))))))))
     141                (if (eq detailed-p :raw)
     142                  (%show-stack-frame p context lfun pc)
     143                  (%show-args-and-locals p context lfun pc))))))))))
    122144
    123145
     
    179201             (match-local-name cellno (function-symbol-map lfun) pc))))))))
    180202
    181 (defun argument-value (context cfp lfun pc name)
     203(defun argument-value (context cfp lfun pc name &optional (quote t))
    182204  (declare (fixnum pc))
    183205  (let* ((info (function-symbol-map lfun))
     
    206228              (if (typep value 'value-cell)
    207229                (setq value (uvref value 0)))
    208               (if (self-evaluating-p value)
     230              (if (or (not quote) (self-evaluating-p value))
    209231                (return value)
    210232                (return (list 'quote value))))))))))
     
    310332
    311333(defun variables-in-scope (lfun pc)
    312   (declare (fixnum pc))
    313334  ;; Return a list of all symbol names "in scope" in the function lfun
    314335  ;; at relative program counter PC, using the function's symbol map.
    315336  ;; The list will be ordered so that least-recent bindings appear first.
    316   (let* ((map (function-symbol-map lfun))
    317          (names (car map))
    318          (info (cdr map)))
    319     (when map
    320       (let* ((vars ()))
    321         (dotimes (i (length names) vars)
    322           (let* ((start-pc (aref info (1+ (* 3 i))))
    323                  (end-pc (aref info (+ 2 (* 3 i)))))
    324             (declare (fixnum start-pc end-pc))
    325             (when (and (>= pc start-pc)
    326                        (< pc end-pc))
    327               (push (svref names i) vars))))))))
     337  (when pc
     338    (locally (declare (fixnum pc))
     339      (let* ((map (function-symbol-map lfun))
     340             (names (car map))
     341             (info (cdr map)))
     342        (when map
     343          (let* ((vars ()))
     344            (dotimes (i (length names) vars)
     345              (let* ((start-pc (aref info (1+ (* 3 i))))
     346                     (end-pc (aref info (+ 2 (* 3 i)))))
     347                (declare (fixnum start-pc end-pc))
     348                (when (and (>= pc start-pc)
     349                           (< pc end-pc))
     350                  (push (svref names i) vars))))))))))
     351
     352(defun arguments-and-locals (context cfp lfun pc)
     353  (let* ((vars (variables-in-scope lfun pc)))
     354    (collect ((args)
     355              (locals))
     356    (multiple-value-bind (valid req opt rest keys)
     357        (arg-names-from-map lfun pc)
     358      (when valid
     359        (flet ((get-arg-value (name)
     360                 (let* ((avail (member name vars :test #'eq)))
     361                   (if avail
     362                     (setf (car (member name vars :test #'eq)) nil))
     363                   (args (cons name (argument-value context cfp lfun pc name nil)))))
     364               (get-local-value (name)
     365                 (when name
     366                   (locals (cons name (argument-value context cfp lfun pc name nil))))))
     367          (dolist (name req)
     368            (get-arg-value name))
     369          (dolist (name opt)
     370            (get-arg-value name))
     371          (when rest
     372            (get-arg-value rest))
     373          (dolist (name keys)
     374            (get-arg-value name))
     375          (dolist (name vars)
     376            (get-local-value name))))
     377      (values (args) (locals))))))
     378                   
     379           
    328380
    329381(defun safe-cell-value (val)
     
    348400
    349401     
    350 
     402;;; Find the oldest binding frame that binds the same symbol as
     403;;; FRAME in context.  If found, return the saved value of that
     404;;; binding, else the value of the symbol in the context's thread.
     405(defun oldest-binding-frame-value (context frame)
     406  (let* ((oldest nil)
     407         (binding-index (%fixnum-ref frame (ash 1 target::fixnum-shift))))
     408    (do* ((db (db-link context) (%fixnum-ref db 0)))
     409         ((eq frame db)
     410          (if oldest
     411            (%fixnum-ref oldest (ash 2 target::fixnum-shift))
     412            (let* ((symbol (binding-index-symbol binding-index)))
     413              (if context
     414                (symbol-value-in-tcr symbol (bt.tcr context))
     415                (%sym-value symbol)))))
     416      (if (eq (%fixnum-ref db (ash 1 target::fixnum-shift)) binding-index)
     417        (setq oldest db)))))
     418   
    351419
    352420
Note: See TracChangeset for help on using the changeset viewer.