10 #define LTT_PACKED_STRUCT __attribute__ ((packed))
12 /* enumeration definition */
14 typedef enum _BuildinEvent
{
15 TRACE_FACILITY_LOAD
= 0,
16 TRACE_BLOCK_START
= 17,
18 TRACE_TIME_HEARTBEAT
= 19
22 /* structure definition */
24 typedef struct _FacilityLoad
{
28 } LTT_PACKED_STRUCT FacilityLoad
;
30 typedef struct _BlockStart
{
31 LttTime time
; //Time stamp of this block
32 LttCycleCount cycle_count
; //cycle count of the event
33 guint32 block_id
; //block id
34 } LTT_PACKED_STRUCT BlockStart
;
36 typedef struct _BlockEnd
{
37 LttTime time
; //Time stamp of this block
38 LttCycleCount cycle_count
; //cycle count of the event
39 guint32 block_id
; //block id
40 } LTT_PACKED_STRUCT BlockEnd
;
42 typedef struct _TimeHeartbeat
{
43 LttTime time
; //Time stamp of this block
44 LttCycleCount cycle_count
; //cycle count of the event
45 } LTT_PACKED_STRUCT TimeHeartbeat
;
49 char * type_name
; //type name if it is a named type
50 char * element_name
; //elements name of the struct
53 LttTypeEnum type_class
; //which type
54 char ** enum_strings
; //for enum labels
55 struct _LttType
** element_type
; //for array, sequence and struct
56 unsigned element_number
; //the number of elements
57 //for enum, array, sequence and structure
63 int index
; //id of the event type within the facility
64 LttFacility
* facility
; //the facility that contains the event type
65 LttField
* root_field
; //root field
66 int latest_block
; //the latest block using the event type
67 int latest_event
; //the latest event using the event type
71 unsigned field_pos
; //field position within its parent
72 LttType
* field_type
; //field type, if it is root field
73 //then it must be struct type
75 off_t offset_root
; //offset from the root, -1:uninitialized
76 short fixed_root
; //offset fixed according to the root
77 //-1:uninitialized, 0:unfixed, 1:fixed
78 off_t offset_parent
; //offset from the parent,-1:uninitialized
79 short fixed_parent
; //offset fixed according to its parent
80 //-1:uninitialized, 0:unfixed, 1:fixed
81 // void * base_address; //base address of the field ????
83 int field_size
; //>0: size of the field,
86 int sequ_number_size
; //the size of unsigned used to save the
87 //number of elements in the sequence
89 int element_size
; //the element size of the sequence
90 int field_fixed
; //0: field has string or sequence
91 //1: field has no string or sequenc
94 struct _LttField
* parent
;
95 struct _LttField
** child
; //for array, sequence and struct:
96 //list of fields, it may have only one
97 //field if the element is not a struct
98 unsigned current_element
; //which element is currently processed
105 LttCycleCount event_cycle_count
;
106 LttTracefile
* tracefile
;
107 void * data
; //event data
108 int which_block
; //the current block of the event
109 int which_event
; //the position of the event
113 char * name
; //facility name
114 int event_number
; //number of events in the facility
115 LttChecksum checksum
; //checksum of the facility
116 guint32 base_id
; //base id of the facility
117 LttEventType
** events
; //array of event types
118 LttType
** named_types
;
119 int named_types_number
;
122 struct _LttTracefile
{
123 char * name
; //tracefile name
124 LttTrace
* trace
; //trace containing the tracefile
125 int fd
; //file descriptor
126 off_t file_size
; //file size
127 unsigned block_size
; //block_size
128 int block_number
; //number of blocks in the file
129 int which_block
; //which block the current block is
130 int which_event
; //which event of the current block
131 //is currently processed
132 LttTime current_event_time
; //time of the current event
133 BlockStart
* a_block_start
; //block start of the block
134 BlockEnd
* a_block_end
; //block end of the block
135 void * cur_event_pos
; //the position of the current event
136 void * buffer
; //the buffer containing the block
137 double cycle_per_nsec
; //Cycles per nsec
138 unsigned cur_heart_beat_number
; //current number of heart beat in the buf
139 LttCycleCount cur_cycle_count
; //current cycle count of the event
140 void * last_event_pos
;
142 LttTime prev_block_end_time
; //the end time of previous block
143 LttTime prev_event_time
; //the time of the previous event
148 char * pathname
; //the pathname of the trace
149 guint facility_number
; //the number of facilities
150 guint control_tracefile_number
; //the number of control files
151 guint per_cpu_tracefile_number
; //the number of per cpu files
152 LttSystemDescription
* system_description
;//system description
154 GPtrArray
*control_tracefiles
; //array of control tracefiles
155 GPtrArray
*per_cpu_tracefiles
; //array of per cpu tracefiles
156 GPtrArray
*facilities
; //array of facilities
157 LttArchSize my_arch_size
; //data size of the local machine
158 LttArchEndian my_arch_endian
; //endian type of the local machine
161 struct _LttEventPosition
{
162 unsigned block_num
; //block which contains the event
163 unsigned event_num
; //event index in the block
164 unsigned event_offset
; //event position in the block
165 LttTime event_time
; //the time of the event
166 LttCycleCount event_cycle_count
; //the cycle count of the event
167 unsigned heart_beat_number
; //current number of heart beats
168 LttTracefile
*tf
; //tracefile containing the event
169 gboolean old_position
; //flag to show if it is the position
173 /*****************************************************************************
174 macro for size of some data types
175 *****************************************************************************/
176 #define EVENT_ID_SIZE sizeof(guint16)
177 #define TIME_DELTA_SIZE sizeof(guint32)
178 #define EVENT_HEADER_SIZE (EVENT_ID_SIZE + TIME_DELTA_SIZE)
183 /* obtain the time of an event */
184 LttTime
getEventTime(LttTracefile
* tf
);
186 /* get the data type size and endian type of the local machine */
187 void getDataEndianType(LttArchSize
* size
, LttArchEndian
* endian
);
189 /* get an integer number */
190 int getIntNumber(int size1
, void *evD
);
193 void ltt_facility_open(LttTrace
* t
, char * facility_name
);
195 /* get facility by event id */
196 LttFacility
* ltt_trace_facility_by_id(LttTrace
* trace
, unsigned id
);
199 LttTracefile
* ltt_tracefile_open(LttTrace
*t
, char * tracefile_name
);
200 void ltt_tracefile_open_cpu(LttTrace
*t
, char * tracefile_name
);
201 void ltt_tracefile_open_control(LttTrace
*t
, char * control_name
);
204 #endif /* LTT_PRIVATE_H */