float word order
[lttv.git] / ltt / branches / poly / ltt / 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 #include <endian.h>
26
27
28 #ifndef max
29 #define max(a,b) ((a)>(b)?(a):(b))
30 #endif
31
32
33 #define LTT_MAGIC_NUMBER 0x00D6B7ED
34 #define LTT_REV_MAGIC_NUMBER 0xEDB7D600
35
36 #define NSEC_PER_USEC 1000
37
38 #define LTT_PACKED_STRUCT __attribute__ ((packed))
39
40 /* Hardcoded facilities */
41 #define LTT_FACILITY_CORE 0
42
43 /* Byte ordering */
44 #define LTT_GET_BO(t) ((t)->reverse_bo)
45
46 #define LTT_HAS_FLOAT(t) ((t)->float_word_order!=0)
47 #define LTT_GET_FLOAT_BO(t) \
48 (((t)->float_word_order==__BYTE_ORDER)?0:1)
49
50
51 /* Hardcoded core events */
52 enum ltt_core_events {
53 LTT_EVENT_FACILITY_LOAD,
54 LTT_EVENT_FACILITY_UNLOAD,
55 LTT_EVENT_HEARTBEAT,
56 LTT_EVENT_STATE_DUMP_FACILITY_LOAD
57 };
58
59
60 #if 0
61 /* enumeration definition */
62
63 typedef enum _BuildinEvent{
64 TRACE_FACILITY_LOAD = 0,
65 TRACE_BLOCK_START = 17,
66 TRACE_BLOCK_END = 18,
67 TRACE_TIME_HEARTBEAT= 19
68 } BuildinEvent;
69
70
71 /* structure definition */
72
73 typedef struct _FacilityLoad{
74 gchar * name;
75 LttChecksum checksum;
76 guint32 base_code;
77 } LTT_PACKED_STRUCT FacilityLoad;
78
79 typedef struct _BlockStart {
80 LttTime time; //Time stamp of this block
81 LttCycleCount cycle_count; //cycle count of the event
82 guint32 block_id; //block id
83 } LTT_PACKED_STRUCT BlockStart;
84
85 typedef struct _BlockEnd {
86 LttTime time; //Time stamp of this block
87 LttCycleCount cycle_count; //cycle count of the event
88 guint32 block_id; //block id
89 } LTT_PACKED_STRUCT BlockEnd;
90 #endif //0
91
92
93 typedef guint8 uint8_t;
94 typedef guint16 uint16_t;
95 typedef guint32 uint32_t;
96 typedef guint64 uint64_t;
97
98 /* Hardcoded facility load event : this plus an preceding "name" string */
99 struct LttFacilityLoad {
100 guint32 checksum;
101 guint32 id;
102 guint32 long_size;
103 guint32 pointer_size;
104 guint32 size_t_size;
105 guint32 alignment;
106 } LTT_PACKED_STRUCT;
107
108 struct LttFacilityUnload {
109 guint32 id;
110 } LTT_PACKED_STRUCT;
111
112 struct LttStateDumpFacilityLoad {
113 guint32 checksum;
114 guint32 id;
115 guint32 long_size;
116 guint32 pointer_size;
117 guint32 size_t_size;
118 guint32 alignment;
119 } LTT_PACKED_STRUCT;
120
121 typedef struct _TimeHeartbeat {
122 LttTime time; //Time stamp of this block
123 uint64_t cycle_count; //cycle count of the event
124 } LTT_PACKED_STRUCT TimeHeartbeat;
125
126 struct ltt_event_header_hb {
127 uint32_t timestamp;
128 unsigned char facility_id;
129 unsigned char event_id;
130 uint16_t event_size;
131 } LTT_PACKED_STRUCT;
132
133 struct ltt_event_header_nohb {
134 uint64_t timestamp;
135 unsigned char facility_id;
136 unsigned char event_id;
137 uint16_t event_size;
138 } LTT_PACKED_STRUCT;
139
140 struct ltt_trace_header {
141 uint32_t magic_number;
142 uint32_t arch_type;
143 uint32_t arch_variant;
144 uint32_t float_word_order;
145 uint8_t arch_size;
146 //uint32_t system_type;
147 uint8_t major_version;
148 uint8_t minor_version;
149 uint8_t flight_recorder;
150 uint8_t has_heartbeat;
151 uint8_t has_alignment; /* Event header alignment */
152 uint8_t has_tsc;
153 } LTT_PACKED_STRUCT;
154
155
156 struct ltt_block_start_header {
157 struct {
158 struct timeval timestamp;
159 uint64_t cycle_count;
160 } begin;
161 struct {
162 struct timeval timestamp;
163 uint64_t cycle_count;
164 } end;
165 uint32_t lost_size; /* Size unused at the end of the buffer */
166 uint32_t buf_size; /* The size of this sub-buffer */
167 struct ltt_trace_header trace;
168 } LTT_PACKED_STRUCT;
169
170
171 struct _LttType{
172 GQuark type_name; //type name if it is a named type
173 GQuark element_name; //elements name of the struct
174 gchar * fmt;
175 unsigned int size;
176 LttTypeEnum type_class; //which type
177 GQuark * enum_strings; //for enum labels
178 struct _LttType ** element_type; //for array, sequence and struct
179 unsigned element_number; //the number of elements
180 //for enum, array, sequence and structure
181 };
182
183 struct _LttEventType{
184 GQuark name;
185 gchar * description;
186 guint index; //id of the event type within the facility
187 LttFacility * facility; //the facility that contains the event type
188 LttField * root_field; //root field
189 };
190
191 /* Structure LttEvent and LttEventPosition must begin with the _exact_ same
192 * fields in the exact same order. LttEventPosition is a parent of LttEvent. */
193 struct _LttEvent{
194
195 /* Begin of LttEventPosition fields */
196 LttTracefile *tracefile;
197 unsigned int block;
198 unsigned int offset;
199
200 /* Timekeeping */
201 uint64_t tsc; /* Current timestamp counter */
202
203 /* End of LttEventPosition fields */
204
205 union { /* choice by trace has_tsc */
206 guint32 timestamp; /* truncated timestamp */
207 LttTime delta;
208 } time;
209
210 unsigned char facility_id; /* facility ID are never reused. */
211 unsigned char event_id;
212
213 LttTime event_time;
214
215 void * data; //event data
216 guint data_size;
217 guint event_size; //event_size field of the header :
218 //used to verify data_size from facility.
219
220 int count; //the number of overflow of cycle count
221 gint64 overflow_nsec; //precalculated nsec for overflows
222 };
223
224 struct _LttEventPosition{
225 LttTracefile *tracefile;
226 unsigned int block;
227 unsigned int offset;
228
229 /* Timekeeping */
230 uint64_t tsc; /* Current timestamp counter */
231 };
232
233
234 enum field_status { FIELD_UNKNOWN, FIELD_VARIABLE, FIELD_FIXED };
235
236 struct _LttField{
237 //guint field_pos; //field position within its parent
238 LttType * field_type; //field type, if it is root field
239 //then it must be struct type
240
241 off_t offset_root; //offset from the root, -1:uninitialized
242 enum field_status fixed_root; //offset fixed according to the root
243 //-1:uninitialized, 0:unfixed, 1:fixed
244 off_t offset_parent; //offset from the parent,-1:uninitialized
245 enum field_status fixed_parent; //offset fixed according to its parent
246 //-1:uninitialized, 0:unfixed, 1:fixed
247 // void * base_address; //base address of the field ????
248
249 guint field_size; // //>0: size of the field,
250 // //0 : uncertain
251 // //-1: uninitialize
252 enum field_status fixed_size;
253
254 /* for sequence */
255 gint sequ_number_size; //the size of unsigned used to save the
256 //number of elements in the sequence
257
258 gint element_size; //the element size of the sequence
259 //int field_fixed; //0: field has string or sequence
260 //1: field has no string or sequenc
261 //-1: uninitialize
262
263 struct _LttField * parent;
264 struct _LttField ** child; //for array, sequence, struct and union:
265 //list of fields, it may have only one
266 //field if the element is not a struct or
267 //union
268 unsigned current_element; //which element is currently processed
269 // Used for sequences and arrays.
270 };
271
272
273 struct _LttFacility{
274 LttTrace *trace;
275 //gchar * name; //facility name
276 GQuark name;
277 guint32 checksum; //checksum of the facility
278 guint32 id; //id of the facility
279
280 guint32 pointer_size;
281 guint32 long_size;
282 guint32 size_t_size;
283 guint32 alignment;
284
285
286 //LttEventType ** events; //array of event types
287 //unsigned int event_number; //number of events in the facility
288 //LttType ** named_types;
289 //unsigned int named_types_number;
290
291 GArray *events;
292 GData *events_by_name;
293 // GArray *named_types;
294 //GData *named_types_by_name;
295 GData *named_types;
296
297 unsigned char exists; /* 0 does not exist, 1 exists */
298 };
299
300 typedef struct _LttBuffer {
301 void * head;
302 unsigned int index;
303
304 struct {
305 LttTime timestamp;
306 uint64_t cycle_count;
307 } begin;
308 struct {
309 LttTime timestamp;
310 uint64_t cycle_count;
311 } end;
312 uint32_t lost_size; /* Size unused at the end of the buffer */
313
314 /* Timekeeping */
315 uint64_t tsc; /* Current timestamp counter */
316 double nsecs_per_cycle;
317 } LttBuffer;
318
319 struct _LttTracefile{
320 gboolean cpu_online; //is the cpu online ?
321 GQuark long_name; //tracefile complete filename
322 GQuark name; //tracefile name
323 guint cpu_num; //cpu number of the tracefile
324 LttTrace * trace; //trace containing the tracefile
325 int fd; //file descriptor
326 off_t file_size; //file size
327 //unsigned block_size; //block_size
328 unsigned int num_blocks; //number of blocks in the file
329 gboolean reverse_bo; //must we reverse byte order ?
330 gboolean float_word_order; //what is the byte order of floats ?
331
332 /* Current event */
333 LttEvent event; //Event currently accessible in the trace
334
335 /* Current block */
336 LttBuffer buffer; //current buffer
337 guint32 buf_size; /* The size of blocks */
338
339 /* Time flow */
340 //unsigned int count; //the number of overflow of cycle count
341 //double nsec_per_cycle; //Nsec per cycle
342 //TimeHeartbeat * last_heartbeat; //last heartbeat
343
344 //LttCycleCount cycles_per_nsec_reciprocal; // Optimisation for speed
345 //void * last_event_pos;
346
347 //LttTime prev_block_end_time; //the end time of previous block
348 //LttTime prev_event_time; //the time of the previous event
349 //LttCycleCount pre_cycle_count; //previous cycle count of the event
350 };
351
352 struct _LttTrace{
353 GQuark pathname; //the pathname of the trace
354 //LttSystemDescription * system_description;//system description
355
356 GArray *facilities_by_num; /* fac_id as index in array */
357 GData *facilities_by_name; /* fac name (GQuark) as index */
358 /* Points to array of fac_id of all the
359 * facilities that has this name. */
360 guint num_cpu;
361
362 guint32 arch_type;
363 guint32 arch_variant;
364 guint8 arch_size;
365 guint8 ltt_major_version;
366 guint8 ltt_minor_version;
367 guint8 flight_recorder;
368 guint8 has_heartbeat;
369 guint8 has_alignment;
370 guint8 has_tsc;
371
372 GData *tracefiles; //tracefiles groups
373 };
374
375 /* The characteristics of the system on which the trace was obtained
376 is described in a LttSystemDescription structure. */
377
378 struct _LttSystemDescription {
379 gchar *description;
380 gchar *node_name;
381 gchar *domain_name;
382 unsigned nb_cpu;
383 LttArchSize size;
384 LttArchEndian endian;
385 gchar *kernel_name;
386 gchar *kernel_release;
387 gchar *kernel_version;
388 gchar *machine;
389 gchar *processor;
390 gchar *hardware_platform;
391 gchar *operating_system;
392 LttTime trace_start;
393 LttTime trace_end;
394 };
395
396 /*****************************************************************************
397 macro for size of some data types
398 *****************************************************************************/
399 // alignment -> dynamic!
400
401 //#define TIMESTAMP_SIZE sizeof(guint32)
402 //#define EVENT_ID_SIZE sizeof(guint16)
403 //#define EVENT_HEADER_SIZE (TIMESTAMP_SIZE + EVENT_ID_SIZE)
404
405
406 #endif /* LTT_PRIVATE_H */
This page took 0.037829 seconds and 5 git commands to generate.