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
Variables That Reflect the Current Scope
Components of the Visiting Scope
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 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.
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
Use the double colon operator (::) to qualify a C++ member function, a top level function, or a variable with global scope with:
An overloaded name (same name used with different argument types)
An ambiguous name (same name used in different classes)
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
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> 2 3 int main(int argc, char** argv) { 4 5 int i=1; 6 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 } 18 (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 `a.out`t.c`main:10`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
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