web-dev-qa-db-fra.com

gprof produit une sortie vide

J'utilise Ubuntu 16.10 et j'essaie de profiler un programme en utilisant gprof. Je compile avec le drapeau -pg et le programme est monothread. Les commandes de compilation réelles sont:

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

Le programme prend quelques secondes pour se terminer lorsque je l'exécute et un fichier nommé gmon.out est produit. Cependant, lorsque je lance gprof ./build/test/performance/stencil_application, la sortie que je reçois ne contient aucun chiffre. Je ne reçois que les en-têtes du tableau et l'explication des différents champs, comme ceci:

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.

etc.

J'ai aussi essayé de compiler sans -O3 et avec -g, mais avec le même résultat. Quelqu'un sait-il ce qui ne va pas?

22
Malin

Comme indiqué dans le commentaire de Tony Beta Lambda ci-dessus, il s'agit d'un bug dans gcc . Il existe deux solutions possibles: rétrograder vers gcc-4.9 ou compiler avec l'indicateur -no-pie.

18
Malin