fix stats at end of trace
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 7 Dec 2006 23:53:04 +0000 (23:53 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 7 Dec 2006 23:53:04 +0000 (23:53 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@2299 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/configure.in
ltt/branches/poly/lttv/lttv/batchtest.c
ltt/branches/poly/lttv/lttv/stats.c
ltt/branches/poly/lttv/lttv/stats.h
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c
ltt/branches/poly/lttv/modules/gui/statistics/statistics.c
ltt/branches/poly/lttv/modules/text/textDump.c

index e04a6fd05e82e530340b995414fd42ce34e18f59..55a1d25478ef34d2e504d2804f4a0630d9a81e2c 100644 (file)
@@ -23,7 +23,7 @@
 AC_PREREQ(2.57)
 AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
 #AC_WITH_LTDL  # not needed ?
-AM_INIT_AUTOMAKE(LinuxTraceToolkitViewer,0.8.74-07122006)
+AM_INIT_AUTOMAKE(LinuxTraceToolkitViewer,0.8.75-07122006)
 AM_CONFIG_HEADER(config.h)
 AM_PROG_LIBTOOL
 
index 7b26ac6b1b9c14333ad6e2d6a17f5da1f7acc32b..9b4184bd9cf1b6b628f2d2fe2d0e13213526d536 100644 (file)
@@ -513,7 +513,7 @@ static gboolean process_traceset(void __UNUSED__ *hook_data,
       g_mem_profile();
     }
 
-    lttv_stats_sum_traceset(tscs);
+    lttv_stats_sum_traceset(tscs, ltt_time_infinite);
 
     if(lttv_profile_memory) {
       g_message("Memory summary after summing stats");
index fe12614144d30f3a6db80e38f1d556c596f96876..f3743dc90c34288ae82bd9eb82792461d161e2b7 100644 (file)
@@ -806,22 +806,35 @@ static gboolean every_event(void *hook_data, void *call_data)
   return FALSE;
 }
 
-static void lttv_stats_cleanup_process_state(LttvTraceState *ts,
-  LttvProcessState *process)
-{
+struct cleanup_state_struct {
+  LttvTraceState *ts;
+  LttTime current_time;
+};
+
+//static void lttv_stats_cleanup_process_state(LttvTraceState *ts,
+//  LttvProcessState *process, LttTime current_time)
+static void lttv_stats_cleanup_process_state(gpointer key, gpointer value,
+  gpointer user_data)
+{
+  struct cleanup_state_struct *cleanup_closure =
+    (struct cleanup_state_struct *)user_data;
+  LttvTraceState *ts = cleanup_closure->ts;
   LttvTraceStats *tcs = (LttvTraceStats *)ts;
+  LttvProcessState *process = (LttvProcessState *)value;
   LttvTracesetContext *tsc = ts->parent.ts_context;
+  LttTime current_time = cleanup_closure->current_time;
   int i;
   LttvTracefileStats **tfs = (LttvTracefileStats **)
       &g_array_index(ts->parent.tracefiles, LttvTracefileContext*,
           process->cpu);
   int cleanup_empty = 0;
   LttTime nested_delta = ltt_time_zero;
+
   /* FIXME : ok, this is a hack. The time is infinite here :( */
-  LttTime save_time = (*tfs)->parent.parent.timestamp;
-  LttTime start, end;
-  ltt_trace_time_span_get(ts->parent.t, &start, &end);
-  (*tfs)->parent.parent.timestamp = end;
+  //LttTime save_time = (*tfs)->parent.parent.timestamp;
+  //LttTime start, end;
+  //ltt_trace_time_span_get(ts->parent.t, &start, &end);
+  //(*tfs)->parent.parent.timestamp = end;
 
   do {
     if(ltt_time_compare(process->state->cum_cpu_time, ltt_time_zero) != 0) {
@@ -830,7 +843,9 @@ static void lttv_stats_cleanup_process_state(LttvTraceState *ts,
           process->current_function,
           process->state->t, process->state->n, &((*tfs)->current_events_tree), 
           &((*tfs)->current_event_types_tree));
-      mode_end(*tfs);
+      /* Call mode_end only if not at end of trace */
+      if(ltt_time_compare(current_time, ltt_time_infinite) != 0)
+        mode_end(*tfs);
       nested_delta = process->state->cum_cpu_time;
     }
     cleanup_empty = lttv_state_pop_state_cleanup(process,
@@ -840,25 +855,33 @@ static void lttv_stats_cleanup_process_state(LttvTraceState *ts,
 
   } while(cleanup_empty != 1);
 
-  (*tfs)->parent.parent.timestamp = save_time;
+  //(*tfs)->parent.parent.timestamp = save_time;
 }
 
 /* For each cpu, for each of their stacked states,
  * perform sum of needed values. */
-static void lttv_stats_cleanup_state(LttvTraceStats *tcs)
+static void lttv_stats_cleanup_state(LttvTraceStats *tcs, LttTime current_time)
 {
   LttvTraceState *ts = (LttvTraceState *)tcs;
+  struct cleanup_state_struct cleanup_closure;
+#if 0
   guint nb_cpus, i;
 
   nb_cpus = ltt_trace_get_num_cpu(ts->parent.t);
   
   for(i=0; i<nb_cpus; i++) {
-    lttv_stats_cleanup_process_state(ts, ts->running_process[i]);
+    lttv_stats_cleanup_process_state(ts, ts->running_process[i], current_time);
   }
+#endif //0
+  cleanup_closure.ts = tcs;
+  cleanup_closure.current_time = current_time;
+  g_hash_table_foreach(ts->processes, lttv_stats_cleanup_process_state,
+    &cleanup_closure);
 }
 
 void
-lttv_stats_sum_trace(LttvTraceStats *self, LttvAttribute *ts_stats)
+lttv_stats_sum_trace(LttvTraceStats *self, LttvAttribute *ts_stats,
+  LttTime current_time)
 {
   LttvAttribute *sum_container = self->stats;
 
@@ -897,7 +920,7 @@ lttv_stats_sum_trace(LttvTraceStats *self, LttvAttribute *ts_stats)
   /* First cleanup the state : sum all stalled information (never ending
    * states). */
   if(!trace_is_summed)
-    lttv_stats_cleanup_state(self);
+    lttv_stats_cleanup_state(self, current_time);
   
   processes_tree = lttv_attribute_find_subdir(main_tree, 
                                               LTTV_STATS_PROCESSES);
@@ -987,12 +1010,14 @@ lttv_stats_sum_trace(LttvTraceStats *self, LttvAttribute *ts_stats)
 
 gboolean lttv_stats_sum_traceset_hook(void *hook_data, void *call_data)
 {
-  lttv_stats_sum_traceset((LttvTracesetStats *)call_data);
+  struct sum_traceset_closure *closure =
+    (struct sum_traceset_closure *)call_data;
+  lttv_stats_sum_traceset(closure->tss, closure->current_time);
   return 0;
 }
 
 void
-lttv_stats_sum_traceset(LttvTracesetStats *self)
+lttv_stats_sum_traceset(LttvTracesetStats *self, LttTime current_time)
 {
   LttvTraceset *traceset = self->parent.parent.ts;
   LttvAttribute *sum_container = self->stats;
@@ -1014,7 +1039,7 @@ lttv_stats_sum_traceset(LttvTracesetStats *self)
 
   for(i = 0 ; i < nb_trace ; i++) {
     tcs = (LttvTraceStats *)(self->parent.parent.traces[i]);
-    lttv_stats_sum_trace(tcs, self->stats);
+    lttv_stats_sum_trace(tcs, self->stats, current_time);
   //        lttv_attribute_recursive_add(sum_container, tcs->stats);
   }
 }
index b794b2b51634dd67139ecb673717c8125e1351a2..f2eed92d553b1c821f66da8d8e4636e22b794ed7 100644 (file)
@@ -179,9 +179,10 @@ gboolean lttv_stats_hook_remove_event_hooks(void *hook_data, void *call_data);
 void lttv_stats_remove_event_hooks(LttvTracesetStats *self);
 
 gboolean lttv_stats_sum_traceset_hook(void *hook_data, void *call_data);
-void lttv_stats_sum_traceset(LttvTracesetStats *self);
+void lttv_stats_sum_traceset(LttvTracesetStats *self, LttTime current_time);
 
-void lttv_stats_sum_trace(LttvTraceStats *self, LttvAttribute *ts_stats);
+void lttv_stats_sum_trace(LttvTraceStats *self, LttvAttribute *ts_stats,
+  LttTime current_time);
 
 /* Reset all statistics containers */
 void lttv_stats_reset(LttvTracesetStats *self);
@@ -251,5 +252,10 @@ struct _LttvTracefileStatsClass {
 
 GType lttv_tracefile_stats_get_type (void);
 
+struct sum_traceset_closure {
+  LttvTracesetStats *tss;
+  LttTime current_time;
+};
+
 
 #endif // STATS_H
index 26cf0f3b6f260f14ce881482aed751f9fba4e8d5..87beead611324da1cad41ae51eb60b5320159f80 100644 (file)
@@ -1312,8 +1312,13 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace)
                                                &value);
             g_assert(type == LTTV_POINTER);
             LttvHooks *after_request = (LttvHooks*)*(value.v_pointer);
-
-            if(after_request != NULL) lttv_hooks_call(after_request, tsc);
+            {
+              struct sum_traceset_closure t_closure;
+             t_closure.tss = (LttvTracesetStats*)tsc;
+             t_closure.current_time = ltt_time_infinite;
+              if(after_request != NULL) lttv_hooks_call(after_request,
+               &t_closure);
+            }
             
             if(bg_req->dialog != NULL)
               gtk_widget_destroy(bg_req->dialog);
index 7e781adbca6281d99ccc36cd9f4ef0191827fcb2..c93a7c3cb6f65cc143dae5a61c6edfb7ed335ad2 100644 (file)
@@ -141,7 +141,8 @@ static gint background_ready(void *hook_data, void *call_data)
 
     gtk_tree_store_clear (svd->store_m);
 
-    lttv_stats_sum_traceset(lttvwindow_get_traceset_stats(tab));
+    lttv_stats_sum_traceset(lttvwindow_get_traceset_stats(tab),
+      ltt_time_infinite);
     show_traceset_stats(svd);
   }
 
index 421ff6f3a2ab9be72a277048041775a9f5b974f5..37dcf7d31997b7a873523340597335f9b08b5348 100644 (file)
@@ -278,7 +278,7 @@ static gboolean write_traceset_footer(void *hook_data, void *call_data)
   fprintf(a_file,"End trace set\n\n");
 
   if(LTTV_IS_TRACESET_STATS(tc)) {
-    lttv_stats_sum_traceset((LttvTracesetStats *)tc);
+    lttv_stats_sum_traceset((LttvTracesetStats *)tc, ltt_time_infinite);
     print_stats(a_file, (LttvTracesetStats *)tc);
   }
 
This page took 0.028686 seconds and 4 git commands to generate.