fix event count in state.c
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 25 Aug 2005 15:09:33 +0000 (15:09 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 25 Aug 2005 15:09:33 +0000 (15:09 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1074 04897980-b3bd-0310-b5e0-8ef037075253

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

index 89b86b9c46b0d064046166337adf5b128327f3f7..0a7d13d5e11b77a5357807681bc57ec3ff4d471e 100644 (file)
@@ -1379,7 +1379,7 @@ static gboolean state_save_event_hook(void *hook_data, void *call_data)
   if(likely((*event_count)++ < LTTV_STATE_SAVE_INTERVAL))
     return FALSE;
   else
-    event_count = 0;
+    *event_count = 0;
   
   LttvTracefileState *self = (LttvTracefileState *)call_data;
 
@@ -1548,10 +1548,9 @@ void lttv_state_save_add_event_hooks(LttvTracesetState *self)
     ts = (LttvTraceState *)self->parent.traces[i];
     nb_tracefile = ts->parent.tracefiles->len;
 
-    guint *event_count = g_new(guint, 1);
-    *event_count = 0;
-
     for(j = 0 ; j < nb_tracefile ; j++) {
+      guint *event_count = g_new(guint, 1);
+      *event_count = 0;
       tfs = 
           LTTV_TRACEFILE_STATE(g_array_index(ts->parent.tracefiles,
                                           LttvTracefileContext*, j));
index c78907909d10bc2846d2d6bd339bcdd50143e983..69b2e14fd19246ee268d4400f3e05cbce9c75f4c 100644 (file)
@@ -56,7 +56,10 @@ struct _LttvTracesetContextPosition {
   GArray *ep;                        /* Array of LttEventPosition */
   GArray *tfc;                       /* Array of corresponding
                                         TracefileContext* */
-  LttTime timestamp;                 /* Current time at the saved position */
+  LttTime timestamp;                 /* Current time at the saved position */ 
+                                     /* If ltt_time_infinite : no position is
+                                      * set, else, a position is set (may be end
+                                      * of trace, with ep->len == 0) */
 };
 
 void lttv_context_init(LttvTracesetContext *self, LttvTraceset *ts)
@@ -178,7 +181,7 @@ init(LttvTracesetContext *self, LttvTraceset *ts)
   self->traces = g_new(LttvTraceContext *, nb_trace);
   self->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
   self->ts_a = lttv_traceset_attribute(ts);
// self->sync_position = lttv_traceset_context_position_new();
+  self->sync_position = lttv_traceset_context_position_new();
   for(i = 0 ; i < nb_trace ; i++) {
     tc = LTTV_TRACESET_CONTEXT_GET_CLASS(self)->new_trace_context(self);
     self->traces[i] = tc;
@@ -250,7 +253,7 @@ void fini(LttvTracesetContext *self)
 
   g_tree_destroy(self->pqueue);
   g_object_unref(self->a);
// lttv_traceset_context_position_destroy(self->sync_position);
+  lttv_traceset_context_position_destroy(self->sync_position);
 
   nb_trace = lttv_traceset_number(ts);
 
@@ -832,21 +835,24 @@ gboolean lttv_process_traceset_seek_position(LttvTracesetContext *self,
                                         const LttvTracesetContextPosition *pos)
 {
   guint i;
-
-  g_tree_destroy(self->pqueue);
-  self->pqueue = g_tree_new(compare_tracefile);
   
-  for(i=0;i<pos->ep->len; i++) {
-    LttEventPosition **ep = &g_array_index(pos->ep, LttEventPosition*, i);
-    LttvTracefileContext **tfc = 
-      &g_array_index(pos->tfc, LttvTracefileContext*, i);
-    if(*ep != NULL) {
-      if(ltt_tracefile_seek_position((*tfc)->tf, *ep) != 0)
-        return 1;
-      (*tfc)->timestamp = ltt_event_time(ltt_tracefile_get_event((*tfc)->tf));
-      g_tree_insert(self->pqueue, (*tfc), (*tfc));
-    } else {
-      (*tfc)->timestamp = ltt_time_infinite;
+  /* 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);
+    
+    for(i=0;i<pos->ep->len; i++) {
+      LttEventPosition **ep = &g_array_index(pos->ep, LttEventPosition*, i);
+      LttvTracefileContext **tfc = 
+        &g_array_index(pos->tfc, LttvTracefileContext*, i);
+      if(*ep != NULL) {
+        if(ltt_tracefile_seek_position((*tfc)->tf, *ep) != 0)
+          return 1;
+        (*tfc)->timestamp = ltt_event_time(ltt_tracefile_get_event((*tfc)->tf));
+        g_tree_insert(self->pqueue, (*tfc), (*tfc));
+      } else {
+        (*tfc)->timestamp = ltt_time_infinite;
+      }
     }
   }
   return 0;
@@ -1195,7 +1201,7 @@ LttvTracefileContext *lttv_traceset_context_get_current_tfc(LttvTracesetContext
 
   return tfc;
 }
-#if 0
+
 /* lttv_process_traceset_synchronize_tracefiles
  *
  * Use the sync_position field of the trace set context to synchronize each
@@ -1216,5 +1222,3 @@ void lttv_process_traceset_get_sync_data(LttvTracesetContext *tsc)
   lttv_traceset_context_position_save(tsc, tsc->sync_position);
 }
 
-#endif //0
-
index 4be8be70aba6388e7544656c3e2ab8c7bdc31d41..429a90162f5545343d884e2991a850d0f504f80c 100644 (file)
@@ -94,8 +94,8 @@ struct _LttvTracesetContext {
   TimeInterval time_span;
   GTree *pqueue;
 
// LttvTracesetContextPosition *sync_position;   /* position at which to sync the
//                                                  trace context */
+  LttvTracesetContextPosition *sync_position;   /* position at which to sync the
+                                                   trace context */
 };
 
 struct _LttvTracesetContextClass {
@@ -331,8 +331,8 @@ gint compare_tracefile(gconstpointer a, gconstpointer b);
 
 /* Synchronisation helpers : save/restore synchronization between ltt traces and
  * a traceset context. */
-//void lttv_process_traceset_synchronize_tracefiles(LttvTracesetContext *tsc);
+void lttv_process_traceset_synchronize_tracefiles(LttvTracesetContext *tsc);
 
-//void lttv_process_traceset_get_sync_data(LttvTracesetContext *tsc);
+void lttv_process_traceset_get_sync_data(LttvTracesetContext *tsc);
 
 #endif // PROCESSTRACE_H
This page took 0.027582 seconds and 4 git commands to generate.