From 79900c9a288489b215340c1d337ffd91f2f92be5 Mon Sep 17 00:00:00 2001 From: Juho Snellman Date: Tue, 2 Jan 2007 21:11:56 +0000 Subject: [PATCH] 1.0.1.7: Display closed over variables in the debugger for code compiled with high debug settings. * Use :ENVIRONMENT TNs for all closure variables. * Allow the debug-info dumper to store debug information for variables that were not defined in the function whose debug information is being dumped. --- NEWS | 2 ++ src/compiler/debug-dump.lisp | 12 +++++------- src/compiler/life.lisp | 14 ++++++++++++++ version.lisp-expr | 2 +- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 0c8219f..c66e659 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ changes in sbcl-1.0.2 relative to sbcl-1.0.1: to use. * improvement: support for GBK external format. (thanks to Chun Tian (binghe)) + * improvement: the debugger now displays variables that have been closed + over, in code compiled with (DEBUG 2) or higher * bug fix: an error is signaled for attempts to use READ-SEQUENCE for a (SIGNED-BYTE 8) stream and (UNSIGNED-BYTE 8) vector, or vice versa. (thanks to Tony Martinez) diff --git a/src/compiler/debug-dump.lisp b/src/compiler/debug-dump.lisp index a286675..6c3d347 100644 --- a/src/compiler/debug-dump.lisp +++ b/src/compiler/debug-dump.lisp @@ -332,9 +332,8 @@ ;;; environment live and is an argument. If a :DEBUG-ENVIRONMENT TN, ;;; then we also exclude set variables, since the variable is not ;;; guaranteed to be live everywhere in that case. -(defun dump-1-var (fun var tn id minimal buffer) - (declare (type lambda-var var) (type (or tn null) tn) (type index id) - (type clambda fun)) +(defun dump-1-var (var tn id minimal buffer) + (declare (type lambda-var var) (type (or tn null) tn) (type index id)) (let* ((name (leaf-debug-name var)) (save-tn (and tn (tn-save-tn tn))) (kind (and tn (tn-kind tn))) @@ -348,8 +347,7 @@ (and (eq kind :debug-environment) (null (basic-var-sets var)))) (not (gethash tn (ir2-component-spilled-tns - (component-info *component-being-compiled*)))) - (eq (lambda-var-home var) fun)) + (component-info *component-being-compiled*))))) (setq flags (logior flags compiled-debug-var-environment-live))) (when save-tn (setq flags (logior flags compiled-debug-var-save-loc-p))) @@ -409,7 +407,7 @@ (incf id)) (t (setq id 0 prev-name name))) - (dump-1-var fun var (cdr x) id nil buffer) + (dump-1-var var (cdr x) id nil buffer) (setf (gethash var var-locs) i)) (incf i)) (coerce buffer 'simple-vector)))) @@ -420,7 +418,7 @@ (declare (type clambda fun)) (let ((buffer (make-array 0 :fill-pointer 0 :adjustable t))) (dolist (var (lambda-vars fun)) - (dump-1-var fun var (leaf-info var) 0 t buffer)) + (dump-1-var var (leaf-info var) 0 t buffer)) (coerce buffer 'simple-vector))) ;;; Return VAR's relative position in the function's variables (determined diff --git a/src/compiler/life.lisp b/src/compiler/life.lisp index 8d81428..5e9d9a3 100644 --- a/src/compiler/life.lisp +++ b/src/compiler/life.lisp @@ -934,9 +934,23 @@ (setf (tn-global-conflicts tn) nil))) (values)) + +;;; On high debug levels, for all variables that a lambda closes over +;;; convert the TNs to :ENVIRONMENT TNs (in the physical environment +;;; of that lambda). This way the debugger can display the variables. +(defun maybe-environmentalize-closure-tns (component) + (dolist (lambda (component-lambdas component)) + (when (policy lambda (>= debug 2)) + (let ((physenv (lambda-physenv lambda))) + (dolist (closure-var (physenv-closure physenv)) + (let ((tn (find-in-physenv closure-var physenv))) + (when (member (tn-kind tn) '(:normal :debug-environment)) + (convert-to-environment-tn tn physenv)))))))) + (defun lifetime-analyze (component) (lifetime-pre-pass component) + (maybe-environmentalize-closure-tns component) (setup-environment-live-conflicts component) (lifetime-flow-analysis component) (lifetime-post-pass component) diff --git a/version.lisp-expr b/version.lisp-expr index 49adfa8..41968f7 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.1.6" +"1.0.1.7" -- 1.7.10.4