| 1 | #ifndef LTT_PRIVATE_H |
| 2 | #define LTT_PRIVATE_H |
| 3 | |
| 4 | #include <glib.h> |
| 5 | #include <ltt/ltt.h> |
| 6 | #include <ltt/LTTTypes.h> |
| 7 | #include <ltt/type.h> |
| 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; |
| 18 | |
| 19 | |
| 20 | /* structure definition */ |
| 21 | |
| 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 |
| 48 | char * fmt; |
| 49 | int size; |
| 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 |
| 55 | }; |
| 56 | |
| 57 | struct _LttEventType{ |
| 58 | char * name; |
| 59 | char * description; |
| 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 |
| 65 | }; |
| 66 | |
| 67 | struct _LttField{ |
| 68 | unsigned field_pos; //field position within its parent |
| 69 | LttType * field_type; //field type, if it is root field |
| 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 | |
| 88 | struct _LttField * parent; |
| 89 | struct _LttField ** child; //for array, sequence and struct: |
| 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 | |
| 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 |
| 102 | }; |
| 103 | |
| 104 | struct _LttFacility{ |
| 105 | char * name; //facility name |
| 106 | int event_number; //number of events in the facility |
| 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 | LttType ** named_types; |
| 111 | int named_types_number; |
| 112 | }; |
| 113 | |
| 114 | struct _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 |
| 134 | }; |
| 135 | |
| 136 | struct _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 | }; |
| 148 | |
| 149 | |
| 150 | /***************************************************************************** |
| 151 | macro for size of some data types |
| 152 | *****************************************************************************/ |
| 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) |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | /* obtain the time of an event */ |
| 161 | LttTime getEventTime(LttTracefile * tf); |
| 162 | |
| 163 | /* get the data type size and endian type of the local machine */ |
| 164 | void getDataEndianType(LttArchSize * size, LttArchEndian * endian); |
| 165 | |
| 166 | /* open facility */ |
| 167 | void ltt_facility_open(LttTrace * t, char * facility_name); |
| 168 | |
| 169 | /* get facility by event id */ |
| 170 | LttFacility * ltt_trace_facility_by_id(LttTrace * trace, unsigned id); |
| 171 | |
| 172 | /* open tracefile */ |
| 173 | LttTracefile * ltt_tracefile_open(LttTrace *t, char * tracefile_name); |
| 174 | void ltt_tracefile_open_cpu(LttTrace *t, char * tracefile_name); |
| 175 | void ltt_tracefile_open_control(LttTrace *t, char * control_name); |
| 176 | |
| 177 | |
| 178 | #endif /* LTT_PRIVATE_H */ |