Rework of lttv_traceset_get_time_span_real function to take advantage of the seek_las...
authorFrancis Deslauriers <francis.deslauriers@polymtl.ca>
Mon, 6 Aug 2012 15:37:29 +0000 (11:37 -0400)
committerYannick Brosseau <yannick.brosseau@gmail.com>
Mon, 13 Aug 2012 21:40:16 +0000 (17:40 -0400)
Signed-off-by: Francis Deslauriers <francis.deslauriers@polymtl.ca>
Signed-off-by: Yannick Brosseau <yannick.brosseau@gmail.com>
lttv/lttv/traceset.c
lttv/lttv/traceset.h
lttv/modules/gui/controlflow/drawing.c
lttv/modules/gui/controlflow/eventhooks.c
lttv/modules/gui/detailedevents/events.c
lttv/modules/gui/histogram/histoeventhooks.c
lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c

index 10108f3ceb76383f70752834713e9a42714f7470..b40ca4e7a50434b0baac0537b2bf5c2002237c60 100644 (file)
@@ -70,6 +70,9 @@ LttvTraceset *lttv_traceset_new(void)
        ts->state_trace_handle_index = g_ptr_array_new();
        ts->has_precomputed_states = FALSE;
 
+       ts->time_span.start_time = ltt_time_from_uint64(0);
+       ts->time_span.end_time = ltt_time_from_uint64(0);
+
        return ts;
 }
 
@@ -510,6 +513,21 @@ guint64 lttv_traceset_get_timestamp_first_event(LttvTraceset *ts)
         return lttv_traceset_position_get_timestamp(&begin_position);  
 }
 
+guint64 lttv_traceset_get_timestamp_last_event(LttvTraceset *ts)
+{
+       LttvTracesetPosition last_position;
+       struct bt_iter_pos pos;
+       last_position.bt_pos = &pos;
+       last_position.timestamp = G_MAXUINT64;
+       last_position.cpu_id = INT_MAX;
+       
+       /* Assign iterator to the last event of the traces */  
+       last_position.bt_pos->type = BT_SEEK_LAST;
+       last_position.iter = ts->iter;
+
+       return lttv_traceset_position_get_timestamp(&last_position);
+}
+
 /*
  * lttv_traceset_get_timestamp_begin : returns the  minimum timestamp of 
  * all the traces in the traceset.
@@ -564,7 +582,7 @@ guint64 lttv_traceset_get_timestamp_end(LttvTraceset *traceset)
                {
                        currentTrace = g_ptr_array_index(traceset->traces,i);
                        timestamp_cur = bt_trace_handle_get_timestamp_end(bt_ctx,
-                                                                         currentTrace->id);
+                                                                       currentTrace->id);
                        if(timestamp_cur > timestamp_max){
                                timestamp_max = timestamp_cur;
                        }
@@ -574,28 +592,35 @@ guint64 lttv_traceset_get_timestamp_end(LttvTraceset *traceset)
 }
 /*
  * lttv_traceset_get_time_span_real : return a TimeInterval representing the
- * minimum timestamp dans le maximum timestamp of the traceset.
+ * minimum timestamp and the maximum timestamp of the traceset.
  * 
  */
 TimeInterval lttv_traceset_get_time_span_real(LttvTraceset *ts)
 {
-        TimeInterval time_span;
-        time_span.start_time =ltt_time_from_uint64(lttv_traceset_get_timestamp_first_event(ts));
-        time_span.end_time = ltt_time_from_uint64(lttv_traceset_get_timestamp_end(ts));
-        return time_span;
+       if(ltt_time_compare(ts->time_span.start_time, 
+                               ltt_time_from_uint64(0)) == 0 && ts->traces->len > 0){
+               ts->time_span.start_time = ltt_time_from_uint64(
+                               lttv_traceset_get_timestamp_first_event(ts));
+               ts->time_span.end_time = ltt_time_from_uint64(
+                               lttv_traceset_get_timestamp_last_event(ts));
+       }
+        return ts->time_span;
 }
 
 /*
  * lttv_traceset_get_time_span : return a TimeInterval representing the
- * minimum timestamp dans le maximum timestamp of the traceset.
+ * minimum timestamp and the maximum timestamp of the traceset.
  * 
  */
 TimeInterval lttv_traceset_get_time_span(LttvTraceset *ts)
 {
-        TimeInterval time_span;
-        time_span.start_time =ltt_time_from_uint64(lttv_traceset_get_timestamp_begin(ts));
-        time_span.end_time = ltt_time_from_uint64(lttv_traceset_get_timestamp_end(ts));
-        return time_span;
+       if(ltt_time_compare(ts->time_span.start_time, ltt_time_from_uint64(0)) == 0){
+               ts->time_span.start_time =ltt_time_from_uint64(
+                                       lttv_traceset_get_timestamp_begin(ts));
+               ts->time_span.end_time = ltt_time_from_uint64(
+                                       lttv_traceset_get_timestamp_end(ts));
+       }
+        return ts->time_span;
 }
 
 const char *lttv_traceset_get_name_from_event(LttvEvent *event)
index 4b998ad27dfc56fffa0204442fe57e32d7894764..5d57ca44ef1f7e8aa56917a37e9adc72c684de5d 100644 (file)
@@ -44,6 +44,7 @@ struct _LttvTraceset {
        struct bt_ctf_iter *iter;
        GPtrArray *state_trace_handle_index;
        gboolean has_precomputed_states;
+       TimeInterval time_span;
 };
 
 struct _LttvTrace {
index fd1333839ffeab0840f031f7644ed2f96d9f0631..c53f5f1ac2b23de2c534e335f5765c9485d2584c 100644 (file)
@@ -172,12 +172,12 @@ void drawing_data_request(Drawing_t *drawing,
  
        lttv_hooks_add(event_hook,before_execmode_hook , control_flow_data, LTTV_PRIO_STATE-5);
    #ifdef BABEL_CLEANUP     
-       lttv_hooks_add(event_hook,syscall_exit , control_flow_data, LTTV_PRIO_STATE);   
-       lttv_hooks_add(event_hook,irq_entry , control_flow_data, LTTV_PRIO_STATE);      
-       lttv_hooks_add(event_hook,irq_exit , control_flow_data, LTTV_PRIO_STATE);       
-       lttv_hooks_add(event_hook,soft_irq_raise , control_flow_data, LTTV_PRIO_STATE); 
-       lttv_hooks_add(event_hook,soft_irq_entry , control_flow_data, LTTV_PRIO_STATE); 
-       lttv_hooks_add(event_hook,soft_irq_exit , control_flow_data, LTTV_PRIO_STATE);  
+       lttv_hooks_add(event_hook,syscall_exit , control_flow_data, LTTV_PRIO_STATE);
+       lttv_hooks_add(event_hook,irq_entry , control_flow_data, LTTV_PRIO_STATE);
+       lttv_hooks_add(event_hook,irq_exit , control_flow_data, LTTV_PRIO_STATE);
+       lttv_hooks_add(event_hook,soft_irq_raise , control_flow_data, LTTV_PRIO_STATE);
+       lttv_hooks_add(event_hook,soft_irq_entry , control_flow_data, LTTV_PRIO_STATE);
+       lttv_hooks_add(event_hook,soft_irq_exit , control_flow_data, LTTV_PRIO_STATE);
 #endif //babel_cleanup
        lttv_hooks_add(event_hook,before_schedchange_hook , control_flow_data, LTTV_PRIO_STATE-5);      
 #ifdef BABEL_CLEANUP
index aae0f79c15580a6e497df7cb208e3212b9e125f7..70ce458d17074f7aece70ace81073db2a61ecd4a 100644 (file)
@@ -507,9 +507,9 @@ int before_schedchange_hook(void *hook_data, void *call_data)
   gint64 state_out;
   LttTime timestamp;
   event = (LttvEvent *) call_data;
-  if (strcmp(lttv_traceset_get_name_from_event(event),
-                                    "sched_switch") != 0)
-    return FALSE;
+  if (strcmp(lttv_traceset_get_name_from_event(event),"sched_switch") != 0)
+        return FALSE;
+  
   ControlFlowData *control_flow_data = (ControlFlowData*)hook_data;
 
 
@@ -519,11 +519,13 @@ int before_schedchange_hook(void *hook_data, void *call_data)
    */
   cpu = lttv_traceset_get_cpuid_from_event(event);
   ts = event->state;      
-  process = ts->running_process[cpu];
+  
   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
@@ -548,7 +550,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
               pid_out,
               process->cpu,
               &birth,
-              18);//TODO "use the right value or delete"
+              trace_number);
       if(hashed_process_data == NULL)
       {
         g_assert(pid_out == 0 || pid_out != process->ppid);
@@ -562,7 +564,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
             process->cpu,
             process->ppid,
             &birth,
-            18,//TODO "use the right value or delete"
+            trace_number,
             process->name,
             process->brand,
             &pl_height,
@@ -685,7 +687,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
      * 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.  */
-    process = ts->running_process[cpu];
+        process = lttv_state_find_process(ts,cpu,pid_in);
     
     if(process != NULL) {
       /* Well, the process existed : we must get it in the process hash
@@ -701,7 +703,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
               pid_in,
               cpu,
               &birth,
-              18);//TODO "use the right value or delete"
+              trace_number);//TODO "use the right value or delete"
       if(hashed_process_data == NULL)
       {
         g_assert(pid_in == 0 || pid_in != process->ppid);
@@ -715,7 +717,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
             cpu,
             process->ppid,
             &birth,
-            18,
+            trace_number,
             process->name,
             process->brand,
             &pl_height,
@@ -1016,6 +1018,7 @@ int before_execmode_hook(void *hook_data, void *call_data)
 {
   LttvEvent *event;
   guint cpu;
+  guint pid;
   LttvTraceState *ts;
   LttvProcessState *process;
   
@@ -1025,9 +1028,11 @@ int before_execmode_hook(void *hook_data, void *call_data)
    */
   
   event = (LttvEvent *) call_data;
-  if (strcmp(lttv_traceset_get_name_from_event(event),
-                            "irq_handler_entry") != 0)
-      return FALSE;
+  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 */
@@ -1037,7 +1042,7 @@ int before_execmode_hook(void *hook_data, void *call_data)
   ts = event->state;
   
   guint trace_number = 0;//TODO fdeslauriers 2012-07-17: // Use trace handle to know trace number
-  process = ts->running_process[cpu];
+  process = lttv_state_find_process(ts ,cpu ,pid);
   g_assert(process != NULL);
 
   guint pid = process->pid;
@@ -1197,7 +1202,7 @@ int before_execmode_hook(void *hook_data, void *call_data)
                              &hashed_process_data->next_good_time);
     }
   }
