time _now_ works. Breaks compatibility work old traces, which were broken anyway...
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 16 Aug 2004 22:15:28 +0000 (22:15 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 16 Aug 2004 22:15:28 +0000 (22:15 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@796 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/ltt/convert/convert.c
ltt/branches/poly/ltt/tracefile.c

index efacdcb630690bcc464689a7d3d82a9f2e4d5957..2fb4d66f1724598dc56c5d0d273ea015633e946a 100644 (file)
@@ -136,7 +136,7 @@ int main(int argc, char ** argv){
   buffer_start start, start_proc, start_intr;
   buffer_start end, end_proc, end_intr;
   heartbeat beat;
-  int beat_count = 0;
+  uint64_t beat_count;
   uint32_t size_lost;
   int reserve_size = sizeof(buffer_start) + sizeof(uint16_t) + 2*sizeof(uint32_t);//lost_size and buffer_end event
   int nb_para;
@@ -320,7 +320,6 @@ int main(int argc, char ** argv){
     
     for(i=0;i<block_number;i++){
       int event_count = 0;
-      beat_count = 0;
 
       memset((void*)buf_out, 0, block_size);
       write_pos = buf_out;
@@ -347,8 +346,10 @@ int main(int argc, char ** argv){
       startId = newId;
       startTimeDelta = time_delta;
       start.seconds = tBufStart->Time.tv_sec;
-      start.nanoseconds = tBufStart->Time.tv_usec;
+      /* usec -> nsec (Mathieu) */
+      start.nanoseconds = tBufStart->Time.tv_usec * 1000;
       start.cycle_count = tBufStart->TSC;
+      beat_count = start.cycle_count;
       start.block_id = tBufStart->ID;
       end.block_id = start.block_id;
       
@@ -362,7 +363,8 @@ int main(int argc, char ** argv){
        tBufEnd = (trace_buffer_end*)(end_pos+sizeof(uint8_t)+sizeof(uint32_t));
       }
       end.seconds = tBufEnd->Time.tv_sec;
-      end.nanoseconds = tBufEnd->Time.tv_usec;
+      /* usec -> nsec (Mathieu) */
+      end.nanoseconds = tBufEnd->Time.tv_usec * 1000;
       end.cycle_count = tBufEnd->TSC;
     
       //skip buffer start and trace start events
@@ -449,8 +451,10 @@ int main(int argc, char ** argv){
        write_to_buffer(write_pos,(void*)&time_delta, sizeof(uint32_t));     
        
        if(evId == TRACE_BUFFER_END){
+#if 0 //(Mathieu : already set correctly to tBufEnd.TSC)
     end.cycle_count = start.cycle_count 
                          + beat_count * OVERFLOW_FIGURE;
+#endif //)
          int size = block_size + ((void*)buf_out - write_pos)+ sizeof(uint16_t) + sizeof(uint32_t);
          write_to_buffer(write_pos,(void*)&end,sizeof(buffer_start));   
          write_pos = buf_out + block_size - sizeof(uint32_t);
@@ -557,11 +561,18 @@ int main(int argc, char ** argv){
            event_size = sizeof(trace_network);
            break;
          case TRACE_HEARTBEAT:
-           beat_count++;
+      /* Fix (Mathieu) */
+      if(timeDelta < (0xFFFFFFFF&beat_count)) {
+        /* Overflow */
+        beat_count += 0x100000000ULL - (uint64_t)(0xFFFFFFFF&beat_count)
+                                     + (uint64_t)timeDelta;
+      } else {
+        /* No overflow */
+        beat_count += timeDelta - (0xFFFFFFFF&beat_count);
+      }
            beat.seconds = 0;
            beat.nanoseconds = 0;
-           beat.cycle_count = (uint64_t)start.cycle_count 
-                         + (uint64_t)beat_count * OVERFLOW_FIGURE;
+           beat.cycle_count = beat_count;
            event_size = 0;
            
            write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t));
index 48621ddc9c99dfa63bce3f13a054608247a73837..67c0efe4174a29b875cdf7d1661cc33941ac4e9c 100644 (file)
@@ -1389,6 +1389,7 @@ int readBlock(LttTracefile * tf, int whichBlock)
 
   tf->a_block_start->time = getEventTime(tf);
 
+
   {
     guint64 lEventNSec;
     LttTime lTimeOffset;
@@ -1657,6 +1658,12 @@ static inline LttTime getEventTime(LttTracefile * tf)
     lEventNSec = ((double)
                  (tf->a_block_end->cycle_count - tf->a_block_start->cycle_count)
                            * tf->nsec_per_cycle);
+    g_printf("CYCLES COUNTED : %llu",
+        (gint64)((double)cycle_count * tf->nsec_per_cycle)
+                                +tf->overflow_nsec 
+                                +tf->a_block_start->cycle_count);
+
+    
   }
   /* heartbeat cycle counter is only numheartbeat<<32, not meaningful
    */
This page took 0.025603 seconds and 4 git commands to generate.