From: yangxx Date: Mon, 15 Sep 2003 19:33:43 +0000 (+0000) Subject: new LttEventPosition structure for backword seeking X-Git-Tag: v0.12.20~3252 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=80da81adfa88158bd3d4c26f89f96f8b58c77b4f;p=lttv.git new LttEventPosition structure for backword seeking git-svn-id: http://ltt.polymtl.ca/svn@237 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/include/ltt/event.h b/ltt/branches/poly/include/ltt/event.h index 96c71ce7..35e78778 100644 --- a/ltt/branches/poly/include/ltt/event.h +++ b/ltt/branches/poly/include/ltt/event.h @@ -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); diff --git a/ltt/branches/poly/include/ltt/ltt-private.h b/ltt/branches/poly/include/ltt/ltt-private.h index 94bc1ebd..30400f55 100644 --- a/ltt/branches/poly/include/ltt/ltt-private.h +++ b/ltt/branches/poly/include/ltt/ltt-private.h @@ -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 diff --git a/ltt/branches/poly/include/ltt/ltt.h b/ltt/branches/poly/include/ltt/ltt.h index 1da397f3..296c8221 100644 --- a/ltt/branches/poly/include/ltt/ltt.h +++ b/ltt/branches/poly/include/ltt/ltt.h @@ -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 diff --git a/ltt/branches/poly/include/ltt/trace.h b/ltt/branches/poly/include/ltt/trace.h index e96e73e4..ac3335a1 100644 --- a/ltt/branches/poly/include/ltt/trace.h +++ b/ltt/branches/poly/include/ltt/trace.h @@ -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 */ diff --git a/ltt/branches/poly/ltt/event.c b/ltt/branches/poly/ltt/event.c index ad7e6c33..7ef67377 100644 --- a/ltt/branches/poly/ltt/event.c +++ b/ltt/branches/poly/ltt/event.c @@ -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 diff --git a/ltt/branches/poly/ltt/tracefile.c b/ltt/branches/poly/ltt/tracefile.c index 05978a48..d7812587 100644 --- a/ltt/branches/poly/ltt/tracefile.c +++ b/ltt/branches/poly/ltt/tracefile.c @@ -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