git-svn-id: http://ltt.polymtl.ca/svn@101 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>
8
7c6b3cd7 9
10/* structure definition */
11
12typedef struct _trace_header_event {
13 //information of the machine type
14 uint32_t arch_type; /* Type of architecture */
15 uint32_t arch_variant; /* Variant of the given type of architecture */
16 uint32_t system_type; /* Operating system type */
17 char system_name[32]; /* system name */
18 // uint32_t magic_number; /* Magic number to identify a trace */
19 ltt_arch_size arch_size; /* data type size */
20 ltt_arch_endian arch_endian; /* endian type : little or big */
21
22 //format of fields
23 uint8_t time_size; /* time size */
24 uint8_t time_granul; /* time granularity */
25 uint8_t id_size; /* size of combined facility/event ids */
26
27 //other elements
28 uint32_t ip_addr; /* IP of the machine */
29 uint8_t cpu_number; /* number of CPU */
30 uint8_t cpu_id; /* cpu id */
31 uint8_t cpu_number_used; /* the number of the cpu used in the tracefile */
32 uint32_t buffer_size; /* Size of blocks */
33} LTT_PACKED_STRUCT trace_header_event;
34
35
36typedef struct _block_header {
37 ltt_time time; /* Time stamp of this block */
38 ltt_cycle_count cycle_count; /* cycle count of the event */
39 uint32_t event_count; /* event count */
40} LTT_PACKED_STRUCT block_header;
41
42
43typedef struct _block_footer {
44 uint32_t unused_bytes; /* unused bytes at the end of the block */
45 ltt_time time; /* Time stamp of this block */
46 ltt_cycle_count cycle_count; /* cycle count of the event */
47} LTT_PACKED_STRUCT block_footer;
48
49
50struct _ltt_type{
51 char * element_name; //elements name of the struct or type name
52 char * fmt;
53 int size;
54 ltt_type_enum type_class; //which type
55 char ** enum_strings; //for enum labels
56 struct _ltt_type ** element_type; //for array, sequence and struct
57 unsigned element_number; //the number of elements
58 //for enum, array, sequence and structure
59};
60
61struct _ltt_eventtype{
62 char * name;
63 char * description;
64 int index; //id of the event type within the facility
65 ltt_facility * facility; //the facility that contains the event type
66 ltt_field * root_field; //root field
67 int latest_block; //the latest block using the event type
68 int latest_event; //the latest event using the event type
69};
70
71struct _ltt_field{
72 unsigned field_pos; //field position within its parent
73 ltt_type * field_type; //field type, if it is root field
74 //then it must be struct type
75
76 off_t offset_root; //offset from the root, -1:uninitialized
77 short fixed_root; //offset fixed according to the root
78 //-1:uninitialized, 0:unfixed, 1:fixed
79 off_t offset_parent; //offset from the parent,-1:uninitialized
80 short fixed_parent; //offset fixed according to its parent
81 //-1:uninitialized, 0:unfixed, 1:fixed
82 // void * base_address; //base address of the field ????
83
84 int field_size; //>0: size of the field,
85 //0 : uncertain
86 //-1: uninitialize
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 _ltt_field * parent;
93 struct _ltt_field ** 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
99struct _ltt_event{
100 int event_id;
101 ltt_cycle_count cycle_count;
102 ltt_tracefile * tracefile;
103 void * data; //event data
104};
105
106struct _ltt_facility{
107 char * name; //facility name
108 int event_number; //number of events in the facility
109 ltt_checksum checksum; //checksum of the facility
110 ltt_eventtype ** events; //array of event types
111 unsigned usage_count; //usage count
fcdf0ec2 112 //FIXME Specify those types
113 //table all_named_types; //an array of named ltt_type
114 //sequence all_unnamed_types;//an array of unnamed ltt_type
115 //sequence all_fields; //an array of fields
7c6b3cd7 116};
117
118struct _ltt_tracefile{
119 int fd; /* file descriptor */
120 off_t file_size; /* file size */
121 int block_number; /* number of blocks in the file */
122 int which_block; /* which block the current block is */
123 int which_event; /* which event of the current block
124 is currently processed */
125 ltt_time current_event_time; /* time of the current event */
126 trace_header_event * trace_header; /* the first event in the first block */
127 block_header * a_block_header; /* block header of the block*/
128 block_footer * a_block_footer; /* block footer of the block*/
129 void * first_event_pos; /* the position of the first event */
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 int cur_heart_beat_number;/* the number of heart beat so far
134 in the block */
135
136 ltt_time start_time; /* trace start time */
137 ltt_time end_time; /* trace end time */
138 ltt_time prev_block_end_time; /* the end time of previous block */
139 ltt_time prev_event_time; /* the time of the previous event */
140
141 int eventtype_number; /* the number of event type
142 in the tracefile */
143 int facility_number; /* the number of the facility in
144 the tracefile */
145 GHashTable * index_facility; /* facility index and facility pair */
146 GHashTable * facility_name; /* name and facility pair */
147 GHashTable * base_id_name; /* facility name and base id pair*/
148
149 GPtrArray * eventtype_event_id; /* an array of eventtypes accessed
150 by event id */
151
152 ltt_arch_size my_arch_size; /* data type size of the local machine */
153 ltt_arch_endian my_arch_endian; /* endian type of the local machine */
154};
155
156
157
158
159
160/*****************************************************************************
161 macro for size of some data types
162 *****************************************************************************/
163#define EVENT_ID_SIZE sizeof(int8_t)
164#define CYCLE_COUNT_SIZE sizeof(ltt_cycle_count)
165//event id and time delta(cycle count)
166//yxx disable during the test
167//#define EVENT_HEADER_SIZE (EVENT_ID_SIZE + CYCLE_COUNT_SIZE)
168#define EVENT_HEADER_SIZE (EVENT_ID_SIZE + sizeof(uint32_t))
169
170
171
172
173/* obtain the time of an event */
174ltt_time getEventTime(ltt_tracefile * tf);
175
176/* get the data type size and endian type of the local machine */
177void getDataEndianType(ltt_arch_size * size, ltt_arch_endian * endian);
178
179
180typedef struct _ptr_wrap{
181 gpointer ptr;
182} ptr_wrap;
183
fcdf0ec2 184
185#endif /* LTT_PRIVATE_H */
This page took 0.029121 seconds and 4 git commands to generate.