From 92c7ad317d63cbc9f760381549a4c58cef4125a3 Mon Sep 17 00:00:00 2001 From: pmf Date: Tue, 3 Feb 2009 00:05:47 +0000 Subject: [PATCH] tracefile.c: remove old facility stuff git-svn-id: http://ltt.polymtl.ca/svn@3309 04897980-b3bd-0310-b5e0-8ef037075253 --- trunk/lttv/ltt/tracefile.c | 841 ------------------------------------- 1 file changed, 841 deletions(-) diff --git a/trunk/lttv/ltt/tracefile.c b/trunk/lttv/ltt/tracefile.c index 73472a4e..81aed84f 100644 --- a/trunk/lttv/ltt/tracefile.c +++ b/trunk/lttv/ltt/tracefile.c @@ -85,16 +85,6 @@ LttTrace *father_trace = NULL; //void set_fields_offsets(LttTracefile *tf, LttEventType *event_type); //size_t get_fields_offsets(LttTracefile *tf, LttEventType *event_type, void *data); -#if 0 -/* get the size of the field type according to - * The facility size information. */ -static inline void preset_field_type_size(LttTracefile *tf, - LttEventType *event_type, - off_t offset_root, off_t offset_parent, - enum field_status *fixed_root, enum field_status *fixed_parent, - LttField *field); -#endif //0 - /* map a fixed size or a block information from the file (fd) */ static gint map_block(LttTracefile * tf, guint block_num); @@ -1614,837 +1604,6 @@ error: return ENOPROTOOPT; } -#if 0 -/***************************************************************************** - *Function name - * set_fields_offsets : set the precomputable offset of the fields - *Input params - * tracefile : opened trace file - * event_type : the event type - ****************************************************************************/ - -void set_fields_offsets(LttTracefile *tf, LttEventType *event_type) -{ - LttField *field = event_type->root_field; - enum field_status fixed_root = FIELD_FIXED, fixed_parent = FIELD_FIXED; - - if(likely(field)) - preset_field_type_size(tf, event_type, 0, 0, - &fixed_root, &fixed_parent, - field); - -} -#endif //0 - - -/***************************************************************************** - *Function name - * get_alignment : Get the alignment needed for a field. - *Input params - * field : field - * - * returns : The size on which it must be aligned. - * - ****************************************************************************/ -#if 0 -off_t get_alignment(LttField *field) -{ - LttType *type = &field->field_type; - - switch(type->type_class) { - case LTT_INT_FIXED: - case LTT_UINT_FIXED: - case LTT_POINTER: - case LTT_CHAR: - case LTT_UCHAR: - case LTT_SHORT: - case LTT_USHORT: - case LTT_INT: - case LTT_UINT: - case LTT_LONG: - case LTT_ULONG: - case LTT_SIZE_T: - case LTT_SSIZE_T: - case LTT_OFF_T: - case LTT_FLOAT: - case LTT_ENUM: - /* Align offset on type size */ - g_assert(field->field_size != 0); - return field->field_size; - break; - case LTT_STRING: - return 1; - break; - case LTT_ARRAY: - g_assert(type->fields->len == 1); - { - LttField *child = &g_array_index(type->fields, LttField, 0); - return get_alignment(child); - } - break; - case LTT_SEQUENCE: - g_assert(type->fields->len == 2); - { - off_t localign = 1; - LttField *child = &g_array_index(type->fields, LttField, 0); - - localign = max(localign, get_alignment(child)); - - child = &g_array_index(type->fields, LttField, 1); - localign = max(localign, get_alignment(child)); - - return localign; - } - break; - case LTT_STRUCT: - case LTT_UNION: - { - guint i; - off_t localign = 1; - - for(i=0; ifields->len; i++) { - LttField *child = &g_array_index(type->fields, LttField, i); - localign = max(localign, get_alignment(child)); - } - return localign; - } - break; - case LTT_NONE: - default: - g_error("get_alignment : unknown type"); - return -1; - } -} - -#endif //0 - -/***************************************************************************** - *Function name - * field_compute_static_size : Determine the size of fields known by their - * sole definition. Unions, arrays and struct sizes might be known, but - * the parser does not give that information. - *Input params - * tf : tracefile - * field : field - * - ****************************************************************************/ -#if 0 -void field_compute_static_size(LttFacility *fac, LttField *field) -{ - LttType *type = &field->field_type; - - switch(type->type_class) { - case LTT_INT_FIXED: - case LTT_UINT_FIXED: - case LTT_POINTER: - case LTT_CHAR: - case LTT_UCHAR: - case LTT_SHORT: - case LTT_USHORT: - case LTT_INT: - case LTT_UINT: - case LTT_LONG: - case LTT_ULONG: - case LTT_SIZE_T: - case LTT_SSIZE_T: - case LTT_OFF_T: - case LTT_FLOAT: - case LTT_ENUM: - case LTT_STRING: - /* nothing to do */ - break; - case LTT_ARRAY: - /* note this : array type size is the number of elements in the array, - * while array field size of the length of the array in bytes */ - g_assert(type->fields->len == 1); - { - LttField *child = &g_array_index(type->fields, LttField, 0); - field_compute_static_size(fac, child); - - if(child->field_size != 0) { - field->field_size = type->size * child->field_size; - field->dynamic_offsets = g_array_sized_new(FALSE, TRUE, - sizeof(off_t), type->size); - } else { - field->field_size = 0; - } - } - break; - case LTT_SEQUENCE: - g_assert(type->fields->len == 2); - { - off_t local_offset = 0; - LttField *child = &g_array_index(type->fields, LttField, 1); - field_compute_static_size(fac, child); - field->field_size = 0; - type->size = 0; - if(child->field_size != 0) { - field->dynamic_offsets = g_array_sized_new(FALSE, TRUE, - sizeof(off_t), SEQUENCE_AVG_ELEMENTS); - } - } - break; - case LTT_STRUCT: - case LTT_UNION: - { - guint i; - for(i=0;ifields->len;i++) { - LttField *child = &g_array_index(type->fields, LttField, i); - field_compute_static_size(fac, child); - if(child->field_size != 0) { - type->size += ltt_align(type->size, get_alignment(child), - fac->alignment); - type->size += child->field_size; - } else { - /* As soon as we find a child with variable size, we have - * a variable size */ - type->size = 0; - break; - } - } - field->field_size = type->size; - } - break; - default: - g_error("field_static_size : unknown type"); - } - -} -#endif //0 - - -/***************************************************************************** - *Function name - * precompute_fields_offsets : set the precomputable offset of the fields - *Input params - * fac : facility - * field : the field - * offset : pointer to the current offset, must be incremented - * - * return : 1 : found a variable length field, stop the processing. - * 0 otherwise. - ****************************************************************************/ - -#if 0 -gint precompute_fields_offsets(LttFacility *fac, LttField *field, off_t *offset, gint is_compact) -{ - LttType *type = &field->field_type; - - if(unlikely(is_compact)) { - g_assert(field->field_size != 0); - /* FIXME THIS IS A HUUUUUGE hack : - * offset is between the compact_data field in struct LttEvent - * and the address of the field root in the memory map. - * ark. Both will stay at the same addresses while the event - * is readable, so it's ok. - */ - field->offset_root = 0; - field->fixed_root = FIELD_FIXED; - return 0; - } - - switch(type->type_class) { - case LTT_INT_FIXED: - case LTT_UINT_FIXED: - case LTT_POINTER: - case LTT_CHAR: - case LTT_UCHAR: - case LTT_SHORT: - case LTT_USHORT: - case LTT_INT: - case LTT_UINT: - case LTT_LONG: - case LTT_ULONG: - case LTT_SIZE_T: - case LTT_SSIZE_T: - case LTT_OFF_T: - case LTT_FLOAT: - case LTT_ENUM: - g_assert(field->field_size != 0); - /* Align offset on type size */ - *offset += ltt_align(*offset, get_alignment(field), - fac->alignment); - /* remember offset */ - field->offset_root = *offset; - field->fixed_root = FIELD_FIXED; - /* Increment offset */ - *offset += field->field_size; - return 0; - break; - case LTT_STRING: - field->offset_root = *offset; - field->fixed_root = FIELD_FIXED; - return 1; - break; - case LTT_ARRAY: - g_assert(type->fields->len == 1); - { - LttField *child = &g_array_index(type->fields, LttField, 0); - - *offset += ltt_align(*offset, get_alignment(field), - fac->alignment); - - /* remember offset */ - field->offset_root = *offset; - field->array_offset = *offset; - field->fixed_root = FIELD_FIXED; - - /* Let the child be variable */ - //precompute_fields_offsets(tf, child, offset); - - if(field->field_size != 0) { - /* Increment offset */ - /* field_size is the array size in bytes */ - *offset += field->field_size; - return 0; - } else { - return 1; - } - } - break; - case LTT_SEQUENCE: - g_assert(type->fields->len == 2); - { - LttField *child; - guint ret; - - *offset += ltt_align(*offset, get_alignment(field), - fac->alignment); - - /* remember offset */ - field->offset_root = *offset; - field->fixed_root = FIELD_FIXED; - - child = &g_array_index(type->fields, LttField, 0); - ret = precompute_fields_offsets(fac, child, offset, is_compact); - g_assert(ret == 0); /* Seq len cannot have variable len */ - - child = &g_array_index(type->fields, LttField, 1); - *offset += ltt_align(*offset, get_alignment(child), - fac->alignment); - field->array_offset = *offset; - /* Let the child be variable. */ - //ret = precompute_fields_offsets(fac, child, offset); - - /* Cannot precompute fields offsets of sequence members, and has - * variable length. */ - return 1; - } - break; - case LTT_STRUCT: - { - LttField *child; - guint i; - gint ret=0; - - *offset += ltt_align(*offset, get_alignment(field), - fac->alignment); - /* remember offset */ - field->offset_root = *offset; - field->fixed_root = FIELD_FIXED; - - for(i=0; i< type->fields->len; i++) { - child = &g_array_index(type->fields, LttField, i); - ret = precompute_fields_offsets(fac, child, offset, is_compact); - - if(ret) break; - } - return ret; - } - break; - case LTT_UNION: - { - LttField *child; - guint i; - gint ret=0; - - *offset += ltt_align(*offset, get_alignment(field), - fac->alignment); - /* remember offset */ - field->offset_root = *offset; - field->fixed_root = FIELD_FIXED; - - for(i=0; i< type->fields->len; i++) { - *offset = field->offset_root; - child = &g_array_index(type->fields, LttField, i); - ret = precompute_fields_offsets(fac, child, offset, is_compact); - - if(ret) break; - } - *offset = field->offset_root + field->field_size; - return ret; - } - - break; - case LTT_NONE: - default: - g_error("precompute_fields_offsets : unknown type"); - return 1; - } - -} - -#endif //0 - -#if 0 -/***************************************************************************** - *Function name - * precompute_offsets : set the precomputable offset of an event type - *Input params - * tf : tracefile - * event : event type - * - ****************************************************************************/ -void precompute_offsets(LttFacility *fac, LttEventType *event) -{ - guint i; - off_t offset = 0; - gint ret; - - /* First, compute the size of fixed size fields. Will determine size for - * arrays, struct and unions, which is not done by the parser */ - for(i=0; ifields->len; i++) { - LttField *field = &g_array_index(event->fields, LttField, i); - field_compute_static_size(fac, field); - } - - /* Precompute all known offsets */ - for(i=0; ifields->len; i++) { - LttField *field = &g_array_index(event->fields, LttField, i); - if(event->has_compact_data && i == 0) - ret = precompute_fields_offsets(fac, field, &offset, 1); - else - ret = precompute_fields_offsets(fac, field, &offset, 0); - if(ret) break; - } -} -#endif //0 - - - -/***************************************************************************** - *Function name - * preset_field_type_size : set the fixed sizes of the field type - *Input params - * tf : tracefile - * event_type : event type - * offset_root : offset from the root - * offset_parent : offset from the parent - * fixed_root : Do we know a fixed offset to the root ? - * fixed_parent : Do we know a fixed offset to the parent ? - * field : field - ****************************************************************************/ - - - -// preset the fixed size offsets. Calculate them just like genevent-new : an -// increment of a *to value that represents the offset from the start of the -// event data. -// The preset information is : offsets up to (and including) the first element -// of variable size. All subsequent fields must be flagged "VARIABLE OFFSET". -#if 0 -void preset_field_type_size(LttTracefile *tf, LttEventType *event_type, - off_t offset_root, off_t offset_parent, - enum field_status *fixed_root, enum field_status *fixed_parent, - LttField *field) -{ - enum field_status local_fixed_root, local_fixed_parent; - guint i; - LttType *type; - - g_assert(field->fixed_root == FIELD_UNKNOWN); - g_assert(field->fixed_parent == FIELD_UNKNOWN); - g_assert(field->fixed_size == FIELD_UNKNOWN); - - type = field->field_type; - - field->fixed_root = *fixed_root; - if(field->fixed_root == FIELD_FIXED) - field->offset_root = offset_root; - else - field->offset_root = 0; - - field->fixed_parent = *fixed_parent; - if(field->fixed_parent == FIELD_FIXED) - field->offset_parent = offset_parent; - else - field->offset_parent = 0; - - size_t current_root_offset; - size_t current_offset; - enum field_status current_child_status, final_child_status; - size_t max_size; - - switch(type->type_class) { - case LTT_INT_FIXED: - case LTT_UINT_FIXED: - case LTT_CHAR: - case LTT_UCHAR: - case LTT_SHORT: - case LTT_USHORT: - case LTT_INT: - case LTT_UINT: - case LTT_FLOAT: - case LTT_ENUM: - field->field_size = ltt_type_size(tf->trace, type); - field->fixed_size = FIELD_FIXED; - break; - case LTT_POINTER: - field->field_size = (off_t)event_type->facility->pointer_size; - field->fixed_size = FIELD_FIXED; - break; - case LTT_LONG: - case LTT_ULONG: - field->field_size = (off_t)event_type->facility->long_size; - field->fixed_size = FIELD_FIXED; - break; - case LTT_SIZE_T: - case LTT_SSIZE_T: - case LTT_OFF_T: - field->field_size = (off_t)event_type->facility->size_t_size; - field->fixed_size = FIELD_FIXED; - break; - case LTT_SEQUENCE: - local_fixed_root = FIELD_VARIABLE; - local_fixed_parent = FIELD_VARIABLE; - preset_field_type_size(tf, event_type, - 0, 0, - &local_fixed_root, &local_fixed_parent, - field->child[0]); - field->fixed_size = FIELD_VARIABLE; - field->field_size = 0; - *fixed_root = FIELD_VARIABLE; - *fixed_parent = FIELD_VARIABLE; - break; - case LTT_STRING: - field->fixed_size = FIELD_VARIABLE; - field->field_size = 0; - *fixed_root = FIELD_VARIABLE; - *fixed_parent = FIELD_VARIABLE; - break; - case LTT_ARRAY: - local_fixed_root = FIELD_VARIABLE; - local_fixed_parent = FIELD_VARIABLE; - preset_field_type_size(tf, event_type, - 0, 0, - &local_fixed_root, &local_fixed_parent, - field->child[0]); - field->fixed_size = field->child[0]->fixed_size; - if(field->fixed_size == FIELD_FIXED) { - field->field_size = type->element_number * field->child[0]->field_size; - } else { - field->field_size = 0; - *fixed_root = FIELD_VARIABLE; - *fixed_parent = FIELD_VARIABLE; - } - break; - case LTT_STRUCT: - current_root_offset = field->offset_root; - current_offset = 0; - current_child_status = FIELD_FIXED; - for(i=0;ielement_number;i++) { - preset_field_type_size(tf, event_type, - current_root_offset, current_offset, - fixed_root, ¤t_child_status, - field->child[i]); - if(current_child_status == FIELD_FIXED) { - current_root_offset += field->child[i]->field_size; - current_offset += field->child[i]->field_size; - } else { - current_root_offset = 0; - current_offset = 0; - } - } - if(current_child_status != FIELD_FIXED) { - *fixed_parent = current_child_status; - field->field_size = 0; - field->fixed_size = current_child_status; - } else { - field->field_size = current_offset; - field->fixed_size = FIELD_FIXED; - } - break; - case LTT_UNION: - current_root_offset = field->offset_root; - current_offset = 0; - max_size = 0; - final_child_status = FIELD_FIXED; - for(i=0;ielement_number;i++) { - enum field_status current_root_child_status = FIELD_FIXED; - enum field_status current_child_status = FIELD_FIXED; - preset_field_type_size(tf, event_type, - current_root_offset, current_offset, - ¤t_root_child_status, ¤t_child_status, - field->child[i]); - if(current_child_status != FIELD_FIXED) - final_child_status = current_child_status; - else - max_size = max(max_size, field->child[i]->field_size); - } - if(final_child_status != FIELD_FIXED) { - g_error("LTTV does not support variable size fields in unions."); - /* This will stop the application. */ - *fixed_root = final_child_status; - *fixed_parent = final_child_status; - field->field_size = 0; - field->fixed_size = current_child_status; - } else { - field->field_size = max_size; - field->fixed_size = FIELD_FIXED; - } - break; - case LTT_NONE: - g_error("unexpected type NONE"); - break; - } - -} -#endif //0 - -/***************************************************************************** - *Function name - * check_fields_compatibility : Check for compatibility between two fields : - * do they use the same inner structure ? - *Input params - * event_type1 : event type - * event_type2 : event type - * field1 : field - * field2 : field - *Returns : 0 if identical - * 1 if not. - ****************************************************************************/ -// this function checks for equality of field types. Therefore, it does not use -// per se offsets. For instance, an aligned version of a structure is -// compatible with an unaligned version of the same structure. -#if 0 -gint check_fields_compatibility(LttEventType *event_type1, - LttEventType *event_type2, - LttField *field1, LttField *field2) -{ - guint different = 0; - LttType *type1; - LttType *type2; - - if(field1 == NULL) { - if(field2 == NULL) goto end; - else { - different = 1; - goto end; - } - } else if(field2 == NULL) { - different = 1; - goto end; - } - - type1 = &field1->field_type; - type2 = &field2->field_type; - - if(type1->type_class != type2->type_class) { - different = 1; - goto end; - } - if(type1->network != type2->network) { - different = 1; - goto end; - } - - switch(type1->type_class) { - case LTT_INT_FIXED: - case LTT_UINT_FIXED: - case LTT_POINTER: - case LTT_CHAR: - case LTT_UCHAR: - case LTT_SHORT: - case LTT_USHORT: - case LTT_INT: - case LTT_UINT: - case LTT_LONG: - case LTT_ULONG: - case LTT_SIZE_T: - case LTT_SSIZE_T: - case LTT_OFF_T: - case LTT_FLOAT: - case LTT_ENUM: - if(field1->field_size != field2->field_size) - different = 1; - break; - case LTT_STRING: - break; - case LTT_ARRAY: - { - LttField *child1 = &g_array_index(type1->fields, LttField, 0); - LttField *child2 = &g_array_index(type2->fields, LttField, 0); - - if(type1->size != type2->size) - different = 1; - if(check_fields_compatibility(event_type1, event_type2, child1, child2)) - different = 1; - } - break; - case LTT_SEQUENCE: - { - LttField *child1 = &g_array_index(type1->fields, LttField, 1); - LttField *child2 = &g_array_index(type2->fields, LttField, 1); - - if(check_fields_compatibility(event_type1, event_type2, child1, child2)) - different = 1; - } - break; - case LTT_STRUCT: - case LTT_UNION: - { - LttField *child; - guint i; - - if(type1->fields->len != type2->fields->len) { - different = 1; - goto end; - } - - for(i=0; i< type1->fields->len; i++) { - LttField *child1; - LttField *child2; - child1 = &g_array_index(type1->fields, LttField, i); - child2 = &g_array_index(type2->fields, LttField, i); - different = check_fields_compatibility(event_type1, - event_type2, child1, child2); - - if(different) break; - } - } - break; - case LTT_NONE: - default: - g_error("check_fields_compatibility : unknown type"); - } - -end: - return different; -} -#endif //0 - -#if 0 -gint check_fields_compatibility(LttEventType *event_type1, - LttEventType *event_type2, - LttField *field1, LttField *field2) -{ - guint different = 0; - guint i; - LttType *type1; - LttType *type2; - - if(field1 == NULL) { - if(field2 == NULL) goto end; - else { - different = 1; - goto end; - } - } else if(field2 == NULL) { - different = 1; - goto end; - } - - g_assert(field1->fixed_root != FIELD_UNKNOWN); - g_assert(field2->fixed_root != FIELD_UNKNOWN); - g_assert(field1->fixed_parent != FIELD_UNKNOWN); - g_assert(field2->fixed_parent != FIELD_UNKNOWN); - g_assert(field1->fixed_size != FIELD_UNKNOWN); - g_assert(field2->fixed_size != FIELD_UNKNOWN); - - type1 = field1->field_type; - type2 = field2->field_type; - - if(type1->type_class != type2->type_class) { - different = 1; - goto end; - } - if(type1->element_name != type2->element_name) { - different = 1; - goto end; - } - - switch(type1->type_class) { - case LTT_INT_FIXED: - case LTT_UINT_FIXED: - case LTT_POINTER: - case LTT_CHAR: - case LTT_UCHAR: - case LTT_SHORT: - case LTT_USHORT: - case LTT_INT: - case LTT_UINT: - case LTT_FLOAT: - case LTT_POINTER: - case LTT_LONG: - case LTT_ULONG: - case LTT_SIZE_T: - case LTT_SSIZE_T: - case LTT_OFF_T: - if(field1->field_size != field2->field_size) { - different = 1; - goto end; - } - break; - case LTT_ENUM: - if(type1->element_number != type2->element_number) { - different = 1; - goto end; - } - for(i=0;ielement_number;i++) { - if(type1->enum_strings[i] != type2->enum_strings[i]) { - different = 1; - goto end; - } - } - break; - case LTT_SEQUENCE: - /* Two elements : size and child */ - g_assert(type1->element_number != type2->element_number); - for(i=0;ielement_number;i++) { - if(check_fields_compatibility(event_type1, event_type2, - field1->child[0], field2->child[0])) { - different = 1; - goto end; - } - } - break; - case LTT_STRING: - break; - case LTT_ARRAY: - if(field1->field_size != field2->field_size) { - different = 1; - goto end; - } - /* Two elements : size and child */ - g_assert(type1->element_number != type2->element_number); - for(i=0;ielement_number;i++) { - if(check_fields_compatibility(event_type1, event_type2, - field1->child[0], field2->child[0])) { - different = 1; - goto end; - } - } - break; - case LTT_STRUCT: - case LTT_UNION: - if(type1->element_number != type2->element_number) { - different = 1; - break; - } - for(i=0;ielement_number;i++) { - if(check_fields_compatibility(event_type1, event_type2, - field1->child[0], field2->child[0])) { - different = 1; - goto end; - } - } - break; - } -end: - return different; -} -#endif //0 - /***************************************************************************** *Function name -- 2.34.1