HP UX Web Development Tools manual Using the Program Database PDB

Page 19

3 Using the Program Database (PDB)

The PDB is a repository of errors, warnings, diagnostic messages, and metrics generated while analyzing the application. The HP Code Advisor uses the PDB also to store the information required for the analysis. If you want to perform cross-file analysis of the application, you need to use a PDB. During the compilation phase of your application, the HP Code Advisor stores an intermediate representation of the application in the PDB and uses it during the application link phase to perform the cross-file analysis. You can use the reporting tool to see different kinds of reports from the information stored in the PDB without having to repeat the analysis phase. A single PDB can be used to store the analysis information of multiple applications. In such cases, the cross-file analysis for each application is performed when cadvise is invoked with the link command for each application.

NOTE: This does not work with the -crossfile=pdboption. Instead, the analysis logs are combined into a single report when cadvise report is used on such a PDB.

The size of the PDB is proportional to the total size of the object files created while building the application. It also depends on the number of errors and the diagnostic messages found during the analysis of the application. The size of the PDB can be three to four times more than the total size of the object files. Therefore, ensure that there is enough space in the volume or the ClearCase VOB where the PDB resides. You can also locate the PDB within a ClearCase VOB. The ClearMake dependency checking and wink-in mechanisms work with the PDB in the VOB. If the PDB is created in a View, then it is winked-in by other Views that have the matching configuration spec and build rules.

NOTE: Due to limitations in ClearCase, cadvise cannot access a PDB located on a clearcase VOB via a NFS mounted directory from a non-ClearCase machine. If you access the VOB from a non-ClearCase machine, ensure that the PDB is located on a local file system or use the -pdb_no_lockingoption. For more information, see the Problems with NFS locking section in Administrator's Guide: Rational Clearcase and Rational Clearcase LT.

The internal format of the PDB has been changed in preparation for creating PDBs in other platforms. This means that this version of cadvise is not compatible with PDBs generated by older versions of cadvise. As an example, users cannot use this version of cadvise to generate reports on PDBs generated by previous versions of cadvise. Ensure you remove the older PDBs with the-pdb_destroyoption (cadvise -pdb <location> -pdb_destroy) before you use this version of cadvise. Alternately, you can use a different location for the PDBs generated with this newer version of Cadvise. One of the following errors appear if you use Cadvise with an incompatible PDB:

cannot open PDB collection "<name>" (Error: Incompatible PDB version)

cannot open PDB element "<name>" (Error: Incompatible PDB version)

found problem while traversing PDB (Error: Incompatible PDB version)

NOTE: We try to make changes to the PDB format in a way that preserves forward compatibility

(ie: a PDB generated by an older version of cadvise can be used by a new version of cadvise). However, it is not guaranteed that all the format changes will be forward compatible. In some cases we are forced to break such forward compatibility in order to support new features.

The organization and the internal format of the PDB may change from release to release. Hence, it is not advisable to directly manipulate the content of the PDB. However, the PDB can be safely copied to different directory by using a recursive copy command (cp –R).

19

