fix seek so that adding and removing a trace from a traceset will work
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 31 Aug 2005 20:55:20 +0000 (20:55 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 31 Aug 2005 20:55:20 +0000 (20:55 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1100 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 bb19955e860de884a0b42f20d6aa234314c432f9..1a48d6a150d7819bfecc3481c58fff2c73435908 100644 (file)
@@ -740,9 +740,13 @@ static gboolean process_traceset(void __UNUSED__ *hook_data,
     lttv_process_traceset_seek_time(tsc, ltt_time_zero);
     count = lttv_process_traceset_seek_n_forward(tsc, 200000, NULL);
     lttv_traceset_context_position_save(tsc, saved_pos);
+    t0 = get_time();
     lttv_process_traceset_seek_n_backward(tsc, 100301,
         seek_back_default_offset,
         (seek_time_fct)lttv_state_traceset_seek_time_closest, NULL);
+    t1 = get_time();
+    g_message("Seek backward 100301 events (with seek closest) in %g seconds",
+                t1 - t0);
     count = lttv_process_traceset_seek_n_forward(tsc, 100301, NULL);
     
     if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos)) {
index 5c1452cb30f95e828cc87b55f05fabc77f875795..dee43252eaf4ddd1eb6c3eb838cb07e71c7c9d58 100644 (file)
@@ -561,8 +561,8 @@ static void state_restore(LttvTraceState *self, LttvAttribute *container)
  
   nb_tracefile = self->parent.tracefiles->len;
 
-  g_tree_destroy(tsc->pqueue);
-  tsc->pqueue = g_tree_new(compare_tracefile);
+  //g_tree_destroy(tsc->pqueue);
+  //tsc->pqueue = g_tree_new(compare_tracefile);
  
   for(i = 0 ; i < nb_tracefile ; i++) {
     tfcs = 
@@ -586,6 +586,7 @@ static void state_restore(LttvTraceState *self, LttvAttribute *container)
     g_assert(tfcs->parent.t_context != NULL);
     
     LttvTracefileContext *tfc = LTTV_TRACEFILE_CONTEXT(tfcs);
+    g_tree_remove(tsc->pqueue, tfc);
     
     if(ep != NULL) {
       g_assert(ltt_tracefile_seek_position(tfc->tf, ep) == 0);
@@ -1879,8 +1880,8 @@ void lttv_state_traceset_seek_time_closest(LttvTracesetState *self, LttTime t)
 
   LttvAttribute *saved_states_tree, *saved_state_tree, *closest_tree;
 
-  g_tree_destroy(self->parent.pqueue);
-  self->parent.pqueue = g_tree_new(compare_tracefile);
+  //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);
   
index 7d560557654a2a239ff5fbbbad4a643d93c3f990..cb7d41857097f76030ae4b85b72d64396d8145f7 100644 (file)
@@ -835,7 +835,7 @@ void lttv_process_trace_seek_time(LttvTraceContext *self, LttTime start)
   for(i = 0 ; i < nb_tracefile ; i++) {
     tfc = &g_array_index(self->tracefiles, LttvTracefileContext*, i);
 
-    //g_tree_remove(pqueue, *tfc);
+    g_tree_remove(pqueue, *tfc);
     
     ret = ltt_tracefile_seek_time((*tfc)->tf, start);
     if(ret == EPERM) g_error("error in lttv_process_trace_seek_time seek");
@@ -866,8 +866,8 @@ void lttv_process_traceset_seek_time(LttvTracesetContext *self, LttTime start)
 
   LttvTraceContext *tc;
 
-  g_tree_destroy(self->pqueue);
-  self->pqueue = g_tree_new(compare_tracefile);
+  //g_tree_destroy(self->pqueue);
+  //self->pqueue = g_tree_new(compare_tracefile);
 
   nb_trace = lttv_traceset_number(self->ts);
   for(i = 0 ; i < nb_trace ; i++) {
@@ -881,16 +881,33 @@ gboolean lttv_process_traceset_seek_position(LttvTracesetContext *self,
                                         const LttvTracesetContextPosition *pos)
 {
   guint i;
-  
-  /* If a position is set, seek the traceset to this position */
+   /* If a position is set, seek the traceset to this position */
   if(ltt_time_compare(pos->timestamp, ltt_time_infinite) != 0) {
-    g_tree_destroy(self->pqueue);
-    self->pqueue = g_tree_new(compare_tracefile);
+
+    /* Test to see if the traces has been added to the trace set :
+     * It should NEVER happen. Clear all positions if a new trace comes in. */
+    /* FIXME I know this test is not optimal : should keep a number of
+     * tracefiles variable in the traceset.. eventually */
+    guint num_traces = lttv_traceset_number(self->ts);
+    guint tf_count = 0;
+    for(i=0; i<num_traces;i++) {
+      GArray * tracefiles = self->traces[i]->tracefiles;
+      guint j;
+      guint num_tracefiles = tracefiles->len;
+      for(j=0;j<num_tracefiles;j++)
+        tf_count++;
+    }
+    g_assert(tf_count == pos->tfcp->len);
+     
+
+    //g_tree_destroy(self->pqueue);
+    //self->pqueue = g_tree_new(compare_tracefile);
     
     for(i=0;i<pos->tfcp->len; i++) {
       LttvTracefileContextPosition *tfcp = 
         &g_array_index(pos->tfcp, LttvTracefileContextPosition, i);
-      
+
+      g_tree_remove(self->pqueue, tfcp->tfc);
       
       if(tfcp->used == TRUE) {
         if(ltt_tracefile_seek_position(tfcp->tfc->tf, tfcp->event) != 0)
This page took 0.029998 seconds and 4 git commands to generate.