X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Ffacility.c;h=0440efb4e05ee721a15d86f79cee8ee4cfacf3e0;hb=01e5c8ac303294105046b1383fe923ae28bd4890;hp=75b89bed5e01f1a084d2b6d2e7e324bcba1f3cd3;hpb=f104d082727461632e7a5cc1d2a854f0ad66db07;p=lttv.git diff --git a/ltt/branches/poly/ltt/facility.c b/ltt/branches/poly/ltt/facility.c index 75b89bed..0440efb4 100644 --- a/ltt/branches/poly/ltt/facility.c +++ b/ltt/branches/poly/ltt/facility.c @@ -2,19 +2,19 @@ * Copyright (C) 2003-2004 Xiangxiu Yang * 2005 Mathieu Desnoyers * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License Version 2 as - * published by the Free Software Foundation; + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License Version 2.1 as published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H @@ -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,8 +279,13 @@ void construct_fields(LttFacility *fac, { guint len; type_descriptor_t *td; + LttType *type; + + if(fld->name) + field->name = g_quark_from_string(fld->name); + else + fld->name = 0; - field->name = g_quark_from_string(fld->name); if(fld->description) { len = strlen(fld->description); field->description = g_new(gchar, len+1); @@ -292,7 +298,8 @@ void construct_fields(LttFacility *fac, type->enum_map = NULL; type->fields = NULL; type->fields_by_name = NULL; - + type->network = td->network; + switch(td->type) { case INT_FIXED: type->type_class = LTT_INT_FIXED; @@ -313,6 +320,7 @@ void construct_fields(LttFacility *fac, case UCHAR: type->type_class = LTT_UCHAR; type->size = td->size; + g_assert(type->size != 0); break; case SHORT: type->type_class = LTT_SHORT; @@ -329,6 +337,7 @@ void construct_fields(LttFacility *fac, case UINT: type->type_class = LTT_UINT; type->size = fac->int_size; + g_assert(type->size != 0); break; case LONG: type->type_class = LTT_LONG; @@ -363,14 +372,14 @@ 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_direct_hash, g_direct_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); } } + g_assert(type->size != 0); break; case ARRAY: type->type_class = LTT_ARRAY; @@ -734,7 +743,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 +758,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 +775,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); } /*****************************************************************************