pid 0 fix
[lttv.git] / ltt / branches / poly / lttv / modules / gui / controlflow / eventhooks.c
index 8431d771a5f263077ceb5f2aa861b90eb073eecf..e87f7edbabd02b7a6c74b24710ca0295cd5cc138 100644 (file)
@@ -79,6 +79,8 @@
 
 
 #define MAX_PATH_LEN 256
+#define STATE_LINE_WIDTH 4
+#define COLLISION_POSITION(height) (((height - STATE_LINE_WIDTH)/2) -3)
 
 extern GSList *g_legend_list;
 
@@ -120,6 +122,7 @@ static void request_background_data(ControlFlowData *control_flow_data)
   gint num_traces = lttv_traceset_number(tsc->ts);
   gint i;
   LttvTrace *trace;
+  LttvTraceState *tstate;
 
   LttvHooks *background_ready_hook = 
     lttv_hooks_new();
@@ -129,8 +132,10 @@ static void request_background_data(ControlFlowData *control_flow_data)
   
   for(i=0;i<num_traces;i++) {
     trace = lttv_traceset_get(tsc->ts, i);
+    tstate = LTTV_TRACE_STATE(tsc->traces[i]);
 
-    if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE) {
+    if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE
+        && !tstate->has_precomputed_states) {
 
       if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
                                           trace) == FALSE) {
@@ -157,7 +162,7 @@ static void request_background_data(ControlFlowData *control_flow_data)
         control_flow_data->background_info_waiting++;
       }
     } else {
-      /* Data ready. Be its nature, this viewer doesn't need to have
+      /* Data ready. By its nature, this viewer doesn't need to have
        * its data ready hook called there, because a background
        * request is always linked with a redraw.
        */
@@ -269,7 +274,7 @@ int event_selected_hook(void *hook_data, void *call_data)
 static inline PropertiesLine prepare_s_e_line(LttvProcessState *process)
 {
   PropertiesLine prop_line;
-  prop_line.line_width = 5;
+  prop_line.line_width = STATE_LINE_WIDTH;
   prop_line.style = GDK_LINE_SOLID;
   prop_line.y = MIDDLE;
   //GdkColormap *colormap = gdk_colormap_get_system();
@@ -365,7 +370,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
   tfc->target_pid = pid_out;
   if(!filter || !filter->head ||
     lttv_filter_tree_parse(filter->head,e,tfc->tf,
-          tfc->t_context->t,tfc)) { 
+          tfc->t_context->t,tfc,NULL,NULL)) { 
     /* 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
@@ -451,7 +456,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
           gdk_draw_point(hashed_process_data->pixmap,
                          drawing->gc,
                          x,
-                         (hashed_process_data->height/2)-3);
+                         COLLISION_POSITION(hashed_process_data->height));
           hashed_process_data->x.middle_marked = TRUE;
         }
       } else {
@@ -482,7 +487,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
             gdk_draw_point(hashed_process_data->pixmap,
                            drawing->gc,
                            x,
-                           (hashed_process_data->height/2)-3);
+                           COLLISION_POSITION(hashed_process_data->height));
             hashed_process_data->x.middle_marked = TRUE;
           }
           /* jump */
@@ -530,7 +535,7 @@ 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)) { 
+          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
@@ -615,7 +620,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
           gdk_draw_point(hashed_process_data->pixmap,
                          drawing->gc,
                          x,
-                         (hashed_process_data->height/2)-3);
+                         COLLISION_POSITION(hashed_process_data->height));
           hashed_process_data->x.middle_marked = TRUE;
         }
       } else {
@@ -647,7 +652,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
             gdk_draw_point(hashed_process_data->pixmap,
                            drawing->gc,
                            x,
-                           (hashed_process_data->height/2)-3);
+                           COLLISION_POSITION(hashed_process_data->height));
             hashed_process_data->x.middle_marked = TRUE;
           }
           /* jump */
@@ -749,7 +754,7 @@ int after_schedchange_hook(void *hook_data, void *call_data)
   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))
+          tfc->t_context->t,tfc,NULL,NULL))
       return FALSE;
 
   LttTime evtime = ltt_event_time(e);
@@ -884,7 +889,7 @@ int before_execmode_hook(void *hook_data, void *call_data)
   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))
+          tfc->t_context->t,tfc,NULL,NULL))
       return FALSE;
 
   LttTime evtime = ltt_event_time(e);
@@ -978,7 +983,7 @@ int before_execmode_hook(void *hook_data, void *call_data)
       gdk_draw_point(hashed_process_data->pixmap,
                      drawing->gc,
                      x,
-                     (hashed_process_data->height/2)-3);
+                     COLLISION_POSITION(hashed_process_data->height));
       hashed_process_data->x.middle_marked = TRUE;
     }
   } else {
@@ -1011,7 +1016,7 @@ int before_execmode_hook(void *hook_data, void *call_data)
         gdk_draw_point(hashed_process_data->pixmap,
                        drawing->gc,
                        x,
-                       (hashed_process_data->height/2)-3);
+                       COLLISION_POSITION(hashed_process_data->height));
         hashed_process_data->x.middle_marked = TRUE;
       }
       /* jump */
