Added options to run different tests in module batchtest
authordagenais <dagenais@04897980-b3bd-0310-b5e0-8ef037075253>
Sun, 22 Feb 2004 03:42:48 +0000 (03:42 +0000)
committerdagenais <dagenais@04897980-b3bd-0310-b5e0-8ef037075253>
Sun, 22 Feb 2004 03:42:48 +0000 (03:42 +0000)
Added option to profile and check memory
Fixed several segmentation faults

git-svn-id: http://ltt.polymtl.ca/svn@492 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/include/lttv/lttv.h
ltt/branches/poly/include/lttv/processTrace.h
ltt/branches/poly/include/lttv/state.h
ltt/branches/poly/lttv/main/main.c
ltt/branches/poly/lttv/main/module.c
ltt/branches/poly/lttv/main/processTrace.c
ltt/branches/poly/lttv/main/state.c
ltt/branches/poly/lttv/main/stats.c
ltt/branches/poly/lttv/modules/gui/detailedevents/events.c
ltt/branches/poly/lttv/modules/gui/statistics/statistics.c
ltt/branches/poly/lttv/modules/text/Makefile.am

index bdd39a6643f9e224c925bcd979588945ce1b8ec2..4c9477adee598176b3e50c27c617829a22fb0811 100644 (file)
@@ -52,4 +52,6 @@ LttvAttribute *lttv_global_attributes();
 #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
 #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
 
+extern gboolean lttv_profile_memory;
+
 #endif // LTTV_H
index 8d4ad238106a55e90c37707e8073767e5f1a597b..6afff0ffca55ce34e8aee3b907054fedff220754 100644 (file)
@@ -137,8 +137,7 @@ struct _LttvTraceContext {
   LttvHooks *check;
   LttvHooks *before;
   LttvHooks *after;
-  LttvTracefileContext **control_tracefiles;
-  LttvTracefileContext **per_cpu_tracefiles;
+  LttvTracefileContext **tracefiles;
   LttvAttribute *a;
   LttvAttribute *t_a;
 };
@@ -161,7 +160,7 @@ struct _LttvTracefileContext {
 
   LttvTraceContext *t_context;
   gboolean control;
-  guint index;                /* in ts_context->control/per_cpu_tracefiles */
+  guint index;                /* in ts_context->tracefiles */
   LttTracefile *tf;
   LttvHooks *check;
   LttvHooks *before;
index 077b809b8f2688cd07924641cfd3f26d7f1e33ca..fb2fa9989e527d4e1694735f167e041ea86d626e 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <glib.h>
 #include <lttv/processTrace.h>
+#include <stdio.h>
 
 /* The operating system state, kept during the trace analysis,
    contains a subset of the real operating system state, 
@@ -156,6 +157,7 @@ LttvProcessState *
 lttv_state_create_process(LttvTracefileState *tfs, LttvProcessState *parent, 
     guint pid);
 
+void lttv_state_write(LttvTraceState *self, LttTime t, FILE *fp);
 
 /* The LttvTracesetState, LttvTraceState and LttvTracefileState types
    inherit from the corresponding Context objects defined in processTrace. */
index eb6625a548b94a7c47b10acfffd15691f7d4308b..fb9c7164e8578bceab33ab47b3925b49a414d7ab 100644 (file)
@@ -26,6 +26,7 @@
 #include <lttv/traceset.h>
 #include <ltt/trace.h>
 #include <stdio.h>
+#include <mcheck.h>
 
 
 void lttv_option_init(int argc, char **argv);
@@ -60,6 +61,8 @@ static gboolean
   a_verbose,
   a_debug;
 
+gboolean lttv_profile_memory;
+
 static int a_argc;
 
 static char **a_argv;
@@ -87,19 +90,42 @@ void ignore_and_drop_message(const gchar *log_domain, GLogLevelFlags log_level,
 
 int main(int argc, char **argv) {
 
+  int i;
+
+  char 
+    *profile_memory_short_option = "-M",
+    *profile_memory_long_option = "--memory";
+
+  gboolean profile_memory = FALSE;
+
   LttvAttributeValue value;
 
-#ifdef MEMDEBUG
-  g_mem_set_vtable(glib_mem_profiler_table);
-  g_message("Memory summary before main");
-  g_mem_profile();
-#endif
 
-  g_log_set_handler(NULL, G_LOG_LEVEL_INFO, ignore_and_drop_message, NULL);
-  g_log_set_handler(NULL, G_LOG_LEVEL_DEBUG, ignore_and_drop_message, NULL);
+  /* Before anything else, check if memory profiling is requested */
+
+  for(i = 1 ; i < argc ; i++) {
+    if(*(argv[i]) != '-') break;
+    if(strcmp(argv[i], profile_memory_short_option) == 0 || 
+       strcmp(argv[i], profile_memory_long_option) == 0) {
+      mcheck(0);
+      g_mem_set_vtable(glib_mem_profiler_table);
+      g_message("Memory summary before main");
+      g_mem_profile();
+      profile_memory = TRUE;
+      break;
+    }
+  }
+
+
+  /* Initialize glib and by default ignore info and debug messages */
 
   g_type_init();
   //g_type_init_with_debug_flags (G_TYPE_DEBUG_OBJECTS | G_TYPE_DEBUG_SIGNALS);
+  g_log_set_handler(NULL, G_LOG_LEVEL_INFO, ignore_and_drop_message, NULL);
+  g_log_set_handler(NULL, G_LOG_LEVEL_DEBUG, ignore_and_drop_message, NULL);
+
+
+  /* Have an attributes subtree to store hooks to be registered by modules. */
 
   attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
 
@@ -108,6 +134,9 @@ int main(int argc, char **argv) {
   before_main = lttv_hooks_new();
   after_main = lttv_hooks_new();
 
+
+  /* Create a number of hooks lists */
+
   g_assert(lttv_iattribute_find_by_path(attributes, "hooks/options/before",
       LTTV_POINTER, &value));
   *(value.v_pointer) = before_options;
@@ -131,10 +160,12 @@ int main(int argc, char **argv) {
   lttv_state_init(argc,argv);
   lttv_stats_init(argc,argv);
 
+
   /* Initialize the module loading */
 
   lttv_module_path_add(PACKAGE_PLUGIN_DIR);
 
+
   /* Add some built-in options */
 
   lttv_option_add("module",'m', "load a module", "name of module to load", 
@@ -156,14 +187,33 @@ int main(int argc, char **argv) {
   lttv_option_add("debug",'d', "print debugging messages", "none", 
       LTTV_OPT_NONE, NULL, lttv_debug, NULL);
  
+  lttv_profile_memory = FALSE;
+  lttv_option_add(profile_memory_long_option + 2, 
+      profile_memory_short_option[1], "print memory information", "none", 
+      LTTV_OPT_NONE, &lttv_profile_memory, NULL, NULL);
+
+
+  /* Process the options */
  
   lttv_hooks_call(before_options, NULL);
   lttv_option_parse(argc, argv);
   lttv_hooks_call(after_options, NULL);
 
+
+  /* Memory profiling to be useful must be activated as early as possible */
+
+  if(profile_memory != lttv_profile_memory) 
+    g_error("Memory profiling options must appear before other options");
+
+
+  /* Do the main work */
+
   lttv_hooks_call(before_main, NULL);
   lttv_hooks_call(after_main, NULL);
 
+
+  /* Clean up everything */
+
   lttv_stats_destroy();
   lttv_state_destroy();
   lttv_module_destroy();
@@ -175,10 +225,10 @@ int main(int argc, char **argv) {
   lttv_hooks_destroy(after_main);
   g_object_unref(attributes);
 
-#ifdef MEMDEBUG
+  if(profile_memory) {
     g_message("Memory summary after main");
     g_mem_profile();
-#endif
+  }
 }
 
 
index 206f3cf113d0b48e48730c82faf1647973734a4e..df98aacf7fe1426370523fa76dc75c61885a60c5 100644 (file)
@@ -187,7 +187,7 @@ lttv_module_require(LttvModule *m, const char *name, int argc, char **argv)
       "Load module %s, as %s is a dependent requiring it", name, 
       g_module_name(m->module));
   module = module_load(name, argc, argv);
-  if(module != NULL) g_ptr_array_add(module->dependents, m);
+  if(module != NULL) g_ptr_array_add(m->dependents, module);
   return module;
 }
 
@@ -210,7 +210,17 @@ static void module_unload(LttvModule *m)
         "Module usage count decremented to %d", m->ref_count);
     return;
   }
-  /* We really have to unload the module, first unload its dependents */
+
+  /* We really have to unload the module. First destroy it. */
+
+  g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, 
+      "Call the destroy function and unload the module");
+  if(!g_module_symbol(m->module, "destroy", (gpointer)&destroy_function)) {
+    g_warning("module (%s) has no destroy function", pathname);
+  }
+  else destroy_function();
+
+  /* Then release the modules required by this module */
 
   len = m->dependents->len;
   g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "Unload dependent modules");
@@ -221,14 +231,7 @@ static void module_unload(LttvModule *m)
 
   if(len != m->dependents->len) g_error("dependents list modified");
 
-  /* Unload the module itself */
-
-  g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, 
-      "Call the destroy function and unload the module");
-  if(!g_module_symbol(m->module, "destroy", (gpointer)&destroy_function)) {
-    g_warning("module (%s) has no destroy function", pathname);
-  }
-  else destroy_function();
+  /* Finally remove any trace of this module */
 
   g_hash_table_remove(modules, g_module_name(m->module));
   g_ptr_array_free(m->dependents, TRUE);
