6 #include <ltt/LTTTypes.h>
10 /* structure definition */
12 typedef 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 */
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 */
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
;
36 typedef 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
;
43 typedef 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
;
51 char * element_name
; //elements name of the struct or type name
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
61 struct _ltt_eventtype
{
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
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
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 ????
84 int field_size
; //>0: size of the field,
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
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
101 ltt_cycle_count cycle_count
;
102 ltt_tracefile
* tracefile
;
103 void * data
; //event data
106 struct _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
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
118 struct _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
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 */
141 int eventtype_number
; /* the number of event type
143 int facility_number
; /* the number of the facility in
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*/
149 GPtrArray
* eventtype_event_id
; /* an array of eventtypes accessed
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 */
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))
173 /* obtain the time of an event */
174 ltt_time
getEventTime(ltt_tracefile
* tf
);
176 /* get the data type size and endian type of the local machine */
177 void getDataEndianType(ltt_arch_size
* size
, ltt_arch_endian
* endian
);
180 typedef struct _ptr_wrap
{
185 #endif /* LTT_PRIVATE_H */