Rename LTTng instrumentation macros
[lttng-modules.git] / instrumentation / events / lttng-module / module.h
1 /*
2 * Because linux/module.h has tracepoints in the header, and ftrace.h
3 * eventually includes this file, define_trace.h includes linux/module.h
4 * But we do not want the module.h to override the TRACE_SYSTEM macro
5 * variable that define_trace.h is processing, so we only set it
6 * when module events are being processed, which would happen when
7 * CREATE_TRACE_POINTS is defined.
8 */
9 #ifdef CREATE_TRACE_POINTS
10 #undef TRACE_SYSTEM
11 #define TRACE_SYSTEM module
12 #endif
13
14 #if !defined(LTTNG_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ)
15 #define LTTNG_TRACE_MODULE_H
16
17 #include "../../../probes/lttng-tracepoint-event.h"
18 #include <linux/version.h>
19
20 #ifdef CONFIG_MODULES
21
22 #ifndef _TRACE_MODULE_DEF
23 #define _TRACE_MODULE_DEF
24 struct module;
25
26 #endif
27
28 LTTNG_TRACEPOINT_EVENT(module_load,
29
30 TP_PROTO(struct module *mod),
31
32 TP_ARGS(mod),
33
34 TP_STRUCT__entry(
35 __field( unsigned int, taints )
36 __string( name, mod->name )
37 ),
38
39 TP_fast_assign(
40 tp_assign(taints, mod->taints)
41 tp_strcpy(name, mod->name)
42 ),
43
44 TP_printk("%s %s", __get_str(name), show_module_flags(__entry->taints))
45 )
46
47 LTTNG_TRACEPOINT_EVENT(module_free,
48
49 TP_PROTO(struct module *mod),
50
51 TP_ARGS(mod),
52
53 TP_STRUCT__entry(
54 __string( name, mod->name )
55 ),
56
57 TP_fast_assign(
58 tp_strcpy(name, mod->name)
59 ),
60
61 TP_printk("%s", __get_str(name))
62 )
63
64 #ifdef CONFIG_MODULE_UNLOAD
65 /* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */
66
67 LTTNG_TRACEPOINT_EVENT_CLASS(module_refcnt,
68
69 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
70 TP_PROTO(struct module *mod, unsigned long ip),
71
72 TP_ARGS(mod, ip),
73 #else
74 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
75
76 TP_ARGS(mod, ip, refcnt),
77 #endif
78
79 TP_STRUCT__entry(
80 __field( unsigned long, ip )
81 __field( int, refcnt )
82 __string( name, mod->name )
83 ),
84
85 TP_fast_assign(
86 tp_assign(ip, ip)
87 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
88 tp_assign(refcnt, __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs))
89 #else
90 tp_assign(refcnt, refcnt)
91 #endif
92 tp_strcpy(name, mod->name)
93 ),
94
95 TP_printk("%s call_site=%pf refcnt=%d",
96 __get_str(name), (void *)__entry->ip, __entry->refcnt)
97 )
98
99 LTTNG_TRACEPOINT_EVENT_INSTANCE(module_refcnt, module_get,
100
101 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
102 TP_PROTO(struct module *mod, unsigned long ip),
103
104 TP_ARGS(mod, ip)
105 #else
106 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
107
108 TP_ARGS(mod, ip, refcnt)
109 #endif
110 )
111
112 LTTNG_TRACEPOINT_EVENT_INSTANCE(module_refcnt, module_put,
113
114 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
115 TP_PROTO(struct module *mod, unsigned long ip),
116
117 TP_ARGS(mod, ip)
118 #else
119 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
120
121 TP_ARGS(mod, ip, refcnt)
122 #endif
123 )
124 #endif /* CONFIG_MODULE_UNLOAD */
125
126 LTTNG_TRACEPOINT_EVENT(module_request,
127
128 TP_PROTO(char *name, bool wait, unsigned long ip),
129
130 TP_ARGS(name, wait, ip),
131
132 TP_STRUCT__entry(
133 __field( unsigned long, ip )
134 __field( bool, wait )
135 __string( name, name )
136 ),
137
138 TP_fast_assign(
139 tp_assign(ip, ip)
140 tp_assign(wait, wait)
141 tp_strcpy(name, name)
142 ),
143
144 TP_printk("%s wait=%d call_site=%pf",
145 __get_str(name), (int)__entry->wait, (void *)__entry->ip)
146 )
147
148 #endif /* CONFIG_MODULES */
149
150 #endif /* LTTNG_TRACE_MODULE_H */
151
152 /* This part must be outside protection */
153 #include "../../../probes/define_trace.h"
This page took 0.036195 seconds and 4 git commands to generate.