From: Francis Deslauriers Date: Mon, 6 Aug 2012 15:37:29 +0000 (-0400) Subject: Rework of lttv_traceset_get_time_span_real function to take advantage of the seek_las... X-Git-Tag: v1.5-beta1~48 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8924e3e4b9f77267572f4fe0d4430748c27e66ea;p=lttv.git Rework of lttv_traceset_get_time_span_real function to take advantage of the seek_last iterator. Signed-off-by: Francis Deslauriers Signed-off-by: Yannick Brosseau --- diff --git a/lttv/lttv/traceset.c b/lttv/lttv/traceset.c index 10108f3c..b40ca4e7 100644 --- a/lttv/lttv/traceset.c +++ b/lttv/lttv/traceset.c @@ -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) diff --git a/lttv/lttv/traceset.h b/lttv/lttv/traceset.h index 4b998ad2..5d57ca44 100644 --- a/lttv/lttv/traceset.h +++ b/lttv/lttv/traceset.h @@ -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 { diff --git a/lttv/modules/gui/controlflow/drawing.c b/lttv/modules/gui/controlflow/drawing.c index fd133383..c53f5f1a 100644 --- a/lttv/modules/gui/controlflow/drawing.c +++ b/lttv/modules/gui/controlflow/drawing.c @@ -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 diff --git a/lttv/modules/gui/controlflow/eventhooks.c b/lttv/modules/gui/controlflow/eventhooks.c index aae0f79c..70ce458d 100644 --- a/lttv/modules/gui/controlflow/eventhooks.c +++ b/lttv/modules/gui/controlflow/eventhooks.c @@ -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; } diff --git a/lttv/modules/gui/detailedevents/events.c b/lttv/modules/gui/detailedevents/events.c index 1c95569a..d97de5f0 100644 --- a/lttv/modules/gui/detailedevents/events.c +++ b/lttv/modules/gui/detailedevents/events.c @@ -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); diff --git a/lttv/modules/gui/histogram/histoeventhooks.c b/lttv/modules/gui/histogram/histoeventhooks.c index 46aeca52..4c11cf3d 100644 --- a/lttv/modules/gui/histogram/histoeventhooks.c +++ b/lttv/modules/gui/histogram/histoeventhooks.c @@ -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; diff --git a/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c b/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c index b3700268..872cd75b 100644 --- a/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -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);