Add member timestamp and cpuid to LttvTracesetPosition to improve the comparaison...
authorFrancis Deslauriers <francis.deslauriers@polymtl.ca>
Wed, 18 Jul 2012 20:01:17 +0000 (16:01 -0400)
committerYannick Brosseau <yannick.brosseau@gmail.com>
Thu, 9 Aug 2012 23:43:19 +0000 (19:43 -0400)
Signed-off-by: Francis Deslauriers <francis.deslauriers@polymtl.ca>
Signed-off-by: Yannick Brosseau <yannick.brosseau@gmail.com>
lttv/lttv/state.c
lttv/lttv/traceset-process.c
lttv/lttv/traceset.c
lttv/modules/gui/detailedevents/events.c
lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c

index a2f609f52d768292ce4c66871c542adfc589bf9d..67ba3025076bb283cf6dbdd9033a244838d4c93d 100644 (file)
@@ -31,6 +31,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <inttypes.h>
+#include <babeltrace/babeltrace.h>
 
 #define PREALLOCATED_EXECUTION_STACK 10
 
index b49542f9fb7aea400464c472fbb562f6931fdc49..02b014180b6b7521039aa3fc31fc3de3f1f2c501 100644 (file)
@@ -243,6 +243,8 @@ guint lttv_process_traceset_seek_n_backward(LttvTraceset *ts,
         beginPos.bt_pos = &pos;
         beginPos.iter = ts->iter;
         beginPos.bt_pos->type = BT_SEEK_BEGIN;
+        beginPos.timestamp = G_MAXUINT64;
+        beginPos.cpu_id = INT_MAX;
         /*Save initial position of the traceset*/
         initialPos = lttv_traceset_create_current_position (ts);
         
index 542101607d064d61fd322fc97409fb425bcff3c1..10108f3ceb76383f70752834713e9a42714f7470 100644 (file)
@@ -435,7 +435,9 @@ LttvTracesetPosition *lttv_traceset_create_current_position(LttvTraceset *traces
 
        traceset_pos->iter = traceset->iter;
        traceset_pos->bt_pos = bt_iter_get_pos(bt_ctf_get_iter(traceset->iter));
-       
+        traceset_pos->timestamp = G_MAXUINT64;
+        traceset_pos->cpu_id = INT_MAX;
+        
        return traceset_pos;
 }
 
@@ -452,10 +454,11 @@ LttvTracesetPosition *lttv_traceset_create_time_position(LttvTraceset *traceset,
         }
         
         traceset_pos->iter = traceset->iter;
-        traceset_pos->bt_pos = bt_iter_create_time_pos(
+        traceset_pos->bt_pos = bt_iter_create_time_pos( 
                                         bt_ctf_get_iter(traceset_pos->iter),
                                         ltt_time_to_uint64(timestamp));
-         
+        traceset_pos->timestamp = G_MAXUINT64;
+        traceset_pos->cpu_id = INT_MAX;
         return traceset_pos;
 }
 
@@ -497,6 +500,8 @@ guint64 lttv_traceset_get_timestamp_first_event(LttvTraceset *ts)
         LttvTracesetPosition begin_position;
         struct bt_iter_pos pos;
         begin_position.bt_pos = &pos;
+        begin_position.timestamp = G_MAXUINT64;
+        begin_position.cpu_id = INT_MAX;
        
          /* Assign iterator to the beginning of the traces */  
         begin_position.bt_pos->type = BT_SEEK_BEGIN;
@@ -598,26 +603,52 @@ const char *lttv_traceset_get_name_from_event(LttvEvent *event)
        return bt_ctf_event_name(event->bt_event);
 }
 
