Next: , Previous: , Up: The Debugger   [Contents][Index]


3.4 Variable Access

There are three ways to access the current frame’s local variables in the debugger. The simplest is to type the variable’s name into the debugger’s read-eval-print loop. The debugger will evaluate the variable reference as though it had appeared inside that frame.

The debugger doesn’t really understand lexical scoping; it has just one namespace for all the variables in a function. If a symbol is the name of multiple variables in the same function, then the reference appears ambiguous, even though lexical scoping specifies which value is visible at any given source location. If the scopes of the two variables are not nested, then the debugger can resolve the ambiguity by observing that only one variable is accessible.

When there are ambiguous variables, the evaluator assigns each one a small integer identifier. The debug:var function and the list-locals command use this identifier to distinguish between ambiguous variables:

list-locals {prefix}

This command prints the name and value of all variables in the current frame whose name has the specified prefix. prefix may be a string or a symbol. If no prefix is given, then all available variables are printed. If a variable has a potentially ambiguous name, then the name is printed with a “#identifier” suffix, where identifier is the small integer used to make the name unique.

Function: debug:var name &optional identifier

This function returns the value of the variable in the current frame with the specified name. If supplied, identifier determines which value to return when there are ambiguous variables.

When name is a symbol, it is interpreted as the symbol name of the variable, i.e. the package is significant. If name is an uninterned symbol (gensym), then return the value of the uninterned variable with the same name. If name is a string, debug:var interprets it as the prefix of a variable name, and must unambiguously complete to the name of a valid variable.

This function is useful mainly for accessing the value of uninterned or ambiguous variables, since most variables can be evaluated directly.


Next: , Previous: , Up: The Debugger   [Contents][Index]