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