6 #include <ltt/LTTTypes.h>
10 /* enumeration definition */
12 typedef enum _BuildinEvent
{
13 TRACE_FACILITY_LOAD
= 0,
14 TRACE_BLOCK_START
= 17,
16 TRACE_TIME_HEARTBEAT
= 22
20 /* structure definition */
22 typedef struct _FacilityLoad
{
26 } LTT_PACKED_STRUCT FacilityLoad
;
28 typedef struct _BlockStart
{
29 LttTime time
; //Time stamp of this block
30 LttCycleCount cycle_count
; //cycle count of the event
31 uint32_t block_id
; //block id
32 } LTT_PACKED_STRUCT BlockStart
;
34 typedef struct _BlockEnd
{
35 LttTime time
; //Time stamp of this block
36 LttCycleCount cycle_count
; //cycle count of the event
37 uint32_t block_id
; //block id
38 } LTT_PACKED_STRUCT BlockEnd
;
40 typedef struct _TimeHeartbeat
{
41 LttTime time
; //Time stamp of this block
42 LttCycleCount cycle_count
; //cycle count of the event
43 } LTT_PACKED_STRUCT TimeHeartbeat
;
47 char * element_name
; //elements name of the struct or type name
50 LttTypeEnum type_class
; //which type
51 char ** enum_strings
; //for enum labels
52 struct _LttType
** element_type
; //for array, sequence and struct
53 unsigned element_number
; //the number of elements
54 //for enum, array, sequence and structure
60 int index
; //id of the event type within the facility
61 LttFacility
* facility
; //the facility that contains the event type
62 LttField
* root_field
; //root field
63 int latest_block
; //the latest block using the event type
64 int latest_event
; //the latest event using the event type
68 unsigned field_pos
; //field position within its parent
69 LttType
* field_type
; //field type, if it is root field
70 //then it must be struct type
72 off_t offset_root
; //offset from the root, -1:uninitialized
73 short fixed_root
; //offset fixed according to the root
74 //-1:uninitialized, 0:unfixed, 1:fixed
75 off_t offset_parent
; //offset from the parent,-1:uninitialized
76 short fixed_parent
; //offset fixed according to its parent
77 //-1:uninitialized, 0:unfixed, 1:fixed
78 // void * base_address; //base address of the field ????
80 int field_size
; //>0: size of the field,
83 int element_size
; //the element size of the sequence
84 int field_fixed
; //0: field has string or sequence
85 //1: field has no string or sequenc
88 struct _LttField
* parent
;
89 struct _LttField
** child
; //for array, sequence and struct:
90 //list of fields, it may have only one
91 //field if the element is not a struct
92 unsigned current_element
; //which element is currently processed
99 LttCycleCount event_cycle_count
;
100 LttTracefile
* tracefile
;
101 void * data
; //event data
105 char * name
; //facility name
106 int event_number
; //number of events in the facility
107 LttChecksum checksum
; //checksum of the facility
108 uint32_t base_id
; //base id of the facility
109 LttEventType
** events
; //array of event types
111 //FIXME Specify those types
112 table all_named_types
; //an array of named LttType
113 sequence all_unnamed_types
;//an array of unnamed LttType
114 sequence all_fields
; //an array of fields
117 struct _LttTracefile
{
118 char * name
; //tracefile name
119 LttTrace
* trace
; //trace containing the tracefile
120 int fd
; //file descriptor
121 off_t file_size
; //file size
122 unsigned block_size
; //block_size
123 int block_number
; //number of blocks in the file
124 int which_block
; //which block the current block is
125 int which_event
; //which event of the current block
126 //is currently processed
127 LttTime current_event_time
; //time of the current event
128 BlockStart
* a_block_start
; //block start of the block
129 BlockEnd
* a_block_end
; //block end of the block
130 void * cur_event_pos
; //the position of the current event
131 void * buffer
; //the buffer containing the block
132 double cycle_per_nsec
; //Cycles per nsec
133 unsigned cur_heart_beat_number
; //current number of heart beat in the buf
135 LttTime prev_block_end_time
; //the end time of previous block
136 LttTime prev_event_time
; //the time of the previous event
140 char * pathname
; //the pathname of the trace
141 guint facility_number
; //the number of facilities
142 guint control_tracefile_number
; //the number of control files
143 guint per_cpu_tracefile_number
; //the number of per cpu files
144 LttSystemDescription
* system_description
;//system description
145 GPtrArray
*control_tracefiles
; //array of control tracefiles
146 GPtrArray
*per_cpu_tracefiles
; //array of per cpu tracefiles
147 GPtrArray
*facilities
; //array of facilities
148 LttArchSize my_arch_size
; //data size of the local machine
149 LttArchEndian my_arch_endian
; //endian type of the local machine
153 /*****************************************************************************
154 macro for size of some data types
155 *****************************************************************************/
156 #define EVENT_ID_SIZE sizeof(uint16_t)
157 #define TIME_DELTA_SIZE sizeof(uint32_t)
158 #define EVENT_HEADER_SIZE (EVENT_ID_SIZE + TIME_DELTA_SIZE)
163 /* obtain the time of an event */
164 LttTime
getEventTime(LttTracefile
* tf
);
166 /* get the data type size and endian type of the local machine */
167 void getDataEndianType(LttArchSize
* size
, LttArchEndian
* endian
);
170 void ltt_facility_open(LttTrace
* t
, char * facility_name
);
172 /* get facility by event id */
173 LttFacility
* ltt_trace_facility_by_id(LttTrace
* trace
, unsigned id
);
176 LttTracefile
* ltt_tracefile_open(LttTrace
*t
, char * tracefile_name
);
177 void ltt_tracefile_open_cpu(LttTrace
*t
, char * tracefile_name
);
178 void ltt_tracefile_open_control(LttTrace
*t
, char * control_name
);
181 #endif /* LTT_PRIVATE_H */