traceset position save fix
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 26 Aug 2005 15:00:32 +0000 (15:00 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 26 Aug 2005 15:00:32 +0000 (15:00 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1080 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/lttv/batchtest.c
ltt/branches/poly/lttv/lttv/state.c
ltt/branches/poly/lttv/lttv/tracecontext.c

index 5cd22fcc51ec02c27ddaba0bfdaa412e04a5f111..8d4be06ea2b0c07afee533ee265af86bc99a605c 100644 (file)
@@ -76,6 +76,7 @@ static gboolean
   a_test5,
   a_test6,
   a_test7,
+  a_test8,
   a_test_all;
 
 static GQuark QUARK_BLOCK_START,
@@ -618,6 +619,36 @@ static gboolean process_traceset(void __UNUSED__ *hook_data,
     }
   }
 
+  /* Seek at specified interval, using states computed in 6, making
+   * sure that there is no more than the number of events between
+   * state save interval to read before getting there.
+   */
+
+  if((a_test8 && a_test6) || a_test_all) {
+    g_message("Running test 8 : check save interval");
+    LttTime time = tc->time_span.start_time;
+    LttTime interval;
+    interval.tv_sec = 0;
+    interval.tv_nsec = 175674987;
+    guint count;
+
+    while(ltt_time_compare(time, tc->time_span.end_time) < 0) {
+      //g_message("Seeking at time %u.%u", time.tv_sec, time.tv_nsec);
+      lttv_process_traceset_seek_time(&ts->parent, ltt_time_zero);
+      lttv_state_traceset_seek_time_closest(ts, time);
+      /* We add no hook to the traceset, not necessary */
+      count = lttv_process_traceset_middle(&ts->parent,
+          time, G_MAXUINT, NULL);
+      g_info("Number of events to jump over : %u", count);
+      
+      if(count > LTTV_STATE_SAVE_INTERVAL)
+        g_warning("Oops! Save interval is %u and it took %u events to seek to a time %lu.%lu supposed to be closer from the last saved state.",
+            LTTV_STATE_SAVE_INTERVAL, count, time.tv_sec, time.tv_nsec);
+      time = ltt_time_add(time, interval);
+    }
+
+  }
+
   if(a_trace_event) lttv_hooks_remove_data(event_hook, trace_event, NULL);
 
   g_free(save_state.write_time);
@@ -723,6 +754,10 @@ static void init()
   lttv_option_add("test7", '7', "Test seeking to positions written out in 3", 
       "", LTTV_OPT_NONE, &a_test7, NULL, NULL);
 
+  a_test8 = FALSE;
+  lttv_option_add("test8", '8', "Test seeking to positions using saved states computed at 6 : check if number of events fits", 
+      "", LTTV_OPT_NONE, &a_test8, NULL, NULL);
+
   a_test_all = FALSE;
   lttv_option_add("testall", 'a', "Run all tests ", "", 
       LTTV_OPT_NONE, &a_test_all, NULL, NULL);
@@ -797,6 +832,7 @@ static void destroy()
   lttv_option_remove("test5");
   lttv_option_remove("test6");
   lttv_option_remove("test7");
+  lttv_option_remove("test8");
   lttv_option_remove("testall");
 
   lttv_hooks_destroy(before_traceset);
index b333729ca003c9ff5718fbf735bd4443b90210f4..a59ac339bc35affc10385447ba07a11cab89ed39 100644 (file)
@@ -467,7 +467,8 @@ static void state_save(LttvTraceState *self, LttvAttribute *container)
   value = lttv_attribute_add(container, LTTV_STATE_RUNNING_PROCESS, 
                              LTTV_POINTER);
   *(value.v_pointer) = running_process;
-
+  
+  g_info("State save");
   
   nb_tracefile = self->parent.tracefiles->len;
 
@@ -501,7 +502,7 @@ static void state_save(LttvTraceState *self, LttvAttribute *container)
       guint64 tsc;
       LttTracefile *tf;
       ltt_event_position_get(ep, &tf, &nb_block, &offset, &tsc);
-      g_debug("Block %u offset %u tsc %llu time %lu.%lu", nb_block, offset,
+      g_info("Block %u offset %u tsc %llu time %lu.%lu", nb_block, offset,
           tsc,
           tfcs->parent.timestamp.tv_sec, tfcs->parent.timestamp.tv_nsec);
     }
@@ -584,6 +585,7 @@ static void state_restore(LttvTraceState *self, LttvAttribute *container)
       tfc->timestamp = ltt_event_time(ltt_tracefile_get_event(tfc->tf));
       g_assert(ltt_time_compare(tfc->timestamp, ltt_time_infinite) != 0);
       g_tree_insert(tsc->pqueue, tfc, tfc);
+      g_info("Restoring state for a tf at time %lu.%lu", tfc->timestamp.tv_sec, tfc->timestamp.tv_nsec);
     } else {
       tfc->timestamp = ltt_time_infinite;
     }
