outstanding bugs fixed
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Sat, 17 Dec 2005 03:55:46 +0000 (03:55 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Sat, 17 Dec 2005 03:55:46 +0000 (03:55 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1413 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/facilities/Makefile.am
ltt/branches/poly/facilities/process.xml
ltt/branches/poly/ltt/event.c
ltt/branches/poly/ltt/event.h
ltt/branches/poly/ltt/facility.c
ltt/branches/poly/ltt/ltt-private.h
ltt/branches/poly/ltt/parser.c
ltt/branches/poly/ltt/tracefile.c
ltt/branches/poly/lttv/lttv/print.c
ltt/branches/poly/lttv/lttv/state.c

index 7425c3dc11276861084516ae6d95772892836cb2..e10a3da6c005de94a62cac360b9d63aee78ea6ab 100644 (file)
@@ -8,6 +8,7 @@ memory.xml \
 network.xml \
 process.xml \
 socket.xml \
+statedump.xml \
 timer.xml
 
 facilities_DATA = \
@@ -19,6 +20,7 @@ memory.xml \
 network.xml \
 process.xml \
 socket.xml \
+statedump.xml \
 timer.xml
 
 
index e9f403e7cd2e4fb52fb8a5ebba87607af25238c0..58133392c72f4ca7e507e27162789d12479accc6 100644 (file)
 
   <event name=fork>
     <description>Process fork</description>
-    <field name="parent_pid"> <description>PID of the parent process</description> <uint size=4/> </field>
-    <field name="child_pid"> <description>PID of the child process</description> <uint size=4/> </field>
+    <field name="parent_pid"> <description>PID of the parent process</description> <uint/> </field>
+    <field name="child_pid"> <description>PID of the child process</description> <uint/> </field>
   </event>
        
   <event name=kernel_thread>
     <description>Just created a new kernel thread</description>
-    <field name="pid"> <description>PID of the kernel thread</description> <uint size=4/> </field>
+    <field name="pid"> <description>PID of the kernel thread</description> <uint/> </field>
     <field name="function"> <description>Function called</description> <pointer/> </field>
   </event>
 
 
   <event name=exit>
     <description>Process exit</description>
-    <field name="pid"> <description>PID of the process</description> <uint size=4/> </field>
+    <field name="pid"> <description>PID of the process</description> <uint/> </field>
   </event>
 
   <event name=wait>
     <description>Process wait</description>
-    <field name="parent_pid"> <description>PID of the waiting process</description> <uint size=4/> </field>
-    <field name="child_pid"> <description>PID of the process waited for</description> <uint size=4/> </field>
+    <field name="parent_pid"> <description>PID of the waiting process</description> <uint/> </field>
+    <field name="child_pid"> <description>PID of the process waited for</description> <uint/> </field>
   </event>
 
   <event name=free>
     <description>Process kernel data structure free (end of life of a zombie)</description>
-    <field name="pid"> <description>PID of the freed process</description> <uint size=4/> </field>
+    <field name="pid"> <description>PID of the freed process</description> <uint/> </field>
   </event>
 
   <event name=kill>
     <description>Process kill system call</description>
-    <field name="pid"> <description>PID of the process</description> <uint size=4/> </field>
-    <field name="target_pid"> <description>PID of the process to kill</description> <uint size=4/> </field>
+    <field name="pid"> <description>PID of the process</description> <uint/> </field>
+    <field name="target_pid"> <description>PID of the process to kill</description> <uint/> </field>
     <field name="signal"> <description>Signal number</description> <typeref name=signal_name/> </field>
   </event>
 
   <event name=signal>
     <description>Process signal reception</description>
-    <field name="pid"> <description>PID of the receiving process</description> <uint size=4/> </field>
+    <field name="pid"> <description>PID of the receiving process</description> <uint/> </field>
     <field name="signal"> <description>Signal number</description> <typeref name=signal_name/> </field>
   </event>
 
   <event name=wakeup>
     <description>Process wakeup</description>
-    <field name="pid"> <description>PID of the receiving process</description> <uint size=4/> </field>
-    <field name="state"> <description>State of the awakened process. -1 unrunnable, 0 runnable, >0 stopped.</description> <int size=4/> </field>
+    <field name="pid"> <description>PID of the receiving process</description> <uint/> </field>
+    <field name="state"> <description>State of the awakened process. -1 unrunnable, 0 runnable, >0 stopped.</description> <int/> </field>
   </event>
 
   <event name=schedchange>
     <description>Scheduling change</description>
-    <field name="out"> <description>Outgoing process</description> <uint size=4/> </field>
-    <field name="in"> <description>Incoming process</description> <uint size=4/> </field>
-    <field name="out_state"> <description>Outgoing process' state. -1 unrunnable, 0 runnable, >0 stopped.</description> <int size=4/> </field>
+    <field name="out"> <description>Outgoing process</description> <uint/> </field>
+    <field name="in"> <description>Incoming process</description> <uint/> </field>
+    <field name="out_state"> <description>Outgoing process' state. -1 unrunnable, 0 runnable, >0 stopped.</description> <int/> </field>
   </event>
 
 </facility>
index f6db18178cb825e3ab6ab46d4e2f0c253b88b0f6..6265f7fbd6e92188062cd14083f1c2e0fbc7a0fe 100644 (file)
 
 
 
-void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset,
-    void *root);
-
-
+void compute_fields_offsets(LttTracefile *tf,
+    LttFacility *fac, LttField *field, off_t *offset, void *root);
 
 
 LttEvent *ltt_event_new()
@@ -462,13 +460,13 @@ LttField *ltt_event_field_element_select(LttEvent *e, LttField *f, gulong i)
  
   if(f->field_type.type_class != LTT_ARRAY &&
      f->field_type.type_class != LTT_SEQUENCE)
-    return ;
+    return NULL;
 
   element_number  = ltt_event_field_element_number(e,f);
   event_type = ltt_event_eventtype(e);
   /* Sanity check for i : 0..n-1 only, and must be lower or equal element_number
    */
-  if(i >= element_number) return;
+  if(i >= element_number) return NULL;
  
   if(f->field_type.type_class == LTT_ARRAY) {
    field = &g_array_index(f->field_type.fields, LttField, 0);
@@ -478,14 +476,15 @@ LttField *ltt_event_field_element_select(LttEvent *e, LttField *f, gulong i)
 
   if(field->field_size != 0) {
     if(f->array_offset + (i * field->field_size) == field->offset_root)
-      return; /* fixed length child, already at the right offset */
+      return field; /* fixed length child, already at the right offset */
     else
       new_offset = f->array_offset + (i * field->field_size);
   } else {
     /* Var. len. child */
     new_offset = g_array_index(f->dynamic_offsets, off_t, i);
   }
-  compute_fields_offsets(e->tracefile, field, &new_offset, e->data);
+  compute_fields_offsets(e->tracefile, 
+      ltt_event_facility(e), field, &new_offset, e->data);
 
   return field;
 }
@@ -691,7 +690,7 @@ size_t get_field_type_size(LttTracefile *tf, LttEventType *event_type,
       g_assert(field->fixed_size == FIELD_FIXED);
                        size = field->field_size;
       align = ltt_align(field->offset_root,
-                                                                                                                               size, event_type->facility->has_alignment);
+                                                                                                                               size, event_type->facility->alignment);
                        field->offset_root += align;
                        field->offset_parent += align;
                        size += align;
@@ -791,14 +790,14 @@ size_t get_field_type_size(LttTracefile *tf, LttEventType *event_type,
  *Function name
  *    compute_fields_offsets : set the precomputable offset of the fields
  *Input params 
- *    tf : tracefile
+ *    fac : facility
  *    field : the field
  *    offset : pointer to the current offset, must be incremented
  ****************************************************************************/
 
 
-void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset,
-    void *root)
+void compute_fields_offsets(LttTracefile *tf, 
+    LttFacility *fac, LttField *field, off_t *offset, void *root)
 {
   LttType *type = &field->field_type;
 
@@ -821,23 +820,29 @@ void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset,
     case LTT_ENUM:
       if(field->fixed_root == FIELD_VARIABLE) {
         /* Align offset on type size */
-        *offset += ltt_align(*offset, get_alignment(tf, field),
-                             tf->has_alignment);
+        *offset += ltt_align(*offset, get_alignment(field),
+                             fac->alignment);
         /* remember offset */
         field->offset_root = *offset;
         /* Increment offset */
         *offset += field->field_size;
+      } else {
+        //g_debug("type before offset : %llu %llu %u\n", *offset,
+        //    field->offset_root,
+        //    field->field_size);
+        *offset = field->offset_root;
+        *offset += field->field_size;
+        //g_debug("type after offset : %llu\n", *offset);
       }
-      /* None of these types has variable size, so we are sure that if
-       * this element has a fixed_root, then the following one will have
-       * a fixed root too, so it does not need the *offset at all.
-       */
       break;
     case LTT_STRING:
       if(field->fixed_root == FIELD_VARIABLE) {
         field->offset_root = *offset;
       }
       *offset += strlen((gchar*)(root+*offset)) + 1;
+      /* Realign the data */
+      *offset += ltt_align(*offset, fac->pointer_size,
+                           fac->alignment);
       break;
     case LTT_ARRAY:
       g_assert(type->fields->len == 1);
@@ -845,8 +850,8 @@ void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset,
         off_t local_offset;
         LttField *child = &g_array_index(type->fields, LttField, 0);
         if(field->fixed_root == FIELD_VARIABLE) {
-          *offset += ltt_align(*offset, get_alignment(tf, field),
-                              tf->has_alignment);
+          *offset += ltt_align(*offset, get_alignment(field),
+                              fac->alignment);
           /* remember offset */
           field->offset_root = *offset;
           field->array_offset = *offset;
@@ -863,12 +868,12 @@ void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset,
                                                     0);
           for(i=0; i<type->size; i++) {
             g_array_append_val(field->dynamic_offsets, *offset);
-            compute_fields_offsets(tf, child, offset, root);
+            compute_fields_offsets(tf, fac, child, offset, root);
           }
         }
   //      local_offset = field->array_offset;
   //      /* Set the offset at position 0 */
-  //      compute_fields_offsets(tf, child, &local_offset, root);
+  //      compute_fields_offsets(tf, fac, child, &local_offset, root);
       }
       break;
     case LTT_SEQUENCE:
