new LttEventPosition structure for backword seeking
[lttv.git] / ltt / branches / poly / ltt / tracefile.c
index 05978a489b306d15f632a086674c6919506ab7ac..d78125873222f972399eb6efafa385265da726be 100644 (file)
@@ -670,6 +670,15 @@ char *ltt_tracefile_name(LttTracefile *tf)
   return tf->name;
 }
 
+/*****************************************************************************
+ * Get the number of blocks in the tracefile 
+ ****************************************************************************/
+
+unsigned ltt_tracefile_block_number(LttTracefile *tf)
+{
+  return tf->block_number; 
+}
+
 /*****************************************************************************
  *Function name
  *    ltt_tracefile_seek_time: seek to the first event of the trace with time 
@@ -742,6 +751,32 @@ void ltt_tracefile_seek_time(LttTracefile *t, LttTime time)
   }
 }
 
+/*****************************************************************************
+ * Seek to the first event with position equal or larger to ep 
+ ****************************************************************************/
+
+void ltt_tracefile_seek_position(LttTracefile *t, LttEventPosition *ep)
+{
+  //if we are at the right place, just return
+  if(t->which_block == ep->block_num && t->which_event == ep->event_num)
+    return;
+  
+  if(t->which_block == ep->block_num) updateTracefile(t);
+  else readBlock(t,ep->block_num);
+
+  //event offset is availiable
+  if(ep->old_position){
+    t->cur_heart_beat_number = ep->heart_beat_number;
+    t->cur_event_pos = t->buffer + ep->event_offset;
+    return;
+  }
+
+  //only block number and event index are availiable
+  while(t->which_event < ep->event_num) ltt_tracefile_read(t);
+
+  return;
+}
+
 /*****************************************************************************
  *Function name
  *    ltt_tracefile_read : read the current event, set the pointer to the next
This page took 0.02258 seconds and 4 git commands to generate.