Chapter 4. GCC Command Options
-p
Generate extra code to write profile information suitable for the analysis program
must use this option when compiling the source files you want data about, and you must also use
it when linking.
-pg
Generate extra code to write profile information suitable for the analysis program
must use this option when compiling the source files you want data about, and you must also use
it when linking.
-Q
Makes the compiler print out each function name as it is compiled, and print some statistics about
each pass when it finishes.
-ftime-report
Makes the compiler print some statistics about the time consumed by each pass when it finishes.
-fmem-report
Makes the compiler print some statistics about permanent memory allocation when it finishes.
-fprofile-arcs
Add code so that program flow arcs are instrumented. During execution the program records how
many times each branch and call is executed and how many times it is taken or returns. When
the compiled program exits it saves this data to a file called
The data may be used for profile-directed optimizations (
test coverage analysis (
name of the output file, if explicitly specified and it is not the final executable, otherwise it is the
basename of the source file. In both cases any suffix is removed (e.g.
, or
dir/foo.c
Compile the source files with
•
tions. For test coverage analysis, use the additional
need to profile every source file in a program.
Link your object files with
•
Run the program on a representative workload to generate the arc profile information. This
•
may be repeated any number of times. You can run concurrent instances of your program, and
provided that the file system supports locking, the data files will be correctly updated. Also
calls are detected and correctly handled (double counting will not happen).
fork
For profile-directed optimizations, compile the source files again with the same optimization
•
and code generation options plus
Control Optimization).
For test coverage analysis, use
•
and
files. Refer to the
.gcda
With
-fprofile-arcs
then finds a spanning tree for the graph. Only arcs that are not on the spanning tree have to be
instrumented: the compiler adds code to count the number of times that these arcs are executed.
When an arc is the only exit or only entrance to a block, the instrumentation code can be added
to the block; otherwise, a new basic block must be created to hold the instrumentation code.
-ftest-coverage
for output file specified as
dir/foo.gcda
-fprofile-arcs
-lgcov
gcov
gcov
, for each function of your program GCC creates a program flow graph,
). Each object file's
plus optimization and code generation op-
-ftest-coverage
or
-fprofile-arcs
-fbranch-probabilities
to produce human readable information from the
documentation for further information.
for each source file.
.gcda
auxname
-fbranch-probabilities
is generated from the
auxname
foo.gcda
).
-o dir/foo.o
option. You do not
(the latter implies the former).
(Section 4.10 Options That
47
. You
prof
. You
gprof
), or for
for input file
.gcno
Need help?
Do you have a question about the ENTERPRISE LINUX 4 and is the answer not in the manual?