-guint64 lttv_traceset_position_get_timestamp(const LttvTracesetPosition *pos)
-{ 
-        guint64 timestamp = 0;
-       /*We save the current iterator,so we can reassign it after the seek*/
-        LttvTracesetPosition previous_pos;
-        previous_pos.iter = pos->iter;
-        previous_pos.bt_pos = bt_iter_get_pos(bt_ctf_get_iter(pos->iter));
+int set_values_position(const LttvTracesetPosition *pos)
+{
+       LttvTracesetPosition previous_pos;
+       previous_pos.iter = pos->iter;
+       previous_pos.bt_pos = bt_iter_get_pos(bt_ctf_get_iter(pos->iter));
        /* Seek to the new desired position */
-        lttv_traceset_seek_to_position(pos);
+       lttv_traceset_seek_to_position(pos);
        /*Read the event*/
-        struct bt_ctf_event *event = bt_ctf_iter_read_event(pos->iter);
-        
+       struct bt_ctf_event *event = bt_ctf_iter_read_event(pos->iter);
+
        if(event != NULL){
-               timestamp = bt_ctf_get_timestamp_raw(event); 
+               ((LttvTracesetPosition *)pos)->timestamp = bt_ctf_get_timestamp_raw(event); 
+               
+               LttvEvent lttv_event;
+               lttv_event.bt_event = event;
+               ((LttvTracesetPosition *)pos)->cpu_id = lttv_traceset_get_cpuid_from_event(&lttv_event);
+       }
+       else {
+               /* The event is null */
+               return 0;
        }
-        /* Reassign the previously saved position */
-        lttv_traceset_seek_to_position(&previous_pos);
-        /*We must desallocate because the function bt_iter_get_pos() does a g_new */
-        bt_iter_free_pos(previous_pos.bt_pos);
-       return timestamp;
+
+       /* Reassign the previously saved position */
+       lttv_traceset_seek_to_position(&previous_pos);
+       /*We must desallocate because the function bt_iter_get_pos() does a g_new */
+       bt_iter_free_pos(previous_pos.bt_pos);
+}
+
+guint64 lttv_traceset_position_get_timestamp(const LttvTracesetPosition *pos)
+{ 
+        if(pos->timestamp == G_MAXUINT64){
+                if(set_values_position(pos) == 0){
+                       return 0;
+               }
+        }
+        
+        return pos->timestamp;
+}
+
+int lttv_traceset_position_get_cpuid(const LttvTracesetPosition *pos){
+        if(pos->cpu_id == INT_MAX ){
+                 if(set_values_position(pos) == 0){
+                       return 0;
+               }
+        }
+        return pos->cpu_id;
 }
 
 LttTime  lttv_traceset_position_get_time(const LttvTracesetPosition *pos)
@@ -636,21 +667,13 @@ int lttv_traceset_position_compare(const LttvTracesetPosition *pos1, const LttvT
         
         guint64 timeStampPos1,timeStampPos2;
         guint cpuId1, cpuId2;
-        LttvEvent event1, event2;
-        int ret;
         
         timeStampPos1 = lttv_traceset_position_get_timestamp(pos1);
         timeStampPos2 = lttv_traceset_position_get_timestamp(pos2);
         
-        event1.bt_event = bt_ctf_iter_read_event(pos1->iter);
-        event2.bt_event = bt_ctf_iter_read_event(pos2->iter);
         
-        if(event1.bt_event == NULL || event2.bt_event == NULL){
-                return -1;
-       }
-
-        cpuId1 = lttv_traceset_get_cpuid_from_event(&event1);
-        cpuId2 = lttv_traceset_get_cpuid_from_event(&event2);
+        cpuId1 = lttv_traceset_position_get_cpuid(pos1);
+        cpuId2 = lttv_traceset_position_get_cpuid(pos2);
        
         if(timeStampPos1 == timeStampPos2 && cpuId1 == cpuId2){
                 return 0;
index 5f1323219a6f7d423de8e3f52aef72050cff2464..1c95569a8613e4421da0eb026ed25a433c9bc4c6 100644 (file)
@@ -1599,6 +1599,9 @@ static void event_update_selection(EventViewerData *event_viewer_data)
   guint i;
   GPtrArray *positions = event_viewer_data->pos;
   g_info("event_update_selection");
+  
+  int isFound = FALSE;
+  
 
   for(i=0;i<positions->len;i++) {
     LttvTracesetPosition *cur_pos = 
@@ -1611,10 +1614,26 @@ static void event_update_selection(EventViewerData *event_viewer_data)
                                     path, NULL, FALSE);
               gtk_widget_grab_focus(event_viewer_data->tree_v );
              gtk_tree_path_free(path);
+              isFound = TRUE;
               break;
                         }               
     }
   } 
+        if(isFound){
+          return;
+        }
+  /* If the current selection is not in the currently displayed events*/
+  LttTime currentTime = lttv_traceset_position_get_time(
+                                event_viewer_data->currently_selected_position);
+  LttTime time;
+  
+  LttvTraceset * ts = lttvwindow_get_traceset(event_viewer_data->tab);
+  TimeInterval time_span = lttv_traceset_get_time_span_real(ts);
+  time = ltt_time_sub(currentTime, time_span.start_time);
+  gtk_adjustment_set_value(event_viewer_data->vadjust_c,
+                                                ltt_time_to_double(time));
+  gtk_widget_grab_focus(event_viewer_data->tree_v );
+  
 }
 
 static int current_time_get_first_event_hook(void *hook_data, void *call_data)
index 53a1e5ab1334a49fa9e53d7aa77a6ecae086be28..9d42fc88e807afcf87b8d5c88e6b4b94bd862e8b 100644 (file)
@@ -1142,8 +1142,12 @@ __EXPORT gboolean lttvwindow_events_request_pending(Tab            *tab)
 {
   GSList *element = tab->events_requests;
 
-  if(element == NULL) return FALSE;
-  else return TRUE;
+  if(element == NULL){
+          return FALSE;
+  }
+  else {
+          return TRUE;
+  }
 }
 
 
This page took 0.028436 seconds and 4 git commands to generate.