2017-03-06 6 views
14

저는 우분투 16.10을 실행 중이며 gprof를 사용하여 프로그램을 프로파일하려고합니다. 플래그 -pg으로 컴파일하고 프로그램은 단일 스레드입니다. 실제 컴파일 명령은 다음과 같습니다gprof가 빈 출력을 생성합니다.

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을 실행하면 출력에는 숫자가 포함되지 않습니다. 나는 다음과 같이 표제 표제와 다른 분야에 대한 설명을 얻는다 :

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없이 컴파일하려고했지만 동일한 결과가 나타납니다. 누가 잘못되었는지 알아?

+6

[이 버그] (https://bugs.launchpad.net/ubuntu/+source/gcc-6/+sug/1678510)와 같은 소리 –

+0

동일한 문제가 있습니다. – thb

+0

@thb : 위의 설명을 참조하십시오. – Malin

답변

10

위의 Tony Beta Lambda가 지적한 바와 같이, 이것은 bug in gcc입니다. 두 가지 가능한 해결 방법이 있습니다 : gcc-4.9로 다운 그레이드하거나 --no-pie 플래그로 컴파일하십시오.

+0

GCC 6.3에서 작동합니다. --no-pie와 -pg를 모두 사용합니다. –

+3

나를 위해'--no-pie' (단 하나의 대시)를 쓰는 반면,'--no-pie'는하지 않았습니다. – 7anner

+0

올바른 플래그는 실제로'-no-pie'입니다. – Olivier

관련 문제