[lttng-dev] Instrumenting a Shared Object

Jérémie Galarneau jeremie.galarneau at efficios.com
Mon Aug 17 18:22:07 EDT 2015


Hi Brian,

Mathieu will probably weigh in on this shortly. In the meantime, here's my
understanding of the problem.

In order to produce a trace, you have to ensure both liblttng-ust and your
provider(s) are linked into the application. That can be done either by
LD_PRELOAD-ing, dynamically linking, or dlopen-ing() both. Not linking
against liblttng-ust will simply result in your application not producing a
trace (since the application will never register to the session daemon),
but will have no adverse effect.

The real concern with dlclose-ing the providers is that you have to be
entirely sure that no tracepoints will be triggered after the provider is
unloaded/dlclose. There is no reference counting to ensure the provider
remains loaded as long as any probes remain reachable or any other
mechanism of the sort. Therefore, triggering a tracepoint after the
provider has been unloaded will result in a crash. Keep in mind that
triggering tracepoints remains entirely safe if the providers are never
loaded. Only triggering after a dlopen/dlclose of providers may cause
problems.

If you can guarantee this doesn't happen, you should be pretty much good to
go.

Regards,
Jérémie


On Thu, Aug 13, 2015 at 7:40 PM, Brian Robbins <brianrob at microsoft.com>
wrote:

> Hello,
>
>
>
> I’m looking to instrument a shared object using LTTng-UST tracepoints.
> The expectation is that users of the library will use dlopen to open it at
> the beginning of their application and dlclose right before process exit.
> From what I’ve read at
> http://lttng.org/docs/#doc-building-tracepoint-providers-and-user-application,
> it sounds like there is some complexity with this as the tracepoint
> definition must remain in memory, but I want to make sure I fully
> understand.
>
>
>
> If I want to instrument a shared object, is my only option to dynamically
> link and use LD_PRELOAD?  Also, do my options change if I know that the
> process will exit right after it calls dlclose on the library?
>
>
>
> Thank you very much.
>
> -Brian
>
>
>
>
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>
>


-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20150817/5cefc7de/attachment.html>


More information about the lttng-dev mailing list