-
Notifications
You must be signed in to change notification settings - Fork 43
/
tracetools.c
437 lines (391 loc) · 9.52 KB
/
tracetools.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
// Copyright 2019 Robert Bosch GmbH
// Copyright 2020 Christophe Bedard
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "tracetools/tracetools.h"
#ifndef TRACETOOLS_DISABLED
/**
* TODO(christophebedard) need to use "ros2" directly instead of "TRACEPOINT_PROVIDER" in some
* places here due to a bug with LTTng. Try again when bumping to a newer LTTng-UST version once
* this fix gets merged: https://review.lttng.org/c/lttng-ust/+/9001
*/
#ifndef TRACETOOLS_TRACEPOINTS_EXCLUDED
# include "tracetools/tp_call.h"
// *INDENT-OFF*
# define _CONDITIONAL_TP(...) \
tracepoint(TRACEPOINT_PROVIDER, __VA_ARGS__)
# define _CONDITIONAL_TP_ENABLED(event_name) \
0 != tracepoint_enabled(ros2, event_name)
# define _CONDITIONAL_DO_TP(...) \
do_tracepoint(ros2, __VA_ARGS__)
#else
# define _CONDITIONAL_TP(...) ((void) (0))
# define _CONDITIONAL_TP_ENABLED(...) false
# define _CONDITIONAL_DO_TP(...) ((void) (0))
#endif // TRACETOOLS_TRACEPOINTS_EXCLUDED
#define TRACEPOINT_ARGS(...) __VA_ARGS__
#define TRACEPOINT_PARAMS(...) __VA_ARGS__
#define DEFINE_TRACEPOINT(event_name, _TP_PARAMS, _TP_ARGS) \
void TRACETOOLS_TRACEPOINT(event_name, _TP_PARAMS) \
{ \
_CONDITIONAL_TP(event_name, _TP_ARGS); \
} \
bool TRACETOOLS_TRACEPOINT_ENABLED(event_name) \
{ \
return _CONDITIONAL_TP_ENABLED(event_name); \
} \
void TRACETOOLS_DO_TRACEPOINT(event_name, _TP_PARAMS) \
{ \
_CONDITIONAL_DO_TP(event_name, _TP_ARGS); \
}
#define DEFINE_TRACEPOINT_NO_ARGS(event_name) \
void TRACETOOLS_TRACEPOINT(event_name) \
{ \
_CONDITIONAL_TP(event_name); \
} \
bool TRACETOOLS_TRACEPOINT_ENABLED(event_name) \
{ \
return _CONDITIONAL_TP_ENABLED(event_name); \
} \
void TRACETOOLS_DO_TRACEPOINT(event_name) \
{ \
_CONDITIONAL_DO_TP(event_name); \
}
// *INDENT-ON*
bool ros_trace_compile_status(void)
{
#ifndef TRACETOOLS_TRACEPOINTS_EXCLUDED
return true;
#else
return false;
#endif
}
// Ignore unused-parameters warning when tracepoints are excluded
#ifndef _WIN32
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused-parameter"
#else
# pragma warning(push)
# pragma warning(disable: 4100)
#endif
// Ignore zero-variadic-macro-arguments clang warnings caused by lttng-ust macros
#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#endif
DEFINE_TRACEPOINT(
rcl_init,
TRACEPOINT_PARAMS(
const void * context_handle),
TRACEPOINT_ARGS(
context_handle))
DEFINE_TRACEPOINT(
rcl_node_init,
TRACEPOINT_PARAMS(
const void * node_handle,
const void * rmw_handle,
const char * node_name,
const char * node_namespace),
TRACEPOINT_ARGS(
node_handle,
rmw_handle,
node_name,
node_namespace))
DEFINE_TRACEPOINT(
rmw_publisher_init,
TRACEPOINT_PARAMS(
const void * rmw_publisher_handle,
const uint8_t * gid),
TRACEPOINT_ARGS(
rmw_publisher_handle,
gid))
DEFINE_TRACEPOINT(
rcl_publisher_init,
TRACEPOINT_PARAMS(
const void * publisher_handle,
const void * node_handle,
const void * rmw_publisher_handle,
const char * topic_name,
const size_t queue_depth),
TRACEPOINT_ARGS(
publisher_handle,
node_handle,
rmw_publisher_handle,
topic_name,
queue_depth))
DEFINE_TRACEPOINT(
rclcpp_publish,
TRACEPOINT_PARAMS(
const void * publisher_handle,
const void * message),
TRACEPOINT_ARGS(
message))
DEFINE_TRACEPOINT(
rclcpp_intra_publish,
TRACEPOINT_PARAMS(
const void * publisher_handle,
const void * message),
TRACEPOINT_ARGS(
publisher_handle,
message))
DEFINE_TRACEPOINT(
rcl_publish,
TRACEPOINT_PARAMS(
const void * publisher_handle,
const void * message),
TRACEPOINT_ARGS(
publisher_handle,
message))
DEFINE_TRACEPOINT(
rmw_publish,
TRACEPOINT_PARAMS(
const void * rmw_publisher_handle,
const void * message,
int64_t timestamp),
TRACEPOINT_ARGS(
rmw_publisher_handle,
message,
timestamp))
DEFINE_TRACEPOINT(
rmw_subscription_init,
TRACEPOINT_PARAMS(
const void * rmw_subscription_handle,
const uint8_t * gid),
TRACEPOINT_ARGS(
rmw_subscription_handle,
gid))
DEFINE_TRACEPOINT(
rcl_subscription_init,
TRACEPOINT_PARAMS(
const void * subscription_handle,
const void * node_handle,
const void * rmw_subscription_handle,
const char * topic_name,
const size_t queue_depth),
TRACEPOINT_ARGS(
subscription_handle,
node_handle,
rmw_subscription_handle,
topic_name,
queue_depth))
DEFINE_TRACEPOINT(
rclcpp_subscription_init,
TRACEPOINT_PARAMS(
const void * subscription_handle,
const void * subscription),
TRACEPOINT_ARGS(
subscription_handle,
subscription))
DEFINE_TRACEPOINT(
rclcpp_subscription_callback_added,
TRACEPOINT_PARAMS(
const void * subscription,
const void * callback),
TRACEPOINT_ARGS(
subscription,
callback))
DEFINE_TRACEPOINT(
rmw_take,
TRACEPOINT_PARAMS(
const void * rmw_subscription_handle,
const void * message,
int64_t source_timestamp,
const bool taken),
TRACEPOINT_ARGS(
rmw_subscription_handle,
message,
source_timestamp,
taken))
DEFINE_TRACEPOINT(
rcl_take,
TRACEPOINT_PARAMS(
const void * message),
TRACEPOINT_ARGS(
message))
DEFINE_TRACEPOINT(
rclcpp_take,
TRACEPOINT_PARAMS(
const void * message),
TRACEPOINT_ARGS(
message))
DEFINE_TRACEPOINT(
rcl_service_init,
TRACEPOINT_PARAMS(
const void * service_handle,
const void * node_handle,
const void * rmw_service_handle,
const char * service_name),
TRACEPOINT_ARGS(
service_handle,
node_handle,
rmw_service_handle,
service_name))
DEFINE_TRACEPOINT(
rclcpp_service_callback_added,
TRACEPOINT_PARAMS(
const void * service_handle,
const void * callback),
TRACEPOINT_ARGS(
service_handle,
callback))
DEFINE_TRACEPOINT(
rcl_client_init,
TRACEPOINT_PARAMS(
const void * client_handle,
const void * node_handle,
const void * rmw_client_handle,
const char * service_name),
TRACEPOINT_ARGS(
client_handle,
node_handle,
rmw_client_handle,
service_name))
DEFINE_TRACEPOINT(
rcl_timer_init,
TRACEPOINT_PARAMS(
const void * timer_handle,
int64_t period),
TRACEPOINT_ARGS(
timer_handle,
period))
DEFINE_TRACEPOINT(
rclcpp_timer_callback_added,
TRACEPOINT_PARAMS(
const void * timer_handle,
const void * callback),
TRACEPOINT_ARGS(
timer_handle,
callback))
DEFINE_TRACEPOINT(
rclcpp_timer_link_node,
TRACEPOINT_PARAMS(
const void * timer_handle,
const void * node_handle),
TRACEPOINT_ARGS(
timer_handle,
node_handle))
DEFINE_TRACEPOINT(
rclcpp_callback_register,
TRACEPOINT_PARAMS(
const void * callback,
const char * function_symbol),
TRACEPOINT_ARGS(
callback,
function_symbol))
DEFINE_TRACEPOINT(
callback_start,
TRACEPOINT_PARAMS(
const void * callback,
const bool is_intra_process),
TRACEPOINT_ARGS(
callback,
is_intra_process))
DEFINE_TRACEPOINT(
callback_end,
TRACEPOINT_PARAMS(
const void * callback),
TRACEPOINT_ARGS(
callback))
DEFINE_TRACEPOINT(
rcl_lifecycle_state_machine_init,
TRACEPOINT_PARAMS(
const void * node_handle,
const void * state_machine),
TRACEPOINT_ARGS(
node_handle,
state_machine))
DEFINE_TRACEPOINT(
rcl_lifecycle_transition,
TRACEPOINT_PARAMS(
const void * state_machine,
const char * start_label,
const char * goal_label),
TRACEPOINT_ARGS(
state_machine,
start_label,
goal_label))
DEFINE_TRACEPOINT_NO_ARGS(
rclcpp_executor_get_next_ready)
DEFINE_TRACEPOINT(
rclcpp_executor_wait_for_work,
TRACEPOINT_PARAMS(
const int64_t timeout),
TRACEPOINT_ARGS(
timeout))
DEFINE_TRACEPOINT(
rclcpp_executor_execute,
TRACEPOINT_PARAMS(
const void * handle),
TRACEPOINT_ARGS(
handle))
DEFINE_TRACEPOINT(
rclcpp_ipb_to_subscription,
TRACEPOINT_PARAMS(
const void * ipb,
const void * subscription),
TRACEPOINT_ARGS(
ipb,
subscription))
DEFINE_TRACEPOINT(
rclcpp_buffer_to_ipb,
TRACEPOINT_PARAMS(
const void * buffer,
const void * ipb),
TRACEPOINT_ARGS(
buffer,
ipb))
DEFINE_TRACEPOINT(
rclcpp_construct_ring_buffer,
TRACEPOINT_PARAMS(
const void * buffer,
const uint64_t capacity),
TRACEPOINT_ARGS(
buffer,
capacity))
DEFINE_TRACEPOINT(
rclcpp_ring_buffer_enqueue,
TRACEPOINT_PARAMS(
const void * buffer,
const uint64_t index,
const uint64_t size,
const bool overwritten),
TRACEPOINT_ARGS(
buffer,
index,
size,
overwritten))
DEFINE_TRACEPOINT(
rclcpp_ring_buffer_dequeue,
TRACEPOINT_PARAMS(
const void * buffer,
const uint64_t index,
const uint64_t size),
TRACEPOINT_ARGS(
buffer,
index,
size))
DEFINE_TRACEPOINT(
rclcpp_ring_buffer_clear,
TRACEPOINT_PARAMS(
const void * buffer),
TRACEPOINT_ARGS(
buffer))
#ifdef __clang__
# pragma clang diagnostic pop
#endif
#ifndef _WIN32
# pragma GCC diagnostic pop
#else
# pragma warning(pop)
#endif
#endif // TRACETOOLS_DISABLED