@@ -310,15 +313,16 @@ lttv_module_unload_all()
 
   LttvModule *m;
 
-  GPtrArray *independent_modules = g_ptr_array_new();
+  GPtrArray *independent_modules;
 
-  g_hash_table_foreach(modules, list_independent, independent_modules);
+  while(g_hash_table_size(modules) != 0) {
+    independent_modules = g_ptr_array_new();
+    g_hash_table_foreach(modules, list_independent, independent_modules);
 
-  for(i = 0 ; i < independent_modules->len ; i++) {
-    m = (LttvModule *)independent_modules->pdata[i];
-    while(m->load_count > 0) lttv_module_unload(m);
+    for(i = 0 ; i < independent_modules->len ; i++) {
+      m = (LttvModule *)independent_modules->pdata[i];
+      lttv_module_unload(m);
+    }
+    g_ptr_array_free(independent_modules, TRUE);
   }
-
-  g_ptr_array_free(independent_modules, TRUE);
-  if(g_hash_table_size(modules) != 0) g_warning("cannot unload all modules"); 
 }
index 7db10a31b37e885585967083bafa31a8518eef85..c811da0eeb521286273762378c3aa61857d035c3 100644 (file)
@@ -142,21 +142,19 @@ init(LttvTracesetContext *self, LttvTraceset *ts)
     nb_control = ltt_trace_control_tracefile_number(tc->t);
     nb_per_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
     nb_tracefile = nb_control + nb_per_cpu;