@@ -877,17 +882,18 @@ void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset,
         off_t local_offset;
         LttField *child;
         guint i;
+        guint num_elem;
         if(field->fixed_root == FIELD_VARIABLE) {
-          *offset += ltt_align(*offset, get_alignment(tf, field),
-                              tf->has_alignment);
+          *offset += ltt_align(*offset, get_alignment(field),
+                              fac->alignment);
           /* remember offset */
           field->offset_root = *offset;
 
           child = &g_array_index(type->fields, LttField, 0);
-          compute_fields_offsets(tf, child, offset, root);
+          compute_fields_offsets(tf, fac, child, offset, root);
           child = &g_array_index(type->fields, LttField, 1);
-          *offset += ltt_align(*offset, get_alignment(tf, child),
-                               tf->has_alignment);
+          *offset += ltt_align(*offset, get_alignment(child),
+                               fac->alignment);
           field->array_offset = *offset;
 
         } else {
@@ -896,13 +902,20 @@ void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset,
         *offset = field->array_offset;
         field->dynamic_offsets = g_array_set_size(field->dynamic_offsets,
                                                   0);
-        for(i=0; i<ltt_event_field_element_number(&tf->event, field); i++) {
+        num_elem = ltt_event_field_element_number(&tf->event, field);
+        for(i=0; i<num_elem; i++) {
           g_array_append_val(field->dynamic_offsets, *offset);
-          compute_fields_offsets(tf, child, offset, root);
+          compute_fields_offsets(tf, fac, child, offset, root);
         }
+        g_assert(num_elem == field->dynamic_offsets->len);
+
+        /* Realign the data */
+        *offset += ltt_align(*offset, fac->pointer_size,
+                             fac->alignment);
+        
  //       local_offset = field->array_offset;
  //       /* Set the offset at position 0 */
- //       compute_fields_offsets(tf, child, &local_offset, root);
+ //       compute_fields_offsets(tf, fac, child, &local_offset, root);
       }
       break;
     case LTT_STRUCT:
@@ -911,8 +924,8 @@ void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset,
         guint i;
         gint ret=0;
         if(field->fixed_root == FIELD_VARIABLE) {
-          *offset += ltt_align(*offset, get_alignment(tf, field),
-                               tf->has_alignment);
+          *offset += ltt_align(*offset, get_alignment(fac, field),
+                               fac->alignment);
           /* remember offset */
           field->offset_root = *offset;
         } else {
@@ -920,7 +933,7 @@ void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset,
         }
         for(i=0; i<type->fields->len; i++) {
           child = &g_array_index(type->fields, LttField, i);
-          compute_fields_offsets(tf, child, offset, root);
+          compute_fields_offsets(tf, fac, child, offset, root);
         }
       }
       break;
