Search code examples
clinuxgprof

Excluding a function from gprof results


I want to exclude some functions from the output generated by gprof. In other words, I do not want them to be included when calculating percentage time spent by each function during execution. I read at one place -E option can be used.

However I'm using gprof -E function_to_be_exluded my_program_name, but nothing happens. The manual says it is depreciated and you should use symspecs instead. However, I have wasted half an hour trying to figure out how to achieve it with symspecs, but no luck. Anyone can kindly help me in this.


Solution

  • Exactly, gprof -e -E are deprecated and superseded by usage of newer relevant options that have argument - symspecs. So try using:

    gprof --no-time=symspec 
    
    The -n option causes "gprof", in its call graph analysis, not to propagate times for
    symbols matching symspec.
    
    e.g.
    
    gprof --no-time=name_of_function_you_dont_want_to_profile.
    

    Use this along with your other gprof options (-E -e definitely ruled out)