JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Studio Overview
search filter icon
search icon

Document Information

Preface

Oracle Solaris Studio 12.2 Overview

Introduction to Oracle Solaris Studio Software

Developer Workflow for Oracle Solaris Studio

Oracle Solaris Studio IDE

Oracle Solaris Studio Compilers

C Compiler

cc Command Syntax

C Documentation

C++ Compiler

CC Command Syntax

C++ Documentation

Fortran 95 Compiler

f95 Command Syntax

Fortran Documentation

C/C++/Fortran Libraries

OpenMP 3.0 for Parallel Programming

Sun Performance Library for Programs With Intensive Computation

dmake Utility for Building Applications

Tools for Detecting Errors

dbx Debugger and dbxtool

dbx on the Command Line

dbx in the IDE

dbx in dbxtool

Discover Tool for Detecting Memory Errors

Uncover Tool for Measuring Code Coverage

Tuning Application Performance

Performance Analyzer Tools

Collect Performance Data With the Collector

Examine Performance Data With the Performance Analyzer

Examine Performance Data With the er_print Utility

Analyze Multithreaded Application Performance With the Thread Analyzer

Simple Performance Optimization Tool (SPOT)

Profiling Tools in DLight

Profiling Tools in the IDE

For More Information

Tools for Detecting Errors

Oracle Solaris Studio includes several tools to help you detect errors in your applications:

dbx Debugger and dbxtool

dbx is an interactive, source-level, command-line debugging tool. You can use it to run a C, C++, or Fortran program in a controlled manner and to inspect the state of a stopped program. dbx gives you complete control of the dynamic execution of a program, including collecting performance and memory usage data, monitoring memory access, and detecting memory leaks.

dbx enables you to perform the following tasks:

You can use the dbx debugger on the command line, graphically through the Oracle Solaris Studio IDE, or through a separate graphical interface called dbxtool.

dbx on the Command Line

The basic syntax of the dbx command to start dbx is:

dbx [options] [program-name|-] [process-ID]

To start a dbx session and load the program test to be debugged:

% dbx test

To start a dbx session and attach it to a program that is already running with the process ID 832:

% dbx - 832

When your dbx session starts, dbx loads the program information for the program you are debugging. Then dbx waits in a ready state visiting the main block of the program such as the main() function in a C or C++ program. The (dbx) command prompt is displayed.

You can type commands at the (dbx) prompt. Typically, you first set a breakpoint by typing a command such as stop in main and then type a run command to run your program:

(dbx) stop in main
(4) stop in main
(dbx) run
Running: quote_1 
(process id 5685)
(dbx)

When execution stops at the breakpoint, you can type commands such as step and next to single-step through your code, and print and display to evaluate expressions and variables.

For information about the command-line options for the dbx utility, see the dbx(1) man page.

For complete information about using dbx including a command reference section, see Oracle Solaris Studio 12.2: Debugging a Program With dbx. You can also learn about the dbx commands and other topics by typing help at the (dbx) command line. For a list of the new and changed features, software corrections, known problems, limitations, and incompatibilities in the current release of dbx, see What’s New In The Oracle Solaris Studio 12.2 Release.

dbx in the IDE

You can use dbx in the Oracle Solaris Studio IDE by opening your project, creating breakpoints in the source, and clicking the Debug button. The IDE enables you to use menu options and buttons to step through your program, and provides a complete set of debugging windows.

As with building your application, the IDE debugs your application as a project. In the following screen capture, one of the IDE sample projects is running in dbx. You can use commands in the Debug menu or the buttons at the top right in the IDE window to control the debugger. As you use the Debug commands and buttons, the IDE issues commands to dbx and displays output in the various debugging windows.

Screen capture of Oracle Solaris Studio IDE with dbx debugger running

In the figure , the debugger is stopped at a breakpoint and the Process I/O window shows the program interaction. Some debugger windows such as Variables, Call Stack, and Breakpoints are also shown but not selected. You can open more debugging windows by selecting from the Window -> Debugging menu. One of the debugging windows is the Dbx Console window, which displays the interaction with dbx. You can also type commands at the (dbx) prompt in the Dbx Console window.

For more information about using dbx in the IDE, see the integrated help in the IDE and Oracle Solaris Studio 12.2 IDE Quick Start Tutorial.

dbx in dbxtool

You can also use dbx through dbxtool, a graphical user interface that is separate from the IDE, but includes similar debugging windows and an editor. Unlike the IDE, dbxtool does not use projects, and you can use it to debug any C, C++, or Fortran executable or core file.

