From: Yannick Brosseau Date: Thu, 7 Jun 2012 20:15:17 +0000 (-0400) Subject: Manage state correctly with multiple open trace X-Git-Tag: v1.5-beta1~72 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=115c78c2bc85677f47b98a60a0df44bea1b95dc2;p=lttv.git Manage state correctly with multiple open trace We can now open a traceset with multiple trace (like a kernel and ust trace made together) Create an index to map the trace_handle to the right state object (we have one state object for each trace) Signed-off-by: Yannick Brosseau --- diff --git a/lttv/lttv/traceset-process.c b/lttv/lttv/traceset-process.c index ee23cbcb..5ea9d0a5 100644 --- a/lttv/lttv/traceset-process.c +++ b/lttv/lttv/traceset-process.c @@ -76,9 +76,10 @@ guint lttv_process_traceset_middle(LttvTraceset *traceset, count++; event.bt_event = bt_event; - /* TODO ybrosseau 2012-04-01: use bt_ctf_get_trace_handle - to retrieve the right state container */ - event.state = traceset->tmpState; + + /* Retreive the associated state */ + event.state = g_ptr_array_index(traceset->state_trace_handle_index, + bt_ctf_event_get_handle_id(bt_event)); lttv_hooks_call(traceset->event_hooks, &event); diff --git a/lttv/lttv/traceset.c b/lttv/lttv/traceset.c index 35c84395..bfab0368 100644 --- a/lttv/lttv/traceset.c +++ b/lttv/lttv/traceset.c @@ -60,7 +60,7 @@ LttvTraceset *lttv_traceset_new(void) // NULL); s->iter = 0; s->event_hooks = lttv_hooks_new(); - + s->state_trace_handle_index = g_ptr_array_new(); @@ -118,7 +118,11 @@ static LttvTrace *lttv_trace_create(LttvTraceset *ts, const char *path) new_trace->traceset = ts; new_trace->state = g_new(LttvTraceState,1); lttv_trace_state_init(new_trace->state,new_trace); - ts->tmpState = new_trace->state; + + /* Add the state to the trace_handle to state index */ + g_ptr_array_set_size(ts->state_trace_handle_index,id+1); + g_ptr_array_index(ts->state_trace_handle_index,id) = new_trace->state; + return new_trace; } @@ -150,6 +154,7 @@ LttvTraceset *lttv_traceset_copy(LttvTraceset *s_orig) s = g_new(LttvTraceset, 1); s->filename = NULL; s->traces = g_ptr_array_new(); + s->state_trace_handle_index = g_ptr_array_new(); for(i=0;itraces->len;i++) { trace = g_ptr_array_index(s_orig->traces, i); @@ -157,6 +162,10 @@ LttvTraceset *lttv_traceset_copy(LttvTraceset *s_orig) /* WARNING: this is an alias, not a copy. */ g_ptr_array_add(s->traces, trace); + + g_ptr_array_set_size(s->state_trace_handle_index,trace->id+1); + g_ptr_array_index(s->state_trace_handle_index,trace->id) = trace->state; + } s->context = s_orig->context; bt_context_get(s->context); diff --git a/lttv/lttv/traceset.h b/lttv/lttv/traceset.h index 63b1df97..b58ca27c 100644 --- a/lttv/lttv/traceset.h +++ b/lttv/lttv/traceset.h @@ -41,8 +41,7 @@ struct _LttvTraceset { LttvAttribute *a; LttvHooks *event_hooks; struct bt_ctf_iter *iter; - LttvTraceState *tmpState; - + GPtrArray *state_trace_handle_index; }; struct _LttvTrace {