From d448fce24840c50fbd998d06a7daa595859df2ff Mon Sep 17 00:00:00 2001 From: compudj Date: Wed, 31 Aug 2005 20:55:20 +0000 Subject: [PATCH] fix seek so that adding and removing a trace from a traceset will work git-svn-id: http://ltt.polymtl.ca/svn@1100 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/lttv/lttv/batchtest.c | 4 +++ ltt/branches/poly/lttv/lttv/state.c | 9 +++--- ltt/branches/poly/lttv/lttv/tracecontext.c | 33 ++++++++++++++++------ 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/ltt/branches/poly/lttv/lttv/batchtest.c b/ltt/branches/poly/lttv/lttv/batchtest.c index bb19955e..1a48d6a1 100644 --- a/ltt/branches/poly/lttv/lttv/batchtest.c +++ b/ltt/branches/poly/lttv/lttv/batchtest.c @@ -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)) { diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index 5c1452cb..dee43252 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -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); diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.c b/ltt/branches/poly/lttv/lttv/tracecontext.c index 7d560557..cb7d4185 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.c +++ b/ltt/branches/poly/lttv/lttv/tracecontext.c @@ -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; itraces[i]->tracefiles; + guint j; + guint num_tracefiles = tracefiles->len; + for(j=0;jtfcp->len); + + + //g_tree_destroy(self->pqueue); + //self->pqueue = g_tree_new(compare_tracefile); for(i=0;itfcp->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) -- 2.34.1