Filter for selecting trace and tracefile
[lttv.git] / ltt / branches / poly / include / ltt / ltt-private.h
1 #ifndef LTT_PRIVATE_H
2 #define LTT_PRIVATE_H
3
4 #include <glib.h>
5 #include <sys/types.h>
6 #include <ltt/ltt.h>
7 #include <ltt/type.h>
8 #include <ltt/trace.h>
9
10 #define LTT_PACKED_STRUCT __attribute__ ((packed))
11
12 /* enumeration definition */
13
14 typedef enum _BuildinEvent{
15 TRACE_FACILITY_LOAD = 0,
16 TRACE_BLOCK_START = 17,
17 TRACE_BLOCK_END = 18,
18 TRACE_TIME_HEARTBEAT= 19
19 } BuildinEvent;
20
21
22 /* structure definition */
23
24 typedef struct _FacilityLoad{
25 char * name;
26 LttChecksum checksum;
27 guint32 base_code;
28 } LTT_PACKED_STRUCT FacilityLoad;
29
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;
35
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;
41
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;
46
47
48 struct _LttType{
49 char * type_name; //type name if it is a named type
50 char * element_name; //elements name of the struct
51 char * fmt;
52 int size;
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
58 };
59
60 struct _LttEventType{
61 char * name;
62 char * description;
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
68 };
69
70 struct _LttField{
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
74
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 ????
82
83 int field_size; //>0: size of the field,
84 //0 : uncertain
85 //-1: uninitialize
86 int sequ_number_size; //the size of unsigned used to save the
87 //number of elements in the sequence
88
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
92 //-1: uninitialize
93
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
99 };
100
101 struct _LttEvent{
102 guint16 event_id;
103 guint32 time_delta;
104 LttTime event_time;
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
110 };
111
112 struct _LttFacility{
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;
120 };
121
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;
141
142 LttTime prev_block_end_time; //the end time of previous block
143 LttTime prev_event_time; //the time of the previous event
144 LttEvent an_event;
145 };
146
147 struct _LttTrace{
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
153
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
159 };
160
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
170 //being remembered
171 };
172
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)
179
180
181
182
183 /* obtain the time of an event */
184 LttTime getEventTime(LttTracefile * tf);
185
186 /* get the data type size and endian type of the local machine */
187 void getDataEndianType(LttArchSize * size, LttArchEndian * endian);
188
189 /* get an integer number */
190 int getIntNumber(int size1, void *evD);
191
192 /* open facility */
193 void ltt_facility_open(LttTrace * t, char * facility_name);
194
195 /* get facility by event id */
196 LttFacility * ltt_trace_facility_by_id(LttTrace * trace, unsigned id);
197
198 /* open tracefile */
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);
202
203
204 #endif /* LTT_PRIVATE_H */
This page took 0.03376 seconds and 4 git commands to generate.