~ chicken-core (chicken-5) ceaff85e6c0fac253a0e8a6b532fbdccaf9642f5


commit ceaff85e6c0fac253a0e8a6b532fbdccaf9642f5
Author:     felix <felix@call-with-current-continuation.org>
AuthorDate: Fri Jul 16 21:10:35 2010 +0200
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Fri Jul 16 21:10:35 2010 +0200

    renamed frameinfo toplevel commands; added explanation in manual

diff --git a/csi.scm b/csi.scm
index 8c03b5ca..188f1b25 100644
--- a/csi.scm
+++ b/csi.scm
@@ -335,13 +335,13 @@ EOF
 				    " " (read-line)))))
 			   (if (not (zero? r))
 			       (printf "Editor returned with non-zero exit status ~a" r))))
-			((f)
+			((c)
 			 (show-frameinfo selected-frame)
 			 (##sys#void))
-			((nf)
+			((f)
 			 (select-frame (read))
 			 (##sys#void))
-			((cf)
+			((g)
 			 (copy-from-frame (read)))
 			((s)
 			 (let* ((str (read-line))
@@ -364,9 +364,9 @@ EOF
  ,e FILENAME       Run external editor
  ,s TEXT ...       Execute shell-command
  ,exn              Describe last exception
- ,f                Show frame information
- ,nf N             Select frame N
- ,cf NAME          Get variable NAME from current frame
+ ,c                Show call-chain of most recent error
+ ,f N              Select frame N
+ ,g NAME           Get variable NAME from current frame
  ,t EXP            Evaluate form and print elapsed time
  ,x EXP            Pretty print expanded expression EXP\n")
 			 (##sys#hash-table-for-each
@@ -756,22 +756,23 @@ EOF
 	    (printf "~a~a:~a\t~a\t  " 
 	      (if here #\* #\space)
 	      i
-	      (if (and finfo (pair? (##sys#slot data 2))) #\. #\space) ; e
+	      (if (and finfo (pair? (##sys#slot data 2))) "[]" "  ") ; e
 	      (##sys#slot info 0))	; raw
 	    (when cntr (printf "[~a] " cntr))
-	    (prin1 form)
+	    (when form (prin1 form))
 	    (newline)
-	    (if (and here finfo)
-		(for-each
-		 (lambda (e v)
-		   (do ((i 0 (fx+ i 1))
-			(be e (cdr be)))
-		       ((null? be))
-		     (printf "  ~s:\t  " (car be))
-		     (prin1 (##sys#slot v i))
-		     (newline)))
-		 (##sys#slot data 2)	   ; e
-		 (##sys#slot data 3)))))))))	   ; v
+	    (when (and here finfo)
+	      (for-each
+	       (lambda (e v)
+		 (display "  ---\n")
+		 (do ((i 0 (fx+ i 1))
+		      (be e (cdr be)))
+		     ((null? be))
+		   (printf "  ~s:\t  " (car be))
+		   (prin1 (##sys#slot v i))
+		   (newline)))
+	       (##sys#slot data 2)	   ; e
+	       (##sys#slot data 3)))))))))	   ; v
 	  
 (define select-frame
   (let ((display display))
diff --git a/manual/Using the interpreter b/manual/Using the interpreter
index ccc516ca..1068bb5c 100644
--- a/manual/Using the interpreter	
+++ b/manual/Using the interpreter	
@@ -143,11 +143,11 @@ The toplevel loop understands a number of special commands:
 
 ; ,exn : Describes the last exception that occurred and adds it to the result history (it can be accessed using the {{#}} notation).
 
-; ,f : Show call-trace items of the most recent error
+; ,c : Show call-trace items of the most recent error
 
-; ,nf N : Select call-trace item with the given number, where the number {{0}} indicates the last item in the trace
+; ,f N : Select call-trace item with the given number, where the number {{0}} indicates the last item in the trace
 
-; cf NAME : Returns the value of the local variable with the given name (which may be a symbol or string)
+; ,g NAME : Returns the value of the local variable with the given name (which may be a symbol or string)
 
 ; ,q : Quit the interpreter.
 
@@ -162,6 +162,7 @@ The toplevel loop understands a number of special commands:
 You can define your own toplevel commands using the {{toplevel-command}}
 procedure:
 
+
 === toplevel-command
 
 <procedure>(toplevel-command SYMBOL PROC [HELPSTRING])</procedure>
@@ -171,6 +172,44 @@ Defines or redefines a toplevel interpreter command which can be invoked by ente
 read any required argument via {{read}} (or {{read-line}}). If the optional
 argument {{HELPSTRING}} is given, it will be listed by the {{,?}} command.
 
+
+=== Getting error information
+
+Interpreted code has some extended debugging information available
+that can be used to locate errors and obtaining information about the
+lexical environment that was effective at the point of error. When an
+error occurs in an evaluated expression, a "call trace" is printed -
+the list of calls up to the error location. Note that this does not
+follow a stack model: it is merely a list of recently made procedure
+calls where the last one in the list is (probably) the call of
+whatever procedure was executing before the error happened. You can
+use the {{,c}} command to show the call-trace of the last
+error. Depending on whether compiled or interpreted code was executing
+and how much debugging information is available, the call trace shows
+trace-buffer entries of the following shape:
+
+  <frame-number>:<environment?> <mode> <procedure-name> <form> 
+
+{{<frame-number>}} gives the number of the call-trace entry, counting
+from zero and beginning with the most recent entry. If a {{[]}}
+follows the frame-number, then this frame contains the lexical
+environment in effect when that procedure call took place. {{<mode>}}
+is optional and is either {{<syntax>}} or {{<eval>}} indicating
+whether this trace-buffer entry represents a syntax-expansion or an
+evaluation and is not given for compiled code. {{<form>}} is also only
+available for interpreted code and shows the procedure call
+expression, possibly following the name of the procedure containing
+the call expression.
+
+If the trace-buffer entry contains lexical environment information
+than the complete environment of the call site is shown.
+
+Use {{,f}} to select a frame by number, if you want to inspect the
+lexical environment of an earlier frame. The {{,g}} command lets you
+retrieve the value of a local or lexical variable from the currently
+selected frame. Note that the variables are renamed to simplify the
+variable lookup done internally by the interpreter.
+
 === Running an external editor
 
 The {{,e}} command runs the editor given by:
Trap