1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Xiangxiu Yang
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;
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.
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,
23 #include <sys/types.h>
26 #define LTT_PACKED_STRUCT __attribute__ ((packed))
28 /* enumeration definition */
30 typedef enum _BuildinEvent
{
31 TRACE_FACILITY_LOAD
= 0,
32 TRACE_BLOCK_START
= 17,
34 TRACE_TIME_HEARTBEAT
= 19
38 /* structure definition */
40 typedef struct _FacilityLoad
{
44 } LTT_PACKED_STRUCT FacilityLoad
;
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
;
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
;
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
;
65 char * type_name
; //type name if it is a named type
66 char * element_name
; //elements name of the struct
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
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 int latest_block
; //the latest block using the event type
83 int latest_event
; //the latest event using the event type
87 unsigned field_pos
; //field position within its parent
88 LttType
* field_type
; //field type, if it is root field
89 //then it must be struct type
91 off_t offset_root
; //offset from the root, -1:uninitialized
92 short fixed_root
; //offset fixed according to the root
93 //-1:uninitialized, 0:unfixed, 1:fixed
94 off_t offset_parent
; //offset from the parent,-1:uninitialized
95 short fixed_parent
; //offset fixed according to its parent
96 //-1:uninitialized, 0:unfixed, 1:fixed
97 // void * base_address; //base address of the field ????
99 int field_size
; //>0: size of the field,
102 int sequ_number_size
; //the size of unsigned used to save the
103 //number of elements in the sequence
105 int element_size
; //the element size of the sequence
106 int field_fixed
; //0: field has string or sequence
107 //1: field has no string or sequenc
110 struct _LttField
* parent
;
111 struct _LttField
** child
; //for array, sequence and struct:
112 //list of fields, it may have only one
113 //field if the element is not a struct
114 unsigned current_element
; //which element is currently processed
121 LttCycleCount event_cycle_count
;
122 LttTracefile
* tracefile
;
123 void * data
; //event data
124 int which_block
; //the current block of the event
125 int which_event
; //the position of the event
126 /* This is a workaround for fast position seek */
127 void * last_event_pos
;
129 LttTime prev_block_end_time
; //the end time of previous block
130 LttTime prev_event_time
; //the time of the previous event
131 LttCycleCount pre_cycle_count
; //previous cycle count of the event
132 int count
; //the number of overflow of cycle count
133 /* end of workaround */
137 char * name
; //facility name
138 int event_number
; //number of events in the facility
139 LttChecksum checksum
; //checksum of the facility
140 guint32 base_id
; //base id of the facility
141 LttEventType
** events
; //array of event types
142 LttType
** named_types
;
143 int named_types_number
;
146 struct _LttTracefile
{
147 char * name
; //tracefile name
148 LttTrace
* trace
; //trace containing the tracefile
149 int fd
; //file descriptor
150 off_t file_size
; //file size
151 unsigned block_size
; //block_size
152 int block_number
; //number of blocks in the file
153 int which_block
; //which block the current block is
154 int which_event
; //which event of the current block
155 //is currently processed
156 LttTime current_event_time
; //time of the current event
157 BlockStart
* a_block_start
; //block start of the block
158 BlockEnd
* a_block_end
; //block end of the block
159 void * cur_event_pos
; //the position of the current event
160 void * buffer
; //the buffer containing the block
161 double cycle_per_nsec
; //Cycles per nsec
162 unsigned cur_heart_beat_number
; //current number of heart beat in the buf
163 LttCycleCount cur_cycle_count
; //current cycle count of the event
164 void * last_event_pos
;
166 LttTime prev_block_end_time
; //the end time of previous block
167 LttTime prev_event_time
; //the time of the previous event
169 LttCycleCount pre_cycle_count
; //previous cycle count of the event
170 int count
; //the number of overflow of cycle count
174 char * pathname
; //the pathname of the trace
175 guint facility_number
; //the number of facilities
176 guint control_tracefile_number
; //the number of control files
177 guint per_cpu_tracefile_number
; //the number of per cpu files
178 LttSystemDescription
* system_description
;//system description
180 GPtrArray
*control_tracefiles
; //array of control tracefiles
181 GPtrArray
*per_cpu_tracefiles
; //array of per cpu tracefiles
182 GPtrArray
*facilities
; //array of facilities
183 LttArchSize my_arch_size
; //data size of the local machine
184 LttArchEndian my_arch_endian
; //endian type of the local machine
187 struct _LttEventPosition
{
188 unsigned block_num
; //block which contains the event
189 unsigned event_num
; //event index in the block
190 unsigned event_offset
; //event position in the block
191 LttTime event_time
; //the time of the event
192 LttCycleCount event_cycle_count
; //the cycle count of the event
193 unsigned heart_beat_number
; //current number of heart beats
194 LttTracefile
*tf
; //tracefile containing the event
195 gboolean old_position
; //flag to show if it is the position
197 /* This is a workaround for fast position seek */
198 void * last_event_pos
;
200 LttTime prev_block_end_time
; //the end time of previous block
201 LttTime prev_event_time
; //the time of the previous event
203 LttCycleCount pre_cycle_count
; //previous cycle count of the event
204 int count
; //the number of overflow of cycle count
205 /* end of workaround */
208 /* The characteristics of the system on which the trace was obtained
209 is described in a LttSystemDescription structure. */
211 struct _LttSystemDescription
{
217 LttArchEndian endian
;
219 char *kernel_release
;
220 char *kernel_version
;
223 char *hardware_platform
;
224 char *operating_system
;
225 unsigned ltt_major_version
;
226 unsigned ltt_minor_version
;
227 unsigned ltt_block_size
;
232 /*****************************************************************************
233 macro for size of some data types
234 *****************************************************************************/
235 #define EVENT_ID_SIZE sizeof(guint16)
236 #define TIME_DELTA_SIZE sizeof(guint32)
237 #define EVENT_HEADER_SIZE (EVENT_ID_SIZE + TIME_DELTA_SIZE)
240 #endif /* LTT_PRIVATE_H */