Image 19
Contents HP Code Advisor C.02.20 User Guide Page Contents Contents Related information Document conventions and symbolsAbout this document Intended audienceCadvise-help@lists.hp.com HP encourages your commentsCadvise user interface FeaturesCadvise user interface Features Introduction$ cadvise cc -c hello.c Advanced static code analysis$ cadvise -pdb ./mypdb +wlint aCC hello.cpp Supported compilersGetting started Using CadviseSteps in using cadvise Supported platforms Installing CadviseInvoking Cadvise Integrating Cadvise with the makefiles and build process Using Cadvise as a wrapper around Compiler or LinkerFor information on PDB, see Using the Program Database PDB See the following makefile contentGenerating code complexity metrics Enabling different categories of diagnostic messagesExample 2 Sample wrapper script Objfile.metrics Example 3 Generating code complexity metricsGenerating code complexity metrics $ cat /tmp/example.c Example 4 Code complexity metrics+wcodeguide=rules-library Example 5 Writing a rule to enforce naming convention Source structure in the rules libraryUsing the Program Database PDB Disabling locks in PDB operations PDB options tableSpecifying the PDB location Deleting PDBExample 9 Creating a PDB snapshot Creating a PDB snapshot at a specified locationDisplaying PDB version Example 8 Removing object file information from the PDBUsage Using cross-file analysisCross-file analysis options Crossfile=auto Example 15 Specifying the location of object files Enabling warnings selectively Configuring diagnostic messagesDiagnostic configuration options table Suppressing warnings selectivelyDisabling warnings in a macro Interpreting selective warnings as errorsManaging warnings in a source file Cadvise report report-options logfile Generating reportsReport generation options table Cadvise report report-options -pdb pdbdir$cadvise report -summary -pdb testpdb -noheader Generating summary reportsGenerating file summary report Generating detailed report$ cadvise report -pdb testpdb -all To save reports, run the following commandGenerating Html report Example 23 Generating detailed reportExample 24 Generating an XML report Printing diagnostics with specific diagnostic numbersFollowing example shows the command to generate XML report Generating XML reportExample 26 Generating reports based on severity Suppressing diagnostics for specific filesGenerating reports based on severity $ cadvise report -pdb testpdb -diag$ cadvise report -pdb test.pdb -summary -include inflate.c Reporting diagnostics from specific filesReporting program complexity metrics $ cadvise report -pdb test.pdb -summary -exclude inflate.cExample 29 Reporting program complexity metrics Generating report for a module$ cadvise report -pdb gzip.pdb +metrics -include inflate.c $ cadvise report -pdb test.pdb -summary -module test1 Modifying the default severity level of a diagnosticSuppressing report header Generating PDB comparison report$ cadvise report -pdb tmp.pdb -basepdb tmp1.pdb -all Example 34 Generating detailed diff report with the header$ cadvise report -pdb tmp.pdb -basepdb tmp1.pdb -diag Example 35 Generating diff report for any particular warning$ cadvise -pdb pdb1 cc one.c two.c $ cadvise report -pdb tmp.pdb -basepdb tmp1.pdb -severity$ cadvise report -pdb new.pdb -basepdb old.pdb -all Report options fileExample 41 Report options file Example 42 Generating a report using -migration optionGenerate report for migration related warnings Generating consolidated report from multiple PDBs$ cadvise report -pdb 1.pdb2.pdb3.pdb4.pdb -all Recommended process for analyzing the diagnostic messagesGenerating PDB diffs with multiple PDBs Report options interoperability$ cadvise report -pdb test.pdb -summary -include a.cb.c Example 44 Reporting options interoperability$ cadvise report -pdb test.pdb -diag 2549 -exclude b.c Example 45 Ignoring the -includeoptionExample 47 Displaying the list of cadvise options Example 48 Using -noabortMiscellaneous driver options Help-h-HFollowing example shows the usage of -nobuildoption Example 49 Using -nobuild optionFollowing command creates the file cadvdir/foo.cad Example 51 Using -tee optionLine generates the following messages Example 52 Using +opts filename optionCategories of diagnostics table Categories of diagnostics with examplesDetecting generic programming errors Categories of diagnostics with examples Such cases, cadvise generates the following warning Example 53 Null pointer dereference checkSuch cases, cadvise generates the following warnings Example 54 Potential memory leak checkExample 56 Out of scope access Example 55 Out of bound accessExample 57 Use of pointer after free Such cases, cadvise generates the following errorExample 58 Allocator/deallocator mismatch Example 59 Signed bit field of length Detecting 32-bit to 64-bit migraton issuesDetecting endianness migration issues Example 60 Detecting 32-bit to 64-bit migraton issuesExample 61 Detecting endian dependent code fragments Detecting potential security vulnerabilitiesConsider the following code fragment This case, cadvise generates the following error Detecting multi-threaded programming issuesRunning 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 AC++ standard conformance and compatibility changes Incompatibilities on PA-RISC based systemsIndex Symbols