Documentation Home
> Debugging a Program With dbx
Debugging a Program With dbx
Book Information
Preface
Chapter 1 Starting dbx
Basic Concepts
Starting a Debugging Session
dbx Start-up Sequence
If a Core File Exists
Process ID
Setting Startup Properties
pathmap
dbxenv
alias
Debugging Optimized Code
Compiling with the -g Option
C++ Support and the -g0 Option
Code Compiled Without the -g Option
Shared Libraries Need -g for Full dbx Support
Completely Stripped Programs
Quitting Debugging
Stopping Execution
Detaching a Process From dbx
Killing a Program Without Terminating the Session
Saving and Restoring a Debugging Run
save
Saving a Series of Debugging Runs as Checkpoints
Restoring a Saved Run
Prerequisites for An Exact Restoration of a Saved Run
Saving and Restoring Using replay
Command Reference
Syntax
Start-up Options
Chapter 2 Customizing dbx
Using the .dbxrc File
Creating a .dbxrc File
A Sample Initialization File
dbx Environment Variables and the Korn Shell
Customizing dbx in Sun WorkShop
Setting Debugging Options
Maintaining a Unified Set of Options
Maintaining Two Sets of Options
Storing Custom Buttons
Command Reference
Chapter 3 Viewing and Visiting Code
Mapping to the Location of the Code
Visiting Code
Visiting a File
Visiting Functions
Selecting from a List of C++ Ambiguous Function Names
Choosing Among Multiple Occurrences
Printing a Source Listing
Walking the Call Stack to Visit Code
Qualifying Symbols with Scope Resolution Operators
Backquote Operator
C++ Double Colon Scope Resolution Operator
Block Local Operator
Linker Names
Scope Resolution Search Path
Locating Symbols
Printing a List of Occurrences of a Symbol
Determining Which Symbol dbx Uses
Viewing Variables, Members, Types, and Classes
Looking Up Definitions of Variables, Members, and Functions
Looking Up Definitions of Types and Classes
Using the Auto-Read Facility
Debugging Without the Presence of .o Files
Listing Modules
Command Reference
modules
whatis
list
Chapter 4 Controlling Program Execution
Running a Program
Attaching dbx to a Running Process
Detaching dbx From a Process
Stepping Through a Program
Single Stepping
Continuing a Program
Calling a Function
Using Ctrl+C to Stop a Process
Command Reference
run
rerun
next
cont
step
debug
detach
Chapter 5 Setting Breakpoints and Traces
Basic Concepts
Setting Breakpoints
Setting a stop Breakpoint at a Line of Source Code
Setting a when Breakpoint at a Line
Setting a Breakpoint in a Dynamically Linked Library
Setting Multiple Breaks in C++ Programs
Setting Breakpoints in Member Functions of Different Classes
Setting Breakpoints in Member Functions of Same Class
Setting Multiple Breakpoints in Nonmember Functions
Setting Breakpoints in Objects
Tracing Code
Setting a Trace
Controlling the Speed of a Trace
Listing and Clearing Event Handlers
Listing Breakpoints and Traces
Deleting Specific Breakpoints Using Handler ID Numbers
Watchpoints
Stopping Execution When Modified
Stopping Execution When Variables Change
Stopping Execution on a Condition
The Faster modify Event
Setting Breakpoint Filters
Efficiency Considerations
Chapter 6 Event Management
Basic Concepts
Creating Event Handlers
when
stop
trace
Manipulating Event Handlers
Using Event Counters
Setting Event Specifications
Breakpoint Event Specifications
in func
at lineno
infunction func
inmember funcinmethod func
inclass classname
inobject obj-expr
Watchpoint Event Specifications
access mode addr-exp, [byte-size-exp]
Limitations of access
change variable
cond cond-expr
modify addr-exp [ , byte-size ]
Limitations of modify event-spec on Solaris 2.5.1
System Event Specifications
dlopen [ lib-path ] | dlclose [ lib-path ]
fault fault
lwp_exit
sig sig
sig sig sub-code
sysin code | name
sysout code | name
sysin | sysout
Execution Progress Event Specifiers
next
returns
returns func
step
Other Event Specifications
attach
detach
lastrites
proc_gone
prog_new
stop
sync
syncrtld
throw
throw type
throw -unhandled
throw -unexpected
timer seconds
Event Specification Modifiers
-if cond
-in func
-disable
-count n-count infinity
-temp
-instr
-thread tid
-lwp lid
-hidden
-perm
Parsing and Ambiguity
Using Predefined Variables
Event-Specific Variables
$handlerid
$booting
Variables Valid for the Given Event
For Event sig
For Event exit
For Events dlopen and dlclose
For Events sysin and sysout
For Event proc_gone
Examples
Set Watchpoint for Store to Array Member
Simple Trace
Enable Handler While Within the Given Function (in func)
Determine the Number of Lines Executed in a Program
Determine the Number of Instructions Executed by a Source Line
Enable Breakpoint after Event Occurs
Reset Application Files for replay
Check Program Status
Catch Floating Point Exceptions
Command Reference
when
stop
step
cancel
status
delete
clear
handler
Chapter 7 Examining the Call Stack
Finding Your Place on the Stack
Walking the Stack and Returning Home
Moving Up and Down the Stack
Moving to a Specific Frame
Command Reference
where
hide/unhide
Chapter 8 Evaluating and Displaying Data
Evaluating Variables and Expressions
Verifying Which Variable dbx Uses
Variables Outside the Scope of the Current Function
Printing C++
Evaluating Unnamed Arguments in C++ Programs
Dereferencing Pointers
Monitoring Expressions
Turning Off Display (Undisplay)
Assigning a Value to a Variable
Evaluating Arrays
Array Slicing for Arrays
Syntax for Array Slicing and Striding
Slices
Strides
Command Reference
print
Chapter 9 Using Runtime Checking
Basic Concepts
When to Use RTC
Requirements
Limitations
Using RTC
Using Access Checking (SPARC only)
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
Default Suppressions
Using Suppression to Manage Errors
Using RTC on a Child Process
Using RTC on an Attached Process
Using Fix and Continue With RTC
Runtime Checking Application Programming Interface
Using RTC in Batch Mode
Troubleshooting Tips
RTC's Eight Megabyte Limit
Working Around the Eight Megabyte Limit
Case 1
Case 2
Case 2a
rtc_patch_area
Examples
Command Reference
check|uncheck
showblock
showleaks
showmemuse
suppress|unsuppress
Error Type Location Specifier
RTC Errors
Address in Block (aib)
Address in Register (air)
Bad Free (baf)
Duplicate Free (duf)
Misaligned Free (maf)
Misaligned Read (mar)
Misaligned Write (maw)
Memory Leak (mel)
Out of Memory (oom)
Read from Unallocated Memory (rua)
Read from Uninitialized Memory (rui)
Write to Read-Only Memory (wro)
Write to Unallocated Memory (wua)
dbxenv Variables
dbxenv rtc_auto_continue {on | off}
dbxenv rtc_auto_suppress {on | off}
dbxenv rtc_biu_at_exit {on | off | verbose}
dbxenv rtc_error_log_file_name filename
dbxenv rtc_error_limit n
dbxenv rtc_mel_at_exit {on | off | verbose}
Chapter 10 Data Visualization
Specifying Proper Array Expressions
Graphing an Array
Automatic Updating of Array Displays
Changing Your Display
Analyzing Visualized Data
Scenario 1: Comparing Different Views of the Same Data
Scenario 2: Updating Graphs of Data Automatically.
Scenario 3: Comparing Data Graphs at Different Points in Program
Scenario 4: Comparing Data Graphs from Different Runs of Same Program
Fortran Example Program
C Example Program
Chapter 11 Fixing and Continuing
Basic Concepts
How fix and continue Operates
Modifying Source Using fix and continue
Restrictions
Fixing Your Program
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
Command Reference
Chapter 12 Debugging Multithreaded Applications
Understanding Multithreaded Debugging
Thread Information
Viewing the Context of Another Thread
Viewing the Threads List
Resuming Execution
Understanding LWP Information
Command Reference
thread
threads
Thread and LWP States
Chapter 13 Debugging Child Processes
Attaching to Child Processes
Following the exec
Following fork
Interacting with Events
Chapter 14 Working With Signals
Understanding Signal Events
Catching Signals
Changing the Default Signal Lists
Trapping the FPE Signal
Determining Where the Exception Occurred
Determining the Cause of the Exception
Sending a Signal in a Program
Automatically Handling Signals
Chapter 15 Collecting Data
Using the Sampling Collector
Profiling
Collecting Data for Multithreaded Applications
Command Reference
Chapter 16 Debugging C++
Using dbx with C++
Exception Handling in dbx
Commands for Handling Exceptions
exception [-d | +d]
intercept [-a | -x | typename]
unintercept [-a | -x | typename]
whocatches typename
Examples of Exception Handling
Debugging With C++ Templates
Template Example
Command Reference
Commands for C++ Templates
whereis name
whatis name
stop inclass classname
stop infunction name
stop in function
call function_name (parameters)
print Expressions
list Expressions
Chapter 17 Debugging Fortran Using dbx
Debugging Fortran
Current Procedure and File
Uppercase Letters (FORTRAN 77 only)
Optimized Programs
Sample dbx Session
Debugging Segmentation Faults
Using dbx to Locate Problems
Locating Exceptions
Tracing Calls
Working With Arrays
Fortran 90 Allocatable Arrays
Slicing Arrays
Showing Intrinsic Functions
Showing Complex Expressions
Showing Logical Operators
Viewing Fortran 90 Derived Types
Pointer to Fortran 90 Derived Type
Fortran 90 Generic Functions
Chapter 18 Debugging at the Machine-Instruction Level
Examining the Contents of Memory
Using the examine or x Command
Addresses
Formats
Count
Examples
Using the dis Command
Using the listi Command
Stepping and Tracing at Machine-Instruction Level
Single-Stepping the Machine-Instruction Level
Tracing at the Machine-Instruction Level
Setting Breakpoints at Machine-Instruction Level
Setting a Breakpoint at an Address
Using the adb Command
Using the regs Command
Platform-specific Registers
SPARC Register Information
Intel Register Information
Chapter 19 Using dbx With the Korn Shell
ksh-88 Features Not Implemented
Extensions to ksh-88
Renamed Commands
Chapter 20 Debugging Shared Libraries
Basic Concepts
Link Map
Startup Sequence and .init Sections
Procedure Linkage Tables (PLT)
Debugging Support for Preloaded Shared Objects
Fix and Continue
Setting a Breakpoint in a Dynamically Linked Library
Appendix A Modifying a Program State
Impacts of Running a Program Under dbx
Commands That Alter the State of the Program
assign
pop
call
print
when
fix
cont at
Appendix B Incremental Link Editor (ild)
Introduction
Overview of Incremental Linking
How to Use ild
How ild Works
What ild Cannot Do
Reasons for Full Relinks
ild Deferred-Link Messages
ild Relink Messages
Example 1: internal free space exhausted
Example 2: running strip
Example 3: ild version
Example 4: too many files changed
Example 5: full relink
Example 6: new working directory
Options
Options Accepted by the Compilation System
Options Passed to ild from the Compilation System
Environment
Notes
ld Options Not Supported by ild
Files Used by ild
Appendix C User Tips
Using dbx Equivalents for Common GDB Commands
Changes in dbx Since Release 2.0.1
Using the .dbxinit File
Alias Definition
The Symbols / and ?
Embedded Slash Command
Using assign Instead of set
Enabling Command-Line Editing
Being In Scope
Locating Files
Reaching Breakpoints
C++ members and whatis Command
Runtime Checking Eight Megabyte Limit
Using dbx to Locate Floating-Point Exceptions
Using dbx with Multithreaded Programs
Thread Numbering
LWP Numbering
Breakpoints on a Specific Thread
dbx Identification of Multithreaded Applications
The Collector, RTC, fix and continue, and Watchpoints
Multithreaded Pitfalls
Sleeping Threads
thr_join, thr_create(), and thr_exit
© 2010, Oracle Corporation and/or its affiliates