-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathros2-comm-trace.bt
373 lines (321 loc) · 9.46 KB
/
ros2-comm-trace.bt
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
/* -*- c -*- */
struct rmw_gid_t {
const char *implementation_identifier;
uint8_t data[24];
};
struct rmw_time_point_value_t {
uint64_t value;
};
struct rmw_message_info_t {
struct rmw_time_point_value_t source_timestamp;
struct rmw_time_point_value_t received_timestamp;
uint64_t publication_sequence_number;
uint64_t reception_sequence_number;
struct rmw_gid_t publisher_gid;
uint32_t from_intra_process;
};
struct rmw_time_t {
uint64_t sec;
uint64_t nsec;
};
struct rmw_qos_profile_t {
uint32_t history; // enum
size_t depth;
uint32_t reliability; // enum
uint32_t durability; // enum
struct rmw_time_t deadline;
struct rmw_time_t lifespan;
uint32_t liveliness; // enum
struct rmw_time_t liveliness_lease_duration;
uint32_t avoid_ros_namespace_conventions;
};
struct rcl_allocator_t {
void *function_allocate;
void *function_deallocate;
void *function_reallocate;
void *function_zero_allocate;
void *state;
};
struct rcutils_string_array_t {
size_t size;
uint8_t **data;
struct rcl_allocator_t allocator;
};
struct rmw_subscription_content_filter_options_t {
char *filter_expression;
struct rcutils_string_array_t expression_parameters;
};
struct rmw_subscription_options_t {
void *rmw_specific_subscription_payload;
uint32_t ignore_local_publications;
uint32_t require_unique_network_flow_endpoints; // enum
struct rmw_subscription_content_filter_options_t *content_filter_options;
};
struct rcl_subscription_options_t {
struct rmw_qos_profile_t qos;
struct rcl_allocator_t allocator;
struct rmw_subscription_options_t rmw_subscription_options;
};
struct rcl_subscription_impl_t {
struct rcl_subscription_options_t options;
struct rmw_qos_profile_t actual_qos;
struct rmw_subscription_t *rmw_handle;
};
struct rmw_subscription_t {
const char *implementation_identifier;
void *data;
char *topic_name;
struct rmw_subscription_options_t options;
uint32_t can_loan_messages;
uint32_t is_cft_enabled;
};
struct rcl_subscription_t {
struct rcl_subscription_impl_t *impl;
};
struct rmw_publisher_options_t
{
void * rmw_specific_publisher_payload;
uint32_t require_unique_network_flow_endpoints; // enum
};
struct rcl_publisher_options_t
{
struct rmw_qos_profile_t qos;
struct rcl_allocator_t allocator;
struct rmw_publisher_options_t rmw_publisher_options;
};
struct rcl_logger_setting_t
{
const char * name;
uint32_t level; // enum rcl_log_severity_t
};
struct rcl_log_levels_t
{
uint32_t default_logger_level; // enum rcl_log_severity_t
struct rcl_logger_setting_t * logger_settings;
size_t num_logger_settings;
size_t capacity_logger_settings;
struct rcl_allocator_t allocator;
};
struct rcl_arguments_impl_t
{
int32_t * unparsed_ros_args;
int32_t num_unparsed_ros_args;
int32_t * unparsed_args;
int32_t num_unparsed_args;
/* struct rcl_params_t */ void * parameter_overrides;
char ** parameter_files;
int32_t num_param_files_args;
/* rcl_remap_t */ void * remap_rules;
int32_t num_remap_rules;
struct rcl_log_levels_t log_levels;
char * external_log_config_file;
uint32_t log_stdout_disabled;
uint32_t log_rosout_disabled;
uint32_t log_ext_lib_disabled;
char * enclave;
struct rcl_allocator_t allocator;
};
struct rcl_arguments_t
{
struct rcl_arguments_impl_t * impl;
};
struct rmw_security_options_t
{
uint32_t enforce_security; // enum rmw_security_enforcement_policy_t
char * security_root_path;
};
struct rmw_init_options_t
{
uint64_t instance_id;
const char * implementation_identifier;
size_t domain_id;
struct rmw_security_options_t security_options;
uint32_t localhost_only; // enum rmw_localhost_only_t
char * enclave;
struct rcl_allocator_t allocator;
/* struct rmw_init_options_impl_t */ void * impl;
};
struct rcl_init_options_impl_t
{
struct rcl_allocator_t allocator;
struct rmw_init_options_t rmw_init_options;
};
struct rcl_init_options_t
{
struct rcl_init_options_impl_t * impl;
};
struct rmw_context_t
{
uint64_t instance_id;
const char * implementation_identifier;
struct rmw_init_options_t options;
size_t actual_domain_id;
/* struct rmw_context_impl_t */ void * impl;
};
struct rcl_context_impl_t
{
struct rcl_allocator_t allocator;
struct rcl_init_options_t init_options;
int64_t argc;
char ** argv;
struct rmw_context_t rmw_context;
}
struct rcl_context_t
{
struct rcl_arguments_t global_arguments;
struct rcl_context_impl_t * impl;
uint8_t instance_id_storage[8];
};
struct rmw_publisher_t
{
const uint8_t * implementation_identifier;
void * data;
const char * topic_name;
struct rmw_publisher_options_t options;
uint32_t can_loan_messages;
};
struct rcl_publisher_impl_t
{
struct rcl_publisher_options_t options;
struct rmw_qos_profile_t actual_qos;
struct rcl_context_t * context;
struct rmw_publisher_t * rmw_handle;
};
struct rcl_publisher_t {
struct rcl_publisher_impl_t *impl;
};
// (rr) p (char*)&subscription_handle_ - (char*)this
// $76 = 48
struct Subscription {
uint8_t crud[48];
struct rcl_subscription_t* rcl_subscription;
};
// (rr) p (char*)&rmw_gid_ - (char*)this
// $3 = 144
// (rr) p (char*)&publisher_handle_ - (char*)this
// $4 = 40
// (rr) p sizeof(publisher_handle_)
// $5 = 16
struct Publisher {
uint8_t crud0[40];
struct rcl_publisher_t* rcl_publisher;
uint8_t crud1[144-40-16];
struct rmw_gid_t rmw_gid;
};
u:{{PUB}}:"*Publisher*do_inter_process_publish*",
u:{{PUB}}:"*Publisher*do_intra_process_publish*",
u:{{PUB}}:"*Publisher*do_intra_process_ros_message_publish*"
{
$Publisher = (struct Publisher*)arg0; // this
$topic = str($Publisher->rcl_publisher->impl->rmw_handle->topic_name);
if($topic == str($1))
{
// Using the topic as the msgid: the publisher gid uniquely identifies the
// pub/sub set with fastrtps, but NOT with cyclone. I don't know why, but I
// can use the topic instead
//
// $msgid = $Publisher->rmw_gid.data;
$msgid = $topic;
@pub_context[$msgid] = (nsecs,tid,cpu);
@follow_tid[tid] = 1;
}
}
u:/opt/ros/humble/lib/librmw_implementation.so:rmw_take,
u:/opt/ros/humble/lib/librmw_implementation.so:rmw_take_event,
u:/opt/ros/humble/lib/librmw_implementation.so:rmw_take_loaned_message,
u:/opt/ros/humble/lib/librmw_implementation.so:rmw_take_loaned_message_with_info,
u:/opt/ros/humble/lib/librmw_implementation.so:rmw_take_sequence,
u:/opt/ros/humble/lib/librmw_implementation.so:rmw_take_serialized_message,
u:/opt/ros/humble/lib/librmw_implementation.so:rmw_take_serialized_message_with_info,
u:/opt/ros/humble/lib/librmw_implementation.so:rmw_take_with_info
{
$subscription = (struct rmw_subscription_t*)arg0;
$topic = str( $subscription->topic_name );
if($topic == str($1))
{
$msgid = $topic;
@take_context[$msgid] = (nsecs,tid,cpu);
}
}
tracepoint:sched:sched_wakeup,
tracepoint:sched:sched_wakeup_new,
tracepoint:sched:sched_waking
/0/
{
$comm_prev = comm;
$tid_prev = (uint32)tid;
$prio_prev = curtask->prio;
$comm_next = args->comm;
$tid_next = (uint32)(args->pid);
$prio_next = args->prio;
if(@follow_tid[tid] || @follow_tid[$tid_next])
{
printf("%ld - - - - - - - - %s >>>%s<<<:%d %d %d >>>%s<<<:%d %d %d\n",
nsecs, probe,
$comm_prev, $tid_prev, $prio_prev, cpu,
$comm_next, $tid_next, $prio_next, args->target_cpu);
if(args->comm != "bpftrace")
{
@follow_tid[$tid_next] = 1;
}
}
}
tracepoint:sched:sched_switch
/0/
{
$comm_next = args->next_comm;
$tid_next = (uint32)(args->next_pid);
$prio_next = args->next_prio;
$comm_prev = args->prev_comm;
$tid_prev = (uint32)(args->prev_pid);
$prio_prev = args->prev_prio;
if(@follow_tid[$tid_prev] || @follow_tid[$tid_next])
{
printf("%ld - - - - - - - - %s >>>%s<<<:%d %d %d >>>%s<<<:%d %d %d\n",
nsecs, probe,
$comm_prev, $tid_prev, $prio_prev, cpu,
$comm_next, $tid_next, $prio_next, cpu);
}
}
u:{{SUB}}:*Subscription*"handle_message*"
{
$Subscription = (struct Subscription*)arg0; // this
$topic = str( $Subscription->rcl_subscription->impl->rmw_handle->topic_name );
if($topic == str($1))
{
$message_info = (uint8*)arg2;
$rmw_message_info = (struct rmw_message_info_t*)($message_info + 8);
// Using the topic as the msgid: the publisher gid uniquely identifies the
// pub/sub set with fastrtps, but NOT with cyclone. I don't know why, but I
// can use the topic instead
//
// $msgid = $rmw_message_info->publisher_gid.data;
$msgid = $topic;
$nsecs_pub = @pub_context [$msgid].0;
$tid_pub = @pub_context [$msgid].1;
$cpu_pub = @pub_context [$msgid].2;
$nsecs_take = @take_context[$msgid].0;
$tid_take = @take_context[$msgid].1;
$cpu_take = @take_context[$msgid].2;
$nsecs_sub = nsecs;
$tid_sub = tid;
$cpu_sub = cpu;
// If the publisher probe never triggered, don't report the latency
if($nsecs_pub && $nsecs_take)
{
printf("%ld %ld %d %ld %ld %d %ld %ld %d - - - - - - -\n",
$nsecs_pub, $tid_pub, $cpu_pub,
$nsecs_take-$nsecs_pub, $tid_take, $cpu_take,
$nsecs_sub -$nsecs_pub, $tid_sub, $cpu_sub);
}
clear(@pub_context);
clear(@take_context);
clear(@follow_tid);
}
}
END
{
clear(@pub_context);
clear(@take_context);
clear(@follow_tid);
}