@@ -1088,7 +1093,7 @@ int before_process_exit_hook(void *hook_data, void *call_data)
   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))
+          tfc->t_context->t,tfc,NULL,NULL))
       return FALSE;
 
   LttTime evtime = ltt_event_time(e);
@@ -1173,7 +1178,7 @@ int before_process_exit_hook(void *hook_data, void *call_data)
       gdk_draw_point(hashed_process_data->pixmap,
                      drawing->gc,
                      x,
-                     (hashed_process_data->height/2)-3);
+                     COLLISION_POSITION(hashed_process_data->height));
       hashed_process_data->x.middle_marked = TRUE;
     }
   } else {
@@ -1206,7 +1211,7 @@ int before_process_exit_hook(void *hook_data, void *call_data)
         gdk_draw_point(hashed_process_data->pixmap,
                        drawing->gc,
                        x,
-                       (hashed_process_data->height/2)-3);
+                       COLLISION_POSITION(hashed_process_data->height));
         hashed_process_data->x.middle_marked = TRUE;
       }
       /* jump */
@@ -1286,7 +1291,7 @@ int before_process_release_hook(void *hook_data, void *call_data)
   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))
+          tfc->t_context->t,tfc,NULL,NULL))
       return FALSE;
 
   LttTime evtime = ltt_event_time(e);
@@ -1375,7 +1380,7 @@ int before_process_release_hook(void *hook_data, void *call_data)
         gdk_draw_point(hashed_process_data->pixmap,
                        drawing->gc,
                        x,
-                       (hashed_process_data->height/2)-3);
+                       COLLISION_POSITION(hashed_process_data->height));
         hashed_process_data->x.middle_marked = TRUE;
       }
     } else {
@@ -1408,7 +1413,7 @@ int before_process_release_hook(void *hook_data, void *call_data)
           gdk_draw_point(hashed_process_data->pixmap,
                          drawing->gc,
                          x,
-                         (hashed_process_data->height/2)-3);
+                         COLLISION_POSITION(hashed_process_data->height));
           hashed_process_data->x.middle_marked = TRUE;
         }
         /* jump */
@@ -1488,7 +1493,7 @@ int after_process_fork_hook(void *hook_data, void *call_data)
   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))
+          tfc->t_context->t,tfc,NULL,NULL))
       return FALSE;
 
   LttTime evtime = ltt_event_time(e);
@@ -1622,7 +1627,7 @@ int after_process_exit_hook(void *hook_data, void *call_data)
   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))
+          tfc->t_context->t,tfc,NULL,NULL))
       return FALSE;
 
   LttTime evtime = ltt_event_time(e);
@@ -1732,7 +1737,7 @@ int after_fs_exec_hook(void *hook_data, void *call_data)
   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))
+          tfc->t_context->t,tfc,NULL,NULL))
       return FALSE;
 
   guint cpu = tfs->cpu;
@@ -1813,7 +1818,7 @@ int after_user_generic_thread_brand_hook(void *hook_data, void *call_data)
   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))
+          tfc->t_context->t,tfc,NULL,NULL))
       return FALSE;
 
   guint cpu = tfs->cpu;
@@ -1899,13 +1904,15 @@ int after_event_enum_process_hook(void *hook_data, void *call_data)
 
   LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
 
+  guint first_cpu, nb_cpus, cpu;
+
   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))
+          tfc->t_context->t,tfc,NULL,NULL))
       return FALSE;
 
   LttTime evtime = ltt_event_time(e);
@@ -1923,58 +1930,67 @@ int after_event_enum_process_hook(void *hook_data, void *call_data)
   {
     pid_in = ltt_event_get_long_unsigned(e, thf->f1);
   }
+  
+  if(pid_in == 0) {
+    first_cpu = 0;
+    nb_cpus = ltt_trace_get_num_cpu(ts->parent.t);
+  } else {
+    first_cpu = ANY_CPU;
+    nb_cpus = ANY_CPU+1;
+  }
 
