reactor-c 1.0
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
tracepoint.h
Go to the documentation of this file.
1
25
27#ifdef RTI_TRACE
28#define LF_TRACE
29#endif
30
31#ifndef TRACEPOINT_H
32#define TRACEPOINT_H
34
35#include "lf_types.h"
36#include <stdio.h>
37
38#ifdef FEDERATED
39#include "net_common.h"
40#endif // FEDERATED
41
42#include "trace_types.h"
43
44#ifdef LF_TRACE
45
46#include "trace.h"
47
80
95void call_tracepoint(int event_type, void* reactor, tag_t tag, int worker, int src_id, int dst_id,
96 instant_t* physical_time, trigger_t* trigger, interval_t extra_delay);
97
108int _lf_register_trace_event(void* pointer1, void* pointer2, _lf_trace_object_t type, char* description);
109
124int register_user_trace_event(void* self, char* description);
125
134#define tracepoint_reaction_starts(env, reaction, worker) \
135 call_tracepoint(reaction_starts, reaction->self, env->current_tag, worker, worker, reaction->number, NULL, NULL, \
136 reaction->deadline)
137
146#define tracepoint_reaction_ends(env, reaction, worker) \
147 call_tracepoint(reaction_ends, reaction->self, env->current_tag, worker, worker, reaction->number, NULL, NULL, \
148 reaction->deadline)
149
158void tracepoint_schedule(environment_t* env, trigger_t* trigger, interval_t extra_delay);
159
173void tracepoint_user_event(void* self, char* description);
174
191void tracepoint_user_value(void* self, char* description, long long value);
192
200#define tracepoint_worker_wait_starts(env, worker) \
201 call_tracepoint(worker_wait_starts, NULL, env->current_tag, worker, worker, -1, NULL, NULL, 0)
202
210#define tracepoint_worker_wait_ends(env, worker) \
211 call_tracepoint(worker_wait_ends, NULL, env->current_tag, worker, worker, -1, NULL, NULL, 0)
212
220#define tracepoint_scheduler_advancing_time_starts(env) \
221 call_tracepoint(scheduler_advancing_time_starts, NULL, env->current_tag, -1, -1, -1, NULL, NULL, 0);
222
230#define tracepoint_scheduler_advancing_time_ends(env) \
231 call_tracepoint(scheduler_advancing_time_ends, NULL, env->current_tag, -1, -1, -1, NULL, NULL, 0)
232
241#define tracepoint_reaction_deadline_missed(env, reaction, worker) \
242 call_tracepoint(reaction_deadline_missed, reaction->self, env->current_tag, worker, worker, reaction->number, NULL, \
243 NULL, 0)
244
250
253
254#if defined(FEDERATED) || defined(LF_ENCLAVES)
255
265void tracepoint_federate_to_rti(trace_event_t event_type, int fed_id, tag_t* tag);
266
276void tracepoint_federate_from_rti(trace_event_t event_type, int fed_id, tag_t* tag);
277
288void tracepoint_federate_to_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag);
289
300void tracepoint_federate_from_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag);
301
302#else
303static inline void tracepoint_federate_to_rti(trace_event_t event_type, int fed_id, tag_t* tag) {
304 (void)event_type;
305 (void)fed_id;
306 (void)tag;
307}
308static inline void tracepoint_federate_from_rti(trace_event_t event_type, int fed_id, tag_t* tag) {
309 (void)event_type;
310 (void)fed_id;
311 (void)tag;
312}
313static inline void tracepoint_federate_to_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag) {
314 (void)event_type;
315 (void)fed_id;
316 (void)partner_id;
317 (void)tag;
318}
319static inline void tracepoint_federate_from_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag) {
320 (void)event_type;
321 (void)fed_id;
322 (void)partner_id;
323 (void)tag;
324}
325#endif // FEDERATED
326
329
330#ifdef RTI_TRACE
331
341void tracepoint_rti_to_federate(trace_event_t event_type, int fed_id, tag_t* tag);
342
352void tracepoint_rti_from_federate(trace_event_t event_type, int fed_id, tag_t* tag);
353
354#else
355static inline void tracepoint_rti_to_federate(trace_event_t event_type, int fed_id, tag_t* tag) {
356 (void)event_type;
357 (void)fed_id;
358 (void)tag;
359}
360static inline void tracepoint_rti_from_federate(trace_event_t event_type, int fed_id, tag_t* tag) {
361 (void)event_type;
362 (void)fed_id;
363 (void)tag;
364}
365#endif // RTI_TRACE
366
367#else
368typedef struct trace_t trace_t;
369static inline int register_user_trace_event(void* self, char* description) {
370 (void)self;
371 (void)description;
372 return 0;
373}
374static inline void tracepoint_schedule(environment_t* env, trigger_t* trigger, interval_t extra_delay) {
375 (void)env;
376 (void)trigger;
377 (void)extra_delay;
378}
379static inline void tracepoint_user_event(void* self, char* description) {
380 (void)self;
381 (void)description;
382}
383static inline void tracepoint_user_value(void* self, char* description, long long value) {
384 (void)self;
385 (void)description;
386 (void)value;
387}
388static inline void tracepoint_rti_to_federate(trace_event_t event_type, int fed_id, tag_t* tag) {
389 (void)event_type;
390 (void)fed_id;
391 (void)tag;
392}
393static inline void tracepoint_rti_from_federate(trace_event_t event_type, int fed_id, tag_t* tag) {
394 (void)event_type;
395 (void)fed_id;
396 (void)tag;
397}
398static inline void tracepoint_federate_to_rti(trace_event_t event_type, int fed_id, tag_t* tag) {
399 (void)event_type;
400 (void)fed_id;
401 (void)tag;
402}
403static inline void tracepoint_federate_from_rti(trace_event_t event_type, int fed_id, tag_t* tag) {
404 (void)event_type;
405 (void)fed_id;
406 (void)tag;
407}
408static inline void tracepoint_federate_to_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag) {
409 (void)event_type;
410 (void)fed_id;
411 (void)partner_id;
412 (void)tag;
413}
414static inline void tracepoint_federate_from_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t* tag) {
415 (void)event_type;
416 (void)fed_id;
417 (void)partner_id;
418 (void)tag;
419}
420
422// The following is defined in trace.h, so ask Doxygen to ignore this.
423
424static inline void lf_tracing_global_init(char* process_name, char* process_names, int process_id,
425 int max_num_local_threads) {
426 (void)process_name;
427 (void)process_names;
428 (void)process_id;
429 (void)max_num_local_threads;
430}
431static inline void lf_tracing_global_shutdown() {}
432static inline void lf_tracing_set_start_time(int64_t start_time) { (void)start_time; }
433
435
436#define tracepoint_reaction_starts(env, reaction, worker) \
437 while (0) { \
438 (void)env; \
439 (void)reaction; \
440 (void)worker; \
441 }
442#define tracepoint_reaction_ends(env, reaction, worker) \
443 while (0) { \
444 (void)env; \
445 (void)reaction; \
446 (void)worker; \
447 }
448#define tracepoint_worker_wait_starts(env, worker) \
449 while (0) { \
450 (void)env; \
451 (void)worker; \
452 }
453#define tracepoint_worker_wait_ends(env, worker) \
454 while (0) { \
455 (void)env; \
456 (void)worker; \
457 }
458#define tracepoint_scheduler_advancing_time_starts(env) \
459 while (0) { \
460 (void)env; \
461 }
462#define tracepoint_scheduler_advancing_time_ends(env) \
463 while (0) { \
464 (void)env; \
465 }
466#define tracepoint_reaction_deadline_missed(env, reaction, worker) \
467 while (0) { \
468 (void)env; \
469 (void)reaction; \
470 (void)worker; \
471 }
472
473#endif // LF_TRACE
475#endif // TRACEPOINT_H
void tracepoint_user_value(void *self, char *description, long long value)
Trace a user-defined event with a value.
int64_t instant_t
Time instant.
Definition tag.h:101
void tracepoint_user_event(void *self, char *description)
Trace a user-defined event.
uint32_t microstep_t
Microstep.
Definition tag.h:113
int register_user_trace_event(void *self, char *description)
Register a user trace event.
int64_t interval_t
Interval of time.
Definition tag.h:107
void tracepoint_federate_to_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t *tag)
Trace federate sending a message to another federate.
void tracepoint_federate_from_federate(trace_event_t event_type, int fed_id, int partner_id, tag_t *tag)
Trace federate receiving a message from another federate.
void tracepoint_federate_to_rti(trace_event_t event_type, int fed_id, tag_t *tag)
Trace federate sending a message to the RTI.
void tracepoint_federate_from_rti(trace_event_t event_type, int fed_id, tag_t *tag)
Trace federate receiving a message from the RTI.
int _lf_register_trace_event(void *pointer1, void *pointer2, _lf_trace_object_t type, char *description)
Register a trace object.
void lf_tracing_check_version()
Check if the tracing library is compatible with the current version of the runtime.
void tracepoint_schedule(environment_t *env, trigger_t *trigger, interval_t extra_delay)
Trace a call to schedule.
void call_tracepoint(int event_type, void *reactor, tag_t tag, int worker, int src_id, int dst_id, instant_t *physical_time, trigger_t *trigger, interval_t extra_delay)
Pass the provided info to the tracing module.
void tracepoint_rti_to_federate(trace_event_t event_type, int fed_id, tag_t *tag)
Trace RTI sending a message to a federate.
void tracepoint_rti_from_federate(trace_event_t event_type, int fed_id, tag_t *tag)
Trace RTI receiving a message from a federate.
void lf_tracing_global_init(char *process_name, char *process_names, int process_id, int max_num_local_threads)
Initialize the tracing module.
void lf_tracing_set_start_time(int64_t start_time)
Give the tracing module access to the start time.
void lf_tracing_global_shutdown()
Shut down the tracing module.
trace_event_t
Trace event types.
Definition trace_types.h:20
_lf_trace_object_t
Identifier for what is in the object table.
Definition trace.h:37
Type definitions that are widely used across different parts of the runtime.
Common message types and definitions for federated Lingua Franca programs.
Execution environment.
Definition environment.h:52
A tag is a time, microstep pair.
Definition tag.h:119
A trace record that gets written in binary to the trace file in the default implementation.
Definition tracepoint.h:52
int dst_id
The ID number of the destination (e.g., reaction number or federate ID) or -1 if not applicable.
Definition tracepoint.h:63
instant_t logical_time
The logical time at which the event occurred.
Definition tracepoint.h:66
void * pointer
Pointer identifying the record, typically points to the self struct of a reactor.
Definition tracepoint.h:57
int src_id
The ID number of the source (e.g., worker thread or federate ID) or -1 if not applicable.
Definition tracepoint.h:60
microstep_t microstep
The microstep at which the event occurred.
Definition tracepoint.h:69
trigger_t * trigger
Pointer to the trigger associated with this event, if applicable (e.g., for scheduled events)
Definition tracepoint.h:75
trace_event_t event_type
The type of event being traced (e.g., reaction start, reaction end, etc.)
Definition tracepoint.h:54
interval_t extra_delay
Additional delay specified for the event, if applicable (e.g., for scheduled events)
Definition tracepoint.h:78
instant_t physical_time
The physical time at which the event occurred.
Definition tracepoint.h:72
Trigger struct representing an output, timer, action, or input.
Definition lf_types.h:391
API for the tracing module that records runtime events for debugging and analysis.
Definitions that are needed by both implementors and callers of the trace API regardless of whether t...
instant_t start_time