From dd691a2ef3d6fdcba001206bf686a4cdce26b545 Mon Sep 17 00:00:00 2001 From: yangxx Date: Thu, 11 Dec 2003 15:45:59 +0000 Subject: [PATCH] bug fixed: getEventTime() git-svn-id: http://ltt.polymtl.ca/svn@343 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/ltt/event.c | 19 +++++++++++++++++-- ltt/branches/poly/ltt/ltt-private.h | 2 ++ ltt/branches/poly/ltt/tracefile.c | 20 +++++++++----------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/ltt/branches/poly/ltt/event.c b/ltt/branches/poly/ltt/event.c index 8a3174cf..f762dbdd 100644 --- a/ltt/branches/poly/ltt/event.c +++ b/ltt/branches/poly/ltt/event.c @@ -252,8 +252,23 @@ void ltt_event_position_set(LttEventPosition *ep, ****************************************************************************/ unsigned ltt_event_cpu_id(LttEvent *e) -{ - return (unsigned)atoi(e->tracefile->name); +{ + char * c1, * c2, * c3; + c1 = strrchr(e->tracefile->name,'\\'); + c2 = strrchr(e->tracefile->name,'/'); + if(c1 == NULL && c2 == NULL){ + return (unsigned)atoi(e->tracefile->name); + }else if(c1 == NULL){ + c2++; + return (unsigned)atoi(c2); + }else if(c2 == NULL){ + c1++; + return (unsigned)atoi(c1); + }else{ + c3 = (c1 > c2) ? c1 : c2; + c3++; + return (unsigned)atoi(c3); + } } /***************************************************************************** diff --git a/ltt/branches/poly/ltt/ltt-private.h b/ltt/branches/poly/ltt/ltt-private.h index ea4dff8c..aeda9e4f 100644 --- a/ltt/branches/poly/ltt/ltt-private.h +++ b/ltt/branches/poly/ltt/ltt-private.h @@ -140,6 +140,8 @@ struct _LttTracefile{ LttTime prev_block_end_time; //the end time of previous block LttTime prev_event_time; //the time of the previous event LttEvent an_event; + LttCycleCount pre_cycle_count; //previous cycle count of the event + int count; //the number of overflow of cycle count }; struct _LttTrace{ diff --git a/ltt/branches/poly/ltt/tracefile.c b/ltt/branches/poly/ltt/tracefile.c index 97ac57cc..82ccda5b 100644 --- a/ltt/branches/poly/ltt/tracefile.c +++ b/ltt/branches/poly/ltt/tracefile.c @@ -1145,18 +1145,16 @@ LttTime getEventTime(LttTracefile * tf) LttTime lTimeOffset; // Time offset in struct LttTime guint16 evId; gint64 nanoSec, tmpCycleCount = (((guint64)1)<<32); - static LttCycleCount preCycleCount = 0; - static int count = 0; evId = *(guint16 *)tf->cur_event_pos; if(evId == TRACE_BLOCK_START){ - count = 0; - preCycleCount = 0; + 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(evId == TRACE_BLOCK_END){ - count = 0; - preCycleCount = 0; + tf->count = 0; + tf->pre_cycle_count = 0; tf->cur_cycle_count = tf->a_block_end->cycle_count; return tf->a_block_end->time; } @@ -1164,12 +1162,12 @@ LttTime getEventTime(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); - if(cycle_count < preCycleCount)count++; - preCycleCount = cycle_count; - cycle_count += tmpCycleCount * count; + if(cycle_count < tf->pre_cycle_count)tf->count++; + tf->pre_cycle_count = cycle_count; + cycle_count += tmpCycleCount * tf->count; - if(tf->cur_heart_beat_number > count) - cycle_count += tmpCycleCount * (tf->cur_heart_beat_number - count); + if(tf->cur_heart_beat_number > tf->count) + cycle_count += tmpCycleCount * (tf->cur_heart_beat_number - tf->count); tf->cur_cycle_count = cycle_count; -- 2.34.1