19b50d902SRodney W. Grimes.\" Copyright (c) 1983, 1990, 1993 29b50d902SRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 39b50d902SRodney W. Grimes.\" 49b50d902SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 59b50d902SRodney W. Grimes.\" modification, are permitted provided that the following conditions 69b50d902SRodney W. Grimes.\" are met: 79b50d902SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 89b50d902SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 99b50d902SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 109b50d902SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 119b50d902SRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 12fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors 139b50d902SRodney W. Grimes.\" may be used to endorse or promote products derived from this software 149b50d902SRodney W. Grimes.\" without specific prior written permission. 159b50d902SRodney W. Grimes.\" 169b50d902SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 179b50d902SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 189b50d902SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 199b50d902SRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 209b50d902SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 219b50d902SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 229b50d902SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 239b50d902SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 249b50d902SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 259b50d902SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 269b50d902SRodney W. Grimes.\" SUCH DAMAGE. 279b50d902SRodney W. Grimes.\" 28*7acc357fSEdward Tomasz Napierala.Dd November 27, 2017 299b50d902SRodney W. Grimes.Dt GPROF 1 3062500372SRuslan Ermilov.Os 319b50d902SRodney W. Grimes.Sh NAME 329b50d902SRodney W. Grimes.Nm gprof 339b50d902SRodney W. Grimes.Nd display call graph profile data 349b50d902SRodney W. Grimes.Sh SYNOPSIS 358fe908efSRuslan Ermilov.Nm 36759dce33SRuslan Ermilov.Op Fl abKlLsuz 3797fa9b77SPhilippe Charnier.Op Fl C Ar count 3897fa9b77SPhilippe Charnier.Op Fl e Ar name 3997fa9b77SPhilippe Charnier.Op Fl E Ar name 4097fa9b77SPhilippe Charnier.Op Fl f Ar name 4197fa9b77SPhilippe Charnier.Op Fl F Ar name 428abea92cSRuslan Ermilov.Op Fl k Ar fromname toname 437e74cac4SJean-Marc Zucconi.Op Ar a.out Op Ar a.out.gmon ... 449b50d902SRodney W. Grimes.Sh DESCRIPTION 45e8937ba0SPhilippe CharnierThe 46e8937ba0SPhilippe Charnier.Nm 47e8937ba0SPhilippe Charnierutility produces an execution profile of C, Pascal, or Fortran77 programs. 489b50d902SRodney W. GrimesThe effect of called routines is incorporated in the profile of each caller. 499b50d902SRodney W. GrimesThe profile data is taken from the call graph profile file 507e74cac4SJean-Marc Zucconiwhich is created by programs that are compiled with the 519b50d902SRodney W. Grimes.Fl pg 529b50d902SRodney W. Grimesoption of 539b50d902SRodney W. Grimes.Xr cc 1 , 549b50d902SRodney W. Grimes.Xr pc 1 , 559b50d902SRodney W. Grimesand 569b50d902SRodney W. Grimes.Xr f77 1 . 579b50d902SRodney W. GrimesThe 589b50d902SRodney W. Grimes.Fl pg 599b50d902SRodney W. Grimesoption also links in versions of the library routines 609b50d902SRodney W. Grimesthat are compiled for profiling. 61fa7a1ab9SJens SchweikhardtBy convention these libraries have their name suffixed with 62fa7a1ab9SJens Schweikhardt.Pa _p , 636a3e8b0aSRuslan Ermilovi.e., the profiled version of 64fa7a1ab9SJens Schweikhardt.Pa libc.a 65fa7a1ab9SJens Schweikhardtis 66fa7a1ab9SJens Schweikhardt.Pa libc_p.a 67fa7a1ab9SJens Schweikhardtand if you specify libraries directly to the 68fa7a1ab9SJens Schweikhardtcompiler or linker you can use 69fa7a1ab9SJens Schweikhardt.Fl l Ns Ar c_p 70fa7a1ab9SJens Schweikhardtinstead of 71fa7a1ab9SJens Schweikhardt.Fl l Ns Ar c . 72e8937ba0SPhilippe CharnierRead the given object file (the default is 739b50d902SRodney W. Grimes.Pa a.out ) 745e75e35cSDima Dorfmanand establishes the relation between its symbol table 7587faa07bSSheldon Hearnand the call graph profile. 7687faa07bSSheldon HearnThe default graph profile file name is the name 777e74cac4SJean-Marc Zucconiof the executable with the suffix 787e74cac4SJean-Marc Zucconi.Pa .gmon 797e74cac4SJean-Marc Zucconiappended. 809b50d902SRodney W. GrimesIf more than one profile file is specified, 819b50d902SRodney W. Grimesthe 828fe908efSRuslan Ermilov.Nm 839b50d902SRodney W. Grimesoutput shows the sum of the profile information in the given profile files. 849b50d902SRodney W. Grimes.Pp 85e8937ba0SPhilippe CharnierThe 86e8937ba0SPhilippe Charnier.Nm 87e8937ba0SPhilippe Charnierutility calculates the amount of time spent in each routine. 889b50d902SRodney W. GrimesNext, these times are propagated along the edges of the call graph. 899b50d902SRodney W. GrimesCycles are discovered, and calls into a cycle are made to share the time 909b50d902SRodney W. Grimesof the cycle. 919b50d902SRodney W. GrimesThe first listing shows the functions 929b50d902SRodney W. Grimessorted according to the time they represent 9397fa9b77SPhilippe Charnierincluding the time of their call graph descendants. 949b50d902SRodney W. GrimesBelow each function entry is shown its (direct) call graph children, 959b50d902SRodney W. Grimesand how their times are propagated to this function. 969b50d902SRodney W. GrimesA similar display above the function shows how this function's time and the 9797fa9b77SPhilippe Charniertime of its descendants is propagated to its (direct) call graph parents. 989b50d902SRodney W. Grimes.Pp 999b50d902SRodney W. GrimesCycles are also shown, with an entry for the cycle as a whole and 1009b50d902SRodney W. Grimesa listing of the members of the cycle and their contributions to the 1019b50d902SRodney W. Grimestime and call counts of the cycle. 1029b50d902SRodney W. Grimes.Pp 1039b50d902SRodney W. GrimesSecond, a flat profile is given, 1049b50d902SRodney W. Grimessimilar to that provided by 1059b50d902SRodney W. Grimes.Xr prof 1 . 1069b50d902SRodney W. GrimesThis listing gives the total execution times, the call counts, 107762116aeSBruce Evansthe time that the call spent in the routine itself, and 108762116aeSBruce Evansthe time that the call spent in the routine itself including 10997fa9b77SPhilippe Charnierits descendants. 110762116aeSBruce EvansThe units for the per-call times are normally milliseconds, 111762116aeSBruce Evansbut they are nanoseconds if the profiling clock frequency 112762116aeSBruce Evansis 10 million or larger, 113762116aeSBruce Evansand if a function appears to be never called then its total self time 114762116aeSBruce Evansis printed as a percentage in the self time per call column. 115762116aeSBruce EvansThe very high profiling clock frequencies needed to get sufficient 116762116aeSBruce Evansaccuracy in the per-call times for short-lived programs are only 117762116aeSBruce Evansimplemented for 118762116aeSBruce Evans.Dq high resolution 119762116aeSBruce Evans(non-statistical) kernel profiling. 1209b50d902SRodney W. Grimes.Pp 1219b50d902SRodney W. GrimesFinally, an index of the function names is provided. 1229b50d902SRodney W. Grimes.Pp 1239b50d902SRodney W. GrimesThe following options are available: 12497fa9b77SPhilippe Charnier.Bl -tag -width indent 1259b50d902SRodney W. Grimes.It Fl a 12697fa9b77SPhilippe CharnierSuppress the printing of statically declared functions. 1279b50d902SRodney W. GrimesIf this option is given, all relevant information about the static function 1289b50d902SRodney W. Grimes(e.g., time samples, calls to other functions, calls from other functions) 1299b50d902SRodney W. Grimesbelongs to the function loaded just before the static function in the 1309b50d902SRodney W. Grimes.Pa a.out 1319b50d902SRodney W. Grimesfile. 1329b50d902SRodney W. Grimes.It Fl b 13397fa9b77SPhilippe CharnierSuppress the printing of a description of each field in the profile. 1349b50d902SRodney W. Grimes.It Fl C Ar count 1359b50d902SRodney W. GrimesFind a minimal set of arcs that can be broken to eliminate all cycles with 1369b50d902SRodney W. Grimes.Ar count 1379b50d902SRodney W. Grimesor more members. 1389b50d902SRodney W. GrimesCaution: the algorithm used to break cycles is exponential, 1399b50d902SRodney W. Grimesso using this option may cause 1408fe908efSRuslan Ermilov.Nm 1419b50d902SRodney W. Grimesto run for a very long time. 1429b50d902SRodney W. Grimes.It Fl e Ar name 14397fa9b77SPhilippe CharnierSuppress the printing of the graph profile entry for routine 1449b50d902SRodney W. Grimes.Ar name 1459b50d902SRodney W. Grimesand all its descendants 1460227791bSRuslan Ermilov(unless they have other ancestors that are not suppressed). 1479b50d902SRodney W. GrimesMore than one 1489b50d902SRodney W. Grimes.Fl e 1499b50d902SRodney W. Grimesoption may be given. 1509b50d902SRodney W. GrimesOnly one 1519b50d902SRodney W. Grimes.Ar name 1529b50d902SRodney W. Grimesmay be given with each 1539b50d902SRodney W. Grimes.Fl e 1549b50d902SRodney W. Grimesoption. 1559b50d902SRodney W. Grimes.It Fl E Ar name 15697fa9b77SPhilippe CharnierSuppress the printing of the graph profile entry for routine 1579b50d902SRodney W. Grimes.Ar name 1589b50d902SRodney W. Grimes(and its descendants) as 1599b50d902SRodney W. Grimes.Fl e , 1609b50d902SRodney W. Grimesabove, and also excludes the time spent in 1619b50d902SRodney W. Grimes.Ar name 1629b50d902SRodney W. Grimes(and its descendants) from the total and percentage time computations. 1639b50d902SRodney W. Grimes(For example, 1649b50d902SRodney W. Grimes.Fl E 1659b50d902SRodney W. Grimes.Ar mcount 1669b50d902SRodney W. Grimes.Fl E 1679b50d902SRodney W. Grimes.Ar mcleanup 1689b50d902SRodney W. Grimesis the default.) 1699b50d902SRodney W. Grimes.It Fl f Ar name 17097fa9b77SPhilippe CharnierPrint the graph profile entry of only the specified routine 1719b50d902SRodney W. Grimes.Ar name 1729b50d902SRodney W. Grimesand its descendants. 1739b50d902SRodney W. GrimesMore than one 1749b50d902SRodney W. Grimes.Fl f 1759b50d902SRodney W. Grimesoption may be given. 1769b50d902SRodney W. GrimesOnly one 1779b50d902SRodney W. Grimes.Ar name 1789b50d902SRodney W. Grimesmay be given with each 1799b50d902SRodney W. Grimes.Fl f 1809b50d902SRodney W. Grimesoption. 1819b50d902SRodney W. Grimes.It Fl F Ar name 18297fa9b77SPhilippe CharnierPrint the graph profile entry of only the routine 1839b50d902SRodney W. Grimes.Ar name 1849b50d902SRodney W. Grimesand its descendants (as 1859b50d902SRodney W. Grimes.Fl f , 1869b50d902SRodney W. Grimesabove) and also uses only the times of the printed routines 1879b50d902SRodney W. Grimesin total time and percentage computations. 1889b50d902SRodney W. GrimesMore than one 1899b50d902SRodney W. Grimes.Fl F 1909b50d902SRodney W. Grimesoption may be given. 1919b50d902SRodney W. GrimesOnly one 1929b50d902SRodney W. Grimes.Ar name 1939b50d902SRodney W. Grimesmay be given with each 1949b50d902SRodney W. Grimes.Fl F 1959b50d902SRodney W. Grimesoption. 1969b50d902SRodney W. GrimesThe 1979b50d902SRodney W. Grimes.Fl F 1989b50d902SRodney W. Grimesoption 1999b50d902SRodney W. Grimesoverrides 2009b50d902SRodney W. Grimesthe 2019b50d902SRodney W. Grimes.Fl E 2029b50d902SRodney W. Grimesoption. 2039b50d902SRodney W. Grimes.It Fl k Ar fromname Ar toname 2049b50d902SRodney W. GrimesWill delete any arcs from routine 2059b50d902SRodney W. Grimes.Ar fromname 2069b50d902SRodney W. Grimesto routine 2079b50d902SRodney W. Grimes.Ar toname . 2089b50d902SRodney W. GrimesThis can be used to break undesired cycles. 2099b50d902SRodney W. GrimesMore than one 2109b50d902SRodney W. Grimes.Fl k 2119b50d902SRodney W. Grimesoption may be given. 2129b50d902SRodney W. GrimesOnly one pair of routine names may be given with each 2139b50d902SRodney W. Grimes.Fl k 2149b50d902SRodney W. Grimesoption. 2153fc980b1SBrian Feldman.It Fl K 2163fc980b1SBrian FeldmanGather information about symbols from the currently-running kernel using the 2173fc980b1SBrian Feldman.Xr sysctl 3 2183fc980b1SBrian Feldmanand 2193fc980b1SBrian Feldman.Xr kldsym 2 2203fc980b1SBrian Feldmaninterfaces. 2213fc980b1SBrian FeldmanThis forces the 2223fc980b1SBrian Feldman.Pa a.out 2233fc980b1SBrian Feldmanargument to be ignored, and allows for symbols in 2243fc980b1SBrian Feldman.Xr kld 4 2253fc980b1SBrian Feldmanmodules to be used. 226d87bdc80SGarrett Wollman.It Fl l 22797fa9b77SPhilippe CharnierSuppress the printing of the call-graph profile. 228d87bdc80SGarrett Wollman.It Fl L 22997fa9b77SPhilippe CharnierSuppress the printing of the flat profile. 2309b50d902SRodney W. Grimes.It Fl s 2319b50d902SRodney W. GrimesA profile file 2329b50d902SRodney W. Grimes.Pa gmon.sum 2339b50d902SRodney W. Grimesis produced that represents 2349b50d902SRodney W. Grimesthe sum of the profile information in all the specified profile files. 2359b50d902SRodney W. GrimesThis summary profile file may be given to later 2369b50d902SRodney W. Grimesexecutions of gprof (probably also with a 2379b50d902SRodney W. Grimes.Fl s ) 2389b50d902SRodney W. Grimesto accumulate profile data across several runs of an 2399b50d902SRodney W. Grimes.Pa a.out 2409b50d902SRodney W. Grimesfile. 241ff18d378SBruce Evans.It Fl u 24297fa9b77SPhilippe CharnierSuppress the printing of functions whose names are not visible to 2436a3e8b0aSRuslan ErmilovC programs. 2446a3e8b0aSRuslan ErmilovFor the ELF object format, this means names that 2455584f22bSJohn Polstracontain the 2469b88faecSRuslan Ermilov.Ql .\& 2476a3e8b0aSRuslan Ermilovcharacter. 2486a3e8b0aSRuslan ErmilovFor the a.out object format, it means names that do not 2495584f22bSJohn Polstrabegin with a 2505584f22bSJohn Polstra.Ql _ 2515584f22bSJohn Polstracharacter. 252ff18d378SBruce EvansAll relevant information about such functions belongs to the 253ff18d378SBruce Evans(non-suppressed) function with the next lowest address. 254ff18d378SBruce EvansThis is useful for eliminating "functions" that are just labels 255ff18d378SBruce Evansinside other functions. 2569b50d902SRodney W. Grimes.It Fl z 25797fa9b77SPhilippe CharnierDisplay routines that have zero usage (as shown by call counts 2589b50d902SRodney W. Grimesand accumulated time). 2599b50d902SRodney W. Grimes.El 2609b50d902SRodney W. Grimes.Sh FILES 2617e74cac4SJean-Marc Zucconi.Bl -tag -width a.out.gmon -compact 2629b50d902SRodney W. Grimes.It Pa a.out 2638abea92cSRuslan ErmilovThe namelist and text space. 2647e74cac4SJean-Marc Zucconi.It Pa a.out.gmon 2658abea92cSRuslan ErmilovDynamic call graph and profile. 2669b50d902SRodney W. Grimes.It Pa gmon.sum 2678abea92cSRuslan ErmilovSummarized dynamic call graph and profile. 2689b50d902SRodney W. Grimes.El 2699b50d902SRodney W. Grimes.Sh SEE ALSO 270da1ff3cbSWolfram Schneider.Xr cc 1 , 2719b50d902SRodney W. Grimes.Xr profil 2 , 272*7acc357fSEdward Tomasz Napierala.Xr clocks 7 , 273*7acc357fSEdward Tomasz Napierala.Xr pmcstat 8 274da1ff3cbSWolfram Schneider.\" .Xr monitor 3 , 275bcff8e2aSMike Pritchard.\" .Xr prof 1 2769b50d902SRodney W. Grimes.Rs 2779b50d902SRodney W. Grimes.%T "An Execution Profiler for Modular Programs" 2789b50d902SRodney W. Grimes.%A S. Graham 2799b50d902SRodney W. Grimes.%A P. Kessler 2809b50d902SRodney W. Grimes.%A M. McKusick 2819b50d902SRodney W. Grimes.%J "Software - Practice and Experience" 2829b50d902SRodney W. Grimes.%V 13 2839b50d902SRodney W. Grimes.%P pp. 671-685 2849b50d902SRodney W. Grimes.%D 1983 2859b50d902SRodney W. Grimes.Re 2869b50d902SRodney W. Grimes.Rs 2879b50d902SRodney W. Grimes.%T "gprof: A Call Graph Execution Profiler" 2889b50d902SRodney W. Grimes.%A S. Graham 2899b50d902SRodney W. Grimes.%A P. Kessler 2909b50d902SRodney W. Grimes.%A M. McKusick 2919b50d902SRodney W. Grimes.%J "Proceedings of the SIGPLAN '82 Symposium on Compiler Construction, SIGPLAN Notices" 2929b50d902SRodney W. Grimes.%V 17 2939b50d902SRodney W. Grimes.%N 6 2949b50d902SRodney W. Grimes.%P pp. 120-126 2959b50d902SRodney W. Grimes.%D June 1982 2969b50d902SRodney W. Grimes.Re 2979b50d902SRodney W. Grimes.Sh HISTORY 2989b50d902SRodney W. GrimesThe 2998fe908efSRuslan Ermilov.Nm 3009b50d902SRodney W. Grimesprofiler 3019b50d902SRodney W. Grimesappeared in 3029b50d902SRodney W. Grimes.Bx 4.2 . 3039b50d902SRodney W. Grimes.Sh BUGS 3049b50d902SRodney W. GrimesThe granularity of the sampling is shown, but remains 3059b50d902SRodney W. Grimesstatistical at best. 3069b50d902SRodney W. GrimesWe assume that the time for each execution of a function 3079b50d902SRodney W. Grimescan be expressed by the total time for the function divided 3089b50d902SRodney W. Grimesby the number of times the function is called. 3099b50d902SRodney W. GrimesThus the time propagated along the call graph arcs to the function's 3109b50d902SRodney W. Grimesparents is directly proportional to the number of times that 3119b50d902SRodney W. Grimesarc is traversed. 3129b50d902SRodney W. Grimes.Pp 3139b50d902SRodney W. GrimesParents that are not themselves profiled will have the time of 3149b50d902SRodney W. Grimestheir profiled children propagated to them, but they will appear 3159b50d902SRodney W. Grimesto be spontaneously invoked in the call graph listing, and will 3169b50d902SRodney W. Grimesnot have their time propagated further. 3179b50d902SRodney W. GrimesSimilarly, signal catchers, even though profiled, will appear 3189b50d902SRodney W. Grimesto be spontaneous (although for more obscure reasons). 3199b50d902SRodney W. GrimesAny profiled children of signal catchers should have their times 3209b50d902SRodney W. Grimespropagated properly, unless the signal catcher was invoked during 3219b50d902SRodney W. Grimesthe execution of the profiling routine, in which case all is lost. 3229b50d902SRodney W. Grimes.Pp 3239b50d902SRodney W. GrimesThe profiled program must call 324906c1e27SMike Pritchard.Xr exit 3 3259b50d902SRodney W. Grimesor return normally for the profiling information to be saved 3267e74cac4SJean-Marc Zucconiin the graph profile file. 327