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