gprof.info 110 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467
  1. This is gprof.info, produced by makeinfo version 6.7 from gprof.texi.
  2. This file documents the gprof profiler of the GNU system.
  3. Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with no
  7. Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
  8. Texts. A copy of the license is included in the section entitled "GNU
  9. Free Documentation License".
  10. INFO-DIR-SECTION Software development
  11. START-INFO-DIR-ENTRY
  12. * gprof: (gprof). Profiling your program's execution
  13. END-INFO-DIR-ENTRY
  14. 
  15. File: gprof.info, Node: Top, Next: Introduction, Up: (dir)
  16. Profiling a Program: Where Does It Spend Its Time?
  17. **************************************************
  18. This manual describes the GNU profiler, 'gprof', and how you can use it
  19. to determine which parts of a program are taking most of the execution
  20. time. We assume that you know how to write, compile, and execute
  21. programs. GNU 'gprof' was written by Jay Fenlason.
  22. This manual is for 'gprof' (GNU Binutils) version 2.34.
  23. This document is distributed under the terms of the GNU Free
  24. Documentation License version 1.3. A copy of the license is included in
  25. the section entitled "GNU Free Documentation License".
  26. * Menu:
  27. * Introduction:: What profiling means, and why it is useful.
  28. * Compiling:: How to compile your program for profiling.
  29. * Executing:: Executing your program to generate profile data
  30. * Invoking:: How to run 'gprof', and its options
  31. * Output:: Interpreting 'gprof''s output
  32. * Inaccuracy:: Potential problems you should be aware of
  33. * How do I?:: Answers to common questions
  34. * Incompatibilities:: (between GNU 'gprof' and Unix 'gprof'.)
  35. * Details:: Details of how profiling is done
  36. * GNU Free Documentation License:: GNU Free Documentation License
  37. 
  38. File: gprof.info, Node: Introduction, Next: Compiling, Prev: Top, Up: Top
  39. 1 Introduction to Profiling
  40. ***************************
  41. Profiling allows you to learn where your program spent its time and
  42. which functions called which other functions while it was executing.
  43. This information can show you which pieces of your program are slower
  44. than you expected, and might be candidates for rewriting to make your
  45. program execute faster. It can also tell you which functions are being
  46. called more or less often than you expected. This may help you spot
  47. bugs that had otherwise been unnoticed.
  48. Since the profiler uses information collected during the actual
  49. execution of your program, it can be used on programs that are too large
  50. or too complex to analyze by reading the source. However, how your
  51. program is run will affect the information that shows up in the profile
  52. data. If you don't use some feature of your program while it is being
  53. profiled, no profile information will be generated for that feature.
  54. Profiling has several steps:
  55. * You must compile and link your program with profiling enabled.
  56. *Note Compiling a Program for Profiling: Compiling.
  57. * You must execute your program to generate a profile data file.
  58. *Note Executing the Program: Executing.
  59. * You must run 'gprof' to analyze the profile data. *Note 'gprof'
  60. Command Summary: Invoking.
  61. The next three chapters explain these steps in greater detail.
  62. Several forms of output are available from the analysis.
  63. The "flat profile" shows how much time your program spent in each
  64. function, and how many times that function was called. If you simply
  65. want to know which functions burn most of the cycles, it is stated
  66. concisely here. *Note The Flat Profile: Flat Profile.
  67. The "call graph" shows, for each function, which functions called it,
  68. which other functions it called, and how many times. There is also an
  69. estimate of how much time was spent in the subroutines of each function.
  70. This can suggest places where you might try to eliminate function calls
  71. that use a lot of time. *Note The Call Graph: Call Graph.
  72. The "annotated source" listing is a copy of the program's source
  73. code, labeled with the number of times each line of the program was
  74. executed. *Note The Annotated Source Listing: Annotated Source.
  75. To better understand how profiling works, you may wish to read a
  76. description of its implementation. *Note Implementation of Profiling:
  77. Implementation.
  78. 
  79. File: gprof.info, Node: Compiling, Next: Executing, Prev: Introduction, Up: Top
  80. 2 Compiling a Program for Profiling
  81. ***********************************
  82. The first step in generating profile information for your program is to
  83. compile and link it with profiling enabled.
  84. To compile a source file for profiling, specify the '-pg' option when
  85. you run the compiler. (This is in addition to the options you normally
  86. use.)
  87. To link the program for profiling, if you use a compiler such as 'cc'
  88. to do the linking, simply specify '-pg' in addition to your usual
  89. options. The same option, '-pg', alters either compilation or linking
  90. to do what is necessary for profiling. Here are examples:
  91. If you use gcc 2.95.x or 3.0.x, you may need to add the
  92. '-fprofile-arcs' option to the compile line along with '-pg' in order to
  93. allow the call-graphs to be properly included in the gmon.out file.
  94. cc -g -c myprog.c utils.c -pg
  95. cc -o myprog myprog.o utils.o -pg
  96. The '-pg' option also works with a command that both compiles and
  97. links:
  98. cc -o myprog myprog.c utils.c -g -pg
  99. Note: The '-pg' option must be part of your compilation options as
  100. well as your link options. If it is not then no call-graph data will be
  101. gathered and when you run 'gprof' you will get an error message like
  102. this:
  103. gprof: gmon.out file is missing call-graph data
  104. If you add the '-Q' switch to suppress the printing of the call graph
  105. data you will still be able to see the time samples:
  106. Flat profile:
  107. Each sample counts as 0.01 seconds.
  108. % cumulative self self total
  109. time seconds seconds calls Ts/call Ts/call name
  110. 44.12 0.07 0.07 zazLoop
  111. 35.29 0.14 0.06 main
  112. 20.59 0.17 0.04 bazMillion
  113. If you run the linker 'ld' directly instead of through a compiler
  114. such as 'cc', you may have to specify a profiling startup file 'gcrt0.o'
  115. as the first input file instead of the usual startup file 'crt0.o'. In
  116. addition, you would probably want to specify the profiling C library,
  117. 'libc_p.a', by writing '-lc_p' instead of the usual '-lc'. This is not
  118. absolutely necessary, but doing this gives you number-of-calls
  119. information for standard library functions such as 'read' and 'open'.
  120. For example:
  121. ld -o myprog /lib/gcrt0.o myprog.o utils.o -lc_p
  122. If you are running the program on a system which supports shared
  123. libraries you may run into problems with the profiling support code in a
  124. shared library being called before that library has been fully
  125. initialised. This is usually detected by the program encountering a
  126. segmentation fault as soon as it is run. The solution is to link
  127. against a static version of the library containing the profiling support
  128. code, which for 'gcc' users can be done via the '-static' or
  129. '-static-libgcc' command-line option. For example:
  130. gcc -g -pg -static-libgcc myprog.c utils.c -o myprog
  131. If you compile only some of the modules of the program with '-pg',
  132. you can still profile the program, but you won't get complete
  133. information about the modules that were compiled without '-pg'. The
  134. only information you get for the functions in those modules is the total
  135. time spent in them; there is no record of how many times they were
  136. called, or from where. This will not affect the flat profile (except
  137. that the 'calls' field for the functions will be blank), but will
  138. greatly reduce the usefulness of the call graph.
  139. If you wish to perform line-by-line profiling you should use the
  140. 'gcov' tool instead of 'gprof'. See that tool's manual or info pages
  141. for more details of how to do this.
  142. Note, older versions of 'gcc' produce line-by-line profiling
  143. information that works with 'gprof' rather than 'gcov' so there is still
  144. support for displaying this kind of information in 'gprof'. *Note
  145. Line-by-line Profiling: Line-by-line.
  146. It also worth noting that 'gcc' implements a '-finstrument-functions'
  147. command-line option which will insert calls to special user supplied
  148. instrumentation routines at the entry and exit of every function in
  149. their program. This can be used to implement an alternative profiling
  150. scheme.
  151. 
  152. File: gprof.info, Node: Executing, Next: Invoking, Prev: Compiling, Up: Top
  153. 3 Executing the Program
  154. ***********************
  155. Once the program is compiled for profiling, you must run it in order to
  156. generate the information that 'gprof' needs. Simply run the program as
  157. usual, using the normal arguments, file names, etc. The program should
  158. run normally, producing the same output as usual. It will, however, run
  159. somewhat slower than normal because of the time spent collecting and
  160. writing the profile data.
  161. The way you run the program--the arguments and input that you give
  162. it--may have a dramatic effect on what the profile information shows.
  163. The profile data will describe the parts of the program that were
  164. activated for the particular input you use. For example, if the first
  165. command you give to your program is to quit, the profile data will show
  166. the time used in initialization and in cleanup, but not much else.
  167. Your program will write the profile data into a file called
  168. 'gmon.out' just before exiting. If there is already a file called
  169. 'gmon.out', its contents are overwritten. There is currently no way to
  170. tell the program to write the profile data under a different name, but
  171. you can rename the file afterwards if you are concerned that it may be
  172. overwritten.
  173. In order to write the 'gmon.out' file properly, your program must
  174. exit normally: by returning from 'main' or by calling 'exit'. Calling
  175. the low-level function '_exit' does not write the profile data, and
  176. neither does abnormal termination due to an unhandled signal.
  177. The 'gmon.out' file is written in the program's _current working
  178. directory_ at the time it exits. This means that if your program calls
  179. 'chdir', the 'gmon.out' file will be left in the last directory your
  180. program 'chdir''d to. If you don't have permission to write in this
  181. directory, the file is not written, and you will get an error message.
  182. Older versions of the GNU profiling library may also write a file
  183. called 'bb.out'. This file, if present, contains an human-readable
  184. listing of the basic-block execution counts. Unfortunately, the
  185. appearance of a human-readable 'bb.out' means the basic-block counts
  186. didn't get written into 'gmon.out'. The Perl script 'bbconv.pl',
  187. included with the 'gprof' source distribution, will convert a 'bb.out'
  188. file into a format readable by 'gprof'. Invoke it like this:
  189. bbconv.pl < bb.out > BH-DATA
  190. This translates the information in 'bb.out' into a form that 'gprof'
  191. can understand. But you still need to tell 'gprof' about the existence
  192. of this translated information. To do that, include BB-DATA on the
  193. 'gprof' command line, _along with 'gmon.out'_, like this:
  194. gprof OPTIONS EXECUTABLE-FILE gmon.out BB-DATA [YET-MORE-PROFILE-DATA-FILES...] [> OUTFILE]
  195. 
  196. File: gprof.info, Node: Invoking, Next: Output, Prev: Executing, Up: Top
  197. 4 'gprof' Command Summary
  198. *************************
  199. After you have a profile data file 'gmon.out', you can run 'gprof' to
  200. interpret the information in it. The 'gprof' program prints a flat
  201. profile and a call graph on standard output. Typically you would
  202. redirect the output of 'gprof' into a file with '>'.
  203. You run 'gprof' like this:
  204. gprof OPTIONS [EXECUTABLE-FILE [PROFILE-DATA-FILES...]] [> OUTFILE]
  205. Here square-brackets indicate optional arguments.
  206. If you omit the executable file name, the file 'a.out' is used. If
  207. you give no profile data file name, the file 'gmon.out' is used. If any
  208. file is not in the proper format, or if the profile data file does not
  209. appear to belong to the executable file, an error message is printed.
  210. You can give more than one profile data file by entering all their
  211. names after the executable file name; then the statistics in all the
  212. data files are summed together.
  213. The order of these options does not matter.
  214. * Menu:
  215. * Output Options:: Controlling 'gprof''s output style
  216. * Analysis Options:: Controlling how 'gprof' analyzes its data
  217. * Miscellaneous Options::
  218. * Deprecated Options:: Options you no longer need to use, but which
  219. have been retained for compatibility
  220. * Symspecs:: Specifying functions to include or exclude
  221. 
  222. File: gprof.info, Node: Output Options, Next: Analysis Options, Up: Invoking
  223. 4.1 Output Options
  224. ==================
  225. These options specify which of several output formats 'gprof' should
  226. produce.
  227. Many of these options take an optional "symspec" to specify functions
  228. to be included or excluded. These options can be specified multiple
  229. times, with different symspecs, to include or exclude sets of symbols.
  230. *Note Symspecs: Symspecs.
  231. Specifying any of these options overrides the default ('-p -q'),
  232. which prints a flat profile and call graph analysis for all functions.
  233. '-A[SYMSPEC]'
  234. '--annotated-source[=SYMSPEC]'
  235. The '-A' option causes 'gprof' to print annotated source code. If
  236. SYMSPEC is specified, print output only for matching symbols.
  237. *Note The Annotated Source Listing: Annotated Source.
  238. '-b'
  239. '--brief'
  240. If the '-b' option is given, 'gprof' doesn't print the verbose
  241. blurbs that try to explain the meaning of all of the fields in the
  242. tables. This is useful if you intend to print out the output, or
  243. are tired of seeing the blurbs.
  244. '-C[SYMSPEC]'
  245. '--exec-counts[=SYMSPEC]'
  246. The '-C' option causes 'gprof' to print a tally of functions and
  247. the number of times each was called. If SYMSPEC is specified,
  248. print tally only for matching symbols.
  249. If the profile data file contains basic-block count records,
  250. specifying the '-l' option, along with '-C', will cause basic-block
  251. execution counts to be tallied and displayed.
  252. '-i'
  253. '--file-info'
  254. The '-i' option causes 'gprof' to display summary information about
  255. the profile data file(s) and then exit. The number of histogram,
  256. call graph, and basic-block count records is displayed.
  257. '-I DIRS'
  258. '--directory-path=DIRS'
  259. The '-I' option specifies a list of search directories in which to
  260. find source files. Environment variable GPROF_PATH can also be
  261. used to convey this information. Used mostly for annotated source
  262. output.
  263. '-J[SYMSPEC]'
  264. '--no-annotated-source[=SYMSPEC]'
  265. The '-J' option causes 'gprof' not to print annotated source code.
  266. If SYMSPEC is specified, 'gprof' prints annotated source, but
  267. excludes matching symbols.
  268. '-L'
  269. '--print-path'
  270. Normally, source filenames are printed with the path component
  271. suppressed. The '-L' option causes 'gprof' to print the full
  272. pathname of source filenames, which is determined from symbolic
  273. debugging information in the image file and is relative to the
  274. directory in which the compiler was invoked.
  275. '-p[SYMSPEC]'
  276. '--flat-profile[=SYMSPEC]'
  277. The '-p' option causes 'gprof' to print a flat profile. If SYMSPEC
  278. is specified, print flat profile only for matching symbols. *Note
  279. The Flat Profile: Flat Profile.
  280. '-P[SYMSPEC]'
  281. '--no-flat-profile[=SYMSPEC]'
  282. The '-P' option causes 'gprof' to suppress printing a flat profile.
  283. If SYMSPEC is specified, 'gprof' prints a flat profile, but
  284. excludes matching symbols.
  285. '-q[SYMSPEC]'
  286. '--graph[=SYMSPEC]'
  287. The '-q' option causes 'gprof' to print the call graph analysis.
  288. If SYMSPEC is specified, print call graph only for matching symbols
  289. and their children. *Note The Call Graph: Call Graph.
  290. '-Q[SYMSPEC]'
  291. '--no-graph[=SYMSPEC]'
  292. The '-Q' option causes 'gprof' to suppress printing the call graph.
  293. If SYMSPEC is specified, 'gprof' prints a call graph, but excludes
  294. matching symbols.
  295. '-t'
  296. '--table-length=NUM'
  297. The '-t' option causes the NUM most active source lines in each
  298. source file to be listed when source annotation is enabled. The
  299. default is 10.
  300. '-y'
  301. '--separate-files'
  302. This option affects annotated source output only. Normally,
  303. 'gprof' prints annotated source files to standard-output. If this
  304. option is specified, annotated source for a file named
  305. 'path/FILENAME' is generated in the file 'FILENAME-ann'. If the
  306. underlying file system would truncate 'FILENAME-ann' so that it
  307. overwrites the original 'FILENAME', 'gprof' generates annotated
  308. source in the file 'FILENAME.ann' instead (if the original file
  309. name has an extension, that extension is _replaced_ with '.ann').
  310. '-Z[SYMSPEC]'
  311. '--no-exec-counts[=SYMSPEC]'
  312. The '-Z' option causes 'gprof' not to print a tally of functions
  313. and the number of times each was called. If SYMSPEC is specified,
  314. print tally, but exclude matching symbols.
  315. '-r'
  316. '--function-ordering'
  317. The '--function-ordering' option causes 'gprof' to print a
  318. suggested function ordering for the program based on profiling
  319. data. This option suggests an ordering which may improve paging,
  320. tlb and cache behavior for the program on systems which support
  321. arbitrary ordering of functions in an executable.
  322. The exact details of how to force the linker to place functions in
  323. a particular order is system dependent and out of the scope of this
  324. manual.
  325. '-R MAP_FILE'
  326. '--file-ordering MAP_FILE'
  327. The '--file-ordering' option causes 'gprof' to print a suggested .o
  328. link line ordering for the program based on profiling data. This
  329. option suggests an ordering which may improve paging, tlb and cache
  330. behavior for the program on systems which do not support arbitrary
  331. ordering of functions in an executable.
  332. Use of the '-a' argument is highly recommended with this option.
  333. The MAP_FILE argument is a pathname to a file which provides
  334. function name to object file mappings. The format of the file is
  335. similar to the output of the program 'nm'.
  336. c-parse.o:00000000 T yyparse
  337. c-parse.o:00000004 C yyerrflag
  338. c-lang.o:00000000 T maybe_objc_method_name
  339. c-lang.o:00000000 T print_lang_statistics
  340. c-lang.o:00000000 T recognize_objc_keyword
  341. c-decl.o:00000000 T print_lang_identifier
  342. c-decl.o:00000000 T print_lang_type
  343. ...
  344. To create a MAP_FILE with GNU 'nm', type a command like 'nm
  345. --extern-only --defined-only -v --print-file-name program-name'.
  346. '-T'
  347. '--traditional'
  348. The '-T' option causes 'gprof' to print its output in "traditional"
  349. BSD style.
  350. '-w WIDTH'
  351. '--width=WIDTH'
  352. Sets width of output lines to WIDTH. Currently only used when
  353. printing the function index at the bottom of the call graph.
  354. '-x'
  355. '--all-lines'
  356. This option affects annotated source output only. By default, only
  357. the lines at the beginning of a basic-block are annotated. If this
  358. option is specified, every line in a basic-block is annotated by
  359. repeating the annotation for the first line. This behavior is
  360. similar to 'tcov''s '-a'.
  361. '--demangle[=STYLE]'
  362. '--no-demangle'
  363. These options control whether C++ symbol names should be demangled
  364. when printing output. The default is to demangle symbols. The
  365. '--no-demangle' option may be used to turn off demangling.
  366. Different compilers have different mangling styles. The optional
  367. demangling style argument can be used to choose an appropriate
  368. demangling style for your compiler.
  369. 
  370. File: gprof.info, Node: Analysis Options, Next: Miscellaneous Options, Prev: Output Options, Up: Invoking
  371. 4.2 Analysis Options
  372. ====================
  373. '-a'
  374. '--no-static'
  375. The '-a' option causes 'gprof' to suppress the printing of
  376. statically declared (private) functions. (These are functions
  377. whose names are not listed as global, and which are not visible
  378. outside the file/function/block where they were defined.) Time
  379. spent in these functions, calls to/from them, etc., will all be
  380. attributed to the function that was loaded directly before it in
  381. the executable file. This option affects both the flat profile and
  382. the call graph.
  383. '-c'
  384. '--static-call-graph'
  385. The '-c' option causes the call graph of the program to be
  386. augmented by a heuristic which examines the text space of the
  387. object file and identifies function calls in the binary machine
  388. code. Since normal call graph records are only generated when
  389. functions are entered, this option identifies children that could
  390. have been called, but never were. Calls to functions that were not
  391. compiled with profiling enabled are also identified, but only if
  392. symbol table entries are present for them. Calls to dynamic
  393. library routines are typically _not_ found by this option. Parents
  394. or children identified via this heuristic are indicated in the call
  395. graph with call counts of '0'.
  396. '-D'
  397. '--ignore-non-functions'
  398. The '-D' option causes 'gprof' to ignore symbols which are not
  399. known to be functions. This option will give more accurate profile
  400. data on systems where it is supported (Solaris and HPUX for
  401. example).
  402. '-k FROM/TO'
  403. The '-k' option allows you to delete from the call graph any arcs
  404. from symbols matching symspec FROM to those matching symspec TO.
  405. '-l'
  406. '--line'
  407. The '-l' option enables line-by-line profiling, which causes
  408. histogram hits to be charged to individual source code lines,
  409. instead of functions. This feature only works with programs
  410. compiled by older versions of the 'gcc' compiler. Newer versions
  411. of 'gcc' are designed to work with the 'gcov' tool instead.
  412. If the program was compiled with basic-block counting enabled, this
  413. option will also identify how many times each line of code was
  414. executed. While line-by-line profiling can help isolate where in a
  415. large function a program is spending its time, it also
  416. significantly increases the running time of 'gprof', and magnifies
  417. statistical inaccuracies. *Note Statistical Sampling Error:
  418. Sampling Error.
  419. '--inline-file-names'
  420. This option causes 'gprof' to print the source file after each
  421. symbol in both the flat profile and the call graph. The full path
  422. to the file is printed if used with the '-L' option.
  423. '-m NUM'
  424. '--min-count=NUM'
  425. This option affects execution count output only. Symbols that are
  426. executed less than NUM times are suppressed.
  427. '-nSYMSPEC'
  428. '--time=SYMSPEC'
  429. The '-n' option causes 'gprof', in its call graph analysis, to only
  430. propagate times for symbols matching SYMSPEC.
  431. '-NSYMSPEC'
  432. '--no-time=SYMSPEC'
  433. The '-n' option causes 'gprof', in its call graph analysis, not to
  434. propagate times for symbols matching SYMSPEC.
  435. '-SFILENAME'
  436. '--external-symbol-table=FILENAME'
  437. The '-S' option causes 'gprof' to read an external symbol table
  438. file, such as '/proc/kallsyms', rather than read the symbol table
  439. from the given object file (the default is 'a.out'). This is
  440. useful for profiling kernel modules.
  441. '-z'
  442. '--display-unused-functions'
  443. If you give the '-z' option, 'gprof' will mention all functions in
  444. the flat profile, even those that were never called, and that had
  445. no time spent in them. This is useful in conjunction with the '-c'
  446. option for discovering which routines were never called.
  447. 
  448. File: gprof.info, Node: Miscellaneous Options, Next: Deprecated Options, Prev: Analysis Options, Up: Invoking
  449. 4.3 Miscellaneous Options
  450. =========================
  451. '-d[NUM]'
  452. '--debug[=NUM]'
  453. The '-d NUM' option specifies debugging options. If NUM is not
  454. specified, enable all debugging. *Note Debugging 'gprof':
  455. Debugging.
  456. '-h'
  457. '--help'
  458. The '-h' option prints command line usage.
  459. '-ONAME'
  460. '--file-format=NAME'
  461. Selects the format of the profile data files. Recognized formats
  462. are 'auto' (the default), 'bsd', '4.4bsd', 'magic', and 'prof' (not
  463. yet supported).
  464. '-s'
  465. '--sum'
  466. The '-s' option causes 'gprof' to summarize the information in the
  467. profile data files it read in, and write out a profile data file
  468. called 'gmon.sum', which contains all the information from the
  469. profile data files that 'gprof' read in. The file 'gmon.sum' may
  470. be one of the specified input files; the effect of this is to merge
  471. the data in the other input files into 'gmon.sum'.
  472. Eventually you can run 'gprof' again without '-s' to analyze the
  473. cumulative data in the file 'gmon.sum'.
  474. '-v'
  475. '--version'
  476. The '-v' flag causes 'gprof' to print the current version number,
  477. and then exit.
  478. 
  479. File: gprof.info, Node: Deprecated Options, Next: Symspecs, Prev: Miscellaneous Options, Up: Invoking
  480. 4.4 Deprecated Options
  481. ======================
  482. These options have been replaced with newer versions that use symspecs.
  483. '-e FUNCTION_NAME'
  484. The '-e FUNCTION' option tells 'gprof' to not print information
  485. about the function FUNCTION_NAME (and its children...) in the call
  486. graph. The function will still be listed as a child of any
  487. functions that call it, but its index number will be shown as '[not
  488. printed]'. More than one '-e' option may be given; only one
  489. FUNCTION_NAME may be indicated with each '-e' option.
  490. '-E FUNCTION_NAME'
  491. The '-E FUNCTION' option works like the '-e' option, but time spent
  492. in the function (and children who were not called from anywhere
  493. else), will not be used to compute the percentages-of-time for the
  494. call graph. More than one '-E' option may be given; only one
  495. FUNCTION_NAME may be indicated with each '-E' option.
  496. '-f FUNCTION_NAME'
  497. The '-f FUNCTION' option causes 'gprof' to limit the call graph to
  498. the function FUNCTION_NAME and its children (and their
  499. children...). More than one '-f' option may be given; only one
  500. FUNCTION_NAME may be indicated with each '-f' option.
  501. '-F FUNCTION_NAME'
  502. The '-F FUNCTION' option works like the '-f' option, but only time
  503. spent in the function and its children (and their children...) will
  504. be used to determine total-time and percentages-of-time for the
  505. call graph. More than one '-F' option may be given; only one
  506. FUNCTION_NAME may be indicated with each '-F' option. The '-F'
  507. option overrides the '-E' option.
  508. Note that only one function can be specified with each '-e', '-E',
  509. '-f' or '-F' option. To specify more than one function, use multiple
  510. options. For example, this command:
  511. gprof -e boring -f foo -f bar myprogram > gprof.output
  512. lists in the call graph all functions that were reached from either
  513. 'foo' or 'bar' and were not reachable from 'boring'.
  514. 
  515. File: gprof.info, Node: Symspecs, Prev: Deprecated Options, Up: Invoking
  516. 4.5 Symspecs
  517. ============
  518. Many of the output options allow functions to be included or excluded
  519. using "symspecs" (symbol specifications), which observe the following
  520. syntax:
  521. filename_containing_a_dot
  522. | funcname_not_containing_a_dot
  523. | linenumber
  524. | ( [ any_filename ] `:' ( any_funcname | linenumber ) )
  525. Here are some sample symspecs:
  526. 'main.c'
  527. Selects everything in file 'main.c'--the dot in the string tells
  528. 'gprof' to interpret the string as a filename, rather than as a
  529. function name. To select a file whose name does not contain a dot,
  530. a trailing colon should be specified. For example, 'odd:' is
  531. interpreted as the file named 'odd'.
  532. 'main'
  533. Selects all functions named 'main'.
  534. Note that there may be multiple instances of the same function name
  535. because some of the definitions may be local (i.e., static).
  536. Unless a function name is unique in a program, you must use the
  537. colon notation explained below to specify a function from a
  538. specific source file.
  539. Sometimes, function names contain dots. In such cases, it is
  540. necessary to add a leading colon to the name. For example, ':.mul'
  541. selects function '.mul'.
  542. In some object file formats, symbols have a leading underscore.
  543. 'gprof' will normally not print these underscores. When you name a
  544. symbol in a symspec, you should type it exactly as 'gprof' prints
  545. it in its output. For example, if the compiler produces a symbol
  546. '_main' from your 'main' function, 'gprof' still prints it as
  547. 'main' in its output, so you should use 'main' in symspecs.
  548. 'main.c:main'
  549. Selects function 'main' in file 'main.c'.
  550. 'main.c:134'
  551. Selects line 134 in file 'main.c'.
  552. 
  553. File: gprof.info, Node: Output, Next: Inaccuracy, Prev: Invoking, Up: Top
  554. 5 Interpreting 'gprof''s Output
  555. *******************************
  556. 'gprof' can produce several different output styles, the most important
  557. of which are described below. The simplest output styles (file
  558. information, execution count, and function and file ordering) are not
  559. described here, but are documented with the respective options that
  560. trigger them. *Note Output Options: Output Options.
  561. * Menu:
  562. * Flat Profile:: The flat profile shows how much time was spent
  563. executing directly in each function.
  564. * Call Graph:: The call graph shows which functions called which
  565. others, and how much time each function used
  566. when its subroutine calls are included.
  567. * Line-by-line:: 'gprof' can analyze individual source code lines
  568. * Annotated Source:: The annotated source listing displays source code
  569. labeled with execution counts
  570. 
  571. File: gprof.info, Node: Flat Profile, Next: Call Graph, Up: Output
  572. 5.1 The Flat Profile
  573. ====================
  574. The "flat profile" shows the total amount of time your program spent
  575. executing each function. Unless the '-z' option is given, functions
  576. with no apparent time spent in them, and no apparent calls to them, are
  577. not mentioned. Note that if a function was not compiled for profiling,
  578. and didn't run long enough to show up on the program counter histogram,
  579. it will be indistinguishable from a function that was never called.
  580. This is part of a flat profile for a small program:
  581. Flat profile:
  582. Each sample counts as 0.01 seconds.
  583. % cumulative self self total
  584. time seconds seconds calls ms/call ms/call name
  585. 33.34 0.02 0.02 7208 0.00 0.00 open
  586. 16.67 0.03 0.01 244 0.04 0.12 offtime
  587. 16.67 0.04 0.01 8 1.25 1.25 memccpy
  588. 16.67 0.05 0.01 7 1.43 1.43 write
  589. 16.67 0.06 0.01 mcount
  590. 0.00 0.06 0.00 236 0.00 0.00 tzset
  591. 0.00 0.06 0.00 192 0.00 0.00 tolower
  592. 0.00 0.06 0.00 47 0.00 0.00 strlen
  593. 0.00 0.06 0.00 45 0.00 0.00 strchr
  594. 0.00 0.06 0.00 1 0.00 50.00 main
  595. 0.00 0.06 0.00 1 0.00 0.00 memcpy
  596. 0.00 0.06 0.00 1 0.00 10.11 print
  597. 0.00 0.06 0.00 1 0.00 0.00 profil
  598. 0.00 0.06 0.00 1 0.00 50.00 report
  599. ...
  600. The functions are sorted first by decreasing run-time spent in them,
  601. then by decreasing number of calls, then alphabetically by name. The
  602. functions 'mcount' and 'profil' are part of the profiling apparatus and
  603. appear in every flat profile; their time gives a measure of the amount
  604. of overhead due to profiling.
  605. Just before the column headers, a statement appears indicating how
  606. much time each sample counted as. This "sampling period" estimates the
  607. margin of error in each of the time figures. A time figure that is not
  608. much larger than this is not reliable. In this example, each sample
  609. counted as 0.01 seconds, suggesting a 100 Hz sampling rate. The
  610. program's total execution time was 0.06 seconds, as indicated by the
  611. 'cumulative seconds' field. Since each sample counted for 0.01 seconds,
  612. this means only six samples were taken during the run. Two of the
  613. samples occurred while the program was in the 'open' function, as
  614. indicated by the 'self seconds' field. Each of the other four samples
  615. occurred one each in 'offtime', 'memccpy', 'write', and 'mcount'. Since
  616. only six samples were taken, none of these values can be regarded as
  617. particularly reliable. In another run, the 'self seconds' field for
  618. 'mcount' might well be '0.00' or '0.02'. *Note Statistical Sampling
  619. Error: Sampling Error, for a complete discussion.
  620. The remaining functions in the listing (those whose 'self seconds'
  621. field is '0.00') didn't appear in the histogram samples at all.
  622. However, the call graph indicated that they were called, so therefore
  623. they are listed, sorted in decreasing order by the 'calls' field.
  624. Clearly some time was spent executing these functions, but the paucity
  625. of histogram samples prevents any determination of how much time each
  626. took.
  627. Here is what the fields in each line mean:
  628. '% time'
  629. This is the percentage of the total execution time your program
  630. spent in this function. These should all add up to 100%.
  631. 'cumulative seconds'
  632. This is the cumulative total number of seconds the computer spent
  633. executing this functions, plus the time spent in all the functions
  634. above this one in this table.
  635. 'self seconds'
  636. This is the number of seconds accounted for by this function alone.
  637. The flat profile listing is sorted first by this number.
  638. 'calls'
  639. This is the total number of times the function was called. If the
  640. function was never called, or the number of times it was called
  641. cannot be determined (probably because the function was not
  642. compiled with profiling enabled), the "calls" field is blank.
  643. 'self ms/call'
  644. This represents the average number of milliseconds spent in this
  645. function per call, if this function is profiled. Otherwise, this
  646. field is blank for this function.
  647. 'total ms/call'
  648. This represents the average number of milliseconds spent in this
  649. function and its descendants per call, if this function is
  650. profiled. Otherwise, this field is blank for this function. This
  651. is the only field in the flat profile that uses call graph
  652. analysis.
  653. 'name'
  654. This is the name of the function. The flat profile is sorted by
  655. this field alphabetically after the "self seconds" and "calls"
  656. fields are sorted.
  657. 
  658. File: gprof.info, Node: Call Graph, Next: Line-by-line, Prev: Flat Profile, Up: Output
  659. 5.2 The Call Graph
  660. ==================
  661. The "call graph" shows how much time was spent in each function and its
  662. children. From this information, you can find functions that, while
  663. they themselves may not have used much time, called other functions that
  664. did use unusual amounts of time.
  665. Here is a sample call from a small program. This call came from the
  666. same 'gprof' run as the flat profile example in the previous section.
  667. granularity: each sample hit covers 2 byte(s) for 20.00% of 0.05 seconds
  668. index % time self children called name
  669. <spontaneous>
  670. [1] 100.0 0.00 0.05 start [1]
  671. 0.00 0.05 1/1 main [2]
  672. 0.00 0.00 1/2 on_exit [28]
  673. 0.00 0.00 1/1 exit [59]
  674. -----------------------------------------------
  675. 0.00 0.05 1/1 start [1]
  676. [2] 100.0 0.00 0.05 1 main [2]
  677. 0.00 0.05 1/1 report [3]
  678. -----------------------------------------------
  679. 0.00 0.05 1/1 main [2]
  680. [3] 100.0 0.00 0.05 1 report [3]
  681. 0.00 0.03 8/8 timelocal [6]
  682. 0.00 0.01 1/1 print [9]
  683. 0.00 0.01 9/9 fgets [12]
  684. 0.00 0.00 12/34 strncmp <cycle 1> [40]
  685. 0.00 0.00 8/8 lookup [20]
  686. 0.00 0.00 1/1 fopen [21]
  687. 0.00 0.00 8/8 chewtime [24]
  688. 0.00 0.00 8/16 skipspace [44]
  689. -----------------------------------------------
  690. [4] 59.8 0.01 0.02 8+472 <cycle 2 as a whole> [4]
  691. 0.01 0.02 244+260 offtime <cycle 2> [7]
  692. 0.00 0.00 236+1 tzset <cycle 2> [26]
  693. -----------------------------------------------
  694. The lines full of dashes divide this table into "entries", one for
  695. each function. Each entry has one or more lines.
  696. In each entry, the primary line is the one that starts with an index
  697. number in square brackets. The end of this line says which function the
  698. entry is for. The preceding lines in the entry describe the callers of
  699. this function and the following lines describe its subroutines (also
  700. called "children" when we speak of the call graph).
  701. The entries are sorted by time spent in the function and its
  702. subroutines.
  703. The internal profiling function 'mcount' (*note The Flat Profile:
  704. Flat Profile.) is never mentioned in the call graph.
  705. * Menu:
  706. * Primary:: Details of the primary line's contents.
  707. * Callers:: Details of caller-lines' contents.
  708. * Subroutines:: Details of subroutine-lines' contents.
  709. * Cycles:: When there are cycles of recursion,
  710. such as 'a' calls 'b' calls 'a'...
  711. 
  712. File: gprof.info, Node: Primary, Next: Callers, Up: Call Graph
  713. 5.2.1 The Primary Line
  714. ----------------------
  715. The "primary line" in a call graph entry is the line that describes the
  716. function which the entry is about and gives the overall statistics for
  717. this function.
  718. For reference, we repeat the primary line from the entry for function
  719. 'report' in our main example, together with the heading line that shows
  720. the names of the fields:
  721. index % time self children called name
  722. ...
  723. [3] 100.0 0.00 0.05 1 report [3]
  724. Here is what the fields in the primary line mean:
  725. 'index'
  726. Entries are numbered with consecutive integers. Each function
  727. therefore has an index number, which appears at the beginning of
  728. its primary line.
  729. Each cross-reference to a function, as a caller or subroutine of
  730. another, gives its index number as well as its name. The index
  731. number guides you if you wish to look for the entry for that
  732. function.
  733. '% time'
  734. This is the percentage of the total time that was spent in this
  735. function, including time spent in subroutines called from this
  736. function.
  737. The time spent in this function is counted again for the callers of
  738. this function. Therefore, adding up these percentages is
  739. meaningless.
  740. 'self'
  741. This is the total amount of time spent in this function. This
  742. should be identical to the number printed in the 'seconds' field
  743. for this function in the flat profile.
  744. 'children'
  745. This is the total amount of time spent in the subroutine calls made
  746. by this function. This should be equal to the sum of all the
  747. 'self' and 'children' entries of the children listed directly below
  748. this function.
  749. 'called'
  750. This is the number of times the function was called.
  751. If the function called itself recursively, there are two numbers,
  752. separated by a '+'. The first number counts non-recursive calls,
  753. and the second counts recursive calls.
  754. In the example above, the function 'report' was called once from
  755. 'main'.
  756. 'name'
  757. This is the name of the current function. The index number is
  758. repeated after it.
  759. If the function is part of a cycle of recursion, the cycle number
  760. is printed between the function's name and the index number (*note
  761. How Mutually Recursive Functions Are Described: Cycles.). For
  762. example, if function 'gnurr' is part of cycle number one, and has
  763. index number twelve, its primary line would be end like this:
  764. gnurr <cycle 1> [12]
  765. 
  766. File: gprof.info, Node: Callers, Next: Subroutines, Prev: Primary, Up: Call Graph
  767. 5.2.2 Lines for a Function's Callers
  768. ------------------------------------
  769. A function's entry has a line for each function it was called by. These
  770. lines' fields correspond to the fields of the primary line, but their
  771. meanings are different because of the difference in context.
  772. For reference, we repeat two lines from the entry for the function
  773. 'report', the primary line and one caller-line preceding it, together
  774. with the heading line that shows the names of the fields:
  775. index % time self children called name
  776. ...
  777. 0.00 0.05 1/1 main [2]
  778. [3] 100.0 0.00 0.05 1 report [3]
  779. Here are the meanings of the fields in the caller-line for 'report'
  780. called from 'main':
  781. 'self'
  782. An estimate of the amount of time spent in 'report' itself when it
  783. was called from 'main'.
  784. 'children'
  785. An estimate of the amount of time spent in subroutines of 'report'
  786. when 'report' was called from 'main'.
  787. The sum of the 'self' and 'children' fields is an estimate of the
  788. amount of time spent within calls to 'report' from 'main'.
  789. 'called'
  790. Two numbers: the number of times 'report' was called from 'main',
  791. followed by the total number of non-recursive calls to 'report'
  792. from all its callers.
  793. 'name and index number'
  794. The name of the caller of 'report' to which this line applies,
  795. followed by the caller's index number.
  796. Not all functions have entries in the call graph; some options to
  797. 'gprof' request the omission of certain functions. When a caller
  798. has no entry of its own, it still has caller-lines in the entries
  799. of the functions it calls.
  800. If the caller is part of a recursion cycle, the cycle number is
  801. printed between the name and the index number.
  802. If the identity of the callers of a function cannot be determined, a
  803. dummy caller-line is printed which has '<spontaneous>' as the "caller's
  804. name" and all other fields blank. This can happen for signal handlers.
  805. 
  806. File: gprof.info, Node: Subroutines, Next: Cycles, Prev: Callers, Up: Call Graph
  807. 5.2.3 Lines for a Function's Subroutines
  808. ----------------------------------------
  809. A function's entry has a line for each of its subroutines--in other
  810. words, a line for each other function that it called. These lines'
  811. fields correspond to the fields of the primary line, but their meanings
  812. are different because of the difference in context.
  813. For reference, we repeat two lines from the entry for the function
  814. 'main', the primary line and a line for a subroutine, together with the
  815. heading line that shows the names of the fields:
  816. index % time self children called name
  817. ...
  818. [2] 100.0 0.00 0.05 1 main [2]
  819. 0.00 0.05 1/1 report [3]
  820. Here are the meanings of the fields in the subroutine-line for 'main'
  821. calling 'report':
  822. 'self'
  823. An estimate of the amount of time spent directly within 'report'
  824. when 'report' was called from 'main'.
  825. 'children'
  826. An estimate of the amount of time spent in subroutines of 'report'
  827. when 'report' was called from 'main'.
  828. The sum of the 'self' and 'children' fields is an estimate of the
  829. total time spent in calls to 'report' from 'main'.
  830. 'called'
  831. Two numbers, the number of calls to 'report' from 'main' followed
  832. by the total number of non-recursive calls to 'report'. This ratio
  833. is used to determine how much of 'report''s 'self' and 'children'
  834. time gets credited to 'main'. *Note Estimating 'children' Times:
  835. Assumptions.
  836. 'name'
  837. The name of the subroutine of 'main' to which this line applies,
  838. followed by the subroutine's index number.
  839. If the caller is part of a recursion cycle, the cycle number is
  840. printed between the name and the index number.
  841. 
  842. File: gprof.info, Node: Cycles, Prev: Subroutines, Up: Call Graph
  843. 5.2.4 How Mutually Recursive Functions Are Described
  844. ----------------------------------------------------
  845. The graph may be complicated by the presence of "cycles of recursion" in
  846. the call graph. A cycle exists if a function calls another function
  847. that (directly or indirectly) calls (or appears to call) the original
  848. function. For example: if 'a' calls 'b', and 'b' calls 'a', then 'a'
  849. and 'b' form a cycle.
  850. Whenever there are call paths both ways between a pair of functions,
  851. they belong to the same cycle. If 'a' and 'b' call each other and 'b'
  852. and 'c' call each other, all three make one cycle. Note that even if
  853. 'b' only calls 'a' if it was not called from 'a', 'gprof' cannot
  854. determine this, so 'a' and 'b' are still considered a cycle.
  855. The cycles are numbered with consecutive integers. When a function
  856. belongs to a cycle, each time the function name appears in the call
  857. graph it is followed by '<cycle NUMBER>'.
  858. The reason cycles matter is that they make the time values in the
  859. call graph paradoxical. The "time spent in children" of 'a' should
  860. include the time spent in its subroutine 'b' and in 'b''s
  861. subroutines--but one of 'b''s subroutines is 'a'! How much of 'a''s
  862. time should be included in the children of 'a', when 'a' is indirectly
  863. recursive?
  864. The way 'gprof' resolves this paradox is by creating a single entry
  865. for the cycle as a whole. The primary line of this entry describes the
  866. total time spent directly in the functions of the cycle. The
  867. "subroutines" of the cycle are the individual functions of the cycle,
  868. and all other functions that were called directly by them. The
  869. "callers" of the cycle are the functions, outside the cycle, that called
  870. functions in the cycle.
  871. Here is an example portion of a call graph which shows a cycle
  872. containing functions 'a' and 'b'. The cycle was entered by a call to
  873. 'a' from 'main'; both 'a' and 'b' called 'c'.
  874. index % time self children called name
  875. ----------------------------------------
  876. 1.77 0 1/1 main [2]
  877. [3] 91.71 1.77 0 1+5 <cycle 1 as a whole> [3]
  878. 1.02 0 3 b <cycle 1> [4]
  879. 0.75 0 2 a <cycle 1> [5]
  880. ----------------------------------------
  881. 3 a <cycle 1> [5]
  882. [4] 52.85 1.02 0 0 b <cycle 1> [4]
  883. 2 a <cycle 1> [5]
  884. 0 0 3/6 c [6]
  885. ----------------------------------------
  886. 1.77 0 1/1 main [2]
  887. 2 b <cycle 1> [4]
  888. [5] 38.86 0.75 0 1 a <cycle 1> [5]
  889. 3 b <cycle 1> [4]
  890. 0 0 3/6 c [6]
  891. ----------------------------------------
  892. (The entire call graph for this program contains in addition an entry
  893. for 'main', which calls 'a', and an entry for 'c', with callers 'a' and
  894. 'b'.)
  895. index % time self children called name
  896. <spontaneous>
  897. [1] 100.00 0 1.93 0 start [1]
  898. 0.16 1.77 1/1 main [2]
  899. ----------------------------------------
  900. 0.16 1.77 1/1 start [1]
  901. [2] 100.00 0.16 1.77 1 main [2]
  902. 1.77 0 1/1 a <cycle 1> [5]
  903. ----------------------------------------
  904. 1.77 0 1/1 main [2]
  905. [3] 91.71 1.77 0 1+5 <cycle 1 as a whole> [3]
  906. 1.02 0 3 b <cycle 1> [4]
  907. 0.75 0 2 a <cycle 1> [5]
  908. 0 0 6/6 c [6]
  909. ----------------------------------------
  910. 3 a <cycle 1> [5]
  911. [4] 52.85 1.02 0 0 b <cycle 1> [4]
  912. 2 a <cycle 1> [5]
  913. 0 0 3/6 c [6]
  914. ----------------------------------------
  915. 1.77 0 1/1 main [2]
  916. 2 b <cycle 1> [4]
  917. [5] 38.86 0.75 0 1 a <cycle 1> [5]
  918. 3 b <cycle 1> [4]
  919. 0 0 3/6 c [6]
  920. ----------------------------------------
  921. 0 0 3/6 b <cycle 1> [4]
  922. 0 0 3/6 a <cycle 1> [5]
  923. [6] 0.00 0 0 6 c [6]
  924. ----------------------------------------
  925. The 'self' field of the cycle's primary line is the total time spent
  926. in all the functions of the cycle. It equals the sum of the 'self'
  927. fields for the individual functions in the cycle, found in the entry in
  928. the subroutine lines for these functions.
  929. The 'children' fields of the cycle's primary line and subroutine
  930. lines count only subroutines outside the cycle. Even though 'a' calls
  931. 'b', the time spent in those calls to 'b' is not counted in 'a''s
  932. 'children' time. Thus, we do not encounter the problem of what to do
  933. when the time in those calls to 'b' includes indirect recursive calls
  934. back to 'a'.
  935. The 'children' field of a caller-line in the cycle's entry estimates
  936. the amount of time spent _in the whole cycle_, and its other
  937. subroutines, on the times when that caller called a function in the
  938. cycle.
  939. The 'called' field in the primary line for the cycle has two numbers:
  940. first, the number of times functions in the cycle were called by
  941. functions outside the cycle; second, the number of times they were
  942. called by functions in the cycle (including times when a function in the
  943. cycle calls itself). This is a generalization of the usual split into
  944. non-recursive and recursive calls.
  945. The 'called' field of a subroutine-line for a cycle member in the
  946. cycle's entry says how many time that function was called from functions
  947. in the cycle. The total of all these is the second number in the
  948. primary line's 'called' field.
  949. In the individual entry for a function in a cycle, the other
  950. functions in the same cycle can appear as subroutines and as callers.
  951. These lines show how many times each function in the cycle called or was
  952. called from each other function in the cycle. The 'self' and 'children'
  953. fields in these lines are blank because of the difficulty of defining
  954. meanings for them when recursion is going on.
  955. 
  956. File: gprof.info, Node: Line-by-line, Next: Annotated Source, Prev: Call Graph, Up: Output
  957. 5.3 Line-by-line Profiling
  958. ==========================
  959. 'gprof''s '-l' option causes the program to perform "line-by-line"
  960. profiling. In this mode, histogram samples are assigned not to
  961. functions, but to individual lines of source code. This only works with
  962. programs compiled with older versions of the 'gcc' compiler. Newer
  963. versions of 'gcc' use a different program - 'gcov' - to display
  964. line-by-line profiling information.
  965. With the older versions of 'gcc' the program usually has to be
  966. compiled with a '-g' option, in addition to '-pg', in order to generate
  967. debugging symbols for tracking source code lines. Note, in much older
  968. versions of 'gcc' the program had to be compiled with the '-a'
  969. command-line option as well.
  970. The flat profile is the most useful output table in line-by-line
  971. mode. The call graph isn't as useful as normal, since the current
  972. version of 'gprof' does not propagate call graph arcs from source code
  973. lines to the enclosing function. The call graph does, however, show
  974. each line of code that called each function, along with a count.
  975. Here is a section of 'gprof''s output, without line-by-line
  976. profiling. Note that 'ct_init' accounted for four histogram hits, and
  977. 13327 calls to 'init_block'.
  978. Flat profile:
  979. Each sample counts as 0.01 seconds.
  980. % cumulative self self total
  981. time seconds seconds calls us/call us/call name
  982. 30.77 0.13 0.04 6335 6.31 6.31 ct_init
  983. Call graph (explanation follows)
  984. granularity: each sample hit covers 4 byte(s) for 7.69% of 0.13 seconds
  985. index % time self children called name
  986. 0.00 0.00 1/13496 name_too_long
  987. 0.00 0.00 40/13496 deflate
  988. 0.00 0.00 128/13496 deflate_fast
  989. 0.00 0.00 13327/13496 ct_init
  990. [7] 0.0 0.00 0.00 13496 init_block
  991. Now let's look at some of 'gprof''s output from the same program run,
  992. this time with line-by-line profiling enabled. Note that 'ct_init''s
  993. four histogram hits are broken down into four lines of source code--one
  994. hit occurred on each of lines 349, 351, 382 and 385. In the call graph,
  995. note how 'ct_init''s 13327 calls to 'init_block' are broken down into
  996. one call from line 396, 3071 calls from line 384, 3730 calls from line
  997. 385, and 6525 calls from 387.
  998. Flat profile:
  999. Each sample counts as 0.01 seconds.
  1000. % cumulative self
  1001. time seconds seconds calls name
  1002. 7.69 0.10 0.01 ct_init (trees.c:349)
  1003. 7.69 0.11 0.01 ct_init (trees.c:351)
  1004. 7.69 0.12 0.01 ct_init (trees.c:382)
  1005. 7.69 0.13 0.01 ct_init (trees.c:385)
  1006. Call graph (explanation follows)
  1007. granularity: each sample hit covers 4 byte(s) for 7.69% of 0.13 seconds
  1008. % time self children called name
  1009. 0.00 0.00 1/13496 name_too_long (gzip.c:1440)
  1010. 0.00 0.00 1/13496 deflate (deflate.c:763)
  1011. 0.00 0.00 1/13496 ct_init (trees.c:396)
  1012. 0.00 0.00 2/13496 deflate (deflate.c:727)
  1013. 0.00 0.00 4/13496 deflate (deflate.c:686)
  1014. 0.00 0.00 5/13496 deflate (deflate.c:675)
  1015. 0.00 0.00 12/13496 deflate (deflate.c:679)
  1016. 0.00 0.00 16/13496 deflate (deflate.c:730)
  1017. 0.00 0.00 128/13496 deflate_fast (deflate.c:654)
  1018. 0.00 0.00 3071/13496 ct_init (trees.c:384)
  1019. 0.00 0.00 3730/13496 ct_init (trees.c:385)
  1020. 0.00 0.00 6525/13496 ct_init (trees.c:387)
  1021. [6] 0.0 0.00 0.00 13496 init_block (trees.c:408)
  1022. 
  1023. File: gprof.info, Node: Annotated Source, Prev: Line-by-line, Up: Output
  1024. 5.4 The Annotated Source Listing
  1025. ================================
  1026. 'gprof''s '-A' option triggers an annotated source listing, which lists
  1027. the program's source code, each function labeled with the number of
  1028. times it was called. You may also need to specify the '-I' option, if
  1029. 'gprof' can't find the source code files.
  1030. With older versions of 'gcc' compiling with 'gcc ... -g -pg -a'
  1031. augments your program with basic-block counting code, in addition to
  1032. function counting code. This enables 'gprof' to determine how many
  1033. times each line of code was executed. With newer versions of 'gcc'
  1034. support for displaying basic-block counts is provided by the 'gcov'
  1035. program.
  1036. For example, consider the following function, taken from gzip, with
  1037. line numbers added:
  1038. 1 ulg updcrc(s, n)
  1039. 2 uch *s;
  1040. 3 unsigned n;
  1041. 4 {
  1042. 5 register ulg c;
  1043. 6
  1044. 7 static ulg crc = (ulg)0xffffffffL;
  1045. 8
  1046. 9 if (s == NULL) {
  1047. 10 c = 0xffffffffL;
  1048. 11 } else {
  1049. 12 c = crc;
  1050. 13 if (n) do {
  1051. 14 c = crc_32_tab[...];
  1052. 15 } while (--n);
  1053. 16 }
  1054. 17 crc = c;
  1055. 18 return c ^ 0xffffffffL;
  1056. 19 }
  1057. 'updcrc' has at least five basic-blocks. One is the function itself.
  1058. The 'if' statement on line 9 generates two more basic-blocks, one for
  1059. each branch of the 'if'. A fourth basic-block results from the 'if' on
  1060. line 13, and the contents of the 'do' loop form the fifth basic-block.
  1061. The compiler may also generate additional basic-blocks to handle various
  1062. special cases.
  1063. A program augmented for basic-block counting can be analyzed with
  1064. 'gprof -l -A'. The '-x' option is also helpful, to ensure that each
  1065. line of code is labeled at least once. Here is 'updcrc''s annotated
  1066. source listing for a sample 'gzip' run:
  1067. ulg updcrc(s, n)
  1068. uch *s;
  1069. unsigned n;
  1070. 2 ->{
  1071. register ulg c;
  1072. static ulg crc = (ulg)0xffffffffL;
  1073. 2 -> if (s == NULL) {
  1074. 1 -> c = 0xffffffffL;
  1075. 1 -> } else {
  1076. 1 -> c = crc;
  1077. 1 -> if (n) do {
  1078. 26312 -> c = crc_32_tab[...];
  1079. 26312,1,26311 -> } while (--n);
  1080. }
  1081. 2 -> crc = c;
  1082. 2 -> return c ^ 0xffffffffL;
  1083. 2 ->}
  1084. In this example, the function was called twice, passing once through
  1085. each branch of the 'if' statement. The body of the 'do' loop was
  1086. executed a total of 26312 times. Note how the 'while' statement is
  1087. annotated. It began execution 26312 times, once for each iteration
  1088. through the loop. One of those times (the last time) it exited, while
  1089. it branched back to the beginning of the loop 26311 times.
  1090. 
  1091. File: gprof.info, Node: Inaccuracy, Next: How do I?, Prev: Output, Up: Top
  1092. 6 Inaccuracy of 'gprof' Output
  1093. ******************************
  1094. * Menu:
  1095. * Sampling Error:: Statistical margins of error
  1096. * Assumptions:: Estimating children times
  1097. 
  1098. File: gprof.info, Node: Sampling Error, Next: Assumptions, Up: Inaccuracy
  1099. 6.1 Statistical Sampling Error
  1100. ==============================
  1101. The run-time figures that 'gprof' gives you are based on a sampling
  1102. process, so they are subject to statistical inaccuracy. If a function
  1103. runs only a small amount of time, so that on the average the sampling
  1104. process ought to catch that function in the act only once, there is a
  1105. pretty good chance it will actually find that function zero times, or
  1106. twice.
  1107. By contrast, the number-of-calls and basic-block figures are derived
  1108. by counting, not sampling. They are completely accurate and will not
  1109. vary from run to run if your program is deterministic and single
  1110. threaded. In multi-threaded applications, or single threaded
  1111. applications that link with multi-threaded libraries, the counts are
  1112. only deterministic if the counting function is thread-safe. (Note:
  1113. beware that the mcount counting function in glibc is _not_ thread-safe).
  1114. *Note Implementation of Profiling: Implementation.
  1115. The "sampling period" that is printed at the beginning of the flat
  1116. profile says how often samples are taken. The rule of thumb is that a
  1117. run-time figure is accurate if it is considerably bigger than the
  1118. sampling period.
  1119. The actual amount of error can be predicted. For N samples, the
  1120. _expected_ error is the square-root of N. For example, if the sampling
  1121. period is 0.01 seconds and 'foo''s run-time is 1 second, N is 100
  1122. samples (1 second/0.01 seconds), sqrt(N) is 10 samples, so the expected
  1123. error in 'foo''s run-time is 0.1 seconds (10*0.01 seconds), or ten
  1124. percent of the observed value. Again, if the sampling period is 0.01
  1125. seconds and 'bar''s run-time is 100 seconds, N is 10000 samples, sqrt(N)
  1126. is 100 samples, so the expected error in 'bar''s run-time is 1 second,
  1127. or one percent of the observed value. It is likely to vary this much
  1128. _on the average_ from one profiling run to the next. (_Sometimes_ it
  1129. will vary more.)
  1130. This does not mean that a small run-time figure is devoid of
  1131. information. If the program's _total_ run-time is large, a small
  1132. run-time for one function does tell you that that function used an
  1133. insignificant fraction of the whole program's time. Usually this means
  1134. it is not worth optimizing.
  1135. One way to get more accuracy is to give your program more (but
  1136. similar) input data so it will take longer. Another way is to combine
  1137. the data from several runs, using the '-s' option of 'gprof'. Here is
  1138. how:
  1139. 1. Run your program once.
  1140. 2. Issue the command 'mv gmon.out gmon.sum'.
  1141. 3. Run your program again, the same as before.
  1142. 4. Merge the new data in 'gmon.out' into 'gmon.sum' with this command:
  1143. gprof -s EXECUTABLE-FILE gmon.out gmon.sum
  1144. 5. Repeat the last two steps as often as you wish.
  1145. 6. Analyze the cumulative data using this command:
  1146. gprof EXECUTABLE-FILE gmon.sum > OUTPUT-FILE
  1147. 
  1148. File: gprof.info, Node: Assumptions, Prev: Sampling Error, Up: Inaccuracy
  1149. 6.2 Estimating 'children' Times
  1150. ===============================
  1151. Some of the figures in the call graph are estimates--for example, the
  1152. 'children' time values and all the time figures in caller and subroutine
  1153. lines.
  1154. There is no direct information about these measurements in the
  1155. profile data itself. Instead, 'gprof' estimates them by making an
  1156. assumption about your program that might or might not be true.
  1157. The assumption made is that the average time spent in each call to
  1158. any function 'foo' is not correlated with who called 'foo'. If 'foo'
  1159. used 5 seconds in all, and 2/5 of the calls to 'foo' came from 'a', then
  1160. 'foo' contributes 2 seconds to 'a''s 'children' time, by assumption.
  1161. This assumption is usually true enough, but for some programs it is
  1162. far from true. Suppose that 'foo' returns very quickly when its
  1163. argument is zero; suppose that 'a' always passes zero as an argument,
  1164. while other callers of 'foo' pass other arguments. In this program, all
  1165. the time spent in 'foo' is in the calls from callers other than 'a'.
  1166. But 'gprof' has no way of knowing this; it will blindly and incorrectly
  1167. charge 2 seconds of time in 'foo' to the children of 'a'.
  1168. We hope some day to put more complete data into 'gmon.out', so that
  1169. this assumption is no longer needed, if we can figure out how. For the
  1170. novice, the estimated figures are usually more useful than misleading.
  1171. 
  1172. File: gprof.info, Node: How do I?, Next: Incompatibilities, Prev: Inaccuracy, Up: Top
  1173. 7 Answers to Common Questions
  1174. *****************************
  1175. How can I get more exact information about hot spots in my program?
  1176. Looking at the per-line call counts only tells part of the story.
  1177. Because 'gprof' can only report call times and counts by function,
  1178. the best way to get finer-grained information on where the program
  1179. is spending its time is to re-factor large functions into sequences
  1180. of calls to smaller ones. Beware however that this can introduce
  1181. artificial hot spots since compiling with '-pg' adds a significant
  1182. overhead to function calls. An alternative solution is to use a
  1183. non-intrusive profiler, e.g. oprofile.
  1184. How do I find which lines in my program were executed the most times?
  1185. Use the 'gcov' program.
  1186. How do I find which lines in my program called a particular function?
  1187. Use 'gprof -l' and lookup the function in the call graph. The
  1188. callers will be broken down by function and line number.
  1189. How do I analyze a program that runs for less than a second?
  1190. Try using a shell script like this one:
  1191. for i in `seq 1 100`; do
  1192. fastprog
  1193. mv gmon.out gmon.out.$i
  1194. done
  1195. gprof -s fastprog gmon.out.*
  1196. gprof fastprog gmon.sum
  1197. If your program is completely deterministic, all the call counts
  1198. will be simple multiples of 100 (i.e., a function called once in
  1199. each run will appear with a call count of 100).
  1200. 
  1201. File: gprof.info, Node: Incompatibilities, Next: Details, Prev: How do I?, Up: Top
  1202. 8 Incompatibilities with Unix 'gprof'
  1203. *************************************
  1204. GNU 'gprof' and Berkeley Unix 'gprof' use the same data file 'gmon.out',
  1205. and provide essentially the same information. But there are a few
  1206. differences.
  1207. * GNU 'gprof' uses a new, generalized file format with support for
  1208. basic-block execution counts and non-realtime histograms. A magic
  1209. cookie and version number allows 'gprof' to easily identify new
  1210. style files. Old BSD-style files can still be read. *Note
  1211. Profiling Data File Format: File Format.
  1212. * For a recursive function, Unix 'gprof' lists the function as a
  1213. parent and as a child, with a 'calls' field that lists the number
  1214. of recursive calls. GNU 'gprof' omits these lines and puts the
  1215. number of recursive calls in the primary line.
  1216. * When a function is suppressed from the call graph with '-e', GNU
  1217. 'gprof' still lists it as a subroutine of functions that call it.
  1218. * GNU 'gprof' accepts the '-k' with its argument in the form
  1219. 'from/to', instead of 'from to'.
  1220. * In the annotated source listing, if there are multiple basic blocks
  1221. on the same line, GNU 'gprof' prints all of their counts, separated
  1222. by commas.
  1223. * The blurbs, field widths, and output formats are different. GNU
  1224. 'gprof' prints blurbs after the tables, so that you can see the
  1225. tables without skipping the blurbs.
  1226. 
  1227. File: gprof.info, Node: Details, Next: GNU Free Documentation License, Prev: Incompatibilities, Up: Top
  1228. 9 Details of Profiling
  1229. **********************
  1230. * Menu:
  1231. * Implementation:: How a program collects profiling information
  1232. * File Format:: Format of 'gmon.out' files
  1233. * Internals:: 'gprof''s internal operation
  1234. * Debugging:: Using 'gprof''s '-d' option
  1235. 
  1236. File: gprof.info, Node: Implementation, Next: File Format, Up: Details
  1237. 9.1 Implementation of Profiling
  1238. ===============================
  1239. Profiling works by changing how every function in your program is
  1240. compiled so that when it is called, it will stash away some information
  1241. about where it was called from. From this, the profiler can figure out
  1242. what function called it, and can count how many times it was called.
  1243. This change is made by the compiler when your program is compiled with
  1244. the '-pg' option, which causes every function to call 'mcount' (or
  1245. '_mcount', or '__mcount', depending on the OS and compiler) as one of
  1246. its first operations.
  1247. The 'mcount' routine, included in the profiling library, is
  1248. responsible for recording in an in-memory call graph table both its
  1249. parent routine (the child) and its parent's parent. This is typically
  1250. done by examining the stack frame to find both the address of the child,
  1251. and the return address in the original parent. Since this is a very
  1252. machine-dependent operation, 'mcount' itself is typically a short
  1253. assembly-language stub routine that extracts the required information,
  1254. and then calls '__mcount_internal' (a normal C function) with two
  1255. arguments--'frompc' and 'selfpc'. '__mcount_internal' is responsible
  1256. for maintaining the in-memory call graph, which records 'frompc',
  1257. 'selfpc', and the number of times each of these call arcs was traversed.
  1258. GCC Version 2 provides a magical function
  1259. ('__builtin_return_address'), which allows a generic 'mcount' function
  1260. to extract the required information from the stack frame. However, on
  1261. some architectures, most notably the SPARC, using this builtin can be
  1262. very computationally expensive, and an assembly language version of
  1263. 'mcount' is used for performance reasons.
  1264. Number-of-calls information for library routines is collected by
  1265. using a special version of the C library. The programs in it are the
  1266. same as in the usual C library, but they were compiled with '-pg'. If
  1267. you link your program with 'gcc ... -pg', it automatically uses the
  1268. profiling version of the library.
  1269. Profiling also involves watching your program as it runs, and keeping
  1270. a histogram of where the program counter happens to be every now and
  1271. then. Typically the program counter is looked at around 100 times per
  1272. second of run time, but the exact frequency may vary from system to
  1273. system.
  1274. This is done is one of two ways. Most UNIX-like operating systems
  1275. provide a 'profil()' system call, which registers a memory array with
  1276. the kernel, along with a scale factor that determines how the program's
  1277. address space maps into the array. Typical scaling values cause every 2
  1278. to 8 bytes of address space to map into a single array slot. On every
  1279. tick of the system clock (assuming the profiled program is running), the
  1280. value of the program counter is examined and the corresponding slot in
  1281. the memory array is incremented. Since this is done in the kernel,
  1282. which had to interrupt the process anyway to handle the clock interrupt,
  1283. very little additional system overhead is required.
  1284. However, some operating systems, most notably Linux 2.0 (and
  1285. earlier), do not provide a 'profil()' system call. On such a system,
  1286. arrangements are made for the kernel to periodically deliver a signal to
  1287. the process (typically via 'setitimer()'), which then performs the same
  1288. operation of examining the program counter and incrementing a slot in
  1289. the memory array. Since this method requires a signal to be delivered
  1290. to user space every time a sample is taken, it uses considerably more
  1291. overhead than kernel-based profiling. Also, due to the added delay
  1292. required to deliver the signal, this method is less accurate as well.
  1293. A special startup routine allocates memory for the histogram and
  1294. either calls 'profil()' or sets up a clock signal handler. This routine
  1295. ('monstartup') can be invoked in several ways. On Linux systems, a
  1296. special profiling startup file 'gcrt0.o', which invokes 'monstartup'
  1297. before 'main', is used instead of the default 'crt0.o'. Use of this
  1298. special startup file is one of the effects of using 'gcc ... -pg' to
  1299. link. On SPARC systems, no special startup files are used. Rather, the
  1300. 'mcount' routine, when it is invoked for the first time (typically when
  1301. 'main' is called), calls 'monstartup'.
  1302. If the compiler's '-a' option was used, basic-block counting is also
  1303. enabled. Each object file is then compiled with a static array of
  1304. counts, initially zero. In the executable code, every time a new
  1305. basic-block begins (i.e., when an 'if' statement appears), an extra
  1306. instruction is inserted to increment the corresponding count in the
  1307. array. At compile time, a paired array was constructed that recorded
  1308. the starting address of each basic-block. Taken together, the two
  1309. arrays record the starting address of every basic-block, along with the
  1310. number of times it was executed.
  1311. The profiling library also includes a function ('mcleanup') which is
  1312. typically registered using 'atexit()' to be called as the program exits,
  1313. and is responsible for writing the file 'gmon.out'. Profiling is turned
  1314. off, various headers are output, and the histogram is written, followed
  1315. by the call-graph arcs and the basic-block counts.
  1316. The output from 'gprof' gives no indication of parts of your program
  1317. that are limited by I/O or swapping bandwidth. This is because samples
  1318. of the program counter are taken at fixed intervals of the program's run
  1319. time. Therefore, the time measurements in 'gprof' output say nothing
  1320. about time that your program was not running. For example, a part of
  1321. the program that creates so much data that it cannot all fit in physical
  1322. memory at once may run very slowly due to thrashing, but 'gprof' will
  1323. say it uses little time. On the other hand, sampling by run time has
  1324. the advantage that the amount of load due to other users won't directly
  1325. affect the output you get.
  1326. 
  1327. File: gprof.info, Node: File Format, Next: Internals, Prev: Implementation, Up: Details
  1328. 9.2 Profiling Data File Format
  1329. ==============================
  1330. The old BSD-derived file format used for profile data does not contain a
  1331. magic cookie that allows to check whether a data file really is a
  1332. 'gprof' file. Furthermore, it does not provide a version number, thus
  1333. rendering changes to the file format almost impossible. GNU 'gprof'
  1334. uses a new file format that provides these features. For backward
  1335. compatibility, GNU 'gprof' continues to support the old BSD-derived
  1336. format, but not all features are supported with it. For example,
  1337. basic-block execution counts cannot be accommodated by the old file
  1338. format.
  1339. The new file format is defined in header file 'gmon_out.h'. It
  1340. consists of a header containing the magic cookie and a version number,
  1341. as well as some spare bytes available for future extensions. All data
  1342. in a profile data file is in the native format of the target for which
  1343. the profile was collected. GNU 'gprof' adapts automatically to the
  1344. byte-order in use.
  1345. In the new file format, the header is followed by a sequence of
  1346. records. Currently, there are three different record types: histogram
  1347. records, call-graph arc records, and basic-block execution count
  1348. records. Each file can contain any number of each record type. When
  1349. reading a file, GNU 'gprof' will ensure records of the same type are
  1350. compatible with each other and compute the union of all records. For
  1351. example, for basic-block execution counts, the union is simply the sum
  1352. of all execution counts for each basic-block.
  1353. 9.2.1 Histogram Records
  1354. -----------------------
  1355. Histogram records consist of a header that is followed by an array of
  1356. bins. The header contains the text-segment range that the histogram
  1357. spans, the size of the histogram in bytes (unlike in the old BSD format,
  1358. this does not include the size of the header), the rate of the profiling
  1359. clock, and the physical dimension that the bin counts represent after
  1360. being scaled by the profiling clock rate. The physical dimension is
  1361. specified in two parts: a long name of up to 15 characters and a single
  1362. character abbreviation. For example, a histogram representing real-time
  1363. would specify the long name as "seconds" and the abbreviation as "s".
  1364. This feature is useful for architectures that support performance
  1365. monitor hardware (which, fortunately, is becoming increasingly common).
  1366. For example, under DEC OSF/1, the "uprofile" command can be used to
  1367. produce a histogram of, say, instruction cache misses. In this case,
  1368. the dimension in the histogram header could be set to "i-cache misses"
  1369. and the abbreviation could be set to "1" (because it is simply a count,
  1370. not a physical dimension). Also, the profiling rate would have to be
  1371. set to 1 in this case.
  1372. Histogram bins are 16-bit numbers and each bin represent an equal
  1373. amount of text-space. For example, if the text-segment is one thousand
  1374. bytes long and if there are ten bins in the histogram, each bin
  1375. represents one hundred bytes.
  1376. 9.2.2 Call-Graph Records
  1377. ------------------------
  1378. Call-graph records have a format that is identical to the one used in
  1379. the BSD-derived file format. It consists of an arc in the call graph
  1380. and a count indicating the number of times the arc was traversed during
  1381. program execution. Arcs are specified by a pair of addresses: the first
  1382. must be within caller's function and the second must be within the
  1383. callee's function. When performing profiling at the function level,
  1384. these addresses can point anywhere within the respective function.
  1385. However, when profiling at the line-level, it is better if the addresses
  1386. are as close to the call-site/entry-point as possible. This will ensure
  1387. that the line-level call-graph is able to identify exactly which line of
  1388. source code performed calls to a function.
  1389. 9.2.3 Basic-Block Execution Count Records
  1390. -----------------------------------------
  1391. Basic-block execution count records consist of a header followed by a
  1392. sequence of address/count pairs. The header simply specifies the length
  1393. of the sequence. In an address/count pair, the address identifies a
  1394. basic-block and the count specifies the number of times that basic-block
  1395. was executed. Any address within the basic-address can be used.
  1396. 
  1397. File: gprof.info, Node: Internals, Next: Debugging, Prev: File Format, Up: Details
  1398. 9.3 'gprof''s Internal Operation
  1399. ================================
  1400. Like most programs, 'gprof' begins by processing its options. During
  1401. this stage, it may building its symspec list ('sym_ids.c:sym_id_add'),
  1402. if options are specified which use symspecs. 'gprof' maintains a single
  1403. linked list of symspecs, which will eventually get turned into 12 symbol
  1404. tables, organized into six include/exclude pairs--one pair each for the
  1405. flat profile (INCL_FLAT/EXCL_FLAT), the call graph arcs
  1406. (INCL_ARCS/EXCL_ARCS), printing in the call graph
  1407. (INCL_GRAPH/EXCL_GRAPH), timing propagation in the call graph
  1408. (INCL_TIME/EXCL_TIME), the annotated source listing
  1409. (INCL_ANNO/EXCL_ANNO), and the execution count listing
  1410. (INCL_EXEC/EXCL_EXEC).
  1411. After option processing, 'gprof' finishes building the symspec list
  1412. by adding all the symspecs in 'default_excluded_list' to the exclude
  1413. lists EXCL_TIME and EXCL_GRAPH, and if line-by-line profiling is
  1414. specified, EXCL_FLAT as well. These default excludes are not added to
  1415. EXCL_ANNO, EXCL_ARCS, and EXCL_EXEC.
  1416. Next, the BFD library is called to open the object file, verify that
  1417. it is an object file, and read its symbol table ('core.c:core_init'),
  1418. using 'bfd_canonicalize_symtab' after mallocing an appropriately sized
  1419. array of symbols. At this point, function mappings are read (if the
  1420. '--file-ordering' option has been specified), and the core text space is
  1421. read into memory (if the '-c' option was given).
  1422. 'gprof''s own symbol table, an array of Sym structures, is now built.
  1423. This is done in one of two ways, by one of two routines, depending on
  1424. whether line-by-line profiling ('-l' option) has been enabled. For
  1425. normal profiling, the BFD canonical symbol table is scanned. For
  1426. line-by-line profiling, every text space address is examined, and a new
  1427. symbol table entry gets created every time the line number changes. In
  1428. either case, two passes are made through the symbol table--one to count
  1429. the size of the symbol table required, and the other to actually read
  1430. the symbols. In between the two passes, a single array of type 'Sym' is
  1431. created of the appropriate length. Finally, 'symtab.c:symtab_finalize'
  1432. is called to sort the symbol table and remove duplicate entries (entries
  1433. with the same memory address).
  1434. The symbol table must be a contiguous array for two reasons. First,
  1435. the 'qsort' library function (which sorts an array) will be used to sort
  1436. the symbol table. Also, the symbol lookup routine
  1437. ('symtab.c:sym_lookup'), which finds symbols based on memory address,
  1438. uses a binary search algorithm which requires the symbol table to be a
  1439. sorted array. Function symbols are indicated with an 'is_func' flag.
  1440. Line number symbols have no special flags set. Additionally, a symbol
  1441. can have an 'is_static' flag to indicate that it is a local symbol.
  1442. With the symbol table read, the symspecs can now be translated into
  1443. Syms ('sym_ids.c:sym_id_parse'). Remember that a single symspec can
  1444. match multiple symbols. An array of symbol tables ('syms') is created,
  1445. each entry of which is a symbol table of Syms to be included or excluded
  1446. from a particular listing. The master symbol table and the symspecs are
  1447. examined by nested loops, and every symbol that matches a symspec is
  1448. inserted into the appropriate syms table. This is done twice, once to
  1449. count the size of each required symbol table, and again to build the
  1450. tables, which have been malloced between passes. From now on, to
  1451. determine whether a symbol is on an include or exclude symspec list,
  1452. 'gprof' simply uses its standard symbol lookup routine on the
  1453. appropriate table in the 'syms' array.
  1454. Now the profile data file(s) themselves are read
  1455. ('gmon_io.c:gmon_out_read'), first by checking for a new-style
  1456. 'gmon.out' header, then assuming this is an old-style BSD 'gmon.out' if
  1457. the magic number test failed.
  1458. New-style histogram records are read by 'hist.c:hist_read_rec'. For
  1459. the first histogram record, allocate a memory array to hold all the
  1460. bins, and read them in. When multiple profile data files (or files with
  1461. multiple histogram records) are read, the memory ranges of each pair of
  1462. histogram records must be either equal, or non-overlapping. For each
  1463. pair of histogram records, the resolution (memory region size divided by
  1464. the number of bins) must be the same. The time unit must be the same
  1465. for all histogram records. If the above containts are met, all
  1466. histograms for the same memory range are merged.
  1467. As each call graph record is read ('call_graph.c:cg_read_rec'), the
  1468. parent and child addresses are matched to symbol table entries, and a
  1469. call graph arc is created by 'cg_arcs.c:arc_add', unless the arc fails a
  1470. symspec check against INCL_ARCS/EXCL_ARCS. As each arc is added, a
  1471. linked list is maintained of the parent's child arcs, and of the child's
  1472. parent arcs. Both the child's call count and the arc's call count are
  1473. incremented by the record's call count.
  1474. Basic-block records are read ('basic_blocks.c:bb_read_rec'), but only
  1475. if line-by-line profiling has been selected. Each basic-block address
  1476. is matched to a corresponding line symbol in the symbol table, and an
  1477. entry made in the symbol's bb_addr and bb_calls arrays. Again, if
  1478. multiple basic-block records are present for the same address, the call
  1479. counts are cumulative.
  1480. A gmon.sum file is dumped, if requested ('gmon_io.c:gmon_out_write').
  1481. If histograms were present in the data files, assign them to symbols
  1482. ('hist.c:hist_assign_samples') by iterating over all the sample bins and
  1483. assigning them to symbols. Since the symbol table is sorted in order of
  1484. ascending memory addresses, we can simple follow along in the symbol
  1485. table as we make our pass over the sample bins. This step includes a
  1486. symspec check against INCL_FLAT/EXCL_FLAT. Depending on the histogram
  1487. scale factor, a sample bin may span multiple symbols, in which case a
  1488. fraction of the sample count is allocated to each symbol, proportional
  1489. to the degree of overlap. This effect is rare for normal profiling, but
  1490. overlaps are more common during line-by-line profiling, and can cause
  1491. each of two adjacent lines to be credited with half a hit, for example.
  1492. If call graph data is present, 'cg_arcs.c:cg_assemble' is called.
  1493. First, if '-c' was specified, a machine-dependent routine ('find_call')
  1494. scans through each symbol's machine code, looking for subroutine call
  1495. instructions, and adding them to the call graph with a zero call count.
  1496. A topological sort is performed by depth-first numbering all the symbols
  1497. ('cg_dfn.c:cg_dfn'), so that children are always numbered less than
  1498. their parents, then making a array of pointers into the symbol table and
  1499. sorting it into numerical order, which is reverse topological order
  1500. (children appear before parents). Cycles are also detected at this
  1501. point, all members of which are assigned the same topological number.
  1502. Two passes are now made through this sorted array of symbol pointers.
  1503. The first pass, from end to beginning (parents to children), computes
  1504. the fraction of child time to propagate to each parent and a print flag.
  1505. The print flag reflects symspec handling of INCL_GRAPH/EXCL_GRAPH, with
  1506. a parent's include or exclude (print or no print) property being
  1507. propagated to its children, unless they themselves explicitly appear in
  1508. INCL_GRAPH or EXCL_GRAPH. A second pass, from beginning to end (children
  1509. to parents) actually propagates the timings along the call graph,
  1510. subject to a check against INCL_TIME/EXCL_TIME. With the print flag,
  1511. fractions, and timings now stored in the symbol structures, the
  1512. topological sort array is now discarded, and a new array of pointers is
  1513. assembled, this time sorted by propagated time.
  1514. Finally, print the various outputs the user requested, which is now
  1515. fairly straightforward. The call graph ('cg_print.c:cg_print') and flat
  1516. profile ('hist.c:hist_print') are regurgitations of values already
  1517. computed. The annotated source listing
  1518. ('basic_blocks.c:print_annotated_source') uses basic-block information,
  1519. if present, to label each line of code with call counts, otherwise only
  1520. the function call counts are presented.
  1521. The function ordering code is marginally well documented in the
  1522. source code itself ('cg_print.c'). Basically, the functions with the
  1523. most use and the most parents are placed first, followed by other
  1524. functions with the most use, followed by lower use functions, followed
  1525. by unused functions at the end.
  1526. 
  1527. File: gprof.info, Node: Debugging, Prev: Internals, Up: Details
  1528. 9.4 Debugging 'gprof'
  1529. =====================
  1530. If 'gprof' was compiled with debugging enabled, the '-d' option triggers
  1531. debugging output (to stdout) which can be helpful in understanding its
  1532. operation. The debugging number specified is interpreted as a sum of
  1533. the following options:
  1534. 2 - Topological sort
  1535. Monitor depth-first numbering of symbols during call graph analysis
  1536. 4 - Cycles
  1537. Shows symbols as they are identified as cycle heads
  1538. 16 - Tallying
  1539. As the call graph arcs are read, show each arc and how the total
  1540. calls to each function are tallied
  1541. 32 - Call graph arc sorting
  1542. Details sorting individual parents/children within each call graph
  1543. entry
  1544. 64 - Reading histogram and call graph records
  1545. Shows address ranges of histograms as they are read, and each call
  1546. graph arc
  1547. 128 - Symbol table
  1548. Reading, classifying, and sorting the symbol table from the object
  1549. file. For line-by-line profiling ('-l' option), also shows line
  1550. numbers being assigned to memory addresses.
  1551. 256 - Static call graph
  1552. Trace operation of '-c' option
  1553. 512 - Symbol table and arc table lookups
  1554. Detail operation of lookup routines
  1555. 1024 - Call graph propagation
  1556. Shows how function times are propagated along the call graph
  1557. 2048 - Basic-blocks
  1558. Shows basic-block records as they are read from profile data (only
  1559. meaningful with '-l' option)
  1560. 4096 - Symspecs
  1561. Shows symspec-to-symbol pattern matching operation
  1562. 8192 - Annotate source
  1563. Tracks operation of '-A' option
  1564. 
  1565. File: gprof.info, Node: GNU Free Documentation License, Prev: Details, Up: Top
  1566. Appendix A GNU Free Documentation License
  1567. *****************************************
  1568. Version 1.3, 3 November 2008
  1569. Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
  1570. <http://fsf.org/>
  1571. Everyone is permitted to copy and distribute verbatim copies
  1572. of this license document, but changing it is not allowed.
  1573. 0. PREAMBLE
  1574. The purpose of this License is to make a manual, textbook, or other
  1575. functional and useful document "free" in the sense of freedom: to
  1576. assure everyone the effective freedom to copy and redistribute it,
  1577. with or without modifying it, either commercially or
  1578. noncommercially. Secondarily, this License preserves for the
  1579. author and publisher a way to get credit for their work, while not
  1580. being considered responsible for modifications made by others.
  1581. This License is a kind of "copyleft", which means that derivative
  1582. works of the document must themselves be free in the same sense.
  1583. It complements the GNU General Public License, which is a copyleft
  1584. license designed for free software.
  1585. We have designed this License in order to use it for manuals for
  1586. free software, because free software needs free documentation: a
  1587. free program should come with manuals providing the same freedoms
  1588. that the software does. But this License is not limited to
  1589. software manuals; it can be used for any textual work, regardless
  1590. of subject matter or whether it is published as a printed book. We
  1591. recommend this License principally for works whose purpose is
  1592. instruction or reference.
  1593. 1. APPLICABILITY AND DEFINITIONS
  1594. This License applies to any manual or other work, in any medium,
  1595. that contains a notice placed by the copyright holder saying it can
  1596. be distributed under the terms of this License. Such a notice
  1597. grants a world-wide, royalty-free license, unlimited in duration,
  1598. to use that work under the conditions stated herein. The
  1599. "Document", below, refers to any such manual or work. Any member
  1600. of the public is a licensee, and is addressed as "you". You accept
  1601. the license if you copy, modify or distribute the work in a way
  1602. requiring permission under copyright law.
  1603. A "Modified Version" of the Document means any work containing the
  1604. Document or a portion of it, either copied verbatim, or with
  1605. modifications and/or translated into another language.
  1606. A "Secondary Section" is a named appendix or a front-matter section
  1607. of the Document that deals exclusively with the relationship of the
  1608. publishers or authors of the Document to the Document's overall
  1609. subject (or to related matters) and contains nothing that could
  1610. fall directly within that overall subject. (Thus, if the Document
  1611. is in part a textbook of mathematics, a Secondary Section may not
  1612. explain any mathematics.) The relationship could be a matter of
  1613. historical connection with the subject or with related matters, or
  1614. of legal, commercial, philosophical, ethical or political position
  1615. regarding them.
  1616. The "Invariant Sections" are certain Secondary Sections whose
  1617. titles are designated, as being those of Invariant Sections, in the
  1618. notice that says that the Document is released under this License.
  1619. If a section does not fit the above definition of Secondary then it
  1620. is not allowed to be designated as Invariant. The Document may
  1621. contain zero Invariant Sections. If the Document does not identify
  1622. any Invariant Sections then there are none.
  1623. The "Cover Texts" are certain short passages of text that are
  1624. listed, as Front-Cover Texts or Back-Cover Texts, in the notice
  1625. that says that the Document is released under this License. A
  1626. Front-Cover Text may be at most 5 words, and a Back-Cover Text may
  1627. be at most 25 words.
  1628. A "Transparent" copy of the Document means a machine-readable copy,
  1629. represented in a format whose specification is available to the
  1630. general public, that is suitable for revising the document
  1631. straightforwardly with generic text editors or (for images composed
  1632. of pixels) generic paint programs or (for drawings) some widely
  1633. available drawing editor, and that is suitable for input to text
  1634. formatters or for automatic translation to a variety of formats
  1635. suitable for input to text formatters. A copy made in an otherwise
  1636. Transparent file format whose markup, or absence of markup, has
  1637. been arranged to thwart or discourage subsequent modification by
  1638. readers is not Transparent. An image format is not Transparent if
  1639. used for any substantial amount of text. A copy that is not
  1640. "Transparent" is called "Opaque".
  1641. Examples of suitable formats for Transparent copies include plain
  1642. ASCII without markup, Texinfo input format, LaTeX input format,
  1643. SGML or XML using a publicly available DTD, and standard-conforming
  1644. simple HTML, PostScript or PDF designed for human modification.
  1645. Examples of transparent image formats include PNG, XCF and JPG.
  1646. Opaque formats include proprietary formats that can be read and
  1647. edited only by proprietary word processors, SGML or XML for which
  1648. the DTD and/or processing tools are not generally available, and
  1649. the machine-generated HTML, PostScript or PDF produced by some word
  1650. processors for output purposes only.
  1651. The "Title Page" means, for a printed book, the title page itself,
  1652. plus such following pages as are needed to hold, legibly, the
  1653. material this License requires to appear in the title page. For
  1654. works in formats which do not have any title page as such, "Title
  1655. Page" means the text near the most prominent appearance of the
  1656. work's title, preceding the beginning of the body of the text.
  1657. The "publisher" means any person or entity that distributes copies
  1658. of the Document to the public.
  1659. A section "Entitled XYZ" means a named subunit of the Document
  1660. whose title either is precisely XYZ or contains XYZ in parentheses
  1661. following text that translates XYZ in another language. (Here XYZ
  1662. stands for a specific section name mentioned below, such as
  1663. "Acknowledgements", "Dedications", "Endorsements", or "History".)
  1664. To "Preserve the Title" of such a section when you modify the
  1665. Document means that it remains a section "Entitled XYZ" according
  1666. to this definition.
  1667. The Document may include Warranty Disclaimers next to the notice
  1668. which states that this License applies to the Document. These
  1669. Warranty Disclaimers are considered to be included by reference in
  1670. this License, but only as regards disclaiming warranties: any other
  1671. implication that these Warranty Disclaimers may have is void and
  1672. has no effect on the meaning of this License.
  1673. 2. VERBATIM COPYING
  1674. You may copy and distribute the Document in any medium, either
  1675. commercially or noncommercially, provided that this License, the
  1676. copyright notices, and the license notice saying this License
  1677. applies to the Document are reproduced in all copies, and that you
  1678. add no other conditions whatsoever to those of this License. You
  1679. may not use technical measures to obstruct or control the reading
  1680. or further copying of the copies you make or distribute. However,
  1681. you may accept compensation in exchange for copies. If you
  1682. distribute a large enough number of copies you must also follow the
  1683. conditions in section 3.
  1684. You may also lend copies, under the same conditions stated above,
  1685. and you may publicly display copies.
  1686. 3. COPYING IN QUANTITY
  1687. If you publish printed copies (or copies in media that commonly
  1688. have printed covers) of the Document, numbering more than 100, and
  1689. the Document's license notice requires Cover Texts, you must
  1690. enclose the copies in covers that carry, clearly and legibly, all
  1691. these Cover Texts: Front-Cover Texts on the front cover, and
  1692. Back-Cover Texts on the back cover. Both covers must also clearly
  1693. and legibly identify you as the publisher of these copies. The
  1694. front cover must present the full title with all words of the title
  1695. equally prominent and visible. You may add other material on the
  1696. covers in addition. Copying with changes limited to the covers, as
  1697. long as they preserve the title of the Document and satisfy these
  1698. conditions, can be treated as verbatim copying in other respects.
  1699. If the required texts for either cover are too voluminous to fit
  1700. legibly, you should put the first ones listed (as many as fit
  1701. reasonably) on the actual cover, and continue the rest onto
  1702. adjacent pages.
  1703. If you publish or distribute Opaque copies of the Document
  1704. numbering more than 100, you must either include a machine-readable
  1705. Transparent copy along with each Opaque copy, or state in or with
  1706. each Opaque copy a computer-network location from which the general
  1707. network-using public has access to download using public-standard
  1708. network protocols a complete Transparent copy of the Document, free
  1709. of added material. If you use the latter option, you must take
  1710. reasonably prudent steps, when you begin distribution of Opaque
  1711. copies in quantity, to ensure that this Transparent copy will
  1712. remain thus accessible at the stated location until at least one
  1713. year after the last time you distribute an Opaque copy (directly or
  1714. through your agents or retailers) of that edition to the public.
  1715. It is requested, but not required, that you contact the authors of
  1716. the Document well before redistributing any large number of copies,
  1717. to give them a chance to provide you with an updated version of the
  1718. Document.
  1719. 4. MODIFICATIONS
  1720. You may copy and distribute a Modified Version of the Document
  1721. under the conditions of sections 2 and 3 above, provided that you
  1722. release the Modified Version under precisely this License, with the
  1723. Modified Version filling the role of the Document, thus licensing
  1724. distribution and modification of the Modified Version to whoever
  1725. possesses a copy of it. In addition, you must do these things in
  1726. the Modified Version:
  1727. A. Use in the Title Page (and on the covers, if any) a title
  1728. distinct from that of the Document, and from those of previous
  1729. versions (which should, if there were any, be listed in the
  1730. History section of the Document). You may use the same title
  1731. as a previous version if the original publisher of that
  1732. version gives permission.
  1733. B. List on the Title Page, as authors, one or more persons or
  1734. entities responsible for authorship of the modifications in
  1735. the Modified Version, together with at least five of the
  1736. principal authors of the Document (all of its principal
  1737. authors, if it has fewer than five), unless they release you
  1738. from this requirement.
  1739. C. State on the Title page the name of the publisher of the
  1740. Modified Version, as the publisher.
  1741. D. Preserve all the copyright notices of the Document.
  1742. E. Add an appropriate copyright notice for your modifications
  1743. adjacent to the other copyright notices.
  1744. F. Include, immediately after the copyright notices, a license
  1745. notice giving the public permission to use the Modified
  1746. Version under the terms of this License, in the form shown in
  1747. the Addendum below.
  1748. G. Preserve in that license notice the full lists of Invariant
  1749. Sections and required Cover Texts given in the Document's
  1750. license notice.
  1751. H. Include an unaltered copy of this License.
  1752. I. Preserve the section Entitled "History", Preserve its Title,
  1753. and add to it an item stating at least the title, year, new
  1754. authors, and publisher of the Modified Version as given on the
  1755. Title Page. If there is no section Entitled "History" in the
  1756. Document, create one stating the title, year, authors, and
  1757. publisher of the Document as given on its Title Page, then add
  1758. an item describing the Modified Version as stated in the
  1759. previous sentence.
  1760. J. Preserve the network location, if any, given in the Document
  1761. for public access to a Transparent copy of the Document, and
  1762. likewise the network locations given in the Document for
  1763. previous versions it was based on. These may be placed in the
  1764. "History" section. You may omit a network location for a work
  1765. that was published at least four years before the Document
  1766. itself, or if the original publisher of the version it refers
  1767. to gives permission.
  1768. K. For any section Entitled "Acknowledgements" or "Dedications",
  1769. Preserve the Title of the section, and preserve in the section
  1770. all the substance and tone of each of the contributor
  1771. acknowledgements and/or dedications given therein.
  1772. L. Preserve all the Invariant Sections of the Document, unaltered
  1773. in their text and in their titles. Section numbers or the
  1774. equivalent are not considered part of the section titles.
  1775. M. Delete any section Entitled "Endorsements". Such a section
  1776. may not be included in the Modified Version.
  1777. N. Do not retitle any existing section to be Entitled
  1778. "Endorsements" or to conflict in title with any Invariant
  1779. Section.
  1780. O. Preserve any Warranty Disclaimers.
  1781. If the Modified Version includes new front-matter sections or
  1782. appendices that qualify as Secondary Sections and contain no
  1783. material copied from the Document, you may at your option designate
  1784. some or all of these sections as invariant. To do this, add their
  1785. titles to the list of Invariant Sections in the Modified Version's
  1786. license notice. These titles must be distinct from any other
  1787. section titles.
  1788. You may add a section Entitled "Endorsements", provided it contains
  1789. nothing but endorsements of your Modified Version by various
  1790. parties--for example, statements of peer review or that the text
  1791. has been approved by an organization as the authoritative
  1792. definition of a standard.
  1793. You may add a passage of up to five words as a Front-Cover Text,
  1794. and a passage of up to 25 words as a Back-Cover Text, to the end of
  1795. the list of Cover Texts in the Modified Version. Only one passage
  1796. of Front-Cover Text and one of Back-Cover Text may be added by (or
  1797. through arrangements made by) any one entity. If the Document
  1798. already includes a cover text for the same cover, previously added
  1799. by you or by arrangement made by the same entity you are acting on
  1800. behalf of, you may not add another; but you may replace the old
  1801. one, on explicit permission from the previous publisher that added
  1802. the old one.
  1803. The author(s) and publisher(s) of the Document do not by this
  1804. License give permission to use their names for publicity for or to
  1805. assert or imply endorsement of any Modified Version.
  1806. 5. COMBINING DOCUMENTS
  1807. You may combine the Document with other documents released under
  1808. this License, under the terms defined in section 4 above for
  1809. modified versions, provided that you include in the combination all
  1810. of the Invariant Sections of all of the original documents,
  1811. unmodified, and list them all as Invariant Sections of your
  1812. combined work in its license notice, and that you preserve all
  1813. their Warranty Disclaimers.
  1814. The combined work need only contain one copy of this License, and
  1815. multiple identical Invariant Sections may be replaced with a single
  1816. copy. If there are multiple Invariant Sections with the same name
  1817. but different contents, make the title of each such section unique
  1818. by adding at the end of it, in parentheses, the name of the
  1819. original author or publisher of that section if known, or else a
  1820. unique number. Make the same adjustment to the section titles in
  1821. the list of Invariant Sections in the license notice of the
  1822. combined work.
  1823. In the combination, you must combine any sections Entitled
  1824. "History" in the various original documents, forming one section
  1825. Entitled "History"; likewise combine any sections Entitled
  1826. "Acknowledgements", and any sections Entitled "Dedications". You
  1827. must delete all sections Entitled "Endorsements."
  1828. 6. COLLECTIONS OF DOCUMENTS
  1829. You may make a collection consisting of the Document and other
  1830. documents released under this License, and replace the individual
  1831. copies of this License in the various documents with a single copy
  1832. that is included in the collection, provided that you follow the
  1833. rules of this License for verbatim copying of each of the documents
  1834. in all other respects.
  1835. You may extract a single document from such a collection, and
  1836. distribute it individually under this License, provided you insert
  1837. a copy of this License into the extracted document, and follow this
  1838. License in all other respects regarding verbatim copying of that
  1839. document.
  1840. 7. AGGREGATION WITH INDEPENDENT WORKS
  1841. A compilation of the Document or its derivatives with other
  1842. separate and independent documents or works, in or on a volume of a
  1843. storage or distribution medium, is called an "aggregate" if the
  1844. copyright resulting from the compilation is not used to limit the
  1845. legal rights of the compilation's users beyond what the individual
  1846. works permit. When the Document is included in an aggregate, this
  1847. License does not apply to the other works in the aggregate which
  1848. are not themselves derivative works of the Document.
  1849. If the Cover Text requirement of section 3 is applicable to these
  1850. copies of the Document, then if the Document is less than one half
  1851. of the entire aggregate, the Document's Cover Texts may be placed
  1852. on covers that bracket the Document within the aggregate, or the
  1853. electronic equivalent of covers if the Document is in electronic
  1854. form. Otherwise they must appear on printed covers that bracket
  1855. the whole aggregate.
  1856. 8. TRANSLATION
  1857. Translation is considered a kind of modification, so you may
  1858. distribute translations of the Document under the terms of section
  1859. 4. Replacing Invariant Sections with translations requires special
  1860. permission from their copyright holders, but you may include
  1861. translations of some or all Invariant Sections in addition to the
  1862. original versions of these Invariant Sections. You may include a
  1863. translation of this License, and all the license notices in the
  1864. Document, and any Warranty Disclaimers, provided that you also
  1865. include the original English version of this License and the
  1866. original versions of those notices and disclaimers. In case of a
  1867. disagreement between the translation and the original version of
  1868. this License or a notice or disclaimer, the original version will
  1869. prevail.
  1870. If a section in the Document is Entitled "Acknowledgements",
  1871. "Dedications", or "History", the requirement (section 4) to
  1872. Preserve its Title (section 1) will typically require changing the
  1873. actual title.
  1874. 9. TERMINATION
  1875. You may not copy, modify, sublicense, or distribute the Document
  1876. except as expressly provided under this License. Any attempt
  1877. otherwise to copy, modify, sublicense, or distribute it is void,
  1878. and will automatically terminate your rights under this License.
  1879. However, if you cease all violation of this License, then your
  1880. license from a particular copyright holder is reinstated (a)
  1881. provisionally, unless and until the copyright holder explicitly and
  1882. finally terminates your license, and (b) permanently, if the
  1883. copyright holder fails to notify you of the violation by some
  1884. reasonable means prior to 60 days after the cessation.
  1885. Moreover, your license from a particular copyright holder is
  1886. reinstated permanently if the copyright holder notifies you of the
  1887. violation by some reasonable means, this is the first time you have
  1888. received notice of violation of this License (for any work) from
  1889. that copyright holder, and you cure the violation prior to 30 days
  1890. after your receipt of the notice.
  1891. Termination of your rights under this section does not terminate
  1892. the licenses of parties who have received copies or rights from you
  1893. under this License. If your rights have been terminated and not
  1894. permanently reinstated, receipt of a copy of some or all of the
  1895. same material does not give you any rights to use it.
  1896. 10. FUTURE REVISIONS OF THIS LICENSE
  1897. The Free Software Foundation may publish new, revised versions of
  1898. the GNU Free Documentation License from time to time. Such new
  1899. versions will be similar in spirit to the present version, but may
  1900. differ in detail to address new problems or concerns. See
  1901. <http://www.gnu.org/copyleft/>.
  1902. Each version of the License is given a distinguishing version
  1903. number. If the Document specifies that a particular numbered
  1904. version of this License "or any later version" applies to it, you
  1905. have the option of following the terms and conditions either of
  1906. that specified version or of any later version that has been
  1907. published (not as a draft) by the Free Software Foundation. If the
  1908. Document does not specify a version number of this License, you may
  1909. choose any version ever published (not as a draft) by the Free
  1910. Software Foundation. If the Document specifies that a proxy can
  1911. decide which future versions of this License can be used, that
  1912. proxy's public statement of acceptance of a version permanently
  1913. authorizes you to choose that version for the Document.
  1914. 11. RELICENSING
  1915. "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
  1916. World Wide Web server that publishes copyrightable works and also
  1917. provides prominent facilities for anybody to edit those works. A
  1918. public wiki that anybody can edit is an example of such a server.
  1919. A "Massive Multiauthor Collaboration" (or "MMC") contained in the
  1920. site means any set of copyrightable works thus published on the MMC
  1921. site.
  1922. "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
  1923. license published by Creative Commons Corporation, a not-for-profit
  1924. corporation with a principal place of business in San Francisco,
  1925. California, as well as future copyleft versions of that license
  1926. published by that same organization.
  1927. "Incorporate" means to publish or republish a Document, in whole or
  1928. in part, as part of another Document.
  1929. An MMC is "eligible for relicensing" if it is licensed under this
  1930. License, and if all works that were first published under this
  1931. License somewhere other than this MMC, and subsequently
  1932. incorporated in whole or in part into the MMC, (1) had no cover
  1933. texts or invariant sections, and (2) were thus incorporated prior
  1934. to November 1, 2008.
  1935. The operator of an MMC Site may republish an MMC contained in the
  1936. site under CC-BY-SA on the same site at any time before August 1,
  1937. 2009, provided the MMC is eligible for relicensing.
  1938. ADDENDUM: How to use this License for your documents
  1939. ====================================================
  1940. To use this License in a document you have written, include a copy of
  1941. the License in the document and put the following copyright and license
  1942. notices just after the title page:
  1943. Copyright (C) YEAR YOUR NAME.
  1944. Permission is granted to copy, distribute and/or modify this document
  1945. under the terms of the GNU Free Documentation License, Version 1.3
  1946. or any later version published by the Free Software Foundation;
  1947. with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
  1948. Texts. A copy of the license is included in the section entitled ``GNU
  1949. Free Documentation License''.
  1950. If you have Invariant Sections, Front-Cover Texts and Back-Cover
  1951. Texts, replace the "with...Texts." line with this:
  1952. with the Invariant Sections being LIST THEIR TITLES, with
  1953. the Front-Cover Texts being LIST, and with the Back-Cover Texts
  1954. being LIST.
  1955. If you have Invariant Sections without Cover Texts, or some other
  1956. combination of the three, merge those two alternatives to suit the
  1957. situation.
  1958. If your document contains nontrivial examples of program code, we
  1959. recommend releasing these examples in parallel under your choice of free
  1960. software license, such as the GNU General Public License, to permit
  1961. their use in free software.
  1962. 
  1963. Tag Table:
  1964. Node: Top719
  1965. Node: Introduction2042
  1966. Node: Compiling4533
  1967. Node: Executing8790
  1968. Node: Invoking11578
  1969. Node: Output Options12993
  1970. Node: Analysis Options20085
  1971. Node: Miscellaneous Options24005
  1972. Node: Deprecated Options25259
  1973. Node: Symspecs27322
  1974. Node: Output29148
  1975. Node: Flat Profile30188
  1976. Node: Call Graph35141
  1977. Node: Primary38373
  1978. Node: Callers40961
  1979. Node: Subroutines43079
  1980. Node: Cycles44920
  1981. Node: Line-by-line51697
  1982. Node: Annotated Source55773
  1983. Node: Inaccuracy58771
  1984. Node: Sampling Error59029
  1985. Node: Assumptions61933
  1986. Node: How do I?63403
  1987. Node: Incompatibilities64960
  1988. Node: Details66454
  1989. Node: Implementation66847
  1990. Node: File Format72746
  1991. Node: Internals77034
  1992. Node: Debugging85524
  1993. Node: GNU Free Documentation License87114
  1994. 
  1995. End Tag Table
  1996. 
  1997. Local Variables:
  1998. coding: utf-8
  1999. End: