new LttEventPosition structure for backword seeking
[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 <ltt/ltt.h>
6 #include <ltt/LTTTypes.h>
7 #include <ltt/type.h>
8 #include <ltt/trace.h>
9
10 /* enumeration definition */
11
12 typedef enum _BuildinEvent{
13 TRACE_FACILITY_LOAD = 0,
14 TRACE_BLOCK_START = 17,
15 TRACE_BLOCK_END = 18,
16 TRACE_TIME_HEARTBEAT= 19
17 } BuildinEvent;
18
19
20 /* structure definition */
21
22 typedef struct _FacilityLoad{
23 char * name;
24 LttChecksum checksum;
25 uint32_t base_code;
26 } LTT_PACKED_STRUCT FacilityLoad;
27
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;
33
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;
39
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;
44
45
46 struct _LttType{
47 char * type_name; //type name if it is a named type
48 char * element_name; //elements name of the struct
49 char * fmt;
50 int size;
51 LttTypeEnum type_class; //which type
52 char ** enum_strings; //for enum labels
53 struct _LttType ** element_type; //for array, sequence and struct
54 unsigned element_number; //the number of elements
55 //for enum, array, sequence and structure
56 };
57
58 struct _LttEventType{
59 char * name;
60 char * description;
61 int index; //id of the event type within the facility
62 LttFacility * facility; //the facility that contains the event type
63 LttField * root_field; //root field
64 int latest_block; //the latest block using the event type
65 int latest_event; //the latest event using the event type
66 };
67
68 struct _LttField{
69 unsigned field_pos; //field position within its parent
70 LttType * field_type; //field type, if it is root field
71 //then it must be struct type
72
73 off_t offset_root; //offset from the root, -1:uninitialized
74 short fixed_root; //offset fixed according to the root
75 //-1:uninitialized, 0:unfixed, 1:fixed
76 off_t offset_parent; //offset from the parent,-1:uninitialized
77 short fixed_parent; //offset fixed according to its parent
78 //-1:uninitialized, 0:unfixed, 1:fixed
79 // void * base_address; //base address of the field ????
80
81 int field_size; //>0: size of the field,
82 //0 : uncertain
83 //-1: uninitialize
84 int sequ_number_size; //the size of unsigned used to save the
85 //number of elements in the sequence
86
87 int element_size; //the element size of the sequence
88 int field_fixed; //0: field has string or sequence
89 //1: field has no string or sequenc
90 //-1: uninitialize
91
92 struct _LttField * parent;
93 struct _LttField ** child; //for array, sequence and struct:
94 //list of fields, it may have only one
95 //field if the element is not a struct
96 unsigned current_element; //which element is currently processed
97 };
98
99 struct _LttEvent{
100 uint16_t event_id;
101 uint32_t time_delta;
102 LttTime event_time;
103 LttCycleCount event_cycle_count;
104 LttTracefile * tracefile;
105 void * data; //event data
106 int which_block; //the current block of the event
107 int which_event; //the position of the event
108 };
109
110 struct _LttFacility{
111 char * name; //facility name
112 int event_number; //number of events in the facility
113 LttChecksum checksum; //checksum of the facility
114 uint32_t base_id; //base id of the facility
115 LttEventType ** events; //array of event types
116 LttType ** named_types;
117 int named_types_number;
118 };
119
120 struct _LttTracefile{
121 char * name; //tracefile name
122 LttTrace * trace; //trace containing the tracefile
123 int fd; //file descriptor
124 off_t file_size; //file size
125 unsigned block_size; //block_size
126 int block_number; //number of blocks in the file
127 int which_block; //which block the current block is
128 int which_event; //which event of the current block
129 //is currently processed
130 LttTime current_event_time; //time of the current event
131 BlockStart * a_block_start; //block start of the block
132 BlockEnd * a_block_end; //block end of the block
133 void * cur_event_pos; //the position of the current event
134 void * buffer; //the buffer containing the block
135 double cycle_per_nsec; //Cycles per nsec
136 unsigned cur_heart_beat_number; //current number of heart beat in the buf
137
138 LttTime prev_block_end_time; //the end time of previous block
139 LttTime prev_event_time; //the time of the previous event
140 LttEvent an_event;
141 };
142
143 struct _LttTrace{
144 char * pathname; //the pathname of the trace
145 guint facility_number; //the number of facilities
146 guint control_tracefile_number; //the number of control files
147 guint per_cpu_tracefile_number; //the number of per cpu files
148 LttSystemDescription * system_description;//system description
149
150 GPtrArray *control_tracefiles; //array of control tracefiles
151 GPtrArray *per_cpu_tracefiles; //array of per cpu tracefiles
152 GPtrArray *facilities; //array of facilities
153 LttArchSize my_arch_size; //data size of the local machine
154 LttArchEndian my_arch_endian; //endian type of the local machine
155 };
156
157 struct _LttEventPosition{
158 unsigned block_num; //block which contains the event
159 unsigned event_num; //event index in the block
160 unsigned event_offset; //event position in the block
161 LttTime event_time; //the time of the event
162 LttCycleCount event_cycle_count; //the cycle count of the event
163 unsigned heart_beat_number; //current number of heart beats
164 gboolean old_position; //flag to show if it is the position
165 //being remembered
166 };
167
168 /*****************************************************************************
169 macro for size of some data types
170 *****************************************************************************/
171 #define EVENT_ID_SIZE sizeof(uint16_t)
172 #define TIME_DELTA_SIZE sizeof(uint32_t)
173 #define EVENT_HEADER_SIZE (EVENT_ID_SIZE + TIME_DELTA_SIZE)
174
175
176
177
178 /* obtain the time of an event */
179 LttTime getEventTime(LttTracefile * tf);
180
181 /* get the data type size and endian type of the local machine */
182 void getDataEndianType(LttArchSize * size, LttArchEndian * endian);
183
184 /* get an integer number */
185 int getIntNumber(int size1, void *evD);
186
187 /* open facility */
188 void ltt_facility_open(LttTrace * t, char * facility_name);
189
190 /* get facility by event id */
191 LttFacility * ltt_trace_facility_by_id(LttTrace * trace, unsigned id);
192
193 /* open tracefile */
194 LttTracefile * ltt_tracefile_open(LttTrace *t, char * tracefile_name);
195 void ltt_tracefile_open_cpu(LttTrace *t, char * tracefile_name);
196 void ltt_tracefile_open_control(LttTrace *t, char * control_name);
197
198
199 #endif /* LTT_PRIVATE_H */
This page took 0.03291 seconds and 4 git commands to generate.