get rid of LTTTypes.h
[lttv.git] / ltt / branches / poly / include / ltt / ltt-private.h
CommitLineData
fcdf0ec2 1#ifndef LTT_PRIVATE_H
2#define LTT_PRIVATE_H
3
858bd80a 4#include <glib.h>
cbd41522 5#include <sys/types.h>
fcdf0ec2 6#include <ltt/ltt.h>
fcdf0ec2 7#include <ltt/type.h>
e3247aa5 8#include <ltt/trace.h>
9
cbd41522 10#define LTT_PACKED_STRUCT __attribute__ ((packed))
11
e3247aa5 12/* enumeration definition */
13
14typedef enum _BuildinEvent{
15 TRACE_FACILITY_LOAD = 0,
16 TRACE_BLOCK_START = 17,
17 TRACE_BLOCK_END = 18,
0d7aac52 18 TRACE_TIME_HEARTBEAT= 19
e3247aa5 19} BuildinEvent;
fcdf0ec2 20
7c6b3cd7 21
22/* structure definition */
23
e3247aa5 24typedef struct _FacilityLoad{
25 char * name;
26 LttChecksum checksum;
cbd41522 27 guint32 base_code;
e3247aa5 28} LTT_PACKED_STRUCT FacilityLoad;
29
30typedef struct _BlockStart {
31 LttTime time; //Time stamp of this block
32 LttCycleCount cycle_count; //cycle count of the event
cbd41522 33 guint32 block_id; //block id
e3247aa5 34} LTT_PACKED_STRUCT BlockStart;
35
36typedef struct _BlockEnd {
37 LttTime time; //Time stamp of this block
38 LttCycleCount cycle_count; //cycle count of the event
cbd41522 39 guint32 block_id; //block id
e3247aa5 40} LTT_PACKED_STRUCT BlockEnd;
41
42typedef 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
48struct _LttType{
0d7aac52 49 char * type_name; //type name if it is a named type
50 char * element_name; //elements name of the struct
7c6b3cd7 51 char * fmt;
52 int size;
e3247aa5 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
7c6b3cd7 58};
59
e3247aa5 60struct _LttEventType{
7c6b3cd7 61 char * name;
62 char * description;
e3247aa5 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
7c6b3cd7 68};
69
e3247aa5 70struct _LttField{
7c6b3cd7 71 unsigned field_pos; //field position within its parent
e3247aa5 72 LttType * field_type; //field type, if it is root field
7c6b3cd7 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
0d7aac52 86 int sequ_number_size; //the size of unsigned used to save the
87 //number of elements in the sequence
88
7c6b3cd7 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
e3247aa5 94 struct _LttField * parent;
95 struct _LttField ** child; //for array, sequence and struct:
7c6b3cd7 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
e3247aa5 101struct _LttEvent{
cbd41522 102 guint16 event_id;
103 guint32 time_delta;
e3247aa5 104 LttTime event_time;
105 LttCycleCount event_cycle_count;
106 LttTracefile * tracefile;
107 void * data; //event data
0d7aac52 108 int which_block; //the current block of the event
109 int which_event; //the position of the event
7c6b3cd7 110};
111
e3247aa5 112struct _LttFacility{
7c6b3cd7 113 char * name; //facility name
114 int event_number; //number of events in the facility
e3247aa5 115 LttChecksum checksum; //checksum of the facility
cbd41522 116 guint32 base_id; //base id of the facility
e3247aa5 117 LttEventType ** events; //array of event types
36921b4e 118 LttType ** named_types;
119 int named_types_number;
7c6b3cd7 120};
121
e3247aa5 122struct _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
fb1a869e 139 LttCycleCount cur_cycle_count; //current cycle count of the event
e37c1372 140 void * last_event_pos;
e3247aa5 141
142 LttTime prev_block_end_time; //the end time of previous block
143 LttTime prev_event_time; //the time of the previous event
7525f9e5 144 LttEvent an_event;
7c6b3cd7 145};
146
e3247aa5 147struct _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
80da81ad 153
e3247aa5 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};
7c6b3cd7 160
80da81ad 161struct _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
fb1a869e 168 LttTracefile *tf; //tracefile containing the event
80da81ad 169 gboolean old_position; //flag to show if it is the position
170 //being remembered
171};
7c6b3cd7 172
173/*****************************************************************************
174 macro for size of some data types
175 *****************************************************************************/
cbd41522 176#define EVENT_ID_SIZE sizeof(guint16)
177#define TIME_DELTA_SIZE sizeof(guint32)
e3247aa5 178#define EVENT_HEADER_SIZE (EVENT_ID_SIZE + TIME_DELTA_SIZE)
7c6b3cd7 179
180
181
182
183/* obtain the time of an event */
e3247aa5 184LttTime getEventTime(LttTracefile * tf);
7c6b3cd7 185
186/* get the data type size and endian type of the local machine */
e3247aa5 187void getDataEndianType(LttArchSize * size, LttArchEndian * endian);
188
0d7aac52 189/* get an integer number */
190int getIntNumber(int size1, void *evD);
191
e3247aa5 192/* open facility */
193void ltt_facility_open(LttTrace * t, char * facility_name);
7c6b3cd7 194
e3247aa5 195/* get facility by event id */
196LttFacility * ltt_trace_facility_by_id(LttTrace * trace, unsigned id);
7c6b3cd7 197
e3247aa5 198/* open tracefile */
199LttTracefile * ltt_tracefile_open(LttTrace *t, char * tracefile_name);
200void ltt_tracefile_open_cpu(LttTrace *t, char * tracefile_name);
201void ltt_tracefile_open_control(LttTrace *t, char * control_name);
7c6b3cd7 202
fcdf0ec2 203
204#endif /* LTT_PRIVATE_H */
This page took 0.037241 seconds and 4 git commands to generate.