x86_64-linux-gnu-gprof.1 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. .\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .nr rF 0
  58. .if \n(.g .if rF .nr rF 1
  59. .if (\n(rF:(\n(.g==0)) \{\
  60. . if \nF \{\
  61. . de IX
  62. . tm Index:\\$1\t\\n%\t"\\$2"
  63. ..
  64. . if !\nF==2 \{\
  65. . nr % 0
  66. . nr F 2
  67. . \}
  68. . \}
  69. .\}
  70. .rr rF
  71. .\"
  72. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  73. .\" Fear. Run. Save yourself. No user-serviceable parts.
  74. . \" fudge factors for nroff and troff
  75. .if n \{\
  76. . ds #H 0
  77. . ds #V .8m
  78. . ds #F .3m
  79. . ds #[ \f1
  80. . ds #] \fP
  81. .\}
  82. .if t \{\
  83. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  84. . ds #V .6m
  85. . ds #F 0
  86. . ds #[ \&
  87. . ds #] \&
  88. .\}
  89. . \" simple accents for nroff and troff
  90. .if n \{\
  91. . ds ' \&
  92. . ds ` \&
  93. . ds ^ \&
  94. . ds , \&
  95. . ds ~ ~
  96. . ds /
  97. .\}
  98. .if t \{\
  99. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  100. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  101. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  102. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  103. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  104. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  105. .\}
  106. . \" troff and (daisy-wheel) nroff accents
  107. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  108. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  109. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  110. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  111. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  112. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  113. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  114. .ds ae a\h'-(\w'a'u*4/10)'e
  115. .ds Ae A\h'-(\w'A'u*4/10)'E
  116. . \" corrections for vroff
  117. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  118. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  119. . \" for low resolution devices (crt and lpr)
  120. .if \n(.H>23 .if \n(.V>19 \
  121. \{\
  122. . ds : e
  123. . ds 8 ss
  124. . ds o a
  125. . ds d- d\h'-1'\(ga
  126. . ds D- D\h'-1'\(hy
  127. . ds th \o'bp'
  128. . ds Th \o'LP'
  129. . ds ae ae
  130. . ds Ae AE
  131. .\}
  132. .rm #[ #] #H #V #F C
  133. .\" ========================================================================
  134. .\"
  135. .IX Title "GPROF 1"
  136. .TH GPROF 1 "2020-09-14" "binutils-2.34" "GNU"
  137. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  138. .\" way too many mistakes in technical documents.
  139. .if n .ad l
  140. .nh
  141. .SH "NAME"
  142. gprof \- display call graph profile data
  143. .SH "SYNOPSIS"
  144. .IX Header "SYNOPSIS"
  145. gprof [ \-[abcDhilLrsTvwxyz] ] [ \-[ACeEfFJnNOpPqQRStZ][\fIname\fR] ]
  146. [ \-I \fIdirs\fR ] [ \-d[\fInum\fR] ] [ \-k \fIfrom/to\fR ]
  147. [ \-m \fImin-count\fR ] [ \-R \fImap_file\fR ] [ \-t \fItable-length\fR ]
  148. [ \-\-[no\-]annotated\-source[=\fIname\fR] ]
  149. [ \-\-[no\-]exec\-counts[=\fIname\fR] ]
  150. [ \-\-[no\-]flat\-profile[=\fIname\fR] ] [ \-\-[no\-]graph[=\fIname\fR] ]
  151. [ \-\-[no\-]time=\fIname\fR] [ \-\-all\-lines ] [ \-\-brief ]
  152. [ \-\-debug[=\fIlevel\fR] ] [ \-\-function\-ordering ]
  153. [ \-\-file\-ordering \fImap_file\fR ] [ \-\-directory\-path=\fIdirs\fR ]
  154. [ \-\-display\-unused\-functions ] [ \-\-file\-format=\fIname\fR ]
  155. [ \-\-file\-info ] [ \-\-help ] [ \-\-line ] [ \-\-inline\-file\-names ]
  156. [ \-\-min\-count=\fIn\fR ] [ \-\-no\-static ] [ \-\-print\-path ]
  157. [ \-\-separate\-files ] [ \-\-static\-call\-graph ] [ \-\-sum ]
  158. [ \-\-table\-length=\fIlen\fR ] [ \-\-traditional ] [ \-\-version ]
  159. [ \-\-width=\fIn\fR ] [ \-\-ignore\-non\-functions ]
  160. [ \-\-demangle[=\fI\s-1STYLE\s0\fR] ] [ \-\-no\-demangle ]
  161. [\-\-external\-symbol\-table=name]
  162. [ \fIimage-file\fR ] [ \fIprofile-file\fR ... ]
  163. .SH "DESCRIPTION"
  164. .IX Header "DESCRIPTION"
  165. \&\f(CW\*(C`gprof\*(C'\fR produces an execution profile of C, Pascal, or Fortran77
  166. programs. The effect of called routines is incorporated in the profile
  167. of each caller. The profile data is taken from the call graph profile file
  168. (\fIgmon.out\fR default) which is created by programs
  169. that are compiled with the \fB\-pg\fR option of
  170. \&\f(CW\*(C`cc\*(C'\fR, \f(CW\*(C`pc\*(C'\fR, and \f(CW\*(C`f77\*(C'\fR.
  171. The \fB\-pg\fR option also links in versions of the library routines
  172. that are compiled for profiling. \f(CW\*(C`Gprof\*(C'\fR reads the given object
  173. file (the default is \f(CW\*(C`a.out\*(C'\fR) and establishes the relation between
  174. its symbol table and the call graph profile from \fIgmon.out\fR.
  175. If more than one profile file is specified, the \f(CW\*(C`gprof\*(C'\fR
  176. output shows the sum of the profile information in the given profile files.
  177. .PP
  178. If you use gcc 2.95.x or 3.0 to compile your binaries, you may need
  179. to add the \fB\-fprofile\-arcs\fR to the compile command line in order
  180. for the call graphs to be properly stored in gmon.out.
  181. .PP
  182. \&\f(CW\*(C`Gprof\*(C'\fR calculates the amount of time spent in each routine.
  183. Next, these times are propagated along the edges of the call graph.
  184. Cycles are discovered, and calls into a cycle are made to share the time
  185. of the cycle.
  186. .PP
  187. Several forms of output are available from the analysis.
  188. .PP
  189. The \fIflat profile\fR shows how much time your program spent in each function,
  190. and how many times that function was called. If you simply want to know
  191. which functions burn most of the cycles, it is stated concisely here.
  192. .PP
  193. The \fIcall graph\fR shows, for each function, which functions called it, which
  194. other functions it called, and how many times. There is also an estimate
  195. of how much time was spent in the subroutines of each function. This can
  196. suggest places where you might try to eliminate function calls that use a
  197. lot of time.
  198. .PP
  199. The \fIannotated source\fR listing is a copy of the program's
  200. source code, labeled with the number of times each line of the
  201. program was executed.
  202. .SH "OPTIONS"
  203. .IX Header "OPTIONS"
  204. These options specify which of several output formats
  205. \&\f(CW\*(C`gprof\*(C'\fR should produce.
  206. .PP
  207. Many of these options take an optional \fIsymspec\fR to specify
  208. functions to be included or excluded. These options can be
  209. specified multiple times, with different symspecs, to include
  210. or exclude sets of symbols.
  211. .PP
  212. Specifying any of these options overrides the default (\fB\-p \-q\fR),
  213. which prints a flat profile and call graph analysis
  214. for all functions.
  215. .ie n .IP """\-A[\fIsymspec\fP]""" 4
  216. .el .IP "\f(CW\-A[\f(CIsymspec\f(CW]\fR" 4
  217. .IX Item "-A[symspec]"
  218. .PD 0
  219. .ie n .IP """\-\-annotated\-source[=\fIsymspec\fP]""" 4
  220. .el .IP "\f(CW\-\-annotated\-source[=\f(CIsymspec\f(CW]\fR" 4
  221. .IX Item "--annotated-source[=symspec]"
  222. .PD
  223. The \fB\-A\fR option causes \f(CW\*(C`gprof\*(C'\fR to print annotated source code.
  224. If \fIsymspec\fR is specified, print output only for matching symbols.
  225. .ie n .IP """\-b""" 4
  226. .el .IP "\f(CW\-b\fR" 4
  227. .IX Item "-b"
  228. .PD 0
  229. .ie n .IP """\-\-brief""" 4
  230. .el .IP "\f(CW\-\-brief\fR" 4
  231. .IX Item "--brief"
  232. .PD
  233. If the \fB\-b\fR option is given, \f(CW\*(C`gprof\*(C'\fR doesn't print the
  234. verbose blurbs that try to explain the meaning of all of the fields in
  235. the tables. This is useful if you intend to print out the output, or
  236. are tired of seeing the blurbs.
  237. .ie n .IP """\-C[\fIsymspec\fP]""" 4
  238. .el .IP "\f(CW\-C[\f(CIsymspec\f(CW]\fR" 4
  239. .IX Item "-C[symspec]"
  240. .PD 0
  241. .ie n .IP """\-\-exec\-counts[=\fIsymspec\fP]""" 4
  242. .el .IP "\f(CW\-\-exec\-counts[=\f(CIsymspec\f(CW]\fR" 4
  243. .IX Item "--exec-counts[=symspec]"
  244. .PD
  245. The \fB\-C\fR option causes \f(CW\*(C`gprof\*(C'\fR to
  246. print a tally of functions and the number of times each was called.
  247. If \fIsymspec\fR is specified, print tally only for matching symbols.
  248. .Sp
  249. If the profile data file contains basic-block count records, specifying
  250. the \fB\-l\fR option, along with \fB\-C\fR, will cause basic-block
  251. execution counts to be tallied and displayed.
  252. .ie n .IP """\-i""" 4
  253. .el .IP "\f(CW\-i\fR" 4
  254. .IX Item "-i"
  255. .PD 0
  256. .ie n .IP """\-\-file\-info""" 4
  257. .el .IP "\f(CW\-\-file\-info\fR" 4
  258. .IX Item "--file-info"
  259. .PD
  260. The \fB\-i\fR option causes \f(CW\*(C`gprof\*(C'\fR to display summary information
  261. about the profile data file(s) and then exit. The number of histogram,
  262. call graph, and basic-block count records is displayed.
  263. .ie n .IP """\-I \fIdirs\fP""" 4
  264. .el .IP "\f(CW\-I \f(CIdirs\f(CW\fR" 4
  265. .IX Item "-I dirs"
  266. .PD 0
  267. .ie n .IP """\-\-directory\-path=\fIdirs\fP""" 4
  268. .el .IP "\f(CW\-\-directory\-path=\f(CIdirs\f(CW\fR" 4
  269. .IX Item "--directory-path=dirs"
  270. .PD
  271. The \fB\-I\fR option specifies a list of search directories in
  272. which to find source files. Environment variable \fI\s-1GPROF_PATH\s0\fR
  273. can also be used to convey this information.
  274. Used mostly for annotated source output.
  275. .ie n .IP """\-J[\fIsymspec\fP]""" 4
  276. .el .IP "\f(CW\-J[\f(CIsymspec\f(CW]\fR" 4
  277. .IX Item "-J[symspec]"
  278. .PD 0
  279. .ie n .IP """\-\-no\-annotated\-source[=\fIsymspec\fP]""" 4
  280. .el .IP "\f(CW\-\-no\-annotated\-source[=\f(CIsymspec\f(CW]\fR" 4
  281. .IX Item "--no-annotated-source[=symspec]"
  282. .PD
  283. The \fB\-J\fR option causes \f(CW\*(C`gprof\*(C'\fR not to
  284. print annotated source code.
  285. If \fIsymspec\fR is specified, \f(CW\*(C`gprof\*(C'\fR prints annotated source,
  286. but excludes matching symbols.
  287. .ie n .IP """\-L""" 4
  288. .el .IP "\f(CW\-L\fR" 4
  289. .IX Item "-L"
  290. .PD 0
  291. .ie n .IP """\-\-print\-path""" 4
  292. .el .IP "\f(CW\-\-print\-path\fR" 4
  293. .IX Item "--print-path"
  294. .PD
  295. Normally, source filenames are printed with the path
  296. component suppressed. The \fB\-L\fR option causes \f(CW\*(C`gprof\*(C'\fR
  297. to print the full pathname of
  298. source filenames, which is determined
  299. from symbolic debugging information in the image file
  300. and is relative to the directory in which the compiler
  301. was invoked.
  302. .ie n .IP """\-p[\fIsymspec\fP]""" 4
  303. .el .IP "\f(CW\-p[\f(CIsymspec\f(CW]\fR" 4
  304. .IX Item "-p[symspec]"
  305. .PD 0
  306. .ie n .IP """\-\-flat\-profile[=\fIsymspec\fP]""" 4
  307. .el .IP "\f(CW\-\-flat\-profile[=\f(CIsymspec\f(CW]\fR" 4
  308. .IX Item "--flat-profile[=symspec]"
  309. .PD
  310. The \fB\-p\fR option causes \f(CW\*(C`gprof\*(C'\fR to print a flat profile.
  311. If \fIsymspec\fR is specified, print flat profile only for matching symbols.
  312. .ie n .IP """\-P[\fIsymspec\fP]""" 4
  313. .el .IP "\f(CW\-P[\f(CIsymspec\f(CW]\fR" 4
  314. .IX Item "-P[symspec]"
  315. .PD 0
  316. .ie n .IP """\-\-no\-flat\-profile[=\fIsymspec\fP]""" 4
  317. .el .IP "\f(CW\-\-no\-flat\-profile[=\f(CIsymspec\f(CW]\fR" 4
  318. .IX Item "--no-flat-profile[=symspec]"
  319. .PD
  320. The \fB\-P\fR option causes \f(CW\*(C`gprof\*(C'\fR to suppress printing a flat profile.
  321. If \fIsymspec\fR is specified, \f(CW\*(C`gprof\*(C'\fR prints a flat profile,
  322. but excludes matching symbols.
  323. .ie n .IP """\-q[\fIsymspec\fP]""" 4
  324. .el .IP "\f(CW\-q[\f(CIsymspec\f(CW]\fR" 4
  325. .IX Item "-q[symspec]"
  326. .PD 0
  327. .ie n .IP """\-\-graph[=\fIsymspec\fP]""" 4
  328. .el .IP "\f(CW\-\-graph[=\f(CIsymspec\f(CW]\fR" 4
  329. .IX Item "--graph[=symspec]"
  330. .PD
  331. The \fB\-q\fR option causes \f(CW\*(C`gprof\*(C'\fR to print the call graph analysis.
  332. If \fIsymspec\fR is specified, print call graph only for matching symbols
  333. and their children.
  334. .ie n .IP """\-Q[\fIsymspec\fP]""" 4
  335. .el .IP "\f(CW\-Q[\f(CIsymspec\f(CW]\fR" 4
  336. .IX Item "-Q[symspec]"
  337. .PD 0
  338. .ie n .IP """\-\-no\-graph[=\fIsymspec\fP]""" 4
  339. .el .IP "\f(CW\-\-no\-graph[=\f(CIsymspec\f(CW]\fR" 4
  340. .IX Item "--no-graph[=symspec]"
  341. .PD
  342. The \fB\-Q\fR option causes \f(CW\*(C`gprof\*(C'\fR to suppress printing the
  343. call graph.
  344. If \fIsymspec\fR is specified, \f(CW\*(C`gprof\*(C'\fR prints a call graph,
  345. but excludes matching symbols.
  346. .ie n .IP """\-t""" 4
  347. .el .IP "\f(CW\-t\fR" 4
  348. .IX Item "-t"
  349. .PD 0
  350. .ie n .IP """\-\-table\-length=\fInum\fP""" 4
  351. .el .IP "\f(CW\-\-table\-length=\f(CInum\f(CW\fR" 4
  352. .IX Item "--table-length=num"
  353. .PD
  354. The \fB\-t\fR option causes the \fInum\fR most active source lines in
  355. each source file to be listed when source annotation is enabled. The
  356. default is 10.
  357. .ie n .IP """\-y""" 4
  358. .el .IP "\f(CW\-y\fR" 4
  359. .IX Item "-y"
  360. .PD 0
  361. .ie n .IP """\-\-separate\-files""" 4
  362. .el .IP "\f(CW\-\-separate\-files\fR" 4
  363. .IX Item "--separate-files"
  364. .PD
  365. This option affects annotated source output only.
  366. Normally, \f(CW\*(C`gprof\*(C'\fR prints annotated source files
  367. to standard-output. If this option is specified,
  368. annotated source for a file named \fIpath/\fIfilename\fI\fR
  369. is generated in the file \fI\fIfilename\fI\-ann\fR. If the underlying
  370. file system would truncate \fI\fIfilename\fI\-ann\fR so that it
  371. overwrites the original \fI\fIfilename\fI\fR, \f(CW\*(C`gprof\*(C'\fR generates
  372. annotated source in the file \fI\fIfilename\fI.ann\fR instead (if the
  373. original file name has an extension, that extension is \fIreplaced\fR
  374. with \fI.ann\fR).
  375. .ie n .IP """\-Z[\fIsymspec\fP]""" 4
  376. .el .IP "\f(CW\-Z[\f(CIsymspec\f(CW]\fR" 4
  377. .IX Item "-Z[symspec]"
  378. .PD 0
  379. .ie n .IP """\-\-no\-exec\-counts[=\fIsymspec\fP]""" 4
  380. .el .IP "\f(CW\-\-no\-exec\-counts[=\f(CIsymspec\f(CW]\fR" 4
  381. .IX Item "--no-exec-counts[=symspec]"
  382. .PD
  383. The \fB\-Z\fR option causes \f(CW\*(C`gprof\*(C'\fR not to
  384. print a tally of functions and the number of times each was called.
  385. If \fIsymspec\fR is specified, print tally, but exclude matching symbols.
  386. .ie n .IP """\-r""" 4
  387. .el .IP "\f(CW\-r\fR" 4
  388. .IX Item "-r"
  389. .PD 0
  390. .ie n .IP """\-\-function\-ordering""" 4
  391. .el .IP "\f(CW\-\-function\-ordering\fR" 4
  392. .IX Item "--function-ordering"
  393. .PD
  394. The \fB\-\-function\-ordering\fR option causes \f(CW\*(C`gprof\*(C'\fR to print a
  395. suggested function ordering for the program based on profiling data.
  396. This option suggests an ordering which may improve paging, tlb and
  397. cache behavior for the program on systems which support arbitrary
  398. ordering of functions in an executable.
  399. .Sp
  400. The exact details of how to force the linker to place functions
  401. in a particular order is system dependent and out of the scope of this
  402. manual.
  403. .ie n .IP """\-R \fImap_file\fP""" 4
  404. .el .IP "\f(CW\-R \f(CImap_file\f(CW\fR" 4
  405. .IX Item "-R map_file"
  406. .PD 0
  407. .ie n .IP """\-\-file\-ordering \fImap_file\fP""" 4
  408. .el .IP "\f(CW\-\-file\-ordering \f(CImap_file\f(CW\fR" 4
  409. .IX Item "--file-ordering map_file"
  410. .PD
  411. The \fB\-\-file\-ordering\fR option causes \f(CW\*(C`gprof\*(C'\fR to print a
  412. suggested .o link line ordering for the program based on profiling data.
  413. This option suggests an ordering which may improve paging, tlb and
  414. cache behavior for the program on systems which do not support arbitrary
  415. ordering of functions in an executable.
  416. .Sp
  417. Use of the \fB\-a\fR argument is highly recommended with this option.
  418. .Sp
  419. The \fImap_file\fR argument is a pathname to a file which provides
  420. function name to object file mappings. The format of the file is similar to
  421. the output of the program \f(CW\*(C`nm\*(C'\fR.
  422. .Sp
  423. .Vb 8
  424. \& c\-parse.o:00000000 T yyparse
  425. \& c\-parse.o:00000004 C yyerrflag
  426. \& c\-lang.o:00000000 T maybe_objc_method_name
  427. \& c\-lang.o:00000000 T print_lang_statistics
  428. \& c\-lang.o:00000000 T recognize_objc_keyword
  429. \& c\-decl.o:00000000 T print_lang_identifier
  430. \& c\-decl.o:00000000 T print_lang_type
  431. \& ...
  432. .Ve
  433. .Sp
  434. To create a \fImap_file\fR with \s-1GNU\s0 \f(CW\*(C`nm\*(C'\fR, type a command like
  435. \&\f(CW\*(C`nm \-\-extern\-only \-\-defined\-only \-v \-\-print\-file\-name program\-name\*(C'\fR.
  436. .ie n .IP """\-T""" 4
  437. .el .IP "\f(CW\-T\fR" 4
  438. .IX Item "-T"
  439. .PD 0
  440. .ie n .IP """\-\-traditional""" 4
  441. .el .IP "\f(CW\-\-traditional\fR" 4
  442. .IX Item "--traditional"
  443. .PD
  444. The \fB\-T\fR option causes \f(CW\*(C`gprof\*(C'\fR to print its output in
  445. \&\*(L"traditional\*(R" \s-1BSD\s0 style.
  446. .ie n .IP """\-w \fIwidth\fP""" 4
  447. .el .IP "\f(CW\-w \f(CIwidth\f(CW\fR" 4
  448. .IX Item "-w width"
  449. .PD 0
  450. .ie n .IP """\-\-width=\fIwidth\fP""" 4
  451. .el .IP "\f(CW\-\-width=\f(CIwidth\f(CW\fR" 4
  452. .IX Item "--width=width"
  453. .PD
  454. Sets width of output lines to \fIwidth\fR.
  455. Currently only used when printing the function index at the bottom
  456. of the call graph.
  457. .ie n .IP """\-x""" 4
  458. .el .IP "\f(CW\-x\fR" 4
  459. .IX Item "-x"
  460. .PD 0
  461. .ie n .IP """\-\-all\-lines""" 4
  462. .el .IP "\f(CW\-\-all\-lines\fR" 4
  463. .IX Item "--all-lines"
  464. .PD
  465. This option affects annotated source output only.
  466. By default, only the lines at the beginning of a basic-block
  467. are annotated. If this option is specified, every line in
  468. a basic-block is annotated by repeating the annotation for the
  469. first line. This behavior is similar to \f(CW\*(C`tcov\*(C'\fR's \fB\-a\fR.
  470. .ie n .IP """\-\-demangle[=\fIstyle\fP]""" 4
  471. .el .IP "\f(CW\-\-demangle[=\f(CIstyle\f(CW]\fR" 4
  472. .IX Item "--demangle[=style]"
  473. .PD 0
  474. .ie n .IP """\-\-no\-demangle""" 4
  475. .el .IP "\f(CW\-\-no\-demangle\fR" 4
  476. .IX Item "--no-demangle"
  477. .PD
  478. These options control whether \*(C+ symbol names should be demangled when
  479. printing output. The default is to demangle symbols. The
  480. \&\f(CW\*(C`\-\-no\-demangle\*(C'\fR option may be used to turn off demangling. Different
  481. compilers have different mangling styles. The optional demangling style
  482. argument can be used to choose an appropriate demangling style for your
  483. compiler.
  484. .SS "Analysis Options"
  485. .IX Subsection "Analysis Options"
  486. .ie n .IP """\-a""" 4
  487. .el .IP "\f(CW\-a\fR" 4
  488. .IX Item "-a"
  489. .PD 0
  490. .ie n .IP """\-\-no\-static""" 4
  491. .el .IP "\f(CW\-\-no\-static\fR" 4
  492. .IX Item "--no-static"
  493. .PD
  494. The \fB\-a\fR option causes \f(CW\*(C`gprof\*(C'\fR to suppress the printing of
  495. statically declared (private) functions. (These are functions whose
  496. names are not listed as global, and which are not visible outside the
  497. file/function/block where they were defined.) Time spent in these
  498. functions, calls to/from them, etc., will all be attributed to the
  499. function that was loaded directly before it in the executable file.
  500. This option affects both the flat profile and the call graph.
  501. .ie n .IP """\-c""" 4
  502. .el .IP "\f(CW\-c\fR" 4
  503. .IX Item "-c"
  504. .PD 0
  505. .ie n .IP """\-\-static\-call\-graph""" 4
  506. .el .IP "\f(CW\-\-static\-call\-graph\fR" 4
  507. .IX Item "--static-call-graph"
  508. .PD
  509. The \fB\-c\fR option causes the call graph of the program to be
  510. augmented by a heuristic which examines the text space of the object
  511. file and identifies function calls in the binary machine code.
  512. Since normal call graph records are only generated when functions are
  513. entered, this option identifies children that could have been called,
  514. but never were. Calls to functions that were not compiled with
  515. profiling enabled are also identified, but only if symbol table
  516. entries are present for them.
  517. Calls to dynamic library routines are typically \fInot\fR found
  518. by this option.
  519. Parents or children identified via this heuristic
  520. are indicated in the call graph with call counts of \fB0\fR.
  521. .ie n .IP """\-D""" 4
  522. .el .IP "\f(CW\-D\fR" 4
  523. .IX Item "-D"
  524. .PD 0
  525. .ie n .IP """\-\-ignore\-non\-functions""" 4
  526. .el .IP "\f(CW\-\-ignore\-non\-functions\fR" 4
  527. .IX Item "--ignore-non-functions"
  528. .PD
  529. The \fB\-D\fR option causes \f(CW\*(C`gprof\*(C'\fR to ignore symbols which
  530. are not known to be functions. This option will give more accurate
  531. profile data on systems where it is supported (Solaris and \s-1HPUX\s0 for
  532. example).
  533. .ie n .IP """\-k \fIfrom\fP/\fIto\fP""" 4
  534. .el .IP "\f(CW\-k \f(CIfrom\f(CW/\f(CIto\f(CW\fR" 4
  535. .IX Item "-k from/to"
  536. The \fB\-k\fR option allows you to delete from the call graph any arcs from
  537. symbols matching symspec \fIfrom\fR to those matching symspec \fIto\fR.
  538. .ie n .IP """\-l""" 4
  539. .el .IP "\f(CW\-l\fR" 4
  540. .IX Item "-l"
  541. .PD 0
  542. .ie n .IP """\-\-line""" 4
  543. .el .IP "\f(CW\-\-line\fR" 4
  544. .IX Item "--line"
  545. .PD
  546. The \fB\-l\fR option enables line-by-line profiling, which causes
  547. histogram hits to be charged to individual source code lines,
  548. instead of functions. This feature only works with programs compiled
  549. by older versions of the \f(CW\*(C`gcc\*(C'\fR compiler. Newer versions of
  550. \&\f(CW\*(C`gcc\*(C'\fR are designed to work with the \f(CW\*(C`gcov\*(C'\fR tool instead.
  551. .Sp
  552. If the program was compiled with basic-block counting enabled,
  553. this option will also identify how many times each line of
  554. code was executed.
  555. While line-by-line profiling can help isolate where in a large function
  556. a program is spending its time, it also significantly increases
  557. the running time of \f(CW\*(C`gprof\*(C'\fR, and magnifies statistical
  558. inaccuracies.
  559. .ie n .IP """\-\-inline\-file\-names""" 4
  560. .el .IP "\f(CW\-\-inline\-file\-names\fR" 4
  561. .IX Item "--inline-file-names"
  562. This option causes \f(CW\*(C`gprof\*(C'\fR to print the source file after each
  563. symbol in both the flat profile and the call graph. The full path to the
  564. file is printed if used with the \fB\-L\fR option.
  565. .ie n .IP """\-m \fInum\fP""" 4
  566. .el .IP "\f(CW\-m \f(CInum\f(CW\fR" 4
  567. .IX Item "-m num"
  568. .PD 0
  569. .ie n .IP """\-\-min\-count=\fInum\fP""" 4
  570. .el .IP "\f(CW\-\-min\-count=\f(CInum\f(CW\fR" 4
  571. .IX Item "--min-count=num"
  572. .PD
  573. This option affects execution count output only.
  574. Symbols that are executed less than \fInum\fR times are suppressed.
  575. .ie n .IP """\-n\fIsymspec\fP""" 4
  576. .el .IP "\f(CW\-n\f(CIsymspec\f(CW\fR" 4
  577. .IX Item "-nsymspec"
  578. .PD 0
  579. .ie n .IP """\-\-time=\fIsymspec\fP""" 4
  580. .el .IP "\f(CW\-\-time=\f(CIsymspec\f(CW\fR" 4
  581. .IX Item "--time=symspec"
  582. .PD
  583. The \fB\-n\fR option causes \f(CW\*(C`gprof\*(C'\fR, in its call graph analysis,
  584. to only propagate times for symbols matching \fIsymspec\fR.
  585. .ie n .IP """\-N\fIsymspec\fP""" 4
  586. .el .IP "\f(CW\-N\f(CIsymspec\f(CW\fR" 4
  587. .IX Item "-Nsymspec"
  588. .PD 0
  589. .ie n .IP """\-\-no\-time=\fIsymspec\fP""" 4
  590. .el .IP "\f(CW\-\-no\-time=\f(CIsymspec\f(CW\fR" 4
  591. .IX Item "--no-time=symspec"
  592. .PD
  593. The \fB\-n\fR option causes \f(CW\*(C`gprof\*(C'\fR, in its call graph analysis,
  594. not to propagate times for symbols matching \fIsymspec\fR.
  595. .ie n .IP """\-S\fIfilename\fP""" 4
  596. .el .IP "\f(CW\-S\f(CIfilename\f(CW\fR" 4
  597. .IX Item "-Sfilename"
  598. .PD 0
  599. .ie n .IP """\-\-external\-symbol\-table=\fIfilename\fP""" 4
  600. .el .IP "\f(CW\-\-external\-symbol\-table=\f(CIfilename\f(CW\fR" 4
  601. .IX Item "--external-symbol-table=filename"
  602. .PD
  603. The \fB\-S\fR option causes \f(CW\*(C`gprof\*(C'\fR to read an external symbol table
  604. file, such as \fI/proc/kallsyms\fR, rather than read the symbol table
  605. from the given object file (the default is \f(CW\*(C`a.out\*(C'\fR). This is useful
  606. for profiling kernel modules.
  607. .ie n .IP """\-z""" 4
  608. .el .IP "\f(CW\-z\fR" 4
  609. .IX Item "-z"
  610. .PD 0
  611. .ie n .IP """\-\-display\-unused\-functions""" 4
  612. .el .IP "\f(CW\-\-display\-unused\-functions\fR" 4
  613. .IX Item "--display-unused-functions"
  614. .PD
  615. If you give the \fB\-z\fR option, \f(CW\*(C`gprof\*(C'\fR will mention all
  616. functions in the flat profile, even those that were never called, and
  617. that had no time spent in them. This is useful in conjunction with the
  618. \&\fB\-c\fR option for discovering which routines were never called.
  619. .SS "Miscellaneous Options"
  620. .IX Subsection "Miscellaneous Options"
  621. .ie n .IP """\-d[\fInum\fP]""" 4
  622. .el .IP "\f(CW\-d[\f(CInum\f(CW]\fR" 4
  623. .IX Item "-d[num]"
  624. .PD 0
  625. .ie n .IP """\-\-debug[=\fInum\fP]""" 4
  626. .el .IP "\f(CW\-\-debug[=\f(CInum\f(CW]\fR" 4
  627. .IX Item "--debug[=num]"
  628. .PD
  629. The \fB\-d\fR \fInum\fR option specifies debugging options.
  630. If \fInum\fR is not specified, enable all debugging.
  631. .ie n .IP """\-h""" 4
  632. .el .IP "\f(CW\-h\fR" 4
  633. .IX Item "-h"
  634. .PD 0
  635. .ie n .IP """\-\-help""" 4
  636. .el .IP "\f(CW\-\-help\fR" 4
  637. .IX Item "--help"
  638. .PD
  639. The \fB\-h\fR option prints command line usage.
  640. .ie n .IP """\-O\fIname\fP""" 4
  641. .el .IP "\f(CW\-O\f(CIname\f(CW\fR" 4
  642. .IX Item "-Oname"
  643. .PD 0
  644. .ie n .IP """\-\-file\-format=\fIname\fP""" 4
  645. .el .IP "\f(CW\-\-file\-format=\f(CIname\f(CW\fR" 4
  646. .IX Item "--file-format=name"
  647. .PD
  648. Selects the format of the profile data files. Recognized formats are
  649. \&\fBauto\fR (the default), \fBbsd\fR, \fB4.4bsd\fR, \fBmagic\fR, and
  650. \&\fBprof\fR (not yet supported).
  651. .ie n .IP """\-s""" 4
  652. .el .IP "\f(CW\-s\fR" 4
  653. .IX Item "-s"
  654. .PD 0
  655. .ie n .IP """\-\-sum""" 4
  656. .el .IP "\f(CW\-\-sum\fR" 4
  657. .IX Item "--sum"
  658. .PD
  659. The \fB\-s\fR option causes \f(CW\*(C`gprof\*(C'\fR to summarize the information
  660. in the profile data files it read in, and write out a profile data
  661. file called \fIgmon.sum\fR, which contains all the information from
  662. the profile data files that \f(CW\*(C`gprof\*(C'\fR read in. The file \fIgmon.sum\fR
  663. may be one of the specified input files; the effect of this is to
  664. merge the data in the other input files into \fIgmon.sum\fR.
  665. .Sp
  666. Eventually you can run \f(CW\*(C`gprof\*(C'\fR again without \fB\-s\fR to analyze the
  667. cumulative data in the file \fIgmon.sum\fR.
  668. .ie n .IP """\-v""" 4
  669. .el .IP "\f(CW\-v\fR" 4
  670. .IX Item "-v"
  671. .PD 0
  672. .ie n .IP """\-\-version""" 4
  673. .el .IP "\f(CW\-\-version\fR" 4
  674. .IX Item "--version"
  675. .PD
  676. The \fB\-v\fR flag causes \f(CW\*(C`gprof\*(C'\fR to print the current version
  677. number, and then exit.
  678. .SS "Deprecated Options"
  679. .IX Subsection "Deprecated Options"
  680. These options have been replaced with newer versions that use symspecs.
  681. .ie n .IP """\-e \fIfunction_name\fP""" 4
  682. .el .IP "\f(CW\-e \f(CIfunction_name\f(CW\fR" 4
  683. .IX Item "-e function_name"
  684. The \fB\-e\fR \fIfunction\fR option tells \f(CW\*(C`gprof\*(C'\fR to not print
  685. information about the function \fIfunction_name\fR (and its
  686. children...) in the call graph. The function will still be listed
  687. as a child of any functions that call it, but its index number will be
  688. shown as \fB[not printed]\fR. More than one \fB\-e\fR option may be
  689. given; only one \fIfunction_name\fR may be indicated with each \fB\-e\fR
  690. option.
  691. .ie n .IP """\-E \fIfunction_name\fP""" 4
  692. .el .IP "\f(CW\-E \f(CIfunction_name\f(CW\fR" 4
  693. .IX Item "-E function_name"
  694. The \f(CW\*(C`\-E \f(CIfunction\f(CW\*(C'\fR option works like the \f(CW\*(C`\-e\*(C'\fR option, but
  695. time spent in the function (and children who were not called from
  696. anywhere else), will not be used to compute the percentages-of-time for
  697. the call graph. More than one \fB\-E\fR option may be given; only one
  698. \&\fIfunction_name\fR may be indicated with each \fB\-E\fR option.
  699. .ie n .IP """\-f \fIfunction_name\fP""" 4
  700. .el .IP "\f(CW\-f \f(CIfunction_name\f(CW\fR" 4
  701. .IX Item "-f function_name"
  702. The \fB\-f\fR \fIfunction\fR option causes \f(CW\*(C`gprof\*(C'\fR to limit the
  703. call graph to the function \fIfunction_name\fR and its children (and
  704. their children...). More than one \fB\-f\fR option may be given;
  705. only one \fIfunction_name\fR may be indicated with each \fB\-f\fR
  706. option.
  707. .ie n .IP """\-F \fIfunction_name\fP""" 4
  708. .el .IP "\f(CW\-F \f(CIfunction_name\f(CW\fR" 4
  709. .IX Item "-F function_name"
  710. The \fB\-F\fR \fIfunction\fR option works like the \f(CW\*(C`\-f\*(C'\fR option, but
  711. only time spent in the function and its children (and their
  712. children...) will be used to determine total-time and
  713. percentages-of-time for the call graph. More than one \fB\-F\fR option
  714. may be given; only one \fIfunction_name\fR may be indicated with each
  715. \&\fB\-F\fR option. The \fB\-F\fR option overrides the \fB\-E\fR option.
  716. .SH "FILES"
  717. .IX Header "FILES"
  718. .ie n .IP """\fIa.out\fP""" 4
  719. .el .IP "\f(CW\f(CIa.out\f(CW\fR" 4
  720. .IX Item "a.out"
  721. the namelist and text space.
  722. .ie n .IP """\fIgmon.out\fP""" 4
  723. .el .IP "\f(CW\f(CIgmon.out\f(CW\fR" 4
  724. .IX Item "gmon.out"
  725. dynamic call graph and profile.
  726. .ie n .IP """\fIgmon.sum\fP""" 4
  727. .el .IP "\f(CW\f(CIgmon.sum\f(CW\fR" 4
  728. .IX Item "gmon.sum"
  729. summarized dynamic call graph and profile.
  730. .SH "BUGS"
  731. .IX Header "BUGS"
  732. The granularity of the sampling is shown, but remains
  733. statistical at best.
  734. We assume that the time for each execution of a function
  735. can be expressed by the total time for the function divided
  736. by the number of times the function is called.
  737. Thus the time propagated along the call graph arcs to the function's
  738. parents is directly proportional to the number of times that
  739. arc is traversed.
  740. .PP
  741. Parents that are not themselves profiled will have the time of
  742. their profiled children propagated to them, but they will appear
  743. to be spontaneously invoked in the call graph listing, and will
  744. not have their time propagated further.
  745. Similarly, signal catchers, even though profiled, will appear
  746. to be spontaneous (although for more obscure reasons).
  747. Any profiled children of signal catchers should have their times
  748. propagated properly, unless the signal catcher was invoked during
  749. the execution of the profiling routine, in which case all is lost.
  750. .PP
  751. The profiled program must call \f(CW\*(C`exit\*(C'\fR(2)
  752. or return normally for the profiling information to be saved
  753. in the \fIgmon.out\fR file.
  754. .SH "SEE ALSO"
  755. .IX Header "SEE ALSO"
  756. \&\fBcc\fR\|(1), \fBprof\fR\|(1), and the Info entry for \fIgprof\fR.
  757. .PP
  758. \&\*(L"An Execution Profiler for Modular Programs\*(R",
  759. by S. Graham, P. Kessler, M. McKusick;
  760. Software \- Practice and Experience,
  761. Vol. 13, pp. 671\-685, 1983.
  762. .PP
  763. \&\*(L"gprof: A Call Graph Execution Profiler\*(R",
  764. by S. Graham, P. Kessler, M. McKusick;
  765. Proceedings of the \s-1SIGPLAN\s0 '82 Symposium on Compiler Construction,
  766. \&\s-1SIGPLAN\s0 Notices, Vol. 17, No 6, pp. 120\-126, June 1982.
  767. .SH "COPYRIGHT"
  768. .IX Header "COPYRIGHT"
  769. Copyright (c) 1988\-2020 Free Software Foundation, Inc.
  770. .PP
  771. Permission is granted to copy, distribute and/or modify this document
  772. under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3
  773. or any later version published by the Free Software Foundation;
  774. with no Invariant Sections, with no Front-Cover Texts, and with no
  775. Back-Cover Texts. A copy of the license is included in the
  776. section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R".