Example 2 Sample wrapper script

$ cat cadvise_cc #!/bin/sh

#

#wrapper script to invoke cadvise

exec /opt/cadvise/bin/cadvise -pdb mypdb +wlint /opt/ansic/bin/cc "$@"

Now cadvise_cc can be used instead of cc in the build line to invoke cadvise analysis in addition to the compilation process.

NOTE: You need not create separate dependency rules for cadvise in the makefiles. Cadvise must be invoked only when the existing dependency rules in the makefile lead to a compile.

The addition of cadvise analysis to the build process increases the total build time. You can either invoke cadvise automatically whenever compiled, or launch cadvise as a separate build process by invoking it explicitly. For large projects where a lot of cross-file analysis is required, it is better to separate the analysis process. You can use the -crossfileoption to manage the cross-file analysis.

2.6 Enabling different categories of diagnostic messages

By default, a limited number of diagnostic messages are enabled in cadvise.

Additionally, the following options can be used to enable various types of diagnostic messages.

+w

Enables all the warnings about potentially questionable constructs in the

 

compiler.

+wall

Enables all the compile time checks.

“+wendian” (page 51)

Detects code fragments which are endian dependent.

“+wlint” (page 45)

Provides compile-time diagnostics which detect potential errors in the source

 

code.

“+wlock” (page 53)

Detects multi-threaded programming issues.

“+wsecurity[=1234]” (page 52) Enables compile time diagnostic messages for potential security vulnerabilities.

“+w64bit ” (page 51)

Enables warnings that help detection of potential problems in converting 32-bit

 

applications to 64-bit.

“+wperfadvice[=1234]

Generates performance advisory diagnostics.

” (page 54)

 

The best method is to use +wall to enable all possible diagnostic messages. Then, use the cadvise report -pdb <pdbname> -summarycommand to see a quick summary of the various diagnostic messages generated by cadvise, sorted by severity. For more information, see Generating Reports (page 27).

2.7 Generating code complexity metrics

Cadvise can generate code complexity metrics to gauge the complexity of the code being developed or migrated. The +metrics option generates program complexity metrics.

Syntax:

$cadvise +metrics[=ict][:out=pdb]

OR

$cadvise +metrics[=ict][:out=[+]<filename>]

Following command shows the examples for generating code complexity metrics.

2.6 Enabling different categories of diagnostic messages

13

Page 13
Image 13
HP UX Web Development Tools manual Enabling different categories of diagnostic messages, Generating code complexity metrics