Skip Navigation Links | |
Exit Print View | |
Oracle Solaris Studio 12.3: Debugging a Program With dbx Oracle Solaris Studio 12.3 Information Library |
4. Viewing and Navigating To Code
Selecting From a List of C++ Ambiguous Function Names
Choosing Among Multiple Occurrences
Walking the Call Stack to Navigate To Code
Qualifying Symbols With Scope Resolution Operators
C++ Double Colon Scope Resolution Operator
Printing a List of Occurrences of a Symbol
Determining Which Symbol dbx Uses
Relaxing the Scope Lookup Rules
Viewing Variables, Members, Types, and Classes
Looking Up Definitions of Variables, Members, and Functions
Looking Up Definitions of Types and Classes
Debugging Information in Object Files and Executables
Listing Debugging Information for Modules
Finding Source and Object Files
5. Controlling Program Execution
6. Setting Breakpoints and Traces
8. Evaluating and Displaying Data
11. Debugging Multithreaded Applications
16. Debugging Fortran Using dbx
17. Debugging a Java Application With dbx
18. Debugging at the Machine-Instruction Level
19. Using dbx With the Korn Shell
A scope is a subset of the program defined in terms of the visibility of a variable or function. A symbol is said to be “in scope” if its name is visible at a given point of execution. In C, functions may have global or file-static scope; variables may have global, file-static, function, or block scope.
The following variables always reflect the current program counter of the current thread or LWP, and are not affected by the various commands that change the visiting scope:
Scope of the current program counter
Current line number
Current function
Class to which $func belongs
Current source file
Current load object
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 remembers its visiting scope.
Some of the components of the visiting scope are visible in the following predefined ksh variables:
Current visiting scope
Current visiting load object
Current visiting file
Current visiting line number
Class to which $vfunc belongs
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.
The following commands are the most common ways of changing the visiting scope:
func
file
up
down
frame
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 (see Setting dbx Environment Variables) is set to ON, dbx attempts to find and make active a stack frame that has source code.
When you use the up command (see up Command), the down command (down Command), the frame number command (see frame Command), or the pop command (see pop Command)to 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 (see list Command) changes the visiting scope only if you use thelist function orlist file 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, if you type the following, dbx lists the start of the source for my_func, and changes the visiting scope to my_func.
(dbx) list my_func
If you type the following, dbx lists 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.