From b91e751bfd4702dd0e73008727b38d9043f609c5 Mon Sep 17 00:00:00 2001 From: compudj Date: Thu, 7 Dec 2006 23:53:04 +0000 Subject: [PATCH] fix stats at end of trace git-svn-id: http://ltt.polymtl.ca/svn@2299 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/configure.in | 2 +- ltt/branches/poly/lttv/lttv/batchtest.c | 2 +- ltt/branches/poly/lttv/lttv/stats.c | 57 +++++++++++++------ ltt/branches/poly/lttv/lttv/stats.h | 10 +++- .../lttvwindow/lttvwindow/lttvwindowtraces.c | 9 ++- .../lttv/modules/gui/statistics/statistics.c | 3 +- .../poly/lttv/modules/text/textDump.c | 2 +- 7 files changed, 61 insertions(+), 24 deletions(-) diff --git a/ltt/branches/poly/configure.in b/ltt/branches/poly/configure.in index e04a6fd0..55a1d254 100644 --- a/ltt/branches/poly/configure.in +++ b/ltt/branches/poly/configure.in @@ -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 diff --git a/ltt/branches/poly/lttv/lttv/batchtest.c b/ltt/branches/poly/lttv/lttv/batchtest.c index 7b26ac6b..9b4184bd 100644 --- a/ltt/branches/poly/lttv/lttv/batchtest.c +++ b/ltt/branches/poly/lttv/lttv/batchtest.c @@ -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"); diff --git a/ltt/branches/poly/lttv/lttv/stats.c b/ltt/branches/poly/lttv/lttv/stats.c index fe126141..f3743dc9 100644 --- a/ltt/branches/poly/lttv/lttv/stats.c +++ b/ltt/branches/poly/lttv/lttv/stats.c @@ -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; irunning_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); } } diff --git a/ltt/branches/poly/lttv/lttv/stats.h b/ltt/branches/poly/lttv/lttv/stats.h index b794b2b5..f2eed92d 100644 --- a/ltt/branches/poly/lttv/lttv/stats.h +++ b/ltt/branches/poly/lttv/lttv/stats.h @@ -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 diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c index 26cf0f3b..87beead6 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c @@ -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); diff --git a/ltt/branches/poly/lttv/modules/gui/statistics/statistics.c b/ltt/branches/poly/lttv/modules/gui/statistics/statistics.c index 7e781adb..c93a7c3c 100644 --- a/ltt/branches/poly/lttv/modules/gui/statistics/statistics.c +++ b/ltt/branches/poly/lttv/modules/gui/statistics/statistics.c @@ -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); } diff --git a/ltt/branches/poly/lttv/modules/text/textDump.c b/ltt/branches/poly/lttv/modules/text/textDump.c index 421ff6f3..37dcf7d3 100644 --- a/ltt/branches/poly/lttv/modules/text/textDump.c +++ b/ltt/branches/poly/lttv/modules/text/textDump.c @@ -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); } -- 2.34.1