From 482fe4814d81bd6109f8ddcada7784b288bfabda Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Thu, 17 Dec 2009 11:28:29 -0500 Subject: [PATCH] Rebuild traceset contexts after performing synchronization This fixes an integration bug with the state system that caused the control flow view display to become corrupted when zooming in closely to synchronized traces. It also caused many messages like WARNING **: Cannot find pin_in in schedchange 5 to be displayed. Signed-off-by: Benjamin Poirier --- lttv/lttv/sync/sync_chain_lttv.c | 9 ++- lttv/lttv/sync/sync_chain_lttv.h | 4 +- .../gui/lttvwindow/lttvwindow/callbacks.c | 63 +++++++++++++++++-- 3 files changed, 68 insertions(+), 8 deletions(-) diff --git a/lttv/lttv/sync/sync_chain_lttv.c b/lttv/lttv/sync/sync_chain_lttv.c index 640042d1..dc207bab 100644 --- a/lttv/lttv/sync/sync_chain_lttv.c +++ b/lttv/lttv/sync/sync_chain_lttv.c @@ -147,8 +147,11 @@ static void destroy() * * Args: * traceSetContext: traceset + * + * Returns: + * false if synchronization was not performed, true otherwise */ -void syncTraceset(LttvTracesetContext* const traceSetContext) +bool syncTraceset(LttvTracesetContext* const traceSetContext) { SyncState* syncState; struct timeval startTime, endTime; @@ -160,7 +163,7 @@ void syncTraceset(LttvTracesetContext* const traceSetContext) if (!optionSync.present) { g_debug("Not synchronizing traceset because option is disabled"); - return; + return false; } if (optionSyncStats.present) @@ -299,6 +302,8 @@ void syncTraceset(LttvTracesetContext* const traceSetContext) printf("\tsystem time: %ld.%06ld\n", endUsage.ru_stime.tv_sec, endUsage.ru_stime.tv_usec); } + + return true; } diff --git a/lttv/lttv/sync/sync_chain_lttv.h b/lttv/lttv/sync/sync_chain_lttv.h index 0688f96e..43e16500 100644 --- a/lttv/lttv/sync/sync_chain_lttv.h +++ b/lttv/lttv/sync/sync_chain_lttv.h @@ -19,8 +19,10 @@ #ifndef SYNC_CHAIN_LTTV_H #define SYNC_CHAIN_LTTV_H +#include + #include -void syncTraceset(LttvTracesetContext* const traceSetContext); +bool syncTraceset(LttvTracesetContext* const traceSetContext); #endif diff --git a/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c b/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c index 6514ef0a..d58c3137 100644 --- a/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -466,13 +466,66 @@ void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor) int SetTraceset(Tab * tab, LttvTraceset *traceset) { + guint i; + TimeInterval time_span; + TimeWindow new_time_window; + LttTime new_current_time; LttvTracesetContext *tsc = - LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); + LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); - syncTraceset(tsc); - TimeInterval time_span = tsc->time_span; - TimeWindow new_time_window = tab->time_window; - LttTime new_current_time = tab->current_time; + // Perform time synchronization on the traces + if (syncTraceset(tsc)) + { + /* There is some time-dependant information that was calculated during + * context initialization. Destroy the old contexts and initialize new + * ones. + * Modified from lttvwindow_add_trace() + */ + // Keep a reference to the traces so they are not freed + for(i = 0; i < lttv_traceset_number(traceset); i++) + { + LttvTrace *trace = lttv_traceset_get(traceset, i); + lttv_trace_ref(trace); + } + + // Remove state update hooks + lttv_state_remove_event_hooks( + (LttvTracesetState*)tab->traceset_info->traceset_context); + + lttv_context_fini(LTTV_TRACESET_CONTEXT( + tab->traceset_info->traceset_context)); + g_object_unref(tab->traceset_info->traceset_context); + + for(i = 0; i < lttv_traceset_number(traceset); i++) + { + LttvTrace *trace = lttv_traceset_get(traceset, i); + lttvwindowtraces_remove_trace(trace); + lttvwindowtraces_add_trace(trace); + } + + // Create new context + tab->traceset_info->traceset_context = + g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); + lttv_context_init(LTTV_TRACESET_CONTEXT(tab->traceset_info-> + traceset_context), traceset); + + // Add state update hooks + lttv_state_add_event_hooks( + (LttvTracesetState*)tab->traceset_info->traceset_context); + + // Remove local reference to the traces + for(i=0; itraceset_info->traceset_context); + } + + time_span = tsc->time_span; + new_time_window = tab->time_window; + new_current_time = tab->current_time; /* Set the tab's time window and current time if * out of bounds */ -- 2.34.1