To start dbxtool, type:

% dbxtool executable-name

You can also omit the executable name and specify it from within dbxtool instead.

As with the IDE, you can issue commands to dbx by clicking toolbar buttons or using Debug menu options in dbxtool. You can also type commands at the (dbx) prompt in the Dbx Console window.

In the following figure, dbx is running in dbxtool on the quote_1 program. The Dbx Console window is selected and you can see the (dbx) prompt and commands that have been entered by dbxtool in response to the user's selections.

Screen Capture of dbxtool with dbx Debugger Running

For information about using dbxtool, see the dbxtool(1) man page and the integrated help in dbxtool. The Oracle Solaris Studio 12.2 dbxtool Tutorial shows how to use dbxtool.

Discover Tool for Detecting Memory Errors

The Sun Memory Error Discovery Tool (Discover) is an advanced development tool for detecting memory access errors in your programs. Discover works on binaries that are compiled with optimization, so one of the -On options such as -O2 must be used when compiling. Compiling a binary with -g enables Discover to display source code and line number information while reporting errors and warnings.

Discover is simple to use. After compiling the binary with optimization and -g, you run the discover command against the optimized binary to create an instrumented binary. Then you run the instrumented binary to create a Discover report. You can request the Discover report in HTML format, text format, or both. The report shows memory errors, warnings, and memory leaks, and you can display the source code and stack trace for each error or warning.

The following example from the discover(1) man page shows how to prepare, instrument, and run an executable to generate a Discover report for detecting memory access errors. The -w option on the discover command line indicates the report should be written as text and the - option indicates that the output should go to the screen.

% cc -g -O2 test.c -o test.prep
% discover -w - -o test.disc test.prep
% ./test.disc
ERROR (UMR): accessing uninitialized data from address 0x5000c (4 bytes) at:
     foo() + 0xdc  <ui.c:6>
          3:    int *t;
          4:    foo() {
          5:     t = malloc(5*sizeof(int));
          6:=>   printf("%d0, t[1]);
          7:    }
          8:
          9:    main()
     main() + 0x1c
     _start() + 0x108
    block at 0x50008 (20 bytes long) was allocated at:
     malloc() + 0x260
     foo() + 0x24  <ui.c:5>
          2:
          3:    int *t;
          4:    foo() {
          5:=>   t = malloc(5*sizeof(int));
          6:     printf("%d0, t[1]);
          7:    }
          8:
     main() + 0x1c
     _start() + 0x108

     ***************** Discover Memory Report *****************

1 block at 1 location left allocated on heap with a total size of 20 bytes

    1 block with total size of 20 bytes
     malloc() + 0x260
     foo() + 0x24  <ui.c:5>
          2:
          3:    int *t;
          4:    foo() {
          5:=>   t = malloc(5*sizeof(int));
          6:     printf("%d0, t[1]);
          7:    }
          8:
     main() + 0x1c
     _start() + 0x108

For more information, see the discover(1) man page and the Oracle Solaris Studio 12.2 Discover and Uncover User’s Guide.

Uncover Tool for Measuring Code Coverage

Uncover is a command-line tool for measuring code coverage. The tool shows you which areas of your application code are exercised when the application is run, and which are not exercised and not covered by testing. Uncover produces a report with statistics and metrics to help you determine which functions should be added to the test suite to ensure that more of the code is covered during testing.

Uncover works on binaries that are compiled with optimization, which means one of the -On options such as -O2 must be used when compiling. Compiling a binary with -g enables Uncover to display source code and line-number information while reporting on code coverage.

After compiling the binary, you run the uncover command on the binary. Uncover creates a new binary with added instrumentation code and also creates a directory named binary.uc that will contain the code coverage data for your program in the form of Performance Analyzer experiments. Each time you run the instrumented binary, code coverage data is collected and stored in the binary.uc directory.

You can display the experiment data in the Performance Analyzer, or generate the Uncover report as HTML and display it in your web browser.

The following example shows how to prepare, instrument, and run an executable to generate an Uncover report for examining code coverage. The optimized binary is test and is replaced by the instrumented binary also named test.

% cc -g -O2 test.c -o test
% uncover test
% test

The experiment directory is test.uc and contains the data that is generated when the instrumented test runs. The test.uc directory also contains a copy of the uninstrumented test binary.

To view the experiment in Performance Analyzer:

% uncover test.uc

To view the experiment in an HTML page in a browser:

% uncover -H test.html test.uc

For more information, see the uncover(1) man page and the Oracle Solaris Studio 12.2 Discover and Uncover User’s Guide.