[ltt-dev] UST Instrumenting function entries and exits

Matthew Khouzam matthew.khouzam at ericsson.com
Thu May 12 14:05:53 EDT 2011


An addition: -finstrument-code doesn't exist. it's -finstrument-functions

On 11-05-12 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