seek time refix
[lttv.git] / ltt / branches / poly / ltt / tracefile.c
index 24fe6fe5f5e7d8760e661a1531fa7db1f50e3015..144ee8cfa0dd60a1b389ff12acc919e62b476291 100644 (file)
@@ -1317,11 +1317,17 @@ void ltt_trace_time_span_get(LttTrace *t, LttTime *start, LttTime *end)
  *Get the name of a tracefile
  ****************************************************************************/
 
-GQuark ltt_tracefile_name(LttTracefile *tf)
+GQuark ltt_tracefile_name(const LttTracefile *tf)
 {
   return tf->name;
 }
 
+GQuark ltt_tracefile_long_name(const LttTracefile *tf)
+{
+  return tf->long_name;
+}
+
+
 
 guint ltt_tracefile_num(LttTracefile *tf)
 {
@@ -1425,16 +1431,16 @@ int ltt_tracefile_seek_time(LttTracefile *tf, LttTime time)
         if(ret == ERANGE) goto range; /* ERANGE or EPERM */
         else if(ret) goto fail;
 
-        if(ltt_time_compare(time, tf->event.event_time) >= 0)
+        if(ltt_time_compare(time, tf->event.event_time) <= 0)
           goto found;
       }
 
     } else if(ltt_time_compare(time, tf->buffer.begin.timestamp) < 0) {
       /* go to lower part */
-      high = block_num;
+      high = block_num - 1;
     } else if(ltt_time_compare(time, tf->buffer.end.timestamp) > 0) {
       /* go to higher part */
-      low = block_num;
+      low = block_num + 1;
     } else {/* The event is right in the buffer!
                (or in the next buffer first event) */
       while(1) {
@@ -1442,7 +1448,7 @@ int ltt_tracefile_seek_time(LttTracefile *tf, LttTime time)
         if(ret == ERANGE) goto range; /* ERANGE or EPERM */
         else if(ret) goto fail;
 
-        if(ltt_time_compare(time, tf->event.event_time) >= 0)
+        if(ltt_time_compare(time, tf->event.event_time) <= 0)
           break;
       }
       goto found;
@@ -1719,15 +1725,15 @@ static gint map_block(LttTracefile * tf, guint block_num)
   tf->buffer.begin.timestamp = ltt_get_time(LTT_GET_BO(tf),
                                               &header->begin.timestamp);
   tf->buffer.begin.timestamp.tv_nsec *= NSEC_PER_USEC;
-  g_debug("block %u begin : %lu.%lu", block_num,
-      tf->buffer.begin.timestamp.tv_sec, tf->buffer.begin.timestamp.tv_nsec);
+  //g_debug("block %u begin : %lu.%lu", block_num,
+  //    tf->buffer.begin.timestamp.tv_sec, tf->buffer.begin.timestamp.tv_nsec);
   tf->buffer.begin.cycle_count = ltt_get_uint64(LTT_GET_BO(tf),
                                               &header->begin.cycle_count);
   tf->buffer.end.timestamp = ltt_get_time(LTT_GET_BO(tf),
                                               &header->end.timestamp);
   tf->buffer.end.timestamp.tv_nsec *= NSEC_PER_USEC;
-  g_debug("block %u end : %lu.%lu", block_num,
-      tf->buffer.end.timestamp.tv_sec, tf->buffer.end.timestamp.tv_nsec);
+  //g_debug("block %u end : %lu.%lu", block_num,
+  //    tf->buffer.end.timestamp.tv_sec, tf->buffer.end.timestamp.tv_nsec);
   tf->buffer.end.cycle_count = ltt_get_uint64(LTT_GET_BO(tf),
                                               &header->end.cycle_count);
   tf->buffer.lost_size = ltt_get_uint32(LTT_GET_BO(tf),
@@ -1774,21 +1780,21 @@ void ltt_update_event_size(LttTracefile *tf)
     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);
+    //g_debug("Update Event facility load of facility %s", (char*)tf->event.data);
     size += sizeof(struct LttFacilityLoad);
     break;
   case LTT_EVENT_FACILITY_UNLOAD:
-    g_debug("Update 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;
-    g_debug("Update Event facility load state dump of facility %s",
-        (char*)tf->event.data);
+    //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");
+    //g_debug("Update Event heartbeat");
     size = sizeof(TimeHeartbeat);
     break;
   default:
@@ -1825,9 +1831,9 @@ void ltt_update_event_size(LttTracefile *tf)
     else
       size = 0;
 
-    g_debug("Event root field : f.e %hhu.%hhu size %zd",
-        tf->event.facility_id,
-        tf->event.event_id, size);
+    //g_debug("Event root field : f.e %hhu.%hhu size %zd",
+    //    tf->event.facility_id,
+    //    tf->event.event_id, size);
   }
   
   tf->event.data_size = size;
@@ -1883,6 +1889,7 @@ static int ltt_seek_next_event(LttTracefile *tf)
     ret = ERANGE;
     goto found;
   }
+  g_assert(tf->event.offset < tf->buf_size - tf->buffer.lost_size);
 
 found:
   return ret;
This page took 0.026429 seconds and 4 git commands to generate.