From: Philippe Proulx Date: Fri, 19 Dec 2014 21:17:21 +0000 (-0500) Subject: dynamic-linking: note about instrumenting a SO X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=382d32dd80972b4c4cef627b935b4aa488c5fd51;p=lttng-docs.git dynamic-linking: note about instrumenting a SO Signed-off-by: Philippe Proulx --- diff --git a/contents/using-lttng/instrumenting/c-application/building-linking/dynamic-linking.md b/contents/using-lttng/instrumenting/c-application/building-linking/dynamic-linking.md index e52363b..aec70c6 100644 --- a/contents/using-lttng/instrumenting/c-application/building-linking/dynamic-linking.md +++ b/contents/using-lttng/instrumenting/c-application/building-linking/dynamic-linking.md @@ -68,15 +68,48 @@ provider, but still needs `libdl`: gcc -o app other.o files.o of.o your.o app.o -ldl -Now, to make LTTng-UST tracing available to the application, -the `LD_PRELOAD` environment variable is used to preload the -tracepoint provider shared library _before_ the application actually -starts: +Now, to make LTTng-UST tracing available to the application, the +`LD_PRELOAD` environment variable is used to preload the tracepoint +provider shared library _before_ the application actually starts:
 LD_PRELOAD=/path/to/tp.so ./app
 
+
+

+ Note:It is not safe to use + dlclose() on a tracepoint provider shared object that + is being actively used for tracing, due to a lack of reference + counting from LTTng-UST to the shared object. +

+ +

+ For example, statically linking a tracepoint provider to a + shared object which is to be dynamically loaded by an application + (e.g., a plugin) is not safe: the shared object, which contains the + tracepoint provider, could be dynamically closed + (dlclose()) at any time by the application. +

+ +

+ To instrument a shared object, either: +

+ +
    +
  1. + Statically link the tracepoint provider to the + application, or +
  2. +
  3. + Build the tracepoint provider as a shared object (following + the procedure shown in this section), and preload it when + tracing is needed using the LD_PRELOAD + environment variable. +
  4. +
+
+ Your application will still work without this preloading, albeit without LTTng-UST tracing support: