add trace verification at opening
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 23 Aug 2005 15:18:45 +0000 (15:18 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 23 Aug 2005 15:18:45 +0000 (15:18 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1059 04897980-b3bd-0310-b5e0-8ef037075253

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

index 4040433df432cae199464a2f467b1da30c0dfb15..929e54aeb898a32c62a352d2fb8e08971cf74485 100644 (file)
@@ -345,7 +345,8 @@ struct _LttTrace{
   GArray *facilities_by_num;            /* fac_id as index in array */
   GData *facilities_by_name;            /* fac name (GQuark) as index */
                                         /* Points to array of fac_id of all the
-                                         * facilities that has this name. */
+                                        * facilities that has this name. */
+  guint     num_cpu;
 
   guint32   arch_type;
   guint32   arch_variant;
index 7736d8f30ad49831da2c150ca3b30dd43c6e86a9..509a3886027e7a3dca5cd5460f7c9a782d3947d6 100644 (file)
@@ -47,6 +47,7 @@ GQuark ltt_trace_name(const LttTrace *t);
 
 void ltt_trace_close(LttTrace *t); 
 
+guint ltt_trace_get_num_cpu(LttTrace *t);
 
 LttSystemDescription *ltt_trace_system_description(LttTrace *t);
 
index fc1f4583d009a732982d96d94a8cd57bb418eb6d..6fe13f1dbd13ee9311885c49037de55db9c57612 100644 (file)
@@ -185,6 +185,11 @@ LttFacility *ltt_trace_get_facility_by_num(LttTrace *t,
 
 }
 
+guint ltt_trace_get_num_cpu(LttTrace *t)
+{
+  return t->num_cpu;
+}
+
 
 /*****************************************************************************
  *Function name
@@ -966,8 +971,14 @@ LttTrace *ltt_trace_open(const gchar *pathname)
   LttTrace  * t;
   LttTracefile *tf;
   GArray *group;
-  int i;
+  int i, ret;
   struct ltt_block_start_header *header;
+       DIR *dir;
+       struct dirent *entry;
+  guint control_found = 0;
+  guint eventdefs_found = 0;
+       struct stat stat_buf;
+  gchar path[PATH_MAX];
   
   t = g_new(LttTrace, 1);
   if(!t) goto alloc_error;
@@ -975,11 +986,40 @@ LttTrace *ltt_trace_open(const gchar *pathname)
   get_absolute_pathname(pathname, abs_path);
   t->pathname = g_quark_from_string(abs_path);
 
-  /* Open all the tracefiles */
   g_datalist_init(&t->tracefiles);
+
+  /* Test to see if it looks like a trace */
+       dir = opendir(abs_path);
+       if(dir == NULL) {
+               perror(abs_path);
+               goto open_error;
+       }
+       while((entry = readdir(dir)) != NULL) {
+    strcpy(path, abs_path);
+    strcat(path, "/");
+    strcat(path, entry->d_name);
+               ret = stat(path, &stat_buf);
+               if(ret == -1) {
+                       perror(path);
+                       continue;
+               }
+               if(S_ISDIR(stat_buf.st_mode)) {
+      if(strcmp(entry->d_name, "control") == 0) {
+        control_found = 1;
+      }
+      if(strcmp(entry->d_name, "eventdefs") == 0) {
+        eventdefs_found = 1;
+      }
+    }
+  }
+  closedir(dir);
+  
+  if(!control_found || !eventdefs_found) goto find_error;
+  
+  /* Open all the tracefiles */
   if(open_tracefiles(t, abs_path, "")) {
     g_warning("Error opening tracefile %s", abs_path);
-    goto open_error;
+    goto find_error;
   }
   
   /* Prepare the facilities containers : array and mapping */
@@ -1012,7 +1052,8 @@ LttTrace *ltt_trace_open(const gchar *pathname)
   t->has_heartbeat = header->trace.has_heartbeat;
   t->has_alignment = header->trace.has_alignment;
   t->has_tsc = header->trace.has_tsc;
-  
+
+  t->num_cpu = group->len;
   
   for(i=0; i<group->len; i++) {
     tf = &g_array_index (group, LttTracefile, i);
@@ -1026,8 +1067,9 @@ LttTrace *ltt_trace_open(const gchar *pathname)
 facilities_error:
   g_datalist_clear(&t->facilities_by_name);
   g_array_free(t->facilities_by_num, TRUE);
-open_error:
+find_error:
   g_datalist_clear(&t->tracefiles);
+open_error:
   g_free(t);
 alloc_error:
   return NULL;
This page took 0.028518 seconds and 4 git commands to generate.