From: Gabor Melis Date: Mon, 1 Aug 2005 12:52:24 +0000 (+0000) Subject: 0.9.3.14: debugger streams X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=75ae7b7af9433418836b65cde48713ab5b8cd2fd;p=sbcl.git 0.9.3.14: debugger streams * flush all standard streams before prompting in the REPL and the debugger * prompt for restart goes to *debug-io* * disable-debugger, enable-debugger don't set *debug-io* anymore * run *invoke-debugger-hook* before *debugger-hook* => if the debugger is disabled then *debugger-hook* is not run * eof selects abort in the debugger --- diff --git a/CREDITS b/CREDITS index 1384e2f..d796c1c 100644 --- a/CREDITS +++ b/CREDITS @@ -4,7 +4,7 @@ appearance. Aware, like a fox crossing the water. Alert, like a general on the battlefield. Kind, like a hostess greeting her guests. - Simple, like uncarved blocks of wood. Opaque, like black + Simple, like uncarved blocks of wood. Opaque, like black pools in darkened caves. Who can tell the secrets of their hearts and minds? The answer exists only in the Tao. @@ -25,7 +25,7 @@ in CMU CL 18b, Lisp implementation for use in the CMU community. and CMU CL has been under continuous development since the early 1980's - (concurrent with the Common Lisp standardization effort.) + (concurrent with the Common Lisp standardization effort.) Apparently most of the CMU Common Lisp implementors moved on to work on the Gwydion environment for Dylan. @@ -154,7 +154,7 @@ The CMU CL seq.lisp code also gave credits for later work by Jim Muller and Bill Chiles. The modules system (code/module.lisp, containing REQUIRE, PROVIDE, -and friends, now deprecated by ANSI) was written by Jim Muller and +and friends, now deprecated by ANSI) was written by Jim Muller and rewritten by Bill Chiles. The CMU CL garbage collector was credited to "Christopher Hoover, @@ -176,7 +176,7 @@ code to pretty-print backquote expressions says that unparsing support was provided by Miles Bader. The CMU implementations of the Common Lisp query functions Y-OR-N-P -and YES-OR-NO-P were originally written by Walter van Roggen, and +and YES-OR-NO-P were originally written by Walter van Roggen, and updated and modified by Rob MacLachlan and Bill Chiles. The CMU CL sort functions (code/sort.lisp) were written by Jim Large, @@ -208,7 +208,7 @@ originally written by Robert MacLachlan: toplevel interface functions and drivers compiler/main.lisp Besides writing the compiler, and various other work mentioned elsewhere, -Robert MacLachlan was also credited with tuning the implementation of +Robert MacLachlan was also credited with tuning the implementation of streams for Unix files, and writing various floating point support code code/float-trap.lisp, floating point traps @@ -217,7 +217,7 @@ streams for Unix files, and writing code/time.lisp William Lott is also credited with writing or heavily maintaining some -parts of the CMU CL compiler. He was responsible for lifting +parts of the CMU CL compiler. He was responsible for lifting compiler/meta-vmdef.lisp out of compiler/vmdef.lisp, and also wrote various optimizations compiler/array-tran.lisp @@ -225,7 +225,7 @@ compiler/meta-vmdef.lisp out of compiler/vmdef.lisp, and also wrote compiler/seqtran.lisp (with some code adapted from an older seqtran written by Wholey and Fahlman) the separable compiler backend - compiler/backend.lisp + compiler/backend.lisp compiler/generic/utils.lisp the implementation of LOAD-TIME-VALUE compiler/ltv.lisp @@ -239,7 +239,7 @@ compiler/meta-vmdef.lisp out of compiler/vmdef.lisp, and also wrote compiler/generic/vm-typetran.lisp, FOO=type ops compiler/generic/objdef.lisp, FOO=object representation compiler/generic/primtype.lisp, FOO=primitive types -Also, Christopher Hoover and William Lott wrote compiler/generic/vm-macs.lisp +Also, Christopher Hoover and William Lott wrote compiler/generic/vm-macs.lisp to centralize information about machine-dependent macros and constants. Sean Hallgren is credited with most of the Alpha backend. Julian @@ -247,7 +247,7 @@ Dolby created the CMU CL Alpha/Linux port. Douglas Crosher added complex-float support. The original PPC backend was the work of Gary Byers. Some bug fixes -and other changes to update it for current CMUCL interfaces were made +and other changes to update it for current CMUCL interfaces were made by Eric Marsden and Douglas Crosher The CMU CL machine-independent disassembler (compiler/disassem.lisp) @@ -268,7 +268,7 @@ Bill Chiles also modified code/macros.lisp. Much of the implementation of PURIFY was rewritten in C by William Lott. The CMU CL number functions (code/number.lisp) were written by Rob -MacLachlan, but acknowledge much code "derived from code written by +MacLachlan, but acknowledge much code "derived from code written by William Lott, Dave Mcdonald, Jim Large, Scott Fahlman, etc." CMU CL's weak pointer support (code/weak.lisp) was written by @@ -304,7 +304,7 @@ Steven Handerson (based on Skef's idea), and that it was rewritten by William Lott to remove assumptions about length of fixnums on the MIPS port. -The comments in the main body of the CMU CL debugger +The comments in the main body of the CMU CL debugger code/debug.lisp say that it was written by Bill Chiles. Some other related files code/debug-int.lisp, programmer's interface to the debugger @@ -324,7 +324,7 @@ MacLachlan. Various CMU CL support code was written by William Lott: the bytecode interpreter - code/byte-interp.lisp + code/byte-interp.lisp bitblt-ish operations a la SYSTEM-AREA-COPY code/bit-bash.lisp Unix interface @@ -519,7 +519,7 @@ Daniel Barlow: contrib packages. Robert E. Brown: - He has reported various bugs and submitted several patches, + He has reported various bugs and submitted several patches, especially improving removing gratuitous efficiencies in the standard library. @@ -530,11 +530,11 @@ Cadabra, Inc. (later merged into GoTo.com): giving SBCL (and CMU CL) its EQUALP hash tables. Douglas Crosher: - He continued to improve CMU CL after SBCL forked from it, creating + He continued to improve CMU CL after SBCL forked from it, creating many patches which were directly applicable to SBCL. Notable examples include fixes for various compiler bugs, the implementation of CL:DEFINE-SYMBOL-MACRO, and a generalization of the type system's - handling of the CONS type to allow ANSI-style (CONS FOO BAR) types. + handling of the CONS type to allow ANSI-style (CONS FOO BAR) types. Alexey Dejneka: He fixed many, many bugs on various themes, and has done a @@ -603,14 +603,14 @@ David Lichteblau: structures with raw slots. Robert MacLachlan: - He has continued to answer questions about, and contribute fixes to, + He has continued to answer questions about, and contribute fixes to, the CMU CL project. Some of these fixes, especially for compiler problems, has been invaluable to the CMU CL project and, by porting, invaluable to the SBCL project as well. Pierre Mai: He has continued to work on CMU CL since the SBCL fork, and also - patched code to SBCL to enable dynamic loading of object files + patched code to SBCL to enable dynamic loading of object files under OpenBSD. He contributed to the port of SBCL to MacOS X, implementing the Lisp side of the PowerOpen ABI. @@ -627,7 +627,7 @@ Antonio Martinez-Shotton: Brian Mastenbrook: He contributed to and extensively maintained the port of SBCL to MacOS X. His contributions include overcoming binary compatibility - issues between different versions of dlcompat on Darwin, other + issues between different versions of dlcompat on Darwin, other linker fixes, and signal handler bugfixes. Dave McDonald: @@ -653,7 +653,7 @@ Timothy Moore: William ("Bill") Newman: He continued to maintain SBCL after the fork, increasing ANSI compliance, fixing bugs, regularizing the internals of the - system, deleting unused extensions, improving performance in + system, deleting unused extensions, improving performance in some areas (especially sequence functions and non-simple vectors), updating documentation, and even, for better or worse, getting rid of various functionality (e.g. the byte interpreter). @@ -701,7 +701,7 @@ Julian Squires: Nikodemus Siivola: He provided build fixes, in particular to tame the SunOS toolchain, implemented package locks, ported the linkage-table code from CMUCL, - reimplemented STEP, and has fixed many (stream-related and other) bugs + reimplemented STEP, and has fixed many (stream-related and other) bugs besides. Juho Snellman: @@ -767,3 +767,4 @@ THS Thiemo Seufer NS Nikodemus Siivola PVE Peter Van Eynde PW Paul Werkowski +MG Gabor Melis diff --git a/NEWS b/NEWS index c9c175d..cae99e3 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,12 @@ changes in sbcl-0.9.4 relative to sbcl-0.9.3: by Bruno Haible) * optimizations: REMOVE-DUPLICATES now runs in linear time on lists in some cases. This partially fixes bug 384. + * flush all standard streams before prompting in the REPL and the + debugger + * eof selects abort in the debugger + * minor incompatible change: *INVOKE-DEBUGGER-HOOK* is run before + *DEBUGGER-HOOK* => *DEBUGGER-HOOK* is not run when the debugger + is disabled changes in sbcl-0.9.3 relative to sbcl-0.9.2: * New feature: Experimental support for bivalent streams: streams diff --git a/doc/sbcl.1 b/doc/sbcl.1 index 29b5559..16f28bf 100644 --- a/doc/sbcl.1 +++ b/doc/sbcl.1 @@ -321,14 +321,12 @@ in trouble (by printing a debug prompt, then listening, on with no programmer available, and this option tries to set up more appropriate behavior for that situation. This is implemented by redefining INVOKE-DEBUGGER so that any call exits the process with a -failure code after printing a backtrace, and by redefining *DEBUG-IO* -to send its output to *ERROR-OUTPUT* and to raise an error if any -input is requested from it. (Note that because it is implemented by -modifying special variables and FDEFINITIONs, its effects persist in -.core files created by SB-EXT:SAVE-LISP-AND-DIE. If you want to undo -its effects, e.g. if you build a system unattended and then want to -operate a derived system interactively, see the SB-EXT:ENABLE-DEBUGGER -command.) +failure code after printing a backtrace. (Note that because it is +implemented by modifying special variables and FDEFINITIONs, its +effects persist in .core files created by SB-EXT:SAVE-LISP-AND-DIE. If +you want to undo its effects, e.g. if you build a system unattended +and then want to operate a derived system interactively, see the +SB-EXT:ENABLE-DEBUGGER command.) .PP Regardless of the order in which --sysinit, --userinit, and --eval diff --git a/src/code/debug.lisp b/src/code/debug.lisp index e47ac17..14f2525 100644 --- a/src/code/debug.lisp +++ b/src/code/debug.lisp @@ -471,28 +471,20 @@ is how many frames to show." (nreverse (mapcar #'cdr *debug-print-variable-alist*)) (apply fun rest))))))) -;;; the ordinary ANSI case of INVOKE-DEBUGGER, when not suppressed by -;;; command-line --disable-debugger option (defun invoke-debugger (condition) #!+sb-doc "Enter the debugger." - (let ((old-hook *debugger-hook*)) - (when old-hook - (let ((*debugger-hook* nil)) - (funcall old-hook condition old-hook)))) + ;; call *INVOKE-DEBUGGER-HOOK* first, so that *DEBUGGER-HOOK* is not + ;; called when the debugger is disabled (let ((old-hook *invoke-debugger-hook*)) (when old-hook (let ((*invoke-debugger-hook* nil)) (funcall old-hook condition old-hook)))) - - ;; Note: CMU CL had (SB-UNIX:UNIX-SIGSETMASK 0) here, to reset the - ;; signal state in the case that we wind up in the debugger as a - ;; result of something done by a signal handler. It's not - ;; altogether obvious that this is necessary, and indeed SBCL has - ;; not been doing it since 0.7.8.5. But nobody seems altogether - ;; convinced yet - ;; -- dan 2003.11.11, based on earlier comment of WHN 2002-09-28 + (let ((old-hook *debugger-hook*)) + (when old-hook + (let ((*debugger-hook* nil)) + (funcall old-hook condition old-hook)))) ;; We definitely want *PACKAGE* to be of valid type. ;; @@ -650,15 +642,15 @@ reset to ~S." ;;; noninteractive and interactive use respectively (defun disable-debugger () (when (eql *invoke-debugger-hook* nil) - (setf *debug-io* *error-output* - *invoke-debugger-hook* 'debugger-disabled-hook))) + ;; *DEBUG-IO* used to be set here to *ERROR-OUTPUT* which is sort + ;; of unexpected but mostly harmless, but then ENABLE-DEBUGGER had + ;; to set it to a suitable value again and be very careful, + ;; especially if the user has also set it. -- MG 2005-07-15 + (setf *invoke-debugger-hook* 'debugger-disabled-hook))) (defun enable-debugger () (when (eql *invoke-debugger-hook* 'debugger-disabled-hook) - (setf *debug-io* *query-io* - *invoke-debugger-hook* nil))) - -(setf *debug-io* *query-io*) + (setf *invoke-debugger-hook* nil))) (defun show-restarts (restarts s) (cond ((null restarts) @@ -718,6 +710,14 @@ reset to ~S." "When set, avoid calling INVOKE-DEBUGGER recursively when errors occur while executing in the debugger.") +(defun debug-read (stream) + (declare (type stream stream)) + (let* ((eof-marker (cons nil nil)) + (form (read stream nil eof-marker))) + (if (eq form eof-marker) + (abort) + form))) + (defun debug-loop-fun () (let* ((*debug-command-level* (1+ *debug-command-level*)) (*real-stack-top* (sb!di:top-frame)) @@ -732,38 +732,39 @@ reset to ~S." (terpri *debug-io*) (print-frame-call *current-frame* *debug-io* :verbosity 2) (loop - (catch 'debug-loop-catcher - (handler-bind ((error (lambda (condition) - (when *flush-debug-errors* - (clear-input *debug-io*) - (princ condition *debug-io*) - (format *debug-io* - "~&error flushed (because ~ + (catch 'debug-loop-catcher + (handler-bind ((error (lambda (condition) + (when *flush-debug-errors* + (clear-input *debug-io*) + (princ condition *debug-io*) + (format *debug-io* + "~&error flushed (because ~ ~S is set)" - '*flush-debug-errors*) - (/show0 "throwing DEBUG-LOOP-CATCHER") - (throw 'debug-loop-catcher nil))))) - ;; We have to bind LEVEL for the restart function created by - ;; WITH-SIMPLE-RESTART. - (let ((level *debug-command-level*) - (restart-commands (make-restart-commands))) - (with-simple-restart (abort - "~@" - level) - (debug-prompt *debug-io*) - (force-output *debug-io*) - (let* ((exp (read *debug-io*)) - (cmd-fun (debug-command-p exp restart-commands))) - (cond ((not cmd-fun) - (debug-eval-print exp)) - ((consp cmd-fun) - (format *debug-io* - "~&Your command, ~S, is ambiguous:~%" - exp) - (dolist (ele cmd-fun) - (format *debug-io* " ~A~%" ele))) - (t - (funcall cmd-fun)))))))))))) + '*flush-debug-errors*) + (/show0 "throwing DEBUG-LOOP-CATCHER") + (throw 'debug-loop-catcher nil))))) + ;; We have to bind LEVEL for the restart function created by + ;; WITH-SIMPLE-RESTART. + (let ((level *debug-command-level*) + (restart-commands (make-restart-commands))) + (flush-standard-output-streams) + (debug-prompt *debug-io*) + (force-output *debug-io*) + (let* ((exp (debug-read *debug-io*)) + (cmd-fun (debug-command-p exp restart-commands))) + (with-simple-restart (abort + "~@" + level) + (cond ((not cmd-fun) + (debug-eval-print exp)) + ((consp cmd-fun) + (format *debug-io* + "~&Your command, ~S, is ambiguous:~%" + exp) + (dolist (ele cmd-fun) + (format *debug-io* " ~A~%" ele))) + (t + (funcall cmd-fun)))))))))))) (defun debug-eval-print (expr) (/noshow "entering DEBUG-EVAL-PRINT" expr) @@ -1095,8 +1096,8 @@ reset to ~S." (let ((num (read-if-available :prompt))) (when (eq num :prompt) (show-restarts *debug-restarts* *debug-io*) - (write-string "restart: ") - (force-output) + (write-string "restart: " *debug-io*) + (force-output *debug-io*) (setf num (read *debug-io*))) (let ((restart (typecase num (unsigned-byte diff --git a/src/code/toplevel.lisp b/src/code/toplevel.lisp index 2dae8cb..bcf7a42 100644 --- a/src/code/toplevel.lisp +++ b/src/code/toplevel.lisp @@ -298,8 +298,10 @@ steppers to maintain contextual information.") *error-output* *query-io* *standard-output* - *trace-output*)) - (finish-output (symbol-value name))) + *trace-output* + *terminal-io*)) + ;; FINISH-OUTPUT may block more easily than FORCE-OUTPUT + (force-output (symbol-value name))) (values)) (defun process-init-file (truename) @@ -586,6 +588,7 @@ steppers to maintain contextual information.") (scrub-control-stack) (sb!thread::get-foreground) (unless noprint + (flush-standard-output-streams) (funcall *repl-prompt-fun* *standard-output*) ;; (Should *REPL-PROMPT-FUN* be responsible for doing its own ;; FORCE-OUTPUT? I can't imagine a valid reason for it not to