fcdf0ec2 |
1 | #ifndef LTT_PRIVATE_H |
2 | #define LTT_PRIVATE_H |
3 | |
858bd80a |
4 | #include <glib.h> |
fcdf0ec2 |
5 | #include <ltt/ltt.h> |
6 | #include <ltt/LTTTypes.h> |
7 | #include <ltt/type.h> |
e3247aa5 |
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= 22 |
17 | } BuildinEvent; |
fcdf0ec2 |
18 | |
7c6b3cd7 |
19 | |
20 | /* structure definition */ |
21 | |
e3247aa5 |
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 * element_name; //elements name of the struct or type name |
7c6b3cd7 |
48 | char * fmt; |
49 | int size; |
e3247aa5 |
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 |
7c6b3cd7 |
55 | }; |
56 | |
e3247aa5 |
57 | struct _LttEventType{ |
7c6b3cd7 |
58 | char * name; |
59 | char * description; |
e3247aa5 |
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 |
7c6b3cd7 |
65 | }; |
66 | |
e3247aa5 |
67 | struct _LttField{ |
7c6b3cd7 |
68 | unsigned field_pos; //field position within its parent |
e3247aa5 |
69 | LttType * field_type; //field type, if it is root field |
7c6b3cd7 |
70 | //then it must be struct type |
71 | |
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 ???? |
79 | |
80 | int field_size; //>0: size of the field, |
81 | //0 : uncertain |
82 | //-1: uninitialize |
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 |
86 | //-1: uninitialize |
87 | |
e3247aa5 |
88 | struct _LttField * parent; |
89 | struct _LttField ** child; //for array, sequence and struct: |
7c6b3cd7 |
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 |
93 | }; |
94 | |
e3247aa5 |
95 | struct _LttEvent{ |
96 | uint16_t event_id; |
97 | uint32_t time_delta; |
98 | LttTime event_time; |
99 | LttCycleCount event_cycle_count; |
100 | LttTracefile * tracefile; |
101 | void * data; //event data |
7c6b3cd7 |
102 | }; |
103 | |
e3247aa5 |
104 | struct _LttFacility{ |
7c6b3cd7 |
105 | char * name; //facility name |
106 | int event_number; //number of events in the facility |
e3247aa5 |
107 | LttChecksum checksum; //checksum of the facility |
108 | uint32_t base_id; //base id of the facility |
109 | LttEventType ** events; //array of event types |
110 | |
fcdf0ec2 |
111 | //FIXME Specify those types |
e3247aa5 |
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 |
7c6b3cd7 |
115 | }; |
116 | |
e3247aa5 |
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 |
134 | |
135 | LttTime prev_block_end_time; //the end time of previous block |
136 | LttTime prev_event_time; //the time of the previous event |
7c6b3cd7 |
137 | }; |
138 | |
e3247aa5 |
139 | struct _LttTrace{ |
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 |
150 | }; |
7c6b3cd7 |
151 | |
152 | |
153 | /***************************************************************************** |
154 | macro for size of some data types |
155 | *****************************************************************************/ |
e3247aa5 |
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) |
7c6b3cd7 |
159 | |
160 | |
161 | |
162 | |
163 | /* obtain the time of an event */ |
e3247aa5 |
164 | LttTime getEventTime(LttTracefile * tf); |
7c6b3cd7 |
165 | |
166 | /* get the data type size and endian type of the local machine */ |
e3247aa5 |
167 | void getDataEndianType(LttArchSize * size, LttArchEndian * endian); |
168 | |
169 | /* open facility */ |
170 | void ltt_facility_open(LttTrace * t, char * facility_name); |
7c6b3cd7 |
171 | |
e3247aa5 |
172 | /* get facility by event id */ |
173 | LttFacility * ltt_trace_facility_by_id(LttTrace * trace, unsigned id); |
7c6b3cd7 |
174 | |
e3247aa5 |
175 | /* open tracefile */ |
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); |
7c6b3cd7 |
179 | |
fcdf0ec2 |
180 | |
181 | #endif /* LTT_PRIVATE_H */ |