Skip Navigation Links | |
Exit Print View | |
![]() |
Oracle Solaris Studio 12.3 Overview Oracle Solaris Studio 12.3 Information Library |
Oracle Solaris Studio 12.3 Overview
Introduction to Oracle Solaris Studio Software
Developer Workflow for Oracle Solaris Studio
Oracle Solaris Studio Compilers
OpenMP 3.1 for Parallel Programming
Sun Performance Library for Programs With Intensive Computation
dmake Utility for Building Applications
Tools for Debugging Applications
Tools for Verifying Applications
Discover Tool for Detecting Memory Errors
Tools for Tuning Application Performance
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
Oracle Solaris Studio provides tools to help verify your application's stability. The following tools combine dynamic, static and code coverage analysis to detect application vulnerabilities, including memory leaks and memory access violations.
Discover. A command-line utility that helps detect memory access errors in your code.
Uncover. A command-line utility that shows you which areas of your application code are not covered by testing.
Code Analyzer. A graphical tool that analyzes and displays static code error data collected by the C or C++ compiler, and data collected by Discover and Uncover. By integrating static error data with dynamic memory access error data and code coverage data, the Code Analyzer lets you find errors in your application that you would not find when using other error detection tools by themselves.
The Memory Error Discovery Tool (Discover) is an advanced development tool for detecting memory access errors in your programs. 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 your binary with the-g option, you run the discover command on the binary to instrument it. 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.3: Discover and Uncover User’s Guide.
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 with any binary that is built with an Oracle Solaris Studio compiler, and works best when the binary is built without optimization. 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. 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.3: Discover and Uncover User’s Guide.
The Oracle Solaris Studio Code Analyzer is a graphical tool that enables you do an integrated analysis of your code. The Code Analyzer uses three types of information that you gather using other tools:
Static code checking, which is performed when you compile your application with the Oracle Solaris Studio C or C++ compiler and specify the -xanalyze=code option.
Dynamic memory access checking, which is performed when you instrument your binary with Discover using the -a option, and then run the instrumented binary.
Code coverage checking, which is performed when you instrument your binary with Uncover, run the instrumented binary, and then run Uncover with the -a option on the collected coverage data.
You can use the Code Analyzer on a binary that has been prepared with any one of these tools or any combination of these tools. However, the integrated view of the three types of data offers the most revealing look into your code and enables you to create a more secure and robust application.
The following example shows how to run the Code Analyzer on a binary named a.out that has been prepared previously with Discover and Uncover.
% code-analyzer a.out
In the following figure, the Code Analyzer is displaying the issues found in the a.out binary.