4. Viewing and Navigating To Code
Variables That Reflect the Current Scope
Components of the Visiting Scope
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
When a program is stopped, you can navigate to code elsewhere in the program. You can navigate to any function or file that is part of the program. Navigating sets the current scope (see Program Scope). It is useful for determining when and at what source line you want to set a stop at breakpoint.
You can navigate to any file dbx recognizes as part of the program (even if a module or file was not compiled with the -g option). To navigate to a file:
(dbx) file filename
Using the file command without arguments echoes the file name of the file you are currently navigating.
(dbx) file
dbx displays the file from its first line unless you specify a line number.
(dbx) file filename ; list line_number
For information on setting a stop at breakpoint at a line of source code, see Setting a stop Breakpoint at a Line of Source Code.
You can use the func command to navigate to a function. To navigate to a function, type the command func followed by the function name. For example:
(dbx) func adjust_speed
The func command by itself echoes the current function.
For more information, see func Command
If you try to navigate to a C++ member function with an ambiguous name or an overloaded function name, a list is displayed, showing all functions with the overloaded name. Type the number of the function you want to navigate. If you know which specific class a function belongs to, you can type the class name and function name. For example:
(dbx) func block::block
If multiple symbols are accessible from the same scope level, dbx prints a message reporting the ambiguity.
(dbx) func main (dbx) which C::foo More than one identifier ’foo’. Select one of the following: 0) Cancel 1) ”a.out”t.cc”C::foo(int) 2) ”a.out”t.cc”C::foo() >1 ”a.out”t.cc”C::foo(int)
In the context of the which command, choosing from the list of occurrences does not affect the state of dbx or the program. Whichever occurrence you choose, dbx echoes the name.
Use the list command to print the source listing for a file or function. Once you navigate through a file, the list command prints number lines from the top. Once you navigate through a function, the list command prints its lines.
For detailed information on the list command, see list Command.
Another way to navigate to code when a live process exists is to “walk the call stack,” using the stack commands to view functions currently on the call stack, which represent all currently active routines. Walking the stack causes the current function and file to change each time you display a stack function. The stop location is considered to be at the “bottom” of the stack, so to move away from it, use the up command, that is, move toward the main or begin function. Use the down command to move toward the current frame.
For more information on walking the call stack, see Walking the Stack and Returning Home.