Go to main content
Oracle® Developer Studio 12.6: Code Analyzer User's Guide

Exit Print View

Updated: June 2017
 
 

Collecting Dynamic Memory Access Data

Collecting dynamic memory access data on your C or C++ program is a two-step process: instrumenting the binary with discover and then running the instrumented binary.

To instrument your program with discover to collect data for Code Analyzer, you must have compiled the program with Oracle Solaris Studio version 12.3 or 12.4, or Oracle Developer Studio version 12.5 or 12.6 C or C++ compiler. Compiling with the –g option generates debug information that enables Code Analyzer to display source code and line number information for dynamic memory access errors and warnings.

discover provides the most complete detection of memory errors at the source code level if you compile your program without optimization. If you compile with optimization, some memory errors will not be detected.

For information about specific types of binaries that Discover can or cannot instrument, see Supported Binaries in Oracle Developer Studio 12.6: Discover and Uncover User’s Guide and Binaries That Use Preloading or Auditing Are Incompatible in Oracle Developer Studio 12.6: Discover and Uncover User’s Guide.


Note -  You can build your program once for use with both discover and uncover. However, because you cannot instrument a binary that is already instrumented, if you are also planning to use uncover to collect coverage data, save a copy of the binary for this purpose before instrumenting it with discover. For example:
% cp a.out a.out.save

How to Collect Dynamic Memory Access Data From the Binary:

  1. Instrument the binary with Discover using the –a option:
    % discover -a binary_name

    Note -  You must use the version of discover in Oracle Solaris Studio version 12.3 or 12.4 or Oracle Developer Studio version 12.5 or 12.6. The –a option is not available in earlier versions of discover.
  2. Run the instrumented binary.

    The dynamic memory access data is written to the dynamic subdirectory in the binary_name.analyze directory.


    Note -  For additional instrumentation options you can specify when instrumenting the binary with discover, see Instrumentation Options in Oracle Developer Studio 12.6: Discover and Uncover User’s Guide or the discover man page.
  3. (Optional) Start Code Analyzer's GUI or the command-line tool (codean) to analyze and display the data, along with any static code data you might have previously collected. Or, you can use an uninstrumented copy of the binary to collect code coverage data.