Index: /branches/ide-1.0/ccl/lib/backtrace.lisp
===================================================================
--- /branches/ide-1.0/ccl/lib/backtrace.lisp	(revision 6617)
+++ /branches/ide-1.0/ccl/lib/backtrace.lisp	(revision 6618)
@@ -309,5 +309,21 @@
 
 
-
+(defun variables-in-scope (lfun pc)
+  (declare (fixnum pc))
+  ;; Return a list of all symbol names "in scope" in the function lfun
+  ;; at relative program counter PC, using the function's symbol map.
+  ;; The list will be ordered so that least-recent bindings appear first.
+  (let* ((map (function-symbol-map lfun))
+         (names (car map))
+         (info (cdr map)))
+    (when map
+      (let* ((vars ()))
+        (dotimes (i (length names) vars)
+          (let* ((start-pc (aref info (1+ (* 3 i))))
+                 (end-pc (aref info (+ 2 (* 3 i)))))
+            (declare (fixnum start-pc end-pc))
+            (when (and (>= pc start-pc)
+                       (< pc end-pc))
+              (push (svref names i) vars))))))))
 
 (defun safe-cell-value (val)
