This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

"New gprof" for gcc V2.95.2+


Hello,

I've developed a profiler for C/C++ programs, based on the '-finstrument-functions' feature
of gcc V2.95.2+.

My motivation is that gprof cant take in count time spend in not-profiled functions.
For example, the function:
f(int n)
{
  sleep(1);
  if (n <=0)
    return;
  f(n-1);
}
profiled with gprof gives a 0 time...

It is a problem for me as I want to profile programs that use _many_ calls to libs
that are not profiled (and not profilable). When profiling with gprof, it gives me
invalid times, because all functions using non-profiling calls have short execution
time, which is not real at all.

With my approach, treatments are adding for each enter/exit of functions, and
an internal call-stack allows to know the local time spend in functions, EVEN
if they call non-profiled function.

See http://www710.univ-lyon1.fr/~yperret/profiler.html (devel version will soon
be the V1.1.5 pre-V1.2).
 

I think that this tool can be usefull for other people, and I think that:
1. people from binutils can help me to improve it
2. it can become a part (I hope) of binutils if you think it can help people
 

Thank you in advance for your answer.
I'm open to discution, you can email me to obtain more details...
 
 

Example of profile output of my library on a small program (including functions
calling functions that are not profiled, recursive function, and cross-recursive functions):

[it is supposed to be displayed with fixed font]

> bin/fncdump bin/essai

FunctionChecker for gcc (by Hexasoft)

Profile for 'bin/essai'
Total execution time: 16.456096
Times computed using real clock time.
Number of realloc performed: 0

|         local      |         total      |            |             |
|        sec. |   %  |        sec. |   %  |   calls    |tot. sec/call| name
|-------------|------|-------------|------|------------|-------------|--------
|     0.001403|  0.01|    16.456096|100.00|           1|    16.456096| main
|     4.031660| 24.50|     8.071628| 49.05|           4|     2.017907| recurs_1s
|     2.737634| 16.64|     5.482986| 33.32|           4|     1.370747| recurs_a
|     2.745352| 16.68|     4.814751| 29.26|           4|     1.203688| recurs_b
|     4.039960| 24.55|     4.039960| 24.55|           4|     1.009990| s1
|     2.899960| 17.62|     2.899960| 17.62|           1|     2.899960| test
|     0.000056|  0.00|     0.000103|  0.00|          32|     0.000003| recurs
|     0.000008|  0.00|     0.000014|  0.00|           1|     0.000014| f3
|     0.000006|  0.00|     0.000006|  0.00|           3|     0.000002| f1
|     0.000002|  0.00|     0.000002|  0.00|           1|     0.000002| small

Unresolved functions not shown    : 0
Spontaneous functions not shown   : 0
Hidden functions due to -not/-only: 0
Final stack size used: 33
Number of function(s): 10

|indx|     MIN     |     MAX     |name
|----|-------------|-------------|-----
|   0|    16.456096|    16.456096| main
|   1|     2.020003|     8.071628| recurs_1s
|   2|     1.401139|     5.482986| recurs_a
|   3|     0.714880|     4.814751| recurs_b
|   4|     1.009984|     1.009993| s1
|   5|     2.899960|     2.899960| test
|   6|     0.000002|     0.000103| recurs
|   7|     0.000014|     0.000014| f3
|   8|     0.000002|     0.000002| f1
|   9|     0.000002|     0.000002| small

'main' [0] spontaneously called.

'recurs_1s' [1] called by:
   [0],
   [1],

'recurs_a' [2] called by:
   [0],
   [3],

'recurs_b' [3] called by:
   [2],

's1' [4] called by:
   [1],

'test' [5] called by:
   [0],

'recurs' [6] called by:
   [0],
   [6],

'f3' [7] called by:
   [0],

'f1' [8] called by:
   [7],

'small' [9] called by:
   [0],
 
 

Here is the '--help' of the 'fncdump' program:

 > bin/fncdump --help
fncdump by Hexasoft (Y.Perret, December 2000)
Usage: bin/fncdump exec [opts]
   or: bin/fncdump -avg
Opts:  -sfile f        : use 'f' as stat file instead of 'fnccheck.out'
       -sort n         : sort mode. See at the end for details
       +sort n         : sort mode (reverse). See at the end for details
       -no-spontaneous : dont print spontaneous called functions (dont apply to main)
       -no-unresolved  : dont print unresolved symbols
       -calls          : show 'called' functions instead of 'called by'
       +calls          : show 'called' functions AND 'called by'
       -no-minmax      : dont display MIN/MAX time for functions
       -nm             : use 'nm' instead of 'libbfd'(1) to extract names
       -addr2line      : use 'addr2line' instead of 'libbfd'(1) to extract names
       -func-details   : add file/line for functions (not with '-nm')
       -call-details   : add file/line for function calls (not with '-nm')
       -fullname       : use full pathname for file/line info
       -only <lst>     : just use functions that are in the comma separated list
       -not <lst>      : dont use functions that are in the comma separated list
       -propagate      : -only/-not is applied to childs
       -rpropagate     : -only/-not is applied to callers
       -real-maxtime   : use total execution time of displayed functions rather
                         than total exec. time of all functions.
       --help          : this message
       --version       : fnccheck/bin/fncdump version
       --misc          : author/contact/bugs
       --details       : explanations about displayed informations
(1): if 'fncdump' is compiled using 'libbfd' (standard behavior).
     Else (make fncdump_nobfd), -addr2line is the default approach.
Sort types:
    1:  sorted by 'Local time'
    2:  sorted by 'Total time'
    3:  sorted by 'Call number'
    4:  sorted by 'Function name'
    5:  sorted by 'No sort'
The -avg usage gives you the average time spend
  in FncCheck treatments per each of your function.
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]