bug fixed: getEventTime()
authoryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 11 Dec 2003 15:45:59 +0000 (15:45 +0000)
committeryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 11 Dec 2003 15:45:59 +0000 (15:45 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@343 04897980-b3bd-0310-b5e0-8ef037075253

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

index 8a3174cff8a8e124322dd5ed75b2fa217f10c72f..f762dbddf5d174e306175115682f4d94a8776444 100644 (file)
@@ -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);        
+  }
 }
 
 /*****************************************************************************
index ea4dff8c91583a751343fac77249b20a6455813e..aeda9e4fae93e7a439595a261ea6f706d266bd6a 100644 (file)
@@ -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{
index 97ac57cc35f260c6c27af23e15d217f56725524e..82ccda5bf68d2336c8138916bbe9bced855b2172 100644 (file)
@@ -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;
 
This page took 0.026515 seconds and 4 git commands to generate.