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);
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
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
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
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 */
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
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
}
}
+/*****************************************************************************
+ * 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