]> AND Public Git Repository - simgrid.git/blobdiff - src/instr/instr_paje.c
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] let paje output its own header
[simgrid.git] / src / instr / instr_paje.c
index d617480ada48d0280c276297520b808d18906bf7..161436d34730b6f6e38c2fc8248c671b58f8360f 100644 (file)
@@ -9,7 +9,6 @@
 #ifdef HAVE_TRACING
 
 static FILE *tracing_file = NULL;
-int tracing_active = 0;
 
 static int pajeDefineContainerTypeId = 0;
 static int pajeDefineStateTypeId = 1;
@@ -42,23 +41,26 @@ static int pajeNewEventId = 27;
 
 #define TRACE_LINE_SIZE 1000
 
-void TRACE_paje_start(FILE * file)
+void TRACE_paje_start(void)
 {
-  tracing_file = file;
-  tracing_active = 1;
+  char *filename = TRACE_get_filename();
+  tracing_file = fopen(filename, "w");
+  if (!tracing_file) {
+    THROW1(tracing_error, TRACE_ERROR_FILE_OPEN,
+           "Tracefile %s could not be opened for writing.", filename);
+  }
+
+  /* output header */
+  TRACE_paje_create_header();
 }
 
-FILE *TRACE_paje_end(void)
+void TRACE_paje_end(void)
 {
-  tracing_active = 0;
-  return tracing_file;
+  fclose(tracing_file);
 }
 
-
 void TRACE_paje_create_header(void)
 {
-  if (!tracing_active)
-    return;
   fprintf(tracing_file, "\
 %%EventDef PajeDefineContainerType %d \n\
 %%       Alias string \n\
@@ -361,4 +363,4 @@ void pajeNewEvent(double time, const char *entityType,
           entityType, container, value);
 }
 
-#endif
+#endif /* HAVE_TRACING */