From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Markus_Sch=c3=b6pflin?= Newsgroups: comp.lang.ada Subject: Profiling Ada binaries Date: Fri, 22 Jul 2016 15:24:31 +0200 Organization: Aioe.org NNTP Server Message-ID: NNTP-Posting-Host: MdpKeRr+sx3LK7JQiK5aNw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 X-Notice: Filtered by postfilter v. 0.8.2 X-Mozilla-News-Host: news://nntp.aioe.org:119 Xref: news.eternal-september.org comp.lang.ada:31122 Date: 2016-07-22T15:24:31+02:00 List-Id: Dear list, I realize that the following question is rather vague, but I hope that perhaps someone can give me some advice on how to proceed, or maybe has already experienced similar issues. I am trying to profile code generated by Gnat using Gprof. For this I add -pg to the compilation and link switches, turn down optimization to -O1 and disable inlining of functions only called once (-fno-inline-functions-called-once). The result obtained when running gprof to generate the report from the profiling data gathered during running the executable is rather strange, as the report suggests that e.g. elaboration functions of compilation units are called countless times, which of course most likely isn't true. To illustrate, here are the first few lines of a flat profile: Flat profile: Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls s/call s/call name 4.66 4.91 4.91 429 0.01 0.01 foo1 4.41 9.55 4.64 162635540 0.00 0.00 bar___elabs 3.99 13.76 4.21 515639 0.00 0.00 foo2 As one can see, the second line suggests that the elaboration for the spec of the package bar is called 162635540 times. Looking at the call graph of bar___elabs shows: 0.00 0.00 1/162635540 adainit [92] 0.00 0.00 33/162635540 standard_math__float_32_elementary__arccosX [2249] 0.00 0.00 1461/162635540 standard_math__float_32_elementary__arcsinX [1099] 0.00 0.00 108848/162635540 standard_math__float_64_elementary__arctanX [1573] 0.00 0.00 109380/162635540 standard_math__float_64_elementary__sinX [1572] 0.00 0.00 163937/162635540 standard_math__float_64_elementary__cosX [687] 0.01 0.00 515639/162635540 standard_math__float_32_elementary__OexponX [609] 0.03 0.00 1029874/162635540 standard_math__float_32_elementary__tanX [346] 0.04 0.00 1358089/162635540 standard_math__float_64_elementary__sqrtX [454] 0.04 0.00 1543778/162635540 standard_math__float_32_elementary__logX [558] 0.50 0.00 17564360/162635540 standard_math__float_32_elementary__expX [93] 0.56 0.00 19681964/162635540 standard_math__float_32_elementary__arctanX [56] 0.79 0.00 27790226/162635540 standard_math__float_32_elementary__cosX [51] 0.82 0.00 28730603/162635540 standard_math__float_32_elementary__sinX [49] 1.83 0.00 64037347/162635540 standard_math__float_32_elementary__sqrtX [45] [33] 4.4 4.64 0.00 162635540 bar___elabs [33] There is one legit call from adainit, all other reported calls are most likely incorrect. The many calls to standard math functions most likely are correct, they just don't call bar___elabs. Did anybody encounter such anomalies before? Is there a way to get correct profiling information for Ada binaries generated by Gnat? Different compiler flags maybe? Or using a different profiling tool altogether? TIA, Markus