You can call the gprof
tool as follows:
$ gprof my_prog gmon.out
or simply:
$ gprof my_prog
The complete form of the gprof
command line is the following:
$ gprof [switches] [executable [data-file]]
gprof
supports numerous switches, whose order does not matter. You
can find the full list of switches in the GNU Profiler User’s Guide.
The following are the most relevant of those switches:
--demangle[=`style']
, --no-demangle
These switches control whether symbol names should be demangled when
printing output. The default is to demangle C++ symbols. You can use
--no-demangle
to turn off demangling. Different
compilers have different mangling styles. The optional demangling style
argument can be used to choose an appropriate demangling style for your
compiler, in particular Ada symbols generated by GNAT can be demangled using
--demangle=gnat
.
-e `function_name'
The -e `function'
option tells gprof
not to print
information about the function function_name
and its
children in the call graph. The function will still be listed
as a child of any functions that call it, but its index number will be
shown as [not printed]
. You may specify more than one -e
switch,
but you may only include one function_name
with each -e
switch.
-E `function_name'
The -E `function'
switch works like the -e
switch, but
execution time spent in the function (and children who were not called from
anywhere else) will not be used to compute the percentages-of-time for
the call graph. You may specify more than one -E
switch, but
you may only include one function_name
with each -E
switch.
-f `function_name'
The -f `function'
switch causes gprof
to limit the
call graph to the function function_name
and its children and
their children. You may specify more than one -f
switch,
but you may only include one function_name
with each -f
switch.
-F `function_name'
The -F `function'
switch works like the -f
switch, but
only time spent in the function and its children and their
children will be used to determine total-time and
percentages-of-time for the call graph. You may specify more than one
-F
switch, but you may include only one function_name
with each
-F
switch. The -F
switch overrides the -E
switch.