ce1ae11dab953baeb0c69febc31f943ed7647dc8
[lttng-docs.git] /
1 ---
2 id: instrumenting-out-of-tree-linux-kernel
3 ---
4
5 Instrumenting a custom Linux kernel module for LTTng follows the exact
6 same steps as
7 [adding instrumentation to the Linux kernel itself](#doc-instrumenting-linux-kernel-itself),
8 the only difference being that your mainline tracepoint definition
9 header doesn't reside in the mainline source tree, but in your
10 kernel module source tree.
11
12 The only reference to this mainline header is in the LTTng custom
13 probe's source code (`probes/lttng-probe-hello.c` in our example), for
14 build time verification:
15
16 ~~~ c
17 /* ... */
18
19 /* Build time verification of mismatch between mainline TRACE_EVENT()
20 * arguments and LTTng adaptation layer LTTNG_TRACEPOINT_EVENT() arguments.
21 */
22 #include <trace/events/hello.h>
23
24 /* ... */
25 ~~~
26
27 The preferred, flexible way to include your module's mainline
28 tracepoint definition header is to put it in a specific directory
29 relative to your module's root, e.g., `tracepoints`, and include it
30 relative to your module's root directory in the LTTng custom probe's
31 source:
32
33 ~~~ c
34 #include <tracepoints/hello.h>
35 ~~~
36
37 You may then build LTTng-modules by adding your module's root
38 directory as an include path to the extra C flags:
39
40 <pre class="term">
41 make <strong>ccflags-y=-I/path/to/kernel/module</strong> KERNELDIR=/path/to/custom/linux
42 </pre>
43
44 Using `ccflags-y` allows you to move your kernel module to another
45 directory and rebuild the LTTng-modules project with no change to
46 source files.
This page took 0.028707 seconds and 3 git commands to generate.