Rebuild traceset contexts after performing synchronization
authorBenjamin Poirier <benjamin.poirier@polymtl.ca>
Thu, 17 Dec 2009 16:28:29 +0000 (11:28 -0500)
committerBenjamin Poirier <benjamin.poirier@polymtl.ca>
Fri, 18 Dec 2009 19:04:17 +0000 (14:04 -0500)
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 <benjamin.poirier@polymtl.ca>
lttv/lttv/sync/sync_chain_lttv.c
lttv/lttv/sync/sync_chain_lttv.h
lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c

index 640042d1c61c92e583a9972874d998ab28578357..dc207babfb6bb949c46764c0fb4dce53787c874b 100644 (file)
@@ -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;
 }
 
 
index 0688f96ea75d86f79c9a69f5c3342fb9c2927a8f..43e165004e16ffb0ecd21b8c18c73732f203e97c 100644 (file)
 #ifndef SYNC_CHAIN_LTTV_H
 #define SYNC_CHAIN_LTTV_H
 
+#include <stdbool.h>
+
 #include <lttv/tracecontext.h>
 
-void syncTraceset(LttvTracesetContext* const traceSetContext);
+bool syncTraceset(LttvTracesetContext* const traceSetContext);
 
 #endif
index 6514ef0a5ccd9e9203840e509f815da870f3f391..d58c3137af64f90a95c9f630df9e8b5612aaf787 100644 (file)
@@ -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; i<lttv_traceset_number(traceset); i++)
+    {
+      LttvTrace *trace = lttv_traceset_get(traceset, i);
+      lttv_trace_unref(trace);
+    }
+
+    tsc = LTTV_TRACESET_CONTEXT(tab->traceset_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 */
This page took 0.027159 seconds and 4 git commands to generate.