reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
tracepoint.h
Go to the documentation of this file.
1
26#ifdef RTI_TRACE
27#define LF_TRACE
28#endif
29
30#ifndef TRACEPOINT_H
31#define TRACEPOINT_H
32
33#include "lf_types.h"
34#include <stdio.h>
35
36#ifdef FEDERATED
37#include "net_common.h"
38#endif // FEDERATED
39
40#include "trace_types.h"
41
42#ifdef LF_TRACE
43
44#include "trace.h"
45
49typedef struct trace_record_t {
50 trace_event_t event_type;
51 void* pointer; // pointer identifying the record, e.g. to self struct for a reactor.
52 int src_id; // The ID number of the source (e.g. worker or federate) or -1 for no ID number.
53 int dst_id; // The ID number of the destination (e.g. reaction or federate) or -1 for no ID number.
54 instant_t logical_time;
55 microstep_t microstep;
56 instant_t physical_time;
57 trigger_t* trigger;
58 interval_t extra_delay;
59} trace_record_t;
60
76void call_tracepoint(int event_type, void* reactor, tag_t tag, int worker, int src_id, int dst_id,
77 instant_t* physical_time, trigger_t* trigger, interval_t extra_delay);
78
88int _lf_register_trace_event(void* pointer1, void* pointer2, _lf_trace_object_t type, char* description);
89
97int register_user_trace_event(void* self, char* description);
98
105#define tracepoint_reaction_starts(env, reaction, worker) \
106 call_tracepoint(reaction_starts, reaction->self, env->current_tag, worker, worker, reaction->number, NULL, NULL, \
107 reaction->deadline)
108
115#define tracepoint_reaction_ends(env, reaction, worker) \
116 call_tracepoint(reaction_ends, reaction->self, env->current_tag, worker, worker, reaction->number, NULL, NULL, \
117 reaction->deadline)
118
125void tracepoint_schedule(environment_t* env, trigger_t* trigger, interval_t extra_delay);
126
136void tracepoint_user_event(void* self, char* description);
137
151void tracepoint_user_value(void* self, char* description, long long value);
152
158#define tracepoint_worker_wait_starts(env, worker) \
159 call_tracepoint(worker_wait_starts, NULL, env->current_tag, worker, worker, -1, NULL, NULL, 0)
160
166#define tracepoint_worker_wait_ends(env, worker) \
167 call_tracepoint(worker_wait_ends, NULL, env->current_tag, worker, worker, -1, NULL, NULL, 0)
168
174#define tracepoint_scheduler_advancing_time_starts(env) \
175 call_tracepoint(scheduler_advancing_time_starts, NULL, env->current_tag, -1, -1, -1, NULL, NULL, 0);
176
182#define tracepoint_scheduler_advancing_time_ends(env) \
183 call_tracepoint(scheduler_advancing_time_ends, NULL, env->current_tag, -1, -1, -1, NULL, NULL, 0)
184
191#define tracepoint_reaction_deadline_missed(env, reaction, worker) \
192 call_tracepoint(reaction_deadline_missed, reaction->self, env->current_tag, worker, worker, reaction->number, NULL, \
193 NULL, 0)
194
199void lf_tracing_check_version();
200
203
204#if defined(FEDERATED) || defined(LF_ENCLAVES)
205
213void tracepoint_federate_to_rti(trace_event_t event_type, int fed_id, tag_t* tag);
214
222void tracepoint_federate_from_rti(trace_event_t event_type, int fed_id, tag_t* tag);
223
232void tracepoint_federate_to_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag);
233
242void tracepoint_federate_from_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag);
243
244#else
245static inline void tracepoint_federate_to_rti(trace_event_t event_type, int fed_id, tag_t* tag) {
246 (void)event_type;
247 (void)fed_id;
248 (void)tag;
249}
250static inline void tracepoint_federate_from_rti(trace_event_t event_type, int fed_id, tag_t* tag) {
251 (void)event_type;
252 (void)fed_id;
253 (void)tag;
254}
255static inline void tracepoint_federate_to_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag) {
256 (void)event_type;
257 (void)fed_id;
258 (void)partner_id;
259 (void)tag;
260}
261static inline void tracepoint_federate_from_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag) {
262 (void)event_type;
263 (void)fed_id;
264 (void)partner_id;
265 (void)tag;
266}
267#endif // FEDERATED
268
271
272#ifdef RTI_TRACE
273
281void tracepoint_rti_to_federate(trace_event_t event_type, int fed_id, tag_t* tag);
282
290void tracepoint_rti_from_federate(trace_event_t event_type, int fed_id, tag_t* tag);
291
292#else
293static inline void tracepoint_rti_to_federate(trace_event_t event_type, int fed_id, tag_t* tag) {
294 (void)event_type;
295 (void)fed_id;
296 (void)tag;
297}
298static inline void tracepoint_rti_from_federate(trace_event_t event_type, int fed_id, tag_t* tag) {
299 (void)event_type;
300 (void)fed_id;
301 (void)tag;
302}
303#endif // RTI_TRACE
304
305#else
306typedef struct trace_t trace_t;
307static inline int register_user_trace_event(void* self, char* description) {
308 (void)self;
309 (void)description;
310 return 0;
311}
312static inline void tracepoint_schedule(environment_t* env, trigger_t* trigger, interval_t extra_delay) {
313 (void)env;
314 (void)trigger;
315 (void)extra_delay;
316}
317static inline void tracepoint_user_event(void* self, char* description) {
318 (void)self;
319 (void)description;
320}
321static inline void tracepoint_user_value(void* self, char* description, long long value) {
322 (void)self;
323 (void)description;
324 (void)value;
325}
326static inline void tracepoint_rti_to_federate(trace_event_t event_type, int fed_id, tag_t* tag) {
327 (void)event_type;
328 (void)fed_id;
329 (void)tag;
330}
331static inline void tracepoint_rti_from_federate(trace_event_t event_type, int fed_id, tag_t* tag) {
332 (void)event_type;
333 (void)fed_id;
334 (void)tag;
335}
336static inline void tracepoint_federate_to_rti(trace_event_t event_type, int fed_id, tag_t* tag) {
337 (void)event_type;
338 (void)fed_id;
339 (void)tag;
340}
341static inline void tracepoint_federate_from_rti(trace_event_t event_type, int fed_id, tag_t* tag) {
342 (void)event_type;
343 (void)fed_id;
344 (void)tag;
345}
346static inline void tracepoint_federate_to_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag) {
347 (void)event_type;
348 (void)fed_id;
349 (void)partner_id;
350 (void)tag;
351}
352static inline void tracepoint_federate_from_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag) {
353 (void)event_type;
354 (void)fed_id;
355 (void)partner_id;
356 (void)tag;
357}
358static inline void lf_tracing_global_init(char* process_name, char* process_names, int process_id,
359 int max_num_local_threads) {
360 (void)process_name;
361 (void)process_names;
362 (void)process_id;
363 (void)max_num_local_threads;
364}
365static inline void lf_tracing_global_shutdown() {}
366static inline void lf_tracing_set_start_time(int64_t start_time) { (void)start_time; }
367
368#define tracepoint_reaction_starts(env, reaction, worker) \
369 while (0) { \
370 (void)env; \
371 (void)reaction; \
372 (void)worker; \
373 }
374#define tracepoint_reaction_ends(env, reaction, worker) \
375 while (0) { \
376 (void)env; \
377 (void)reaction; \
378 (void)worker; \
379 }
380#define tracepoint_worker_wait_starts(env, worker) \
381 while (0) { \
382 (void)env; \
383 (void)worker; \
384 }
385#define tracepoint_worker_wait_ends(env, worker) \
386 while (0) { \
387 (void)env; \
388 (void)worker; \
389 }
390#define tracepoint_scheduler_advancing_time_starts(env) \
391 while (0) { \
392 (void)env; \
393 }
394#define tracepoint_scheduler_advancing_time_ends(env) \
395 while (0) { \
396 (void)env; \
397 }
398#define tracepoint_reaction_deadline_missed(env, reaction, worker) \
399 while (0) { \
400 (void)env; \
401 (void)reaction; \
402 (void)worker; \
403 }
404
405#endif // LF_TRACE
406#endif // TRACEPOINT_H
Type definitions that are widely used across different parts of the runtime.
instant_t start_time
Definition tag.c:33
void * worker(void *arg)
Definition reactor_threaded.c:906
Execution environment. This struct contains information about the execution environment....
Definition environment.h:49
Definition tag.h:81
This struct holds all the state associated with tracing in a single environment. Each environment whi...
Definition trace_impl.h:19
Definition lf_types.h:208
int64_t instant_t
Definition tag.h:66
uint32_t microstep_t
Definition tag.h:76
int64_t interval_t
Definition tag.h:71
_lf_trace_object_t
Definition trace.h:22
trace_event_t
Definition trace_types.h:18