Changeset 14367 for trunk/source/level-1


Ignore:
Timestamp:
Oct 15, 2010, 9:32:17 PM (9 years ago)
Author:
gb
Message:

Add NTH-FUNCTION-FRAME, which is like NTH-RAW-FRAME but only counts
stack frames that are FUNCTION-FRAME-P. (There's little or no difference
on x86; on PPC and ARM, the multiple-value return mechanism creates some
extra stack frames.)

Toplevel break loop commands that take a frame number use NTH-FUNCTION-FRAME,
so the frame numbers correspond to the numbers that backtrace prints. (They
always did on x86, seldom did on PPC/ARM.)

Lose the :set toplevel command, which used raw frame numbers and raw value
indices (neither of which we display in any other break loop commands.)

Location:
trunk/source/level-1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-1/l1-lisp-threads.lisp

    r14119 r14367  
    852852    (if (= i n)
    853853      (return p))))
     854
     855(defun nth-function-frame (n start-frame context)
     856  (declare (fixnum n))
     857  (do* ((p start-frame (parent-frame p context))
     858        (i -1)
     859        (q (last-frame-ptr context)))
     860       ((or (null p) (eq p q) (%stack< q p context)))
     861    (declare (fixnum i))
     862    (when (function-frame-p p context)
     863      (incf i)
     864      (if (= i n)
     865        (return p)))))
    854866
    855867;;; True if the object is in one of the heap areas
  • trunk/source/level-1/l1-readloop-lds.lisp

    r14351 r14367  
    102102(define-toplevel-command :break r () "list restarts" (list-restarts))
    103103
    104 (define-toplevel-command :break set (n frame value) "Set <n>th item of frame <frame> to <value>"
    105   (let* ((frame-sp (nth-raw-frame frame *break-frame* nil)))
    106     (if frame-sp
    107         (toplevel-print (list (set-nth-value-in-frame frame-sp n nil value)))
    108         (format *debug-io* "No frame with number ~D~%" frame))))
    109104
    110105(define-toplevel-command :break nframes ()
    111106  "print the number of stack frames accessible from this break loop"
    112107  (do* ((p *break-frame* (parent-frame p nil))
    113         (i 0 (1+ i))
     108        (i 0 )
    114109        (last (last-frame-ptr)))
    115       ((eql p last) (toplevel-print (list i)))))
     110      ((eql p last) (toplevel-print (list i)))
     111    (declare (fixnum i))
     112    (when (function-frame-p p nil)
     113      (incf i))))
    116114
    117115(define-toplevel-command :global ? () "help"
     
    149147
    150148(define-toplevel-command :break return-from-frame (i &rest values) "Return VALUES from the I'th stack frame"
    151   (let* ((frame-sp (nth-raw-frame  i *break-frame* nil)))
     149  (let* ((frame-sp (nth-function-frame  i *break-frame* nil)))
    152150    (if frame-sp
    153151      (apply #'return-from-frame frame-sp values))))
    154152
    155153(define-toplevel-command :break apply-in-frame (i function &rest args) "Applies FUNCTION to ARGS in the execution context of the Ith stack frame"
    156   (let* ((frame-sp (nth-raw-frame  i *break-frame* nil)))
     154  (let* ((frame-sp (nth-function-frame  i *break-frame* nil)))
    157155    (if frame-sp
    158156      (apply-in-frame frame-sp function args))))
     
    167165
    168166(define-toplevel-command :break v (n frame-number) "Return value <n> in frame <frame-number>"
    169   (let* ((frame-sp (nth-raw-frame frame-number *break-frame* nil)))
     167  (let* ((frame-sp (nth-function-frame frame-number *break-frame* nil)))
    170168    (if frame-sp
    171169      (toplevel-print (list (nth-value-in-frame frame-sp n nil))))))
    172170
    173171(define-toplevel-command :break arg (name frame-number) "Return value of argument named <name> in frame <frame-number>"
    174   (let* ((frame-sp (nth-raw-frame frame-number *break-frame* nil)))
     172  (let* ((frame-sp (nth-function-frame frame-number *break-frame* nil)))
    175173    (when frame-sp
    176174      (multiple-value-bind (lfun pc) (cfp-lfun frame-sp)
     
    184182
    185183(define-toplevel-command :break set-arg (name frame-number new) "Set value of argument named <name> in frame <frame-number> to value <new>."
    186   (let* ((frame-sp (nth-raw-frame frame-number *break-frame* nil)))
     184  (let* ((frame-sp (nth-function-frame frame-number *break-frame* nil)))
    187185    (when frame-sp
    188186      (multiple-value-bind (lfun pc) (cfp-lfun frame-sp)
     
    194192(define-toplevel-command :break local (name frame-number) "Return value of local denoted by <name> in frame <frame-number> <name> can either be a symbol - in which case the most recent
    195193binding of that symbol is used - or an integer index into the frame's set of local bindings."
    196   (let* ((frame-sp (nth-raw-frame frame-number *break-frame* nil)))
     194  (let* ((frame-sp (nth-function-frame frame-number *break-frame* nil)))
    197195    (when frame-sp
    198196      (multiple-value-bind (lfun pc) (cfp-lfun frame-sp)
     
    206204
    207205(define-toplevel-command :break set-local (name frame-number new) "Set value of argument denoted <name> (see :LOCAL) in frame <frame-number> to value <new>."
    208   (let* ((frame-sp (nth-raw-frame frame-number *break-frame* nil)))
     206  (let* ((frame-sp (nth-function-frame frame-number *break-frame* nil)))
    209207    (when frame-sp
    210208      (multiple-value-bind (lfun pc) (cfp-lfun frame-sp)
     
    225223(define-toplevel-command :break function (frame-number)
    226224  "Returns the function invoked in backtrace frame <frame-number>.  This may be useful for, e.g., disassembly"
    227   (let* ((cfp (nth-raw-frame frame-number *break-frame* nil)))
     225  (let* ((cfp (nth-function-frame frame-number *break-frame* nil)))
    228226    (when (and cfp (not (catch-csp-p cfp nil)))
    229227      (let* ((function (cfp-lfun cfp)))
Note: See TracChangeset for help on using the changeset viewer.