Add before and after hook to the control flow computing
[lttv.git] / lttv / modules / gui / controlflow / eventhooks.c
index 540ac9ae3d706813926ec8eb92cdaf37d72b2912..854f1db61f71eba770466fc95653c997e71af0f9 100644 (file)
@@ -92,7 +92,6 @@ extern GSList *g_legend_list;
 static gint background_ready(void *hook_data, void *call_data)
 {
   ControlFlowData *control_flow_data = (ControlFlowData *)hook_data;
-  LttvTrace *trace = (LttvTrace*)call_data;
 
   control_flow_data->background_info_waiting--;
   
@@ -114,27 +113,27 @@ static gint background_ready(void *hook_data, void *call_data)
 /* Request background computation. Verify if it is in progress or ready first.
  * Only for each trace in the tab's traceset.
  */
+
 static void request_background_data(ControlFlowData *control_flow_data)
 {
-  LttvTracesetContext * tsc =
-        lttvwindow_get_traceset_context(control_flow_data->tab);
-  gint num_traces = lttv_traceset_number(tsc->ts);
+
+  LttvTraceset *ts = lttvwindow_get_traceset(control_flow_data->tab);
+  gint num_traces = lttv_traceset_number(ts);
   gint i;
   LttvTrace *trace;
   LttvTraceState *tstate;
 
-  LttvHooks *background_ready_hook = 
-    lttv_hooks_new();
+  LttvHooks *background_ready_hook = lttv_hooks_new();
   lttv_hooks_add(background_ready_hook, background_ready, control_flow_data,
       LTTV_PRIO_DEFAULT);
   control_flow_data->background_info_waiting = 0;
   
   for(i=0;i<num_traces;i++) {
-    trace = lttv_traceset_get(tsc->ts, i);
-    tstate = LTTV_TRACE_STATE(tsc->traces[i]);
+    trace = lttv_traceset_get(ts, i);
+    tstate = trace->state;
 
     if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE
-        && !tstate->has_precomputed_states) {
+        && !ts->has_precomputed_states) {
 
       if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
                                           trace) == FALSE) {
@@ -219,7 +218,6 @@ h_guicontrolflow(LttvPlugin *plugin)
 
 int event_selected_hook(void *hook_data, void *call_data)
 {
-  ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
   guint *event_number = (guint*) call_data;
 
   g_debug("DEBUG : event selected by main window : %u", *event_number);
@@ -247,6 +245,12 @@ static inline PropertiesLine prepare_s_e_line(LttvProcessState *process)
       prop_line.color = drawing_colors[COL_RUN_IRQ];
     else if(process->state->t == LTTV_STATE_SOFT_IRQ)
       prop_line.color = drawing_colors[COL_RUN_SOFT_IRQ];
+    else if(process->state->t == LTTV_STATE_MAYBE_SYSCALL)
+      prop_line.color = drawing_colors[COL_MODE_UNKNOWN];
+    else if(process->state->t == LTTV_STATE_MAYBE_USER_MODE)
+      prop_line.color = drawing_colors[COL_MODE_UNKNOWN];
+    else if(process->state->t == LTTV_STATE_MAYBE_TRAP)
+      prop_line.color = drawing_colors[COL_MODE_UNKNOWN];
     else if(process->state->t == LTTV_STATE_MODE_UNKNOWN)
       prop_line.color = drawing_colors[COL_MODE_UNKNOWN];
     else
@@ -283,40 +287,43 @@ static inline PropertiesLine prepare_s_e_line(LttvProcessState *process)
 
 int before_trywakeup_hook(void *hook_data, void *call_data)
 {
-  LttvTraceHook *th = (LttvTraceHook*)hook_data;
-  EventsRequest *events_request = (EventsRequest*)th->hook_data;
-  ControlFlowData *control_flow_data = events_request->viewer_data;
+  
+  LttvEvent *event;
 
-  LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
+  event = (LttvEvent *) call_data;
+  if (strcmp(lttv_traceset_get_name_from_event(event),"sched_wakeup") != 0)
+        return FALSE; 
 
-  LttvTracefileState *tfs = (LttvTracefileState *)call_data;
-  LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
+  ControlFlowData *control_flow_data = (ControlFlowData*)hook_data;
+
+  LttvTraceState *ts =  event->state;;
 
-  LttEvent *e = ltt_tracefile_get_event(tfc->tf);
-  gint target_pid_saved = tfc->target_pid;
 
-  LttTime evtime = ltt_event_time(e);
+  LttTime evtime = lttv_event_get_timestamp(event);
+#ifdef BABEL_CLEANUP
   LttvFilter *filter = control_flow_data->filter;
+#endif
 
   guint woken_pid;
   gint woken_cpu;
 
-  woken_pid = ltt_event_get_int(e, lttv_trace_get_hook_field(th, 0));
-  woken_cpu = ltt_event_get_unsigned(e, lttv_trace_get_hook_field(th, 1));
-  
-  tfc->target_pid = woken_pid;
+  woken_pid = lttv_event_get_long(event, "tid");
+  woken_cpu = lttv_event_get_long(event, "target_cpu");
+
+#ifdef BABEL_CLEANUP  
   if(!filter || !filter->head ||
     lttv_filter_tree_parse(filter->head,e,tfc->tf,
           tfc->t_context->t,tfc,NULL,NULL)) { 
-
+#else
+    {
+#endif
     /* First, check if the woken process is in the state computation
      * process list. If it is there, that means we must add it right now and
      * draw items from the beginning of the read for it. If it is not
      * present, it's a new process and it was not present : it will
      * be added after the state update. TOCHECK: What does that last para mean? */
-    guint cpu = tfs->cpu;
-    guint trace_num = ts->parent.index;
-    LttvProcessState *process = lttv_state_find_process(ts, woken_cpu, woken_pid);
+      guint trace_num = 0; /*TODO ybrosseau 2012-08-23: use right number */
+      LttvProcessState *process = lttv_state_find_process(ts, woken_cpu, woken_pid);
     
     if(process != NULL) {
       /* Well, the woken process existed : we must get it in the process hash
@@ -465,7 +472,8 @@ int before_trywakeup_hook(void *hook_data, void *call_data)
     }
   }
 
-  tfc->target_pid = target_pid_saved;
+
+
 
   return 0;
 
@@ -491,54 +499,46 @@ int before_trywakeup_hook(void *hook_data, void *call_data)
 
 int before_schedchange_hook(void *hook_data, void *call_data)
 {
-  LttvTraceHook *th = (LttvTraceHook*)hook_data;
-  EventsRequest *events_request = (EventsRequest*)th->hook_data;
-  ControlFlowData *control_flow_data = events_request->viewer_data;
-
-  LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
-
-  LttvTracefileState *tfs = (LttvTracefileState *)call_data;
-  LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
-
-  LttEvent *e;
-  e = ltt_tracefile_get_event(tfc->tf);
-  gint target_pid_saved = tfc->target_pid;
+  LttvEvent *event;
+  guint cpu;
+  LttvTraceState *ts;
+  LttvProcessState *process;
+
+  //LttvProcessState *old_process = ts->running_process[cpu];
+
+  guint pid_in, pid_out;
+  gint64 state_out;
+  LttTime timestamp;
+  event = (LttvEvent *) call_data;
+  if (strcmp(lttv_traceset_get_name_from_event(event),"sched_switch") != 0)
+        return FALSE;
+  
+  ControlFlowData *control_flow_data = (ControlFlowData*)hook_data;
 
-  LttTime evtime = ltt_event_time(e);
-  LttvFilter *filter = control_flow_data->filter;
 
   /* we are in a schedchange, before the state update. We must draw the
    * items corresponding to the state before it changes : now is the right
    * time to do it.
    */
-
-  guint pid_out;
-  guint pid_in;
-  guint state_out;
-  {
-    pid_out = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0));
-    pid_in = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1));
-    state_out = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 2));
-  }
+  cpu = lttv_traceset_get_cpuid_from_event(event);
+  ts = event->state;      
   
-  tfc->target_pid = pid_out;
-  if(!filter || !filter->head ||
-    lttv_filter_tree_parse(filter->head,e,tfc->tf,
-          tfc->t_context->t,tfc,NULL,NULL)) { 
+  pid_out = lttv_event_get_long(event, "prev_tid");
+  pid_in = lttv_event_get_long(event, "next_tid");
+  state_out = lttv_event_get_long(event, "prev_state");
+  guint trace_number = 0;//TODO fdeslauriers 2012-07-17: // Use trace handle to know trace number
+
+  process = lttv_state_find_process(ts,cpu,pid_out);
+  timestamp = lttv_event_get_timestamp(event);
     /* For the pid_out */
     /* First, check if the current process is in the state computation
      * process list. If it is there, that means we must add it right now and
      * draw items from the beginning of the read for it. If it is not
      * present, it's a new process and it was not present : it will
      * be added after the state update.  */
-    guint cpu = tfs->cpu;
-    guint trace_num = ts->parent.index;
-    LttvProcessState *process = ts->running_process[cpu];
-    /* unknown state, bad current pid */
-    if(process->pid != pid_out)
-      process = lttv_state_find_process(ts,
-          tfs->cpu, pid_out);
     
+    /* unknown state, bad current pid */
+   
     if(process != NULL) {
       /* Well, the process_out existed : we must get it in the process hash
        * or add it, and draw its items.
@@ -553,7 +553,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
               pid_out,
               process->cpu,
               &birth,
-              trace_num);
+              trace_number);
       if(hashed_process_data == NULL)
       {
         g_assert(pid_out == 0 || pid_out != process->ppid);
@@ -567,7 +567,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
             process->cpu,
             process->ppid,
             &birth,
-            trace_num,
+            trace_number,
             process->name,
             process->brand,
             &pl_height,
@@ -579,13 +579,12 @@ int before_schedchange_hook(void *hook_data, void *call_data)
         gtk_widget_queue_draw(drawing->drawing_area);
 
       }
-  
       /* Now, the process is in the state hash and our own process hash.
        * We definitely can draw the items related to the ending state.
        */
       
       if(ltt_time_compare(hashed_process_data->next_good_time,
-                          evtime) > 0)
+                          timestamp) > 0)
       {
         if(hashed_process_data->x.middle_marked == FALSE) {
     
@@ -601,7 +600,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
           guint x;
           convert_time_to_pixels(
                     time_window,
-                    evtime,
+                    timestamp,
                     width,
                     &x);
 
@@ -626,7 +625,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
         guint x;
         convert_time_to_pixels(
                   time_window,
-                  evtime,
+                  timestamp,
                   width,
                   &x);
 
@@ -684,22 +683,14 @@ int before_schedchange_hook(void *hook_data, void *call_data)
         }
       }
     }