@@ -930,15 +943,15 @@ void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset,
         guint i;
         gint ret=0;
         if(field->fixed_root == FIELD_VARIABLE) {
-          *offset += ltt_align(*offset, get_alignment(tf, field),
-                               tf->has_alignment);
+          *offset += ltt_align(*offset, get_alignment(field),
+                               fac->alignment);
           /* remember offset */
           field->offset_root = *offset;
         }
         for(i=0; i<type->fields->len; i++) {
           *offset = field->offset_root;
           child = &g_array_index(type->fields, LttField, i);
-          compute_fields_offsets(tf, child, offset, root);
+          compute_fields_offsets(tf, fac, child, offset, root);
         }
         *offset = field->offset_root + field->field_size;
       }
@@ -959,17 +972,16 @@ void compute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset,
  *    event : event type
  *
  ****************************************************************************/
-void compute_offsets(LttTracefile *tf, LttEventType *event, off_t *offset,
-      void *root)
+void compute_offsets(LttTracefile *tf, LttFacility *fac,
+    LttEventType *event, off_t *offset, void *root)
 {
   guint i;
-  gint ret;
 
   /* compute all variable offsets */
   for(i=0; i<event->fields->len; i++) {
+    //g_debug("computing offset %u of %u\n", i, event->fields->len-1);
     LttField *field = &g_array_index(event->fields, LttField, i);
-    compute_fields_offsets(tf, field, offset, root);
-    if(ret) break;
+    compute_fields_offsets(tf, fac, field, offset, root);
   }
 
 }
