From: compudj Date: Fri, 16 Dec 2005 20:32:46 +0000 (+0000) Subject: compile fixes X-Git-Tag: v0.12.20~2087 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2312de30ce2be53f81c4eaaa772ffff21511b509;p=lttv.git compile fixes git-svn-id: http://ltt.polymtl.ca/svn@1402 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/facilities/Makefile.am b/ltt/branches/poly/facilities/Makefile.am index af48d365..7425c3dc 100644 --- a/ltt/branches/poly/facilities/Makefile.am +++ b/ltt/branches/poly/facilities/Makefile.am @@ -7,7 +7,6 @@ kernel.xml \ memory.xml \ network.xml \ process.xml \ -s390_kernel.xml \ socket.xml \ timer.xml @@ -19,7 +18,6 @@ kernel.xml \ memory.xml \ network.xml \ process.xml \ -s390_kernel.xml \ socket.xml \ timer.xml diff --git a/ltt/branches/poly/facilities/core.xml b/ltt/branches/poly/facilities/core.xml index 0ec8f9fc..41374e4b 100644 --- a/ltt/branches/poly/facilities/core.xml +++ b/ltt/branches/poly/facilities/core.xml @@ -14,11 +14,11 @@ - - - - - + + + + + @@ -42,7 +42,7 @@ - + diff --git a/ltt/branches/poly/ltt/event.c b/ltt/branches/poly/ltt/event.c index 53a2b2ec..f6db1817 100644 --- a/ltt/branches/poly/ltt/event.c +++ b/ltt/branches/poly/ltt/event.c @@ -35,6 +35,14 @@ #include #include + + +void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset, + void *root); + + + + LttEvent *ltt_event_new() { return g_new(LttEvent, 1); @@ -242,25 +250,6 @@ LttEventType *ltt_event_eventtype(const LttEvent *e) return &g_array_index(facility->events, LttEventType, e->event_id); } -/***************************************************************************** - *Function name - * ltt_event_field : get the root field of the event - *Input params - * e : an instance of an event type - * name : field name - *Return value - * LttField * : The requested field, or NULL - ****************************************************************************/ - -LttField *ltt_event_field(LttEvent *e, GQuark name) -{ - LttField * field; - LttEventType * event_type = ltt_event_eventtype(e); - if(unlikely(!event_type)) return NULL; - - return (LttField*)g_datalist_id_get_data(&event_type->fields_by_name, name); - -} /***************************************************************************** *Function name @@ -440,13 +429,14 @@ void *ltt_event_data(LttEvent *e) ****************************************************************************/ guint64 ltt_event_field_element_number(LttEvent *e, LttField *f) { - if(f->field_type->type_class != LTT_ARRAY && - f->field_type->type_class != LTT_SEQUENCE) + if(f->field_type.type_class != LTT_ARRAY && + f->field_type.type_class != LTT_SEQUENCE) return 0; - if(f->field_type->type_class == LTT_ARRAY) - return f->field_type->size; - return ltt_get_long_unsigned(e, &g_array_index(f->fields, LttField, 0)); + if(f->field_type.type_class == LTT_ARRAY) + return f->field_type.size; + return ltt_event_get_long_unsigned(e, &g_array_index(f->field_type.fields, + LttField, 0)); } /***************************************************************************** @@ -470,8 +460,8 @@ LttField *ltt_event_field_element_select(LttEvent *e, LttField *f, gulong i) LttEventType *event_type; off_t new_offset; - if(f->field_type->type_class != LTT_ARRAY && - f->field_type->type_class != LTT_SEQUENCE) + if(f->field_type.type_class != LTT_ARRAY && + f->field_type.type_class != LTT_SEQUENCE) return ; element_number = ltt_event_field_element_number(e,f); @@ -480,10 +470,10 @@ LttField *ltt_event_field_element_select(LttEvent *e, LttField *f, gulong i) */ if(i >= element_number) return; - if(f->field_type->type_class == LTT_ARRAY) { - field = &g_array_index(f->fields, LttField, 0); + if(f->field_type.type_class == LTT_ARRAY) { + field = &g_array_index(f->field_type.fields, LttField, 0); } else { - field = &g_array_index(f->fields, LttField, 1); + field = &g_array_index(f->field_type.fields, LttField, 1); } if(field->field_size != 0) { @@ -495,7 +485,7 @@ LttField *ltt_event_field_element_select(LttEvent *e, LttField *f, gulong i) /* Var. len. child */ new_offset = g_array_index(f->dynamic_offsets, off_t, i); } - compute_fields_offsets(e->tracefile, field, new_offset); + compute_fields_offsets(e->tracefile, field, &new_offset, e->data); return field; } @@ -508,9 +498,7 @@ guint32 ltt_event_get_unsigned(LttEvent *e, LttField *f) { gboolean reverse_byte_order = LTT_GET_BO(e->tracefile); - LttTypeEnum t = f->field_type->type_class; - - g_assert(t == LTT_UINT || t == LTT_ENUM); + LttTypeEnum t = f->field_type.type_class; if(f->field_size == 1){ guint8 x = *(guint8 *)(e->data + f->offset_root); @@ -537,8 +525,6 @@ gint32 ltt_event_get_int(LttEvent *e, LttField *f) { gboolean reverse_byte_order = LTT_GET_BO(e->tracefile); - g_assert(f->field_type->type_class == LTT_INT); - if(f->field_size == 1){ gint8 x = *(gint8 *)(e->data + f->offset_root); return (gint32) x; @@ -564,10 +550,7 @@ guint64 ltt_event_get_long_unsigned(LttEvent *e, LttField *f) { gboolean reverse_byte_order = LTT_GET_BO(e->tracefile); - LttTypeEnum t = f->field_type->type_class; - - g_assert(t == LTT_UINT || t == LTT_ENUM - || t == LTT_ULONG || LTT_SIZE_T || LTT_OFF_T || LTT_POINTER); + LttTypeEnum t = f->field_type.type_class; if(f->field_size == 1){ guint8 x = *(guint8 *)(e->data + f->offset_root); @@ -589,10 +572,6 @@ gint64 ltt_event_get_long_int(LttEvent *e, LttField *f) // e->tracefile->trace->system_description->endian ? 0:1; gboolean reverse_byte_order = LTT_GET_BO(e->tracefile); - g_assert( f->field_type->type_class == LTT_INT - || f->field_type->type_class == LTT_LONG - || f->field_type->type_class == LTT_SSIZE_T); - if(f->field_size == 1){ gint8 x = *(gint8 *)(e->data + f->offset_root); return (gint64) x; @@ -612,7 +591,7 @@ float ltt_event_get_float(LttEvent *e, LttField *f) g_assert(LTT_HAS_FLOAT(e->tracefile)); gboolean reverse_byte_order = LTT_GET_FLOAT_BO(e->tracefile); - g_assert(f->field_type->type_class == LTT_FLOAT && f->field_size == 4); + g_assert(f->field_type.type_class == LTT_FLOAT && f->field_size == 4); if(reverse_byte_order == 0) return *(float *)(e->data + f->offset_root); else{ @@ -627,7 +606,10 @@ double ltt_event_get_double(LttEvent *e, LttField *f) g_assert(LTT_HAS_FLOAT(e->tracefile)); gboolean reverse_byte_order = LTT_GET_FLOAT_BO(e->tracefile); - g_assert(f->field_type->type_class == LTT_FLOAT && f->field_size == 8); + if(f->field_size == 4) + return ltt_event_get_float(e, f); + + g_assert(f->field_type.type_class == LTT_FLOAT && f->field_size == 8); if(reverse_byte_order == 0) return *(double *)(e->data + f->offset_root); else { @@ -643,7 +625,7 @@ double ltt_event_get_double(LttEvent *e, LttField *f) ****************************************************************************/ char *ltt_event_get_string(LttEvent *e, LttField *f) { - g_assert(f->field_type->type_class == LTT_STRING); + g_assert(f->field_type.type_class == LTT_STRING); return (gchar*)g_strdup((gchar*)(e->data + f->offset_root)); } @@ -818,7 +800,7 @@ size_t get_field_type_size(LttTracefile *tf, LttEventType *event_type, void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset, void *root) { - type = &field->field_type; + LttType *type = &field->field_type; switch(type->type_class) { case LTT_INT_FIXED: @@ -881,13 +863,14 @@ void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset, 0); for(i=0; isize; i++) { g_array_append_val(field->dynamic_offsets, *offset); - compute_fields_offsets(tf, child, offset); + compute_fields_offsets(tf, child, offset, root); } } // local_offset = field->array_offset; // /* Set the offset at position 0 */ - // compute_fields_offsets(tf, child, &local_offset); - break; + // compute_fields_offsets(tf, child, &local_offset, root); + } + break; case LTT_SEQUENCE: g_assert(type->fields->len == 2); { @@ -901,7 +884,7 @@ void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset, field->offset_root = *offset; child = &g_array_index(type->fields, LttField, 0); - compute_fields_offsets(tf, child, offset); + compute_fields_offsets(tf, child, offset, root); child = &g_array_index(type->fields, LttField, 1); *offset += ltt_align(*offset, get_alignment(tf, child), tf->has_alignment); @@ -915,11 +898,11 @@ void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset, 0); for(i=0; ievent, field); i++) { g_array_append_val(field->dynamic_offsets, *offset); - compute_fields_offsets(tf, child, offset); + compute_fields_offsets(tf, child, offset, root); } // local_offset = field->array_offset; // /* Set the offset at position 0 */ - // compute_fields_offsets(tf, child, &local_offset); + // compute_fields_offsets(tf, child, &local_offset, root); } break; case LTT_STRUCT: @@ -937,7 +920,7 @@ void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset, } for(i=0; ifields->len; i++) { child = &g_array_index(type->fields, LttField, i); - compute_fields_offsets(tf, child, offset); + compute_fields_offsets(tf, child, offset, root); } } break; @@ -955,7 +938,7 @@ void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset, for(i=0; ifields->len; i++) { *offset = field->offset_root; child = &g_array_index(type->fields, LttField, i); - compute_fields_offsets(tf, child, offset); + compute_fields_offsets(tf, child, offset, root); } *offset = field->offset_root + field->field_size; } @@ -976,7 +959,7 @@ void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset, * event : event type * ****************************************************************************/ -void compute_offsets(LttTracefile *tf, LttEventType *event, size_t *offset, +void compute_offsets(LttTracefile *tf, LttEventType *event, off_t *offset, void *root) { guint i; @@ -985,7 +968,7 @@ void compute_offsets(LttTracefile *tf, LttEventType *event, size_t *offset, /* compute all variable offsets */ for(i=0; ifields->len; i++) { LttField *field = &g_array_index(event->fields, LttField, i); - ret = compute_fields_offsets(tf, field, offset, root); + compute_fields_offsets(tf, field, offset, root); if(ret) break; } diff --git a/ltt/branches/poly/ltt/event.h b/ltt/branches/poly/ltt/event.h index a7408b4d..209ba361 100644 --- a/ltt/branches/poly/ltt/event.h +++ b/ltt/branches/poly/ltt/event.h @@ -46,10 +46,6 @@ LttFacility *ltt_event_facility(const LttEvent *e); LttEventType *ltt_event_eventtype(const LttEvent *e); -/* Root field for the event */ - -LttField *ltt_event_field(LttEvent *e); - /* Time and cycle count for the event */ @@ -100,7 +96,7 @@ guint64 ltt_event_field_element_number(LttEvent *e, LttField *f); /* Set the currently selected element for a sequence or array field. */ -void ltt_event_field_element_select(LttEvent *e, LttField *f, unsigned i); +LttField *ltt_event_field_element_select(LttEvent *e, LttField *f, gulong i); /* A union is like a structure except that only a single member at a time @@ -131,11 +127,7 @@ double ltt_event_get_double(LttEvent *e, LttField *f); gchar *ltt_event_get_string(LttEvent *e, LttField *f); -size_t get_field_type_size(LttTracefile *tf, - LttEventType *event_type, - off_t offset_root, off_t offset_parent, - LttField *field, void *data); - - +void compute_offsets(LttTracefile *tf, LttEventType *event, off_t *offset, + void *root); #endif // EVENT_H diff --git a/ltt/branches/poly/ltt/facility.c b/ltt/branches/poly/ltt/facility.c index 75b89bed..252c6759 100644 --- a/ltt/branches/poly/ltt/facility.c +++ b/ltt/branches/poly/ltt/facility.c @@ -47,8 +47,9 @@ LttType * lookup_named_type(LttFacility *fac, type_descriptor_t * td); /* construct directed acyclic graph for types, and tree for fields */ -void construct_types_and_fields(LttFacility * fac, type_descriptor_t * td, - LttField * fld); +void construct_fields(LttFacility *fac, + LttField *field, + field_t *fld); /* generate the facility according to the events belongin to it */ void generateFacility(LttFacility * f, facility_t * fac, @@ -57,7 +58,7 @@ void generateFacility(LttFacility * f, facility_t * fac, /* functions to release the memory occupied by a facility */ void freeFacility(LttFacility * facility); void freeEventtype(LttEventType * evType); -void freeLttType(LttType ** type); +void freeLttType(LttType * type); void freeLttField(LttField * fld); void freeLttNamedType(LttType * type); @@ -80,7 +81,7 @@ int ltt_facility_open(LttFacility *f, LttTrace * t, gchar * pathname) gchar *token; parse_file_t in; facility_t * fac; - unsigned long checksum; + unsigned int checksum; gchar buffer[BUFFER_SIZE]; gboolean generated = FALSE; @@ -187,7 +188,7 @@ void generateFacility(LttFacility *f, facility_t *fac, guint32 checksum) f->events = g_array_set_size(f->events, events->position); g_datalist_init(&f->events_by_name); - g_datalist_init(&f->named_types); + // g_datalist_init(&f->named_types); #if 0 /* The first day, he created the named types */ @@ -216,7 +217,7 @@ void generateFacility(LttFacility *f, facility_t *fac, guint32 checksum) /* The second day, he created the event fields and types */ //for each event, construct field and type acyclic graph for(i=0;iposition;i++){ - event_t parser_event = (event_t*)events->array[i]; + event_t *parser_event = (event_t*)events->array[i]; LttEventType *event_type = &g_array_index(f->events, LttEventType, i); event_type->name = @@ -241,7 +242,7 @@ void generateFacility(LttFacility *f, facility_t *fac, guint32 checksum) LttField *field = &g_array_index(event_type->fields, LttField, j); field_t *parser_field = (field_t*)parser_event->fields.array[j]; - construct_types_and_fields(NULL, NULL, field, parser_field, ...); + construct_fields(f, field, parser_field); g_datalist_id_set_data(&event_type->fields_by_name, field->name, field); @@ -278,6 +279,7 @@ void construct_fields(LttFacility *fac, { guint len; type_descriptor_t *td; + LttType *type; field->name = g_quark_from_string(fld->name); if(fld->description) { @@ -363,12 +365,11 @@ void construct_fields(LttFacility *fac, type->size = fac->int_size; { guint i; - g_datalist_init(&type->enum_map); + type->enum_map = g_hash_table_new(g_int_hash, g_int_equal); for(i=0; ilabels.position; i++) { - GQuark key = g_quark_from_string((char*)td->labels.array[i]); - int *src = (int*)td->labels_values.array[i]; - /* it's always ok to cast a int to a pointer type */ - g_datalist_id_set_data(&type->enum_map, key, (gpointer)*src); + GQuark value = g_quark_from_string((char*)td->labels.array[i]); + gint key = *(int*)td->labels_values.array[i]; + g_hash_table_insert(type->enum_map, (gpointer)key, (gpointer)value); } } break; @@ -734,7 +735,8 @@ void freeEventtype(LttEventType * evType) g_free(evType->description); for(i=0; ifields->len;i++) { - freeLttType(&g_array_index(evType->fields, LttType, i)); + LttField *field = &g_array_index(evType->fields, LttField, i); + freeLttField(field); } g_array_free(evType->fields, TRUE); g_datalist_clear(&evType->fields_by_name); @@ -748,7 +750,7 @@ void freeLttType(LttType * type) g_free(type->fmt); if(type->enum_map) - g_datalist_clear(&type->enum_map); + g_hash_table_destroy(type->enum_map); if(type->fields) { for(i=0; ifields->len; i++) { @@ -765,19 +767,13 @@ void freeLttNamedType(LttType * type) freeLttType(type); } -void copy_enum_element(GQuark keyid, gpointer data, gpointer user_data) -{ - int *value = gpointer data; - -} - void freeLttField(LttField * field) { if(field->description) g_free(field->description); if(field->dynamic_offsets) g_array_free(field->dynamic_offsets, TRUE); - freeLttType(field->type); + freeLttType(&field->field_type); } /***************************************************************************** diff --git a/ltt/branches/poly/ltt/ltt-private.h b/ltt/branches/poly/ltt/ltt-private.h index 03da264e..7327ca79 100644 --- a/ltt/branches/poly/ltt/ltt-private.h +++ b/ltt/branches/poly/ltt/ltt-private.h @@ -29,6 +29,11 @@ #define max(a,b) ((a)>(b)?(a):(b)) #endif +#ifndef min +#define min(a,b) ((a)<(b)?(a):(b)) +#endif + + #define LTT_MAGIC_NUMBER 0x00D6B7ED #define LTT_REV_MAGIC_NUMBER 0xEDB7D600 @@ -218,7 +223,7 @@ struct _LttType{ gchar * fmt; guint size; LttTypeEnum type_class; //which type - GData *enum_map; //maps enum labels to numbers. + GHashTable *enum_map; //maps enum labels to numbers. GArray *fields; // Array of LttFields, for array, sequence, union, struct. GData *fields_by_name; }; diff --git a/ltt/branches/poly/ltt/parser.c b/ltt/branches/poly/ltt/parser.c index 23162992..bfa64564 100644 --- a/ltt/branches/poly/ltt/parser.c +++ b/ltt/branches/poly/ltt/parser.c @@ -1239,12 +1239,13 @@ void generateChecksum(char* facName, unsigned long crc ; int pos; event_t * ev; + unsigned int i; crc = crc32(facName); for(pos = 0; pos < events->position; pos++){ ev = (event_t *)(events->array[pos]); crc = partial_crc32(ev->name, crc); - for(unsigned int i = 0; i < ev->fields.position; i++) { + for(i = 0; i < ev->fields.position; i++) { field_t *f = (field_t*)ev->fields.array[i]; crc = partial_crc32(f->name, crc); crc = getTypeChecksum(crc, f->type); diff --git a/ltt/branches/poly/ltt/tracefile.c b/ltt/branches/poly/ltt/tracefile.c index ec5152f3..2a12480d 100644 --- a/ltt/branches/poly/ltt/tracefile.c +++ b/ltt/branches/poly/ltt/tracefile.c @@ -105,6 +105,9 @@ static int ltt_seek_next_event(LttTracefile *tf); void ltt_update_event_size(LttTracefile *tf); + +void precompute_offsets(LttTracefile *tf, LttEventType *event); + #if 0 /* Functions to parse system.xml file (using glib xml parser) */ static void parser_start_element (GMarkupParseContext __UNUSED__ *context, @@ -973,7 +976,7 @@ static int ltt_process_facility_tracefile(LttTracefile *tf) fac->size_t_size = ltt_get_uint32(LTT_GET_BO(tf), &fac_load_data->size_t_size); fac->alignment = ltt_get_uint32(LTT_GET_BO(tf), - &fac_load_data->alignment); + &fac_load_data->has_alignment); if(ltt_get_facility_description(fac, tf->trace, tf)) continue; /* error opening description */ @@ -1029,7 +1032,7 @@ static int ltt_process_facility_tracefile(LttTracefile *tf) fac->size_t_size = ltt_get_uint32(LTT_GET_BO(tf), &fac_state_dump_load_data->size_t_size); fac->alignment = ltt_get_uint32(LTT_GET_BO(tf), - &fac_state_dump_load_data->alignment); + &fac_state_dump_load_data->has_alignment); if(ltt_get_facility_description(fac, tf->trace, tf)) continue; /* error opening description */ @@ -1662,7 +1665,7 @@ int ltt_tracefile_read_update_event(LttTracefile *tf) /* Read event header */ /* Align the head */ - pos += ltt_align(pos, tf->trace->arch_size, tf->has_alignment); + pos += ltt_align((size_t)pos, tf->trace->arch_size, tf->has_alignment); if(tf->trace->has_tsc) { if(tf->trace->has_heartbeat) { @@ -1711,7 +1714,7 @@ int ltt_tracefile_read_update_event(LttTracefile *tf) pos += sizeof(guint16); /* Align the head */ - pos += ltt_align(pos, tf->trace->arch_size, tf->has_alignment); + pos += ltt_align((size_t)pos, tf->trace->arch_size, tf->has_alignment); event->data = pos; @@ -1846,7 +1849,7 @@ map_error: /* It will update the fields offsets too */ void ltt_update_event_size(LttTracefile *tf) { - size_t size = 0; + off_t size = 0; /* Specific handling of core events : necessary to read the facility control * tracefile. */ @@ -2047,7 +2050,7 @@ void set_fields_offsets(LttTracefile *tf, LttEventType *event_type) ****************************************************************************/ off_t get_alignment(LttTracefile *tf, LttField *field) { - type = &field->field_type; + LttType *type = &field->field_type; switch(type->type_class) { case LTT_INT_FIXED: @@ -2126,7 +2129,7 @@ off_t get_alignment(LttTracefile *tf, LttField *field) void field_compute_static_size(LttTracefile *tf, LttField *field) { - type = &field->field_type; + LttType *type = &field->field_type; switch(type->type_class) { case LTT_INT_FIXED: @@ -2168,7 +2171,7 @@ void field_compute_static_size(LttTracefile *tf, LttField *field) case LTT_SEQUENCE: g_assert(type->fields->len == 2); { - local_offset = 0; + off_t local_offset = 0; LttField *child = &g_array_index(type->fields, LttField, 1); field_compute_static_size(tf, child); field->field_size = 0; @@ -2202,6 +2205,7 @@ void field_compute_static_size(LttTracefile *tf, LttField *field) break; default: g_error("field_static_size : unknown type"); + } } @@ -2222,7 +2226,7 @@ void field_compute_static_size(LttTracefile *tf, LttField *field) gint precompute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset) { - type = &field->field_type; + LttType *type = &field->field_type; switch(type->type_class) { case LTT_INT_FIXED: @@ -2587,6 +2591,8 @@ gint check_fields_compatibility(LttEventType *event_type1, LttField *field1, LttField *field2) { guint different = 0; + LttType *type1; + LttType *type2; if(field1 == NULL) { if(field2 == NULL) goto end; @@ -2599,17 +2605,13 @@ gint check_fields_compatibility(LttEventType *event_type1, goto end; } - type1 = field1->field_type; - type2 = field2->field_type; + 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: @@ -2665,6 +2667,8 @@ gint check_fields_compatibility(LttEventType *event_type1, } 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, diff --git a/ltt/branches/poly/ltt/type.c b/ltt/branches/poly/ltt/type.c index 4b09e3f7..0961eb14 100644 --- a/ltt/branches/poly/ltt/type.c +++ b/ltt/branches/poly/ltt/type.c @@ -101,47 +101,17 @@ guint8 ltt_eventtype_id(LttEventType *et) /***************************************************************************** *Function name - * ltt_eventtype_type : get the type of the event type + * ltt_field_name : get the name of the field *Input params - * et : an event type - *Return value - * LttType * : the type of the event type - ****************************************************************************/ - -LttType *ltt_eventtype_type(LttEventType *et) -{ - if(unlikely(!et->root_field)) return NULL; - else return et->root_field->field_type; -} - -/***************************************************************************** - *Function name - * ltt_eventtype_field : get the root filed of the event type - *Input params - * et : an event type - *Return value - * LttField * : the root filed of the event type - ****************************************************************************/ - -LttField *ltt_eventtype_field(LttEventType *et) -{ - return et->root_field; -} - -/***************************************************************************** - *Function name - * ltt_type_name : get the name of the type - *Input params - * t : a type + * f : a field *Return value * char * : the name of the type ****************************************************************************/ -GQuark ltt_type_name(LttType *t) +GQuark ltt_field_name(LttField *f) { - return t->element_name; + return f->name; } - /***************************************************************************** *Function name * ltt_type_class : get the type class of the type @@ -226,11 +196,17 @@ error: LttType *ltt_type_element_type(LttType *t) { LttType *element_type; + LttField *field; if(unlikely(t->type_class != LTT_ARRAY && t->type_class != LTT_SEQUENCE)) element_type = NULL; - else - element_type = t->element_type[0]; + else { + if(t->type_class == LTT_ARRAY) + field = &g_array_index(t->fields, LttField, 0); + else + field = &g_array_index(t->fields, LttField, 1); + element_type = ltt_field_type(field); + } return element_type; } @@ -243,7 +219,7 @@ LttType *ltt_type_element_type(LttType *t) *Return value * unsigned : the number of elements for arrays ****************************************************************************/ - +#if 0 unsigned ltt_type_element_number(LttType *t) { unsigned ret = 0; @@ -253,7 +229,7 @@ unsigned ltt_type_element_number(LttType *t) return ret; } - +#endif //0 /***************************************************************************** *Function name * ltt_type_member_number : obtain the number of data members for structure @@ -268,39 +244,11 @@ unsigned ltt_type_member_number(LttType *t) unsigned ret = 0; if(likely(t->type_class == LTT_STRUCT || t->type_class == LTT_UNION)) - ret =t->element_number; + ret = t->fields->len; return ret; } -/***************************************************************************** - *Function name - * ltt_type_member_type : obtain the type of a data member in a structure - * or union. - *Input params - * t : a type - * i : index of the member - *Return value - * LttType * : the type of structure member - ****************************************************************************/ - -LttType *ltt_type_member_type(LttType *t, unsigned i, GQuark *name) -{ - LttType *member_type = NULL; - - if(unlikely( (t->type_class != LTT_STRUCT - && t->type_class != LTT_UNION) - || - (i >= t->element_number) - )) { - *name = 0; - } else { - *name = t->element_type[i]->element_name; - member_type = t->element_type[i]; - } - - return member_type; -} /***************************************************************************** *Function name @@ -314,14 +262,14 @@ LttType *ltt_type_member_type(LttType *t, unsigned i, GQuark *name) * char * : symbolic string associated with a value ****************************************************************************/ -GQuark ltt_enum_string_get(LttType *t, unsigned i) +GQuark ltt_enum_string_get(LttType *t, gulong i) { - if(likely(t->type_class == LTT_ENUM && i < t->element_number)) - return t->enum_strings[i]; + if(likely(t->type_class == LTT_ENUM)) + return (GQuark)g_hash_table_lookup(t->enum_map, (gpointer)i); else return 0; } - +#if 0 /***************************************************************************** *Function name * ltt_field_element : obtain the field of nested elements for arrays and @@ -342,6 +290,30 @@ LttField *ltt_field_element(LttField *f) return nest; } +#endif//0 + +/***************************************************************************** + *Function name + * ltt_field_member_by_name : obtain the field of data members for structure + *Input params + * f : a field + * name : name of the field + *Return value + * LttField * : the field of the nested element + ****************************************************************************/ + +LttField *ltt_field_member_by_name(LttField *f, GQuark name) +{ + LttField *field_member; + + g_assert(f->field_type.type_class == LTT_STRUCT || + f->field_type.type_class == LTT_UNION); + + field_member = g_datalist_id_get_data(&f->field_type.fields_by_name, name); + + return field_member; +} + /***************************************************************************** *Function name @@ -353,21 +325,15 @@ LttField *ltt_field_element(LttField *f) * LttField * : the field of the nested element ****************************************************************************/ -LttField *ltt_field_member(LttField *f, unsigned i) +LttField *ltt_field_member(LttField *f, guint i) { LttField *field_member; - g_assert(f->field_type->type_class == LTT_STRUCT || - f->field_type->type_class == LTT_UNION); - g_assert(i < f->field_type->element_number); -#if 0 - if(unlikely( f->field_type->type_class != LTT_STRUCT - && f->field_type->type_class != LTT_UNION) - || i >= f->field_type->element_number ) - field_member = NULL; - else -#endif //0 - field_member = f->child[i]; + g_assert(f->field_type.type_class == LTT_STRUCT || + f->field_type.type_class == LTT_UNION); + g_assert(i < f->field_type.fields->len); + + field_member = &g_array_index(f->field_type.fields, LttField, i); return field_member; } @@ -384,7 +350,7 @@ LttField *ltt_field_member(LttField *f, unsigned i) LttType *ltt_field_type(LttField *f) { if(unlikely(!f))return NULL; - return f->field_type; + return &f->field_type; } int ltt_field_size(LttField * f) @@ -392,3 +358,60 @@ int ltt_field_size(LttField * f) if(unlikely(!f))return 0; return f->field_size; } + + +/***************************************************************************** + *Function name + * ltt_eventtype_num_fields : get the number of fields of the event + *Input params + * e : an instance of an event type + *Return value + * guint : number of fields + ****************************************************************************/ + +guint ltt_eventtype_num_fields(LttEventType *event_type) +{ + if(unlikely(!event_type)) return NULL; + + return event_type->fields->len; + +} +/***************************************************************************** + *Function name + * ltt_eventtype_field : get the i th field of the event + *Input params + * e : an instance of an event type + * i : field index + *Return value + * LttField * : The requested field, or NULL + ****************************************************************************/ + +LttField *ltt_eventtype_field(LttEventType *event_type, guint i) +{ + if(unlikely(!event_type)) return NULL; + + if(i >= event_type->fields->len) return NULL; + + return &g_array_index(event_type->fields, LttField, i); + +} + +/***************************************************************************** + *Function name + * ltt_eventtype_field_by_name : get a field of the event + *Input params + * e : an instance of an event type + * name : field name + *Return value + * LttField * : The requested field, or NULL + ****************************************************************************/ + +LttField *ltt_eventtype_field_by_name(LttEventType *event_type, GQuark name) +{ + if(unlikely(!event_type)) return NULL; + + return (LttField*)g_datalist_id_get_data(&event_type->fields_by_name, name); + +} + + diff --git a/ltt/branches/poly/ltt/type.h b/ltt/branches/poly/ltt/type.h index 98e7b8c0..0ff3dfe0 100644 --- a/ltt/branches/poly/ltt/type.h +++ b/ltt/branches/poly/ltt/type.h @@ -41,17 +41,14 @@ unsigned ltt_eventtype_relative_id(LttEventType *et); guint8 ltt_eventtype_id(LttEventType *et); -LttType *ltt_eventtype_type(LttEventType *et); - -LttField *ltt_eventtype_field(LttEventType *et); - - /* obtain the type name and size. The size is the number of bytes for primitive types (INT, UINT, FLOAT, ENUM), or the size for the unsigned integer length count for sequences. */ GQuark ltt_type_name(LttType *t); +GQuark ltt_field_name(LttField *f); + LttTypeEnum ltt_type_class(LttType *t); unsigned ltt_type_size(LttTrace *trace, LttType *t); @@ -64,23 +61,18 @@ LttType *ltt_type_element_type(LttType *t); /* The number of elements for arrays. */ -unsigned ltt_type_element_number(LttType *t); +//unsigned ltt_type_element_number(LttType *t); /* The number of data members for structures and unions. */ -unsigned ltt_type_member_number(LttType *t); - - -/* The type of a data member in a structure. */ - -LttType *ltt_type_member_type(LttType *t, unsigned i, GQuark *name); +guint ltt_type_member_number(LttType *t); /* For enumerations, obtain the symbolic string associated with a value (0 to n - 1 for an enumeration of n elements). */ -GQuark ltt_enum_string_get(LttType *t, unsigned i); +GQuark ltt_enum_string_get(LttType *t, gulong i); /* The fields form a tree representing a depth first search of the @@ -91,12 +83,20 @@ GQuark ltt_enum_string_get(LttType *t, unsigned i); platform/trace specific offset values (for efficient access) and points back to the corresponding LttType for the rest. */ -LttField *ltt_field_element(LttField *f); +//LttField *ltt_field_element(LttField *f); + +LttField *ltt_field_member_by_name(LttField *f, GQuark name); -LttField *ltt_field_member(LttField *f, unsigned i); +LttField *ltt_field_member(LttField *f, guint i); LttType *ltt_field_type(LttField *f); int ltt_field_size(LttField * f); +guint ltt_eventtype_num_fields(LttEventType *event_type); + +LttField *ltt_eventtype_field(LttEventType *event_type, guint i); + +LttField *ltt_eventtype_field_by_name(LttEventType *event_type, GQuark name); + #endif // TYPE_H diff --git a/ltt/branches/poly/lttctl/lttctl.c b/ltt/branches/poly/lttctl/lttctl.c index 5b8c262d..105aacb6 100644 --- a/ltt/branches/poly/lttctl/lttctl.c +++ b/ltt/branches/poly/lttctl/lttctl.c @@ -25,7 +25,7 @@ #include /* Buffer for file copy : 4k seems optimal. */ -#define BUF_SIZE 4194304 +#define BUF_SIZE 4096 enum trace_ctl_op { CTL_OP_CREATE_START, diff --git a/ltt/branches/poly/lttd/lttd.c b/ltt/branches/poly/lttd/lttd.c index 3a2fdd3f..4f5f4bc4 100644 --- a/ltt/branches/poly/lttd/lttd.c +++ b/ltt/branches/poly/lttd/lttd.c @@ -311,7 +311,8 @@ int read_subbuffer(struct fd_pair *pair) } err = TEMP_FAILURE_RETRY(write(pair->trace, - pair->mmap + (consumed_old & (~(pair->subbuf_size-1))), + pair->mmap + + (consumed_old & ((pair->n_subbufs * pair->subbuf_size)-1)), pair->subbuf_size)); if(err < 0) { diff --git a/ltt/branches/poly/lttv/lttv/print.c b/ltt/branches/poly/lttv/lttv/print.c index 085216f6..84f3af79 100644 --- a/ltt/branches/poly/lttv/lttv/print.c +++ b/ltt/branches/poly/lttv/lttv/print.c @@ -49,8 +49,6 @@ void lttv_print_field(LttEvent *e, LttField *f, GString *s, LttType *type; - LttField *element; - GQuark name; int nb, i; @@ -107,10 +105,9 @@ void lttv_print_field(LttEvent *e, LttField *f, GString *s, case LTT_SEQUENCE: g_string_append_printf(s, "{ "); nb = ltt_event_field_element_number(e,f); - element = ltt_field_element(f); for(i = 0 ; i < nb ; i++) { - ltt_event_field_element_select(e,f,i); - lttv_print_field(e, element, s, field_names); + LttField *child = ltt_event_field_element_select(e,f,i); + lttv_print_field(e, child, s, field_names); if(i != nb-1) g_string_append_printf(s, ", "); } g_string_append_printf(s, " }"); @@ -120,9 +117,10 @@ void lttv_print_field(LttEvent *e, LttField *f, GString *s, g_string_append_printf(s, "{ "); nb = ltt_type_member_number(type); for(i = 0 ; i < nb ; i++) { + LttField *element; element = ltt_field_member(f,i); if(field_names) { - ltt_type_member_type(type, i, &name); + name = ltt_field_name(element); g_string_append_printf(s, "%s = ", g_quark_to_string(name)); } lttv_print_field(e, element, s, field_names); @@ -135,9 +133,10 @@ void lttv_print_field(LttEvent *e, LttField *f, GString *s, g_string_append_printf(s, "{ "); nb = ltt_type_member_number(type); for(i = 0 ; i < nb ; i++) { + LttField *element; element = ltt_field_member(f,i); if(field_names) { - ltt_type_member_type(type, i, &name); + name = ltt_field_name(element); g_string_append_printf(s, "%s = ", g_quark_to_string(name)); } lttv_print_field(e, element, s, field_names); @@ -145,7 +144,8 @@ void lttv_print_field(LttEvent *e, LttField *f, GString *s, } g_string_append_printf(s, " }"); break; - + case LTT_NONE: + break; } } @@ -165,6 +165,8 @@ void lttv_event_to_string(LttEvent *e, GString *s, LttvTraceState *ts = (LttvTraceState*)tfs->parent.t_context; LttvProcessState *process = ts->running_process[cpu]; + GQuark name; + guint i, num_fields; g_string_set_size(s,0); @@ -189,7 +191,12 @@ void lttv_event_to_string(LttEvent *e, GString *s, num_fields = ltt_eventtype_num_fields(event_type); for(i=0; i