1 ;;;; Debugger for sb-aclrepl
3 ;;;; The documentation, which may or may not apply in its entirety at
4 ;;;; any given time, for this functionality is on the ACL website:
5 ;;;; <http://www.franz.com/support/documentation/6.2/doc/top-level.htm>.
7 (cl:in-package
:sb-aclrepl
)
9 ;;; FIXME: These declaims violate package locks. Are they needed at
13 sb-debug
::*debug-command-level
*
14 sb-debug
::*real-stack-top
* sb-debug
::*stack-top
*
15 sb-debug
::*stack-top-hint
* sb-debug
::*current-frame
*
16 sb-debug
::*flush-debug-errors
*))
19 (let* ((sb-debug::*debug-command-level
* (1+ sb-debug
::*debug-command-level
*))
20 (sb-debug::*real-stack-top
* (sb-di:top-frame
))
21 (sb-debug::*stack-top
* (or sb-debug
::*stack-top-hint
*
22 sb-debug
::*real-stack-top
*))
23 (sb-debug::*stack-top-hint
* nil
)
24 (sb-debug::*current-frame
* sb-debug
::*stack-top
*)
25 (continuable (continuable-break-p)))
26 (handler-bind ((sb-di:debug-condition
28 (princ condition sb-debug
::*debug-io
*)
29 (throw 'debug-loop-catcher nil
))))
31 ;;(sb-debug::print-frame-call sb-debug::*current-frame* :verbosity 2)
32 (loop ;; only valid to way to exit invoke-debugger is by a restart
33 (catch 'debug-loop-catcher
34 (handler-bind ((error (lambda (condition)
35 (when sb-debug
::*flush-debug-errors
*
36 (clear-input *debug-io
*)
38 ;; FIXME: Doing input on *DEBUG-IO*
39 ;; and output on T seems broken.
41 "~&error flushed (because ~
43 'sb-debug
::*flush-debug-errors
*)
44 (throw 'debug-loop-catcher nil
)))))
46 (if (zerop *break-level
*) ; restart added by SBCL
47 (repl :continuable continuable
)
48 (let ((level *break-level
*))
50 (abort "~@<Reduce debugger level (to break level ~W).~@:>"
52 (let ((sb-debug::*debug-restarts
* (compute-restarts)))
53 (repl :continuable continuable
)))))))
54 (throw 'repl-catcher
(values :debug
:exit
))
58 (defun continuable-break-p ()
60 (restart-name (car (compute-restarts))))
64 (when (boundp 'sb-debug
::*debug-loop-fun
*)
65 (setq sb-debug
::*debug-loop-fun
* #'debug-loop
))
67 (defun print-restarts ()
68 ;; (format *output* "~&Restart actions (select using :continue)~%")
69 (format *standard-output
* "~&Restart actions (select using :continue)~%")
70 (let ((restarts (compute-restarts)))
71 (dotimes (i (length restarts
))
72 (format *standard-output
* "~&~2D: ~A~%" i
(nth i restarts
)))))
76 (defun debugger (condition)
78 (let ((old-hook *debugger-hook
*))
80 (let ((*debugger-hook
* nil
))
81 (funcall old-hook condition old-hook
))))
82 (%debugger condition
))
85 (when (boundp 'sb-debug
::*invoke-debugger-fun
*)
86 (setq sb-debug
::*invoke-debugger-fun
* #'debugger
))
89 (defun print-condition (condition)
90 (format *output
* "~&Error: ~A~%" condition
))
93 (defun print-condition-type (condition)
94 (format *output
* "~& [Condition type: ~A]~%" (type-of condition
)))
97 (defun %debugger
(condition)
98 (print-condition condition
)
99 (print-condition-type condition
)
100 (princ #\newline
*output
*)
106 (defun acldebug-loop ()
107 (let ((continuable (continuable-break-p)))
109 (aclrepl :continuable t
)
110 (let ((level *break-level
*))
112 (abort "~@<Reduce debugger level (to debug level ~W).~@:>" level
)