From: Nikodemus Siivola Date: Thu, 10 Mar 2005 23:26:06 +0000 (+0000) Subject: 0.8.20.15: remove TOPLEVEL restart X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=64f013aaf9d09edb2d82cb7eed6cb098bbbc169a;p=sbcl.git 0.8.20.15: remove TOPLEVEL restart * add TOPLEVEL/TOP debugger command for convenience, making it return to the top level. * use the gained screen real-estate to insert an empty line between restarts and the first frame. --- diff --git a/NEWS b/NEWS index 5bd50ee..2fdd5c5 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,8 @@ changes in sbcl-0.8.21 (0.9alpha.1?) relative to sbcl-0.8.20: + * incompatible change: the top level REPL now has only an ABORT + restart associated with it, not TOPLEVEL and ABORT as it used to. + TOP and TOPLEVEL are now available as debugger commands for + returning to the top level. * incompatible change: forms evaluated in the REPL now use the global optimization policy. * incompatible change: user- and system-initialization files are diff --git a/package-data-list.lisp-expr b/package-data-list.lisp-expr index bdc54bf..49b56e7 100644 --- a/package-data-list.lisp-expr +++ b/package-data-list.lisp-expr @@ -1040,6 +1040,9 @@ retained, possibly temporariliy, because it might be used internally." "COLD-FSET" "!DEFUN-FROM-COLLECTED-COLD-INIT-FORMS" + ;; catch tags + "TOPLEVEL-CATCHER" + ;; hooks for contrib/ stuff we're insufficiently sure ;; about to add to SB!EXT "*REPL-PROMPT-FUN*" diff --git a/src/code/debug.lisp b/src/code/debug.lisp index 62a2d71..b20dc7e 100644 --- a/src/code/debug.lisp +++ b/src/code/debug.lisp @@ -101,11 +101,13 @@ SB-DEBUG:*FLUSH-DEBUG-ERRORS* controls whether errors at the debug prompt to debugger. Getting in and out of the debugger: - RESTART invokes restart numbered as shown (prompt if not given). - ERROR prints the error condition and restart cases. + TOPLEVEL, TOP exits debugger and returns to top level REPL + RESTART invokes restart numbered as shown (prompt if not given). + ERROR prints the error condition and restart cases. + The number of any restart, or its name, or a unique abbreviation for its - name, is a valid command, and is the same as using RESTART to invoke - that restart. + name, is a valid command, and is the same as using RESTART to invoke + that restart. Changing frames: UP up frame DOWN down frame @@ -560,7 +562,7 @@ reset to ~S." (unless (typep condition 'step-condition) (when *debug-beginner-help-p* (format *debug-io* - "~%~@~2%")) (show-restarts *debug-restarts* *debug-io*)) (internal-debug)) @@ -661,6 +663,10 @@ reset to ~S." (incf max-name-len 3)) (dolist (restart restarts) (let ((name (restart-name restart))) + ;; FIXME: maybe it would be better to display later names + ;; in parens instead of brakets, not just omit them fully. + ;; Call BREAK, call BREAK in the debugger, and tell me + ;; it's not confusing looking. --NS 20050310 (cond ((member name names-used) (format s "~& ~2D: ~V@T~A~%" count max-name-len restart)) (t @@ -705,7 +711,7 @@ reset to ~S." (princ condition *debug-io*) (/show0 "handling d-c by THROWing DEBUG-LOOP-CATCHER") (throw 'debug-loop-catcher nil)))) - (fresh-line *debug-io*) + (terpri *debug-io*) (print-frame-call *current-frame* *debug-io* :verbosity 2) (loop (catch 'debug-loop-catcher @@ -1027,16 +1033,6 @@ reset to ~S." (!def-debug-command-alias "D" "DOWN") -;;; CMU CL had this command, but SBCL doesn't, since it's redundant -;;; with "FRAME 0", and it interferes with abbreviations for the -;;; TOPLEVEL restart. -;;;(!def-debug-command "TOP" () -;;; (do ((prev *current-frame* lead) -;;; (lead (sb!di:frame-up *current-frame*) (sb!di:frame-up lead))) -;;; ((null lead) -;;; (setf *current-frame* prev) -;;; (print-frame-call prev *debug-io*)))) - (!def-debug-command "BOTTOM" () (do ((prev *current-frame* lead) (lead (sb!di:frame-down *current-frame*) (sb!di:frame-down lead))) @@ -1070,21 +1066,11 @@ reset to ~S." ;;;; commands for entering and leaving the debugger -;;; CMU CL supported this QUIT debug command, but SBCL provides this -;;; functionality with a restart instead. (The QUIT debug command was -;;; removed because it's confusing to have "quit" mean two different -;;; things in the system, "restart the top level REPL" in the debugger -;;; and "terminate the Lisp system" as the SB-EXT:QUIT function.) -;;; -;;;(!def-debug-command "QUIT" () -;;; (throw 'sb!impl::toplevel-catcher nil)) - -;;; CMU CL supported this GO debug command, but SBCL doesn't -- in -;;; SBCL you just type the CONTINUE restart name instead (or "C" or -;;; "RESTART CONTINUE", that's OK too). -;;;(!def-debug-command "GO" () -;;; (continue *debug-condition*) -;;; (error "There is no restart named CONTINUE.")) +(!def-debug-command "TOPLEVEL" () + (throw 'toplevel-catcher nil)) + +;;; make T safe +(!def-debug-command-alias "TOP" "TOPLEVEL") (!def-debug-command "RESTART" () (/show0 "doing RESTART debug-command") diff --git a/src/code/error-error.lisp b/src/code/error-error.lisp index 5a0873a..992b13e 100644 --- a/src/code/error-error.lisp +++ b/src/code/error-error.lisp @@ -23,7 +23,7 @@ (/show0 "*ERROR-THROW-UP-COUNT* too big, trying HALT") (%primitive sb!c:halt) (/show0 "*ERROR-THROW-UP-COUNT* too big, trying THROW") - (throw 'sb!impl::toplevel-catcher nil)) + (throw 'toplevel-catcher nil)) (case *error-error-depth* (1) (2 @@ -31,12 +31,12 @@ (3 (incf *error-throw-up-count*) (/show0 "*ERROR-ERROR-DEPTH* too big, trying THROW") - (throw 'sb!impl::toplevel-catcher nil)) + (throw 'toplevel-catcher nil)) (t (/show0 "*ERROR-ERROR-DEPTH* too big, trying HALT") (%primitive sb!c:halt) (/show0 "*ERROR-ERROR-DEPTH* too big, trying THROW") - (throw 'sb!impl::toplevel-catcher nil))) + (throw 'toplevel-catcher nil))) (with-standard-io-syntax (let ((*print-readably* nil)) diff --git a/src/code/target-signal.lisp b/src/code/target-signal.lisp index 5a43e17..f0f98d7 100644 --- a/src/code/target-signal.lisp +++ b/src/code/target-signal.lisp @@ -116,7 +116,7 @@ (defun sigquit-handler (signal code context) (declare (ignore signal code context)) - (throw 'sb!impl::toplevel-catcher nil)) + (throw 'toplevel-catcher nil)) (defun sb!kernel:signal-cold-init-or-reinit () #!+sb-doc diff --git a/src/code/toplevel.lisp b/src/code/toplevel.lisp index c02f06d..b944db4 100644 --- a/src/code/toplevel.lisp +++ b/src/code/toplevel.lisp @@ -481,31 +481,34 @@ steppers to maintain contextual information.") (init-file-name (posix-getenv "HOME") ".sbclrc")))) - ;; We wrap all the pre-REPL user/system customized startup code - ;; in a restart. - ;; - ;; (Why not wrap everything, even the stuff above, in this - ;; restart? Errors above here are basically command line or - ;; Unix environment errors, e.g. a missing file or a typo on - ;; the Unix command line, and you don't need to get into Lisp - ;; to debug them, you should just start over and do it right - ;; at the Unix level. Errors below here are generally errors - ;; in user Lisp code, and it might be helpful to let the user - ;; reach the REPL in order to help figure out what's going - ;; on.) - (restart-case - (progn - (process-init-file sysinit-truename) - (process-init-file userinit-truename) - (process-eval-options (reverse reversed-evals))) - (toplevel () - :report "Skip to toplevel READ/EVAL/PRINT loop." - (/show0 "CONTINUEing from pre-REPL RESTART-CASE") - (values)) ; (no-op, just fall through) - (quit () - :report "Quit SBCL (calling #'QUIT, killing the process)." - (/show0 "falling through to QUIT from pre-REPL RESTART-CASE") - (quit)))) + ;; This CATCH is needed for the debugger command TOPLEVEL to + ;; work. + (catch 'toplevel-catcher + ;; We wrap all the pre-REPL user/system customized startup + ;; code in a restart. + ;; + ;; (Why not wrap everything, even the stuff above, in this + ;; restart? Errors above here are basically command line + ;; or Unix environment errors, e.g. a missing file or a + ;; typo on the Unix command line, and you don't need to + ;; get into Lisp to debug them, you should just start over + ;; and do it right at the Unix level. Errors below here + ;; are generally errors in user Lisp code, and it might be + ;; helpful to let the user reach the REPL in order to help + ;; figure out what's going on.) + (restart-case + (progn + (process-init-file sysinit-truename) + (process-init-file userinit-truename) + (process-eval-options (reverse reversed-evals))) + (abort () + :report "Skip to toplevel READ/EVAL/PRINT loop." + (/show0 "CONTINUEing from pre-REPL RESTART-CASE") + (values)) ; (no-op, just fall through) + (quit () + :report "Quit SBCL (calling #'QUIT, killing the process)." + (/show0 "falling through to QUIT from pre-REPL RESTART-CASE") + (quit))))) ;; one more time for good measure, in case we fell out of the ;; RESTART-CASE above before one of the flushes in the ordinary @@ -549,28 +552,13 @@ steppers to maintain contextual information.") (handler-bind ((step-condition 'invoke-stepper)) (let ((*stepping* nil) (*step* nil)) - ;; WITH-SIMPLE-RESTART doesn't actually restart its body as - ;; some (like WHN for an embarrassingly long time - ;; ca. 2001-12-07) might think, but instead drops control back - ;; out at the end. So when a TOPLEVEL or outermost-ABORT - ;; restart happens, we need this outer LOOP wrapper to grab - ;; control and start over again. (And it also wraps CATCH - ;; 'TOPLEVEL-CATCHER for similar reasons.) (loop (/show0 "about to set up restarts in TOPLEVEL-REPL") - ;; There should only be one TOPLEVEL restart, and it's here, - ;; so restarting at TOPLEVEL always bounces you all the way - ;; out here. - (with-simple-restart (toplevel - "Restart at toplevel READ/EVAL/PRINT loop.") - ;; We add a new ABORT restart for every debugger level, so - ;; restarting at ABORT in a nested debugger gets you out to - ;; the innermost enclosing debugger, and only when you're - ;; in the outermost, unnested debugger level does - ;; restarting at ABORT get you out to here. + ;; CLHS recommends that there should always be an + ;; ABORT restart; we have this one here, and one per + ;; debugger level. (with-simple-restart - (abort "~@") + (abort "~@") (catch 'toplevel-catcher (sb!unix::reset-signal-mask) ;; In the event of a control-stack-exhausted-error, we @@ -578,7 +566,7 @@ steppers to maintain contextual information.") ;; here that this is now possible. (sb!kernel::protect-control-stack-guard-page 1) (funcall repl-fun noprint) - (critically-unreachable "after REPL"))))))))))) + (critically-unreachable "after REPL")))))))))) ;;; Our default REPL prompt is the minimal traditional one. (defun repl-prompt-fun (stream) diff --git a/version.lisp-expr b/version.lisp-expr index d9b066b..96e1c15 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.8.20.14" +"0.8.20.15"