-  }
 
-  tfc->target_pid = pid_in;
-  if(!filter || !filter->head ||
-    lttv_filter_tree_parse(filter->head,e,tfc->tf,
-          tfc->t_context->t,tfc,NULL,NULL)) { 
     /* For the pid_in */
     /* First, check if the current process is in the state computation
      * process list. If it is there, that means we must add it right now and
      * draw items from the beginning of the read for it. If it is not
      * present, it's a new process and it was not present : it will
      * be added after the state update.  */
-    LttvProcessState *process;
-    process = lttv_state_find_process(ts,
-        tfs->cpu, pid_in);
-    guint trace_num = ts->parent.index;
+        process = lttv_state_find_process(ts,cpu,pid_in);
     
     if(process != NULL) {
       /* Well, the process existed : we must get it in the process hash
@@ -713,9 +704,9 @@ int before_schedchange_hook(void *hook_data, void *call_data)
       
       hashed_process_data = processlist_get_process_data(process_list,
               pid_in,
-              tfs->cpu,
+              cpu,
               &birth,
-              trace_num);
+              trace_number);//TODO "use the right value or delete"
       if(hashed_process_data == NULL)
       {
         g_assert(pid_in == 0 || pid_in != process->ppid);
@@ -726,10 +717,10 @@ int before_schedchange_hook(void *hook_data, void *call_data)
             drawing,
             pid_in,
             process->tgid,
-            tfs->cpu,
+            cpu,
             process->ppid,
             &birth,
-            trace_num,
+            trace_number,
             process->name,
             process->brand,
             &pl_height,
@@ -749,7 +740,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
        */
       
       if(ltt_time_compare(hashed_process_data->next_good_time,
-                          evtime) > 0)
+                          timestamp) > 0)
       {
         if(hashed_process_data->x.middle_marked == FALSE) {
 
@@ -765,7 +756,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
           guint x;
           convert_time_to_pixels(
                     time_window,
-                    evtime,
+                    timestamp,
                     width,
                     &x);
 
@@ -791,7 +782,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
 
         convert_time_to_pixels(
                   time_window,
-                  evtime,
+                  timestamp,
                   width,
                   &x);
 
@@ -851,8 +842,9 @@ int before_schedchange_hook(void *hook_data, void *call_data)
       }
     } else
       g_warning("Cannot find pin_in in schedchange %u", pid_in);