-
-  /* 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;
-  //process_in = ts->running_process[cpu];
-  /* It should exist, because we are after the state update. */
-#ifdef EXTRA_CHECK
-  //g_assert(process_in != NULL);
-#endif //EXTRA_CHECK
-  birth = process_in->creation_time;
-
-  hashed_process_data_in = processlist_get_process_data(process_list,
+  for(cpu = first_cpu; cpu < nb_cpus; cpu++) {
+    /* Find process pid_in in the list... */
+    process_in = lttv_state_find_process(ts, cpu, pid_in);
+    //process_in = tfs->process;
+    //guint cpu = tfs->cpu;
+    //guint trace_num = ts->parent.index;
+    //process_in = ts->running_process[cpu];
+    /* It should exist, because we are after the state update. */
+  #ifdef EXTRA_CHECK
+    //g_assert(process_in != NULL);
+  #endif //EXTRA_CHECK
+    birth = process_in->creation_time;
+
+    hashed_process_data_in = processlist_get_process_data(process_list,
+            pid_in,
+            process_in->cpu,
+            &birth,
+            trace_num);
+    if(hashed_process_data_in == NULL)
+    {
+      if(pid_in != 0 && pid_in == process_in->ppid)
+        g_critical("TEST %u , %u", pid_in, process_in->ppid);
+      g_assert(pid_in == 0 || pid_in != process_in->ppid);
+      ProcessInfo *process_info;
+      Drawing_t *drawing = control_flow_data->drawing;
+      /* Process not present */
+      processlist_add(process_list,
+          drawing,
           pid_in,
+          process_in->tgid,
           process_in->cpu,
+          process_in->ppid,
           &birth,
-          trace_num);
-  if(hashed_process_data_in == NULL)
-  {
-               if(pid_in != 0 && pid_in == process_in->ppid)
-                       g_critical("TEST %u , %u", pid_in, process_in->ppid);
-    g_assert(pid_in == 0 || pid_in != process_in->ppid);
-    ProcessInfo *process_info;
-    Drawing_t *drawing = control_flow_data->drawing;
-    /* Process not present */
-    processlist_add(process_list,
-        drawing,
-        pid_in,
-        process_in->tgid,
-        process_in->cpu,
-        process_in->ppid,
-        &birth,
-        trace_num,
-        process_in->name,
-        process_in->brand,
-        &pl_height,
-        &process_info,
-        &hashed_process_data_in);
-        gtk_widget_set_size_request(drawing->drawing_area,
-                                    -1,
-                                    pl_height);
-        gtk_widget_queue_draw(drawing->drawing_area);
-  } else {
-          processlist_set_name(process_list, process_in->name,
-                               hashed_process_data_in);
-          processlist_set_ppid(process_list, process_in->ppid,
-                               hashed_process_data_in);
-          processlist_set_tgid(process_list, process_in->tgid,
-                               hashed_process_data_in);
-       }
+          trace_num,
+          process_in->name,
+          process_in->brand,
+          &pl_height,
+          &process_info,
+          &hashed_process_data_in);
+          gtk_widget_set_size_request(drawing->drawing_area,
+                                      -1,
+                                      pl_height);
+          gtk_widget_queue_draw(drawing->drawing_area);
+    } else {
+      processlist_set_name(process_list, process_in->name,
+                           hashed_process_data_in);
+      processlist_set_ppid(process_list, process_in->ppid,
+                           hashed_process_data_in);
+      processlist_set_tgid(process_list, process_in->tgid,
+                           hashed_process_data_in);
+    }
+  }
   return 0;
 }
 
@@ -2391,6 +2407,8 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data)
 
   LttTime evtime = closure_data->end_time;
 
+  gboolean dodraw = TRUE;
+
   { 
     /* For the process */
     /* First, check if the current process is in the state computation
@@ -2429,6 +2447,12 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data)
 
     if(unlikely(process != NULL)) {
       
+       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;
+
       /* Only draw for processes that are currently in the trace states */
 
       ProcessList *process_list = control_flow_data->process_list;
@@ -2510,8 +2534,10 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data)
         } else {
           draw_context.drawinfo.start.x = hashed_process_data->x.middle;
           /* Draw the line */
-          PropertiesLine prop_line = prepare_s_e_line(process);
-          draw_line((void*)&prop_line, (void*)&draw_context);
+          if(dodraw) {
+                  PropertiesLine prop_line = prepare_s_e_line(process);
+                  draw_line((void*)&prop_line, (void*)&draw_context);
+          }
 
            /* become the last x position */
           if(likely(x != hashed_process_data->x.middle)) {
@@ -2668,3 +2694,70 @@ int after_chunk(void *hook_data, void *call_data)
   return 0;
 }
 
+/* after_statedump_end
+ * 
+ * @param hook_data ControlFlowData structure of the viewer. 
+ * @param call_data Event context.
+ *
+ * This function adds items to be drawn in a queue for each process.
+ * 
+ */
+int before_statedump_end(void *hook_data, void *call_data)
+{
+  LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data;
+  EventsRequest *events_request = (EventsRequest*)thf->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;
+
+  LttvTracesetState *tss = (LttvTracesetState*)tfc->t_context->ts_context;
+  ProcessList *process_list = control_flow_data->process_list;
+
+  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);
+
+  ClosureData closure_data;
+  closure_data.events_request = events_request;
+  closure_data.tss = tss;
+  closure_data.end_time = evtime;
+
+  TimeWindow time_window = 
+          lttvwindow_get_time_window(control_flow_data->tab);
+  guint width = control_flow_data->drawing->width;
+  convert_time_to_pixels(
+            time_window,
+            evtime,
+            width,
+            &closure_data.x_end);
+
+  /* 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(
+      GTK_TREE_SORTABLE(control_flow_data->process_list->list_store),
+      GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
+      GTK_SORT_ASCENDING);
+
+  update_index_to_pixmap(control_flow_data->process_list);
+  /* Request a full expose : drawing scrambled */
+  gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
+#endif //0
+  /* Request expose (updates damages zone also) */
+  drawing_request_expose(events_request, tss, evtime);
+
+  return 0;
+}
This page took 0.028836 seconds and 4 git commands to generate.