add ltt_type_name
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 13 Nov 2006 21:11:13 +0000 (21:11 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 13 Nov 2006 21:11:13 +0000 (21:11 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@2256 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/configure.in
ltt/branches/poly/ltt/event.c
ltt/branches/poly/ltt/facility.c
ltt/branches/poly/ltt/ltt.h
ltt/branches/poly/ltt/type.c

index db97c82d88d778c39580d563796f1fb5e60b9661..d9d4ad7b6262ca5c0da16f5705db4fcbfe9c025a 100644 (file)
@@ -23,7 +23,7 @@
 AC_PREREQ(2.57)
 AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
 #AC_WITH_LTDL  # not needed ?
-AM_INIT_AUTOMAKE(LinuxTraceToolkitViewer,0.8.70-08112006)
+AM_INIT_AUTOMAKE(LinuxTraceToolkitViewer,0.8.71-13112006)
 AM_CONFIG_HEADER(config.h)
 AM_PROG_LIBTOOL
 
index 1483102734e22ceb358282b138b5309263ebaeb4..f3645887fe7245a13cc975b4d5825209a5432813 100644 (file)
@@ -384,11 +384,11 @@ off_t ltt_event_field_offset(LttEvent *e, LttField *f)
 guint32 ltt_event_get_unsigned(LttEvent *e, LttField *f)
 {
   gboolean reverse_byte_order;
-       if(unlikely(f->field_type.network)) {
-               reverse_byte_order = (g_ntohs(0x1) != 0x1);
-       } else {
-       reverse_byte_order = LTT_GET_BO(e->tracefile);
-       }
+  if(unlikely(f->field_type.network)) {
+    reverse_byte_order = (g_ntohs(0x1) != 0x1);
+  } else {
+    reverse_byte_order = LTT_GET_BO(e->tracefile);
+  }
 
   switch(f->field_size) {
   case 1:
@@ -414,11 +414,11 @@ guint32 ltt_event_get_unsigned(LttEvent *e, LttField *f)
 gint32 ltt_event_get_int(LttEvent *e, LttField *f)
 {
   gboolean reverse_byte_order;
-       if(unlikely(f->field_type.network)) {
-               reverse_byte_order = (g_ntohs(0x1) != 0x1);
-       } else {
-       reverse_byte_order = LTT_GET_BO(e->tracefile);
-       }
+  if(unlikely(f->field_type.network)) {
+    reverse_byte_order = (g_ntohs(0x1) != 0x1);
+  } else {
+    reverse_byte_order = LTT_GET_BO(e->tracefile);
+  }
 
   switch(f->field_size) {
   case 1:
@@ -443,12 +443,12 @@ gint32 ltt_event_get_int(LttEvent *e, LttField *f)
 
 guint64 ltt_event_get_long_unsigned(LttEvent *e, LttField *f)
 {
-       gboolean reverse_byte_order;
-       if(unlikely(f->field_type.network)) {
-               reverse_byte_order = (g_ntohs(0x1) != 0x1);
-       } else {
-       reverse_byte_order = LTT_GET_BO(e->tracefile);
-       }
+  gboolean reverse_byte_order;
+  if(unlikely(f->field_type.network)) {
+    reverse_byte_order = (g_ntohs(0x1) != 0x1);
+  } else {
+    reverse_byte_order = LTT_GET_BO(e->tracefile);
+  }
   
   switch(f->field_size) {
   case 1:
@@ -475,12 +475,12 @@ guint64 ltt_event_get_long_unsigned(LttEvent *e, LttField *f)
 
 gint64 ltt_event_get_long_int(LttEvent *e, LttField *f)
 {
-       gboolean reverse_byte_order;
-       if(unlikely(f->field_type.network)) {
-               reverse_byte_order = (g_ntohs(0x1) != 0x1);
-       } else {
-       reverse_byte_order = LTT_GET_BO(e->tracefile);
-       }
+  gboolean reverse_byte_order;
+  if(unlikely(f->field_type.network)) {
+    reverse_byte_order = (g_ntohs(0x1) != 0x1);
+  } else {
+    reverse_byte_order = LTT_GET_BO(e->tracefile);
+  }
   
   switch(f->field_size) {
   case 1:
@@ -507,13 +507,13 @@ gint64 ltt_event_get_long_int(LttEvent *e, LttField *f)
 
 float ltt_event_get_float(LttEvent *e, LttField *f)
 {
-       gboolean reverse_byte_order;
-       if(unlikely(f->field_type.network)) {
-               reverse_byte_order = (g_ntohs(0x1) != 0x1);
-       } else {
-         g_assert(LTT_HAS_FLOAT(e->tracefile));
-       reverse_byte_order = LTT_GET_FLOAT_BO(e->tracefile);
-       }
+  gboolean reverse_byte_order;
+  if(unlikely(f->field_type.network)) {
+    reverse_byte_order = (g_ntohs(0x1) != 0x1);
+  } else {
+    g_assert(LTT_HAS_FLOAT(e->tracefile));
+    reverse_byte_order = LTT_GET_FLOAT_BO(e->tracefile);
+  }
 
   g_assert(f->field_type.type_class == LTT_FLOAT && f->field_size == 4);
 
@@ -527,13 +527,13 @@ float ltt_event_get_float(LttEvent *e, LttField *f)
 
 double ltt_event_get_double(LttEvent *e, LttField *f)
 {
-       gboolean reverse_byte_order;
-       if(unlikely(f->field_type.network)) {
-               reverse_byte_order = (g_ntohs(0x1) != 0x1);
-       } else {
-         g_assert(LTT_HAS_FLOAT(e->tracefile));
-       reverse_byte_order = LTT_GET_FLOAT_BO(e->tracefile);
-       }
+  gboolean reverse_byte_order;
+  if(unlikely(f->field_type.network)) {
+    reverse_byte_order = (g_ntohs(0x1) != 0x1);
+  } else {
+    g_assert(LTT_HAS_FLOAT(e->tracefile));
+    reverse_byte_order = LTT_GET_FLOAT_BO(e->tracefile);
+  }
 
   if(f->field_size == 4)
     return ltt_event_get_float(e, f);
index 619a4bab3b9f1e45d6b34d901ab9e90b154c96d6..9d342123dcb13f3d3e5e7ad9ca5d6104abd48b19 100644 (file)
@@ -48,7 +48,7 @@ LttType * lookup_named_type(LttFacility *fac, type_descriptor_t * td);
 
 /* construct directed acyclic graph for types, and tree for fields */
 void construct_fields(LttFacility *fac,
-                                                                                       LttField *field,
+                      LttField *field,
                       field_t *fld);
 
 /* generate the facility according to the events belongin to it */
@@ -103,24 +103,24 @@ int ltt_facility_open(LttFacility *f, LttTrace * t, gchar * pathname)
     token = getToken(&in);
     if(in.type == ENDFILE) break;
    
-               if(g_ascii_strcasecmp(token, "<")) in.error(&in,"not a facility file");
-               token = getName(&in);
-               if(g_ascii_strcasecmp(token, "?")) in.error(&in,"not a facility file");
-               token = getName(&in);
-               if(g_ascii_strcasecmp(token, "xml")) in.error(&in,"not a facility file");
-               token = getName(&in);
-               if(g_ascii_strcasecmp(token, "version")) in.error(&in,"not a facility file");
-               token = getName(&in);
-               if(g_ascii_strcasecmp(token, "=")) in.error(&in,"not a facility file");
-               token = getQuotedString(&in);
-               if(g_ascii_strcasecmp(token, "1.0")) in.error(&in,"not a facility file");
-               token = getName(&in);
-               if(g_ascii_strcasecmp(token, "?")) in.error(&in,"not a facility file");
-               token = getToken(&in);
-               if(g_ascii_strcasecmp(token, ">")) in.error(&in,"not a facility file");
-
-               token = getToken(&in);
-               
+    if(g_ascii_strcasecmp(token, "<")) in.error(&in,"not a facility file");
+    token = getName(&in);
+    if(g_ascii_strcasecmp(token, "?")) in.error(&in,"not a facility file");
+    token = getName(&in);
+    if(g_ascii_strcasecmp(token, "xml")) in.error(&in,"not a facility file");
+    token = getName(&in);
+    if(g_ascii_strcasecmp(token, "version")) in.error(&in,"not a facility file");
+    token = getName(&in);
+    if(g_ascii_strcasecmp(token, "=")) in.error(&in,"not a facility file");
+    token = getQuotedString(&in);
+    if(g_ascii_strcasecmp(token, "1.0")) in.error(&in,"not a facility file");
+    token = getName(&in);
+    if(g_ascii_strcasecmp(token, "?")) in.error(&in,"not a facility file");
+    token = getToken(&in);
+    if(g_ascii_strcasecmp(token, ">")) in.error(&in,"not a facility file");
+
+    token = getToken(&in);
+    
     if(g_ascii_strcasecmp(token, "<")) in.error(&in,"not a facility file");
     token = getName(&in);
 
@@ -235,7 +235,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;i<events->position;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 = 
@@ -292,17 +292,17 @@ void generateFacility(LttFacility *f, facility_t *fac, guint32 checksum)
 
 
 void construct_fields(LttFacility *fac,
-                                                                                       LttField *field,
+                      LttField *field,
                       field_t *fld)
 {
   guint len;
   type_descriptor_t *td;
   LttType *type;
 
-       if(fld->name)
-         field->name = g_quark_from_string(fld->name);
-       else
-               fld->name = 0;
+  if(fld->name)
+    field->name = g_quark_from_string(fld->name);
+  else
+    fld->name = 0;
 
   if(fld->description) {
     len = strlen(fld->description);
@@ -316,7 +316,7 @@ void construct_fields(LttFacility *fac,
   type->enum_map = NULL;
   type->fields = NULL;
   type->fields_by_name = NULL;
-       type->network = td->network;
+  type->network = td->network;
 
   switch(td->type) {
     case INT_FIXED:
@@ -564,14 +564,14 @@ void construct_types_and_fields(LttFacility * fac, type_descriptor_t * td,
     for(i=0;i<td->fields.position;i++){
       tmpTd = ((field_t*)(td->fields.array[i]))->type;
 
-       fld->field_type->element_type[i] = lookup_named_type(fac, tmpTd);
+      fld->field_type->element_type[i] = lookup_named_type(fac, tmpTd);
       fld->child[i] = g_new(LttField,1); 
 
  //     fld->child[i]->field_pos = i;
       fld->child[i]->field_type = fld->field_type->element_type[i]; 
 
       fld->child[i]->field_type->element_name 
-                 = g_quark_from_string(((field_t*)(td->fields.array[i]))->name);
+            = g_quark_from_string(((field_t*)(td->fields.array[i]))->name);
 
       fld->child[i]->offset_root = 0;
       fld->child[i]->fixed_root = FIELD_UNKNOWN;
@@ -650,15 +650,15 @@ void construct_types_and_fields(LttFacility * fac, type_descriptor * td,
       tmpTd = ((type_fields*)(td->fields.array[i]))->type;
 
       if(flag)
-       fld->field_type->element_type[i] = lookup_named_type(fac, tmpTd);
+  fld->field_type->element_type[i] = lookup_named_type(fac, tmpTd);
       fld->child[i] = g_new(LttField,1); 
 
       fld->child[i]->field_pos = i;
       fld->child[i]->field_type = fld->field_type->element_type[i]; 
 
       if(flag){
-       fld->child[i]->field_type->element_name 
-                 = g_quark_from_string(((type_fields*)(td->fields.array[i]))->name);
+        fld->child[i]->field_type->element_name 
+            = g_quark_from_string(((type_fields*)(td->fields.array[i]))->name);
       }
 
       fld->child[i]->offset_root = -1;
index 57298fe0dc240be48b07362ff922fc7f6718d3ae..357500109239b3e4f9ab78f73f20dd0076e00f61 100644 (file)
@@ -166,8 +166,8 @@ typedef enum _LttTypeEnum
 #define LTT_ARCH_TYPE_ARM           6
 #define LTT_ARCH_TYPE_PPC64         7
 #define LTT_ARCH_TYPE_X86_64        8
-#define LTT_ARCH_TYPE_C2                 9
-#define LTT_ARCH_TYPE_POWERPC            10
+#define LTT_ARCH_TYPE_C2            9
+#define LTT_ARCH_TYPE_POWERPC       10
 
 /* Standard definitions for variants */
 #define LTT_ARCH_VARIANT_NONE       0  /* Main architecture implementation */
index d650d35510f5ab07fb268a60b9b7a7cb4f882730..1d1481de453653599d2c4fde6fd59f2af66545f3 100644 (file)
@@ -33,13 +33,19 @@ static unsigned intSizes[] = {
   sizeof(int8_t), sizeof(int16_t), sizeof(int32_t), sizeof(int64_t), 
   sizeof(short) };
 
+static unsigned floatSizes[] = {
+  0, 0, sizeof(float), sizeof(double), 0, sizeof(float), sizeof(double) };
+
+
 typedef enum _intSizesNames { SIZE_INT8, SIZE_INT16, SIZE_INT32,
                               SIZE_INT64, SIZE_SHORT, INT_SIZES_NUMBER }
                    intSizesNames;
 
+static char * typeNames[] = {
+  "int_fixed", "uint_fixed", "pointer", "char", "uchar", "short", "ushort",
+  "int", "uint", "long", "ulong", "size_t", "ssize_t", "off_t", "float",
+  "string", "enum", "array", "sequence", "struct", "union", "none" };
 
-static unsigned floatSizes[] = {
-  0, 0, sizeof(float), sizeof(double), 0, sizeof(float), sizeof(double) };
 
 #define FLOAT_SIZES_NUMBER 7
 
@@ -100,6 +106,20 @@ guint8 ltt_eventtype_id(LttEventType *et)
   return et->index;
 }
 
+/*****************************************************************************
+ *Function name
+ *    ltt_type_name  : get the name of the type
+ *Input params
+ *    t              : a type
+ *Return value
+ *    GQuark         : the name of the type
+ ****************************************************************************/
+
+GQuark ltt_type_name(LttType *t)
+{
+  return g_quark_from_static_string(typeNames[t->type_class]);
+}
+
 /*****************************************************************************
  *Function name
  *    ltt_field_name  : get the name of the field
This page took 0.029968 seconds and 4 git commands to generate.