-  }
+#ifdef BABEL_CLEANUP
   tfc->target_pid = target_pid_saved;
+#endif //babel_cleanup
   return 0;
 
 
@@ -892,21 +884,22 @@ int before_schedchange_hook(void *hook_data, void *call_data)
  */
 int after_schedchange_hook(void *hook_data, void *call_data)
 {
-  LttvTraceHook *th = (LttvTraceHook*)hook_data;
-  EventsRequest *events_request = (EventsRequest*)th->hook_data;
-  ControlFlowData *control_flow_data = events_request->viewer_data;
+  LttvEvent *event;
 
-  LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
+  event = (LttvEvent *) call_data;
+               
+  if (strcmp(lttv_traceset_get_name_from_event(event),"sched_switch") != 0)
+        return FALSE;
 
-  LttvTracefileState *tfs = (LttvTracefileState *)call_data;
+  ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
 
-  LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
 
-  LttEvent *e;
-  e = ltt_tracefile_get_event(tfc->tf);
+  LttvTraceState *ts = event->state;
 
+#ifdef BABEL_CLEANUP
   LttvFilter *filter = control_flow_data->filter;
-  LttTime evtime = ltt_event_time(e);
+#endif
+  LttTime evtime = lttv_event_get_timestamp(event);
 
   /* Add process to process list (if not present) */
   LttvProcessState *process_in;
@@ -918,20 +911,21 @@ int after_schedchange_hook(void *hook_data, void *call_data)
   
   guint pid_in;
   {
-    guint pid_out;
-    pid_out = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0));
-    pid_in = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1));
+    pid_in = lttv_event_get_long(event, "next_tid");
   }
 
