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