|
672 | 672 | (values)))) |
673 | 673 |
|
674 | 674 |
|
675 | | -(defun control-debugger-hook (condition me-or-my-encapsulation) |
676 | | - (declare (ignore me-or-my-encapsulation)) |
677 | | - (cond ((typep condition 'warning) |
678 | | - (inform :warning "[~S] ~A~%" (type-of condition) condition) |
679 | | - (muffle-warning)) |
680 | | - (t |
681 | | - (inform :error "[~S] ~A~%" (type-of condition) condition) |
682 | | - (abort)))) |
683 | | - |
684 | | -(defun shell-debugger-hook (condition me-or-my-encapsulation) |
685 | | - (declare (ignore me-or-my-encapsulation)) |
686 | | - (cond ((typep condition 'warning) |
687 | | - (format *standard-output* "[~S] ~A~%" (type-of condition) condition) |
688 | | - (finish-output *standard-output*) |
689 | | - (muffle-warning)) |
690 | | - (t |
691 | | - (let ((env (dissect:capture-environment condition))) |
692 | | - (format *error-output* "[~S] ~A~%" (type-of condition) condition) |
693 | | - (finish-output *error-output*) |
694 | | - (throw 'debug-error |
695 | | - (make-eval-error condition (format nil "~A" condition) |
696 | | - (mapcar (lambda (frame) |
697 | | - (dissect:present frame nil)) |
698 | | - (dissect:environment-stack env)))))))) |
699 | | - |
700 | | -(defun debugger-type () |
701 | | - (cond ((or (not *enable-debugger*) |
702 | | - #+clasp (core:debugger-disabled-p) |
703 | | - #+sbcl (eq sb-ext:*invoke-debugger-hook* 'sb-debug::debugger-disabled-hook)) |
704 | | - :none) |
705 | | - #+abcl |
706 | | - (sys::*invoke-debugger-hook* :external) |
707 | | - #+allegro |
708 | | - (excl::*break-hook* :external) |
709 | | - #+ccl |
710 | | - (ccl:*break-hook* :external) |
711 | | - #+clisp |
712 | | - (sys::*break-driver* :external) |
713 | | - #+clasp |
714 | | - (ext:*invoke-debugger-hook* :external) |
715 | | - #+ecl |
716 | | - (ext:*invoke-debugger-hook* :external) |
717 | | - #+lispworks |
718 | | - (dbg::*debugger-wrapper-list* :external) |
719 | | - #+mezzano |
720 | | - (mezzano.debug:*global-debugger* :external) |
721 | | - #+sbcl |
722 | | - (sb-ext:*invoke-debugger-hook* :external) |
723 | | - (*enable-internal-debugger* :internal) |
724 | | - (t :none))) |
725 | | - |
726 | | -(defmacro with-debugger ((&key control internal) &body body) |
727 | | - (let ((debugger-hook (if control |
728 | | - 'control-debugger-hook |
729 | | - 'shell-debugger-hook))) |
730 | | - `(flet ((body-func () |
731 | | - (catch 'debug-error |
732 | | - (with-simple-restart |
733 | | - (abort "Exit debugger, returning to top level.") |
734 | | - ,@body)))) |
735 | | - (case (debugger-type) |
736 | | - (:external |
737 | | - (body-func)) |
738 | | - ,@(when internal |
739 | | - #+clasp |
740 | | - `((:internal |
741 | | - (catch sys::*quit-tag* |
742 | | - (body-func)))) |
743 | | - #-clasp |
744 | | - `((:internal |
745 | | - (body-func)))) |
746 | | - (otherwise |
747 | | - (let ((*debugger-hook* ',debugger-hook) |
748 | | - #+sbcl (sb-ext:*invoke-debugger-hook* ',debugger-hook) |
749 | | - #+ccl (ccl:*break-hook* ',debugger-hook) |
750 | | - #+ecl (ext:*invoke-debugger-hook* ',debugger-hook) |
751 | | - #+clasp (ext:*invoke-debugger-hook* ',debugger-hook) |
752 | | - #+abcl (sys::*invoke-debugger-hook* ',debugger-hook) |
753 | | - #+clisp (sys::*break-driver* (lambda (continuable &optional condition print) |
754 | | - (declare (ignore continuable print)) |
755 | | - (,debugger-hook condition nil))) |
756 | | - #+allegro (excl::*break-hook* (lambda (&rest args) |
757 | | - (,debugger-hook (fifth args)))) |
758 | | - #+lispworks (dbg::*debugger-wrapper-list* (lambda (function condition) |
759 | | - (declare (ignore function)) |
760 | | - (,debugger-hook condition nil))) |
761 | | - #+mezzano (mezzano.debug:*global-debugger* (lambda (condition) |
762 | | - (,debugger-hook condition nil)))) |
763 | | - (body-func))))))) |
764 | | - |
765 | 675 | (defun debug-enter-loop () |
766 | 676 | "Re-enter the debug loop after a restart which implements a debugger command." |
767 | 677 | (throw 'enter-loop t)) |
|
0 commit comments