URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Subversion Repositories openrisc_me
[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.20.1/] [gprof/] [README] - Rev 205
Compare with Previous | Blame | View Log
README for GPROFThis is the GNU profiler. It is distributed with other "binaryutilities" which should be in ../binutils. See ../binutils/README formore general notes, including where to send bug reports.This file documents the changes and new features available with thisversion of GNU gprof.* New Featureso Long optionso Supports generalized file format, without breaking backward compatibility:new file format supports basic-block execution counts and non-realtimehistograms (see below)o Supports profiling at the line level: flat profiles, call-graph profiles,and execution-counts can all be displayed at a level that identifiesindividual lines rather than just functionso Test-coverage support (similar to Sun tcov program): source filescan be annotated with the number of times a function was invokedor with the number of times each basic-block in a function wasexecutedo Generalized histograms: not just execution-time, but arbitraryhistograms are support (for example, performance counter basedprofiles)o Powerful mechanism to select data to be included/excluded fromanalysis and/or outputo Support for DEC OSF/1 v3.0o Full cross-platform profiling support: gprof uses BFD to supportarbitrary, non-native object file formats and non-native byte-orders(this feature has not been tested yet)o In the call-graph function index, static function names are nowprinted together with the filename in which the function was defined(required bfd_find_nearest_line() support and symbolic debugginginformation to be present in the executable file)o Major overhaul of source code (compiles cleanly with -Wall, etc.)* Supported PlatformsThe current version is known to work on:o DEC OSF/1 v3.0All features supported.o SunOS 4.1.xAll features supported.o Solaris 2.3Line-level profiling unsupported because bfd_find_nearest_line()is not fully implemented for Elf binaries.o HP-UX 9.01Line-level profiling unsupported because bfd_find_nearest_line()is not fully implemented for SOM binaries.* Detailed Description** User Interface ChangesThe command-line interface is backwards compatible with earlierversions of GNU gprof and Berkeley gprof. The only exception isthe option to delete arcs from the call graph. The old syntaxwas:-k fromname tonamewhile the new syntax is:-k fromname/tonameThis change was necessary to be compatible with long-option parsing.Also, "fromname" and "toname" can now be arbitrary symspecs ratherthan just function names (see below for an explanation of symspecs).For example, option "-k gprof.c/" suppresses all arcs due to calls outof file "gprof.c".*** Sym SpecsIt is often necessary to apply gprof only to specific parts of aprogram. GNU gprof has a simple but powerful mechanism to achievethis. So called {\em symspecs\/} provide the foundation for thismechanism. A symspec selects the parts of a profiled program to whichan operation should be applied to. The syntax of a symspec issimple:filename_containing_a_dot| funcname_not_containing_a_dot| linenumber| ( [ any_filename ] `:' ( any_funcname | linenumber ) )Here are some examples:main.c Selects everything in file "main.c"---thedot in the string tells gprof to interpretthe string as a filename, rather than asa function name. To select a file whosename does contain a dot, a trailing colonshould be specified. For example, "odd:" isinterpreted as the file named "odd".main Selects all functions named "main". Noticethat there may be multiple instances of thesame function name because some of thedefinitions may be local (i.e., static).Unless a function name is unique in a program,you must use the colon notation explainedbelow to specify a function from a specificsource file. Sometimes, functionnames containdots. In such cases, it is necessary toadd a leading colon to the name. For example,":.mul" selects function ".mul".main.c:main Selects function "main" in file "main.c".main.c:134 Selects line 134 in file "main.c".IMPLEMENTATION NOTE: The source code uses the type sym_id for symspecs.At some point, this probably ought to be changed to "sym_spec" to makereading the code easier.*** Long optionsGNU gprof now supports long options. The following is a list of allsupported options. Options that are listed without descriptionoperate in the same manner as the corresponding option in olderversions of gprof.Short Form: Long Form:----------- -----------l --lineRequest profiling at the line-level ratherthan just at the function level. Sourcelines are identified by symbols of the form:func (file:line)where "func" is the function name, "file" is thefile name and "line" is the line-number thatcorresponds to the line.To work properly, the binary must contain symbolicdebugging information. This means that the sourcehave to be translated with option "-g" specified.Functions for which there is no symbolic debugginginformation available are treated as if "--line"had not been specified. However, the line numberprinted with such symbols is usually incorrectand should be ignored.-a --no-static-A[symspec] --annotated-source[=symspec]Request output in the form of annotated sourcefiles. If "symspec" is specified, print output onlyfor symbols selected by "symspec". If the optionis specified multiple times, annotated output isgenerated for the union of all symspecs.Examples:-A Prints annotated source for allsource files.-Agprof.c Prints annotated source for filegprof.c.-Afoobar Prints annotated source for filescontaining a function named "foobar".The entire file will be printed, butonly the function itself will beannotated with profile data.-J[symspec] --no-annotated-source[=symspec]Suppress annotated source output. If specifiedwithout argument, annotated output is suppressedcompletely. With an argument, annotated outputis suppressed only for the symbols selected by"symspec". If the option is specified multipletimes, annotated output is suppressed for theunion of all symspecs. This option has lowerprecedence than --annotated-source-p[symspec] --flat-profile[=symspec]Request output in the form of a flat profile(unless any other output-style option is specified,this option is turned on by default). If"symspec" is specified, include only symbolsselected by "symspec" in flat profile. If theoption is specified multiple times, the flatprofile includes symbols selected by the unionof all symspecs.-P[symspec] --no-flat-profile[=symspec]Suppress output in the flat profile. If givenwithout an argument, the flat profile is suppressedcompletely. If "symspec" is specified, suppressthe selected symbols in the flat profile. If theoption is specified multiple times, the union ofthe selected symbols is suppressed. This optionhas lower precedence than --flat-profile.-q[symspec] --graph[=symspec]Request output in the form of a call-graph(unless any other output-style option is specified,this option is turned on by default). If "symspec"is specified, include only symbols selected by"symspec" in the call-graph. If the option isspecified multiple times, the call-graph includessymbols selected by the union of all symspecs.-Q[symspec] --no-graph[=symspec]Suppress output in the call-graph. If given withoutan argument, the call-graph is suppressed completely.With a "symspec", suppress the selected symbolsfrom the call-graph. If the option is specifiedmultiple times, the union of the selected symbolsis suppressed. This option has lower precedencethan --graph.-C[symspec] --exec-counts[=symspec]Request output in the form of execution counts.If "symspec" is present, include only symbolsselected by "symspec" in the execution countlisting. If the option is specified multipletimes, the execution count listing includessymbols selected by the union of all symspecs.-Z[symspec] --no-exec-counts[=symspec]Suppress output in the execution count listing.If given without an argument, the listing issuppressed completely. With a "symspec", suppressthe selected symbols from the call-graph. If theoption is specified multiple times, the union ofthe selected symbols is suppressed. This optionhas lower precedence than --exec-counts.-i --file-infoPrint information about the profile files thatare read. The information consists of thenumber and types of records present in theprofile file. Currently, a profile file cancontain any number and any combination of histogram,call-graph, or basic-block count records.-s --sum-x --all-linesThis option affects annotated source output only.By default, only the lines at the beginning ofa basic-block are annotated. If this option isspecified, every line in a basic-block is annotatedby repeating the annotation for the first line.This option is identical to tcov's "-a".-I dirs --directory-path=dirsThis option affects annotated source output only.Specifies the list of directories to be searchedfor source files. The argument "dirs" is a colonseparated list of directories. By default, gprofsearches for source files relative to the currentworking directory only.-z --display-unused-functions-m num --min-count=numThis option affects annotated source and executioncount output only. Symbols that are executedless than "num" times are suppressed. For annotatedsource output, suppressed symbols are markedby five hash-marks (#####). In an execution countoutput, suppressed symbols do not appear at all.-L --print-pathNormally, source filenames are printed with the pathcomponent suppressed. With this option, gprofcan be forced to print the full pathname ofsource filenames. The full pathname is determinedfrom symbolic debugging information in the image fileand is relative to the directory in which the compilerwas invoked.-y --separate-filesThis option affects annotated source output only.Normally, gprof prints annotated source filesto standard-output. If this option is specified,annotated source for a file named "path/filename"is generated in the file "filename-ann". That is,annotated output is {\em always\/} generated ingprof's current working directory. Care has tobe taken if a program consists of files that haveidentical filenames, but distinct paths.-c --static-call-graph-t num --table-length=numThis option affects annotated source output only.After annotating a source file, gprof generatesan execution count summary consisting of a tableof lines with the top execution counts. Bydefault, this table is ten entries long.This option can be used to change the table lengthor, by specifying an argument value of 0, it can besuppressed completely.-n symspec --time=symspecOnly symbols selected by "symspec" are consideredin total and percentage time computations.However, this option does not affect percentage timecomputation for the flat profile.If the option is specified multiple times, the unionof all selected symbols is used in time computations.-N --no-time=symspecExclude the symbols selected by "symspec" fromtotal and percentage time computations.However, this option does not affect percentage timecomputation for the flat profile.This option is ignored if any --time options arespecified.-w num --width=numSets the output line width. Currently, this optionaffects the printing of the call-graph function indexonly.-e <no long form---for backwards compatibility only>-E <no long form---for backwards compatibility only>-f <no long form---for backwards compatibility only>-F <no long form---for backwards compatibility only>-k <no long form---for backwards compatibility only>-b --brief-dnum --debug[=num]-h --helpPrints a usage message.-O name --file-format=nameSelects the format of the profile data files.Recognized formats are "auto", "bsd", "magic",and "prof". The last one is not yet supported.Format "auto" attempts to detect the file formatautomatically (this is the default behavior).It attempts to read the profile data files as"magic" files and if this fails, falls back tothe "bsd" format. "bsd" forces gprof to readthe data files in the BSD format. "magic" forcesgprof to read the data files in the "magic" format.-T --traditional-v --version** File Format ChangesThe old BSD-derived format used for profile data does not contain amagic cookie that allows to check whether a data file really is agprof file. Furthermore, it does not provide a version number, thusrendering changes to the file format almost impossible. GNU gprofuses a new file format that provides these features. For backwardcompatibility, GNU gprof continues to support the old BSD-derivedformat, but not all features are supported with it. For example,basic-block execution counts cannot be accommodated by the old fileformat.The new file format is defined in header file \file{gmon_out.h}. Itconsists of a header containing the magic cookie and a version number,as well as some spare bytes available for future extensions. All datain a profile data file is in the native format of the host on whichthe profile was collected. GNU gprof adapts automatically to thebyte-order in use.In the new file format, the header is followed by a sequence ofrecords. Currently, there are three different record types: histogramrecords, call-graph arc records, and basic-block execution countrecords. Each file can contain any number of each record type. Whenreading a file, GNU gprof will ensure records of the same type arecompatible with each other and compute the union of all records. Forexample, for basic-block execution counts, the union is simply the sumof all execution counts for each basic-block.*** Histogram RecordsHistogram records consist of a header that is followed by an array ofbins. The header contains the text-segment range that the histogramspans, the size of the histogram in bytes (unlike in the old BSDformat, this does not include the size of the header), the rate of theprofiling clock, and the physical dimension that the bin countsrepresent after being scaled by the profiling clock rate. Thephysical dimension is specified in two parts: a long name of up to 15characters and a single character abbreviation. For example, ahistogram representing real-time would specify the long name as"seconds" and the abbreviation as "s". This feature is useful forarchitectures that support performance monitor hardware (which,fortunately, is becoming increasingly common). For example, under DECOSF/1, the "uprofile" command can be used to produce a histogram of,say, instruction cache misses. In this case, the dimension in thehistogram header could be set to "i-cache misses" and the abbreviationcould be set to "1" (because it is simply a count, not a physicaldimension). Also, the profiling rate would have to be set to 1 inthis case.Histogram bins are 16-bit numbers and each bin represent an equalamount of text-space. For example, if the text-segment is onethousand bytes long and if there are ten bins in the histogram, eachbin represents one hundred bytes.*** Call-Graph RecordsCall-graph records have a format that is identical to the one used inthe BSD-derived file format. It consists of an arc in the call graphand a count indicating the number of times the arc was traversedduring program execution. Arcs are specified by a pair of addresses:the first must be within caller's function and the second must bewithin the callee's function. When performing profiling at thefunction level, these addresses can point anywhere within therespective function. However, when profiling at the line-level, it isbetter if the addresses are as close to the call-site/entry-point aspossible. This will ensure that the line-level call-graph is able toidentify exactly which line of source code performed calls to afunction.*** Basic-Block Execution Count RecordsBasic-block execution count records consist of a header followed by asequence of address/count pairs. The header simply specifies thelength of the sequence. In an address/count pair, the addressidentifies a basic-block and the count specifies the number of timesthat basic-block was executed. Any address within the basic-address canbe used.IMPLEMENTATION NOTE: gcc -a can be used to instrument a program torecord basic-block execution counts. However, the __bb_exit_func()that is currently present in libgcc2.c does not generate a gmon.outfile in a suitable format. This should be fixed for future releasesof gcc. In the meantime, contact davidm@cs.arizona.edu for a versionof __bb_exit_func() to is appropriate.
