Cool Tools - Sun Memory Error Discovery Tool (Discover)
The Sun Memory Error Discovery Tool (Discover) is a tool used by software
developers to detect programming errors related to the allocation and
use of program memory at runtime on Sun Solaris® systems.
Examples of errors detected by Discover include:
-
Accessing uninitialized memory.
-
Reads from and writes to unallocated memory.
-
Accessing memory beyond allocated array bounds.
-
Use of freed memory.
-
Freeing wrong memory blocks.
-
Memory leaks.
NOTE:
Starting with Discover 1.1 (distributed with
GCC for Sun Systems release 4.2.0),
multi-threaded programs are supported.
Download and Install
Discover can be used with either the SunTM Studio 12 and newer
Compilers and Tools
or the GCC for Sun Systems compilers.
You should always use Discover from the same level of the Sun Studio Compilers and Tools.
For example, Discover from
CMT Developer Tools for Sun Studio 12 Update 1 should be
used on binaries built by Sun Studio 12 Update 1 Compilers and Tools.
Starting with CMT Developer Tools for Sun Studio 12 update 1, Discover(version 1.3)
is available on both SPARC and x64 platforms.
To use with
Sun Studio 12 Update 1 Compilers and Tools, please install
CMT Developer Tools for Sun Studio 12 Update 1.
To use with
Sun Studio 12 Compilers and Tools, please install
CMT Developer Tools for Sun Studio 12.
Starting with
GCC for Sun Systems release 4.0.4, Discover is already installed as part of the
distribution. It is invoked as <gcc-install-dir>/gcc/bin/discover.
The man page is <gcc-install-dir>/gcc/man/man1/discover.1.
Documents
Please see the man page
for a description of supported features. The man page is also supplied
with the download package.
More details about Discover can be found in the
Discover User's Guide.
Using Discover
Discover can work with the Sun Studio 12 and newer compilers for C, C++, and FORTRAN, as
well as the GCC for Sun Systems where Discover is part of the
distribution.
Please refer to the
User's Guide and man page
for detailed instructions on usage and data analysis. Below we provide a brief example of usage.
First, make sure the application you are testing is compiled with the ‑xannotate
option. On Solaris 10 Update 5 or higher, this option is turned on by default.
This will not change the executable code, but will make it possible for Discover
(and other Cool Tools) to postprocess the binary. (If you're using Sun Studio 12, you must
also compile with optimization using ‑O or ‑xO1 or above.)
We also strongly recommend the use of the ‑g option as it will facilitate error detection.
Once you have the
executable file ready, instrument it with command:
Now the target is modified for detecting memory errors. Run the binary
in your regular environment and Discover will report any encountered errors to stderr.
For example:
You can use instrumentation options to write the Discover report to a different file
or generate the report in HTML format.
A sample of HTML output can be found here.
The simplest way to generate an HTML report is to set
the DISCOVER_HTML environment variable in your shell
prior to running binary. For example, in the bash shell, simply say:
Alternatively, you can supply -H option at instrumentation time.
Please note that Discover will only report errors from code that is executed at
runtime. If the source code contains a memory error (e.g. uninitialized memory
use) that was not executed during the invocation of the program,
or if the compiler has
performed an optimization (e.g. dead code elimination) that deleted the code
for the erroneous source code statement, then the error will not be reported.
See the man page or the
Discover User's Guide
for details and more examples.
Known Issues
Because of the way libraries are instrumented at run time when using
discover, it is possible for its analysis to be incomplete, and in rare
instances program execution may be incorrect. See
this page for more information
and details on workarounds.
This issue has been fixed in Discover 1.1. However, in order for the fix
to be effective, the instrumented binary must be run on a machine with
one of the following operating systems:
- Solaris 10 Update 5
- Solaris 10 with
Patch 127111-07 installed
- Solaris 11 build 70 or above
Dependencies
On Solaris 9, Discover requires that
Patch 112963-14 for the SunOS 5.9 linker be
installed. Solaris 9 or later is required as a host OS at runtime.
Starting with Sun Studio 12 Update 1, the minimum OS requirement is Solaris 10
update 5. Consequently, minimum OS requirement for Discover 1.3 is also Solaris
10 update 5. It is also recommended that Sun Studio 12 Update 1
Patch 141860-02 (SPARC) or
Patch 141858-03 (x64) be installed for Discover 1.3.
Support
Discover is provided without support. However, a
CoolTools Forum
is available where questions and discussions about
installing, using, or improving Discover can be posted. Posting in the
forums does not guarantee a response.
Please send your feedback to:
.
|