📄 gprof.texi
字号:
@itemx --exec-counts[=@var{symspec}]The @samp{-C} option causes @code{gprof} toprint a tally of functions and the number of times each was called.If @var{symspec} is specified, print tally only for matching symbols.If the profile data file contains basic-block count records, specifyingthe @samp{-l} option, along with @samp{-C}, will cause basic-blockexecution counts to be tallied and displayed.@item -i@itemx --file-infoThe @samp{-i} option causes @code{gprof} to display summary informationabout the profile data file(s) and then exit. The number of histogram,call graph, and basic-block count records is displayed.@item -I @var{dirs}@itemx --directory-path=@var{dirs}The @samp{-I} option specifies a list of search directories inwhich to find source files. Environment variable @var{GPROF_PATH}can also be used to convey this information.Used mostly for annotated source output.@item -J[@var{symspec}]@itemx --no-annotated-source[=@var{symspec}]The @samp{-J} option causes @code{gprof} not toprint annotated source code.If @var{symspec} is specified, @code{gprof} prints annotated source,but excludes matching symbols.@item -L@itemx --print-pathNormally, source filenames are printed with the pathcomponent suppressed. The @samp{-L} option causes @code{gprof}to print the full pathname ofsource filenames, which is determinedfrom symbolic debugging information in the image fileand is relative to the directory in which the compilerwas invoked.@item -p[@var{symspec}]@itemx --flat-profile[=@var{symspec}]The @samp{-p} option causes @code{gprof} to print a flat profile.If @var{symspec} is specified, print flat profile only for matching symbols.@xref{Flat Profile}.@item -P[@var{symspec}]@itemx --no-flat-profile[=@var{symspec}]The @samp{-P} option causes @code{gprof} to suppress printing a flat profile.If @var{symspec} is specified, @code{gprof} prints a flat profile,but excludes matching symbols.@item -q[@var{symspec}]@itemx --graph[=@var{symspec}]The @samp{-q} option causes @code{gprof} to print the call graph analysis.If @var{symspec} is specified, print call graph only for matching symbolsand their children.@xref{Call Graph}.@item -Q[@var{symspec}]@itemx --no-graph[=@var{symspec}]The @samp{-Q} option causes @code{gprof} to suppress printing thecall graph.If @var{symspec} is specified, @code{gprof} prints a call graph,but excludes matching symbols.@item -y@itemx --separate-filesThis option affects annotated source output only.Normally, @code{gprof} prints annotated source filesto standard-output. If this option is specified,annotated source for a file named @file{path/@var{filename}}is generated in the file @file{@var{filename}-ann}. If the underlyingfilesystem would truncate @file{@var{filename}-ann} so that itoverwrites the original @file{@var{filename}}, @code{gprof} generatesannotated source in the file @file{@var{filename}.ann} instead (if theoriginal file name has an extension, that extension is @emph{replaced}with @file{.ann}).@item -Z[@var{symspec}]@itemx --no-exec-counts[=@var{symspec}]The @samp{-Z} option causes @code{gprof} not toprint a tally of functions and the number of times each was called.If @var{symspec} is specified, print tally, but exclude matching symbols.@item --function-orderingThe @samp{--function-ordering} option causes @code{gprof} to print asuggested function ordering for the program based on profiling data.This option suggests an ordering which may improve paging, tlb andcache behavior for the program on systems which support arbitraryordering of functions in an executable.The exact details of how to force the linker to place functionsin a particular order is system dependent and out of the scope of thismanual.@item --file-ordering @var{map_file}The @samp{--file-ordering} option causes @code{gprof} to print asuggested .o link line ordering for the program based on profiling data.This option suggests an ordering which may improve paging, tlb andcache behavior for the program on systems which do not support arbitraryordering of functions in an executable.Use of the @samp{-a} argument is highly recommended with this option.The @var{map_file} argument is a pathname to a file which providesfunction name to object file mappings. The format of the file is similar tothe output of the program @code{nm}.@smallexample@groupc-parse.o:00000000 T yyparsec-parse.o:00000004 C yyerrflagc-lang.o:00000000 T maybe_objc_method_namec-lang.o:00000000 T print_lang_statisticsc-lang.o:00000000 T recognize_objc_keywordc-decl.o:00000000 T print_lang_identifierc-decl.o:00000000 T print_lang_type@dots{}@end group@end smallexampleTo create a @var{map_file} with @sc{gnu} @code{nm}, type a command like@kbd{nm --extern-only --defined-only -v --print-file-name program-name}.@item -T@itemx --traditionalThe @samp{-T} option causes @code{gprof} to print its output in``traditional'' BSD style.@item -w @var{width}@itemx --width=@var{width}Sets width of output lines to @var{width}.Currently only used when printing the function index at the bottomof the call graph.@item -x@itemx --all-linesThis option affects annotated source output only.By default, only the lines at the beginning of a basic-blockare annotated. If this option is specified, every line ina basic-block is annotated by repeating the annotation for thefirst line. This behavior is similar to @code{tcov}'s @samp{-a}.@item --demangle[=@var{style}]@itemx --no-demangleThese options control whether C++ symbol names should be demangled whenprinting output. The default is to demangle symbols. The@code{--no-demangle} option may be used 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.@end table@node Analysis Options,Miscellaneous Options,Output Options,Invoking@section Analysis Options@table @code@item -a@itemx --no-staticThe @samp{-a} option causes @code{gprof} to suppress the printing ofstatically declared (private) functions. (These are functions whosenames are not listed as global, and which are not visible outside thefile/function/block where they were defined.) Time spent in thesefunctions, calls to/from them, etc, will all be attributed to thefunction that was loaded directly before it in the executable file.@c This is compatible with Unix @code{gprof}, but a bad idea. This option affects both the flat profile and the call graph.@item -c@itemx --static-call-graphThe @samp{-c} option causes the call graph of the program to beaugmented by a heuristic which examines the text space of the objectfile and identifies function calls in the binary machine code.Since normal call graph records are only generated when functions areentered, this option identifies children that could have been called,but never were. Calls to functions that were not compiled withprofiling enabled are also identified, but only if symbol tableentries are present for them.Calls to dynamic library routines are typically @emph{not} foundby this option.Parents or children identified via this heuristicare indicated in the call graph with call counts of @samp{0}.@item -D@itemx --ignore-non-functionsThe @samp{-D} option causes @code{gprof} to ignore symbols whichare not known to be functions. This option will give more accurateprofile data on systems where it is supported (Solaris and HPUX forexample).@item -k @var{from}/@var{to}The @samp{-k} option allows you to delete from the call graph any arcs fromsymbols matching symspec @var{from} to those matching symspec @var{to}.@item -l@itemx --lineThe @samp{-l} option enables line-by-line profiling, which causeshistogram 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 ofcode was executed.While line-by-line profiling can help isolate where in a large functiona program is spending its time, it also significantly increasesthe running time of @code{gprof}, and magnifies statisticalinaccuracies.@xref{Sampling Error}.@item -m @var{num}@itemx --min-count=@var{num}This option affects execution count output only.Symbols that are executed less than @var{num} times are suppressed.@item -n[@var{symspec}]@itemx --time[=@var{symspec}]The @samp{-n} option causes @code{gprof}, in its call graph analysis,to only propagate times for symbols matching @var{symspec}.@item -N[@var{symspec}]@itemx --no-time[=@var{symspec}]The @samp{-n} option causes @code{gprof}, in its call graph analysis,not to propagate times for symbols matching @var{symspec}.@item -z@itemx --display-unused-functionsIf you give the @samp{-z} option, @code{gprof} will mention allfunctions in the flat profile, even those that were never called, andthat had no time spent in them. This is useful in conjunction with the@samp{-c} option for discovering which routines were never called.@end table@node Miscellaneous Options,Deprecated Options,Analysis Options,Invoking@section Miscellaneous Options@table @code@item -d[@var{num}]@itemx --debug[=@var{num}]The @samp{-d @var{num}} option specifies debugging options.If @var{num} is not specified, enable all debugging.@xref{Debugging}.@item -O@var{name}@itemx --file-format=@var{name}Selects the format of the profile data files. Recognized formats are@samp{auto} (the default), @samp{bsd}, @samp{4.4bsd}, @samp{magic}, and@samp{prof} (not yet supported).@item -s@itemx --sumThe @samp{-s} option causes @code{gprof} to summarize the informationin the profile data files it read in, and write out a profile datafile called @file{gmon.sum}, which contains all the information fromthe profile data files that @code{gprof} read in. The file @file{gmon.sum}may be one of the specified input files; the effect of this is tomerge the data in the other input files into @file{gmon.sum}.Eventually you can run @code{gprof} again without @samp{-s} to analyze thecumulative data in the file @file{gmon.sum}.@item -v@itemx --versionThe @samp{-v} flag causes @code{gprof} to print the current versionnumber, and then exit.@end table@node Deprecated Options,Symspecs,Miscellaneous Options,Invoking@section Deprecated Options@table @codeThese options have been replaced with newer versions that use symspecs.@item -e @var{function_name}The @samp{-e @var{function}} option tells @code{gprof} to not printinformation about the function @var{function_name} (and itschildren@dots{}) in the call graph. The function will still be listedas a child of any functions that call it, but its index number will beshown as @samp{[not printed]}. More than one @samp{-e} option may begiven; only one @var{function_name} may be indicated with each @samp{-e}option. @item -E @var{function_name}The @code{-E @var{function}} option works like the @code{-e} option, buttime spent in the function (and children who were not called fromanywhere else), will not be used to compute the percentages-of-time forthe call graph. More than one @samp{-E} option may be given; only one@var{function_name} may be indicated with each @samp{-E} option.@item -f @var{function_name}The @samp{-f @var{function}} option causes @code{gprof} to limit thecall graph to the function @var{function_name} and its children (andtheir children@dots{}). More than one @samp{-f} option may be given;only one @var{function_name} may be indicated with each @samp{-f}option. @item -F @var{function_name}The @samp{-F @var{function}} option works like the @code{-f} option, butonly time spent in the function and its children (and theirchildren@dots{}) will be used to determine total-time andpercentages-of-time for the call graph. More than one @samp{-F} optionmay be given; only one @var{function_name} may be indicated with each@samp{-F} option. The @samp{-F} option overrides the @samp{-E} option.@end tableNote that only one function can be specified with each @code{-e},@code{-E}, @code{-f} or @code{-F} option. To specify more than onefunction, use multiple options. For example, this command:@examplegprof -e boring -f foo -f bar myprogram > gprof.output@end example@noindentlists in the call graph all functions that were reached from either@code{foo} or @code{bar} and were not reachable from @code{boring}.@node Symspecs,,Deprecated Options,Invoking@section SymspecsMany of the output options allow functions to be included or excludedusing @dfn{symspecs} (symbol specifications), which observe the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -