new LttEventPosition structure for backword seeking
authoryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 15 Sep 2003 19:33:43 +0000 (19:33 +0000)
committeryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 15 Sep 2003 19:33:43 +0000 (19:33 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@237 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/include/ltt/event.h
ltt/branches/poly/include/ltt/ltt-private.h
ltt/branches/poly/include/ltt/ltt.h
ltt/branches/poly/include/ltt/trace.h
ltt/branches/poly/ltt/event.c
ltt/branches/poly/ltt/tracefile.c

index 96c71ce7b49865cbd1d1599eb4c7cddce1fc2f94..35e78778e1333f01329af9105e84549980f940a9 100644 (file)
@@ -34,6 +34,22 @@ LttTime ltt_event_time(LttEvent *e);
 LttCycleCount ltt_event_cycle_count(LttEvent *e);
 
 
+/* Obtain the position of the event within the tracefile. This
+   is used to seek back to this position later or to seek to another
+   position, computed relative to this position. The event position
+   structure is opaque and contains several fields, only two
+   of which are user accessible: block number and event index
+   within the block. */
+
+void ltt_event_position(LttEvent *e, LttEventPosition *ep);
+
+void ltt_event_position_get(LttEventPosition *ep,
+    unsigned *block_number, unsigned *index_in_block);
+
+void ltt_event_position_set(LttEventPosition *ep,
+    unsigned block_number, unsigned index_in_block);
+
+
 /* CPU id of the event */
 
 unsigned ltt_event_cpu_id(LttEvent *e);
index 94bc1ebd6c614ca7d6b9f15bfb2afaa40ea9475b..30400f5502a7c102e7306aa1c4201e318bde9d82 100644 (file)
@@ -146,6 +146,7 @@ struct _LttTrace{
   guint control_tracefile_number;           //the number of control files 
   guint per_cpu_tracefile_number;           //the number of per cpu files 
   LttSystemDescription * system_description;//system description 
+
   GPtrArray *control_tracefiles;            //array of control tracefiles 
   GPtrArray *per_cpu_tracefiles;            //array of per cpu tracefiles 
   GPtrArray *facilities;                    //array of facilities 
@@ -153,6 +154,16 @@ struct _LttTrace{
   LttArchEndian my_arch_endian;             //endian type of the local machine
 };
 
+struct _LttEventPosition{
+  unsigned      block_num;          //block which contains the event 
+  unsigned      event_num;          //event index in the block
+  unsigned      event_offset;       //event position in the block
+  LttTime       event_time;         //the time of the event
+  LttCycleCount event_cycle_count;  //the cycle count of the event
+  unsigned      heart_beat_number;  //current number of heart beats  
+  gboolean      old_position;       //flag to show if it is the position
+                                    //being remembered
+};
 
 /*****************************************************************************
  macro for size of some data types
index 1da397f365d7f8e816fa87a363fd242008139764..296c82218b3462e27fd6407c80f29aee464ab997 100644 (file)
@@ -82,6 +82,11 @@ typedef struct _LttTime {
 
 typedef uint64_t LttCycleCount;
 
+/* Event positions are used to seek within a tracefile based on
+   the block number and event position within the block. */
+
+typedef struct _LttEventPosition LttEventPosition;
+
 
 /* Differences between architectures include word sizes, endianess,
    alignment, floating point format and calling conventions. For a
index e96e73e4573c072bedecf16e5eacbd734d1a2703..ac3335a1927108c21ecf195dd12ea42e5d86bf8b 100644 (file)
@@ -99,10 +99,19 @@ LttTracefile *ltt_trace_per_cpu_tracefile_get(LttTrace *t, unsigned i);
 char *ltt_tracefile_name(LttTracefile *tf);
 
 
+/* Get the number of blocks in the tracefile */
+
+unsigned ltt_tracefile_block_number(LttTracefile *tf);
+
+
 /* Seek to the first event of the trace with time larger or equal to time */
 
 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);
 
 /* Read the next event */
 
index ad7e6c33366fb0e822b8dd2e19993cd1ece75b9e..7ef6737728bbba7cbeebd9ee8cc58f81205fd019 100644 (file)
@@ -181,6 +181,57 @@ LttCycleCount ltt_event_cycle_count(LttEvent *e)
   return e->event_cycle_count;
 }
 
+/*****************************************************************************
+ *Function name
+ *    ltt_event_position : get the event's position
+ *Input params
+ *    e                  : an instance of an event type   
+ *    ep                 : a pointer to event's position structure
+ ****************************************************************************/
+
+void ltt_event_position(LttEvent *e, LttEventPosition *ep)
+{
+  ep->block_num         = e->which_block;
+  ep->event_num         = e->which_event;
+  ep->event_time        = e->event_time;
+  ep->event_cycle_count = e->event_cycle_count;
+  ep->heart_beat_number = e->tracefile->cur_heart_beat_number;
+  ep->old_position      = TRUE;
+  ep->event_offset      = e->data - e->tracefile->buffer - EVENT_HEADER_SIZE ;
+}
+
+/*****************************************************************************
+ *Function name
+ *    ltt_event_position_get : get the block number and index of the event
+ *Input params
+ *    ep                     : a pointer to event's position structure
+ *    block_number           : the block number of the event
+ *    index_in_block         : the index of the event within the block
+ ****************************************************************************/
+
+void ltt_event_position_get(LttEventPosition *ep,
+    unsigned *block_number, unsigned *index_in_block)
+{
+  *block_number   = ep->block_num;
+  *index_in_block = ep->event_num;
+}
+
+/*****************************************************************************
+ *Function name
+ *    ltt_event_position_set : set the block number and index of the event
+ *Input params
+ *    ep                     : a pointer to event's position structure
+ *    block_number           : the block number of the event
+ *    index_in_block         : the index of the event within the block
+ ****************************************************************************/
+
+void ltt_event_position_set(LttEventPosition *ep,
+    unsigned block_number, unsigned index_in_block)
+{
+  ep->block_num = block_number;
+  ep->event_num = index_in_block;
+}
+
 /*****************************************************************************
  *Function name
  *    ltt_event_cpu_i: get the cpu id where the event happens
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.027859 seconds and 4 git commands to generate.