User's Manual
The cadvise command has the following modes of operation:
• Analysis mode
Used to analyze and create the Program Database (PDB). To invoke cadvise in this mode,
enter the cadvise command in the following format:
cadvise [cadvise-options] compile-cmd [compile-options]
• Report mode
Used to create reports. To invoke cadvise in this mode, enter the cadvise command in the
following format:
cadvise report [report-options] [-pdb <pdb-name> | logfile]
For information on PDB, see Using the Program Database (PDB) (page 19).
The cadvise command is used as a wrapper around the compiler or linker. The cadvise
report option is used to generate reports.
2.4 Using Cadvise as a wrapper around Compiler or Linker
Cadvise is used with the HP C and HP aC++ compilers; GNU gcc and g++ compilers or HP-UX
linker. The cadvise command is used as a wrapper around the compile and link command-line
options (hereafter referred to as build line). The cadvise command and options are prefixed to
the build line as command line arguments.
For example
The following command lines show how to invoke cadvise:
Regular command line: $ cc -c abc.c def.c
Cadvise command line: $ cadvise -pdb mypdb +wlint cc -c abc.c def.c
$ cadvise -pdb mypdb +wlint cc -c abc.c def.c
$ cadvise -pdb mypdb +wlint ld -r abc.o def.o -o abcdef.o
The cadvise command first executes the user's regular build line, and then analyzes the source
code. Cadvise also analyzes the build line and automatically determines the include paths, defines,
and language dialect needed for the source code analysis. The -nobuild option allows you to
skip the regular build process, and perform only the source code analysis.
The result of the cadvise analysis can be stored in a program database using the -pdb option. In
this case, the PDB also stores the summary information used for cross-file analysis. For more
information on PDB, see Using the Program Database (PDB) (page 19).
2.5 Integrating Cadvise with the makefiles and build process
Cadvise can be easily integrated with the makefiles and the build scripts. If a makefile variable is
used to define the C and C++ compilers, you can redefine it to include the cadvise invocation.
Example 1 Updating the makefile to integrate cadvise
See the following makefile content:
CADVISE_OPTS= -pdb mypdb +wlint
CADVISE= /opt/cadvise/bin/cadvise
CC= $(CADVISE) $(CADVISE_OPTS) /opt/ansic/bin/cc
CXX= $(CADVISE) $(CADVISE_OPTS) /opt/aCC/bin/aCC
You may also define a wrapper script instead of the standard compiler commands. For example,
see the following sample wrapper script:
12 Using Cadvise