-  tfc->target_pid = pid_in;
+#ifdef BABEL_CLEANUP
   if(!filter || !filter->head ||
     lttv_filter_tree_parse(filter->head,e,tfc->tf,
           tfc->t_context->t,tfc,NULL,NULL)) { 
+#else 
+    {
+#endif 
     /* Find process pid_in in the list... */
     //process_in = lttv_state_find_process(ts, ANY_CPU, pid_in);
     //process_in = tfs->process;
-    guint cpu = tfs->cpu;
-    guint trace_num = ts->parent.index;
+    guint cpu = lttv_traceset_get_cpuid_from_event(event);
+    guint trace_num = 0; /* TODO set right trace number */
     process_in = ts->running_process[cpu];
     /* It should exist, because we are after the state update. */
 #ifdef EXTRA_CHECK
@@ -1027,36 +1021,33 @@ int after_schedchange_hook(void *hook_data, void *call_data)
 
 int before_execmode_hook(void *hook_data, void *call_data)
 {
-  LttvTraceHook *th = (LttvTraceHook*)hook_data;
-  EventsRequest *events_request = (EventsRequest*)th->hook_data;
-  ControlFlowData *control_flow_data = events_request->viewer_data;
-
-  LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
-
-  LttvTracefileState *tfs = (LttvTracefileState *)call_data;
-
-  LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
-
-  LttEvent *e;
-  e = ltt_tracefile_get_event(tfc->tf);
-
-  LttvFilter *filter = control_flow_data->filter;
-  if(filter != NULL && filter->head != NULL)
-    if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
-          tfc->t_context->t,tfc,NULL,NULL))
-      return FALSE;
-
-  LttTime evtime = ltt_event_time(e);
-
+  LttvEvent *event;
+  guint cpu;
+  guint pid = 0;
+  LttvTraceState *ts;
+  LttvProcessState *process;
+  
   /* we are in a execmode, before the state update. We must draw the
    * items corresponding to the state before it changes : now is the right
    * time to do it.
    */
+  
+  event = (LttvEvent *) call_data;
+  if ((strncmp(lttv_traceset_get_name_from_event(event),"sys_", sizeof("sys_") - 1) == 0)
+          ||(strcmp(lttv_traceset_get_name_from_event(event),"exit_syscall") == 0)
+          ||(strncmp(lttv_traceset_get_name_from_event(event),"irq_handler_",sizeof("irq_handler_")) == 0)
+          ||(strncmp(lttv_traceset_get_name_from_event(event),"softirq_", sizeof("softirq_")) == 0)){
+          
+  LttTime evtime = lttv_event_get_timestamp(event);
+  ControlFlowData *control_flow_data = (ControlFlowData*)hook_data;
   /* For the pid */
-  //LttvProcessState *process = tfs->process;
-  guint cpu = tfs->cpu;
-  guint trace_num = ts->parent.index;
-  LttvProcessState *process = ts->running_process[cpu];
+  LttvTraceset *traceSet = lttvwindow_get_traceset(control_flow_data->tab);
+  
+  cpu = lttv_traceset_get_cpuid_from_event(event);
+  ts = event->state;
+  
+  guint trace_number = 0;//TODO fdeslauriers 2012-07-17: // Use trace handle to know trace number
+  process = lttv_state_find_process(ts ,cpu ,pid);
   g_assert(process != NULL);
 
   guint pid = process->pid;
@@ -1068,16 +1059,20 @@ int before_execmode_hook(void *hook_data, void *call_data)
   guint pl_height = 0;
   HashedProcessData *hashed_process_data = NULL;
   ProcessList *process_list = control_flow_data->process_list;
+  if(process_list->current_hash_data == NULL){//TODO fdeslauriers 2012-07-17 : should not be necessary
+    return 0;
+  }
+  
   LttTime birth = process->creation_time;
  
-  if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) {
-    hashed_process_data = process_list->current_hash_data[trace_num][cpu];
+  if(likely(process_list->current_hash_data[trace_number][cpu] != NULL)) {
+    hashed_process_data = process_list->current_hash_data[trace_number][cpu];
   } else {
     hashed_process_data = processlist_get_process_data(process_list,
             pid,
             process->cpu,
             &birth,
-            trace_num);
+            trace_number);
     if(unlikely(hashed_process_data == NULL))
     {
       g_assert(pid == 0 || pid != process->ppid);
@@ -1091,7 +1086,7 @@ int before_execmode_hook(void *hook_data, void *call_data)
           process->cpu,
           process->ppid,
           &birth,
-          trace_num,
+          trace_number,
           process->name,
           process->brand,
           &pl_height,
@@ -1103,7 +1098,7 @@ int before_execmode_hook(void *hook_data, void *call_data)
         gtk_widget_queue_draw(drawing->drawing_area);
     }
     /* Set the current process */
-    process_list->current_hash_data[trace_num][process->cpu] =
+    process_list->current_hash_data[trace_number][process->cpu] =
                                                hashed_process_data;
   }
 
@@ -1212,7 +1207,7 @@ int before_execmode_hook(void *hook_data, void *call_data)
                              &hashed_process_data->next_good_time);
     }
   }
-  
+  }
   return 0;
 }
 
@@ -1230,32 +1225,33 @@ int before_execmode_hook(void *hook_data, void *call_data)
 
 int before_process_exit_hook(void *hook_data, void *call_data)
 {
-  LttvTraceHook *th = (LttvTraceHook*)hook_data;
-  EventsRequest *events_request = (EventsRequest*)th->hook_data;
-
-  ControlFlowData *control_flow_data = events_request->viewer_data;
-
-  LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
 
-  LttvTracefileState *tfs = (LttvTracefileState *)call_data;
+  LttvEvent *event;
 
-  LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
+  event = (LttvEvent *) call_data;
+  if (strcmp(lttv_traceset_get_name_from_event(event),
+            "sched_process_exit") != 0)
+    return FALSE;
 
-  LttEvent *e;
-  e = ltt_tracefile_get_event(tfc->tf);
+  ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
+  LttvTraceState *ts = event->state;
 
+#ifdef BABEL_CLEANUP
   LttvFilter *filter = control_flow_data->filter;
   if(filter != NULL && filter->head != NULL)
     if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
           tfc->t_context->t,tfc,NULL,NULL))
       return FALSE;
+#endif
 
-  LttTime evtime = ltt_event_time(e);
+  LttTime evtime = lttv_event_get_timestamp(event);
 
   /* Add process to process list (if not present) */
   //LttvProcessState *process = tfs->process;
-  guint cpu = tfs->cpu;
-  guint trace_num = ts->parent.index;
+    guint cpu = lttv_traceset_get_cpuid_from_event(event);
+    guint trace_num = 0; /* TODO set right trace number */
+
   LttvProcessState *process = ts->running_process[cpu];
   guint pid = process->pid;
   LttTime birth;
@@ -1407,7 +1403,7 @@ int before_process_exit_hook(void *hook_data, void *call_data)
                              &hashed_process_data->next_good_time);
     }
   }
-  
+
   return 0;
 
 }
@@ -1428,33 +1424,34 @@ int before_process_exit_hook(void *hook_data, void *call_data)
 
 int before_process_release_hook(void *hook_data, void *call_data)
 {
-  LttvTraceHook *th = (LttvTraceHook*)hook_data;
-  EventsRequest *events_request = (EventsRequest*)th->hook_data;
 
-  ControlFlowData *control_flow_data = events_request->viewer_data;
+  LttvEvent *event;
 
-  LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
+  event = (LttvEvent *) call_data;
+               
+  if (strcmp(lttv_traceset_get_name_from_event(event),"sched_process_free") != 0)
+        return FALSE;
 
-  LttvTracefileState *tfs = (LttvTracefileState *)call_data;
+  ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
 
-  LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
 
-  LttEvent *e;
-  e = ltt_tracefile_get_event(tfc->tf);
+  LttvTraceState *ts = event->state;
 
+#ifdef BABEL_CLEANUP
   LttvFilter *filter = control_flow_data->filter;
   if(filter != NULL && filter->head != NULL)
     if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
           tfc->t_context->t,tfc,NULL,NULL))
       return FALSE;
+#endif
+  LttTime evtime = lttv_event_get_timestamp(event);
 
-  LttTime evtime = ltt_event_time(e);
 
-  guint trace_num = ts->parent.index;
+    guint trace_num = 0; /* TODO set right trace number */
 
   guint pid;
   {
-    pid = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0));
+    pid = lttv_event_get_long(event, "tid");
   }
 
   /* Add process to process list (if not present) */
@@ -1465,7 +1462,6 @@ int before_process_release_hook(void *hook_data, void *call_data)
 
   if(process != NULL) {
     LttTime birth;
-    guint pl_height = 0;
     HashedProcessData *hashed_process_data = NULL;
 
     ProcessList *process_list = control_flow_data->process_list;
@@ -1613,30 +1609,31 @@ int before_process_release_hook(void *hook_data, void *call_data)
  */
 int after_process_fork_hook(void *hook_data, void *call_data)
 {
-  LttvTraceHook *th = (LttvTraceHook*)hook_data;
-  EventsRequest *events_request = (EventsRequest*)th->hook_data;
-  ControlFlowData *control_flow_data = events_request->viewer_data;
+ LttvEvent *event;
 
-  LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
+  event = (LttvEvent *) call_data;
+               
+  if (strcmp(lttv_traceset_get_name_from_event(event),"sched_process_fork") != 0)
+        return FALSE;
 
-  LttvTracefileState *tfs = (LttvTracefileState *)call_data;
+  ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
 
-  LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
 
-  LttEvent *e;
-  e = ltt_tracefile_get_event(tfc->tf);
+  LttvTraceState *ts = event->state;
 
+#ifdef BABEL_CLEANUP
   LttvFilter *filter = control_flow_data->filter;
   if(filter != NULL && filter->head != NULL)
     if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
           tfc->t_context->t,tfc,NULL,NULL))
       return FALSE;
+#endif
 
-  LttTime evtime = ltt_event_time(e);
+  LttTime evtime = lttv_event_get_timestamp(event);
 
   guint child_pid;
   {
-    child_pid = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1));
+    child_pid = lttv_event_get_long(event, "child_tid");
   }
 
   /* Add process to process list (if not present) */
@@ -1653,7 +1650,7 @@ int after_process_fork_hook(void *hook_data, void *call_data)
   g_assert(process_child != NULL);
 
   birth = process_child->creation_time;
-  guint trace_num = ts->parent.index;
+  guint trace_num = 0; /* TODO put right */
 
   /* Cannot use current process, because this action is done by the parent
    * on its child. */
@@ -1747,31 +1744,32 @@ int after_process_fork_hook(void *hook_data, void *call_data)
  */
 int after_process_exit_hook(void *hook_data, void *call_data)
 {
-  LttvTraceHook *th = (LttvTraceHook*)hook_data;
-  EventsRequest *events_request = (EventsRequest*)th->hook_data;
-  ControlFlowData *control_flow_data = events_request->viewer_data;
-
-  LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
+#if 0
+  LttvEvent *event;
 
-  LttvTracefileState *tfs = (LttvTracefileState *)call_data;
+  event = (LttvEvent *) call_data;
+               
+  if (strcmp(lttv_traceset_get_name_from_event(event),"sched_process_exit") != 0)
+    return FALSE;
 
-  LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
+  ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
 
-  LttEvent *e;
-  e = ltt_tracefile_get_event(tfc->tf);
+  LttvTraceState *ts = event->state;
 
+#ifdef BABEL_CLEANUP
   LttvFilter *filter = control_flow_data->filter;
   if(filter != NULL && filter->head != NULL)
     if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
           tfc->t_context->t,tfc,NULL,NULL))
       return FALSE;
+#endif
 
-  LttTime evtime = ltt_event_time(e);
+  LttTime evtime = lttv_event_get_timestamp(event);
 
   /* Add process to process list (if not present) */
   //LttvProcessState *process = tfs->process;
-  guint cpu = tfs->cpu;
-  guint trace_num = ts->parent.index;
+  guint cpu = lttv_traceset_get_cpuid_from_event(event);
+  guint trace_num = 0; /* TODO set right trace number */
   LttvProcessState *process = ts->running_process[cpu];
 
   /* It should exist, because we are after the state update. */
@@ -1849,7 +1847,7 @@ int after_process_exit_hook(void *hook_data, void *call_data)
       hashed_process_data->x.middle_marked = FALSE;
     }
   }
-
+#endif
   return FALSE;
 }
 
@@ -1857,6 +1855,7 @@ int after_process_exit_hook(void *hook_data, void *call_data)
 /* Get the filename of the process to print */
 int after_fs_exec_hook(void *hook_data, void *call_data)
 {
+#ifdef BABEL_CLEANUP
   LttvTraceHook *th = (LttvTraceHook*)hook_data;
   EventsRequest *events_request = (EventsRequest*)th->hook_data;
   ControlFlowData *control_flow_data = events_request->viewer_data;
@@ -1931,6 +1930,7 @@ int after_fs_exec_hook(void *hook_data, void *call_data)
 
   processlist_set_name(process_list, process->name, hashed_process_data);
 
+#endif //babel_cleanup
   return 0;
 
 }
@@ -1938,6 +1938,7 @@ int after_fs_exec_hook(void *hook_data, void *call_data)
 /* Get the filename of the process to print */
 int after_user_generic_thread_brand_hook(void *hook_data, void *call_data)
 {
+#ifdef BABEL_CLEANUP
   LttvTraceHook *th = (LttvTraceHook*)hook_data;
   EventsRequest *events_request = (EventsRequest*)th->hook_data;
   ControlFlowData *control_flow_data = events_request->viewer_data;
@@ -2012,8 +2013,8 @@ int after_user_generic_thread_brand_hook(void *hook_data, void *call_data)
 
   processlist_set_brand(process_list, process->brand, hashed_process_data);
 
+#endif //babel_cleanup
   return 0;
-
 }
 
 
@@ -2030,29 +2031,27 @@ int after_user_generic_thread_brand_hook(void *hook_data, void *call_data)
  */
 int after_event_enum_process_hook(void *hook_data, void *call_data)
 {
-  LttvTraceHook *th = (LttvTraceHook*)hook_data;
-  EventsRequest *events_request = (EventsRequest*)th->hook_data;
-  ControlFlowData *control_flow_data = events_request->viewer_data;
+  LttvEvent *event;
 
-  LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
+  event = (LttvEvent *) call_data;
+               
+  if (strcmp(lttv_traceset_get_name_from_event(event),"lttng_statedump_process_state") != 0)
+        return FALSE;
 
-  LttvTracefileState *tfs = (LttvTracefileState *)call_data;
+  ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
 
-  LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
 
-  guint first_cpu, nb_cpus, cpu;
+  LttvTraceState *ts = event->state;
 
-  LttEvent *e;
-  e = ltt_tracefile_get_event(tfc->tf);
+  guint first_cpu, nb_cpus, cpu;
 
+#ifdef BABEL_CLEANUP
   LttvFilter *filter = control_flow_data->filter;
   if(filter != NULL && filter->head != NULL)
     if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
           tfc->t_context->t,tfc,NULL,NULL))
       return FALSE;
-
-  LttTime evtime = ltt_event_time(e);
-
+#endif
   /* Add process to process list (if not present) */
   LttvProcessState *process_in;
   LttTime birth;
@@ -2060,16 +2059,16 @@ int after_event_enum_process_hook(void *hook_data, void *call_data)
   HashedProcessData *hashed_process_data_in = NULL;
 
   ProcessList *process_list = control_flow_data->process_list;
-  guint trace_num = ts->parent.index;
+  guint trace_num = 0; /* TODO put right trace number */
   
   guint pid_in;
   {
-    pid_in = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0));
+    pid_in = lttv_event_get_long(event, "tid");
   }
   
   if(pid_in == 0) {
     first_cpu = 0;
-    nb_cpus = ltt_trace_get_num_cpu(ts->parent.t);
+    nb_cpus = lttv_trace_get_num_cpu(ts->trace);
   } else {
     first_cpu = ANY_CPU;
     nb_cpus = ANY_CPU+1;
@@ -2175,9 +2174,7 @@ gint update_time_window_hook(void *hook_data, void *call_data)
     /* Same scale (scrolling) */
     g_info("scrolling");
     LttTime *ns = &new_time_window->start_time;
-    LttTime *nw = &new_time_window->time_width;
     LttTime *os = &old_time_window->start_time;
-    LttTime *ow = &old_time_window->time_width;
     LttTime old_end = old_time_window->end_time;
     LttTime new_end = new_time_window->end_time;
     //if(ns<os+w<ns+w)
@@ -2439,11 +2436,11 @@ gint continue_notify(void *hook_data, void *call_data)
 
 gint update_current_time_hook(void *hook_data, void *call_data)
 {
+
   ControlFlowData *control_flow_data = (ControlFlowData*)hook_data;
-  Drawing_t *drawing = control_flow_data->drawing;
 
   LttTime current_time = *((LttTime*)call_data);
-  
+
   TimeWindow time_window =
             lttvwindow_get_time_window(control_flow_data->tab);
   
@@ -2457,11 +2454,11 @@ gint update_current_time_hook(void *hook_data, void *call_data)
   }
   LttTime time_end = ltt_time_add(time_begin, width);
 
-  LttvTracesetContext * tsc =
-        lttvwindow_get_traceset_context(control_flow_data->tab);
+  LttvTraceset * ts = lttvwindow_get_traceset(control_flow_data->tab);
   
-  LttTime trace_start = tsc->time_span.start_time;
-  LttTime trace_end = tsc->time_span.end_time;
+  TimeInterval time_span = lttv_traceset_get_time_span_real(ts);
+  LttTime trace_start = time_span.start_time;
+  LttTime trace_end = time_span.end_time;
   
   g_info("New current time HOOK : %lu, %lu", current_time.tv_sec,
               current_time.tv_nsec);
@@ -2519,11 +2516,11 @@ gint update_current_time_hook(void *hook_data, void *call_data)
       TRUE);
                              
   return 0;
+  
 }
 
 typedef struct _ClosureData {
   EventsRequest *events_request;
-  LttvTracesetState *tss;
   LttTime end_time;
   guint x_end;
 } ClosureData;
@@ -2531,15 +2528,15 @@ typedef struct _ClosureData {
 
 void draw_closure(gpointer key, gpointer value, gpointer user_data)
 {
+
   ProcessInfo *process_info = (ProcessInfo*)key;
   HashedProcessData *hashed_process_data = (HashedProcessData*)value;
   ClosureData *closure_data = (ClosureData*)user_data;
-    
+  
   EventsRequest *events_request = closure_data->events_request;
   ControlFlowData *control_flow_data = events_request->viewer_data;
+  LttvTraceset *ts = lttvwindow_get_traceset(control_flow_data->tab);
 
-  LttvTracesetState *tss = closure_data->tss;
-  LttvTracesetContext *tsc = (LttvTracesetContext*)tss;
 
   LttTime evtime = closure_data->end_time;
 
@@ -2555,8 +2552,9 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data)
 #ifdef EXTRA_CHECK
     g_assert(lttv_traceset_number(tsc->ts) > 0);
 #endif //EXTRA_CHECK
-    LttvTraceContext *tc = tsc->traces[process_info->trace_num];
-    LttvTraceState *ts = (LttvTraceState*)tc;
+    //TODO Fdeslauriers 2012-07-17: adapt for multiple traces
+    LttvTrace *trace = lttv_traceset_get(ts,0);
+    LttvTraceState *trace_state = trace->state;
 
 #if 0
     //FIXME : optimize data structures.
@@ -2573,25 +2571,24 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data)
     g_assert(i<tc->tracefiles->len);
     tfs = LTTV_TRACEFILE_STATE(tfc);
 #endif //0
- //   LttvTracefileState *tfs =
+ //   LttvTracefileState *tfs =ts
  //    (LttvTracefileState*)tsc->traces[process_info->trace_num]->
  //                        tracefiles[process_info->cpu];
  
     LttvProcessState *process;
