git-svn-id: http://ltt.polymtl.ca/svn@131 04897980-b3bd-0310-b5e0-8ef037075253
[lttv.git] / ltt / branches / poly / ltt / tracefile.c
index ea07019b74aff0891a29823857864f2d71739234..f3ee2e20b8252c42cde495b4ae29250871ff5f6e 100644 (file)
@@ -130,6 +130,7 @@ void ltt_tracefile_open_cpu(LttTrace *t, char * tracefile_name)
 {
   LttTracefile * tf;
   tf = ltt_tracefile_open(t,tracefile_name);
+  if(!tf) return;
   t->per_cpu_tracefile_number++;
   g_ptr_array_add(t->per_cpu_tracefiles, tf);
 }
@@ -150,7 +151,7 @@ void ltt_tracefile_open_control(LttTrace *t, char * control_name)
   g_ptr_array_add(t->control_tracefiles,tf);
 
   //parse facilities tracefile to get base_id
-  if(strcmp(control_name,"facilities") ==0){
+  if(strcmp(&control_name[strlen(control_name)-10],"facilities") ==0){
     while(1){
       ev = ltt_tracefile_read(tf);
       if(!ev)return; // end of file
@@ -477,15 +478,15 @@ LttTrace *ltt_trace_open(char *pathname)
   strcat(tmp,"system.xml");
   getSystemInfo(sys_description, tmp);
 
+  //get facilities info
+  getFacilityInfo(t,eventdefs);
+  
   //get control tracefile info
   getControlFileInfo(t,control);
 
   //get cpu tracefile info
   getCpuFileInfo(t,cpu);
 
-  //get facilities info
-  getFacilityInfo(t,eventdefs);
-  
   return t;
 }
 
@@ -790,7 +791,8 @@ LttEvent *ltt_tracefile_read(LttTracefile *t)
 
   //update the fields of the current event and go to the next event
   err = skipEvent(t);
-  if(err == ENOENT) return NULL;
+  if(err == ENOMEM) return NULL;
+  if(err == ENOENT) return lttEvent;
   if(err == ERANGE) g_error("event id is out of range\n");
   if(err)g_error("Can not read tracefile\n");
 
@@ -904,7 +906,8 @@ void updateTracefile(LttTracefile * tf)
  *    0               : success
  *    EINVAL          : lseek fail
  *    EIO             : can not read from the file
- *    ENOENT          : end of file
+ *    ENOMEM          : end of file
+ *    ENOENT          : last event
  *    ERANGE          : event id is out of range
  ****************************************************************************/
 
@@ -914,6 +917,14 @@ int skipEvent(LttTracefile * t)
   void * evData;
   LttEventType * evT;
   LttField * rootFld;
+  static int evCount = 0;
+
+  if(evCount){
+    if(t->which_block == t->block_number && 
+       evCount == t->which_event){
+      return ENOMEM;
+    }else evCount = 0;
+  }
 
   evId   = (int)(*(uint16_t *)(t->cur_event_pos));
   evData = t->cur_event_pos + EVENT_HEADER_SIZE;
@@ -946,7 +957,11 @@ int skipEvent(LttTracefile * t)
   
   //the next event is in the next block
   if(evId == TRACE_BLOCK_END){
-    if(t->which_block == t->block_number) return ENOENT;
+    if(t->which_block == t->block_number){
+      t->which_event++;
+      evCount = t->which_event;
+      return ENOENT;
+    }
     err = readBlock(t, t->which_block + 1);
     if(err) return err;
   }else{
This page took 0.024341 seconds and 4 git commands to generate.