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)
11 sb-debug::*debug-command-level sb-debug::*debug-command-level*
12 sb-debug::*real-stack-top* sb-debug::*stack-top*
13 sb-debug::*stack-top-hint* sb-debug::*current-frame*
14 sb-debug::*flush-debug-errors*))
17 (let* ((sb-debug::*debug-command-level* (1+ sb-debug::*debug-command-level*))
18 (sb-debug::*real-stack-top* (sb-di:top-frame))
19 (sb-debug::*stack-top* (or sb-debug::*stack-top-hint*
20 sb-debug::*real-stack-top*))
21 (sb-debug::*stack-top-hint* nil)
22 (sb-debug::*current-frame* sb-debug::*stack-top*)
23 (continuable (continuable-break-p)))
24 (handler-bind ((sb-di:debug-condition
26 (princ condition sb-debug::*debug-io*)
27 (sb-int:/show0 "handling d-c by THROWing DEBUG-LOOP-CATCHER")
28 (throw 'debug-loop-catcher nil))))
30 ;;(sb-debug::print-frame-call sb-debug::*current-frame* :verbosity 2)
31 (loop ;; only valid to way to exit invoke-debugger is by a restart
32 (catch 'debug-loop-catcher
33 (handler-bind ((error (lambda (condition)
34 (when sb-debug::*flush-debug-errors*
35 (clear-input *debug-io*)
37 ;; FIXME: Doing input on *DEBUG-IO*
38 ;; and output on T seems broken.
40 "~&error flushed (because ~
42 'sb-debug::*flush-debug-errors*)
43 (sb-int:/show0 "throwing DEBUG-LOOP-CATCHER")
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)