X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=contents%2Fusing-lttng%2Finstrumenting%2Fc-application%2Fbuilding-linking%2Fstatic-linking.md;h=23e049ad0c3b9b42e9eb6bc1b64c37cdf774557a;hb=6d30cd92b72a789ccdd2c881271dd4e51441a862;hp=4f53e2b656132e1ff690f5630c90881e98087244;hpb=5e0cbfb01373c18e521217342fd8a9159cc186b1;p=lttng-docs.git diff --git a/contents/using-lttng/instrumenting/c-application/building-linking/static-linking.md b/contents/using-lttng/instrumenting/c-application/building-linking/static-linking.md index 4f53e2b..23e049a 100644 --- a/contents/using-lttng/instrumenting/c-application/building-linking/static-linking.md +++ b/contents/using-lttng/instrumenting/c-application/building-linking/static-linking.md @@ -39,10 +39,11 @@ int my_func(int a, const char* b) /* ... */ ~~~ -Again, `TRACEPOINT_CREATE_PROBES` and `TRACEPOINT_DEFINE` must be -defined in one, **and only one**, translation unit. Other C source -files of the same application may include `tp.h` to use tracepoints -with `tracepoint()`, but must not define +Again, before including a given tracepoint provider header file, +`TRACEPOINT_CREATE_PROBES` and `TRACEPOINT_DEFINE` must be defined in +one, **and only one**, translation unit. Other C source files of the +same application may include `tp.h` to use tracepoints with +the `tracepoint()` macro, but must not define `TRACEPOINT_CREATE_PROBES`/`TRACEPOINT_DEFINE` again. This translation unit may be built as an object file by making sure to @@ -63,8 +64,17 @@ separate object file by using a dedicated C source file to create probes: `TRACEPOINT_DEFINE` must be defined by a translation unit of the application. Since we're talking about static linking here, it could as -well be defined in the file above, before `#include "tp.h"`. This is -actually what [`lttng-gen-tp`](#doc-lttng-gen-tp) does. +well be defined directly in the file above, before `#include "tp.h"`: + +~~~ c +#define TRACEPOINT_CREATE_PROBES +#define TRACEPOINT_DEFINE + +#include "tp.h" +~~~ + +This is actually what [`lttng-gen-tp`](#doc-lttng-gen-tp) does, and is +the recommended practice. Build the tracepoint provider: