03d7fdf3 |
1 | /* This file is part of the Linux Trace Toolkit trace reading library |
2 | * Copyright (C) 2003-2004 Michel Dagenais |
3 | * 2006 Mathieu Desnoyers |
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 | |
20 | #ifndef EVENT_H |
21 | #define EVENT_H |
22 | |
23 | #include <glib.h> |
24 | #include <ltt/ltt.h> |
25 | #include <sys/types.h> |
26 | |
27 | LttEvent *ltt_event_new(); |
28 | |
29 | void ltt_event_destroy(LttEvent *event); |
30 | |
31 | /* Events and their content, including the raw data, are only valid |
32 | until reading another event from the same tracefile. |
33 | Indeed, since event reading is critical to the performance, |
34 | the memory associated with an event may be reused at each read. */ |
35 | |
36 | /* Obtain the trace unique integer id associated with the type of |
37 | this event */ |
38 | |
39 | unsigned ltt_event_eventtype_id(const LttEvent *e); |
40 | |
41 | unsigned ltt_event_facility_id(const LttEvent *e); |
42 | |
43 | /* Facility and type for the event */ |
44 | |
45 | LttFacility *ltt_event_facility(const LttEvent *e); |
46 | |
47 | LttEventType *ltt_event_eventtype(const LttEvent *e); |
48 | |
49 | |
50 | |
51 | /* Time and cycle count for the event */ |
52 | |
53 | LttTime ltt_event_time(const LttEvent *e); |
54 | |
55 | LttCycleCount ltt_event_cycle_count(const LttEvent *e); |
56 | |
57 | |
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 | |
67 | LttEventPosition * ltt_event_position_new(); |
68 | |
69 | void ltt_event_position_get(LttEventPosition *ep, LttTracefile **tf, |
70 | guint *block, guint *offset, guint64 *tsc); |
71 | |
72 | void ltt_event_position_set(LttEventPosition *ep, LttTracefile *tf, |
73 | guint block, guint offset, guint64 tsc); |
74 | |
75 | gint ltt_event_position_compare(const LttEventPosition *ep1, |
76 | const LttEventPosition *ep2); |
77 | |
78 | void ltt_event_position_copy(LttEventPosition *dest, |
79 | const LttEventPosition *src); |
80 | |
81 | LttTracefile *ltt_event_position_tracefile(LttEventPosition *ep); |
82 | |
83 | /* CPU id of the event */ |
84 | |
85 | unsigned ltt_event_cpu_id(LttEvent *e); |
86 | |
87 | |
88 | /* Pointer to the raw data for the event. This should not be used directly |
89 | unless prepared to do all the architecture specific conversions. */ |
90 | |
91 | void *ltt_event_data(LttEvent *e); |
92 | |
93 | |
94 | /* The number of elements in a sequence field is specific to each event |
95 | instance. This function returns the number of elements for an array or |
96 | sequence field in an event. */ |
97 | |
98 | guint64 ltt_event_field_element_number(LttEvent *e, LttField *f); |
99 | |
100 | |
101 | /* Set the currently selected element for a sequence or array field. */ |
102 | |
103 | LttField *ltt_event_field_element_select(LttEvent *e, LttField *f, gulong i); |
104 | |
105 | off_t ltt_event_field_offset(LttEvent *e, LttField *f); |
106 | |
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 | |
114 | /* These functions extract data from an event after architecture specific |
115 | conversions. */ |
116 | |
117 | guint32 ltt_event_get_unsigned(LttEvent *e, LttField *f); |
118 | |
119 | gint32 ltt_event_get_int(LttEvent *e, LttField *f); |
120 | |
121 | guint64 ltt_event_get_long_unsigned(LttEvent *e, LttField *f); |
122 | |
123 | gint64 ltt_event_get_long_int(LttEvent *e, LttField *f); |
124 | |
125 | float ltt_event_get_float(LttEvent *e, LttField *f); |
126 | |
127 | double ltt_event_get_double(LttEvent *e, LttField *f); |
128 | |
129 | |
130 | /* The string obtained is only valid until the next read from |
131 | the same tracefile. */ |
132 | |
133 | gchar *ltt_event_get_string(LttEvent *e, LttField *f); |
134 | |
135 | void compute_offsets(LttTracefile *tf, LttFacility *fac, |
136 | LttEventType *event, off_t *offset, void *root); |
137 | |
138 | #endif // EVENT_H |