From: compudj Date: Thu, 25 Aug 2005 15:09:33 +0000 (+0000) Subject: fix event count in state.c X-Git-Tag: v0.12.20~2415 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=18c87975cf8d433804fd1ba833e1024790c5b4b8;p=lttv.git fix event count in state.c git-svn-id: http://ltt.polymtl.ca/svn@1074 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index 89b86b9c..0a7d13d5 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -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)); diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.c b/ltt/branches/poly/lttv/lttv/tracecontext.c index c7890790..69b2e14f 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.c +++ b/ltt/branches/poly/lttv/lttv/tracecontext.c @@ -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;iep->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;iep->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 - diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.h b/ltt/branches/poly/lttv/lttv/tracecontext.h index 4be8be70..429a9016 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.h +++ b/ltt/branches/poly/lttv/lttv/tracecontext.h @@ -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