Skip to content

Commit

Permalink
(find-top-frame): New function used to hide debugger internal frames.
Browse files Browse the repository at this point in the history
(call-with-debugging-environment): Use it.
  • Loading branch information
Helmut Eller committed May 1, 2004
1 parent a8fad51 commit f18968b
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions swank-lispworks.lisp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -178,15 +178,6 @@ Return NIL if the symbol is unbound."


(defvar *sldb-top-frame*) (defvar *sldb-top-frame*)


(defimplementation call-with-debugging-environment (fn)
(dbg::with-debugger-stack ()
(let ((*sldb-top-frame*
(dbg::frame-next
(dbg::frame-next
(dbg::frame-next
(dbg::debugger-stack-current-frame dbg::*debugger-stack*))))))
(funcall fn))))

(defun interesting-frame-p (frame) (defun interesting-frame-p (frame)
(cond ((or (dbg::call-frame-p frame) (cond ((or (dbg::call-frame-p frame)
(dbg::derived-call-frame-p frame) (dbg::derived-call-frame-p frame)
Expand All @@ -200,12 +191,30 @@ Return NIL if the symbol is unbound."
((dbg::open-frame-p frame) dbg:*print-open-frames*) ((dbg::open-frame-p frame) dbg:*print-open-frames*)
(t nil))) (t nil)))


(defun nth-frame (index) (defun nth-next-frame (frame n)
(do ((frame *sldb-top-frame* (dbg::frame-next frame)) "Unwind FRAME N times."
(i index (if (interesting-frame-p frame) (1- i) i))) (do ((frame frame (dbg::frame-next frame))
(i n (if (interesting-frame-p frame) (1- i) i)))
((and (interesting-frame-p frame) (zerop i)) frame) ((and (interesting-frame-p frame) (zerop i)) frame)
(assert frame))) (assert frame)))


(defun nth-frame (index)
(nth-next-frame *sldb-top-frame* index))

(defun find-top-frame ()
"Return the most suitable top-frame for the debugger."
(do ((frame (dbg::debugger-stack-current-frame dbg::*debugger-stack*)
(nth-next-frame frame 1)))
((and (dbg::call-frame-p frame)
(eq (dbg::call-frame-function-name frame)
'invoke-debugger))
(nth-next-frame frame 1))))

(defimplementation call-with-debugging-environment (fn)
(dbg::with-debugger-stack ()
(let ((*sldb-top-frame* (find-top-frame)))
(funcall fn))))

(defimplementation compute-backtrace (start end) (defimplementation compute-backtrace (start end)
(let ((end (or end most-positive-fixnum)) (let ((end (or end most-positive-fixnum))
(backtrace '())) (backtrace '()))
Expand Down

0 comments on commit f18968b

Please sign in to comment.