fixed substraction from start cycle counter : end and start times between blocs 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
cbd41522 26#define LTT_PACKED_STRUCT __attribute__ ((packed))
27
e3247aa5 28/* enumeration definition */
29
30typedef enum _BuildinEvent{
31 TRACE_FACILITY_LOAD = 0,
32 TRACE_BLOCK_START = 17,
33 TRACE_BLOCK_END = 18,
0d7aac52 34 TRACE_TIME_HEARTBEAT= 19
e3247aa5 35} BuildinEvent;
fcdf0ec2 36
7c6b3cd7 37
38/* structure definition */
39
e3247aa5 40typedef struct _FacilityLoad{
41 char * name;
42 LttChecksum checksum;
cbd41522 43 guint32 base_code;
e3247aa5 44} LTT_PACKED_STRUCT FacilityLoad;
45
46typedef struct _BlockStart {
47 LttTime time; //Time stamp of this block
48 LttCycleCount cycle_count; //cycle count of the event
cbd41522 49 guint32 block_id; //block id
e3247aa5 50} LTT_PACKED_STRUCT BlockStart;
51
52typedef struct _BlockEnd {
53 LttTime time; //Time stamp of this block
54 LttCycleCount cycle_count; //cycle count of the event
cbd41522 55 guint32 block_id; //block id
e3247aa5 56} LTT_PACKED_STRUCT BlockEnd;
57
58typedef 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
64struct _LttType{
0d7aac52 65 char * type_name; //type name if it is a named type
66 char * element_name; //elements name of the struct
7c6b3cd7 67 char * fmt;
8d1e6362 68 unsigned int size;
e3247aa5 69 LttTypeEnum type_class; //which type
70 char ** 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
7c6b3cd7 74};
75
e3247aa5 76struct _LttEventType{
7c6b3cd7 77 char * name;
78 char * description;
e3247aa5 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
8d1e6362 82 unsigned int latest_block; //the latest block using the event type
83 unsigned int latest_event; //the latest event using the event type
7c6b3cd7 84};
85
c02ea99f 86struct _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
8d1e6362 93 unsigned int which_block; //the current block of the event
94 unsigned int which_event; //the position of the event
c02ea99f 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 /* end of workaround */
103};
104
105
e3247aa5 106struct _LttField{
7c6b3cd7 107 unsigned field_pos; //field position within its parent
e3247aa5 108 LttType * field_type; //field type, if it is root field
7c6b3cd7 109 //then it must be struct type
110
111 off_t offset_root; //offset from the root, -1:uninitialized
112 short fixed_root; //offset fixed according to the root
113 //-1:uninitialized, 0:unfixed, 1:fixed
114 off_t offset_parent; //offset from the parent,-1:uninitialized
115 short fixed_parent; //offset fixed according to its parent
116 //-1:uninitialized, 0:unfixed, 1:fixed
117 // void * base_address; //base address of the field ????
118
119 int field_size; //>0: size of the field,
120 //0 : uncertain
121 //-1: uninitialize
0d7aac52 122 int sequ_number_size; //the size of unsigned used to save the
123 //number of elements in the sequence
124
7c6b3cd7 125 int element_size; //the element size of the sequence
126 int field_fixed; //0: field has string or sequence
127 //1: field has no string or sequenc
128 //-1: uninitialize
129
e3247aa5 130 struct _LttField * parent;
131 struct _LttField ** child; //for array, sequence and struct:
7c6b3cd7 132 //list of fields, it may have only one
133 //field if the element is not a struct
134 unsigned current_element; //which element is currently processed
135};
136
7c6b3cd7 137
e3247aa5 138struct _LttFacility{
7c6b3cd7 139 char * name; //facility name
8d1e6362 140 unsigned int event_number; //number of events in the facility
e3247aa5 141 LttChecksum checksum; //checksum of the facility
cbd41522 142 guint32 base_id; //base id of the facility
e3247aa5 143 LttEventType ** events; //array of event types
36921b4e 144 LttType ** named_types;
8d1e6362 145 unsigned int named_types_number;
7c6b3cd7 146};
147
e3247aa5 148struct _LttTracefile{
149 char * name; //tracefile name
150 LttTrace * trace; //trace containing the tracefile
151 int fd; //file descriptor
152 off_t file_size; //file size
153 unsigned block_size; //block_size
8d1e6362 154 unsigned int block_number; //number of blocks in the file
155 unsigned int which_block; //which block the current block is
156 unsigned int which_event; //which event of the current block
e3247aa5 157 //is currently processed
158 LttTime current_event_time; //time of the current event
159 BlockStart * a_block_start; //block start of the block
160 BlockEnd * a_block_end; //block end of the block
161 void * cur_event_pos; //the position of the current event
162 void * buffer; //the buffer containing the block
887208b7 163 double nsec_per_cycle; //Nsec per cycle
164 //LttCycleCount cycles_per_nsec_reciprocal; // Optimisation for speed
e3247aa5 165 unsigned cur_heart_beat_number; //current number of heart beat in the buf
fb1a869e 166 LttCycleCount cur_cycle_count; //current cycle count of the event
e37c1372 167 void * last_event_pos;
e3247aa5 168
169 LttTime prev_block_end_time; //the end time of previous block
170 LttTime prev_event_time; //the time of the previous event
dd691a2e 171 LttCycleCount pre_cycle_count; //previous cycle count of the event
8d1e6362 172 unsigned int count; //the number of overflow of cycle count
7c6b3cd7 173};
174
e3247aa5 175struct _LttTrace{
176 char * pathname; //the pathname of the trace
177 guint facility_number; //the number of facilities
178 guint control_tracefile_number; //the number of control files
179 guint per_cpu_tracefile_number; //the number of per cpu files
180 LttSystemDescription * system_description;//system description
80da81ad 181
e3247aa5 182 GPtrArray *control_tracefiles; //array of control tracefiles
183 GPtrArray *per_cpu_tracefiles; //array of per cpu tracefiles
184 GPtrArray *facilities; //array of facilities
185 LttArchSize my_arch_size; //data size of the local machine
186 LttArchEndian my_arch_endian; //endian type of the local machine
187};
7c6b3cd7 188
80da81ad 189struct _LttEventPosition{
190 unsigned block_num; //block which contains the event
191 unsigned event_num; //event index in the block
192 unsigned event_offset; //event position in the block
193 LttTime event_time; //the time of the event
194 LttCycleCount event_cycle_count; //the cycle count of the event
195 unsigned heart_beat_number; //current number of heart beats
fb1a869e 196 LttTracefile *tf; //tracefile containing the event
80da81ad 197 gboolean old_position; //flag to show if it is the position
198 //being remembered
18206708 199 /* This is a workaround for fast position seek */
200 void * last_event_pos;
201
202 LttTime prev_block_end_time; //the end time of previous block
203 LttTime prev_event_time; //the time of the previous event
18206708 204 LttCycleCount pre_cycle_count; //previous cycle count of the event
205 int count; //the number of overflow of cycle count
206 /* end of workaround */
80da81ad 207};
7c6b3cd7 208
a5dcde2f 209/* The characteristics of the system on which the trace was obtained
210 is described in a LttSystemDescription structure. */
211
212struct _LttSystemDescription {
213 char *description;
214 char *node_name;
215 char *domain_name;
216 unsigned nb_cpu;
217 LttArchSize size;
218 LttArchEndian endian;
219 char *kernel_name;
220 char *kernel_release;
221 char *kernel_version;
222 char *machine;
223 char *processor;
224 char *hardware_platform;
225 char *operating_system;
226 unsigned ltt_major_version;
227 unsigned ltt_minor_version;
228 unsigned ltt_block_size;
229 LttTime trace_start;
230 LttTime trace_end;
231};
232
7c6b3cd7 233/*****************************************************************************
234 macro for size of some data types
235 *****************************************************************************/
cbd41522 236#define EVENT_ID_SIZE sizeof(guint16)
237#define TIME_DELTA_SIZE sizeof(guint32)
e3247aa5 238#define EVENT_HEADER_SIZE (EVENT_ID_SIZE + TIME_DELTA_SIZE)
7c6b3cd7 239
240
fcdf0ec2 241#endif /* LTT_PRIVATE_H */
This page took 0.039607 seconds and 4 git commands to generate.