|Skip Navigation Links|
|Exit Print View|
|Oracle Solaris Studio 12.3: Debugging a Program With dbx Oracle Solaris Studio 12.3 Information Library|
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
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)
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.