Commit | Line | Data |
---|---|---|
b728d87e | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: MIT |
b728d87e | 3 | * |
c0c0989a | 4 | * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
b728d87e MD |
5 | */ |
6 | ||
c0c0989a MJ |
7 | #ifndef _LTTNG_TRACEPOINT_H |
8 | #define _LTTNG_TRACEPOINT_H | |
9 | ||
76aca78d MD |
10 | #include <stdio.h> |
11 | #include <stdlib.h> | |
8fce9e2b | 12 | #include <lttng/tracepoint-types.h> |
40b2b5a4 | 13 | #include <lttng/tracepoint-rcu.h> |
b728d87e | 14 | #include <urcu/compiler.h> |
c082d14b | 15 | #include <urcu/system.h> |
deb6e540 | 16 | #include <dlfcn.h> /* for dlopen */ |
51920067 | 17 | #include <string.h> /* for memset */ |
3d3dc207 | 18 | |
b2f60c79 | 19 | #include <lttng/ust-config.h> /* for sdt */ |
a8909ba5 | 20 | #include <lttng/ust-compiler.h> |
3d3dc207 | 21 | #include <lttng/ust-tracer.h> |
cbc06a3b | 22 | #include <lttng/ust-api-compat.h> |
b2f60c79 | 23 | |
81b16412 MD |
24 | #define LTTNG_UST_TRACEPOINT_NAME_LEN_MAX 256 |
25 | ||
b2f60c79 | 26 | #ifdef LTTNG_UST_HAVE_SDT_INTEGRATION |
23b75ae5 MJ |
27 | /* |
28 | * Instead of using SDT_USE_VARIADIC from 'sys/sdt.h', use our own namespaced | |
29 | * macros since the instrumented application might already have included | |
30 | * 'sys/sdt.h' without variadic support. | |
31 | */ | |
b2f60c79 | 32 | #include <sys/sdt.h> |
23b75ae5 | 33 | |
b88f9167 MD |
34 | #define _LTTNG_UST_SDT_NARG(...) \ |
35 | __LTTNG_UST_SDT_NARG(__VA_ARGS__, 12,11,10,9,8,7,6,5,4,3,2,1,0) | |
23b75ae5 | 36 | |
b88f9167 | 37 | #define __LTTNG_UST_SDT_NARG(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12, N, ...) N |
23b75ae5 | 38 | |
b88f9167 | 39 | #define _LTTNG_UST_SDT_PROBE_N(provider, name, N, ...) \ |
23b75ae5 MJ |
40 | _SDT_PROBE(provider, name, N, (__VA_ARGS__)) |
41 | ||
b88f9167 MD |
42 | #define LTTNG_UST_STAP_PROBEV(provider, name, ...) \ |
43 | _LTTNG_UST_SDT_PROBE_N(provider, name, _LTTNG_UST_SDT_NARG(0, ##__VA_ARGS__), ##__VA_ARGS__) | |
23b75ae5 | 44 | |
b2f60c79 | 45 | #else |
b88f9167 | 46 | #define LTTNG_UST_STAP_PROBEV(...) |
b2f60c79 | 47 | #endif |
b728d87e MD |
48 | |
49 | #ifdef __cplusplus | |
50 | extern "C" { | |
51 | #endif | |
52 | ||
cbc06a3b | 53 | #define lttng_ust_tracepoint_enabled(provider, name) \ |
c082d14b | 54 | caa_unlikely(CMM_LOAD_SHARED(__tracepoint_##provider##___##name.state)) |
8da6d0c8 | 55 | |
cbc06a3b | 56 | #define lttng_ust_do_tracepoint(provider, name, ...) \ |
8da6d0c8 DS |
57 | __tracepoint_cb_##provider##___##name(__VA_ARGS__) |
58 | ||
cbc06a3b MD |
59 | #define lttng_ust_tracepoint(provider, name, ...) \ |
60 | do { \ | |
61 | LTTNG_UST_STAP_PROBEV(provider, name, ## __VA_ARGS__); \ | |
62 | if (lttng_ust_tracepoint_enabled(provider, name)) \ | |
63 | lttng_ust_do_tracepoint(provider, name, __VA_ARGS__); \ | |
b728d87e MD |
64 | } while (0) |
65 | ||
cadfcbfc | 66 | #define LTTNG_UST_TP_ARGS(...) __VA_ARGS__ |
b728d87e MD |
67 | |
68 | /* | |
cadfcbfc | 69 | * LTTNG_UST_TP_ARGS takes tuples of type, argument separated by a comma. |
b728d87e MD |
70 | * It can take up to 10 tuples (which means that less than 10 tuples is |
71 | * fine too). | |
72 | * Each tuple is also separated by a comma. | |
73 | */ | |
df854e41 MD |
74 | #define __TP_COMBINE_TOKENS(_tokena, _tokenb) \ |
75 | _tokena##_tokenb | |
76 | #define _TP_COMBINE_TOKENS(_tokena, _tokenb) \ | |
77 | __TP_COMBINE_TOKENS(_tokena, _tokenb) | |
78 | #define __TP_COMBINE_TOKENS3(_tokena, _tokenb, _tokenc) \ | |
79 | _tokena##_tokenb##_tokenc | |
80 | #define _TP_COMBINE_TOKENS3(_tokena, _tokenb, _tokenc) \ | |
81 | __TP_COMBINE_TOKENS3(_tokena, _tokenb, _tokenc) | |
82 | #define __TP_COMBINE_TOKENS4(_tokena, _tokenb, _tokenc, _tokend) \ | |
83 | _tokena##_tokenb##_tokenc##_tokend | |
84 | #define _TP_COMBINE_TOKENS4(_tokena, _tokenb, _tokenc, _tokend) \ | |
85 | __TP_COMBINE_TOKENS4(_tokena, _tokenb, _tokenc, _tokend) | |
b728d87e | 86 | |
4495dd39 MD |
87 | /* |
88 | * _TP_EXVAR* extract the var names. | |
89 | * _TP_EXVAR1 and _TP_EXDATA_VAR1 are needed for -std=c99. | |
90 | */ | |
b728d87e | 91 | #define _TP_EXVAR0() |
4495dd39 | 92 | #define _TP_EXVAR1(a) |
b728d87e MD |
93 | #define _TP_EXVAR2(a,b) b |
94 | #define _TP_EXVAR4(a,b,c,d) b,d | |
95 | #define _TP_EXVAR6(a,b,c,d,e,f) b,d,f | |
96 | #define _TP_EXVAR8(a,b,c,d,e,f,g,h) b,d,f,h | |
97 | #define _TP_EXVAR10(a,b,c,d,e,f,g,h,i,j) b,d,f,h,j | |
98 | #define _TP_EXVAR12(a,b,c,d,e,f,g,h,i,j,k,l) b,d,f,h,j,l | |
99 | #define _TP_EXVAR14(a,b,c,d,e,f,g,h,i,j,k,l,m,n) b,d,f,h,j,l,n | |
100 | #define _TP_EXVAR16(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) b,d,f,h,j,l,n,p | |
101 | #define _TP_EXVAR18(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) b,d,f,h,j,l,n,p,r | |
102 | #define _TP_EXVAR20(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) b,d,f,h,j,l,n,p,r,t | |
103 | ||
104 | #define _TP_EXDATA_VAR0() __tp_data | |
4495dd39 | 105 | #define _TP_EXDATA_VAR1(a) __tp_data |
b728d87e MD |
106 | #define _TP_EXDATA_VAR2(a,b) __tp_data,b |
107 | #define _TP_EXDATA_VAR4(a,b,c,d) __tp_data,b,d | |
108 | #define _TP_EXDATA_VAR6(a,b,c,d,e,f) __tp_data,b,d,f | |
109 | #define _TP_EXDATA_VAR8(a,b,c,d,e,f,g,h) __tp_data,b,d,f,h | |
110 | #define _TP_EXDATA_VAR10(a,b,c,d,e,f,g,h,i,j) __tp_data,b,d,f,h,j | |
111 | #define _TP_EXDATA_VAR12(a,b,c,d,e,f,g,h,i,j,k,l) __tp_data,b,d,f,h,j,l | |
112 | #define _TP_EXDATA_VAR14(a,b,c,d,e,f,g,h,i,j,k,l,m,n) __tp_data,b,d,f,h,j,l,n | |
113 | #define _TP_EXDATA_VAR16(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) __tp_data,b,d,f,h,j,l,n,p | |
114 | #define _TP_EXDATA_VAR18(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) __tp_data,b,d,f,h,j,l,n,p,r | |
115 | #define _TP_EXDATA_VAR20(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) __tp_data,b,d,f,h,j,l,n,p,r,t | |
116 | ||
4495dd39 MD |
117 | /* |
118 | * _TP_EXPROTO* extract tuples of type, var. | |
119 | * _TP_EXPROTO1 and _TP_EXDATA_PROTO1 are needed for -std=c99. | |
120 | */ | |
86637aa6 | 121 | #define _TP_EXPROTO0() void |
4495dd39 | 122 | #define _TP_EXPROTO1(a) void |
b728d87e MD |
123 | #define _TP_EXPROTO2(a,b) a b |
124 | #define _TP_EXPROTO4(a,b,c,d) a b,c d | |
125 | #define _TP_EXPROTO6(a,b,c,d,e,f) a b,c d,e f | |
126 | #define _TP_EXPROTO8(a,b,c,d,e,f,g,h) a b,c d,e f,g h | |
127 | #define _TP_EXPROTO10(a,b,c,d,e,f,g,h,i,j) a b,c d,e f,g h,i j | |
128 | #define _TP_EXPROTO12(a,b,c,d,e,f,g,h,i,j,k,l) a b,c d,e f,g h,i j,k l | |
129 | #define _TP_EXPROTO14(a,b,c,d,e,f,g,h,i,j,k,l,m,n) a b,c d,e f,g h,i j,k l,m n | |
130 | #define _TP_EXPROTO16(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) a b,c d,e f,g h,i j,k l,m n,o p | |
131 | #define _TP_EXPROTO18(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) a b,c d,e f,g h,i j,k l,m n,o p,q r | |
132 | #define _TP_EXPROTO20(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) a b,c d,e f,g h,i j,k l,m n,o p,q r,s t | |
133 | ||
134 | #define _TP_EXDATA_PROTO0() void *__tp_data | |
4495dd39 | 135 | #define _TP_EXDATA_PROTO1(a) void *__tp_data |
b728d87e MD |
136 | #define _TP_EXDATA_PROTO2(a,b) void *__tp_data,a b |
137 | #define _TP_EXDATA_PROTO4(a,b,c,d) void *__tp_data,a b,c d | |
138 | #define _TP_EXDATA_PROTO6(a,b,c,d,e,f) void *__tp_data,a b,c d,e f | |
139 | #define _TP_EXDATA_PROTO8(a,b,c,d,e,f,g,h) void *__tp_data,a b,c d,e f,g h | |
140 | #define _TP_EXDATA_PROTO10(a,b,c,d,e,f,g,h,i,j) void *__tp_data,a b,c d,e f,g h,i j | |
141 | #define _TP_EXDATA_PROTO12(a,b,c,d,e,f,g,h,i,j,k,l) void *__tp_data,a b,c d,e f,g h,i j,k l | |
142 | #define _TP_EXDATA_PROTO14(a,b,c,d,e,f,g,h,i,j,k,l,m,n) void *__tp_data,a b,c d,e f,g h,i j,k l,m n | |
143 | #define _TP_EXDATA_PROTO16(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) void *__tp_data,a b,c d,e f,g h,i j,k l,m n,o p | |
144 | #define _TP_EXDATA_PROTO18(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) void *__tp_data,a b,c d,e f,g h,i j,k l,m n,o p,q r | |
145 | #define _TP_EXDATA_PROTO20(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) void *__tp_data,a b,c d,e f,g h,i j,k l,m n,o p,q r,s t | |
146 | ||
147 | /* Preprocessor trick to count arguments. Inspired from sdt.h. */ | |
148 | #define _TP_NARGS(...) __TP_NARGS(__VA_ARGS__, 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0) | |
149 | #define __TP_NARGS(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20, N, ...) N | |
23c8854a MD |
150 | #define _TP_PROTO_N(N, ...) _TP_PARAMS(_TP_COMBINE_TOKENS(_TP_EXPROTO, N)(__VA_ARGS__)) |
151 | #define _TP_VAR_N(N, ...) _TP_PARAMS(_TP_COMBINE_TOKENS(_TP_EXVAR, N)(__VA_ARGS__)) | |
152 | #define _TP_DATA_PROTO_N(N, ...) _TP_PARAMS(_TP_COMBINE_TOKENS(_TP_EXDATA_PROTO, N)(__VA_ARGS__)) | |
153 | #define _TP_DATA_VAR_N(N, ...) _TP_PARAMS(_TP_COMBINE_TOKENS(_TP_EXDATA_VAR, N)(__VA_ARGS__)) | |
b728d87e | 154 | #define _TP_ARGS_PROTO(...) _TP_PROTO_N(_TP_NARGS(0, ##__VA_ARGS__), ##__VA_ARGS__) |
23c8854a | 155 | #define _TP_ARGS_VAR(...) _TP_VAR_N(_TP_NARGS(0, ##__VA_ARGS__), ##__VA_ARGS__) |
b728d87e | 156 | #define _TP_ARGS_DATA_PROTO(...) _TP_DATA_PROTO_N(_TP_NARGS(0, ##__VA_ARGS__), ##__VA_ARGS__) |
23c8854a | 157 | #define _TP_ARGS_DATA_VAR(...) _TP_DATA_VAR_N(_TP_NARGS(0, ##__VA_ARGS__), ##__VA_ARGS__) |
b728d87e MD |
158 | #define _TP_PARAMS(...) __VA_ARGS__ |
159 | ||
81b16412 MD |
160 | /* |
161 | * sizeof(#_provider) - 1 : length of the provider string (excluding \0). | |
162 | * sizeof(#_name) - 1 : length of the name string (excluding \0). | |
163 | * + 1 : separator between provider and event name. | |
164 | * | |
165 | * Upper bound (inclusive) is LTTNG_UST_TRACEPOINT_NAME_LEN_MAX - 1 to | |
166 | * account for \0. | |
167 | * | |
168 | * The comparison is: | |
169 | * left hand side: sizeof(#_provider) - 1 + sizeof(#_name) - 1 + 1 | |
170 | * right hand side: LTTNG_UST_TRACEPOINT_NAME_LEN_MAX - 1 | |
171 | * operator: <= (inclusive) | |
172 | * Simplified in the code below. | |
173 | */ | |
174 | #define lttng_ust_tracepoint_validate_name_len(_provider, _name) \ | |
175 | lttng_ust_static_assert(sizeof(#_provider) + sizeof(#_name) <= LTTNG_UST_TRACEPOINT_NAME_LEN_MAX, \ | |
176 | "Tracepoint name length is too long", \ | |
177 | Tracepoint_name_length_is_too_long) | |
178 | ||
96f85541 MD |
179 | /* |
180 | * The tracepoint cb is marked always inline so we can distinguish | |
181 | * between caller's ip addresses within the probe using the return | |
182 | * address. | |
183 | */ | |
7f2f82c3 | 184 | #define LTTNG_UST__DECLARE_TRACEPOINT(_provider, _name, ...) \ |
1a206094 | 185 | extern struct lttng_ust_tracepoint __tracepoint_##_provider##___##_name; \ |
8da9deee MJ |
186 | static inline \ |
187 | void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) \ | |
188 | __attribute__((always_inline, unused)) lttng_ust_notrace; \ | |
96f85541 | 189 | static \ |
a8909ba5 | 190 | void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) \ |
b728d87e | 191 | { \ |
10544ee8 | 192 | struct lttng_ust_tracepoint_probe *__tp_probe; \ |
b728d87e | 193 | \ |
d3db6a40 | 194 | if (caa_unlikely(!TP_RCU_LINK_TEST())) \ |
deb6e540 | 195 | return; \ |
10544ee8 MD |
196 | tp_rcu_read_lock(); \ |
197 | __tp_probe = tp_rcu_dereference(__tracepoint_##_provider##___##_name.probes); \ | |
23c8854a | 198 | if (caa_unlikely(!__tp_probe)) \ |
b728d87e MD |
199 | goto end; \ |
200 | do { \ | |
1a206094 | 201 | void (*__tp_cb)(void) = __tp_probe->func; \ |
23c8854a | 202 | void *__tp_data = __tp_probe->data; \ |
b728d87e | 203 | \ |
23c8854a MD |
204 | URCU_FORCE_CAST(void (*)(_TP_ARGS_DATA_PROTO(__VA_ARGS__)), __tp_cb) \ |
205 | (_TP_ARGS_DATA_VAR(__VA_ARGS__)); \ | |
206 | } while ((++__tp_probe)->func); \ | |
b728d87e | 207 | end: \ |
10544ee8 | 208 | tp_rcu_read_unlock(); \ |
b728d87e | 209 | } \ |
106ff4da | 210 | static inline \ |
34f7f142 | 211 | void __tracepoint_register_##_provider##___##_name(char *provider_name, char *event_name, \ |
106ff4da MJ |
212 | void (*func)(void), void *data) \ |
213 | lttng_ust_notrace; \ | |
a8909ba5 | 214 | static inline \ |
34f7f142 | 215 | void __tracepoint_register_##_provider##___##_name(char *provider_name, char *event_name, \ |
a8909ba5 | 216 | void (*func)(void), void *data) \ |
b728d87e | 217 | { \ |
34f7f142 | 218 | __tracepoint_probe_register(provider_name, event_name, func, data, \ |
67e5f391 | 219 | __tracepoint_##_provider##___##_name.signature); \ |
b728d87e | 220 | } \ |
106ff4da | 221 | static inline \ |
34f7f142 | 222 | void __tracepoint_unregister_##_provider##___##_name(char *provider_name, char *event_name, \ |
106ff4da MJ |
223 | void (*func)(void), void *data) \ |
224 | lttng_ust_notrace; \ | |
a8909ba5 | 225 | static inline \ |
34f7f142 | 226 | void __tracepoint_unregister_##_provider##___##_name(char *provider_name, char *event_name, \ |
a8909ba5 | 227 | void (*func)(void), void *data) \ |
b728d87e | 228 | { \ |
34f7f142 | 229 | __tracepoint_probe_unregister(provider_name, event_name, func, data); \ |
b728d87e MD |
230 | } |
231 | ||
34f7f142 MD |
232 | extern int __tracepoint_probe_register(const char *provider_name, const char *event_name, |
233 | void (*func)(void), void *data, const char *signature); | |
234 | extern int __tracepoint_probe_unregister(const char *provider_name, const char *event_name, | |
235 | void (*func)(void), void *data); | |
deb6e540 | 236 | |
51920067 MD |
237 | /* |
238 | * tracepoint dynamic linkage handling (callbacks). Hidden visibility: | |
239 | * shared across objects in a module/main executable. | |
f641d544 MD |
240 | * |
241 | * IMPORTANT: this structure is part of the ABI between instrumented | |
242 | * applications and UST. Fields need to be only added at the end, never | |
243 | * reordered, never removed. | |
244 | * | |
245 | * The field @struct_size should be used to determine the size of the | |
246 | * structure. It should be queried before using additional fields added | |
247 | * at the end of the structure. | |
51920067 | 248 | */ |
1a206094 | 249 | struct lttng_ust_tracepoint_dlopen { |
f641d544 MD |
250 | uint32_t struct_size; |
251 | ||
51920067 MD |
252 | void *liblttngust_handle; |
253 | ||
1a206094 | 254 | int (*tracepoint_register_lib)(struct lttng_ust_tracepoint * const *tracepoints_start, |
51920067 | 255 | int tracepoints_count); |
1a206094 | 256 | int (*tracepoint_unregister_lib)(struct lttng_ust_tracepoint * const *tracepoints_start); |
10544ee8 MD |
257 | void (*rcu_read_lock_sym)(void); |
258 | void (*rcu_read_unlock_sym)(void); | |
259 | void *(*rcu_dereference_sym)(void *p); | |
f641d544 MD |
260 | |
261 | /* End of base ABI. Fields below should be used after checking struct_size. */ | |
51920067 MD |
262 | }; |
263 | ||
7863d51a MJ |
264 | extern struct lttng_ust_tracepoint_dlopen lttng_ust_tracepoint_dlopen; |
265 | extern struct lttng_ust_tracepoint_dlopen *lttng_ust_tracepoint_dlopen_ptr; | |
51920067 | 266 | |
46c881a7 MD |
267 | /* |
268 | * These weak symbols, the constructor, and destructor take care of | |
269 | * registering only _one_ instance of the tracepoints per shared-ojbect | |
270 | * (or for the whole main program). | |
271 | */ | |
272 | int __tracepoint_registered | |
273 | __attribute__((weak, visibility("hidden"))); | |
274 | int __tracepoint_ptrs_registered | |
275 | __attribute__((weak, visibility("hidden"))); | |
7863d51a | 276 | struct lttng_ust_tracepoint_dlopen lttng_ust_tracepoint_dlopen |
f641d544 MD |
277 | __attribute__((weak, visibility("hidden"))) = { |
278 | .struct_size = sizeof(struct lttng_ust_tracepoint_dlopen), | |
279 | }; | |
9443a022 MD |
280 | /* |
281 | * Deal with gcc O1 optimisation issues with weak hidden symbols. gcc | |
282 | * 4.8 and prior does not have the same behavior for symbol scoping on | |
283 | * 32-bit powerpc depending on the object size: symbols for objects of 8 | |
284 | * bytes or less have the same address throughout a module, whereas they | |
285 | * have different addresses between compile units for objects larger | |
286 | * than 8 bytes. Add this pointer indirection to ensure that the symbol | |
287 | * scoping match that of the other weak hidden symbols found in this | |
288 | * header. | |
289 | */ | |
7863d51a | 290 | struct lttng_ust_tracepoint_dlopen *lttng_ust_tracepoint_dlopen_ptr |
9443a022 | 291 | __attribute__((weak, visibility("hidden"))); |
46c881a7 | 292 | |
0fd0de10 FD |
293 | /* |
294 | * Tracepoint dynamic linkage handling (callbacks). Hidden visibility: shared | |
295 | * across objects in a module/main executable. The callbacks are used to | |
296 | * control and check if the destructors should be executed. | |
f641d544 MD |
297 | * |
298 | * IMPORTANT: this structure is part of the ABI between instrumented | |
299 | * applications and UST. Fields need to be only added at the end, never | |
300 | * reordered, never removed. | |
301 | * | |
302 | * The field @struct_size should be used to determine the size of the | |
303 | * structure. It should be queried before using additional fields added | |
304 | * at the end of the structure. | |
0fd0de10 FD |
305 | */ |
306 | struct lttng_ust_tracepoint_destructors_syms { | |
f641d544 MD |
307 | uint32_t struct_size; |
308 | ||
0fd0de10 FD |
309 | void (*tracepoint_disable_destructors)(void); |
310 | int (*tracepoint_get_destructors_state)(void); | |
f641d544 MD |
311 | |
312 | /* End of base ABI. Fields below should be used after checking struct_size. */ | |
0fd0de10 FD |
313 | }; |
314 | ||
315 | extern struct lttng_ust_tracepoint_destructors_syms tracepoint_destructors_syms; | |
316 | extern struct lttng_ust_tracepoint_destructors_syms *tracepoint_destructors_syms_ptr; | |
317 | ||
318 | struct lttng_ust_tracepoint_destructors_syms tracepoint_destructors_syms | |
f641d544 MD |
319 | __attribute__((weak, visibility("hidden"))) = { |
320 | .struct_size = sizeof(struct lttng_ust_tracepoint_destructors_syms), | |
321 | }; | |
0fd0de10 FD |
322 | struct lttng_ust_tracepoint_destructors_syms *tracepoint_destructors_syms_ptr |
323 | __attribute__((weak, visibility("hidden"))); | |
324 | ||
325 | static inline void tracepoint_disable_destructors(void) | |
326 | { | |
7863d51a MJ |
327 | if (!lttng_ust_tracepoint_dlopen_ptr) |
328 | lttng_ust_tracepoint_dlopen_ptr = <tng_ust_tracepoint_dlopen; | |
0fd0de10 FD |
329 | if (!tracepoint_destructors_syms_ptr) |
330 | tracepoint_destructors_syms_ptr = &tracepoint_destructors_syms; | |
7863d51a | 331 | if (lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle |
0fd0de10 FD |
332 | && tracepoint_destructors_syms_ptr->tracepoint_disable_destructors) |
333 | tracepoint_destructors_syms_ptr->tracepoint_disable_destructors(); | |
0fd0de10 FD |
334 | } |
335 | ||
99234da6 | 336 | #ifndef _LGPL_SOURCE |
106ff4da MJ |
337 | static inline void |
338 | __tracepoint__init_urcu_sym(void) | |
339 | lttng_ust_notrace; | |
99234da6 MD |
340 | static inline void |
341 | __tracepoint__init_urcu_sym(void) | |
342 | { | |
7863d51a MJ |
343 | if (!lttng_ust_tracepoint_dlopen_ptr) |
344 | lttng_ust_tracepoint_dlopen_ptr = <tng_ust_tracepoint_dlopen; | |
99234da6 MD |
345 | /* |
346 | * Symbols below are needed by tracepoint call sites and probe | |
347 | * providers. | |
348 | */ | |
7863d51a MJ |
349 | if (!lttng_ust_tracepoint_dlopen_ptr->rcu_read_lock_sym) |
350 | lttng_ust_tracepoint_dlopen_ptr->rcu_read_lock_sym = | |
99234da6 | 351 | URCU_FORCE_CAST(void (*)(void), |
7863d51a | 352 | dlsym(lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle, |
10544ee8 | 353 | "tp_rcu_read_lock")); |
7863d51a MJ |
354 | if (!lttng_ust_tracepoint_dlopen_ptr->rcu_read_unlock_sym) |
355 | lttng_ust_tracepoint_dlopen_ptr->rcu_read_unlock_sym = | |
99234da6 | 356 | URCU_FORCE_CAST(void (*)(void), |
7863d51a | 357 | dlsym(lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle, |
10544ee8 | 358 | "tp_rcu_read_unlock")); |
7863d51a MJ |
359 | if (!lttng_ust_tracepoint_dlopen_ptr->rcu_dereference_sym) |
360 | lttng_ust_tracepoint_dlopen_ptr->rcu_dereference_sym = | |
99234da6 | 361 | URCU_FORCE_CAST(void *(*)(void *p), |
7863d51a | 362 | dlsym(lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle, |
10544ee8 | 363 | "tp_rcu_dereference_sym")); |
99234da6 MD |
364 | } |
365 | #else | |
106ff4da MJ |
366 | static inline void |
367 | __tracepoint__init_urcu_sym(void) | |
368 | lttng_ust_notrace; | |
99234da6 MD |
369 | static inline void |
370 | __tracepoint__init_urcu_sym(void) | |
371 | { | |
372 | } | |
373 | #endif | |
374 | ||
465a0d04 MJ |
375 | static void |
376 | __tracepoints__init(void) | |
377 | lttng_ust_notrace __attribute__((constructor)); | |
46c881a7 MD |
378 | static void |
379 | __tracepoints__init(void) | |
380 | { | |
8f0d1c78 | 381 | if (__tracepoint_registered++) { |
7863d51a | 382 | if (!lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle) |
8f0d1c78 MD |
383 | return; |
384 | __tracepoint__init_urcu_sym(); | |
46c881a7 | 385 | return; |
8f0d1c78 | 386 | } |
46c881a7 | 387 | |
7863d51a MJ |
388 | if (!lttng_ust_tracepoint_dlopen_ptr) |
389 | lttng_ust_tracepoint_dlopen_ptr = <tng_ust_tracepoint_dlopen; | |
390 | if (!lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle) | |
391 | lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle = | |
3d3dc207 | 392 | dlopen(LTTNG_UST_TRACEPOINT_LIB_SONAME, RTLD_NOW | RTLD_GLOBAL); |
7863d51a | 393 | if (!lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle) |
46c881a7 | 394 | return; |
99234da6 | 395 | __tracepoint__init_urcu_sym(); |
46c881a7 MD |
396 | } |
397 | ||
c589eca2 MJ |
398 | static void |
399 | __tracepoints__destroy(void) | |
400 | lttng_ust_notrace __attribute__((destructor)); | |
46c881a7 MD |
401 | static void |
402 | __tracepoints__destroy(void) | |
403 | { | |
404 | int ret; | |
405 | ||
406 | if (--__tracepoint_registered) | |
407 | return; | |
7863d51a MJ |
408 | if (!lttng_ust_tracepoint_dlopen_ptr) |
409 | lttng_ust_tracepoint_dlopen_ptr = <tng_ust_tracepoint_dlopen; | |
0fd0de10 FD |
410 | if (!tracepoint_destructors_syms_ptr) |
411 | tracepoint_destructors_syms_ptr = &tracepoint_destructors_syms; | |
7863d51a | 412 | if (!lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle) |
0fd0de10 FD |
413 | return; |
414 | if (__tracepoint_ptrs_registered) | |
415 | return; | |
416 | /* | |
417 | * Lookup if destructors must be executed using the new method. | |
418 | */ | |
419 | if (tracepoint_destructors_syms_ptr->tracepoint_get_destructors_state | |
420 | && !tracepoint_destructors_syms_ptr->tracepoint_get_destructors_state()) { | |
421 | /* | |
422 | * The tracepoint_get_destructors_state symbol was found with | |
423 | * dlsym but its returned value is 0 meaning that destructors | |
424 | * must not be executed. | |
425 | */ | |
426 | return; | |
427 | } | |
7863d51a | 428 | ret = dlclose(lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle); |
0fd0de10 FD |
429 | if (ret) { |
430 | fprintf(stderr, "Error (%d) in dlclose\n", ret); | |
431 | abort(); | |
432 | } | |
7863d51a | 433 | memset(lttng_ust_tracepoint_dlopen_ptr, 0, sizeof(*lttng_ust_tracepoint_dlopen_ptr)); |
46c881a7 MD |
434 | } |
435 | ||
deb6e540 MD |
436 | #ifdef TRACEPOINT_DEFINE |
437 | ||
558b9d86 MD |
438 | /* |
439 | * These weak symbols, the constructor, and destructor take care of | |
440 | * registering only _one_ instance of the tracepoints per shared-ojbect | |
441 | * (or for the whole main program). | |
442 | */ | |
1a206094 | 443 | extern struct lttng_ust_tracepoint * const __start___tracepoints_ptrs[] |
558b9d86 | 444 | __attribute__((weak, visibility("hidden"))); |
1a206094 | 445 | extern struct lttng_ust_tracepoint * const __stop___tracepoints_ptrs[] |
558b9d86 MD |
446 | __attribute__((weak, visibility("hidden"))); |
447 | ||
628e1d81 MD |
448 | /* |
449 | * When TRACEPOINT_PROBE_DYNAMIC_LINKAGE is defined, we do not emit a | |
450 | * unresolved symbol that requires the provider to be linked in. When | |
451 | * TRACEPOINT_PROBE_DYNAMIC_LINKAGE is not defined, we emit an | |
452 | * unresolved symbol that depends on having the provider linked in, | |
453 | * otherwise the linker complains. This deals with use of static | |
454 | * libraries, ensuring that the linker does not remove the provider | |
455 | * object from the executable. | |
456 | */ | |
457 | #ifdef TRACEPOINT_PROBE_DYNAMIC_LINKAGE | |
b4f3bc52 | 458 | #define _TRACEPOINT_UNDEFINED_REF(provider) NULL |
628e1d81 | 459 | #else /* TRACEPOINT_PROBE_DYNAMIC_LINKAGE */ |
b4f3bc52 | 460 | #define _TRACEPOINT_UNDEFINED_REF(provider) &__tracepoint_provider_##provider |
628e1d81 MD |
461 | #endif /* TRACEPOINT_PROBE_DYNAMIC_LINKAGE */ |
462 | ||
b728d87e MD |
463 | /* |
464 | * Note: to allow PIC code, we need to allow the linker to update the pointers | |
465 | * in the __tracepoints_ptrs section. | |
466 | * Therefore, this section is _not_ const (read-only). | |
467 | */ | |
b4f3bc52 MD |
468 | #define _TP_EXTRACT_STRING(...) #__VA_ARGS__ |
469 | ||
7f2f82c3 | 470 | #define LTTNG_UST__DEFINE_TRACEPOINT(_provider, _name, _args) \ |
81b16412 | 471 | lttng_ust_tracepoint_validate_name_len(_provider, _name); \ |
b4f3bc52 | 472 | extern int __tracepoint_provider_##_provider; \ |
34f7f142 | 473 | static const char __tp_provider_strtab_##_provider##___##_name[] \ |
b728d87e | 474 | __attribute__((section("__tracepoints_strings"))) = \ |
34f7f142 MD |
475 | #_provider; \ |
476 | static const char __tp_name_strtab_##_provider##___##_name[] \ | |
477 | __attribute__((section("__tracepoints_strings"))) = \ | |
478 | #_name; \ | |
1a206094 | 479 | struct lttng_ust_tracepoint __tracepoint_##_provider##___##_name \ |
f641d544 MD |
480 | __attribute__((section("__tracepoints"))) = { \ |
481 | sizeof(struct lttng_ust_tracepoint), \ | |
34f7f142 MD |
482 | __tp_provider_strtab_##_provider##___##_name, \ |
483 | __tp_name_strtab_##_provider##___##_name, \ | |
b4f3bc52 MD |
484 | 0, \ |
485 | NULL, \ | |
486 | _TRACEPOINT_UNDEFINED_REF(_provider), \ | |
487 | _TP_EXTRACT_STRING(_args), \ | |
488 | }; \ | |
1a206094 SM |
489 | static struct lttng_ust_tracepoint * \ |
490 | __tracepoint_ptr_##_provider##___##_name \ | |
4f74bc5e MD |
491 | __attribute__((section("__tracepoints_ptrs"), used)) \ |
492 | __lttng_ust_variable_attribute_no_sanitize_address = \ | |
b4f3bc52 | 493 | &__tracepoint_##_provider##___##_name; |
b728d87e | 494 | |
465a0d04 MJ |
495 | static void |
496 | __tracepoints__ptrs_init(void) | |
497 | lttng_ust_notrace __attribute__((constructor)); | |
a8909ba5 | 498 | static void |
46c881a7 | 499 | __tracepoints__ptrs_init(void) |
b728d87e | 500 | { |
46c881a7 | 501 | if (__tracepoint_ptrs_registered++) |
b728d87e | 502 | return; |
7863d51a MJ |
503 | if (!lttng_ust_tracepoint_dlopen_ptr) |
504 | lttng_ust_tracepoint_dlopen_ptr = <tng_ust_tracepoint_dlopen; | |
505 | if (!lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle) | |
506 | lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle = | |
3d3dc207 | 507 | dlopen(LTTNG_UST_TRACEPOINT_LIB_SONAME, RTLD_NOW | RTLD_GLOBAL); |
7863d51a | 508 | if (!lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle) |
deb6e540 | 509 | return; |
0fd0de10 FD |
510 | if (!tracepoint_destructors_syms_ptr) |
511 | tracepoint_destructors_syms_ptr = &tracepoint_destructors_syms; | |
7863d51a | 512 | lttng_ust_tracepoint_dlopen_ptr->tracepoint_register_lib = |
1a206094 | 513 | URCU_FORCE_CAST(int (*)(struct lttng_ust_tracepoint * const *, int), |
7863d51a | 514 | dlsym(lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle, |
ae14f822 | 515 | "tracepoint_register_lib")); |
7863d51a | 516 | lttng_ust_tracepoint_dlopen_ptr->tracepoint_unregister_lib = |
1a206094 | 517 | URCU_FORCE_CAST(int (*)(struct lttng_ust_tracepoint * const *), |
7863d51a | 518 | dlsym(lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle, |
ae14f822 | 519 | "tracepoint_unregister_lib")); |
0fd0de10 FD |
520 | tracepoint_destructors_syms_ptr->tracepoint_disable_destructors = |
521 | URCU_FORCE_CAST(void (*)(void), | |
7863d51a | 522 | dlsym(lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle, |
0fd0de10 FD |
523 | "tp_disable_destructors")); |
524 | tracepoint_destructors_syms_ptr->tracepoint_get_destructors_state = | |
525 | URCU_FORCE_CAST(int (*)(void), | |
7863d51a | 526 | dlsym(lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle, |
0fd0de10 | 527 | "tp_get_destructors_state")); |
99234da6 | 528 | __tracepoint__init_urcu_sym(); |
7863d51a MJ |
529 | if (lttng_ust_tracepoint_dlopen_ptr->tracepoint_register_lib) { |
530 | lttng_ust_tracepoint_dlopen_ptr->tracepoint_register_lib(__start___tracepoints_ptrs, | |
46c881a7 MD |
531 | __stop___tracepoints_ptrs - |
532 | __start___tracepoints_ptrs); | |
99234da6 | 533 | } |
b728d87e MD |
534 | } |
535 | ||
c589eca2 MJ |
536 | static void |
537 | __tracepoints__ptrs_destroy(void) | |
538 | lttng_ust_notrace __attribute__((destructor)); | |
a8909ba5 | 539 | static void |
46c881a7 | 540 | __tracepoints__ptrs_destroy(void) |
b728d87e | 541 | { |
deb6e540 | 542 | int ret; |
51920067 | 543 | |
46c881a7 | 544 | if (--__tracepoint_ptrs_registered) |
b728d87e | 545 | return; |
7863d51a MJ |
546 | if (!lttng_ust_tracepoint_dlopen_ptr) |
547 | lttng_ust_tracepoint_dlopen_ptr = <tng_ust_tracepoint_dlopen; | |
0fd0de10 FD |
548 | if (!tracepoint_destructors_syms_ptr) |
549 | tracepoint_destructors_syms_ptr = &tracepoint_destructors_syms; | |
7863d51a MJ |
550 | if (lttng_ust_tracepoint_dlopen_ptr->tracepoint_unregister_lib) |
551 | lttng_ust_tracepoint_dlopen_ptr->tracepoint_unregister_lib(__start___tracepoints_ptrs); | |
552 | if (lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle | |
0fd0de10 FD |
553 | && tracepoint_destructors_syms_ptr->tracepoint_get_destructors_state |
554 | && tracepoint_destructors_syms_ptr->tracepoint_get_destructors_state() | |
664ccf24 | 555 | && !__tracepoint_ptrs_registered) { |
7863d51a | 556 | ret = dlclose(lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle); |
76aca78d MD |
557 | if (ret) { |
558 | fprintf(stderr, "Error (%d) in dlclose\n", ret); | |
559 | abort(); | |
560 | } | |
7863d51a | 561 | memset(lttng_ust_tracepoint_dlopen_ptr, 0, sizeof(*lttng_ust_tracepoint_dlopen_ptr)); |
deb6e540 | 562 | } |
b728d87e MD |
563 | } |
564 | ||
46c881a7 MD |
565 | #else /* TRACEPOINT_DEFINE */ |
566 | ||
7f2f82c3 | 567 | #define LTTNG_UST__DEFINE_TRACEPOINT(_provider, _name, _args) |
46c881a7 MD |
568 | |
569 | #endif /* #else TRACEPOINT_DEFINE */ | |
deb6e540 | 570 | |
cbc06a3b MD |
571 | #if LTTNG_UST_COMPAT_API(0) |
572 | #define tracepoint lttng_ust_tracepoint | |
573 | #define do_tracepoint lttng_ust_do_tracepoint | |
574 | #define tracepoint_enabled lttng_ust_tracepoint_enabled | |
cadfcbfc | 575 | #define TP_ARGS LTTNG_UST_TP_ARGS |
efa14d16 | 576 | #define TP_FIELDS LTTNG_UST_TP_FIELDS |
cbc06a3b MD |
577 | #endif /* #if LTTNG_UST_COMPAT_API(0) */ |
578 | ||
b728d87e MD |
579 | #ifdef __cplusplus |
580 | } | |
581 | #endif | |
582 | ||
583 | #endif /* _LTTNG_TRACEPOINT_H */ | |
584 | ||
585 | /* The following declarations must be outside re-inclusion protection. */ | |
586 | ||
c785c634 MD |
587 | #ifndef TRACEPOINT_ENUM |
588 | ||
589 | /* | |
590 | * Tracepoint Enumerations | |
591 | * | |
592 | * The enumeration is a mapping between an integer, or range of integers, and | |
593 | * a string. It can be used to have a more compact trace in cases where the | |
594 | * possible values for a field are limited: | |
595 | * | |
596 | * An example: | |
597 | * | |
598 | * TRACEPOINT_ENUM(someproject_component, enumname, | |
599 | * TP_ENUM_VALUES( | |
600 | * ctf_enum_value("even", 0) | |
601 | * ctf_enum_value("uneven", 1) | |
602 | * ctf_enum_range("twoto4", 2, 4) | |
603 | * ctf_enum_value("five", 5) | |
604 | * ) | |
605 | * ) | |
606 | * | |
607 | * Where "someproject_component" is the name of the component this enumeration | |
608 | * belongs to and "enumname" identifies this enumeration. Inside the | |
609 | * TP_ENUM_VALUES macro is the actual mapping. Each string value can map | |
610 | * to either a single value with ctf_enum_value or a range of values | |
611 | * with ctf_enum_range. | |
612 | * | |
613 | * Enumeration ranges may overlap, but the behavior is implementation-defined, | |
614 | * each trace reader will handle overlapping as it wishes. | |
615 | * | |
616 | * That enumeration can then be used in a field inside the TP_FIELD macro using | |
617 | * the following line: | |
618 | * | |
619 | * ctf_enum(someproject_component, enumname, enumtype, enumfield, enumval) | |
620 | * | |
621 | * Where "someproject_component" and "enumname" match those in the | |
622 | * TRACEPOINT_ENUM, "enumtype" is a signed or unsigned integer type | |
623 | * backing the enumeration, "enumfield" is the name of the field and | |
624 | * "enumval" is the value. | |
625 | */ | |
626 | ||
627 | #define TRACEPOINT_ENUM(provider, name, values) | |
628 | ||
629 | #endif /* #ifndef TRACEPOINT_ENUM */ | |
630 | ||
7f2f82c3 | 631 | #ifndef LTTNG_UST_TRACEPOINT_EVENT |
b728d87e MD |
632 | |
633 | /* | |
7f2f82c3 | 634 | * How to use the LTTNG_UST_TRACEPOINT_EVENT macro: |
b728d87e MD |
635 | * |
636 | * An example: | |
a60af3a5 | 637 | * |
7f2f82c3 | 638 | * LTTNG_UST_TRACEPOINT_EVENT(someproject_component, event_name, |
b728d87e | 639 | * |
cadfcbfc | 640 | * * LTTNG_UST_TP_ARGS takes from 0 to 10 "type, field_name" pairs * |
b728d87e | 641 | * |
cadfcbfc | 642 | * LTTNG_UST_TP_ARGS(int, arg0, void *, arg1, char *, string, size_t, strlen, |
b728d87e MD |
643 | * long *, arg4, size_t, arg4_len), |
644 | * | |
efa14d16 | 645 | * * LTTNG_UST_TP_FIELDS describes the event payload layout in the trace * |
b728d87e | 646 | * |
efa14d16 | 647 | * LTTNG_UST_TP_FIELDS( |
a60af3a5 | 648 | * * Integer, printed in base 10 * |
b728d87e MD |
649 | * ctf_integer(int, field_a, arg0) |
650 | * | |
a60af3a5 | 651 | * * Integer, printed with 0x base 16 * |
b728d87e MD |
652 | * ctf_integer_hex(unsigned long, field_d, arg1) |
653 | * | |
c785c634 MD |
654 | * * Enumeration * |
655 | * ctf_enum(someproject_component, enum_name, int, field_e, arg0) | |
656 | * | |
a60af3a5 | 657 | * * Array Sequence, printed as UTF8-encoded array of bytes * |
b728d87e MD |
658 | * ctf_array_text(char, field_b, string, FIXED_LEN) |
659 | * ctf_sequence_text(char, field_c, string, size_t, strlen) | |
660 | * | |
a60af3a5 | 661 | * * String, printed as UTF8-encoded string * |
b728d87e MD |
662 | * ctf_string(field_e, string) |
663 | * | |
a60af3a5 | 664 | * * Array sequence of signed integer values * |
b728d87e MD |
665 | * ctf_array(long, field_f, arg4, FIXED_LEN4) |
666 | * ctf_sequence(long, field_g, arg4, size_t, arg4_len) | |
667 | * ) | |
668 | * ) | |
669 | * | |
670 | * More detailed explanation: | |
671 | * | |
672 | * The name of the tracepoint is expressed as a tuple with the provider | |
673 | * and name arguments. | |
674 | * | |
675 | * The provider and name should be a proper C99 identifier. | |
676 | * The "provider" and "name" MUST follow these rules to ensure no | |
677 | * namespace clash occurs: | |
678 | * | |
679 | * For projects (applications and libraries) for which an entity | |
680 | * specific to the project controls the source code and thus its | |
681 | * tracepoints (typically with a scope larger than a single company): | |
682 | * | |
683 | * either: | |
684 | * project_component, event | |
685 | * or: | |
686 | * project, event | |
687 | * | |
688 | * Where "project" is the name of the project, | |
689 | * "component" is the name of the project component (which may | |
690 | * include several levels of sub-components, e.g. | |
691 | * ...component_subcomponent_...) where the tracepoint is located | |
692 | * (optional), | |
693 | * "event" is the name of the tracepoint event. | |
694 | * | |
695 | * For projects issued from a single company wishing to advertise that | |
696 | * the company controls the source code and thus the tracepoints, the | |
697 | * "com_" prefix should be used: | |
698 | * | |
699 | * either: | |
700 | * com_company_project_component, event | |
701 | * or: | |
702 | * com_company_project, event | |
703 | * | |
704 | * Where "company" is the name of the company, | |
705 | * "project" is the name of the project, | |
706 | * "component" is the name of the project component (which may | |
707 | * include several levels of sub-components, e.g. | |
708 | * ...component_subcomponent_...) where the tracepoint is located | |
709 | * (optional), | |
710 | * "event" is the name of the tracepoint event. | |
711 | * | |
712 | * the provider:event identifier is limited to 127 characters. | |
713 | */ | |
714 | ||
7f2f82c3 MJ |
715 | #define LTTNG_UST_TRACEPOINT_EVENT(provider, name, args, fields) \ |
716 | LTTNG_UST__DECLARE_TRACEPOINT(provider, name, _TP_PARAMS(args)) \ | |
717 | LTTNG_UST__DEFINE_TRACEPOINT(provider, name, _TP_PARAMS(args)) | |
b728d87e | 718 | |
7f2f82c3 | 719 | #define LTTNG_UST_TRACEPOINT_EVENT_CLASS(provider, name, args, fields) |
b728d87e | 720 | |
7f2f82c3 MJ |
721 | #define LTTNG_UST_TRACEPOINT_EVENT_INSTANCE(provider, _template, name, args) \ |
722 | LTTNG_UST__DECLARE_TRACEPOINT(provider, name, _TP_PARAMS(args)) \ | |
723 | LTTNG_UST__DEFINE_TRACEPOINT(provider, name, _TP_PARAMS(args)) | |
b728d87e | 724 | |
7f2f82c3 MJ |
725 | #if LTTNG_UST_COMPAT_API(0) |
726 | #define TRACEPOINT_EVENT LTTNG_UST_TRACEPOINT_EVENT | |
727 | #define TRACEPOINT_EVENT_CLASS LTTNG_UST_TRACEPOINT_EVENT_CLASS | |
728 | #define TRACEPOINT_EVENT_INSTANCE LTTNG_UST_TRACEPOINT_EVENT_INSTANCE | |
729 | #endif /* #if LTTNG_UST_COMPAT_API(0) */ | |
730 | ||
731 | #endif /* #ifndef LTTNG_UST_TRACEPOINT_EVENT */ | |
b728d87e MD |
732 | |
733 | #ifndef TRACEPOINT_LOGLEVEL | |
734 | ||
735 | /* | |
75c5ad79 | 736 | * Tracepoint Loglevels |
b728d87e MD |
737 | * |
738 | * Typical use of these loglevels: | |
739 | * | |
d8de1354 | 740 | * The loglevels go from 0 to 14. Higher numbers imply the most |
75c5ad79 MD |
741 | * verbosity (higher event throughput expected. |
742 | * | |
d8de1354 MD |
743 | * Loglevels 0 through 6, and loglevel 14, match syslog(3) loglevels |
744 | * semantic. Loglevels 7 through 13 offer more fine-grained selection of | |
745 | * debug information. | |
75c5ad79 | 746 | * |
d8de1354 | 747 | * TRACE_EMERG 0 |
75c5ad79 MD |
748 | * system is unusable |
749 | * | |
d8de1354 | 750 | * TRACE_ALERT 1 |
75c5ad79 MD |
751 | * action must be taken immediately |
752 | * | |
d8de1354 | 753 | * TRACE_CRIT 2 |
75c5ad79 MD |
754 | * critical conditions |
755 | * | |
d8de1354 | 756 | * TRACE_ERR 3 |
75c5ad79 MD |
757 | * error conditions |
758 | * | |
d8de1354 | 759 | * TRACE_WARNING 4 |
75c5ad79 MD |
760 | * warning conditions |
761 | * | |
d8de1354 | 762 | * TRACE_NOTICE 5 |
75c5ad79 MD |
763 | * normal, but significant, condition |
764 | * | |
d8de1354 | 765 | * TRACE_INFO 6 |
75c5ad79 MD |
766 | * informational message |
767 | * | |
d8de1354 MD |
768 | * TRACE_DEBUG_SYSTEM 7 |
769 | * debug information with system-level scope (set of programs) | |
75c5ad79 | 770 | * |
d8de1354 MD |
771 | * TRACE_DEBUG_PROGRAM 8 |
772 | * debug information with program-level scope (set of processes) | |
75c5ad79 | 773 | * |
d8de1354 MD |
774 | * TRACE_DEBUG_PROCESS 9 |
775 | * debug information with process-level scope (set of modules) | |
75c5ad79 | 776 | * |
d8de1354 MD |
777 | * TRACE_DEBUG_MODULE 10 |
778 | * debug information with module (executable/library) scope (set of units) | |
75c5ad79 | 779 | * |
d8de1354 MD |
780 | * TRACE_DEBUG_UNIT 11 |
781 | * debug information with compilation unit scope (set of functions) | |
75c5ad79 | 782 | * |
d8de1354 MD |
783 | * TRACE_DEBUG_FUNCTION 12 |
784 | * debug information with function-level scope | |
75c5ad79 | 785 | * |
d8de1354 | 786 | * TRACE_DEBUG_LINE 13 |
7f2f82c3 | 787 | * debug information with line-level scope (LTTNG_UST_TRACEPOINT_EVENT default) |
902e1379 | 788 | * |
d8de1354 | 789 | * TRACE_DEBUG 14 |
1e3b0059 | 790 | * debug-level message |
75c5ad79 | 791 | * |
7f2f82c3 | 792 | * Declare tracepoint loglevels for tracepoints. A LTTNG_UST_TRACEPOINT_EVENT |
75c5ad79 | 793 | * should be declared prior to the the TRACEPOINT_LOGLEVEL for a given |
853cda88 MD |
794 | * tracepoint name. The first field is the provider name, the second |
795 | * field is the name of the tracepoint, the third field is the loglevel | |
796 | * name. | |
b728d87e MD |
797 | * |
798 | * TRACEPOINT_LOGLEVEL(< [com_company_]project[_component] >, < event >, | |
799 | * < loglevel_name >) | |
800 | * | |
75c5ad79 MD |
801 | * The TRACEPOINT_PROVIDER must be already declared before declaring a |
802 | * TRACEPOINT_LOGLEVEL. | |
b728d87e MD |
803 | */ |
804 | ||
882a56d7 | 805 | enum { |
d8de1354 MD |
806 | TRACE_EMERG = 0, |
807 | TRACE_ALERT = 1, | |
808 | TRACE_CRIT = 2, | |
809 | TRACE_ERR = 3, | |
810 | TRACE_WARNING = 4, | |
811 | TRACE_NOTICE = 5, | |
812 | TRACE_INFO = 6, | |
813 | TRACE_DEBUG_SYSTEM = 7, | |
814 | TRACE_DEBUG_PROGRAM = 8, | |
815 | TRACE_DEBUG_PROCESS = 9, | |
816 | TRACE_DEBUG_MODULE = 10, | |
817 | TRACE_DEBUG_UNIT = 11, | |
818 | TRACE_DEBUG_FUNCTION = 12, | |
819 | TRACE_DEBUG_LINE = 13, | |
820 | TRACE_DEBUG = 14, | |
882a56d7 MD |
821 | }; |
822 | ||
05ceaafd | 823 | #define TRACEPOINT_LOGLEVEL(provider, name, loglevel) |
b728d87e MD |
824 | |
825 | #endif /* #ifndef TRACEPOINT_LOGLEVEL */ | |
6ddc916d MD |
826 | |
827 | #ifndef TRACEPOINT_MODEL_EMF_URI | |
828 | ||
829 | #define TRACEPOINT_MODEL_EMF_URI(provider, name, uri) | |
830 | ||
831 | #endif /* #ifndef TRACEPOINT_MODEL_EMF_URI */ |