Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new tracing options to reduce the size of the traces
[simgrid.git] / src / instr / instr_paje_trace.c
index 7b5568d..e3d78b2 100644 (file)
@@ -5,6 +5,7 @@
   * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "instr/instr_private.h"
+#include "xbt/virtu.h" /* sg_cmdline */
 
 #ifdef HAVE_TRACING
 
@@ -178,6 +179,13 @@ void TRACE_paje_start(void)
 
   /* output generator version */
   fprintf (tracing_file, "#This file was generated using SimGrid-%d.%d.%d\n", SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR, SIMGRID_VERSION_PATCH);
+  fprintf (tracing_file, "#[");
+  unsigned int cpt;
+  char *str;
+  xbt_dynar_foreach (xbt_cmdline, cpt, str){
+    fprintf(tracing_file, "%s ",str);
+  }
+  fprintf (tracing_file, "]\n");
 
   /* output one line comment */
   dump_comment (TRACE_get_comment());
@@ -216,15 +224,16 @@ void TRACE_paje_dump_buffer (int force)
     buffer = xbt_dynar_new (sizeof(paje_event_t), NULL);
   }else{
     paje_event_t event;
-    while (!xbt_dynar_is_empty(buffer)){
-      double head_timestamp = (*(paje_event_t*)xbt_dynar_get_ptr(buffer, 0))->timestamp;
+    unsigned int cursor;
+    xbt_dynar_foreach(buffer, cursor, event) {
+      double head_timestamp = event->timestamp;
       if (head_timestamp > TRACE_last_timestamp_to_dump){
         break;
       }
-      xbt_dynar_remove_at (buffer, 0, &event);
       event->print (event);
       event->free (event);
     }
+    xbt_dynar_remove_n_at(buffer, cursor, 0);
   }
   XBT_DEBUG("%s: ends", __FUNCTION__);
 }