Remove #+-win32 from the run-program docstring.
[sbcl.git] / contrib / sb-aclrepl / debug.lisp
bloba746d112af4149cbf719fa93a0b9f8d963169fa1
1 ;;;; Debugger for sb-aclrepl
2 ;;;;
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
10 ;;; all? Seems not.
11 #+ignore
12 (declaim (special
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*))
18 (defun debug-loop ()
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
27 (lambda (condition)
28 (princ condition sb-debug::*debug-io*)
29 (throw 'debug-loop-catcher nil))))
30 (fresh-line)
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*)
37 (princ condition)
38 ;; FIXME: Doing input on *DEBUG-IO*
39 ;; and output on T seems broken.
40 (format t
41 "~&error flushed (because ~
42 ~S is set)"
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*))
49 (with-simple-restart
50 (abort "~@<Reduce debugger level (to break level ~W).~@:>"
51 level)
52 (let ((sb-debug::*debug-restarts* (compute-restarts)))
53 (repl :continuable continuable)))))))
54 (throw 'repl-catcher (values :debug :exit))
55 ))))
58 (defun continuable-break-p ()
59 (when (eq 'continue
60 (restart-name (car (compute-restarts))))
61 t))
63 #+ignore
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)))))
75 #+ignore
76 (defun debugger (condition)
77 "Enter the debugger."
78 (let ((old-hook *debugger-hook*))
79 (when old-hook
80 (let ((*debugger-hook* nil))
81 (funcall old-hook condition old-hook))))
82 (%debugger condition))
84 #+ignore
85 (when (boundp 'sb-debug::*invoke-debugger-fun*)
86 (setq sb-debug::*invoke-debugger-fun* #'debugger))
88 #+ignore
89 (defun print-condition (condition)
90 (format *output* "~&Error: ~A~%" condition))
92 #+ignore
93 (defun print-condition-type (condition)
94 (format *output* "~& [Condition type: ~A]~%" (type-of condition)))
96 #+ignore
97 (defun %debugger (condition)
98 (print-condition condition)
99 (print-condition-type condition)
100 (princ #\newline *output*)
101 (print-restarts)
102 (acldebug-loop))
105 #+ignore
106 (defun acldebug-loop ()
107 (let ((continuable (continuable-break-p)))
108 (if continuable
109 (aclrepl :continuable t)
110 (let ((level *break-level*))
111 (with-simple-restart
112 (abort "~@<Reduce debugger level (to debug level ~W).~@:>" level)
113 (loop
114 (repl)))))))