简体   繁体   English

gprof命令没有创建正确的out.txt

[英]gprof command is not creating proper out.txt

First of all I'm running MacOSX 10.7.1. 首先,我正在运行MacOSX 10.7.1。 I've installed all properly, Xcode 4 and all the libraries, to work with C lenguage. 我安装了所有正确的Xcode 4和所有库,以使用C语言。

I'm having troubles running gprof command in shell. 我在shell中运行gprof命令时遇到了麻烦。 I'll explain step by step what I'm doing and the output I'm receiving. 我将逐步解释我正在做的事情以及我收到的输出。

Step 1: 第1步:

~ roger$ cd Path/to/my/workspace
~ roger$ ls

Output (Step 1): 输出(步骤1):

queue.c         queue.h         testqueue.c

Step 2: 第2步:

~ roger$ gcc -c -g -pg queue.c
~ roger$ ls

Output (Step 2): 输出(第2步):

queue.c         queue.h         queue.o         testqueue.c

Step 3: 第3步:

~ roger$ gcc -o testqueue -g -pg queue.o testqueue.c
~ roger$ ls

Output (Step 3): 输出(步骤3):

queue.c         queue.h         queue.o         testqueue       testqueue.c

Step 4: 第四步:

~ roger$ ./testqueue
~ roger$ ls

Output (Step 4): 输出(步骤4):

enqueue element 16807
head=0,tail=1
enqueue element 282475249
head=0,tail=2
enqueue element 1622650073
head=0,tail=3
enqueue element 984943658
head=0,tail=4
enqueue element 1144108930
head=0,tail=5
enqueue element 470211272
head=0,tail=6
enqueue element 101027544
head=0,tail=7
enqueue element 1457850878
head=0,tail=8
enqueue element 1458777923
head=0,tail=9
enqueue element 2007237709
head=0,tail=10
queue is full
dequeue element 16807
dequeue element 282475249
dequeue element 1622650073
dequeue element 984943658
dequeue element 1144108930
dequeue element 470211272
dequeue element 101027544
dequeue element 1457850878
dequeue element 1458777923
dequeue element 2007237709
queue is empty

gmon.out        queue.h         testqueue
queue.c         queue.o         testqueue.c

Step 5: 第5步:

~ roger$ gprof -b testqueue gmon.out > out.txt
~ roger$ nano out.txt

Output (Step 5): 输出(步骤5):

  GNU nano 2.0.6               File: out.txt


granularity: each sample hit covers 4 byte(s) no time propagated
called/total       parents
index  %time    self descendents  called+self    name           index
called/total       children

^L

granularity: each sample hit covers 4 byte(s) no time accumulated

%   cumulative   self              self     total
time   seconds   seconds    calls  ms/call  ms/call  name

^L

Index by function name

Finally. 最后。 The output file should show something like this: 输出文件应该显示如下:

    %   cumulative   self              self     total
 time   seconds   seconds    calls  ms/call  ms/call  name
 33.34      0.02     0.02     7208     0.00     0.00  open
 16.67      0.03     0.01      244     0.04     0.12  offtime
 16.67      0.04     0.01        8     1.25     1.25  memccpy
 16.67      0.05     0.01        7     1.43     1.43  write
 16.67      0.06     0.01                             mcount
  0.00      0.06     0.00      236     0.00     0.00  tzset
  0.00      0.06     0.00      192     0.00     0.00  tolower
  0.00      0.06     0.00       47     0.00     0.00  strlen
  0.00      0.06     0.00       45     0.00     0.00  strchr
  0.00      0.06     0.00        1     0.00    50.00  main
  0.00      0.06     0.00        1     0.00     0.00  memcpy
  0.00      0.06     0.00        1     0.00    10.11  print
  0.00      0.06     0.00        1     0.00     0.00  profil
  0.00      0.06     0.00        1     0.00    50.00  report
...

And it shows blank field. 它显示空白字段。

I searched here and I found nothing helpfully at all. 我在这里搜索,我一点也没有找到任何帮助。 I google it but the same thing. 我谷歌但是同样的事情。

I would be very grateful If anyone could help me please. 如果有人能帮助我,我将非常感激。

gprof does not work on OS X. The system call it needs was removed several versions ago. gprof在OS X上不起作用。几个版本之前删除了它所需的系统调用。 It's not clear why the utility still ships. 目前尚不清楚为什么公用事业仍在发货。 The alternatives are to use dtrace and/or sample. 替代方案是使用dtrace和/或样本。

不需要在最后一行给出gmon.out,给gprof -b testqueue> out.txt看http://www.network-theory.co.uk/docs/gccintro/gccintro_80.html以供进一步参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM