Manage state correctly with multiple open trace
authorYannick Brosseau <yannick.brosseau@gmail.com>
Thu, 7 Jun 2012 20:15:17 +0000 (16:15 -0400)
committerYannick Brosseau <yannick.brosseau@gmail.com>
Mon, 11 Jun 2012 21:34:34 +0000 (17:34 -0400)
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 <yannick.brosseau@gmail.com>
lttv/lttv/traceset-process.c
lttv/lttv/traceset.c
lttv/lttv/traceset.h

index ee23cbcbac03dcc93f03fbcd09850a1291aff033..5ea9d0a5d9aae0588414c976d9726118706deae2 100644 (file)
@@ -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);
 
index 35c84395af6678aa54356876ec5c3aef9097ffb9..bfab0368db84547e0a01718165d56926cb20bae3 100644 (file)
@@ -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;i<s_orig->traces->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);
index 63b1df97522d3d1a5ec5747ec4b2f8e4f03e2260..b58ca27cc317f010f681ad34d8e42249c3ff10ef 100644 (file)
@@ -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 {
This page took 0.026203 seconds and 4 git commands to generate.