29af7cfd |
1 | #ifndef _LTT_EVENT_H |
2 | #define _LTT_EVENT_H |
7c6b3cd7 |
3 | |
29af7cfd |
4 | #include <ltt/time.h> |
3aee1200 |
5 | #include <glib.h> |
29af7cfd |
6 | #include <stdint.h> |
eed2ef37 |
7 | #include <sys/types.h> |
29af7cfd |
8 | #include <ltt/ltt.h> |
9 | #include <endian.h> |
c37440c8 |
10 | #include <ltt/markers.h> |
975e44c7 |
11 | |
29af7cfd |
12 | /* |
13 | * Structure LttEvent and LttEventPosition must begin with the _exact_ same |
14 | * fields in the exact same order. LttEventPosition is a parent of LttEvent. |
15 | */ |
16 | struct LttEvent { |
17 | /* Begin of LttEventPosition fields */ |
18 | LttTracefile *tracefile; |
19 | unsigned int block; |
20 | unsigned int offset; |
21 | |
22 | /* Timekeeping */ |
23 | uint64_t tsc; /* Current timestamp counter */ |
24 | |
25 | /* End of LttEventPosition fields */ |
26 | guint32 timestamp; /* truncated timestamp */ |
27 | |
28 | guint16 event_id; |
29 | |
30 | LttTime event_time; |
31 | |
32 | void *data; /* event data */ |
33 | guint data_size; |
34 | guint event_size; /* event_size field of the header : |
35 | used to verify data_size from facility. */ |
36 | uint32_t compact_data; |
37 | |
38 | int count; /* the number of overflow of cycle count */ |
39 | gint64 overflow_nsec; /* precalculated nsec for overflows */ |
40 | }; |
41 | |
42 | struct LttEventPosition { |
43 | LttTracefile *tracefile; |
44 | unsigned int block; |
45 | unsigned int offset; |
46 | |
47 | /* Timekeeping */ |
48 | uint64_t tsc; /* Current timestamp counter */ |
49 | }; |
50 | |
51 | static inline guint16 ltt_event_id(struct LttEvent *event) |
52 | { |
53 | return event->event_id; |
54 | } |
55 | |
56 | static inline LttTime ltt_event_time(struct LttEvent *event) |
57 | { |
58 | return event->event_time; |
59 | } |
975e44c7 |
60 | |
80da81ad |
61 | /* Obtain the position of the event within the tracefile. This |
62 | is used to seek back to this position later or to seek to another |
63 | position, computed relative to this position. The event position |
64 | structure is opaque and contains several fields, only two |
65 | of which are user accessible: block number and event index |
66 | within the block. */ |
67 | |
68 | void ltt_event_position(LttEvent *e, LttEventPosition *ep); |
69 | |
a5dcde2f |
70 | LttEventPosition * ltt_event_position_new(); |
71 | |
eed2ef37 |
72 | void ltt_event_position_get(LttEventPosition *ep, LttTracefile **tf, |
73 | guint *block, guint *offset, guint64 *tsc); |
80da81ad |
74 | |
6d0cdf22 |
75 | void ltt_event_position_set(LttEventPosition *ep, LttTracefile *tf, |
76 | guint block, guint offset, guint64 tsc); |
77 | |
96da5c0d |
78 | gint ltt_event_position_compare(const LttEventPosition *ep1, |
79 | const LttEventPosition *ep2); |
80da81ad |
80 | |
2a74fbf4 |
81 | void ltt_event_position_copy(LttEventPosition *dest, |
82 | const LttEventPosition *src); |
83 | |
27304273 |
84 | LttTracefile *ltt_event_position_tracefile(LttEventPosition *ep); |
85 | |
c37440c8 |
86 | /* These functions extract data from an event after architecture specific |
87 | * conversions. */ |
88 | |
89 | guint32 ltt_event_get_unsigned(LttEvent *e, struct marker_field *f); |
90 | |
91 | gint32 ltt_event_get_int(LttEvent *e, struct marker_field *f); |
92 | |
93 | guint64 ltt_event_get_long_unsigned(LttEvent *e, struct marker_field *f); |
94 | |
95 | gint64 ltt_event_get_long_int(LttEvent *e, struct marker_field *f); |
96 | |
97 | float ltt_event_get_float(LttEvent *e, struct marker_field *f); |
98 | |
99 | double ltt_event_get_double(LttEvent *e, struct marker_field *f); |
100 | |
101 | |
102 | /* The string obtained is only valid until the next read from |
103 | * the same tracefile. */ |
104 | |
105 | gchar *ltt_event_get_string(LttEvent *e, struct marker_field *f); |
106 | |
29af7cfd |
107 | #endif //_LTT_EVENT_H |