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

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

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

Parameters and Variables

Inlined Functions

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

3.  Customizing dbx

4.  Viewing and Navigating To Code

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


Compiling a Program for Debugging

You must prepare your program for debugging with dbx by compiling it with the -g or -g0 option.

Compiling with the -g Option

The -g option instructs the compiler to generate debugging information during compilation.

For example, to compile using the C++ compiler, type:

% CC -g

For the C++ compiler:

To compile optimized code for use with dbx, compile the source code with both the -O (uppercase letter O) and the -g options.

Using a Separate Debug File

dbx lets you use options in the objcopy command on Linux platforms and the gobjcopy command on Solaris platforms to copy the debugging information from an executable to a separate debug file, strip that information from the executable, and create a link between these two files.

dbx searches for the separate debug file in the following order and reads the debugging information from the first file it finds:

For example, to create a separate debug file for executable a.out, you would do the following.

Creating a Separate Debug File

  1. Create a separate debug file named a.out.debug containing the debugging information:
    objcopy --only-keep-debug a.out a.out.debug
  2. Strip the debugging information from a.out:
    objcopy --strip-debug a.out
  3. Establish the link between the two files:
    objcopy --add-gnu-debuglink=a.out.debug a.out

    On Solaris platforms, use the gobjcopy command. On Linux platforms, use the objcopy command.

    On a Linux platform, you can use the command objcopy -help to find out whether or not the -add-gnu-debuglink option is supported on the platform. You can replace the -only-keep-debug option of the objcopy command with the command cp a.out a.out.debug to make a.out.debug a fully executable file.