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