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.

System Analyzer: Execution Graph features : do I need target instrumentation code for generation UIA function entry/exit events ?

Other Parts Discussed in Thread: SYSBIOS

Hi,

I would like to run the excution graph features of the System Analzer.

So far I understand that functions are displayed as UIA start/stop events are available.

Questions:

Can I generate function entry/exit event without adding instrumentation code to the target ? (like log_write1(UIBenchmak_start...))

Would it be possible to run some function profiling automatically, without the need to instrument the target code ?

 

many thanks

Alois

  • Alois,

    Unfortunately you cannot currently do function profiling with System Analyzer without instrumenting the target code. We are working on support using hardware instrumentation but this will not be available until mid-2012.

    If you don't mind the overhead of the instrumentation and is more concern with the actual work of adding the instrumentation, there is a way to get the compiler to call a hook function at the entry and exist of each function. This can be used to simplify the instrumentation required.

    On simulator you can run the Profiler feature without instrumenting code.

    Regards,

    Imtaz.

  • Hi Imtaz,

    many thanks for the infos.

    Could you give me some hints (or examples) adding proper hook function with the compiler ?

    Actually I can do manual insertion anyway, as I have only a few functions to watch.

     

    regards

    Alois

  • Alois,

     

    Just some info …

     

    You’re probably aware that there are two type of analysis/events supported by System Analyzer … benchmarking which is stop time – start time and context aware profile.

     

    Key differences between benchmark/duration and context profile:

    • Context profile calculates inclusive and exclusive benchmarking
    • If context information is being logged (either by turning SYSBIOS context switch or explicitly logging via an OS hook function) then context will be taken into consideration. If no context then it will assume all in the same context
    • Inclusive benchmarking = stoptime – starttime - anytime spent in any other context
    • Exclusive benchmaking = inclusive benchmarking – any time spent in any other function during this time

     

    Btw, it wasn’t clear if you wanted me to dig up info on using the hook functions or if you’re ok with inserting individual instrumentation.

     

    Regards,

    Imtaz.

  • Imtaz,

    yes, your information is very helpful.

    For the moment I am OK with inserting individual instrumentation.

    Still I would ask you for more information about inserting hook functions with the compiler. Iwould like to understand how it works (compiler options, exampes ?), because thsi is still an option for me.

     

    regards

    Alois

     

     

  • Alois,

    Sorry for the slow response. Here is the content from the compiler help regarding this. Basically you define an function to log the UIA function start event and one for exit then use the compiler to hook these in automatically to every function. We are in the process of creating an example on how to do this and will post additional info when available.

     Regards,

    Imtaz.

    Enabling Entry Hook and Exit Hook Functions

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    An entry hook is a routine that is called upon entry to each function in the program. An exit hook is a routine that is called upon exit of each function. Applications for hooks include debugging, trace, profiling, and stack overflow checking.

    Entry and exit hooks are enabled using the following options:

    --entry_hook[=Name] :

     

    Enables entry hooks. If specified, the hook function is called name. Otherwise, the default entry hook function name is __entry_hook.

    --entry_parm{=Name|address|none} :

     

    Specify the parameters to the hook function. The name parameter specifies address|none} that the name of the calling function is passed to the hook function as an argument. In this case the signature for the hook function is: void hook(const char *name); The address parameter specifies that the address of the calling function is passed to the hook function. In this case the signature for the hook function is: void hook(void (*addr)()); The none parameter specifies that the hook is called with no parameters. This is the default. In this case the signature for the hook function is: void hook(void);

    --exit_hook

     

     

    --exit_parm

     

    {=Name|address|none} :  Specify the parameters to the hook function. The name parameter specifies that the name of the calling function is passed to the hook function as an argument. In this case the signature for the hook function is: void hook(const char *name); The address parameter specifies that the address of the calling function is passed to the hook function. In this case the signature for the hook function is: void hook(void (*addr)()); The none parameter specifies that the hook is called with no parameters. This is the default. In this case the signature for the hook function is: void hook(void);

    The presence of the hook options creates an implicit declaration of the hook function with the given signature. If a declaration or definition of the hook function appears in the compilation unit compiled with the options, it must agree with the signatures listed above.

    In C++, the hooks are declared extern "C". Thus you can define them in C (or assembly) without being concerned with name mangling.

    Hooks can be declared inline, in which case the compiler tries to inline them using the same criteria as other inline functions.

    Entry hooks and exit hooks are independent. You can enable one but not the other, or both. The same function can be used as both the entry and exit hook.

    You must take care to avoid recursive calls to hook functions. The hook function should not call any function which itself has hook calls inserted. To help prevent this, hooks are not generated for inline functions, or for the hook functions themselves.

    You can use the --remove_hooks_when_inlining option to remove entry/exit hooks for functions that are auto-inlined by the optimizer.

    See

     

    Section 6.9.21 for information about the NO_HOOKS pragma

    [=name] : Enables exit hooks. If specified, the hook function is called name. Otherwise, the default exit hook function name is __exit_hook.

     

     

  • Hi Imtaz,

    with the following compiler options and hook functions code I could instrument my application properperly.

    many thanks and best regards

    Alois

     

    compiler options:

    --entry_hook=Diag_function_entry_hook --entry_parm=address

    --exit_hook=Diag_function_exit_hook --exit_parm=address

     

    actual hook function code:

    void Diag_function_entry_hook(void (*addr)()) {

        Log_write3(UIABenchmark_startInstanceWithAdrs, (IArg)"Func: id=%x, Fxn=%x", 0, (IArg)addr);

    }

    void Diag_function_exit_hook(void (*addr)()) {

        Log_write3(UIABenchmark_stopInstanceWithAdrs, (IArg)"Func: id=%x, Fxn=%x", 0, (IArg)addr);

    }

     

  • Alois,

    Thanks for the update and good to here that you're able to instrument your code. We are in the process of updating the System Analyzer wiki page with a FAQ on how to do this.

    Regards,

    Imtaz.