[ltt-dev] UST Instrumenting function entries and exits

Bernd Hufmann Bernd.Hufmann at ericsson.com
Fri May 13 10:36:49 EDT 2011


Hi Matthew

This is an interesting feature. This could be used to create call trees 
which could be visualized in different ways.

I have two questions around this:

1) Performance
What is the performance of such an instrumentation? I think it adds a 
constant overhead to each function call and exit. This overhead will be 
smaller if the compiler can use inline methods instead of plain function 
calls. Moreover,  these instrumentation function calls (inline or not) 
will be done every time, even if the ust_makers are disabled. Ideally, 
what we want is to have only the ust_makers at entry and exit of the 
functions. So, we would benefit from the performance of UST.

2) Exceptions
In C++ the software designer could use exceptions to exit methods in for 
example an error case. Does this instrumentation cover this, too?

Thanks
Bernd

On 05/12/2011 01:32 PM, Matthew Khouzam wrote:
> Hello world,
> I just made a little program that I'm testing out and want some opinions
> now that Mathieu D and Nils are not able to read their emails. ;)
>
> This is a shared object (or code injected straight into the source) that
> will allow ust calls to be hooked onto the function entries and exits.
>
> Here is the basic code.
> <code>
> #include<execinfo.h>
> #include<ust/marker.h>
>
> // will add a cache for the function names later.
>
> void __cyg_profile_func_enter (void *this_fn,
>                                           void *call_site)
> {
>      char *funcname = backtrace_symbols(&this_fn, 1)[0];
>      ust_marker(entry, "func_entry %s", funcname);
>      // memory leak
> }
>
> void __cyg_profile_func_exit  (void *this_fn,
>                                           void *call_site)
> {
>      char *funcname = backtrace_symbols(&this_fn, 1)[0];
>      ust_marker(exit, "func_exit %s", funcname);
>      // memory leak
> }
> </code>
> When you make the main program, you must include in the cflags
> -finstrument-code.
>
> I would like some comments on this and to get the idea rolling to
> include something similar but less ugly in ust's mainline.
>
> The first thing I will say : backtrace_symbols does a malloc, we are
> therefore doing two mallocs per function calls and no frees.
> I think we do need function names and not offsets though, the user
> experience is key in this feature since it is not adding a new
> functionality, just making people have an easier time.
> I hope that something like this would be able to make us generate UST
> "sequence diagram" like viewers.
>
> Thanks world,
> Matthew
>
>
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev





More information about the lttng-dev mailing list