keep current process : y position shorter to find
[lttv.git] / ltt / branches / poly / lttv / modules / gui / controlflow / eventhooks.c
index d080a2c17e32bcf85f07376f41af4d1c42200fcd..fc4e2caa4724518e1de10f5fb0c8a04a360af122 100644 (file)
@@ -419,8 +419,11 @@ int before_schedchange_hook(void *hook_data, void *call_data)
      * 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(tfs, pid_out);
-    //process = tfs->process;
+    /* unknown state, bad current pid */
+    if(tfs->process->pid != pid_out)
+      process = lttv_state_find_process(tfs, pid_out);
+    else
+      process = tfs->process;
     
     if(process != NULL) {
       /* Well, the process_out existed : we must get it in the process hash
@@ -431,11 +434,10 @@ int before_schedchange_hook(void *hook_data, void *call_data)
       HashedProcessData *hashed_process_data = NULL;
       ProcessList *process_list = control_flow_data->process_list;
       LttTime birth = process->creation_time;
-      const gchar *name = g_quark_to_string(process->name);
       
       if(processlist_get_process_pixels(process_list,
               pid_out,
-              process->last_cpu,
+              process->last_cpu_index,
               &birth,
               tfc->t_context->index,
               &y,
@@ -443,11 +445,12 @@ int before_schedchange_hook(void *hook_data, void *call_data)
               &hashed_process_data) == 1)
       {
         g_assert(pid_out == 0 || pid_out != process->ppid);
+        const gchar *name = g_quark_to_string(process->name);
         /* Process not present */
         ProcessInfo *process_info;
         processlist_add(process_list,
             pid_out,
-            process->last_cpu,
+            process->last_cpu_index,
             process->ppid,
             &birth,
             tfc->t_context->index,
@@ -456,7 +459,6 @@ int before_schedchange_hook(void *hook_data, void *call_data)
             &process_info,
             &hashed_process_data);
         processlist_get_pixels_from_data(process_list,
-                process_info,
                 hashed_process_data,
                 &y,
                 &height);
@@ -591,11 +593,10 @@ int before_schedchange_hook(void *hook_data, void *call_data)
       HashedProcessData *hashed_process_data = NULL;
       ProcessList *process_list = control_flow_data->process_list;
       LttTime birth = process->creation_time;
-      const gchar *name = g_quark_to_string(process->name);
       
       if(processlist_get_process_pixels(process_list,
               pid_in,
-              process->last_cpu,
+              process->last_cpu_index,
               &birth,
               tfc->t_context->index,
               &y,
@@ -603,11 +604,12 @@ int before_schedchange_hook(void *hook_data, void *call_data)
               &hashed_process_data) == 1)
       {
         g_assert(pid_in == 0 || pid_in != process->ppid);
+        const gchar *name = g_quark_to_string(process->name);
         /* Process not present */
         ProcessInfo *process_info;
         processlist_add(process_list,
             pid_in,
-            process->last_cpu,
+            process->last_cpu_index,
             process->ppid,
             &birth,
             tfc->t_context->index,
@@ -616,12 +618,13 @@ int before_schedchange_hook(void *hook_data, void *call_data)
             &process_info,
             &hashed_process_data);
         processlist_get_pixels_from_data(process_list,
-                process_info,
                 hashed_process_data,
                 &y,
                 &height);
         drawing_insert_square( drawing, y, height);
       }
+      //We could set the current process and hash here, but will be done
+      //by after schedchange hook
     
       /* Now, the process is in the state hash and our own process hash.
        * We definitely can draw the items related to the ending state.
@@ -1393,16 +1396,16 @@ int after_schedchange_hook(void *hook_data, void *call_data)
 
 
   /* Find process pid_in in the list... */
-  process_in = lttv_state_find_process(tfs, pid_in);
+  //process_in = lttv_state_find_process(tfs, pid_in);
+  process_in = tfs->process;
   /* It should exist, because we are after the state update. */
   g_assert(process_in != NULL);
 
   birth = process_in->creation_time;
-  const gchar *name = g_quark_to_string(process_in->name);
 
   if(processlist_get_process_pixels(process_list,
           pid_in,
-          process_in->last_cpu,
+          process_in->last_cpu_index,
           &birth,
           tfc->t_context->index,
           &y_in,
@@ -1410,11 +1413,12 @@ int after_schedchange_hook(void *hook_data, void *call_data)
           &hashed_process_data_in) == 1)
   {
     g_assert(pid_in == 0 || pid_in != process_in->ppid);
+    const gchar *name = g_quark_to_string(process_in->name);
     ProcessInfo *process_info;
     /* Process not present */
     processlist_add(process_list,
         pid_in,
-        process_in->last_cpu,
+        process_in->last_cpu_index,
         process_in->ppid,
         &birth,
         tfc->t_context->index,
@@ -1423,12 +1427,14 @@ int after_schedchange_hook(void *hook_data, void *call_data)
         &process_info,
         &hashed_process_data_in);
     processlist_get_pixels_from_data(process_list,
-                process_info,
                 hashed_process_data_in,
                 &y_in,
                 &height);
     drawing_insert_square( control_flow_data->drawing, y_in, height);
   }
+  /* Set the current process */
+  process_list->current_hash_data[process_in->last_cpu_index] =
+                                             hashed_process_data_in;
 
   if(ltt_time_compare(hashed_process_data_in->next_good_time,
                           evtime) <= 0)
@@ -1999,36 +2005,46 @@ int before_execmode_hook(void *hook_data, void *call_data)
   HashedProcessData *hashed_process_data = NULL;
   ProcessList *process_list = control_flow_data->process_list;
   LttTime birth = process->creation_time;
-  const gchar *name = g_quark_to_string(process->name);
-  
-  if(processlist_get_process_pixels(process_list,
-          pid,
-          process->last_cpu,
-          &birth,
-          tfc->t_context->index,
-          &y,
-          &height,
-          &hashed_process_data) == 1)
-  {
-    g_assert(pid == 0 || pid != process->ppid);
-    ProcessInfo *process_info;
-    /* Process not present */
-    processlist_add(process_list,
-        pid,
-        process->last_cpu,
-        process->ppid,
-        &birth,
-        tfc->t_context->index,
-        name,
-        &pl_height,
-        &process_info,
-        &hashed_process_data);
+  if(process_list->current_hash_data[tfc->index] != NULL) {
+    hashed_process_data = process_list->current_hash_data[tfc->index];
     processlist_get_pixels_from_data(process_list,
-                process_info,
                 hashed_process_data,
                 &y,
                 &height);
-    drawing_insert_square( drawing, y, height);
+  } else {
+    if(processlist_get_process_pixels(process_list,
+            pid,
+            process->last_cpu_index,
+            &birth,
+            tfc->t_context->index,
+            &y,
+            &height,
+            &hashed_process_data) == 1)
+    {
+      g_assert(pid == 0 || pid != process->ppid);
+      ProcessInfo *process_info;
+      /* Process not present */
+      const gchar *name = g_quark_to_string(process->name);
+      processlist_add(process_list,
+          pid,
+          process->last_cpu_index,
+          process->ppid,
+          &birth,
+          tfc->t_context->index,
+          name,
+          &pl_height,
+          &process_info,
+          &hashed_process_data);
+      processlist_get_pixels_from_data(process_list,
+                  hashed_process_data,
+                  &y,
+                  &height);
+      drawing_insert_square( drawing, y, height);
+    }
+    /* Set the current process */
+    process_list->current_hash_data[process->last_cpu_index] =
+                                               hashed_process_data;
   }
 
   /* Now, the process is in the state hash and our own process hash.
@@ -2185,38 +2201,48 @@ int after_execmode_hook(void *hook_data, void *call_data)
   guint pid = process->pid;
 
   birth = process->creation_time;
-  const gchar *name = g_quark_to_string(process->name);
 
-  if(processlist_get_process_pixels(process_list,
-          pid,
-          process->last_cpu,
-          &birth,
-          tfc->t_context->index,
-          &y,
-          &height,
-          &hashed_process_data) == 1)
-  {
-    g_assert(pid == 0 || pid != process->ppid);
-    /* Process not present */
-    ProcessInfo *process_info;
-    processlist_add(process_list,
-        pid,
-        process->last_cpu,
-        process->ppid,
-        &birth,
-        tfc->t_context->index,
-        name,
-        &pl_height,
-        &process_info,
-        &hashed_process_data);
+  if(process_list->current_hash_data[tfc->index] != NULL) {
+    hashed_process_data = process_list->current_hash_data[tfc->index];
     processlist_get_pixels_from_data(process_list,
-                process_info,
                 hashed_process_data,
                 &y,
                 &height);
-    drawing_insert_square( control_flow_data->drawing, y, height);
+  } else {
+    if(processlist_get_process_pixels(process_list,
+            pid,
+            process->last_cpu_index,
+            &birth,
+            tfc->t_context->index,
+            &y,
+            &height,
+            &hashed_process_data) == 1)
+    {
+      g_assert(pid == 0 || pid != process->ppid);
+      /* Process not present */
+      const gchar *name = g_quark_to_string(process->name);
+      ProcessInfo *process_info;
+      processlist_add(process_list,
+          pid,
+          process->last_cpu_index,
+          process->ppid,
+          &birth,
+          tfc->t_context->index,
+          name,
+          &pl_height,
+          &process_info,
+          &hashed_process_data);
+      processlist_get_pixels_from_data(process_list,
+                  hashed_process_data,
+                  &y,
+                  &height);
+      drawing_insert_square( control_flow_data->drawing, y, height);
+    }
+    /* Set the current process */
+    process_list->current_hash_data[process->last_cpu_index] =
+                                               hashed_process_data;
   }
-  
+
   if(ltt_time_compare(hashed_process_data->next_good_time,
                           evtime) <= 0)
   {
@@ -2298,11 +2324,16 @@ int before_process_hook(void *hook_data, void *call_data)
     g_assert(process != NULL);
 
     birth = process->creation_time;
-    const gchar *name = g_quark_to_string(process->name);
 
-    if(processlist_get_process_pixels(process_list,
+    if(process_list->current_hash_data[tfc->index] != NULL) {
+      hashed_process_data = process_list->current_hash_data[tfc->index];
+      processlist_get_pixels_from_data(process_list,
+                hashed_process_data,
+                &y,
+                &height);
+    } else  if(processlist_get_process_pixels(process_list,
             pid,
-            process->last_cpu,
+            process->last_cpu_index,
             &birth,
             tfc->t_context->index,
             &y,
@@ -2311,10 +2342,11 @@ int before_process_hook(void *hook_data, void *call_data)
     {
       g_assert(pid == 0 || pid != process->ppid);
       /* Process not present */
+      const gchar *name = g_quark_to_string(process->name);
       ProcessInfo *process_info;
       processlist_add(process_list,
           pid,
-          process->last_cpu,
+          process->last_cpu_index,
           process->ppid,
           &birth,
           tfc->t_context->index,
@@ -2323,7 +2355,6 @@ int before_process_hook(void *hook_data, void *call_data)
           &process_info,
           &hashed_process_data);
       processlist_get_pixels_from_data(process_list,
-                process_info,
                 hashed_process_data,
                 &y,
                 &height);
@@ -2506,11 +2537,10 @@ int after_process_hook(void *hook_data, void *call_data)
     g_assert(process_child != NULL);
 
     birth = process_child->creation_time;
-    const gchar *name = g_quark_to_string(process_child->name);
 
     if(processlist_get_process_pixels(process_list,
             child_pid,
-            process_child->last_cpu,
+            process_child->last_cpu_index,
             &birth,
             tfc->t_context->index,
             &y_child,
@@ -2519,10 +2549,11 @@ int after_process_hook(void *hook_data, void *call_data)
     {
       g_assert(child_pid == 0 || child_pid != process_child->ppid);
       /* Process not present */
+      const gchar *name = g_quark_to_string(process_child->name);
       ProcessInfo *process_info;
       processlist_add(process_list,
           child_pid,
-          process_child->last_cpu,
+          process_child->last_cpu_index,
           process_child->ppid,
           &birth,
           tfc->t_context->index,
@@ -2531,13 +2562,13 @@ int after_process_hook(void *hook_data, void *call_data)
           &process_info,
           &hashed_process_data_child);
       processlist_get_pixels_from_data(process_list,
-                process_info,
                 hashed_process_data_child,
                 &y_child,
                 &height);
       drawing_insert_square( control_flow_data->drawing, y_child, height);
     }
 
+
     if(ltt_time_compare(hashed_process_data_child->next_good_time,
                           evtime) <= 0)
     {
@@ -2589,36 +2620,48 @@ int after_process_hook(void *hook_data, void *call_data)
     g_assert(process != NULL);
 
     birth = process->creation_time;
-    const gchar *name = g_quark_to_string(process->name);
 
-    if(processlist_get_process_pixels(process_list,
-            pid,
-            process->last_cpu,
-            &birth,
-            tfc->t_context->index,
-            &y,
-            &height,
-            &hashed_process_data) == 1)
-    {
-      g_assert(pid == 0 || pid != process->ppid);
-      /* Process not present */
-      ProcessInfo *process_info;
-      processlist_add(process_list,
-          pid,
-          process->last_cpu,
-          process->ppid,
-          &birth,
-          tfc->t_context->index,
-          name,
-          &pl_height,
-          &process_info,
-          &hashed_process_data);
+    if(process_list->current_hash_data[tfc->index] != NULL) {
+      hashed_process_data = process_list->current_hash_data[tfc->index];
       processlist_get_pixels_from_data(process_list,
-                process_info,
                 hashed_process_data,
                 &y,
                 &height);
-      drawing_insert_square( control_flow_data->drawing, y, height);
+      
+    } else {
+      if(processlist_get_process_pixels(process_list,
+              pid,
+              process->last_cpu_index,
+              &birth,
+              tfc->t_context->index,
+              &y,
+              &height,
+              &hashed_process_data) == 1)
+      {
+        g_assert(pid == 0 || pid != process->ppid);
+        /* Process not present */
+        const gchar *name = g_quark_to_string(process->name);
+        ProcessInfo *process_info;
+        processlist_add(process_list,
+            pid,
+            process->last_cpu_index,
+            process->ppid,
+            &birth,
+            tfc->t_context->index,
+            name,
+            &pl_height,
+            &process_info,
+            &hashed_process_data);
+        processlist_get_pixels_from_data(process_list,
+                  hashed_process_data,
+                  &y,
+                  &height);
+        drawing_insert_square( control_flow_data->drawing, y, height);
+      }
+
+      /* Set the current process */
+      process_list->current_hash_data[process->last_cpu_index] =
+                                               hashed_process_data;
     }
 
     if(ltt_time_compare(hashed_process_data->next_good_time,
@@ -3104,11 +3147,8 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data)
       if(control_flow_data->background_info_waiting==0)
         g_assert(ltt_time_compare(process->creation_time,
                                   process_info->birth) == 0);
-      const gchar *name = g_quark_to_string(process->name);
-      
       /* process HAS to be present */
       processlist_get_pixels_from_data(process_list,
-              process_info,
               hashed_process_data,
               &y,
               &height);
@@ -3284,6 +3324,9 @@ int after_chunk(void *hook_data, void *call_data)
   
   ProcessList *process_list = control_flow_data->process_list;
 
+  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 */
This page took 0.027552 seconds and 4 git commands to generate.