lttv and lib ltt new compiles
[lttv.git] / ltt / branches / poly / ltt-oldlib / ltt-private.h
1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Xiangxiu Yang
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program 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
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16 * MA 02111-1307, USA.
17 */
18
19 #ifndef LTT_PRIVATE_H
20 #define LTT_PRIVATE_H
21
22 #include <glib.h>
23 #include <sys/types.h>
24 #include <ltt/ltt.h>
25
26 #define LTT_PACKED_STRUCT __attribute__ ((packed))
27
28 /* enumeration definition */
29
30 typedef enum _BuildinEvent{
31 TRACE_FACILITY_LOAD = 0,
32 TRACE_BLOCK_START = 17,
33 TRACE_BLOCK_END = 18,
34 TRACE_TIME_HEARTBEAT= 19
35 } BuildinEvent;
36
37
38 /* structure definition */
39
40 typedef struct _FacilityLoad{
41 gchar * name;
42 LttChecksum checksum;
43 guint32 base_code;
44 } LTT_PACKED_STRUCT FacilityLoad;
45
46 typedef struct _BlockStart {
47 LttTime time; //Time stamp of this block
48 LttCycleCount cycle_count; //cycle count of the event
49 guint32 block_id; //block id
50 } LTT_PACKED_STRUCT BlockStart;
51
52 typedef struct _BlockEnd {
53 LttTime time; //Time stamp of this block
54 LttCycleCount cycle_count; //cycle count of the event
55 guint32 block_id; //block id
56 } LTT_PACKED_STRUCT BlockEnd;
57
58 typedef struct _TimeHeartbeat {
59 LttTime time; //Time stamp of this block
60 LttCycleCount cycle_count; //cycle count of the event
61 } LTT_PACKED_STRUCT TimeHeartbeat;
62
63
64 struct _LttType{
65 gchar * type_name; //type name if it is a named type
66 gchar * element_name; //elements name of the struct
67 gchar * fmt;
68 unsigned int size;
69 LttTypeEnum type_class; //which type
70 gchar ** enum_strings; //for enum labels
71 struct _LttType ** element_type; //for array, sequence and struct
72 unsigned element_number; //the number of elements
73 //for enum, array, sequence and structure
74 };
75
76 struct _LttEventType{
77 gchar * name;
78 gchar * description;
79 int index; //id of the event type within the facility
80 LttFacility * facility; //the facility that contains the event type
81 LttField * root_field; //root field
82 unsigned int latest_block; //the latest block using the event type
83 unsigned int latest_event; //the latest event using the event type
84 };
85
86 struct _LttEvent{
87 guint16 event_id;
88 guint32 time_delta;
89 LttTime event_time;
90 LttCycleCount event_cycle_count;
91 LttTracefile * tracefile;
92 void * data; //event data
93 unsigned int which_block; //the current block of the event
94 unsigned int which_event; //the position of the event
95 /* This is a workaround for fast position seek */
96 void * last_event_pos;
97
98 LttTime prev_block_end_time; //the end time of previous block
99 LttTime prev_event_time; //the time of the previous event
100 LttCycleCount pre_cycle_count; //previous cycle count of the event
101 int count; //the number of overflow of cycle count
102 gint64 overflow_nsec; //precalculated nsec for overflows
103 TimeHeartbeat * last_heartbeat; //last heartbeat
104
105 /* end of workaround */
106 };
107
108
109 struct _LttField{
110 unsigned field_pos; //field position within its parent
111 LttType * field_type; //field type, if it is root field
112 //then it must be struct type
113
114 off_t offset_root; //offset from the root, -1:uninitialized
115 short fixed_root; //offset fixed according to the root
116 //-1:uninitialized, 0:unfixed, 1:fixed
117 off_t offset_parent; //offset from the parent,-1:uninitialized
118 short fixed_parent; //offset fixed according to its parent
119 //-1:uninitialized, 0:unfixed, 1:fixed
120 // void * base_address; //base address of the field ????
121
122 int field_size; //>0: size of the field,
123 //0 : uncertain
124 //-1: uninitialize
125 int sequ_number_size; //the size of unsigned used to save the
126 //number of elements in the sequence
127
128 int element_size; //the element size of the sequence
129 int field_fixed; //0: field has string or sequence
130 //1: field has no string or sequenc
131 //-1: uninitialize
132
133 struct _LttField * parent;
134 struct _LttField ** child; //for array, sequence and struct:
135 //list of fields, it may have only one
136 //field if the element is not a struct
137 unsigned current_element; //which element is currently processed
138 };
139
140
141 struct _LttFacility{
142 gchar * name; //facility name
143 unsigned int event_number; //number of events in the facility
144 LttChecksum checksum; //checksum of the facility
145 guint32 base_id; //base id of the facility
146 LttEventType ** events; //array of event types
147 LttType ** named_types;
148 unsigned int named_types_number;
149 };
150
151 struct _LttTracefile{
152 gchar * name; //tracefile name
153 LttTrace * trace; //trace containing the tracefile
154 int fd; //file descriptor
155 off_t file_size; //file size
156 unsigned block_size; //block_size
157 unsigned int block_number; //number of blocks in the file
158 unsigned int which_block; //which block the current block is
159 unsigned int which_event; //which event of the current block
160 //is currently processed
161 LttTime current_event_time; //time of the current event
162 BlockStart * a_block_start; //block start of the block- trace endian
163 BlockEnd * a_block_end; //block end of the block - trace endian
164 TimeHeartbeat * last_heartbeat; //last heartbeat
165 void * cur_event_pos; //the position of the current event
166 void * buffer; //the buffer containing the block
167 double nsec_per_cycle; //Nsec per cycle
168 guint64 one_overflow_nsec; //nsec for one overflow
169 gint64 overflow_nsec; //precalculated nsec for overflows
170 //can be negative to include value
171 //of block start cycle count.
172 //incremented at each overflow while
173 //reading.
174 //LttCycleCount cycles_per_nsec_reciprocal; // Optimisation for speed
175 unsigned cur_heart_beat_number; //current number of heart beat in the buf
176 LttCycleCount cur_cycle_count; //current cycle count of the event
177 void * last_event_pos;
178
179 LttTime prev_block_end_time; //the end time of previous block
180 LttTime prev_event_time; //the time of the previous event
181 LttCycleCount pre_cycle_count; //previous cycle count of the event
182 unsigned int count; //the number of overflow of cycle count
183 };
184
185 struct _LttTrace{
186 gchar * pathname; //the pathname of the trace
187 guint facility_number; //the number of facilities
188 guint control_tracefile_number; //the number of control files
189 guint per_cpu_tracefile_number; //the number of per cpu files
190 LttSystemDescription * system_description;//system description
191
192 GPtrArray *control_tracefiles; //array of control tracefiles
193 GPtrArray *per_cpu_tracefiles; //array of per cpu tracefiles
194 GPtrArray *facilities; //array of facilities
195 gboolean reverse_byte_order; //must we reverse BO ?
196 };
197
198 struct _LttEventPosition{
199 unsigned block_num; //block which contains the event
200 unsigned event_num; //event index in the block
201 unsigned event_offset; //event position in the block
202 LttTime event_time; //the time of the event
203 LttCycleCount event_cycle_count; //the cycle count of the event
204 unsigned heart_beat_number; //current number of heart beats
205 LttTracefile *tf; //tracefile containing the event
206 gboolean old_position; //flag to show if it is the position
207 //being remembered
208 /* This is a workaround for fast position seek */
209 void * last_event_pos;
210
211 LttTime prev_block_end_time; //the end time of previous block
212 LttTime prev_event_time; //the time of the previous event
213 LttCycleCount pre_cycle_count; //previous cycle count of the event
214 int count; //the number of overflow of cycle count
215 gint64 overflow_nsec; //precalculated nsec for overflows
216 TimeHeartbeat * last_heartbeat; //last heartbeat
217 /* end of workaround */
218 };
219
220 /* The characteristics of the system on which the trace was obtained
221 is described in a LttSystemDescription structure. */
222
223 struct _LttSystemDescription {
224 gchar *description;
225 gchar *node_name;
226 gchar *domain_name;
227 unsigned nb_cpu;
228 LttArchSize size;
229 LttArchEndian endian;
230 gchar *kernel_name;
231 gchar *kernel_release;
232 gchar *kernel_version;
233 gchar *machine;
234 gchar *processor;
235 gchar *hardware_platform;
236 gchar *operating_system;
237 unsigned ltt_major_version;
238 unsigned ltt_minor_version;
239 unsigned ltt_block_size;
240 LttTime trace_start;
241 LttTime trace_end;
242 };
243
244 /*****************************************************************************
245 macro for size of some data types
246 *****************************************************************************/
247 #define EVENT_ID_SIZE sizeof(guint16)
248 #define TIME_DELTA_SIZE sizeof(guint32)
249 #define EVENT_HEADER_SIZE (EVENT_ID_SIZE + TIME_DELTA_SIZE)
250
251
252 #endif /* LTT_PRIVATE_H */
This page took 0.038227 seconds and 4 git commands to generate.