-    process = lttv_state_find_process(ts, process_info->cpu,
+    process = lttv_state_find_process(trace_state, process_info->cpu,
                                       process_info->pid);
 
     if(unlikely(process != NULL)) {
-      
+#ifdef BABEL_CLEANUP
        LttvFilter *filter = control_flow_data->filter;
        if(filter != NULL && filter->head != NULL)
          if(!lttv_filter_tree_parse(filter->head,NULL,NULL,
              tc->t,NULL,process,tc))
            dodraw = FALSE;
-
+#endif //babel_cleanup
       /* Only draw for processes that are currently in the trace states */
 
-      ProcessList *process_list = control_flow_data->process_list;
 #ifdef EXTRA_CHECK
       /* Should be alike when background info is ready */
       if(control_flow_data->background_info_waiting==0)
@@ -2694,9 +2691,9 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data)
 
 int before_chunk(void *hook_data, void *call_data)
 {
+
   EventsRequest *events_request = (EventsRequest*)hook_data;
-  LttvTracesetState *tss = (LttvTracesetState*)call_data;
-  ControlFlowData *cfd = (ControlFlowData*)events_request->viewer_data;
+  LttvTraceset *ts = (LttvTraceset*)call_data;
 #if 0  
   /* Desactivate sort */
   gtk_tree_sortable_set_sort_column_id(
@@ -2704,19 +2701,20 @@ int before_chunk(void *hook_data, void *call_data)
       TRACE_COLUMN,
       GTK_SORT_ASCENDING);
 #endif //0
-  drawing_chunk_begin(events_request, tss);
+  drawing_chunk_begin(events_request, ts);
 
   return 0;
 }
 
 int before_request(void *hook_data, void *call_data)
 {
+
   EventsRequest *events_request = (EventsRequest*)hook_data;
-  LttvTracesetState *tss = (LttvTracesetState*)call_data;
  
-  drawing_data_request_begin(events_request, tss);
+  drawing_data_request_begin(events_request);
 
   return 0;
+
 }
 
 
@@ -2731,16 +2729,15 @@ int before_request(void *hook_data, void *call_data)
  */
 int after_request(void *hook_data, void *call_data)
 {
+
   EventsRequest *events_request = (EventsRequest*)hook_data;
   ControlFlowData *control_flow_data = events_request->viewer_data;
-  LttvTracesetState *tss = (LttvTracesetState*)call_data;
   
   ProcessList *process_list = control_flow_data->process_list;
   LttTime end_time = events_request->end_time;
 
   ClosureData closure_data;
   closure_data.events_request = (EventsRequest*)hook_data;
-  closure_data.tss = tss;
   closure_data.end_time = end_time;
 
   TimeWindow time_window = 
@@ -2759,7 +2756,7 @@ int after_request(void *hook_data, void *call_data)
   
 
   /* Request expose */
-  drawing_request_expose(events_request, tss, end_time);
+  drawing_request_expose(events_request, end_time);
   return 0;
 }
 
@@ -2770,17 +2767,16 @@ int after_request(void *hook_data, void *call_data)
  */
 int after_chunk(void *hook_data, void *call_data)
 {
+
   EventsRequest *events_request = (EventsRequest*)hook_data;
   ControlFlowData *control_flow_data = events_request->viewer_data;
-  LttvTracesetState *tss = (LttvTracesetState*)call_data;
-  LttvTracesetContext *tsc = (LttvTracesetContext*)call_data;
-  LttvTracefileContext *tfc = lttv_traceset_context_get_current_tfc(tsc);
+  LttvTraceset *ts = (LttvTraceset*)call_data;
+  
   LttTime end_time;
   
   ProcessList *process_list = control_flow_data->process_list;
   guint i;
-  LttvTraceset *traceset = tsc->ts;
-  guint nb_trace = lttv_traceset_number(traceset);
+  guint nb_trace = lttv_traceset_number(ts);
 
   /* Only execute when called for the first trace's events request */
   if(!process_list->current_hash_data)
@@ -2792,14 +2788,10 @@ int after_chunk(void *hook_data, void *call_data)
   g_free(process_list->current_hash_data);
   process_list->current_hash_data = NULL;
 
-  if(tfc != NULL)
-    end_time = LTT_TIME_MIN(tfc->timestamp, events_request->end_time);
-  else /* end of traceset, or position now out of request : end */
     end_time = events_request->end_time;
   
   ClosureData closure_data;
   closure_data.events_request = (EventsRequest*)hook_data;
-  closure_data.tss = tss;
   closure_data.end_time = end_time;
 
   TimeWindow time_window = 
@@ -2826,8 +2818,8 @@ int after_chunk(void *hook_data, void *call_data)
   gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
 #endif //0
   /* Request expose (updates damages zone also) */
-  drawing_request_expose(events_request, tss, end_time);
 
+  drawing_request_expose(events_request, end_time);
   return 0;
 }
 
@@ -2841,30 +2833,31 @@ int after_chunk(void *hook_data, void *call_data)
  */
 int before_statedump_end(void *hook_data, void *call_data)
 {
-  LttvTraceHook *th = (LttvTraceHook*)hook_data;
-  EventsRequest *events_request = (EventsRequest*)th->hook_data;
-  ControlFlowData *control_flow_data = events_request->viewer_data;
+  LttvEvent *event;
 
-  LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
+  event = (LttvEvent *) call_data;
+               
+  if (strcmp(lttv_traceset_get_name_from_event(event),"lttng_statedump_end") != 0)
+        return FALSE;
 
-  LttvTracefileState *tfs = (LttvTracefileState *)call_data;
+  ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
 
-  LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
 
-  LttvTracesetState *tss = (LttvTracesetState*)tfc->t_context->ts_context;
-  ProcessList *process_list = control_flow_data->process_list;
+  LttvTraceState *ts = event->state;
 
-  LttEvent *e;
-  e = ltt_tracefile_get_event(tfc->tf);
 
+  ProcessList *process_list = control_flow_data->process_list;
+
+#ifdef BABEL_CLEANUP
   LttvFilter *filter = control_flow_data->filter;
   if(filter != NULL && filter->head != NULL)
     if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
           tfc->t_context->t,tfc,NULL,NULL))
       return FALSE;
+#endif
 
-  LttTime evtime = ltt_event_time(e);
-
+  LttTime evtime = lttv_event_get_timestamp(event);
+#ifdef BABEL_CLEANUP
   ClosureData closure_data;
   closure_data.events_request = events_request;
   closure_data.tss = tss;
@@ -2882,6 +2875,7 @@ int before_statedump_end(void *hook_data, void *call_data)
   /* Draw last items */
   g_hash_table_foreach(process_list->process_hash, draw_closure,
                         (void*)&closure_data);
+
 #if 0
   /* Reactivate sort */
   gtk_tree_sortable_set_sort_column_id(
@@ -2895,6 +2889,6 @@ int before_statedump_end(void *hook_data, void *call_data)
 #endif //0
   /* Request expose (updates damages zone also) */
   drawing_request_expose(events_request, tss, evtime);
-
+#endif
   return 0;
 }
This page took 0.035738 seconds and 4 git commands to generate.