git-svn-id: http://ltt.polymtl.ca/svn@152 04897980-b3bd-0310-b5e0-8ef037075253
[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>
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
12typedef 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 22typedef struct _FacilityLoad{
23 char * name;
24 LttChecksum checksum;
25 uint32_t base_code;
26} LTT_PACKED_STRUCT FacilityLoad;
27
28typedef 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
34typedef 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
40typedef 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
46struct _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 57struct _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 67struct _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 95struct _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 104struct _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
36921b4e 110 LttType ** named_types;
111 int named_types_number;
7c6b3cd7 112};
113
e3247aa5 114struct _LttTracefile{
115 char * name; //tracefile name
116 LttTrace * trace; //trace containing the tracefile
117 int fd; //file descriptor
118 off_t file_size; //file size
119 unsigned block_size; //block_size
120 int block_number; //number of blocks in the file
121 int which_block; //which block the current block is
122 int which_event; //which event of the current block
123 //is currently processed
124 LttTime current_event_time; //time of the current event
125 BlockStart * a_block_start; //block start of the block
126 BlockEnd * a_block_end; //block end of the block
127 void * cur_event_pos; //the position of the current event
128 void * buffer; //the buffer containing the block
129 double cycle_per_nsec; //Cycles per nsec
130 unsigned cur_heart_beat_number; //current number of heart beat in the buf
131
132 LttTime prev_block_end_time; //the end time of previous block
133 LttTime prev_event_time; //the time of the previous event
7c6b3cd7 134};
135
e3247aa5 136struct _LttTrace{
137 char * pathname; //the pathname of the trace
138 guint facility_number; //the number of facilities
139 guint control_tracefile_number; //the number of control files
140 guint per_cpu_tracefile_number; //the number of per cpu files
141 LttSystemDescription * system_description;//system description
142 GPtrArray *control_tracefiles; //array of control tracefiles
143 GPtrArray *per_cpu_tracefiles; //array of per cpu tracefiles
144 GPtrArray *facilities; //array of facilities
145 LttArchSize my_arch_size; //data size of the local machine
146 LttArchEndian my_arch_endian; //endian type of the local machine
147};
7c6b3cd7 148
149
150/*****************************************************************************
151 macro for size of some data types
152 *****************************************************************************/
e3247aa5 153#define EVENT_ID_SIZE sizeof(uint16_t)
154#define TIME_DELTA_SIZE sizeof(uint32_t)
155#define EVENT_HEADER_SIZE (EVENT_ID_SIZE + TIME_DELTA_SIZE)
7c6b3cd7 156
157
158
159
160/* obtain the time of an event */
e3247aa5 161LttTime getEventTime(LttTracefile * tf);
7c6b3cd7 162
163/* get the data type size and endian type of the local machine */
e3247aa5 164void getDataEndianType(LttArchSize * size, LttArchEndian * endian);
165
166/* open facility */
167void ltt_facility_open(LttTrace * t, char * facility_name);
7c6b3cd7 168
e3247aa5 169/* get facility by event id */
170LttFacility * ltt_trace_facility_by_id(LttTrace * trace, unsigned id);
7c6b3cd7 171
e3247aa5 172/* open tracefile */
173LttTracefile * ltt_tracefile_open(LttTrace *t, char * tracefile_name);
174void ltt_tracefile_open_cpu(LttTrace *t, char * tracefile_name);
175void ltt_tracefile_open_control(LttTrace *t, char * control_name);
7c6b3cd7 176
fcdf0ec2 177
178#endif /* LTT_PRIVATE_H */
This page took 0.028937 seconds and 4 git commands to generate.