9c312311 |
1 | /* This file is part of the Linux Trace Toolkit trace reading library |
2 | * Copyright (C) 2003-2004 Michel Dagenais |
1b44b0b5 |
3 | * 2006 Mathieu Desnoyers |
9c312311 |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Lesser General Public |
7 | * License Version 2.1 as published by the Free Software Foundation. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public |
15 | * License along with this library; if not, write to the |
16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | * Boston, MA 02111-1307, USA. |
18 | */ |
19 | |
7c6b3cd7 |
20 | #ifndef EVENT_H |
21 | #define EVENT_H |
22 | |
3aee1200 |
23 | #include <glib.h> |
7c6b3cd7 |
24 | #include <ltt/ltt.h> |
eed2ef37 |
25 | #include <sys/types.h> |
3c165eaf |
26 | #include <ltt/markers.h> |
975e44c7 |
27 | |
c02ea99f |
28 | LttEvent *ltt_event_new(); |
29 | |
30 | void ltt_event_destroy(LttEvent *event); |
31 | |
975e44c7 |
32 | /* Events and their content, including the raw data, are only valid |
33 | until reading another event from the same tracefile. |
34 | Indeed, since event reading is critical to the performance, |
35 | the memory associated with an event may be reused at each read. */ |
36 | |
1b82f325 |
37 | /* Obtain the trace unique integer id associated with the type of |
975e44c7 |
38 | this event */ |
39 | |
3c165eaf |
40 | uint16_t ltt_event_eventtype_id(const LttEvent *e); |
975e44c7 |
41 | |
3c165eaf |
42 | struct marker_info *ltt_event_marker(const LttEvent *e); |
975e44c7 |
43 | |
eed2ef37 |
44 | LttEventType *ltt_event_eventtype(const LttEvent *e); |
975e44c7 |
45 | |
975e44c7 |
46 | /* Time and cycle count for the event */ |
47 | |
eed2ef37 |
48 | LttTime ltt_event_time(const LttEvent *e); |
975e44c7 |
49 | |
eed2ef37 |
50 | LttCycleCount ltt_event_cycle_count(const LttEvent *e); |
975e44c7 |
51 | |
52 | |
80da81ad |
53 | /* Obtain the position of the event within the tracefile. This |
54 | is used to seek back to this position later or to seek to another |
55 | position, computed relative to this position. The event position |
56 | structure is opaque and contains several fields, only two |
57 | of which are user accessible: block number and event index |
58 | within the block. */ |
59 | |
60 | void ltt_event_position(LttEvent *e, LttEventPosition *ep); |
61 | |
a5dcde2f |
62 | LttEventPosition * ltt_event_position_new(); |
63 | |
eed2ef37 |
64 | void ltt_event_position_get(LttEventPosition *ep, LttTracefile **tf, |
65 | guint *block, guint *offset, guint64 *tsc); |
80da81ad |
66 | |
6d0cdf22 |
67 | void ltt_event_position_set(LttEventPosition *ep, LttTracefile *tf, |
68 | guint block, guint offset, guint64 tsc); |
69 | |
96da5c0d |
70 | gint ltt_event_position_compare(const LttEventPosition *ep1, |
71 | const LttEventPosition *ep2); |
80da81ad |
72 | |
2a74fbf4 |
73 | void ltt_event_position_copy(LttEventPosition *dest, |
74 | const LttEventPosition *src); |
75 | |
27304273 |
76 | LttTracefile *ltt_event_position_tracefile(LttEventPosition *ep); |
77 | |
290dfc8c |
78 | /* CPU id of the event */ |
975e44c7 |
79 | |
290dfc8c |
80 | unsigned ltt_event_cpu_id(LttEvent *e); |
975e44c7 |
81 | |
82 | |
83 | /* Pointer to the raw data for the event. This should not be used directly |
84 | unless prepared to do all the architecture specific conversions. */ |
85 | |
290dfc8c |
86 | void *ltt_event_data(LttEvent *e); |
975e44c7 |
87 | |
88 | |
a6bf5e74 |
89 | /* The number of elements in a sequence field is specific to each event |
90 | instance. This function returns the number of elements for an array or |
91 | sequence field in an event. */ |
975e44c7 |
92 | |
3aee1200 |
93 | guint64 ltt_event_field_element_number(LttEvent *e, LttField *f); |
975e44c7 |
94 | |
95 | |
96 | /* Set the currently selected element for a sequence or array field. */ |
97 | |
2312de30 |
98 | LttField *ltt_event_field_element_select(LttEvent *e, LttField *f, gulong i); |
975e44c7 |
99 | |
f2923fb2 |
100 | off_t ltt_event_field_offset(LttEvent *e, LttField *f); |
975e44c7 |
101 | |
a6bf5e74 |
102 | /* A union is like a structure except that only a single member at a time |
103 | is present depending on the specific event instance. This function tells |
104 | the active member for a union field in an event. */ |
105 | |
106 | unsigned ltt_event_field_union_member(LttEvent *e, LttField *f); |
107 | |
108 | |
975e44c7 |
109 | /* These functions extract data from an event after architecture specific |
110 | conversions. */ |
111 | |
63c35f6c |
112 | guint32 ltt_event_get_unsigned(LttEvent *e, LttField *f); |
975e44c7 |
113 | |
63c35f6c |
114 | gint32 ltt_event_get_int(LttEvent *e, LttField *f); |
975e44c7 |
115 | |
63c35f6c |
116 | guint64 ltt_event_get_long_unsigned(LttEvent *e, LttField *f); |
975e44c7 |
117 | |
63c35f6c |
118 | gint64 ltt_event_get_long_int(LttEvent *e, LttField *f); |
975e44c7 |
119 | |
290dfc8c |
120 | float ltt_event_get_float(LttEvent *e, LttField *f); |
975e44c7 |
121 | |
290dfc8c |
122 | double ltt_event_get_double(LttEvent *e, LttField *f); |
975e44c7 |
123 | |
124 | |
125 | /* The string obtained is only valid until the next read from |
126 | the same tracefile. */ |
127 | |
45e14832 |
128 | gchar *ltt_event_get_string(LttEvent *e, LttField *f); |
7c6b3cd7 |
129 | |
743e50fd |
130 | void compute_offsets(LttTracefile *tf, LttFacility *fac, |
131 | LttEventType *event, off_t *offset, void *root); |
eed2ef37 |
132 | |
7c6b3cd7 |
133 | #endif // EVENT_H |