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

Document Information


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.  Macros

D.  Command Reference


Qualifying Symbols With Scope Resolution Operators

When using the func command or the file command, you might need to use scope resolution operators to qualify the names of the functions that you give as targets.

dbx provides three scope resolution operators with which to qualify symbols: the backquote operator (`), the C++ double colon operator (::), and the block local operator (:lineno). You use them separately or, in some cases, together.

In addition to qualifying file and function names when navigating through code, symbol name qualifying is also necessary for printing and displaying out-of-scope variables and expressions, and for displaying type and class declarations (using the whatis command). The symbol qualifying rules are the same in all cases; this section covers the rules for all types of symbol name qualifying.

Backquote Operator

Use the backquote character (`) to find a variable or function of global scope:

(dbx) print `item

A program can use the same function name in two different files (or compilation modules). In this case, you must also qualify the function name to dbx so that it registers which function you will navigate. To qualify a function name with respect to its file name, use the general purpose backquote (`) scope resolution operator.

(dbx) func`file_name`function_name

C++ Double Colon Scope Resolution Operator

Use the double colon operator (::) to qualify a C++ member function, a top level function, or a variable with global scope with:

You might want to qualify an overloaded function name. If you do not qualify it, dbx displays an overload list so you can choose which function you will navigate. If you know the function class name, you can use it with the double colon scope resolution operator to qualify the name.

(dbx) func class::function_name (args)

For example, if hand is the class name and draw is the function name, type:

(dbx) func hand::draw

Block Local Operator

The block local operator (:line_number) allows you to refer specifically to a variable in a nested block. You might want to do so if you have a local variable shadowing a parameter or member name, or if you have several blocks, each with its own version of a local variable. The line_number is the number of the first line of code within the block for the variable of interest. When dbx qualifies a local variable with the block local operator, dbx uses the line number of the first block of code, but you can use any line number within the scope in dbx expressions.

In the following example, the block local operator (:230) is combined with the backquote operator.

(dbx) stop in `animate.o`change_glyph:230`item

The following example shows how dbx evaluates a variable name qualified with the block local operator when there are multiple occurrences in a function.

(dbx) list 1,$
    1   #include <stddef.h>
    3   int main(int argc, char** argv) {
    5   int i=1;
    7       {
    8            int i=2;
    9            {
   10                   int j=4;
   11                   int i=3;
   12                   printf("hello");
   13            }
   14            printf("world\n");
   15       }
   16       printf("hi\n");
   17   }
(dbx) whereis i
variable: `a.out`t.c`main`i
variable: `a.out`t.c`main:8`i
variable: `a.out`t.`main:10`i
(dbx) stop at 12 ; run
(dbx) print i
i = 3
(dbx) which i
(dbx) print `main:7`i
`a.out`t.c`main`i = 1
(dbx) print `main:8`i
`a.out`t.c`main:8`i = 2
(dbx) print `main:10`i
`a.out`t.c`main:10`i = 3
(dbx) print `main:14`i
`a.out`t.c`main:8`i = 2
(dbx) print `main:15`i
`a.out`t.c`main`i = 1

Linker Names

dbx provides a special syntax for looking up symbols by their linker names (mangled names in C++). Prefix the symbol name with a # (pound sign) character (use the ksh escape character \ (backslash) before any $ (dollar sign) characters), as in these examples:

(dbx) stop in #.mul
(dbx) whatis #\$FEcopyPc
(dbx) print `foo.c`#staticvar