From db97ea04895820f70c90bdeb0399aa0229410b5d Mon Sep 17 00:00:00 2001 From: Richard M Kreuter Date: Wed, 22 Apr 2009 18:51:21 +0000 Subject: [PATCH] 1.0.27.19: Restore variable access in debugger REPL. * Contributed by Alex Plotnick --- NEWS | 2 ++ package-data-list.lisp-expr | 2 +- src/code/debug-int.lisp | 9 +++++++++ src/code/debug.lisp | 14 +++++++++++++- src/code/toplevel.lisp | 4 ++-- version.lisp-expr | 2 +- 6 files changed, 28 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 92cdbf8..27172f6 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,8 @@ changes in sbcl-1.0.28 relative to 1.0.27: * minor incompatible changes: echo-streams now propagate unread-char to the underlying input stream, and no longer permit unreading more than one character. + * improvement: the debugger REPL can now reference lexical variables + by name directly for code compiled with (DEBUG 3). changes in sbcl-1.0.27 relative to 1.0.26: * new port: support added for x86-64 OpenBSD. (thanks to Josh Elsasser) diff --git a/package-data-list.lisp-expr b/package-data-list.lisp-expr index 5615e2b..45cde20 100644 --- a/package-data-list.lisp-expr +++ b/package-data-list.lisp-expr @@ -455,7 +455,7 @@ like *STACK-TOP-HINT* and unsupported stuff like *TRACED-FUN-LIST*." "INVALID-CONTROL-STACK-POINTER" "INVALID-VALUE" "LAMBDA-LIST-UNAVAILABLE" "MAKE-BREAKPOINT" "NO-DEBUG-BLOCKS" "NO-DEBUG-FUN-RETURNS" "NO-DEBUG-INFO" "PREPROCESS-FOR-EVAL" - "RETURN-FROM-FRAME" "SOURCE-PATH-CONTEXT" + "EVAL-IN-FRAME" "RETURN-FROM-FRAME" "SOURCE-PATH-CONTEXT" "TOP-FRAME" "UNHANDLED-DEBUG-CONDITION" "UNKNOWN-CODE-LOCATION" "UNKNOWN-CODE-LOCATION-P" "UNKNOWN-DEBUG-VAR" "CODE-LOCATION-KIND" "FLUSH-FRAMES-ABOVE")) diff --git a/src/code/debug-int.lisp b/src/code/debug-int.lisp index d003425..234bcbf 100644 --- a/src/code/debug-int.lisp +++ b/src/code/debug-int.lisp @@ -2565,6 +2565,15 @@ register." (debug-signal 'frame-fun-mismatch :code-location loc :form form :frame frame)) (funcall res frame)))))) + +;;; EVAL-IN-FRAME + +(defun eval-in-frame (frame form) + (declare (type frame frame)) + #!+sb-doc + "Evaluate FORM in the lexical context of FRAME's current code location, + returning the results of the evaluation." + (funcall (preprocess-for-eval form (frame-code-location frame)) frame)) ;;;; breakpoints diff --git a/src/code/debug.lisp b/src/code/debug.lisp index ecbf3e8..165a874 100644 --- a/src/code/debug.lisp +++ b/src/code/debug.lisp @@ -806,9 +806,21 @@ reset to ~S." (t (funcall cmd-fun)))))))))))) +(defvar *auto-eval-in-frame* t + #!+sb-doc + "When set (the default), evaluations in the debugger's command loop occur + relative to the current frame's environment without the need of debugger + forms that explicitly control this kind of evaluation.") + +(defun debug-eval (expr) + (if (and (fboundp 'compile) *auto-eval-in-frame*) + (sb!di:eval-in-frame *current-frame* expr) + (eval expr))) + (defun debug-eval-print (expr) (/noshow "entering DEBUG-EVAL-PRINT" expr) - (let ((values (multiple-value-list (interactive-eval expr)))) + (let ((values (multiple-value-list + (interactive-eval expr :eval #'debug-eval)))) (/noshow "done with EVAL in DEBUG-EVAL-PRINT") (dolist (value values) (fresh-line *debug-io*) diff --git a/src/code/toplevel.lisp b/src/code/toplevel.lisp index 95cd0ec..6071131 100644 --- a/src/code/toplevel.lisp +++ b/src/code/toplevel.lisp @@ -291,13 +291,13 @@ command-line.") (defvar +++ nil #!+sb-doc "the previous value of ++") (defvar - nil #!+sb-doc "the form currently being evaluated") -(defun interactive-eval (form) +(defun interactive-eval (form &key (eval #'eval)) #!+sb-doc "Evaluate FORM, returning whatever it returns and adjusting ***, **, *, +++, ++, +, ///, //, /, and -." (setf - form) (unwind-protect - (let ((results (multiple-value-list (eval form)))) + (let ((results (multiple-value-list (funcall eval form)))) (setf /// // // / / results diff --git a/version.lisp-expr b/version.lisp-expr index 2a4f2d0..da4f452 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".) -"1.0.27.18" +"1.0.27.19" -- 1.7.10.4