JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Studio 12.2: Debugging a Program With dbx
search filter icon
search icon

Document Information

Preface

1.  Getting Started With dbx

2.  Starting dbx

3.  Customizing dbx

4.  Viewing and Navigating To Code

Navigating To Code

Navigating To a File

Navigating To Functions

Selecting From a List of C++ Ambiguous Function Names

Choosing Among Multiple Occurrences

Printing a Source Listing

Walking the Call Stack to Navigate To Code

Types of Program Locations

Program Scope

Variables That Reflect the Current Scope

Visiting Scope

Components of the Visiting Scope

Changing the Visiting Scope

Qualifying Symbols With Scope Resolution Operators

Backquote Operator

C++ Double Colon Scope Resolution Operator

Block Local Operator

Linker Names

Locating Symbols

Printing a List of Occurrences of a Symbol

Determining Which Symbol dbx Uses

Scope Resolution Search Path

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

Object File Loading

Listing Debugging Information for Modules

Listing Modules

Finding Source and Object Files

5.  Controlling Program Execution

6.  Setting Breakpoints and Traces

7.  Using the Call Stack

8.  Evaluating and Displaying Data

9.  Using Runtime Checking

10.  Fixing and Continuing

11.  Debugging Multithreaded Applications

12.  Debugging Child Processes

13.  Debugging OpenMP Programs

14.  Working With Signals

15.  Debugging C++ With dbx

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

20.  Debugging Shared Libraries

A.  Modifying a Program State

B.  Event Management

C.  Command Reference

Index

Navigating To Code

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.

Navigating To a File

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.

Navigating To Functions

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

Selecting From a List of C++ Ambiguous Function Names

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
Choosing Among Multiple Occurrences

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.

Printing a Source Listing

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.

Walking the Call Stack to Navigate To Code

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.