In This Book

Understanding Blocks and Environments

A block is a program unit, such as a module, a main program, a subroutine, or a function. What constitutes a block depends on the language in which the program is written. Use the list blocks command to display the blocks in the program you are debugging.

A block de￿nes and encloses a scope, the region of source code over which a name's declaration is active. The debugger also de￿nes blocks called `declared (for user-declared symbols), `predefined (for data types for supported languages) and `image (for the program images).

The debugger de￿nes two environments:

The run environment is the block containing the current point of execution.

The current environment is the block to which the debugger refers when evaluating expressions.

The current environment is identical to the run environment, except when you explicitly change it to another block (by using the environment command, for example). The source ￿le display shows an arrow at the current point

of execution. When the current environment is set to some other block, a horizontal bar appears within the block where the current environment is set.

In addition, the block containing the current point of execution is displayed after the PC Location label above the source display. The current environment block is displayed after the Current Location label.

Each time execution of the target program stops, the debugger sets the current environment to the run environment.

The debugger starts its search for ob jects within the block that corresp onds to the current environment. If the debugger cannot ￿nd the object in the current environment, it extends its searc h into outer encompassing blocks. The debugger bases its search of outer blocks on the scope and visibility rules described in \Applying Scope and Visibility Rules".

For multi-threaded applications (implemen ted using HP DCE threads), the debugger also includes a thread component in its concept of en vironment. See \Debugging Multi-Threaded Applications" in Chapter 8 for more information on debugging multi-threaded applications.

7-2 Identifying Program Objects