[lttng-dev] Instrumenting a Shared Object
jeremie.galarneau at efficios.com
Mon Aug 17 18:22:07 EDT 2015
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
If you can guarantee this doesn't happen, you should be pretty much good to
On Thu, Aug 13, 2015 at 7:40 PM, Brian Robbins <brianrob at microsoft.com>
> 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
> 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
> 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.
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the lttng-dev