Skip Navigation Links | |
Exit Print View | |
Oracle Solaris Studio 12.3 Code Analyzer User's Guide Oracle Solaris Studio 12.3 Information Library |
2. Collecting Data And Starting the Code Analyzer
Collecting Dynamic Memory Access Data
Starting the Code Analyzer GUI
To collect static error data on your C or C++ program, compile the program using the Oracle Solaris Studio 12.3 C or C++ compiler with the -xanalyze=code option. (The -xanalyze=code option is not available in the compilers in previous releases of Oracle Solaris Studio.) When you use this option, the compiler automatically extracts static errors and writes the data to the static subdirectory in the binary_name.analyze directory.
If you compile your program with the -xanalyze=code option and then link it in a separate step, you also need to include the -xanalyze=code option on the link step.
The compilers cannot detect all of the static errors in your code.
Some errors depend on data that is available only at runtime. For example, given the following code, the compiler would not detect an ABW (beyond Array Bounds Write) error, because it could not detect that the value of ix, read from a file, lies outside the range [0,9]:
void f(int fd, int array[10]) { int ix; read(fd, &ix, sizeof(ix)); array[ix] = 0; }
Some errors are ambiguous, that is, they might be real errors in your code, but they also might not be. The compiler does not report these errors.
Some complex errors are not detected by the compilers in this release.
After collecting static error data, you can start the Code Analyzer GUI to analyze and display the data (see Starting the Code Analyzer GUI) or recompile the program so that you can collect dynamic memory access or code coverage data.