HP UX Web Development Tools manual Using cross-file analysis, Usage, Cross-file analysis options

Page 22

4 Using cross-file analysis

Cadvise provides different operating modes for performing cross-file analysis of the application. The cross-file analysis can be performed along with the regular build of the application, or separated from the regular build. You can also initiate it either on all the files or only on a selected group of files or modules. It can also be disabled completely. The default and recommended mode is to enable cross-file analysis at link time. Cadvise fetches all the recorded information from the PDB for all the object files specified at the link command line and performs cross-file analysis.

Usage:

-crossfile = option

Table 3 Cross-file analysis options

Option

Description

none

Disables cross-file analysis. If a PDB location is specified using the –pdb

 

option, the logs of errors and the diagnostic messages found during the

 

compile time of the application are stored in the PDB.

auto

Directs the cross-file analysis to be automatically done at the link time of

 

the application. This is the default mode.

defer

Does not initiate the cross-file analysis at the link time of the application.

 

When you use this option, a PDB location must be specified using the –pdb

 

option. During the compile time of the application, logs and intermediate

 

representation files are stored in the PDB so that the cross-file analysis can

 

be initiated later with either of the

 

–crossfile=[pdbmodulelistlistfile] options.

pdb

Initiates cross-file analysis on all the intermediate representation files stored

 

in the PDB. When you use this option, a PDB location must be specified

 

using the –pdb option.

module:<module_name>

Enables cross-file analysis of object files in a PDB corresponding to a

 

particular module(shared library or executable). During the build, cadvise

 

records the list of files that make up the module. So, for cross-file analysis,you

 

can use the name of the module instead of specifying the list of object files.

list:<file1:file2:.. ..:fileN> Enables cross-file analysis of object files in a PDB corresponding to the listed object files. File1, File2,..., FileN are object files. For more information, see

 

.

listfile:<file_name>

Enables cross-file analysis of object files in a PDB corresponding to the

 

object files listed in the specified file. The list of object files in <file_name>

 

must be separated by space or newline characters. For more information,

 

see Example 15 (page 24).

The following examples illustrate the equivalent usage of different cross-file options to perform cross-file analysis:

22 Using cross-file analysis

Image 22
Contents HP Code Advisor C.02.20 User Guide Page Contents Contents Intended audience Document conventions and symbolsAbout this document Related informationHP encourages your comments Cadvise-help@lists.hp.comIntroduction FeaturesCadvise user interface Features Cadvise user interfaceAdvanced static code analysis $ cadvise cc -c hello.cSupported compilers $ cadvise -pdb ./mypdb +wlint aCC hello.cppSupported platforms Installing Cadvise Using CadviseSteps in using cadvise Getting startedInvoking Cadvise See the following makefile content Using Cadvise as a wrapper around Compiler or LinkerFor information on PDB, see Using the Program Database PDB Integrating Cadvise with the makefiles and build processGenerating code complexity metrics Enabling different categories of diagnostic messagesExample 2 Sample wrapper script Example 3 Generating code complexity metrics Objfile.metricsGenerating code complexity metrics Example 4 Code complexity metrics $ cat /tmp/example.c+wcodeguide=rules-library Source structure in the rules library Example 5 Writing a rule to enforce naming conventionUsing the Program Database PDB Deleting PDB PDB options tableSpecifying the PDB location Disabling locks in PDB operationsExample 8 Removing object file information from the PDB Creating a PDB snapshot at a specified locationDisplaying PDB version Example 9 Creating a PDB snapshotUsage Using cross-file analysisCross-file analysis options Crossfile=auto Example 15 Specifying the location of object files Suppressing warnings selectively Configuring diagnostic messagesDiagnostic configuration options table Enabling warnings selectivelyDisabling warnings in a macro Interpreting selective warnings as errorsManaging warnings in a source file Cadvise report report-options -pdb pdbdir Generating reportsReport generation options table Cadvise report report-options logfileGenerating detailed report Generating summary reportsGenerating file summary report $cadvise report -summary -pdb testpdb -noheaderExample 23 Generating detailed report To save reports, run the following commandGenerating Html report $ cadvise report -pdb testpdb -allGenerating XML report Printing diagnostics with specific diagnostic numbersFollowing example shows the command to generate XML report Example 24 Generating an XML report$ cadvise report -pdb testpdb -diag Suppressing diagnostics for specific filesGenerating reports based on severity Example 26 Generating reports based on severity$ cadvise report -pdb test.pdb -summary -exclude inflate.c Reporting diagnostics from specific filesReporting program complexity metrics $ cadvise report -pdb test.pdb -summary -include inflate.cExample 29 Reporting program complexity metrics Generating report for a module$ cadvise report -pdb gzip.pdb +metrics -include inflate.c Generating PDB comparison report Modifying the default severity level of a diagnosticSuppressing report header $ cadvise report -pdb test.pdb -summary -module test1Example 34 Generating detailed diff report with the header $ cadvise report -pdb tmp.pdb -basepdb tmp1.pdb -allExample 35 Generating diff report for any particular warning $ cadvise report -pdb tmp.pdb -basepdb tmp1.pdb -diag$ cadvise report -pdb tmp.pdb -basepdb tmp1.pdb -severity $ cadvise -pdb pdb1 cc one.c two.cReport options file $ cadvise report -pdb new.pdb -basepdb old.pdb -allGenerating consolidated report from multiple PDBs Example 42 Generating a report using -migration optionGenerate report for migration related warnings Example 41 Report options fileReport options interoperability Recommended process for analyzing the diagnostic messagesGenerating PDB diffs with multiple PDBs $ cadvise report -pdb 1.pdb2.pdb3.pdb4.pdb -allExample 45 Ignoring the -includeoption Example 44 Reporting options interoperability$ cadvise report -pdb test.pdb -diag 2549 -exclude b.c $ cadvise report -pdb test.pdb -summary -include a.cb.cHelp-h-H Example 48 Using -noabortMiscellaneous driver options Example 47 Displaying the list of cadvise optionsExample 51 Using -tee option Example 49 Using -nobuild optionFollowing command creates the file cadvdir/foo.cad Following example shows the usage of -nobuildoptionExample 52 Using +opts filename option Line generates the following messagesCategories of diagnostics table Categories of diagnostics with examplesDetecting generic programming errors Categories of diagnostics with examples Example 53 Null pointer dereference check Such cases, cadvise generates the following warningExample 54 Potential memory leak check Such cases, cadvise generates the following warningsExample 55 Out of bound access Example 56 Out of scope accessExample 57 Use of pointer after free Such cases, cadvise generates the following errorExample 58 Allocator/deallocator mismatch Example 60 Detecting 32-bit to 64-bit migraton issues Detecting 32-bit to 64-bit migraton issuesDetecting endianness migration issues Example 59 Signed bit field of lengthExample 61 Detecting endian dependent code fragments Detecting potential security vulnerabilitiesConsider the following code fragment Detecting multi-threaded programming issues This case, cadvise generates the following errorRunning cadvise generates the following error Example 63 Detecting multi-threaded programming issuesDetecting potential performance improvement opportunities Detecting potential performance improvement opportunities Fixing the warnings by source change Incompatibilities on PA-RISC based systems AC++ standard conformance and compatibility changesSymbols Index