Clarify TRACEPOINT_DEFINE and multi TP
[lttng-docs.git] / contents / using-lttng / instrumenting / c-application / building-linking / dynamic-linking.md
index 1284be60bca02dd7fd80d7bf330ff02c1d05b6d4..e52363bc78715ea0b5bf02f2f03e14ab6193d013 100644 (file)
@@ -19,11 +19,27 @@ The process to create the tracepoint provider shared object is pretty
 much the same as the static library method, except that:
 
   * since the tracepoint provider is not part of the application
-    anymore, `TRACEPOINT_DEFINE` _must_ be defined in one translation
-    unit (C source file) of the _application_;
+    anymore, `TRACEPOINT_DEFINE` _must_ be defined, for each tracepoint
+    provider, in exactly one translation unit (C source file) of the
+    _application_;
   * `TRACEPOINT_PROBE_DYNAMIC_LINKAGE` must be defined next to
     `TRACEPOINT_DEFINE`.
 
+Regarding `TRACEPOINT_DEFINE` and `TRACEPOINT_PROBE_DYNAMIC_LINKAGE`,
+the recommended practice is to use a separate C source file in your
+application to define them, and then include the tracepoint provider
+header files afterwards, e.g.:
+
+~~~ c
+#define TRACEPOINT_DEFINE
+#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
+
+/* include the header files of one or more tracepoint providers below */
+#include "tp1.h"
+#include "tp2.h"
+#include "tp3.h"
+~~~
+
 `TRACEPOINT_PROBE_DYNAMIC_LINKAGE` makes the macros included afterwards
 (by including the tracepoint provider header, which itself includes
 LTTng-UST headers) aware that the tracepoint provider is to be loaded
@@ -67,3 +83,4 @@ LTTng-UST tracing support:
 <pre class="term">
 ./app
 </pre>
+
This page took 0.023638 seconds and 4 git commands to generate.