Code profiler (GNU)
gprof_variant options [executable [data-files...]] [> outfile]
The gprof_variant depends on the target platform, as follows:
|All targets, plus native
These options specify gprof's output format.
Many of these options take an optional symspec to specify functions to
be included or excluded. These options can be specified multiple
times, with different symspecs, to include or exclude sets of
symbols. For more information, see the gprof documentation
at the GNU website
Specifying any of these options overrides the default
(-p -q), which prints a flat profile and
call graph analysis for all functions.
- -A[symspec] or --annotated-source[=symspec]
- Print annotated source code. If symspec is specified,
print output only for matching symbols.
- -b or --brief
- Don't print the verbose explanations for all table fields.
- -C[symspec] or --exec-counts[=symspec]
- Print a tally of functions and the number of times each was
called. If symspec is specified, print the tally only
for matching symbols. If the profile data file contains
basic-block count records, specifying the -l option with
-C will tally and display basic-block execution counts.
- Demangle C++ symbol names.
- --file-ordering map_file
- Print a suggested .o link line ordering for the
program based on profiling data. This option suggests an ordering
which might improve paging, TLB and cache behavior for the program
on systems that don't support arbitrary ordering of functions in
an executable. Use of the -a argument is highly
recommended with this option. The map_file argument is
a pathname to a file providing function name to object file
mappings. The format of the file is similar to the output of the
c-parse.o:00000000 T yyparse
c-parse.o:00000004 C yyerrflag
c-lang.o:00000000 T maybe_objc_method_name
c-lang.o:00000000 T print_lang_statistics
c-lang.o:00000000 T recognize_objc_keyword
c-decl.o:00000000 T print_lang_identifier
c-decl.o:00000000 T print_lang_type
The GNU nm --extern-only
--print-file-name can be used to create
- Print a suggested function ordering for the program based on the
profiling data. This option suggests an ordering which might
improve paging, TLB and cache behavior for the program on systems
that support arbitrary ordering of functions in an executable. The
exact details of how to force the linker to place functions in a
particular order is system dependent and out of the scope of this
- -i or --file-info
- Display the number of histogram, call graph, and basic-block count
records in the profile data file(s), then exit.
- -I dirs or --directory-path=dirs
- Specify a list of search directories for finding source files. The
GPROF_PATH environment variable can also be used to
specify the list of search directories.
- -J[symspec] or --no-annotated-source[=symspec]
- Don't print annotated source code. If symspec is
specified, print annotated source, but exclude matching symbols.
- -L or --print-path
- Print the full pathname of source filenames, which is determined
from symbolic debugging information in the image file and is
relative to the directory the compiler was invoked from.
- Don't demangle C++ symbol names.
- -p[symspec] or --flat-profile[=symspec]
- Print a flat profile. If symspec is specified, print
the flat profile only for matching symbols.
- -P[symspec] or --no-flat-profile[=symspec]
- Don't suppress print a flat profile. If symspec is
specified, gprof prints a flat profile but excludes matching
- -q[symspec] or --graph[=symspec]
- Print the call graph analysis. If symspec is specified,
print the call graph only for matching symbols and their children.
- -Q[symspec] or --no-graph[=symspec]
- Don't print the call graph. If symspec is specified,
print the call graph but excludes matching symbols.
- -T or --traditional
- Print gprof output in "traditional" BSD
- -w width or --width=width
- Set the width of output lines to width characters. Only
used when printing the function index at the bottom of the call
- -x or --all-lines
- When printing annotated source, annotate every line in a
basic-block by repeating the annotation for the first line.
- -y or --separate-files
- If generating annotated source, write the annotated source for
filename to filename-ann.
- -Z[symspec] or --no-exec-counts[=symspec]
- Don't print a tally of functions and the number of times each was
called. If symspec is specified, print the tally but
exclude matching symbols.
- -a or --no-static
- Don't print statically declared (private) functions. Time spent in
these functions, calls to/from them, etc., will all be attributed
to the function that was loaded directly before it in the
executable file. This option affects the flat profile and the
- -c or --static-call-graph
- Augment the call graph by a heuristic which examines the text
space of the object file and identifies function calls in the
binary machine code. Since normal call graph records are only
generated when functions are entered, this option identifies
children that could have been called, but never were. Calls to
functions that were not compiled with profiling enabled are also
identified, but only if symbol table entries are present for
them. Calls to dynamic library routines are typically not found by
this option. Parents or children identified via this heuristic are
indicated in the call graph with call counts of 0.
- -D or --ignore-non-functions
- Ignore symbols which are not known to be functions. This option
will give more accurate profile data.
- -k from/to
- Delete any arcs from symbols matching symspec from to
those matching symspec to when generating the call
- -l or --line
- Enable line-by-line profiling, which causes histogram hits to be
charged to individual source code lines, instead of functions. If
the program was compiled with basic-block counting enabled, this
option will also identify how many times each line of code was
executed. While line-by-line profiling can help isolate where in a
large function a program is spending its time, it also
significantly increases gprof's running time, and
magnifies statistical inaccuracies.
- -m num or --min-count=num
- Suppress symbols that are executed less than num times
in execution count output.
- -n[symspec] or --time[=symspec]
- Only propagate times for symbols matching symspec in
the call graph analysis.
- -N[symspec] or --no-time[=symspec]
- Don't propagate times for symbols matching symspec in
the call graph analysis.
- -z or --display-unused-functions
- Mention all functions in the flat profile, even those that were
never called, and that had no time spent in them. This is useful
in conjunction with the -c option for discovering which
routines were never called.
- -d[num] or --debug[=num]
- Specify debugging options. If num is not specified,
enable all debugging.
- -Oname or --file-format=name
- Specify the profile data file format. name can be
auto (the default), bsd, magic,
- -s or --sum
- Summarize the information in the specified profile data files and
write out a profile data file called gmon.sum,
which contains all the information from the profile data files
that gprof read. The gmon.sum file may
be one of the specified input files; the effect of this is to
merge the data in the other input files into the existing
gmon.sum. You can run gprof again to analyze
the cumulative data in the gmon.sum file.
- -v or --version
- Print the current version number and exit.
The gprof utility produces code-profiling data for an application
compiled with the -p option to
qcc (or the -pg
option to gcc). This data is
interpreted visually for you by the Application Profiler perspective
in the QNX Momentics IDE.
For detailed documentation about gprof, see the
the GNU website at
- not 0
- An error occurred.