X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Ftracefile.c;h=556fe492529e53011e45cb775f842359b2bc2386;hb=ac84977454f760c5273dd1ea902bb73d8c671a37;hp=5c30d9a18fa1e5df08c59034585ad6dcc573fe75;hpb=a1062ddd65b968c3ba077bc68b88887888b5057a;p=lttv.git diff --git a/ltt/branches/poly/ltt/tracefile.c b/ltt/branches/poly/ltt/tracefile.c index 5c30d9a1..556fe492 100644 --- a/ltt/branches/poly/ltt/tracefile.c +++ b/ltt/branches/poly/ltt/tracefile.c @@ -1238,17 +1238,24 @@ gboolean ltt_tracefile_pre_read_cycles(LttTracefile *tf) // Calculate total time in cycles from start of buffer for this event cycle_count = (LttCycleCount)*(guint32 *)(tf->cur_event_pos + EVENT_ID_SIZE); //g_debug("event cycle count %llu", cycle_count); - gint64 delta_count = (gint64)(cycle_count - tf->pre_cycle_count); - LttCycleCount res_delta_count; + // + //gint64 delta_count = (gint64)(cycle_count - tf->pre_cycle_count); + //LttCycleCount res_delta_count; + gboolean comp_count = cycle_count < tf->pre_cycle_count; tf->pre_cycle_count = cycle_count; + if(unlikely(comp_count)) { + /* Wrapped */ + tf->count++; //increment wrap count + } + //if(unlikely(cycle_count < tf->pre_cycle_count)) tf->count++; - if(unlikely(delta_count < 0)) { + //if(unlikely(delta_count < 0)) { // tf->count++; //increment wrap count // keep in mind that delta_count is negative here. - res_delta_count = delta_count + 0x100000000ULL ; - } else - res_delta_count = (LttCycleCount)delta_count; + // res_delta_count = delta_count + 0x100000000ULL ; + //} else + // res_delta_count = (LttCycleCount)delta_count; //cycle_count += (LttCycleCount)tf->count << 32; @@ -1256,7 +1263,8 @@ gboolean ltt_tracefile_pre_read_cycles(LttTracefile *tf) // if(tf->cur_heart_beat_number > tf->count) // cycle_count += (tf->cur_heart_beat_number - tf->count) << 32; - tf->cur_cycle_count = tf->cur_cycle_count + res_delta_count; + //tf->cur_cycle_count = tf->cur_cycle_count + res_delta_count; + tf->cur_cycle_count = cycle_count | ((LttCycleCount)tf->count << 32); g_debug("cur cycle count %llu", tf->cur_cycle_count); @@ -1298,6 +1306,9 @@ int readBlock(LttTracefile * tf, int whichBlock) off_t nbBytes; guint32 lostSize; + /* same block already opened requested */ + if((guint)whichBlock == tf->which_block) return 0; + if(likely(whichBlock - tf->which_block == 1 && tf->which_block != 0)){ tf->prev_block_end_time = tf->a_block_end->time; tf->prev_event_time = tf->a_block_end->time; @@ -1328,9 +1339,14 @@ int readBlock(LttTracefile * tf, int whichBlock) /* read the whole block to precalculate total of cycles in it */ tf->count = 0; tf->pre_cycle_count = 0; - tf->cur_cycle_count = tf->a_block_start->cycle_count; + tf->cur_cycle_count = 0; + g_debug("precalculating cycles begin for block %i", whichBlock); while(likely(ltt_tracefile_pre_read_cycles(tf))); + g_debug("precalculating cycles end for block %i", whichBlock); + tf->count = 0; + tf->pre_cycle_count = 0; + tf->cur_cycle_count = 0; /* put back pointer at the beginning */ tf->which_event = 1; tf->cur_event_pos = tf->buffer;//the beginning of the block, block start ev @@ -1468,18 +1484,56 @@ static inline LttTime getEventTime(LttTracefile * tf) guint16 evId; evId = *(guint16 *)tf->cur_event_pos; - if(unlikely(evId == TRACE_BLOCK_START)){ - tf->count = 0; - tf->pre_cycle_count = 0; - tf->cur_cycle_count = tf->a_block_start->cycle_count; - return tf->a_block_start->time; - }else if(unlikely(evId == TRACE_BLOCK_END)){ - tf->count = 0; - tf->pre_cycle_count = 0; - tf->cur_cycle_count = tf->a_block_end->cycle_count; - return tf->a_block_end->time; + //if(unlikely(evId == TRACE_BLOCK_START)){ + // tf->count = 0; + // tf->pre_cycle_count = 0; + // tf->cur_cycle_count = tf->a_block_start->cycle_count; + // return tf->a_block_start->time; + //}//else if(unlikely(evId == TRACE_BLOCK_END)){ + //tf->count = 0; + //tf->pre_cycle_count = 0; + //tf->cur_cycle_count = tf->a_block_end->cycle_count; + //return tf->a_block_end->time; + //} + + // Calculate total time in cycles from start of buffer for this event + cycle_count = (LttCycleCount)*(guint32 *)(tf->cur_event_pos + EVENT_ID_SIZE); + //g_debug("event cycle count %llu", cycle_count); + // + //gint64 delta_count = (gint64)(cycle_count - tf->pre_cycle_count); + //LttCycleCount res_delta_count; + gboolean comp_count = cycle_count < tf->pre_cycle_count; + tf->pre_cycle_count = cycle_count; + + if(unlikely(comp_count)) { + /* Wrapped */ + tf->count++; //increment wrap count } + //if(unlikely(cycle_count < tf->pre_cycle_count)) tf->count++; + //if(unlikely(delta_count < 0)) { + // tf->count++; //increment wrap count + // keep in mind that delta_count is negative here. + // res_delta_count = delta_count + 0x100000000ULL ; + //} else + // res_delta_count = (LttCycleCount)delta_count; + + //cycle_count += (LttCycleCount)tf->count << 32; + + //FIXME (MD) + // if(tf->cur_heart_beat_number > tf->count) + // cycle_count += (tf->cur_heart_beat_number - tf->count) << 32; + + //tf->cur_cycle_count = tf->cur_cycle_count + res_delta_count; + tf->cur_cycle_count = cycle_count | ((LttCycleCount)tf->count << 32); + g_debug("cur cycle count %llu", tf->cur_cycle_count); + + + lEventTotalCycle = tf->cur_cycle_count; + + + +#if 0 // Calculate total time in cycles from start of buffer for this event cycle_count = (LttCycleCount)*(guint32 *)(tf->cur_event_pos + EVENT_ID_SIZE); @@ -1495,7 +1549,7 @@ static inline LttTime getEventTime(LttTracefile * tf) lEventTotalCycle = cycle_count; lEventTotalCycle -= tf->a_block_start->cycle_count; - +#endif //0 // Convert it to nsecs lEventNSec = (double)lEventTotalCycle * (double)tf->nsec_per_cycle; //lEventNSec = (tf->cycles_per_nsec_reciprocal * lEventTotalCycle) >> 16;