Oracle® Solaris Studio 12.4: Debugging a Program With dbx

Exit Print View

Updated: January 2015
 
 

Visiting Scope

When you inspect various elements of your program with dbx, you modify the visiting scope. dbx uses the visiting scope during expression evaluation for purposes such as resolving ambiguous symbols. For example, if you type the following command, dbx uses the visiting scope to determine which i to print:

(dbx) print i

Each thread or LWP has its own visiting scope. When you switch between threads, each thread returns its visiting scope.

Components of the Visiting Scope

Some of the components of the visiting scope are visible in the following predefined ksh variables:

$vscope

Current visiting scope

$vloadobj

Current visiting load object

$vfile

Current visiting file

$vlineno

Current visiting line number

$vclass

Class to which $vfunc belongs

$vfunc

Current visiting function

All of the components of the current visiting scope stay compatible with one another. For example, if you visit a file that contains no functions, the current visiting source file is updated to the new file name and the current visiting function is updated to NULL.

Changing the Visiting Scope

    The following commands are the most common ways of changing the visiting scope:

  • func

  • file

  • up

  • down

  • frame number

  • pop

  • list procedure

The debug command and the attach command set the initial visiting scope.

When you hit a breakpoint, dbx sets the visiting scope to the current location. If the stack_find_source environment variable set to on, dbx attempts to find and make active a stack frame that has source code.

When you use the up command, the down command the frame command, or the pop command o change the current stack frame, dbx sets the visiting scope according to the program counter from the new stack frame.

The line number location used by the list command changes the visiting scope only if you use the list command. When the visiting scope is set, the line number location for the list command is set to the first line number of the visiting scope. When you subsequently use the list command, the current line number location for the list command is updated, but as long as you are listing lines in the current file, the visiting scope does not change. For example, the following command causes dbx to list the start of the source for my_func and change the visiting scope to my_func.

(dbx) list my_func

he following command causesdbx to list line 127 in the current source file and does not change the visiting scope.

(dbx) list 127

When you use the file command or the func command to change the current file or the current function, the visiting scope is updated accordingly.