Documentation Home
> Sun Studio 12 Update 1: Debugging a Program With dbx
Sun Studio 12 Update 1: Debugging a Program With dbx
Book Information
Index
Numbers and Symbols
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Preface
Chapter 1 Getting Started With dbx
Compiling Your Code for Debugging
Starting dbx or dbxtool and Loading Your Program
Running Your Program in dbx
Debugging Your Program With dbx
Examining a Core File
Setting Breakpoints
Stepping Through Your Program
Looking at the Call Stack
Examining Variables
Finding Memory Access Problems and Memory Leaks
Quitting dbx
Accessing dbx Online Help
Chapter 2 Starting dbx
Starting a Debugging Session
Debugging a Core File
Debugging a Core File in the Same Operating Environment
If Your Core File Is Truncated
Debugging a Mismatched Core File
Eliminating Shared Library Problems
To Eliminate the Library Problems and Debug a “mismatched” Core File
Things to Remember
Using the Process ID
The dbx Startup Sequence
Setting Startup Properties
Mapping the Compile-time Directory to the Debug-time Directory
Setting dbx Environment Variables
Creating Your Own dbx Commands
Compiling a Program for Debugging
Compiling with the -g Option
Using a Separate Debug File
Creating a Separate Debug File
Debugging Optimized Code
Code Compiled Without the -g Option
Shared Libraries Require the -g Option for Full dbx Support
Completely Stripped Programs
Quitting Debugging
Stopping a Process Execution
Detaching a Process From dbx
Killing a Program Without Terminating the Session
Saving and Restoring a Debugging Run
Using the save Command
Saving a Series of Debugging Runs as Checkpoints
Restoring a Saved Run
Saving and Restoring Using replay
Chapter 3 Customizing dbx
Using the dbx Initialization File
Creating a .dbxrc File
Initialization File Sample
Setting dbx Environment Variables
The dbx Environment Variables and the Korn Shell
Chapter 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
Chapter 5 Controlling Program Execution
Running a Program
Attaching dbx to a Running Process
Detaching dbx From a Process
Stepping Through a Program
Single Stepping
Stepping Into a Function
Continuing Execution of a Program
To Resume Program Execution at a Specific Line
Calling a Function
Call Safety
Using Ctrl+C to Stop a Process
Chapter 6 Setting Breakpoints and Traces
Setting Breakpoints
Setting a stop Breakpoint at a Line of Source Code
Setting a stop Breakpoint in a Function
Setting Multiple Breaks in C++ Programs
Setting Breakpoints in Member Functions of Different Classes
Setting Breakpoints in All Member Functions of a Class
Setting Multiple Breakpoints in Nonmember Functions
Setting Breakpoints in Objects
Setting Data Change Breakpoints
Stopping Execution When an Address Is Accessed
Stopping Execution When Variables Change
Stopping Execution on a Condition
Setting Filters on Breakpoints
Using the Return Value of a Function Call as a Filter
Setting Data Change Breakpoints on Local Variables
Using a Filter With a Conditional Event
Tracing Execution
Setting a Trace
Controlling the Speed of a Trace
Directing Trace Output to a File
Setting a when Breakpoint at a Line
Setting Breakpoints in Dynamically Loaded Libraries
Listing and Clearing Breakpoints
Listing Breakpoints and Traces
Deleting Specific Breakpoints Using Handler ID Numbers
Enabling and Disabling Breakpoints
Efficiency Considerations
Chapter 7 Using the Call Stack
Finding Your Place on the Stack
Walking the Stack and Returning Home
Moving Up and Down the Stack
Moving Up the Stack
Moving Down the Stack
Moving to a Specific Frame
Popping the Call Stack
Hiding Stack Frames
Displaying and Reading a Stack Trace
Chapter 8 Evaluating and Displaying Data
Evaluating Variables and Expressions
Verifying Which Variable dbx Uses
Variables Outside the Scope of the Current Function
Printing the Value of a Variable, Expression, or Identifier
Printing C++ Pointers
Evaluating Unnamed Arguments in C++ Programs
Dereferencing Pointers
Monitoring Expressions
Turning Off Display (Undisplaying)
Assigning a Value to a Variable
Evaluating Arrays
Array Slicing
Array Slicing Syntax for C and C++
Array Slicing Syntax for Fortran
Using Slices
Using Strides
Using Pretty-Printing
Chapter 9 Using Runtime Checking
Capabilities of Runtime Checking
When to Use Runtime Checking
Runtime Checking Requirements
Using Runtime Checking
Turning On Memory Use and Memory Leak Checking
Turning On Memory Access Checking
Turning On All Runtime Checking
Turning Off Runtime Checking
Running Your Program
Using Access Checking
Understanding the Memory Access Error Report
Memory Access Errors
Using Memory Leak Checking
Detecting Memory Leak Errors
Possible Leaks
Checking for Leaks
Understanding the Memory Leak Report
Generating a Leak Report
Combining Leaks
Fixing Memory Leaks
Using Memory Use Checking
Suppressing Errors
Types of Suppression
Suppression by Scope and Type
Suppression of Last Error
Limiting the Number of Errors Reported
Suppressing Error Examples
Default Suppressions
Using Suppression to Manage Errors
Using Runtime Checking on a Child Process
Using Runtime Checking on an Attached Process
Using Fix and Continue With Runtime Checking
Runtime Checking Application Programming Interface
Using Runtime Checking in Batch Mode
bcheck Syntax
bcheck Examples
Enabling Batch Mode Directly From dbx
Troubleshooting Tips
Runtime Checking Limitations
Works Better With More Symbols and Debug Information
SIGSEGV and SIGALTSTACK Signals Are Restricted on x86 Platforms
Works Better When Sufficient Patch Area is Available Within 8 MB of All Existing Code (SPARC platforms only).
Runtime Checking Errors
Access Errors
Bad Free (baf) Error
Duplicate Free (duf) Error
Misaligned Free (maf) Error
Misaligned Read (mar) Error
Misaligned Write (maw) Error
Out of Memory (oom) Error
Read From Array Out-of-Bounds (rob) Error
Read From Unallocated Memory (rua) Error
Read From Uninitialized Memory (rui) Error
Write to Array Out-of-Bounds Memory (wob) Error
Write to Read-Only Memory (wro) Error
Write to Unallocated Memory (wua) Error
Memory Leak Errors
Address in Block (aib) Error
Address in Register (air) Error
Memory Leak (mel) Error
Chapter 10 Fixing and Continuing
Using Fix and Continue
How Fix and Continue Operates
Modifying Source Using Fix and Continue
Fixing Your Program
To Fix Your File
Continuing After Fixing
Changing an Executed Function
Changing a Function Not Yet Called
Changing a Function Currently Being Executed
Changing a Function Presently on the Stack
Changing Variables After Fixing
Modifying a Header File
Fixing C++ Template Definitions
Chapter 11 Debugging Multithreaded Applications
Understanding Multithreaded Debugging
Thread Information
Viewing the Context of Another Thread
Viewing the Threads List
Resuming Execution
Understanding Thread Creation Activity
Understanding LWP Information
Chapter 12 Debugging Child Processes
Attaching to Child Processes
Following the exec Function
Following the fork Function
Interacting With Events
Chapter 13 Debugging OpenMP Programs
How Compilers Transform OpenMP Code
dbx Functionality Available for OpenMP Code
Using Stack Traces With OpenMP Code
Using the dump Command on OpenMP Code
Execution Sequence of OpenMP Code
Chapter 14 Working With Signals
Understanding Signal Events
Catching Signals
Changing the Default Signal Lists
Trapping the FPE Signal (Solaris Platforms Only)
Determining Where the Exception Occurred
Determining the Cause of the Exception
Sending a Signal to a Program
Automatically Handling Signals
Chapter 15 Debugging C++ With dbx
Using dbx With C++
Exception Handling in dbx
Commands for Handling Exceptions
exception [-d | +d] Command
intercept [-all] [-x] [-set] [typename] Command
unintercept [-all] [-x] [typename] Command
whocatches typename Command
Examples of Exception Handling
Debugging With C++ Templates
Template Example
Commands for C++ Templates
whereis name Command
whatis name Command
stop inclass classname Command
stop infunction name Command
stop in function Command
call function_name(parameters) Command
print Expressions
list Expressions
Chapter 16 Debugging Fortran Using dbx
Debugging Fortran
Current Procedure and File
Uppercase Letters
Sample dbx Session
Running the Sample dbx Session
Debugging Segmentation Faults
Using dbx to Locate Problems
Locating Exceptions
Tracing Calls
Working With Arrays
Fortran 95 Allocatable Arrays
Showing Intrinsic Functions
Showing Complex Expressions
Showing Interval Expressions
Showing Logical Operators
Viewing Fortran 95 Derived Types
Pointer to Fortran 95 Derived Type
Chapter 17 Debugging a Java Application With dbx
Using dbx With Java Code
Capabilities of dbx With Java Code
Limitations of dbx With Java Code
Environment Variables for Java Debugging
Starting to Debug a Java Application
Debugging a Class File
Debugging a JAR File
Debugging a Java Application That Has a Wrapper
Attaching dbx to a Running Java Application
Debugging a C Application or C++ Application That Embeds a Java Application
Passing Arguments to the JVM Software
Specifying the Location of Your Java Source Files
Specifying the Location of Your C Source Files or C++ Source Files
Specifying a Path for Class Files That Use Custom Class Loaders
Setting Breakpoints on Java Methods
Setting Breakpoints in Native (JNI) Code
Customizing Startup of the JVM Software
Specifying a Path Name for the JVM Software
Passing Run Arguments to the JVM Software
Specifying a Custom Wrapper for Your Java Application
Using a Custom Wrapper That Accepts Command-Line Options
Using a Custom Wrapper That Does Not Accept Command-Line Options
Specifying 64-bit JVM Software
dbx Modes for Debugging Java Code
Switching from Java or JNI Mode to Native Mode
Switching Modes When You Interrupt Execution
Using dbx Commands in Java Mode
The Java Expression Evaluation in dbx Commands
Static and Dynamic Information Used by dbx Commands
Commands With Identical Syntax and Functionality in Java Mode and Native Mode
Commands With Different Syntax in Java Mode
Commands Valid Only in Java Mode
Chapter 18 Debugging at the Machine-Instruction Level
Examining the Contents of Memory
Using the examine or x Command
Using Addresses
Using Formats
Using Count
Examples of Using an Address
Using the dis Command
Using the listi Command
Stepping and Tracing at Machine-Instruction Level
Single Stepping at the Machine-Instruction Level
Tracing at the Machine-Instruction Level
Setting Breakpoints at the Machine-Instruction Level
Setting a Breakpoint at an Address
Using the regs Command
Platform-Specific Registers
SPARC Register Information
x86 Register Information
AMD64 Register Information
Chapter 19 Using dbx With the Korn Shell
ksh-88 Features Not Implemented
Extensions to ksh-88
Renamed Commands
Rebinding of Editing Functions
Chapter 20 Debugging Shared Libraries
Dynamic Linker
Link Map
Startup Sequence and .init Sections
Procedure Linkage Tables
Fix and Continue
Setting Breakpoints in Shared Libraries
Setting a Breakpoint in an Explicitly Loaded Library
Appendix A Modifying a Program State
Impacts of Running a Program Under dbx
Commands That Alter the State of the Program
assign Command
pop Command
call Command
print Command
when Command
fix Command
cont at Command
Appendix B Event Management
Event Handlers
Event Safety
Creating Event Handlers
Manipulating Event Handlers
Using Event Counters
Setting Event Specifications
Breakpoint Event Specifications
in function
at [filename:]line_number
at address_expression
infile filename
infunction function
inmember function inmethod function
inclass classname [-recurse | -norecurse]
inobject object-expression [-recurse | -norecurse]
Data Change Event Specifications
access mode address-expression [, byte-size-expression]
change variable
cond condition-expression
System Event Specifications
dlopen [ lib-path ] dlclose [ lib-path ]
fault fault
lwp_exit
sig signal
sig signal sub-code
sysin code | name
sysout code | name
sysin | sysout
Execution Progress Event Specifications
exit exitcode
next
returns
returns function
step
Other Event Specifications
attach
detach
lastrites
proc_gone
prog_new
stop
sync
syncrtld
thr_create [thread_id]
thr_exit
throw
throw type
throw -unhandled
throw -unexpected
timer seconds
Event Specification Modifiers
-if condition
-resumeone
-in function
-disable
-count n-count infinity
-temp
-instr
-thread thread_id
-lwp lwp_id
-hidden
-perm
Parsing and Ambiguity
Using Predefined Variables
Variables Valid for when Command
$handlerid
Variables Valid for when Command and Specific Events
Event Handler Examples
Setting a Breakpoint for Store to an Array Member
Implementing a Simple Trace
Enabling a Handler While Within a Function (in function)
Determining the Number of Lines Executed
Determining the Number of Instructions Executed by a Source Line
Enabling a Breakpoint After an Event Occurs
Resetting Application Files for replay
Checking Program Status
Catch Floating Point Exceptions
Appendix C Command Reference
assign Command
Native Mode Syntax
Java Mode Syntax
attach Command
Syntax
To Attach to a Running Java Process
bsearch Command
Syntax
call Command
Native Mode Syntax
Java Mode Syntax
cancel Command
Syntax
catch Command
Syntax
check Command
Syntax
clear Command
Syntax
collector Command
Syntax
collector archive Command
Syntax
collector dbxsample Command
Syntax
collector disable Command
Syntax
collector enable Command
Syntax
collector heaptrace Command
Syntax
collector hw_profile Command
Syntax
collector limit Command
Syntax
collector mpitrace Command
Syntax
collector pause Command
Syntax
collector profile Command
Syntax
collector resume Command
Syntax
collector sample Command
Syntax
collector show Command
Syntax
collector status Command
Syntax
collector store Command
Syntax
collector synctrace Command
Syntax
collector tha Command
Syntax
collector version Command
Syntax
cont Command
Syntax
dalias Command
Syntax
dbx Command
Native Mode Syntax
Java Mode Syntax
Options
dbxenv Command
Syntax
debug Command
Native Mode Syntax
Java Mode Syntax
Options
delete Command
Syntax
detach Command
Native Mode Syntax
Java Mode Syntax
dis Command
Syntax
Options
display Command
Native Mode Syntax
Java Mode Syntax
down Command
Syntax
dump Command
Syntax
edit Command
Syntax
examine Command
Syntax
exception Command
Syntax
exists Command
Syntax
file Command
Syntax
files Command
Native Mode Syntax
Java Mode Syntax
fix Command
Syntax
fixed Command
Syntax
fortran_modules Command
Syntax
frame Command
Syntax
func Command
Native Mode Syntax
Java Mode Syntax
funcs Command
Syntax
gdb Command
Syntax
handler Command
Syntax
hide Command
Syntax
ignore Command
Syntax
import Command
Syntax
intercept Command
Syntax
java Command
Syntax
jclasses Command
Syntax
joff Command
Syntax
jon Command
Syntax
jpkgs Command
Syntax
kill Command
Syntax
language Command
Syntax
line Command
Syntax
Examples
list Command
Syntax
Options
Examples
listi Command
loadobject Command
Syntax
loadobject -dumpelf Command
Syntax
loadobject -exclude Command
Syntax
loadobject -hide Command
Syntax
loadobject -list Command
Syntax
loadobject -load Command
Syntax
loadobject -unload Command
Syntax
loadobject -use Command
Syntax
lwp Command
Syntax
lwps Command
Syntax
mmapfile Command
Syntax
Example
module Command
Syntax
modules Command
Syntax
native Command
Syntax
next Command
Native Mode Syntax
Java Mode Syntax
nexti Command
Syntax
pathmap Command
Syntax
Examples
pop Command
Syntax
print Command
Native Mode Syntax
Java Mode Syntax
proc Command
Syntax
prog Command
Syntax
quit Command
Syntax
regs Command
Syntax
Example (SPARC platform)
replay Command
Syntax
rerun Command
Syntax
restore Command
Syntax
rprint Command
Syntax
rtc showmap Command
Syntax
rtc skippatch Command
Syntax
run Command
Native Mode Syntax
Java Mode Syntax
runargs Command
Syntax
save Command
Syntax
scopes Command
Syntax
search Command
Syntax
showblock Command
Syntax
showleaks Command
Syntax
showmemuse Command
Syntax
source Command
Syntax
status Command
Syntax
Example
step Command
Native Mode Syntax
Java Mode Syntax
stepi Command
Syntax
stop Command
Syntax
Native Mode Syntax
Java Mode Syntax
stopi Command
Syntax
suppress Command
Syntax
sync Command
Syntax
syncs Command
Syntax
thread Command
Native Mode Syntax
Java Mode Syntax
threads Command
Native Mode Syntax
Java Mode Syntax
trace Command
Syntax
Native Mode Syntax
Java Mode Syntax
tracei Command
Syntax
uncheck Command
Syntax
undisplay Command
Native Mode Syntax
Java Mode Syntax
unhide Command
Syntax
unintercept Command
Syntax
unsuppress Command
Syntax
unwatch Command
Syntax
up Command
Syntax
use Command
watch Command
Syntax
whatis Command
Native Mode Syntax
Java Mode Syntax
when Command
Syntax
Native Mode Syntax
Java Mode Syntax
wheni Command
Syntax
where Command
Native Mode Syntax
Java Mode Syntax
whereami Command
Syntax
whereis Command
Syntax
which Command
Syntax
whocatches Command
Syntax
© 2010, Oracle Corporation and/or its affiliates