new function to get the time span of a trace
authoryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 15 Sep 2003 20:37:11 +0000 (20:37 +0000)
committeryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 15 Sep 2003 20:37:11 +0000 (20:37 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@238 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/include/ltt/trace.h
ltt/branches/poly/ltt/tracefile.c

index ac3335a1927108c21ecf195dd12ea42e5d86bf8b..18ef016c5ef9fac30d8f4e34c3c1a3b2456e1948 100644 (file)
@@ -94,6 +94,11 @@ LttTracefile *ltt_trace_control_tracefile_get(LttTrace *t, unsigned i);
 LttTracefile *ltt_trace_per_cpu_tracefile_get(LttTrace *t, unsigned i);
 
 
+/* Get the start time and end time of the trace */
+
+void ltt_trace_time_span_get(LttTrace *t, LttTime *start, LttTime *end);
+
+
 /* Get the name of a tracefile */
 
 char *ltt_tracefile_name(LttTracefile *tf);
index d78125873222f972399eb6efafa385265da726be..43334ed366d727fcb1527ed7ef7b411ed178004e 100644 (file)
@@ -661,6 +661,52 @@ LttTracefile *ltt_trace_per_cpu_tracefile_get(LttTrace *t, unsigned i)
   return (LttTracefile*)g_ptr_array_index(t->per_cpu_tracefiles, i);
 }
 
+/*****************************************************************************
+ * Get the start time and end time of the trace 
+ ****************************************************************************/
+
+void ltt_trace_time_span_get(LttTrace *t, LttTime *start, LttTime *end)
+{
+  LttTime startSmall, startTmp, endBig, endTmp;
+  int i, j=0;
+  LttTracefile * tf;
+
+  for(i=0;i<t->control_tracefile_number;i++){
+    tf = g_ptr_array_index(t->control_tracefiles, i);
+    readBlock(tf,1);
+    startTmp = tf->a_block_start->time;    
+    readBlock(tf,tf->block_number);
+    endTmp = tf->a_block_end->time;
+    if(i==0){
+      startSmall = startTmp;
+      endBig     = endTmp;
+      j = 1;
+      continue;
+    }
+    if(timecmp(&startSmall,&startTmp) > 0) startSmall = startTmp;
+    if(timecmp(&endBig,&endTmp) < 0) endBig = endTmp;
+  }
+
+  for(i=0;i<t->per_cpu_tracefile_number;i++){
+    tf = g_ptr_array_index(t->per_cpu_tracefiles, i);
+    readBlock(tf,1);
+    startTmp = tf->a_block_start->time;    
+    readBlock(tf,tf->block_number);
+    endTmp = tf->a_block_end->time;
+    if(j == 0 && i==0){
+      startSmall = startTmp;
+      endBig     = endTmp;
+      continue;
+    }
+    if(timecmp(&startSmall,&startTmp) > 0) startSmall = startTmp;
+    if(timecmp(&endBig,&endTmp) < 0) endBig = endTmp;
+  }
+
+  *start = startSmall;
+  *end = endBig;
+}
+
+
 /*****************************************************************************
  *Get the name of a tracefile
  ****************************************************************************/
@@ -793,7 +839,6 @@ LttEvent *ltt_tracefile_read(LttTracefile *t)
 
   if(t->cur_event_pos == t->buffer + t->block_size){
     if(t->which_block == t->block_number){
-      g_free(lttEvent);
       return NULL;
     }
     err = readBlock(t, t->which_block + 1);
This page took 0.025233 seconds and 4 git commands to generate.