gprof产生空输出 [英] gprof produces empty output

查看:210
本文介绍了gprof产生空输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Ubuntu 16.10,并尝试使用gprof分析程序.我用标志-pg进行编译,并且该程序是单线程的.实际的编译命令为:

I'm running Ubuntu 16.10 and trying to profile a program using gprof. I compile with the flag -pg and the program is single-threaded. The actual compile commands are:

g++ -I. -std=c++11 -Wall -Wextra -O3 -pg -fPIC -Wno-unused-parameter -c -o build/obj/performance/stencil_application.o test/performance/stencil_application.cpp
g++ -I. -std=c++11 -Wall -Wextra -O3 -pg -Wno-unused-parameter build/obj/performance/stencil_application.o -o build/test/performance/stencil_application

该程序在运行时需要花费几秒钟才能完成,并且会生成一个名为gmon.out的文件.但是,当我运行gprof ./build/test/performance/stencil_application时,得到的输出中没有数字.我只得到表格标题和不同字段的解释,就像这样:

The program takes a couple of seconds to finish when I run it, and a file named gmon.out is produced. However, when I run gprof ./build/test/performance/stencil_application, the output I get contains no numbers. I only get the table headings and the explanation for the different fields, like this:

Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  Ts/call  Ts/call  name    

 %         the percentage of the total running time of the
time       program used by this function.

cumulative a running sum of the number of seconds accounted
 seconds   for by this function and those listed above it.

 self      the number of seconds accounted for by this
seconds    function alone.  This is the major sort for this
           listing.

calls      the number of times this function was invoked, if
           this function is profiled, else blank.

 self      the average number of milliseconds spent in this
ms/call    function per call, if this function is profiled,
           else blank.

 total     the average number of milliseconds spent in this
ms/call    function and its descendents per call, if this
           function is profiled, else blank.

name       the name of the function.  This is the minor sort
           for this listing. The index shows the location of
           the function in the gprof listing. If the index is
           in parenthesis it shows where it would appear in
           the gprof listing if it were to be printed.

Copyright (C) 2012-2016 Free Software Foundation, Inc.

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.

                     Call graph (explanation follows)


granularity: each sample hit covers 2 byte(s) no time propagated

index % time    self  children    called     name

 This table describes the call tree of the program, and was sorted by
 the total amount of time spent in each function and its children.

以此类推.

我也尝试了在没有-O3-g的情况下进行编译,但是结果相同.有人知道怎么了吗?

I've also tried to compile without -O3 and with -g, but with the same result. Does anybody know what's wrong?

推荐答案

正如上述Tony Beta Lambda的评论所指出的,这是

As pointed out in the comment by Tony Beta Lambda above, this is a bug in gcc. There are two possible workarounds: Downgrade to gcc-4.9, or compile with the flag -no-pie.

这篇关于gprof产生空输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