-    tc->control_tracefiles = g_new(LttvTracefileContext *, nb_control);
-    tc->per_cpu_tracefiles = g_new(LttvTracefileContext *, nb_per_cpu);
+    tc->tracefiles = g_new(LttvTracefileContext *, nb_tracefile);
 
     for(j = 0 ; j < nb_tracefile ; j++) {
       tfc = LTTV_TRACESET_CONTEXT_GET_CLASS(self)->new_tracefile_context(self);
+      tc->tracefiles[j] = tfc;
+      tfc->index = j;
+
       if(j < nb_control) {
-        tc->control_tracefiles[j] = tfc;
         tfc->control = TRUE;
-        tfc->index = j;
         tfc->tf = ltt_trace_control_tracefile_get(tc->t, j);
       }
       else {
-        tc->per_cpu_tracefiles[j - nb_control] = tfc;
         tfc->control = FALSE;
-        tfc->index = j - nb_control;
         tfc->tf = ltt_trace_per_cpu_tracefile_get(tc->t, j - nb_control);
       }
       tfc->t_context = tc;
@@ -180,7 +178,7 @@ init(LttvTracesetContext *self, LttvTraceset *ts)
 
 void fini(LttvTracesetContext *self)
 {
-  guint i, j, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+  guint i, j, nb_trace, nb_tracefile;
 
   LttvTraceContext *tc;
 
@@ -205,14 +203,11 @@ void fini(LttvTracesetContext *self)
     lttv_hooks_destroy(tc->after);
     g_object_unref(tc->a);
 
-    nb_control = ltt_trace_control_tracefile_number(tc->t);
-    nb_per_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
-    nb_tracefile = nb_control + nb_per_cpu;
+    nb_tracefile = ltt_trace_control_tracefile_number(tc->t) +
+        ltt_trace_per_cpu_tracefile_number(tc->t);
 
     for(j = 0 ; j < nb_tracefile ; j++) {
-      if(j < nb_control) tfc = tc->control_tracefiles[j];
-      else tfc = tc->per_cpu_tracefiles[j - nb_control];
-
+      tfc = tc->tracefiles[j];
       lttv_hooks_destroy(tfc->check);
       lttv_hooks_destroy(tfc->before);
       lttv_hooks_destroy(tfc->after);
@@ -224,8 +219,7 @@ void fini(LttvTracesetContext *self)
       g_object_unref(tfc->a);
       g_object_unref(tfc);
     }
-    g_free(tc->control_tracefiles);
-    g_free(tc->per_cpu_tracefiles);
+    g_free(tc->tracefiles);
     g_object_unref(tc);
   }
   g_free(self->traces);
@@ -247,7 +241,7 @@ void lttv_traceset_context_add_hooks(LttvTracesetContext *self,
 {
   LttvTraceset *ts = self->ts;
 
-  guint i, j, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+  guint i, j, nb_trace, nb_tracefile;
 
   LttvTraceContext *tc;
 
@@ -264,17 +258,11 @@ void lttv_traceset_context_add_hooks(LttvTracesetContext *self,
     lttv_hooks_add_list(tc->check, check_trace);
     lttv_hooks_add_list(tc->before, before_trace);
     lttv_hooks_add_list(tc->after, after_trace);
-    nb_control = ltt_trace_control_tracefile_number(tc->t);
-    nb_per_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
-    nb_tracefile = nb_control + nb_per_cpu;
+    nb_tracefile = ltt_trace_control_tracefile_number(tc->t) +
+        ltt_trace_per_cpu_tracefile_number(tc->t);
 
     for(j = 0 ; j < nb_tracefile ; j++) {
-      if(j < nb_control) {
-        tfc = tc->control_tracefiles[j];
-      }
-      else {
-        tfc = tc->per_cpu_tracefiles[j-nb_control];
-      }
+      tfc = tc->tracefiles[j];
       lttv_hooks_add_list(tfc->check, check_tracefile);
       lttv_hooks_add_list(tfc->before, before_tracefile);
       lttv_hooks_add_list(tfc->after, after_tracefile);
@@ -301,7 +289,7 @@ void lttv_traceset_context_remove_hooks(LttvTracesetContext *self,
 {
   LttvTraceset *ts = self->ts;
 
-  guint i, j, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+  guint i, j, nb_trace, nb_tracefile;
 
   LttvTraceContext *tc;
 
@@ -318,17 +306,11 @@ void lttv_traceset_context_remove_hooks(LttvTracesetContext *self,
     lttv_hooks_remove_list(tc->check, check_trace);
     lttv_hooks_remove_list(tc->before, before_trace);
     lttv_hooks_remove_list(tc->after, after_trace);
-    nb_control = ltt_trace_control_tracefile_number(tc->t);
-    nb_per_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
-    nb_tracefile = nb_control + nb_per_cpu;
+    nb_tracefile = ltt_trace_control_tracefile_number(tc->t) +
+        ltt_trace_per_cpu_tracefile_number(tc->t);
 
     for(j = 0 ; j < nb_tracefile ; j++) {
-      if(j < nb_control) {
-        tfc = tc->control_tracefiles[j];
-      }
-      else {
-        tfc = tc->per_cpu_tracefiles[j-nb_control];
-      }
+      tfc = tc->tracefiles[j];
       lttv_hooks_remove_list(tfc->check, check_tracefile);
       lttv_hooks_remove_list(tfc->before, before_tracefile);
       lttv_hooks_remove_list(tfc->after, after_tracefile);
@@ -594,7 +576,7 @@ gboolean get_first(gpointer key, gpointer value, gpointer user_data) {
 
 void lttv_process_traceset_begin(LttvTracesetContext *self, LttTime end)
 {
-  guint i, j, nbi, nbj, nb_control, nb_cpu;
+  guint i, j, nbi, nb_tracefile;
 
   LttvTraceContext *tc;
 
@@ -613,24 +595,19 @@ void lttv_process_traceset_begin(LttvTracesetContext *self, LttTime end)
 
     if(!lttv_hooks_call_check(tc->check, tc)) {
       lttv_hooks_call(tc->before, tc);
-      nb_control = ltt_trace_control_tracefile_number(tc->t);
-      nb_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
-      nbj = nb_control + nb_cpu;
+      nb_tracefile = ltt_trace_control_tracefile_number(tc->t) +
+          ltt_trace_per_cpu_tracefile_number(tc->t);
 
-      for(j = 0 ; j < nbj ; j++) {
-        if(j < nb_control) {
-          tfc = tc->control_tracefiles[j];
-        }
-        else {
-          tfc = tc->per_cpu_tracefiles[j - nb_control];
-        }
+      for(j = 0 ; j < nb_tracefile ; j++) {
+        tfc = tc->tracefiles[j];
 
         if(!lttv_hooks_call_check(tfc->check, tfc)) {
           lttv_hooks_call(tfc->before, tfc);
 
           if(tfc->e != NULL) {
            if(tfc->timestamp.tv_sec < end.tv_sec ||
-              (tfc->timestamp.tv_sec == end.tv_sec && tfc->timestamp.tv_nsec <= end.tv_nsec)){
+              (tfc->timestamp.tv_sec == end.tv_sec && 
+               tfc->timestamp.tv_nsec <= end.tv_nsec)) {
              g_tree_insert(self->pqueue, &(tfc->timestamp), tfc);
            }
           }
@@ -709,7 +686,7 @@ guint lttv_process_traceset_middle(LttvTracesetContext *self, LttTime end,
 
 void lttv_process_traceset_end(LttvTracesetContext *self)
 {
-  guint i, j, nbi, nbj, nb_control, nb_cpu;
+  guint i, j, nbi, nb_tracefile;
 
   LttvTraceContext *tc;
 
@@ -726,17 +703,11 @@ void lttv_process_traceset_end(LttvTracesetContext *self)
        obtained at the beginning. CHECK if it poses a problem */
 
     if(!lttv_hooks_call_check(tc->check, tc)) {
-      nb_control = ltt_trace_control_tracefile_number(tc->t);
-      nb_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
-      nbj = nb_control + nb_cpu;
+      nb_tracefile = ltt_trace_control_tracefile_number(tc->t) +
+          ltt_trace_per_cpu_tracefile_number(tc->t);
 
-      for(j = 0 ; j < nbj ; j++) {
-        if(j < nb_control) {
-          tfc = tc->control_tracefiles[j];
-        }
-        else {
-          tfc = tc->per_cpu_tracefiles[j - nb_control];
-        }
+      for(j = 0 ; j < nb_tracefile ; j++) {
+        tfc = tc->tracefiles[j];
 
         if(!lttv_hooks_call_check(tfc->check, tfc)) {
           lttv_hooks_call(tfc->after, tfc);
@@ -770,19 +741,17 @@ void lttv_process_traceset(LttvTracesetContext *self, LttTime end,
 
 void lttv_process_trace_seek_time(LttvTraceContext *self, LttTime start)
 {
-  guint i, nb_control, nb_per_cpu, nb_tracefile;
+  guint i, nb_tracefile;
 
   LttvTracefileContext *tfc;
 
   LttEvent *event;
 
-  nb_control = ltt_trace_control_tracefile_number(self->t);
-  nb_per_cpu = ltt_trace_per_cpu_tracefile_number(self->t);
-  nb_tracefile = nb_control + nb_per_cpu;
-  for(i = 0 ; i < nb_tracefile ; i++) {
-    if(i < nb_control) tfc = self->control_tracefiles[i];
-    else tfc = self->per_cpu_tracefiles[i - nb_control];
+  nb_tracefile = ltt_trace_control_tracefile_number(self->t) +
+      ltt_trace_per_cpu_tracefile_number(self->t);
 
+  for(i = 0 ; i < nb_tracefile ; i++) {
+    tfc = self->tracefiles[i];
     ltt_tracefile_seek_time(tfc->tf, start);
     event = ltt_tracefile_read(tfc->tf);
     tfc->e = event;
index 54a5b75c19ab3cd07cc34f4cd3c6748272e54a57..5f67bf7b4cdb2f84757c96809c4ef98e78ceff44 100644 (file)
@@ -48,6 +48,7 @@ static GQuark
   LTTV_STATE_PROCESS,
   LTTV_STATE_EVENT,
   LTTV_STATE_SAVED_STATES,
+  LTTV_STATE_SAVED_STATES_TIME,
   LTTV_STATE_TIME,
   LTTV_STATE_HOOKS;
 
@@ -101,7 +102,7 @@ gboolean process_equal(gconstpointer a, gconstpointer b)
 static void
 restore_init_state(LttvTraceState *self)
 {
-  guint i, nb_control, nb_per_cpu, nb_tracefile;
+  guint i, nb_tracefile;
 
   LttvTracefileState *tfcs;
   
@@ -111,17 +112,11 @@ restore_init_state(LttvTraceState *self)
   self->processes = g_hash_table_new(process_hash, process_equal);
   self->nb_event = 0;
 
-  nb_control = ltt_trace_control_tracefile_number(self->parent.t);
-  nb_per_cpu = ltt_trace_per_cpu_tracefile_number(self->parent.t);
-  nb_tracefile = nb_control + nb_per_cpu;
-  for(i = 0 ; i < nb_tracefile ; i++) {
-    if(i < nb_control) {
-      tfcs = LTTV_TRACEFILE_STATE(self->parent.control_tracefiles[i]);
-    }
-    else {
-      tfcs = LTTV_TRACEFILE_STATE(self->parent.per_cpu_tracefiles[i - nb_control]);
-    }
+  nb_tracefile = ltt_trace_control_tracefile_number(self->parent.t) +
+      ltt_trace_per_cpu_tracefile_number(self->parent.t);
 
+  for(i = 0 ; i < nb_tracefile ; i++) {
+    tfcs = LTTV_TRACEFILE_STATE(self->parent.tracefiles[i]);
     tfcs->parent.timestamp = null_time;
     tfcs->saved_position = 0;
     tfcs->process = lttv_state_create_process(tfcs, NULL,0);
@@ -135,7 +130,7 @@ static LttTime time_zero = {0,0};
 static void
 init(LttvTracesetState *self, LttvTraceset *ts)
 {
-  guint i, j, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+  guint i, j, nb_trace, nb_tracefile;
 
   LttvTraceContext *tc;
 
@@ -143,6 +138,8 @@ init(LttvTracesetState *self, LttvTraceset *ts)
 
   LttvTracefileState *tfcs;
   
+  LttvAttributeValue v;
+
   LTTV_TRACESET_CONTEXT_CLASS(g_type_class_peek(LTTV_TRACESET_CONTEXT_TYPE))->
       init((LttvTracesetContext *)self, ts);
 
@@ -150,20 +147,19 @@ init(LttvTracesetState *self, LttvTraceset *ts)
   for(i = 0 ; i < nb_trace ; i++) {
     tc = self->parent.traces[i];
     tcs = (LttvTraceState *)tc;
-    tcs->save_interval = 100000;
-    tcs->max_time_state_recomputed_in_seek = &time_zero;
+    tcs->save_interval = 50000;
+    lttv_attribute_find(tcs->parent.t_a, LTTV_STATE_SAVED_STATES_TIME, 
+        LTTV_POINTER, &v);
+    if(*(v.v_pointer) == NULL) *(v.v_pointer) = g_new(LttTime,1);
+    tcs->max_time_state_recomputed_in_seek = (LttTime *)*(v.v_pointer);
+
     fill_name_tables(tcs);
 
-    nb_control = ltt_trace_control_tracefile_number(tc->t);
-    nb_per_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
-    nb_tracefile = nb_control + nb_per_cpu;
+    nb_tracefile = ltt_trace_control_tracefile_number(tc->t) +
+        ltt_trace_per_cpu_tracefile_number(tc->t);
+
     for(j = 0 ; j < nb_tracefile ; j++) {
-      if(j < nb_control) {
-        tfcs = LTTV_TRACEFILE_STATE(tc->control_tracefiles[j]);
-      }
-      else {
-        tfcs = LTTV_TRACEFILE_STATE(tc->per_cpu_tracefiles[j - nb_control]);
-      }
+      tfcs = LTTV_TRACEFILE_STATE(tc->tracefiles[j]);
       tfcs->cpu_name= g_quark_from_string(ltt_tracefile_name(tfcs->parent.tf));
     }
     tcs->processes = NULL;
@@ -175,7 +171,7 @@ init(LttvTracesetState *self, LttvTraceset *ts)
 static void
 fini(LttvTracesetState *self)
 {
-  guint i, j, nb_trace, nb_tracefile;
+  guint i, j, nb_trace;
 
   LttvTraceState *tcs;
 
@@ -214,6 +210,74 @@ new_tracefile_context(LttvTracesetContext *self)
 }
 
 
+/* Write the process state of the trace */
+
+static void write_process_state(gpointer key, gpointer value,
+    gpointer user_data)
+{
+  LttvProcessState *process;
+
+  LttvExecutionState *es;
+
+  FILE *fp = (FILE *)user_data;
+
+  guint i;
+
+  process = (LttvProcessState *)value;
+  fprintf(fp,
+"  <PROCESS PID=%u PPID=%u CTIME_S=%lu CTIME_NS=%lu NAME=\"%s\" CPU=\"%s\">\n",
+      process->pid, process->ppid, process->creation_time.tv_sec,
+      process->creation_time.tv_nsec, g_quark_to_string(process->name),
+      g_quark_to_string(process->last_cpu));
+
+  for(i = 0 ; i < process->execution_stack->len; i++) {
+    es = &g_array_index(process->execution_stack, LttvExecutionState, i);
+    fprintf(fp, "    <ES MODE=\"%s\" SUBMODE=\"%s\" ENTRY_S=%lu ENTRY_NS=%lu",
+           g_quark_to_string(es->t), g_quark_to_string(es->n),
+            es->entry.tv_sec, es->entry.tv_nsec);
+    fprintf(fp, " CHANGE_S=%lu CHANGE_NS=%lu STATUS=\"%s\"/>\n",
+            es->change.tv_sec, es->change.tv_nsec, g_quark_to_string(es->s)); 
+  }
+  fprintf(fp, "  </PROCESS>\n");
+}
+
+
+void lttv_state_write(LttvTraceState *self, LttTime t, FILE *fp)
+{
+  guint i, nb_tracefile, nb_block, nb_event;
+
+  LttvTracefileState *tfcs;
+
+  LttTracefile *tf;
+
+  LttEventPosition *ep;
+
+  ep = ltt_event_position_new();
+
+  fprintf(fp,"<PROCESS_STATE TIME_S=%lu TIME_NS=%lu>\n", t.tv_sec, t.tv_nsec);
+
+  g_hash_table_foreach(self->processes, write_process_state, fp);
+
+  nb_tracefile = ltt_trace_control_tracefile_number(self->parent.t) +
+      ltt_trace_per_cpu_tracefile_number(self->parent.t);
+
+  for(i = 0 ; i < nb_tracefile ; i++) {
+    tfcs = (LttvTracefileState *)self->parent.tracefiles[i];
+    fprintf(fp, "  <TRACEFILE PID=%u", tfcs->process->pid);
+    if(tfcs->parent.e == NULL) fprintf(fp,"/>\n");
+    else {
+      ltt_event_position(tfcs->parent.e, ep);
+      ltt_event_position_get(ep, &nb_block, &nb_event, &tf);
+      fprintf(fp, " BLOCK=%u EVENT=%u/>\n", nb_block, nb_event);
+    }
+  }
+  g_free(ep);
+  fprintf(fp,"</PROCESS_STATE>");
+}
+
+
+/* Copy each process from an existing hash table to a new one */
+
 static void copy_process_state(gpointer key, gpointer value,gpointer user_data)
 {
   LttvProcessState *process, *new_process;
@@ -255,7 +319,7 @@ static GHashTable *lttv_state_copy_process_table(GHashTable *processes)
 
 static void state_save(LttvTraceState *self, LttvAttribute *container)
 {
-  guint i, nb_control, nb_per_cpu, nb_tracefile;
+  guint i, nb_tracefile;
 
   LttvTracefileState *tfcs;
 
@@ -276,16 +340,11 @@ static void state_save(LttvTraceState *self, LttvAttribute *container)
       LTTV_POINTER);
   *(value.v_pointer) = lttv_state_copy_process_table(self->processes);
 
-  nb_control = ltt_trace_control_tracefile_number(self->parent.t);
-  nb_per_cpu = ltt_trace_per_cpu_tracefile_number(self->parent.t);
-  nb_tracefile = nb_control + nb_per_cpu;
+  nb_tracefile = ltt_trace_control_tracefile_number(self->parent.t) +
+      ltt_trace_per_cpu_tracefile_number(self->parent.t);
 
   for(i = 0 ; i < nb_tracefile ; i++) {
-    if(i < nb_control) 
-        tfcs = (LttvTracefileState *)self->parent.control_tracefiles[i];
-    else tfcs = (LttvTracefileState *)
-        self->parent.per_cpu_tracefiles[i - nb_control];
-
+    tfcs = (LttvTracefileState *)self->parent.tracefiles[i];
     tracefile_tree = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
     value = lttv_attribute_add(tracefiles_tree, i, 
         LTTV_GOBJECT);
@@ -307,7 +366,7 @@ static void state_save(LttvTraceState *self, LttvAttribute *container)
 
 static void state_restore(LttvTraceState *self, LttvAttribute *container)
 {
-  guint i, nb_control, nb_per_cpu, nb_tracefile, pid;
+  guint i, nb_tracefile, pid;
 
   LttvTracefileState *tfcs;
 
@@ -330,16 +389,11 @@ static void state_restore(LttvTraceState *self, LttvAttribute *container)
   lttv_state_free_process_table(self->processes);
   self->processes = lttv_state_copy_process_table(*(value.v_pointer));
 
-  nb_control = ltt_trace_control_tracefile_number(self->parent.t);
-  nb_per_cpu = ltt_trace_per_cpu_tracefile_number(self->parent.t);
-  nb_tracefile = nb_control + nb_per_cpu;
+  nb_tracefile = ltt_trace_control_tracefile_number(self->parent.t) +
+      ltt_trace_per_cpu_tracefile_number(self->parent.t);
 
   for(i = 0 ; i < nb_tracefile ; i++) {
-    if(i < nb_control) tfcs = (LttvTracefileState *)
-        self->parent.control_tracefiles[i];
-    else tfcs = (LttvTracefileState *)
-        self->parent.per_cpu_tracefiles[i - nb_control];
-
+    tfcs = (LttvTracefileState *)self->parent.tracefiles[i];
     type = lttv_attribute_get(tracefiles_tree, i, &name, &value);
     g_assert(type == LTTV_GOBJECT);
     tracefile_tree = *((LttvAttribute **)(value.v_gobject));
@@ -366,7 +420,7 @@ static void state_restore(LttvTraceState *self, LttvAttribute *container)
 
 static void state_saved_free(LttvTraceState *self, LttvAttribute *container)
 {
-  guint i, nb_control, nb_per_cpu, nb_tracefile;
+  guint i, nb_tracefile;
 
   LttvTracefileState *tfcs;
 
@@ -391,16 +445,11 @@ static void state_saved_free(LttvTraceState *self, LttvAttribute *container)
   *(value.v_pointer) = NULL;
   lttv_attribute_remove_by_name(container, LTTV_STATE_PROCESSES);
 
-  nb_control = ltt_trace_control_tracefile_number(self->parent.t);
-  nb_per_cpu = ltt_trace_per_cpu_tracefile_number(self->parent.t);
-  nb_tracefile = nb_control + nb_per_cpu;
+  nb_tracefile = ltt_trace_control_tracefile_number(self->parent.t) +
+      ltt_trace_per_cpu_tracefile_number(self->parent.t);
 
   for(i = 0 ; i < nb_tracefile ; i++) {
-    if(i < nb_control) tfcs = (LttvTracefileState *)
-        self->parent.control_tracefiles[i];
-    else tfcs = (LttvTracefileState *)
-        self->parent.per_cpu_tracefiles[i - nb_control];
-
+    tfcs = (LttvTracefileState *)self->parent.tracefiles[i];
     type = lttv_attribute_get(tracefiles_tree, i, &name, &value);
     g_assert(type == LTTV_GOBJECT);
     tracefile_tree = *((LttvAttribute **)(value.v_gobject));
@@ -810,7 +859,7 @@ void lttv_state_add_event_hooks(LttvTracesetState *self)
 {
   LttvTraceset *traceset = self->parent.ts;
 
-  guint i, j, k, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+  guint i, j, k, nb_trace, nb_tracefile;
 
   LttvTraceState *ts;
 
@@ -861,16 +910,11 @@ void lttv_state_add_event_hooks(LttvTracesetState *self)
 
     /* Add these hooks to each before_event_by_id hooks list */
 
-    nb_control = ltt_trace_control_tracefile_number(ts->parent.t);
-    nb_per_cpu = ltt_trace_per_cpu_tracefile_number(ts->parent.t);
-    nb_tracefile = nb_control + nb_per_cpu;
+    nb_tracefile = ltt_trace_control_tracefile_number(ts->parent.t) +
+        ltt_trace_per_cpu_tracefile_number(ts->parent.t);
+
     for(j = 0 ; j < nb_tracefile ; j++) {
-      if(j < nb_control) {
-        tfs = LTTV_TRACEFILE_STATE(ts->parent.control_tracefiles[j]);
-      }
-      else {
-        tfs = LTTV_TRACEFILE_STATE(ts->parent.per_cpu_tracefiles[j-nb_control]);
-      }
+      tfs = LTTV_TRACEFILE_STATE(ts->parent.tracefiles[j]);
 
       for(k = 0 ; k < hooks->len ; k++) {
         hook = g_array_index(hooks, LttvTraceHook, k);
@@ -888,7 +932,7 @@ void lttv_state_remove_event_hooks(LttvTracesetState *self)
 {
   LttvTraceset *traceset = self->parent.ts;
 
-  guint i, j, k, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+  guint i, j, k, nb_trace, nb_tracefile;
 
   LttvTraceState *ts;
 
@@ -908,16 +952,11 @@ void lttv_state_remove_event_hooks(LttvTracesetState *self)
 
     /* Add these hooks to each before_event_by_id hooks list */
 
-    nb_control = ltt_trace_control_tracefile_number(ts->parent.t);
-    nb_per_cpu = ltt_trace_per_cpu_tracefile_number(ts->parent.t);
-    nb_tracefile = nb_control + nb_per_cpu;
+    nb_tracefile = ltt_trace_control_tracefile_number(ts->parent.t) +
+        ltt_trace_per_cpu_tracefile_number(ts->parent.t);
+
     for(j = 0 ; j < nb_tracefile ; j++) {
-      if(j < nb_control) {
-        tfs = LTTV_TRACEFILE_STATE(ts->parent.control_tracefiles[j]);
-      }
-      else {
-        tfs = LTTV_TRACEFILE_STATE(ts->parent.per_cpu_tracefiles[j-nb_control]);
-      }
+      tfs = LTTV_TRACEFILE_STATE(ts->parent.tracefiles[j]);
 
       for(k = 0 ; k < hooks->len ; k++) {
         hook = g_array_index(hooks, LttvTraceHook, k);
@@ -933,13 +972,15 @@ void lttv_state_remove_event_hooks(LttvTracesetState *self)
 
 static gboolean block_end(void *hook_data, void *call_data)
 {
-  LttvTracefileState *tfcs = (LttvTracefileState *)call_data;
+  LttvTracefileState *self = (LttvTracefileState *)call_data;
 
-  LttvTraceState *tcs = (LttvTraceState *)(tfcs->parent.t_context);
+  LttvTracefileState *tfcs;
 
-  LttEventPosition *ep = ltt_event_position_new();
+  LttvTraceState *tcs = (LttvTraceState *)(self->parent.t_context);
+
+  LttEventPosition *ep;
 
-  guint nb_block, nb_event;
+  guint i, nb_block, nb_event, nb_tracefile;
 
   LttTracefile *tf;
 
@@ -947,11 +988,22 @@ static gboolean block_end(void *hook_data, void *call_data)
 
   LttvAttributeValue value;
 
-  ltt_event_position(tfcs->parent.e, ep);
+  ep = ltt_event_position_new();
+  nb_tracefile = ltt_trace_control_tracefile_number(tcs->parent.t) +
+      ltt_trace_per_cpu_tracefile_number(tcs->parent.t);
+
+  /* Count the number of events added since the last block end in any
+     tracefile. */
+
+  for(i = 0 ; i < nb_tracefile ; i++) {
+    tfcs = (LttvTracefileState *)tcs->parent.tracefiles[i];
+    ltt_event_position(tfcs->parent.e, ep);
+    ltt_event_position_get(ep, &nb_block, &nb_event, &tf);
+    tcs->nb_event += nb_event - tfcs->saved_position;
+    tfcs->saved_position = nb_event;
+  }
+  g_free(ep);
 
-  ltt_event_position_get(ep, &nb_block, &nb_event, &tf);
-  tcs->nb_event += nb_event - tfcs->saved_position;
-  tfcs->saved_position = 0;
   if(tcs->nb_event >= tcs->save_interval) {
     saved_states_tree = lttv_attribute_find_subdir(tcs->parent.t_a, 
         LTTV_STATE_SAVED_STATES);
@@ -960,10 +1012,11 @@ static gboolean block_end(void *hook_data, void *call_data)
         lttv_attribute_get_number(saved_states_tree), LTTV_GOBJECT);
     *(value.v_gobject) = (GObject *)saved_state_tree;
     value = lttv_attribute_add(saved_state_tree, LTTV_STATE_TIME, LTTV_TIME);
-    *(value.v_time) = tfcs->parent.timestamp;
+    *(value.v_time) = self->parent.timestamp;
     lttv_state_save(tcs, saved_state_tree);
     tcs->nb_event = 0;
   }
+  *(tcs->max_time_state_recomputed_in_seek) = self->parent.timestamp;
   return FALSE;
 }
 
@@ -972,7 +1025,7 @@ void lttv_state_save_add_event_hooks(LttvTracesetState *self)
 {
   LttvTraceset *traceset = self->parent.ts;
 
-  guint i, j, k, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+  guint i, j, k, nb_trace, nb_tracefile;
 
   LttvTraceState *ts;
 
@@ -986,17 +1039,11 @@ void lttv_state_save_add_event_hooks(LttvTracesetState *self)
     lttv_trace_find_hook(ts->parent.t, "core","block_end",NULL, 
        NULL, NULL, block_end, &hook);
 
-    nb_control = ltt_trace_control_tracefile_number(ts->parent.t);
-    nb_per_cpu = ltt_trace_per_cpu_tracefile_number(ts->parent.t);
-    nb_tracefile = nb_control + nb_per_cpu;
-    for(j = 0 ; j < nb_tracefile ; j++) {
-      if(j < nb_control) {
-        tfs = LTTV_TRACEFILE_STATE(ts->parent.control_tracefiles[j]);
-      }
-      else {
-        tfs =LTTV_TRACEFILE_STATE(ts->parent.per_cpu_tracefiles[j-nb_control]);
-      }
+    nb_tracefile = ltt_trace_control_tracefile_number(ts->parent.t) +
+        ltt_trace_per_cpu_tracefile_number(ts->parent.t);
 
+    for(j = 0 ; j < nb_tracefile ; j++) {
+      tfs = LTTV_TRACEFILE_STATE(ts->parent.tracefiles[j]);
       lttv_hooks_add(lttv_hooks_by_id_find(tfs->parent.after_event_by_id, 
          hook.id), hook.h, NULL);
     }
@@ -1008,7 +1055,7 @@ void lttv_state_save_remove_event_hooks(LttvTracesetState *self)
 {
   LttvTraceset *traceset = self->parent.ts;
 
-  guint i, j, k, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+  guint i, j, k, nb_trace, nb_tracefile;
 
   LttvTraceState *ts;
 
@@ -1022,17 +1069,11 @@ void lttv_state_save_remove_event_hooks(LttvTracesetState *self)
     lttv_trace_find_hook(ts->parent.t, "core","block_end",NULL, 
        NULL, NULL, block_end, &hook);
 
-    nb_control = ltt_trace_control_tracefile_number(ts->parent.t);
-    nb_per_cpu = ltt_trace_per_cpu_tracefile_number(ts->parent.t);
-    nb_tracefile = nb_control + nb_per_cpu;
-    for(j = 0 ; j < nb_tracefile ; j++) {
-      if(j < nb_control) {
-        tfs = LTTV_TRACEFILE_STATE(ts->parent.control_tracefiles[j]);
-      }
-      else {
-        tfs =LTTV_TRACEFILE_STATE(ts->parent.per_cpu_tracefiles[j-nb_control]);
-      }
+    nb_tracefile = ltt_trace_control_tracefile_number(ts->parent.t) +
+        ltt_trace_per_cpu_tracefile_number(ts->parent.t);
 
+    for(j = 0 ; j < nb_tracefile ; j++) {
+      tfs = LTTV_TRACEFILE_STATE(ts->parent.tracefiles[j]);
       lttv_hooks_remove_data(lttv_hooks_by_id_find(
           tfs->parent.after_event_by_id, hook.id), hook.h, NULL);
     }
@@ -1145,7 +1186,7 @@ lttv_traceset_state_get_type(void)
       (GClassInitFunc) traceset_state_class_init,   /* class_init */
       NULL,   /* class_finalize */
       NULL,   /* class_data */
-      sizeof (LttvTracesetContext),
+      sizeof (LttvTracesetState),
       0,      /* n_preallocs */
       (GInstanceInitFunc) traceset_state_instance_init    /* instance_init */
     };
@@ -1274,6 +1315,7 @@ void lttv_state_init(int argc, char **argv)
   LTTV_STATE_PROCESS = g_quark_from_string("process");
   LTTV_STATE_EVENT = g_quark_from_string("event");
   LTTV_STATE_SAVED_STATES = g_quark_from_string("saved states");
+  LTTV_STATE_SAVED_STATES_TIME = g_quark_from_string("saved states time");
   LTTV_STATE_TIME = g_quark_from_string("time");
   LTTV_STATE_HOOKS = g_quark_from_string("saved state hooks");
 }
index 8415b4e42218d215458dec1be2a9cd391cfc2deb..c5686976b3e1967968605f67585fd314fc5c7bf3 100644 (file)
@@ -53,7 +53,7 @@ find_event_tree(LttvTracefileStats *tfcs, GQuark process, GQuark cpu,
 static void
 init(LttvTracesetStats *self, LttvTraceset *ts)
 {
-  guint i, j, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+  guint i, j, nb_trace, nb_tracefile;
 
   LttvTraceContext *tc;
 
@@ -75,17 +75,11 @@ init(LttvTracesetStats *self, LttvTraceset *ts)
     tcs = (LttvTraceStats *)tc = (LTTV_TRACESET_CONTEXT(self)->traces[i]);
     tcs->stats = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
 
-    nb_control = ltt_trace_control_tracefile_number(tc->t);
-    nb_per_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
-    nb_tracefile = nb_control + nb_per_cpu;
-    for(j = 0 ; j < nb_tracefile ; j++) {
-      if(j < nb_control) {
-        tfcs = LTTV_TRACEFILE_STATS(tc->control_tracefiles[j]);
-      }
-      else {
-        tfcs = LTTV_TRACEFILE_STATS(tc->per_cpu_tracefiles[j - nb_control]);
-      }
+    nb_tracefile = ltt_trace_control_tracefile_number(tc->t) +
+        ltt_trace_per_cpu_tracefile_number(tc->t);
 
+    for(j = 0 ; j < nb_tracefile ; j++) {
+      tfcs = LTTV_TRACEFILE_STATS(tc->tracefiles[j]);
       tfcs->stats = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
       find_event_tree(tfcs, LTTV_STATS_PROCESS_UNKNOWN,
           tfcs->parent.cpu_name, LTTV_STATE_MODE_UNKNOWN, 
@@ -121,17 +115,11 @@ fini(LttvTracesetStats *self)
     tcs = (LttvTraceStats *)tc = (LTTV_TRACESET_CONTEXT(self)->traces[i]);
     lttv_attribute_recursive_free(tcs->stats);
 
-    nb_tracefile = ltt_trace_control_tracefile_number(tc->t);
-    for(j = 0 ; j < nb_tracefile ; j++) {
-      tfcs = (LttvTracefileStats *)tfc = tc->control_tracefiles[j];
-      lttv_attribute_recursive_free(tfcs->stats);
-      tfcs->current_events_tree = NULL;
-      tfcs->current_event_types_tree = NULL;
-    }
+    nb_tracefile = ltt_trace_control_tracefile_number(tc->t) +
+        ltt_trace_per_cpu_tracefile_number(tc->t);
 
-    nb_tracefile = ltt_trace_per_cpu_tracefile_number(tc->t);
     for(j = 0 ; j < nb_tracefile ; j++) {
-      tfcs = (LttvTracefileStats *)tfc = tc->per_cpu_tracefiles[j];
+      tfcs = (LttvTracefileStats *)tfc = tc->tracefiles[j];
       lttv_attribute_recursive_free(tfcs->stats);
       tfcs->current_events_tree = NULL;
       tfcs->current_event_types_tree = NULL;
@@ -203,7 +191,7 @@ lttv_traceset_stats_get_type(void)
       (GClassInitFunc) traceset_stats_class_init,   /* class_init */
       NULL,   /* class_finalize */
       NULL,   /* class_data */
-      sizeof (LttvTracesetContext),
+      sizeof (LttvTracesetStats),
       0,      /* n_preallocs */
       (GInstanceInitFunc) traceset_stats_instance_init    /* instance_init */
     };
@@ -631,7 +619,7 @@ lttv_stats_add_event_hooks(LttvTracesetStats *self)
 {
   LttvTraceset *traceset = self->parent.parent.ts;
 
-  guint i, j, k, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+  guint i, j, k, nb_trace, nb_tracefile;
 
   LttFacility *f;
 
@@ -720,18 +708,11 @@ lttv_stats_add_event_hooks(LttvTracesetStats *self)
 
     /* Add these hooks to each before_event_by_id hooks list */
 
-    nb_control = ltt_trace_control_tracefile_number(ts->parent.parent.t);
-    nb_per_cpu = ltt_trace_per_cpu_tracefile_number(ts->parent.parent.t);
-    nb_tracefile = nb_control + nb_per_cpu;
-    for(j = 0 ; j < nb_tracefile ; j++) {
-      if(j < nb_control) {
-        tfs = LTTV_TRACEFILE_STATS(ts->parent.parent.control_tracefiles[j]);
-      }
-      else {
-        tfs = LTTV_TRACEFILE_STATS(ts->parent.parent.per_cpu_tracefiles[
-            j-nb_control]);
-      }
+    nb_tracefile = ltt_trace_control_tracefile_number(ts->parent.parent.t) +
+        ltt_trace_per_cpu_tracefile_number(ts->parent.parent.t);
 
+    for(j = 0 ; j < nb_tracefile ; j++) {
+      tfs = LTTV_TRACEFILE_STATS(ts->parent.parent.tracefiles[j]);
       lttv_hooks_add(tfs->parent.parent.after_event, every_event, NULL);
 
       for(k = 0 ; k < before_hooks->len ; k++) {
@@ -762,7 +743,7 @@ lttv_stats_remove_event_hooks(LttvTracesetStats *self)
 {
   LttvTraceset *traceset = self->parent.parent.ts;
 
-  guint i, j, k, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+  guint i, j, k, nb_trace, nb_tracefile;
 
   LttvTraceStats *ts;
 
@@ -788,18 +769,11 @@ lttv_stats_remove_event_hooks(LttvTracesetStats *self)
 
     /* Add these hooks to each before_event_by_id hooks list */
 
-    nb_control = ltt_trace_control_tracefile_number(ts->parent.parent.t);
-    nb_per_cpu = ltt_trace_per_cpu_tracefile_number(ts->parent.parent.t);
-    nb_tracefile = nb_control + nb_per_cpu;
-    for(j = 0 ; j < nb_tracefile ; j++) {
-      if(j < nb_control) {
-        tfs = LTTV_TRACEFILE_STATS(ts->parent.parent.control_tracefiles[j]);
-      }
-      else {
-        tfs =LTTV_TRACEFILE_STATS(ts->parent.parent.per_cpu_tracefiles[
-            j-nb_control]);
-      }
+    nb_tracefile = ltt_trace_control_tracefile_number(ts->parent.parent.t) +
+        ltt_trace_per_cpu_tracefile_number(ts->parent.parent.t);
 
+    for(j = 0 ; j < nb_tracefile ; j++) {
+      tfs = LTTV_TRACEFILE_STATS(ts->parent.parent.tracefiles[j]);
       lttv_hooks_remove_data(tfs->parent.parent.after_event, every_event, 
           NULL);
 
index 82f83500b545466e46c0a058cd32cbf79a2df8d5..17cc9321c5255f45f969668d3e270801245fc1cc 100644 (file)
@@ -1273,7 +1273,7 @@ void add_context_hooks(EventViewerData * event_viewer_data,
            LttvTracesetContext * tsc)
 {
   gint i, j, k, m,n, nbi, id;
-  gint nb_tracefile, nb_control, nb_per_cpu, nb_facility, nb_event;
+  gint nb_tracefile, nb_facility, nb_event;
   LttTrace *trace;
   LttvTraceContext *tc;
   LttvTracefileContext *tfc;
@@ -1299,19 +1299,14 @@ void add_context_hooks(EventViewerData * event_viewer_data,
     trace = tc->t;
     //if there are hooks for trace, add them here
 
-    nb_control = ltt_trace_control_tracefile_number(trace);
-    nb_per_cpu = ltt_trace_per_cpu_tracefile_number(trace);
-    nb_tracefile = nb_control + nb_per_cpu;
+    nb_tracefile = ltt_trace_control_tracefile_number(trace) +
+        ltt_trace_per_cpu_tracefile_number(trace);
     
     for(j = 0 ; j < nb_tracefile ; j++) {
       tf_s = lttv_trace_selector_tracefile_get(t_s,j);
       selected = lttv_tracefile_selector_get_selected(tf_s);
       if(!selected) continue;
-      
-      if(j < nb_control)
-  tfc = tc->control_tracefiles[j];
-      else
-  tfc = tc->per_cpu_tracefiles[j - nb_control];
+      tfc = tc->tracefiles[j];
       
       //if there are hooks for tracefile, add them here
       //      lttv_tracefile_context_add_hooks(tfc, NULL,NULL,NULL,NULL,
@@ -1349,7 +1344,7 @@ void remove_context_hooks(EventViewerData * event_viewer_data,
         LttvTracesetContext * tsc)
 {
   gint i, j, k, m, nbi, n, id;
-  gint nb_tracefile, nb_control, nb_per_cpu, nb_facility, nb_event;
+  gint nb_tracefile, nb_facility, nb_event;
   LttTrace *trace;
   LttvTraceContext *tc;
   LttvTracefileContext *tfc;
@@ -1375,19 +1370,14 @@ void remove_context_hooks(EventViewerData * event_viewer_data,
     trace = tc->t;
     //if there are hooks for trace, remove them here
 
-    nb_control = ltt_trace_control_tracefile_number(trace);
-    nb_per_cpu = ltt_trace_per_cpu_tracefile_number(trace);
-    nb_tracefile = nb_control + nb_per_cpu;
+    nb_tracefile = ltt_trace_control_tracefile_number(trace) +
+        ltt_trace_per_cpu_tracefile_number(trace);
     
     for(j = 0 ; j < nb_tracefile ; j++) {
       tf_s = lttv_trace_selector_tracefile_get(t_s,j);
       selected = lttv_tracefile_selector_get_selected(tf_s);
       if(!selected) continue;
-      
-      if(j < nb_control)
-  tfc = tc->control_tracefiles[j];
-      else
-  tfc = tc->per_cpu_tracefiles[j - nb_control];
+      tfc = tc->tracefiles[j];
       
       //if there are hooks for tracefile, remove them here
       //      lttv_tracefile_context_remove_hooks(tfc, NULL,NULL,NULL,NULL,
index 53391b0af537ddff73251be12388d8857a45cf45..9bd4b8d6f1ded28fbd42554e3f7d51010aca6e70 100644 (file)
 
 #include "../icons/hGuiStatisticInsert.xpm"
 
-#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
-#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
-
-#define PATH_LENGTH        256
+#define PATH_LENGTH        256  /* CHECK */
 
 static LttvModule *statistic_main_win_module;
 static GPtrArray  * statistic_traceset;
@@ -605,7 +602,7 @@ gboolean statistic_traceset_changed(void * hook_data, void * call_data)
 void statistic_add_context_hooks(StatisticViewerData * statistic_viewer_data, 
            LttvTracesetContext * tsc)
 {
-  gint i, j, nbi, nb_tracefile, nb_control, nb_per_cpu;
+  gint i, j, nbi, nb_tracefile;
   LttTrace *trace;
   LttvTraceContext *tc;
   LttvTracefileContext *tfc;
@@ -628,19 +625,14 @@ void statistic_add_context_hooks(StatisticViewerData * statistic_viewer_data,
     trace = tc->t;
     //if there are hooks for trace, add them here
 
-    nb_control = ltt_trace_control_tracefile_number(trace);
-    nb_per_cpu = ltt_trace_per_cpu_tracefile_number(trace);
-    nb_tracefile = nb_control + nb_per_cpu;
+    nb_tracefile = ltt_trace_control_tracefile_number(trace) +
+        ltt_trace_per_cpu_tracefile_number(trace);
     
     for(j = 0 ; j < nb_tracefile ; j++) {
       tf_s = lttv_trace_selector_tracefile_get(t_s,j);
       selected = lttv_tracefile_selector_get_selected(tf_s);
       if(!selected) continue;
-      
-      if(j < nb_control)
-  tfc = tc->control_tracefiles[j];
-      else
-  tfc = tc->per_cpu_tracefiles[j - nb_control];
+      tfc = tc->tracefiles[j];
       
       //if there are hooks for tracefile, add them here
       //      lttv_tracefile_context_add_hooks(tfc, NULL,NULL,NULL,NULL,
@@ -657,7 +649,7 @@ void statistic_add_context_hooks(StatisticViewerData * statistic_viewer_data,
 void statistic_remove_context_hooks(StatisticViewerData * statistic_viewer_data, 
         LttvTracesetContext * tsc)
 {
-  gint i, j, nbi, nb_tracefile, nb_control, nb_per_cpu;
+  gint i, j, nbi, nb_tracefile;
   LttTrace *trace;
   LttvTraceContext *tc;
   LttvTracefileContext *tfc;
@@ -680,19 +672,14 @@ void statistic_remove_context_hooks(StatisticViewerData * statistic_viewer_data,
     trace = tc->t;
     //if there are hooks for trace, remove them here
 
-    nb_control = ltt_trace_control_tracefile_number(trace);
-    nb_per_cpu = ltt_trace_per_cpu_tracefile_number(trace);
-    nb_tracefile = nb_control + nb_per_cpu;
+    nb_tracefile = ltt_trace_control_tracefile_number(trace) +
+        ltt_trace_per_cpu_tracefile_number(trace);
     
     for(j = 0 ; j < nb_tracefile ; j++) {
       tf_s = lttv_trace_selector_tracefile_get(t_s,j);
       selected = lttv_tracefile_selector_get_selected(tf_s);
       if(!selected) continue;
-      
-      if(j < nb_control)
-  tfc = tc->control_tracefiles[j];
-      else
-  tfc = tc->per_cpu_tracefiles[j - nb_control];
+      tfc = tc->tracefiles[j];
       
       //if there are hooks for tracefile, remove them here
       //      lttv_tracefile_context_remove_hooks(tfc, NULL,NULL,NULL,NULL,
index a9fecc1187d3627baae0717324dc6d8fdd8c1fc1..a682e35fc9fddccabce1b4d49d624186046ce283 100644 (file)
@@ -5,9 +5,11 @@ LIBS += $(GLIB_LIBS) -lgobject-2.0 -L$(top_srcdir)/ltt -ltraceread
 
 libdir = ${lttvplugindir}
 
-lib_LTLIBRARIES = libtextDump.la libbatchAnalysis.la
+lib_LTLIBRARIES = libtextDump.la libbatchAnalysis.la libbatchtest.la
 libtextDump_la_LDFLAGS = -module
 libtextDump_la_SOURCES = textDump.c
 libbatchAnalysis_la_LDFLAGS = -module
 libbatchAnalysis_la_SOURCES = batchAnalysis.c
+libbatchtest_la_LDFLAGS = -module
+libbatchtest_la_SOURCES = batchtest.c
 
This page took 0.0411 seconds and 4 git commands to generate.