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, 0)
107
114#define tracepoint_reaction_ends(env, reaction, worker) \
115 call_tracepoint(reaction_ends, reaction->self, env->current_tag, worker, worker, reaction->number, NULL, NULL, 0)
116
123void tracepoint_schedule(environment_t* env, trigger_t* trigger, interval_t extra_delay);
124
134void tracepoint_user_event(void* self, char* description);
135
149void tracepoint_user_value(void* self, char* description, long long value);
150
156#define tracepoint_worker_wait_starts(env, worker) \
157 call_tracepoint(worker_wait_starts, NULL, env->current_tag, worker, worker, -1, NULL, NULL, 0)
158
164#define tracepoint_worker_wait_ends(env, worker) \
165 call_tracepoint(worker_wait_ends, NULL, env->current_tag, worker, worker, -1, NULL, NULL, 0)
166
172#define tracepoint_scheduler_advancing_time_starts(env) \
173 call_tracepoint(scheduler_advancing_time_starts, NULL, env->current_tag, -1, -1, -1, NULL, NULL, 0);
174
180#define tracepoint_scheduler_advancing_time_ends(env) \
181 call_tracepoint(scheduler_advancing_time_ends, NULL, env->current_tag, -1, -1, -1, NULL, NULL, 0)
182
189#define tracepoint_reaction_deadline_missed(env, reaction, worker) \
190 call_tracepoint(reaction_deadline_missed, reaction->self, env->current_tag, worker, worker, reaction->number, NULL, \
191 NULL, 0)
192
197void lf_tracing_check_version();
198
201
202#if defined(FEDERATED) || defined(LF_ENCLAVES)
203
211void tracepoint_federate_to_rti(trace_event_t event_type, int fed_id, tag_t* tag);
212
220void tracepoint_federate_from_rti(trace_event_t event_type, int fed_id, tag_t* tag);
221
230void tracepoint_federate_to_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag);
231
240void tracepoint_federate_from_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag);
241
242#else
243static inline void tracepoint_federate_to_rti(trace_event_t event_type, int fed_id, tag_t* tag) {
244 (void)event_type;
245 (void)fed_id;
246 (void)tag;
247}
248static inline void tracepoint_federate_from_rti(trace_event_t event_type, int fed_id, tag_t* tag) {
249 (void)event_type;
250 (void)fed_id;
251 (void)tag;
252}
253static inline void tracepoint_federate_to_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag) {
254 (void)event_type;
255 (void)fed_id;
256 (void)partner_id;
257 (void)tag;
258}
259static inline void tracepoint_federate_from_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag) {
260 (void)event_type;
261 (void)fed_id;
262 (void)partner_id;
263 (void)tag;
264}
265#endif // FEDERATED
266
269
270#ifdef RTI_TRACE
271
279void tracepoint_rti_to_federate(trace_event_t event_type, int fed_id, tag_t* tag);
280
288void tracepoint_rti_from_federate(trace_event_t event_type, int fed_id, tag_t* tag);
289
290#else
291static inline void tracepoint_rti_to_federate(trace_event_t event_type, int fed_id, tag_t* tag) {
292 (void)event_type;
293 (void)fed_id;
294 (void)tag;
295}
296static inline void tracepoint_rti_from_federate(trace_event_t event_type, int fed_id, tag_t* tag) {
297 (void)event_type;
298 (void)fed_id;
299 (void)tag;
300}
301#endif // RTI_TRACE
302
303#else
304typedef struct trace_t trace_t;
305static inline int register_user_trace_event(void* self, char* description) {
306 (void)self;
307 (void)description;
308 return 0;
309}
310static inline void tracepoint_schedule(environment_t* env, trigger_t* trigger, interval_t extra_delay) {
311 (void)env;
312 (void)trigger;
313 (void)extra_delay;
314}
315static inline void tracepoint_user_event(void* self, char* description) {
316 (void)self;
317 (void)description;
318}
319static inline void tracepoint_user_value(void* self, char* description, long long value) {
320 (void)self;
321 (void)description;
322 (void)value;
323}
324static inline void tracepoint_rti_to_federate(trace_event_t event_type, int fed_id, tag_t* tag) {
325 (void)event_type;
326 (void)fed_id;
327 (void)tag;
328}
329static inline void tracepoint_rti_from_federate(trace_event_t event_type, int fed_id, tag_t* tag) {
330 (void)event_type;
331 (void)fed_id;
332 (void)tag;
333}
334static inline void tracepoint_federate_to_rti(trace_event_t event_type, int fed_id, tag_t* tag) {
335 (void)event_type;
336 (void)fed_id;
337 (void)tag;
338}
339static inline void tracepoint_federate_from_rti(trace_event_t event_type, int fed_id, tag_t* tag) {
340 (void)event_type;
341 (void)fed_id;
342 (void)tag;
343}
344static inline void tracepoint_federate_to_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag) {
345 (void)event_type;
346 (void)fed_id;
347 (void)partner_id;
348 (void)tag;
349}
350static inline void tracepoint_federate_from_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag) {
351 (void)event_type;
352 (void)fed_id;
353 (void)partner_id;
354 (void)tag;
355}
356static inline void lf_tracing_global_init(char* process_name, char* process_names, int process_id,
357 int max_num_local_threads) {
358 (void)process_name;
359 (void)process_names;
360 (void)process_id;
361 (void)max_num_local_threads;
362}
363static inline void lf_tracing_global_shutdown() {}
364static inline void lf_tracing_set_start_time(int64_t start_time) { (void)start_time; }
365
366#define tracepoint_reaction_starts(env, reaction, worker) \
367 while (0) { \
368 (void)env; \
369 (void)reaction; \
370 (void)worker; \
371 }
372#define tracepoint_reaction_ends(env, reaction, worker) \
373 while (0) { \
374 (void)env; \
375 (void)reaction; \
376 (void)worker; \
377 }
378#define tracepoint_worker_wait_starts(env, worker) \
379 while (0) { \
380 (void)env; \
381 (void)worker; \
382 }
383#define tracepoint_worker_wait_ends(env, worker) \
384 while (0) { \
385 (void)env; \
386 (void)worker; \
387 }
388#define tracepoint_scheduler_advancing_time_starts(env) \
389 while (0) { \
390 (void)env; \
391 }
392#define tracepoint_scheduler_advancing_time_ends(env) \
393 while (0) { \
394 (void)env; \
395 }
396#define tracepoint_reaction_deadline_missed(env, reaction, worker) \
397 while (0) { \
398 (void)env; \
399 (void)reaction; \
400 (void)worker; \
401 }
402
403#endif // LF_TRACE
404#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:911
Execution environment. This struct contains information about the execution environment....
Definition environment.h:69
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:210
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