Diff of /src/code/debug.lisp [0ace89] .. [5d4902] Maximize Restore

  Switch to side-by-side view

--- a/src/code/debug.lisp
+++ b/src/code/debug.lisp
@@ -650,6 +650,9 @@
       (let ((*debugger-hook* nil))
 	(funcall old-hook condition old-hook))))
 
+  ;; If we're a background thread and *background-threads-wait-for-debugger*
+  ;; is NIL, this will invoke a restart
+
   ;; Note: CMU CL had (SB-UNIX:UNIX-SIGSETMASK 0) here. I deleted it
   ;; around sbcl-0.7.8.5 (by which time it had mutated to have a
   ;; #!-SUNOS prefix and a FIXME note observing that it wasn't needed
@@ -703,6 +706,7 @@
 	   (*readtable* *debug-readtable*)
 	   (*print-readably* nil)
 	   (*package* original-package)
+	   (background-p nil)
 	   (*print-pretty* original-print-pretty))
 
        ;; Before we start our own output, finish any pending output.
@@ -747,33 +751,38 @@
        ;; older debugger code which was written to do i/o on whatever
        ;; stream was in fashion at the time, and not all of it has
        ;; been converted to behave this way. -- WHN 2000-11-16)
-       (let (;; FIXME: Rebinding *STANDARD-OUTPUT* here seems wrong,
-	     ;; violating the principle of least surprise, and making
-	     ;; it impossible for the user to do reasonable things
-	     ;; like using PRINT at the debugger prompt to send output
-	     ;; to the program's ordinary (possibly
-	     ;; redirected-to-a-file) *STANDARD-OUTPUT*. (CMU CL
-	     ;; used to rebind *STANDARD-INPUT* here too, but that's
-	     ;; been fixed already.)
-	     (*standard-output* *debug-io*)
-	     ;; This seems reasonable: e.g. if the user has redirected
-	     ;; *ERROR-OUTPUT* to some log file, it's probably wrong
-	     ;; to send errors which occur in interactive debugging to
-	     ;; that file, and right to send them to *DEBUG-IO*.
-	     (*error-output* *debug-io*))
-	 (unless (typep condition 'step-condition)
-	   (when *debug-beginner-help-p*
-	     (format *debug-io*
-		     "~%~@<Within the debugger, you can type HELP for help. ~
+
+       (setf background-p
+	     (sb!thread::debugger-wait-until-foreground-thread *debug-io*))
+       (unwind-protect
+	    (let (;; FIXME: Rebinding *STANDARD-OUTPUT* here seems wrong,
+		  ;; violating the principle of least surprise, and making
+		  ;; it impossible for the user to do reasonable things
+		  ;; like using PRINT at the debugger prompt to send output
+		  ;; to the program's ordinary (possibly
+		  ;; redirected-to-a-file) *STANDARD-OUTPUT*. (CMU CL
+		  ;; used to rebind *STANDARD-INPUT* here too, but that's
+		  ;; been fixed already.)
+		  (*standard-output* *debug-io*)
+		  ;; This seems reasonable: e.g. if the user has redirected
+		  ;; *ERROR-OUTPUT* to some log file, it's probably wrong
+		  ;; to send errors which occur in interactive debugging to
+		  ;; that file, and right to send them to *DEBUG-IO*.
+		  (*error-output* *debug-io*))
+	      (unless (typep condition 'step-condition)
+		(when *debug-beginner-help-p*
+		  (format *debug-io*
+			  "~%~@<Within the debugger, you can type HELP for help. ~
                       At any command prompt (within the debugger or not) you ~
                       can type (SB-EXT:QUIT) to terminate the SBCL ~
                       executable. The condition which caused the debugger to ~
                       be entered is bound to ~S. You can suppress this ~
                       message by clearing ~S.~:@>~2%"
-		     '*debug-condition*
-		     '*debug-beginner-help-p*))
-	   (show-restarts *debug-restarts* *debug-io*))
-	 (internal-debug))))))
+			  '*debug-condition*
+			  '*debug-beginner-help-p*))
+		(show-restarts *debug-restarts* *debug-io*))
+	      (internal-debug))
+	 (when background-p (sb!thread::release-foreground)))))))
 
 (defun show-restarts (restarts s)
   (cond ((null restarts)