This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TI-CGT: Is there a way to set entry_hook, exit_hook on a function by function basis?

Part Number: TI-CGT

Hi All,

I am using the --entry_hook and --exit_hook options for profiling my code.  It's great.  I can enable hooks on a per project or per file basis easily.  Additionally, I know how to disable hooks for specific function by using the #PRAGMA NO_HOOKS() directive.  However, it can get onerous to add the NO_HOOKS directive to every function in a file if I only want to profile a subset of the functions.

Is there an easy way to tell the linker to only enable the entry/exit hooks on a per function basis?  I.e. Opt in to profiling instead of Opt out?

Thanks,

-Colin

  • Niloc2004 said:
    Is there an easy way to tell the linker to only enable the entry/exit hooks on a per function basis?

    Unfortunately, no.  However, there is way to do it yourself.  It is a fair amount of work.  But you only have to do it once.

    Add #PRAGMA NO_HOOKS for every function in the file, but control whether they are applied with preprocessor symbols that may or may not be set on the compile command line.  

    #if !defined(PROFILE_SUBSET1)
    #pragma NO_HOOKS(f1)
    #pragma NO_HOOKS(f2)
    #pragma NO_HOOKS(f3)
    #endif
    
    #if !defined(PROFILE_SUBSET2)
    #pragma NO_HOOKS(f4)
    #pragma NO_HOOKS(f5)
    #pragma NO_HOOKS(f6)
    #endif

    By default, none of these functions are profiled.  To profile the first set of functions, build with -DPROFILE_SUBSET1.  To profile the second set of functions, build with -DPROFILE_SUBSET2.

    Thanks and regards,

    -George

  • George,

    Thank you.

    -Colin