1 ;;;; single stepper for SBCL
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
12 ;;;; Single stepping works by having compiler insert STEP-CONDITION
13 ;;;; signalling forms into code compiled at high debug settings, and
14 ;;;; having a handler for them at the toplevel.
16 (in-package "SB!IMPL")
18 ;; Used for controlling whether the stepper is enabled / disabled when
19 ;; building without SB-THREAD. With SB-THREAD, a slot in the thread
20 ;; structure is used instead. (See EMIT-SINGLE-STEP-TEST in
21 ;; src/compiler/x86/call.lisp).
23 (defvar *stepping
* nil
)
25 ;; Used for implementing the STEP-OUT restart. The step-wrapper will
26 ;; bind this to :MAYBE, before calling the wrapped code. When
27 ;; unwinding, the wrapper will check whether it's been set to T. If
28 ;; so, it'll re-enable the stepper. This is a tri-state variable (NIL,
29 ;; :MAYBE, T) so that the debugger can detect in advance whether the
30 ;; OUT debugger command will actually have a wrapper to step out to.
31 (defvar *step-out
* nil
)
33 (symbol-macrolet ((place
34 #!+sb-thread
(sb!thread
::thread-stepping
)
35 #!-sb-thread
*stepping
*))
36 (defun (setf stepping
) (new-value)
37 (setf place new-value
))
38 (defun stepping-enabled-p ()
41 (defun enable-stepping ()
43 (defun disable-stepping ()
44 (setf (stepping) nil
))
47 (defmacro with-stepping-enabled
(&body body
)
48 (let ((orig (gensym)))
49 `(let ((,orig
(stepping-enabled-p)))
54 (setf (stepping) ,orig
)))))
56 (defmacro with-stepping-disabled
(&body body
)
57 (let ((orig (gensym)))
58 `(let ((,orig
(stepping-enabled-p)))
63 (setf (stepping) ,orig
)))))