7c6b3cd7 |
1 | #ifndef EVENT_H |
2 | #define EVENT_H |
3 | |
4 | #include <ltt/ltt.h> |
975e44c7 |
5 | |
6 | /* Events and their content, including the raw data, are only valid |
7 | until reading another event from the same tracefile. |
8 | Indeed, since event reading is critical to the performance, |
9 | the memory associated with an event may be reused at each read. */ |
10 | |
11 | |
1b82f325 |
12 | /* Obtain the trace unique integer id associated with the type of |
975e44c7 |
13 | this event */ |
14 | |
290dfc8c |
15 | unsigned ltt_event_eventtype_id(LttEvent *e); |
975e44c7 |
16 | |
17 | |
18 | /* Facility and type for the event */ |
19 | |
290dfc8c |
20 | LttFacility *ltt_event_facility(LttEvent *e); |
975e44c7 |
21 | |
290dfc8c |
22 | LttEventType *ltt_event_eventtype(LttEvent *e); |
975e44c7 |
23 | |
1b82f325 |
24 | |
25 | /* Root field for the event */ |
26 | |
290dfc8c |
27 | LttField *ltt_event_field(LttEvent *e); |
975e44c7 |
28 | |
1b82f325 |
29 | |
975e44c7 |
30 | /* Time and cycle count for the event */ |
31 | |
290dfc8c |
32 | LttTime ltt_event_time(LttEvent *e); |
975e44c7 |
33 | |
290dfc8c |
34 | LttCycleCount ltt_event_cycle_count(LttEvent *e); |
975e44c7 |
35 | |
36 | |
80da81ad |
37 | /* Obtain the position of the event within the tracefile. This |
38 | is used to seek back to this position later or to seek to another |
39 | position, computed relative to this position. The event position |
40 | structure is opaque and contains several fields, only two |
41 | of which are user accessible: block number and event index |
42 | within the block. */ |
43 | |
44 | void ltt_event_position(LttEvent *e, LttEventPosition *ep); |
45 | |
46 | void ltt_event_position_get(LttEventPosition *ep, |
fb1a869e |
47 | unsigned *block_number, unsigned *index_in_block, LttTracefile ** tf); |
80da81ad |
48 | |
49 | void ltt_event_position_set(LttEventPosition *ep, |
50 | unsigned block_number, unsigned index_in_block); |
51 | |
52 | |
290dfc8c |
53 | /* CPU id of the event */ |
975e44c7 |
54 | |
290dfc8c |
55 | unsigned ltt_event_cpu_id(LttEvent *e); |
975e44c7 |
56 | |
57 | |
58 | /* Pointer to the raw data for the event. This should not be used directly |
59 | unless prepared to do all the architecture specific conversions. */ |
60 | |
290dfc8c |
61 | void *ltt_event_data(LttEvent *e); |
975e44c7 |
62 | |
63 | |
a6bf5e74 |
64 | /* The number of elements in a sequence field is specific to each event |
65 | instance. This function returns the number of elements for an array or |
66 | sequence field in an event. */ |
975e44c7 |
67 | |
290dfc8c |
68 | unsigned ltt_event_field_element_number(LttEvent *e, LttField *f); |
975e44c7 |
69 | |
70 | |
71 | /* Set the currently selected element for a sequence or array field. */ |
72 | |
290dfc8c |
73 | void ltt_event_field_element_select(LttEvent *e, LttField *f, unsigned i); |
975e44c7 |
74 | |
75 | |
a6bf5e74 |
76 | /* A union is like a structure except that only a single member at a time |
77 | is present depending on the specific event instance. This function tells |
78 | the active member for a union field in an event. */ |
79 | |
80 | unsigned ltt_event_field_union_member(LttEvent *e, LttField *f); |
81 | |
82 | |
975e44c7 |
83 | /* These functions extract data from an event after architecture specific |
84 | conversions. */ |
85 | |
290dfc8c |
86 | unsigned ltt_event_get_unsigned(LttEvent *e, LttField *f); |
975e44c7 |
87 | |
290dfc8c |
88 | int ltt_event_get_int(LttEvent *e, LttField *f); |
975e44c7 |
89 | |
290dfc8c |
90 | unsigned long ltt_event_get_long_unsigned(LttEvent *e, LttField *f); |
975e44c7 |
91 | |
290dfc8c |
92 | long int ltt_event_get_long_int(LttEvent *e, LttField *f); |
975e44c7 |
93 | |
290dfc8c |
94 | float ltt_event_get_float(LttEvent *e, LttField *f); |
975e44c7 |
95 | |
290dfc8c |
96 | double ltt_event_get_double(LttEvent *e, LttField *f); |
975e44c7 |
97 | |
98 | |
99 | /* The string obtained is only valid until the next read from |
100 | the same tracefile. */ |
101 | |
290dfc8c |
102 | char *ltt_event_get_string(LttEvent *e, LttField *f); |
7c6b3cd7 |
103 | |
104 | #endif // EVENT_H |