state hooks bug fixed
[lttv.git] / ltt / branches / poly / lttv / lttv / batchtest.c
index 101cef506e0cc51002bb5d976c86e7d3c8f67176..bacca9ba31a804146a5f4e407b4f1091c556782c 100644 (file)
@@ -99,8 +99,11 @@ static void lttv_trace_option(void __UNUSED__ *hook_data)
   LttTrace *trace;
 
   trace = ltt_trace_open(a_trace);
-  if(trace == NULL) g_critical("cannot open trace %s", a_trace);
-  lttv_traceset_add(traceset, lttv_trace_new(trace));
+  if(trace == NULL) {
+    g_critical("cannot open trace %s", a_trace);
+  } else {
+    lttv_traceset_add(traceset, lttv_trace_new(trace));
+  }
 }
 
 static double get_time() 
@@ -248,18 +251,28 @@ gboolean save_state_event(void *hook_data, void *call_data)
 }
 
 
+static void sanitize_name(gchar *name)
+{
+  while(*name != '\0') {
+    if(*name == '/') *name = '_';
+    name++;
+  }
+  
+}
+
 
-static void compute_tracefile(LttTracefile *tracefile)
+static void compute_tracefile(LttTracefile *tracefile, void *hook_data)
 {
   GString *filename;
-  guint i, j, nb_equal, nb_block, offset;
+  guint nb_equal, nb_block, offset;
   guint64 tsc;
   FILE *fp;
   LttTime time, previous_time;
-  LttEvent *event = ltt_event_new();
+  LttEvent *event = ltt_tracefile_get_event(tracefile);
   LttFacility *facility;
   LttEventType *event_type;
   int err;
+  gchar mod_name[PATH_MAX];
 
   /* start_count is always initialized in this function _if_ there is always
    * a block_start before a block_end.
@@ -268,7 +281,13 @@ static void compute_tracefile(LttTracefile *tracefile)
 
 
   filename = g_string_new("");
-  g_string_printf(filename, "%s.%u.%u.trace", a_dump_tracefiles, i, j);
+  strcpy(mod_name, g_quark_to_string(ltt_tracefile_name(tracefile)));
+  
+  sanitize_name(mod_name);
+  
+  g_warning("test %s test", g_quark_to_string(ltt_tracefile_name(tracefile)));
+  g_string_printf(filename, "%s.%s.%u.trace", a_dump_tracefiles,
+      mod_name, ltt_tracefile_num(tracefile));
   fp = fopen(filename->str, "w");
   if(fp == NULL) g_error("Cannot open %s", filename->str);
   g_string_free(filename, TRUE);
@@ -285,15 +304,23 @@ static void compute_tracefile(LttTracefile *tracefile)
     time = ltt_event_time(event);
     ltt_event_position(event, a_event_position);
     ltt_event_position_get(a_event_position, &tf_pos, &nb_block, &offset, &tsc);
-    fprintf(fp,"%s.%s: %llu %lu.%09lu position %u/%u\n", 
-        ltt_facility_name(facility), ltt_eventtype_name(event_type), 
+    //fprintf(fp,"%s.%s: %llu %lu.%09lu position %u/%u\n", 
+    fprintf(fp, "%s.%s: %llu %lu.%09lu position %u/%u, tracefile %s\n", 
+        g_quark_to_string(ltt_facility_name(facility)),
+        g_quark_to_string(ltt_eventtype_name(event_type)),
         tsc, (unsigned long)time.tv_sec, 
         (unsigned long)time.tv_nsec, 
-        nb_block, offset);
+        nb_block, offset,
+        g_quark_to_string(ltt_tracefile_name(tracefile)));
 
     if(ltt_time_compare(time, previous_time) < 0) {
-      g_warning("Time decreasing trace %d tracefile %d position %u/%u",
-    i, j, nb_block, offset);
+      g_warning("Time decreasing trace %s tracefile %s cpu %u position %u/%u",
+    g_quark_to_string(ltt_trace_name(ltt_tracefile_get_trace(tracefile))),
+    g_quark_to_string(ltt_tracefile_name(tracefile)), 
+    ltt_tracefile_num(tracefile), nb_block, offset);
+      g_warning("last time %lu.%lu vs current %lu.%lu",
+    previous_time.tv_sec, previous_time.tv_nsec,
+    time.tv_sec, time.tv_nsec);
     }
 
 #if 0 //FIXME
@@ -331,7 +358,6 @@ static void compute_tracefile(LttTracefile *tracefile)
 
 close:
   fclose(fp);
-  ltt_event_destroy(event);
 }
 
 static gboolean process_traceset(void __UNUSED__ *hook_data, 
@@ -368,6 +394,11 @@ static gboolean process_traceset(void __UNUSED__ *hook_data,
 
   GData **tracefiles_groups;
 
+  struct compute_tracefile_group_args args;
+
+  args.func = compute_tracefile;
+  args.func_args = NULL;
+  
   if(a_dump_tracefiles != NULL) {
     for(i = 0 ; i < lttv_traceset_number(traceset) ; i++) {
       trace = lttv_trace(lttv_traceset_get(traceset, i));
@@ -375,7 +406,7 @@ static gboolean process_traceset(void __UNUSED__ *hook_data,
 
       g_datalist_foreach(tracefiles_groups, 
                             (GDataForeachFunc)compute_tracefile_group,
-                            compute_tracefile);
+                            &args);
       
     }
   }
@@ -395,7 +426,7 @@ static gboolean process_traceset(void __UNUSED__ *hook_data,
     lttv_hooks_add(event_hook, count_event, &count, LTTV_PRIO_DEFAULT);
     t = run_one_test(ts, ltt_time_zero, max_time);
     lttv_hooks_remove_data(event_hook, count_event, &count);
-    g_warning(
+    g_message(
         "Processing trace while counting events (%u events in %g seconds)",
        count, t);
   }
@@ -406,7 +437,7 @@ static gboolean process_traceset(void __UNUSED__ *hook_data,
     lttv_state_add_event_hooks(ts);
     t = run_one_test(ts, ltt_time_zero, max_time);
     lttv_state_remove_event_hooks(ts);
-    g_warning("Processing trace while updating state (%g seconds)", t);
+    g_message("Processing trace while updating state (%g seconds)", t);
   }
 
   /* Run through all events computing the state and writing it out 
@@ -446,7 +477,7 @@ static gboolean process_traceset(void __UNUSED__ *hook_data,
     lttv_stats_add_event_hooks(tscs);
     t = run_one_test(ts, ltt_time_zero, max_time);
     lttv_stats_remove_event_hooks(tscs);
-    g_warning("Processing trace while counting stats (%g seconds)", t);
+    g_message("Processing trace while counting stats (%g seconds)", t);
 
     if(lttv_profile_memory) {
       g_message("Memory summary after computing stats");
@@ -482,7 +513,7 @@ static gboolean process_traceset(void __UNUSED__ *hook_data,
     t = run_one_test(ts, ltt_time_zero, max_time);
     lttv_state_remove_event_hooks(ts);
     lttv_stats_remove_event_hooks(tscs);
-    g_warning(
+    g_message(
         "Processing trace while counting state and stats (%g seconds)", t);
 
     if(lttv_profile_memory) {
@@ -521,7 +552,7 @@ static gboolean process_traceset(void __UNUSED__ *hook_data,
     if(a_save_state_copy)
         lttv_hooks_remove_data(event_hook,save_state_copy_event, &save_state);
 
-    g_warning("Processing trace while updating/saving state (%g seconds)", t);
+    g_message("Processing trace while updating/saving state (%g seconds)", t);
 
     if(lttv_profile_memory) {
       g_message("Memory summary after computing/saving state");
@@ -541,7 +572,7 @@ static gboolean process_traceset(void __UNUSED__ *hook_data,
         t = run_one_test(ts, save_state.write_time[j], 
             save_state.write_time[j]);
         lttv_state_remove_event_hooks(ts);
-        g_warning("Seeking to %lu.%lu (%g seconds)", 
+        g_message("Seeking to %lu.%lu (%g seconds)", 
             save_state.write_time[j].tv_sec, save_state.write_time[j].tv_nsec,
             t);
 
This page took 0.025681 seconds and 4 git commands to generate.