-  
+  }
   return 0;
 }
 
index 1c95569a8613e4421da0eb026ed25a433c9bc4c6..d97de5f0e252ca2de9bbe3047aacf0411af57785 100644 (file)
@@ -1721,7 +1721,7 @@ gboolean timespan_changed(void * hook_data, void * call_data)
        
   EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
   LttvTraceset * ts = lttvwindow_get_traceset(event_viewer_data->tab);
-  TimeInterval time_span = lttv_traceset_get_time_span(ts);
+  TimeInterval time_span = lttv_traceset_get_time_span_real(ts);
  
   LttTime end;
 
@@ -1743,7 +1743,7 @@ gboolean traceset_changed(void * hook_data, void * call_data)
 
   EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
   LttvTraceset * ts = lttvwindow_get_traceset(event_viewer_data->tab);
-  TimeInterval time_span = lttv_traceset_get_time_span(ts);
+  TimeInterval time_span = lttv_traceset_get_time_span_real(ts);
   
   LttTime end;
   gtk_list_store_clear(event_viewer_data->store_m);
index 46aeca526a94bf6717ae7a074138ef2d999d08c1..4c11cf3dcf252dd7f7e14e98a34532f9af0025e0 100644 (file)
@@ -634,7 +634,7 @@ gint histo_update_current_time_hook(void *hook_data, void *call_data)
 
   LttvTraceset *traceset =
         lttvwindow_get_traceset(histocontrol_flow_data->tab);
-  TimeInterval time_span = lttv_traceset_get_time_span(traceset);
+  TimeInterval time_span = lttv_traceset_get_time_span_real(traceset);
 
   LttTime trace_start = time_span.start_time;
   LttTime trace_end = time_span.end_time;
index b370026810f3f004f6e5703f2e86410cd3f6d9df..872cd75bbeb26f34310e80c0de71fe889b8f4f6d 100644 (file)
@@ -283,7 +283,7 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset)
   }
 #endif /*BABEL_CLEANUP*/
 
-  time_span = lttv_traceset_get_time_span(traceset);
+  time_span = lttv_traceset_get_time_span_real(traceset);
   
   tab->traceset_info->traceset = traceset;
   
@@ -3323,9 +3323,8 @@ void time_change_manager               (Tab *tab,
   TimeInterval time_span;
   
   LttvTraceset *ts = tab->traceset_info->traceset;
-  time_span.start_time =ltt_time_from_uint64( lttv_traceset_get_timestamp_begin(ts));
-  time_span.end_time = ltt_time_from_uint64(lttv_traceset_get_timestamp_end(ts));
   
+  time_span = lttv_traceset_get_time_span_real(ts);
 
   LttTime start_time = new_time_window.start_time;
   LttTime end_time = new_time_window.end_time;
@@ -3432,7 +3431,7 @@ static void on_timebar_starttime_changed(Timebar *timebar,
 {
        Tab *tab = (Tab *)user_data;
        LttvTraceset * ts =tab->traceset_info->traceset;
-       TimeInterval time_span = lttv_traceset_get_time_span(ts);
+       TimeInterval time_span = lttv_traceset_get_time_span_real(ts);
 
        TimeWindow new_time_window = tab->time_window;
        new_time_window.start_time = timebar_get_start_time(timebar);
@@ -3468,7 +3467,7 @@ static void on_timebar_endtime_changed(Timebar *timebar,
 {
        Tab *tab = (Tab *)user_data;
         LttvTraceset * ts =tab->traceset_info->traceset;
-        TimeInterval time_span = lttv_traceset_get_time_span(ts);
+        TimeInterval time_span = lttv_traceset_get_time_span_real(ts);
 
        TimeWindow new_time_window = tab->time_window;
 
@@ -3519,7 +3518,7 @@ void scroll_value_changed_cb(GtkWidget *scrollbar,
   gdouble page_size;
   
   LttvTraceset * ts = tab->traceset_info->traceset;
-  TimeInterval time_span = lttv_traceset_get_time_span(ts);
+  TimeInterval time_span = lttv_traceset_get_time_span_real(ts);
 
   time = ltt_time_add(ltt_time_from_double(value),
                       time_span.start_time);
This page took 0.033489 seconds and 4 git commands to generate.