@@ -623,7 +625,7 @@ static void state_saved_free(LttvTraceState *self, LttvAttribute *container)
 
   /* Free running processes array */
   nb_cpus = ltt_trace_get_num_cpu(self->parent.t);
-  type = lttv_attribute_get_by_name(tracefile_tree, LTTV_STATE_RUNNING_PROCESS, 
+  type = lttv_attribute_get_by_name(container, LTTV_STATE_RUNNING_PROCESS, 
         &value);
   g_assert(type == LTTV_POINTER);
   running_process = *(value.v_pointer);
@@ -1412,6 +1414,7 @@ gint lttv_state_hook_remove_event_hooks(void *hook_data, void *call_data)
   return 0;
 }
 
+static guint test_event_count = 0;
 void lttv_state_remove_event_hooks(LttvTracesetState *self)
 {
   LttvTraceset *traceset = self->parent.ts;
@@ -1461,9 +1464,9 @@ void lttv_state_remove_event_hooks(LttvTracesetState *self)
       lttv_trace_hook_destroy(&g_array_index(hooks, LttvTraceHook, k));
     g_array_free(hooks, TRUE);
   }
+  g_info("EVENT COUNT TEST : %u", test_event_count);
 }
 
-static guint test_event_count = 0;
 static gboolean state_save_event_hook(void *hook_data, void *call_data)
 {
   guint *event_count = (guint*)hook_data;
@@ -1735,7 +1738,6 @@ void lttv_state_save_remove_event_hooks(LttvTracesetState *self)
     }
     g_free(event_count);
   }
-  g_info("EVENT COUNT TEST : %u", test_event_count);
 }
 
 gint lttv_state_save_hook_remove_event_hooks(void *hook_data, void *call_data)
@@ -1755,6 +1757,8 @@ void lttv_state_traceset_seek_time_closest(LttvTracesetState *self, LttTime t)
 
   int min_pos, mid_pos, max_pos;
 
+  guint call_rest = 0;
+
   LttvTraceState *tcs;
 
   LttvAttributeValue value;
@@ -1768,6 +1772,8 @@ void lttv_state_traceset_seek_time_closest(LttvTracesetState *self, LttTime t)
   g_tree_destroy(self->parent.pqueue);
   self->parent.pqueue = g_tree_new(compare_tracefile);
   
+  g_info("Entering seek_time_closest for time %lu.%lu", t.tv_sec, t.tv_nsec);
+  
   nb_trace = lttv_traceset_number(traceset);
   for(i = 0 ; i < nb_trace ; i++) {
     tcs = (LttvTraceState *)self->parent.traces[i];
@@ -1800,6 +1806,7 @@ void lttv_state_traceset_seek_time_closest(LttvTracesetState *self, LttTime t)
       /* restore the closest earlier saved state */
       if(min_pos != -1) {
         lttv_state_restore(tcs, closest_tree);
+        call_rest = 1;
       }
 
       /* There is no saved state, yet we want to have it. Restart at T0 */
@@ -1814,6 +1821,7 @@ void lttv_state_traceset_seek_time_closest(LttvTracesetState *self, LttTime t)
       lttv_process_trace_seek_time(&(tcs->parent), t);
     }
   }
+  if(!call_rest) g_info("NOT Calling restore");
 }
 
 
index be0f8d9dc28b2310321d48e0e32f68931ca97df5..58310b4090f8453558dfd2a1f522e4d0e4856b95 100644 (file)
@@ -1076,7 +1076,10 @@ void lttv_traceset_context_position_save(const LttvTracesetContext *self,
 {
   guint i;
   guint num_traces = lttv_traceset_number(self->ts);
-
+  
+  pos->tfc = g_array_set_size(pos->tfc, 0);
+  pos->ep = g_array_set_size(pos->ep, 0);
+  
   for(i=0; i<num_traces;i++) {
     GArray * tracefiles = self->traces[i]->tracefiles;
     guint j;
@@ -1125,8 +1128,8 @@ void lttv_traceset_context_position_copy(LttvTracesetContextPosition *dest,
   int i;
   LttEventPosition **src_ep, **dest_ep;
   
-  g_array_set_size(dest->ep, src->ep->len);
-  g_array_set_size(dest->tfc, src->tfc->len);
+  dest->ep = g_array_set_size(dest->ep, src->ep->len);
+  dest->tfc = g_array_set_size(dest->tfc, src->tfc->len);
   
   for(i=0;i<src->ep->len;i++) {
     src_ep = &g_array_index(src->ep, LttEventPosition*, i);
This page took 0.032988 seconds and 4 git commands to generate.