update compat
[lttv.git] / ltt / branches / poly / ltt / tracefile.c
index f28a1b21e25c5414ae798739a4a8498c15c161dc..72eb3a6efc0a4af46bb0a21859b373666de68dc7 100644 (file)
@@ -272,7 +272,9 @@ int parse_trace_header(void *header, LttTracefile *tf, LttTrace *t)
           t->start_time.tv_nsec *= 1000; /* microsec to nanosec */
 
           t->start_time_from_tsc = ltt_time_from_uint64(
-              (double)t->start_tsc * 1000000.0 / (double)t->start_freq);
+              (double)t->start_tsc
+              * (1000000000.0 / tf->trace->freq_scale)
+             / (double)t->start_freq);
         }
       }
       break;
@@ -664,6 +666,7 @@ int get_tracefile_name_number(gchar *raw_name,
   if(i==-1) { /* Either not found or name length is 0 */
                /* This is a userspace tracefile */
                strncpy(char_name, raw_name, raw_name_len);
+               char_name[raw_name_len] = '\0';
                *name = g_quark_from_string(char_name);
                *num = 0;       /* unknown cpu */
                for(i=0;i<raw_name_len;i++) {
@@ -1081,7 +1084,7 @@ static int ltt_process_facility_tracefile(LttTracefile *tf)
           g_debug("Doing LTT_EVENT_FACILITY_LOAD of facility %s",
               fac_name);
           pos = (tf->event.data + strlen(fac_name) + 1);
-          pos += ltt_align((size_t)pos, sizeof(guint32), tf->has_alignment);
+          pos += ltt_align((size_t)pos, tf->trace->arch_size, tf->has_alignment);
           fac_load_data = (struct LttFacilityLoad *)pos;
 
           fac = &g_array_index (tf->trace->facilities_by_num, LttFacility,
@@ -1137,7 +1140,7 @@ static int ltt_process_facility_tracefile(LttTracefile *tf)
           g_debug("Doing LTT_EVENT_STATE_DUMP_FACILITY_LOAD of facility %s",
               fac_name);
           pos = (tf->event.data + strlen(fac_name) + 1);
-          pos += ltt_align((size_t)pos, sizeof(guint32), tf->has_alignment);
+          pos += ltt_align((size_t)pos, tf->trace->arch_size, tf->has_alignment);
           fac_state_dump_load_data = (struct LttStateDumpFacilityLoad *)pos;
 
           fac = &g_array_index (tf->trace->facilities_by_num, LttFacility,
@@ -2001,71 +2004,73 @@ map_error:
 void ltt_update_event_size(LttTracefile *tf)
 {
   off_t size = 0;
-
-  /* Specific handling of core events : necessary to read the facility control
-   * tracefile. */
   LttFacility *f = ltt_trace_get_facility_by_num(tf->trace, 
                                           tf->event.facility_id);
-
-  if(likely(tf->event.facility_id == LTT_FACILITY_CORE)) {
-    switch((enum ltt_core_events)tf->event.event_id) {
-  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:
-    //g_debug("Update Event facility unload");
-    size = sizeof(struct LttFacilityUnload);
-    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);
-    break;
-  case LTT_EVENT_HEARTBEAT:
-    //g_debug("Update Event heartbeat");
-    size = sizeof(TimeHeartbeat);
-    break;
-  default:
-    g_warning("Error in getting event size : tracefile %s, "
-        "unknown event id %hhu in core facility.",
-        g_quark_to_string(tf->name),
-        tf->event.event_id);
-    goto event_id_error;
-
-    }
-  } else {
-    if(!f->exists) {
+  if(!f->exists) {
+    /* Specific handling of core events : necessary to read the facility control
+     * tracefile. */
+    if(likely(tf->event.facility_id == LTT_FACILITY_CORE)) {
+      switch((enum ltt_core_events)tf->event.event_id) {
+    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:
+      //g_debug("Update Event facility unload");
+      size = sizeof(struct LttFacilityUnload);
+      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);
+      break;
+    case LTT_EVENT_HEARTBEAT:
+      //g_debug("Update Event heartbeat");
+      size = sizeof(TimeHeartbeat);
+      break;
+    default:
+      g_warning("Error in getting event size : tracefile %s, "
+          "unknown event id %hhu in core facility.",
+          g_quark_to_string(tf->name),
+          tf->event.event_id);
+      goto event_id_error;
+  
+      }
+      goto no_offset;  /* Skip the field computation */
+    } else {
       g_warning("Unknown facility %hhu (0x%hhx) in tracefile %s",
           tf->event.facility_id,
           tf->event.facility_id,
           g_quark_to_string(tf->name));
       goto facility_error;
     }
+  }
 
-    LttEventType *event_type = 
-      ltt_facility_eventtype_get(f, tf->event.event_id);
-
-    if(!event_type) {
-      g_warning("Unknown event id %hhu in facility %s in tracefile %s",
-          tf->event.event_id,
-          g_quark_to_string(f->name),
-          g_quark_to_string(tf->name));
-      goto event_type_error;
-    }
-    
-    /* Compute the dynamic offsets */
-    compute_offsets(tf, f, event_type, &size, tf->event.data);
+  LttEventType *event_type = 
+    ltt_facility_eventtype_get(f, tf->event.event_id);
 
-    //g_debug("Event root field : f.e %hhu.%hhu size %zd",
-    //    tf->event.facility_id,
-    //    tf->event.event_id, size);
+  if(!event_type) {
+    g_warning("Unknown event id %hhu in facility %s in tracefile %s",
+        tf->event.event_id,
+        g_quark_to_string(f->name),
+        g_quark_to_string(tf->name));
+    goto event_type_error;
   }
   
+  /* Compute the dynamic offsets */
+  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,
+  //    tf->event.event_id, size);
+
+no_offset: 
   tf->event.data_size = size;
   
   /* Check consistency between kernel and LTTV structure sizes */
This page took 0.025193 seconds and 4 git commands to generate.