Changeset 6628
- Timestamp:
- May 29, 2007, 5:37:50 AM (18 years ago)
- File:
-
- 1 edited
-
branches/ide-1.0/ccl/lib/backtrace.lisp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/ide-1.0/ccl/lib/backtrace.lisp
r6618 r6628 61 61 (terpri) 62 62 (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))))) 63 83 64 84 … … 119 139 pc) 120 140 (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)))))))))) 122 144 123 145 … … 179 201 (match-local-name cellno (function-symbol-map lfun) pc)))))))) 180 202 181 (defun argument-value (context cfp lfun pc name )203 (defun argument-value (context cfp lfun pc name &optional (quote t)) 182 204 (declare (fixnum pc)) 183 205 (let* ((info (function-symbol-map lfun)) … … 206 228 (if (typep value 'value-cell) 207 229 (setq value (uvref value 0))) 208 (if ( self-evaluating-p value)230 (if (or (not quote) (self-evaluating-p value)) 209 231 (return value) 210 232 (return (list 'quote value)))))))))) … … 310 332 311 333 (defun variables-in-scope (lfun pc) 312 (declare (fixnum pc))313 334 ;; Return a list of all symbol names "in scope" in the function lfun 314 335 ;; at relative program counter PC, using the function's symbol map. 315 336 ;; 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 328 380 329 381 (defun safe-cell-value (val) … … 348 400 349 401 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 351 419 352 420
Note:
See TracChangeset
for help on using the changeset viewer.