index 209ba36103f86348490f143c97491d5e3d4a00b8..f243851f6033f84c0ee4ad2f921ab699f32ecb14 100644 (file)
@@ -127,7 +127,7 @@ double ltt_event_get_double(LttEvent *e, LttField *f);
 
 gchar *ltt_event_get_string(LttEvent *e, LttField *f);
 
-void compute_offsets(LttTracefile *tf, LttEventType *event, off_t *offset,
-      void *root);
+void compute_offsets(LttTracefile *tf, LttFacility *fac,
+    LttEventType *event, off_t *offset, void *root);
 
 #endif // EVENT_H
index 252c6759c49ac65bd9f9eda3718a1a23b828fa9a..1e49b8d28b8f2eacd30d0de650e3c763391de233 100644 (file)
@@ -294,7 +294,7 @@ void construct_fields(LttFacility *fac,
   type->enum_map = NULL;
   type->fields = NULL;
   type->fields_by_name = NULL;
+
   switch(td->type) {
     case INT_FIXED:
       type->type_class = LTT_INT_FIXED;
@@ -315,6 +315,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;
@@ -331,6 +332,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;
@@ -365,13 +367,14 @@ void construct_fields(LttFacility *fac,
       type->size = fac->int_size;
       {
         guint i;
-        type->enum_map = g_hash_table_new(g_int_hash, g_int_equal);
+        type->enum_map = g_hash_table_new(g_direct_hash, g_direct_equal);
         for(i=0; i<td->labels.position; i++) {
           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;
index 8af6e3bff4e8c17bfd0fa3e4ef7c47c9a0f6c049..72d2ebf0c50e34b182883afb9a89af78f466c1b8 100644 (file)
@@ -460,7 +460,5 @@ static inline unsigned int ltt_align(size_t align_drift,
        return ((alignment - align_drift) & (alignment-1));
 }
 
-off_t field_align(LttTracefile *tf, LttField *field, off_t offset);
-
 
 #endif /* LTT_PRIVATE_H */
index bfa645643fde76932c19559ed7bfec597f2a2429..921c559ae5fed7e131107fc14f79db99d33b6fce 100644 (file)
@@ -784,29 +784,29 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType,
   }
   else if(strcmp(token,"char") == 0) {
     t->type = CHAR;
-               t->size = 1;
     getTypeAttributes(in, t, unnamed_types, named_types);
+               t->size = 1;
     getForwardslash(in);
     getRAnglebracket(in); 
   }
   else if(strcmp(token,"uchar") == 0) {
     t->type = UCHAR;
-               t->size = 1;
     getTypeAttributes(in, t, unnamed_types, named_types);
+               t->size = 1;
     getForwardslash(in);
     getRAnglebracket(in); 
   }
   else if(strcmp(token,"short") == 0) {
     t->type = SHORT;
-               t->size = 2;
     getTypeAttributes(in, t, unnamed_types, named_types);
+               t->size = 2;
     getForwardslash(in);
     getRAnglebracket(in); 
   }
   else if(strcmp(token,"ushort") == 0) {
     t->type = USHORT;
-               t->size = 2;
     getTypeAttributes(in, t, unnamed_types, named_types);
+               t->size = 2;
     getForwardslash(in);
     getRAnglebracket(in); 
   }
@@ -1344,8 +1344,7 @@ unsigned long getTypeChecksum(unsigned long aCrc, type_descriptor_t * type)
       flag = 1;
       break;
     case SEQUENCE:
-      sprintf(buf,"%zu", type->size);
-      str = appendString("sequence ",buf);
+      str = allocAndCopy("sequence ");
       flag = 1;
       break;
     case STRUCT:
index 5ddabdbd0adebe857d717cad29f202c400b5e4ee..5fbf53cb32fc2d1842b291787ef115d4068da5a8 100644 (file)
@@ -106,7 +106,7 @@ static int ltt_seek_next_event(LttTracefile *tf);
 void ltt_update_event_size(LttTracefile *tf);
 
 
-void precompute_offsets(LttTracefile *tf, LttEventType *event);
+void precompute_offsets(LttFacility *fac, LttEventType *event);
 
 #if 0
 /* Functions to parse system.xml file (using glib xml parser) */
@@ -951,6 +951,7 @@ static int ltt_process_facility_tracefile(LttTracefile *tf)
       struct LttFacilityLoad *fac_load_data;
       struct LttStateDumpFacilityLoad *fac_state_dump_load_data;
       char *fac_name;
+      void *pos;
 
       // FIXME align
       switch((enum ltt_core_events)tf->event.event_id) {
@@ -958,9 +959,10 @@ static int ltt_process_facility_tracefile(LttTracefile *tf)
           fac_name = (char*)(tf->event.data);
           g_debug("Doing LTT_EVENT_FACILITY_LOAD of facility %s",
               fac_name);
-          fac_load_data =
-            (struct LttFacilityLoad *)
-                (tf->event.data + strlen(fac_name) + 1);
+          pos = (tf->event.data + strlen(fac_name) + 1);
+          pos += ltt_align((size_t)pos, sizeof(guint32), tf->has_alignment);
+          fac_load_data = (struct LttFacilityLoad *)pos;
+
           fac = &g_array_index (tf->trace->facilities_by_num, LttFacility,
               ltt_get_uint32(LTT_GET_BO(tf), &fac_load_data->id));
           /* facility may already exist if trace is paused/unpaused */
@@ -988,7 +990,7 @@ static int ltt_process_facility_tracefile(LttTracefile *tf)
           /* Preset the field offsets */
           for(i=0; i<fac->events->len; i++){
             et = &g_array_index(fac->events, LttEventType, i);
-            precompute_offsets(tf, et);
+            precompute_offsets(fac, et);
           }
 
           fac->exists = 1;
@@ -1013,9 +1015,10 @@ static int ltt_process_facility_tracefile(LttTracefile *tf)
           fac_name = (char*)(tf->event.data);
           g_debug("Doing LTT_EVENT_STATE_DUMP_FACILITY_LOAD of facility %s",
               fac_name);
-          fac_state_dump_load_data =
-            (struct LttStateDumpFacilityLoad *)
-                (tf->event.data + strlen(fac_name) + 1);
+          pos = (tf->event.data + strlen(fac_name) + 1);
+          pos += ltt_align((size_t)pos, sizeof(guint32), tf->has_alignment);
+          fac_state_dump_load_data = (struct LttStateDumpFacilityLoad *)pos;
+
           fac = &g_array_index (tf->trace->facilities_by_num, LttFacility,
               ltt_get_uint32(LTT_GET_BO(tf), &fac_state_dump_load_data->id));
           /* facility may already exist if trace is paused/unpaused */
@@ -1043,7 +1046,7 @@ static int ltt_process_facility_tracefile(LttTracefile *tf)
           /* Preset the field offsets */
           for(i=0; i<fac->events->len; i++){
             et = &g_array_index(fac->events, LttEventType, i);
-            precompute_offsets(tf, et);
+            precompute_offsets(fac, et);
           }
 
           fac->exists = 1;
@@ -1863,6 +1866,7 @@ void ltt_update_event_size(LttTracefile *tf)
   case LTT_EVENT_FACILITY_LOAD:
     size = strlen((char*)tf->event.data) + 1;
     //g_debug("Update Event facility load of facility %s", (char*)tf->event.data);
+    size += ltt_align(size, sizeof(guint32), tf->has_alignment);
     size += sizeof(struct LttFacilityLoad);
     break;
   case LTT_EVENT_FACILITY_UNLOAD:
@@ -1871,6 +1875,7 @@ void ltt_update_event_size(LttTracefile *tf)
     break;
   case LTT_EVENT_STATE_DUMP_FACILITY_LOAD:
     size = strlen((char*)tf->event.data) + 1;
+    size += ltt_align(size, sizeof(guint32), tf->has_alignment);
     //g_debug("Update Event facility load state dump of facility %s",
     //    (char*)tf->event.data);
     size += sizeof(struct LttStateDumpFacilityLoad);
@@ -1908,7 +1913,7 @@ void ltt_update_event_size(LttTracefile *tf)
     }
     
     /* Compute the dynamic offsets */
-    compute_offsets(tf, event_type, &size, tf->event.data);
+    compute_offsets(tf, f, event_type, &size, tf->event.data);
 
     //g_debug("Event root field : f.e %hhu.%hhu size %zd",
     //    tf->event.facility_id,
@@ -2044,13 +2049,12 @@ void set_fields_offsets(LttTracefile *tf, LttEventType *event_type)
  *Function name
  *    get_alignment : Get the alignment needed for a field.
  *Input params 
- *    tf : tracefile
  *    field : field
  *
  *    returns : The size on which it must be aligned.
  *
  ****************************************************************************/
-off_t get_alignment(LttTracefile *tf, LttField *field)
+off_t get_alignment(LttField *field)
 {
   LttType *type = &field->field_type;
 
@@ -2081,7 +2085,7 @@ off_t get_alignment(LttTracefile *tf, LttField *field)
       g_assert(type->fields->len == 1);
       {
         LttField *child = &g_array_index(type->fields, LttField, 0);
-        return get_alignment(tf, child);
+        return get_alignment(child);
       }
       break;
     case LTT_SEQUENCE:
@@ -2090,10 +2094,10 @@ off_t get_alignment(LttTracefile *tf, LttField *field)
         off_t localign = 0;
         LttField *child = &g_array_index(type->fields, LttField, 0);
 
-        localign = max(localign, get_alignment(tf, child));
+        localign = max(localign, get_alignment(child));
 
         child = &g_array_index(type->fields, LttField, 1);
-        localign = max(localign, get_alignment(tf, child));
+        localign = max(localign, get_alignment(child));
         
         return localign;
       }
@@ -2106,7 +2110,7 @@ off_t get_alignment(LttTracefile *tf, LttField *field)
         
         for(i=0; i<type->fields->len; i++) {
           LttField *child = &g_array_index(type->fields, LttField, i);
-          localign = max(localign, get_alignment(tf, child));
+          localign = max(localign, get_alignment(child));
         }
         return localign;
       }
@@ -2129,7 +2133,7 @@ off_t get_alignment(LttTracefile *tf, LttField *field)
  *
  ****************************************************************************/
 
-void field_compute_static_size(LttTracefile *tf, LttField *field)
+void field_compute_static_size(LttFacility *fac, LttField *field)
 {
   LttType *type = &field->field_type;
 
@@ -2159,7 +2163,7 @@ void field_compute_static_size(LttTracefile *tf, LttField *field)
       g_assert(type->fields->len == 1);
       {
         LttField *child = &g_array_index(type->fields, LttField, 0);
-        field_compute_static_size(tf, child);
+        field_compute_static_size(fac, child);
         
         if(child->field_size != 0) {
           field->field_size = type->size * child->field_size;
@@ -2175,7 +2179,7 @@ void field_compute_static_size(LttTracefile *tf, LttField *field)
       {
         off_t local_offset = 0;
         LttField *child = &g_array_index(type->fields, LttField, 1);
-        field_compute_static_size(tf, child);
+        field_compute_static_size(fac, child);
         field->field_size = 0;
         type->size = 0;
         if(child->field_size != 0) {
@@ -2190,10 +2194,10 @@ void field_compute_static_size(LttTracefile *tf, LttField *field)
         guint i;
         for(i=0;i<type->fields->len;i++) {
           LttField *child = &g_array_index(type->fields, LttField, i);
-          field_compute_static_size(tf, child);
+          field_compute_static_size(fac, child);
           if(child->field_size != 0) {
-            type->size += ltt_align(type->size, get_alignment(tf, child),
-                                    tf->has_alignment);
+            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
@@ -2217,7 +2221,7 @@ void field_compute_static_size(LttTracefile *tf, LttField *field)
  *Function name
  *    precompute_fields_offsets : set the precomputable offset of the fields
  *Input params 
- *    tf : tracefile
+ *    fac : facility
  *    field : the field
  *    offset : pointer to the current offset, must be incremented
  *
@@ -2226,7 +2230,7 @@ void field_compute_static_size(LttTracefile *tf, LttField *field)
  ****************************************************************************/
 
 
-gint precompute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset)
+gint precompute_fields_offsets(LttFacility *fac, LttField *field, off_t *offset)
 {
   LttType *type = &field->field_type;
 
@@ -2247,9 +2251,10 @@ gint precompute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset)
     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(tf, field),
-                           tf->has_alignment);
+      *offset += ltt_align(*offset, get_alignment(field),
+                           fac->alignment);
       /* remember offset */
       field->offset_root = *offset;
       field->fixed_root = FIELD_FIXED;
@@ -2267,8 +2272,8 @@ gint precompute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset)
       {
         LttField *child = &g_array_index(type->fields, LttField, 0);
 
-        *offset += ltt_align(*offset, get_alignment(tf, field),
-                            tf->has_alignment);
+        *offset += ltt_align(*offset, get_alignment(field),
+                             fac->alignment);
         
         /* remember offset */
         field->offset_root = *offset;
@@ -2294,23 +2299,23 @@ gint precompute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset)
         LttField *child;
         guint ret;
 
-        *offset += ltt_align(*offset, get_alignment(tf, field),
-                             tf->has_alignment);
+        *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(tf, child, offset);
+        ret = precompute_fields_offsets(fac, child, offset);
         g_assert(ret == 0); /* Seq len cannot have variable len */
 
         child = &g_array_index(type->fields, LttField, 1);
-        *offset += ltt_align(*offset, get_alignment(tf, child),
-                             tf->has_alignment);
+        *offset += ltt_align(*offset, get_alignment(child),
+                             fac->alignment);
         field->array_offset = *offset;
-        /* Set the offset position at position 0 */
-        ret = precompute_fields_offsets(tf, child, offset);
+        /* Let the child be variable. */
+        //ret = precompute_fields_offsets(fac, child, offset);
 
         /* Cannot precompute fields offsets of sequence members, and has
          * variable length. */
@@ -2323,15 +2328,15 @@ gint precompute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset)
         guint i;
         gint ret=0;
 
-        *offset += ltt_align(*offset, get_alignment(tf, field),
-                             tf->has_alignment);
+        *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(tf, child, offset);
+          ret = precompute_fields_offsets(fac, child, offset);
 
           if(ret) break;
         }
@@ -2344,8 +2349,8 @@ gint precompute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset)
         guint i;
         gint ret=0;
 
-        *offset += ltt_align(*offset, get_alignment(tf, field),
-                             tf->has_alignment);
+        *offset += ltt_align(*offset, get_alignment(field),
+                             fac->alignment);
         /* remember offset */
         field->offset_root = *offset;
         field->fixed_root = FIELD_FIXED;
@@ -2353,7 +2358,7 @@ gint precompute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset)
         for(i=0; i< type->fields->len; i++) {
           *offset = field->offset_root;
           child = &g_array_index(type->fields, LttField, i);
-          ret = precompute_fields_offsets(tf, child, offset);
+          ret = precompute_fields_offsets(fac, child, offset);
 
           if(ret) break;
         }
@@ -2379,7 +2384,7 @@ gint precompute_fields_offsets(LttTracefile *tf, LttField *field, off_t *offset)
  *    event : event type
  *
  ****************************************************************************/
-void precompute_offsets(LttTracefile *tf, LttEventType *event)
+void precompute_offsets(LttFacility *fac, LttEventType *event)
 {
   guint i;
   off_t offset = 0;
@@ -2389,13 +2394,13 @@ void precompute_offsets(LttTracefile *tf, LttEventType *event)
    * arrays, struct and unions, which is not done by the parser */
   for(i=0; i<event->fields->len; i++) {
     LttField *field = &g_array_index(event->fields, LttField, i);
-    field_compute_static_size(tf, field);
+    field_compute_static_size(fac, field);
   }
   
   /* Precompute all known offsets */
   for(i=0; i<event->fields->len; i++) {
     LttField *field = &g_array_index(event->fields, LttField, i);
-    ret = precompute_fields_offsets(tf, field, &offset);
+    ret = precompute_fields_offsets(fac, field, &offset);
     if(ret) break;
   }
 }
index 84f3af795adab287833024dd45a15b36119099a1..50c7c67473dbcb9560950892d83633b296a1f731 100644 (file)
@@ -190,6 +190,9 @@ void lttv_event_to_string(LttEvent *e, GString *s,
   event_type = ltt_event_eventtype(e);
   
   num_fields = ltt_eventtype_num_fields(event_type);
+  if(num_fields == 0) return;
+  g_string_append_printf(s, " ");
+  g_string_append_printf(s, "{ ");
   for(i=0; i<num_fields; i++) {
     field = ltt_eventtype_field(event_type, i);
     if(field_names) {
@@ -198,7 +201,9 @@ void lttv_event_to_string(LttEvent *e, GString *s,
         g_string_append_printf(s, "%s = ", g_quark_to_string(name));
     }
     lttv_print_field(e, field, s, field_names);
+    if(i != num_fields-1) g_string_append_printf(s, ", ");
   }
+  g_string_append_printf(s, " }");
 } 
 
 static void init()
index 5d757e035feb3206fb45bab515b74aac2a876780..728e589928657b44f29408c59f1680cb3019ed3c 100644 (file)
@@ -1375,14 +1375,19 @@ static gboolean process_exec(void *hook_data, void *call_data)
   LttvTraceState *ts = (LttvTraceState*)s->parent.t_context;
   LttEvent *e = ltt_tracefile_get_event(s->parent.tf);
   LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data;
-  gchar *name;
+  //gchar *name;
   guint cpu = ltt_tracefile_num(s->parent.tf);
   LttvProcessState *process = ts->running_process[cpu];
 
   /* PID of the process to release */
-  name = ltt_event_get_string(e, thf->f1);
-
-  process->name = g_quark_from_string(name);
+  guint64 name_len = ltt_event_field_element_number(e, thf->f1);
+  //name = ltt_event_get_string(e, thf->f1);
+  gchar *name_begin = ltt_event_field_element_select(e, thf->f1, 0);
+  gchar *null_term_name = g_new(gchar, name_len+1);
+  memcpy(null_term_name, name_begin, name_len);
+  null_term_name[name_len] = '\0';
+
+  process->name = g_quark_from_string(null_term_name);
 
   return FALSE;
 }
This page took 0.039463 seconds and 4 git commands to generate.