From: Francis Deslauriers Date: Wed, 18 Jul 2012 20:01:17 +0000 (-0400) Subject: Add member timestamp and cpuid to LttvTracesetPosition to improve the comparaison... X-Git-Tag: v1.5-beta1~50 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=c73ce169d9ddd488b2dbee4d6062b75814e379e0;p=lttv.git Add member timestamp and cpuid to LttvTracesetPosition to improve the comparaison processing Signed-off-by: Francis Deslauriers Signed-off-by: Yannick Brosseau --- diff --git a/lttv/lttv/state.c b/lttv/lttv/state.c index a2f609f5..67ba3025 100644 --- a/lttv/lttv/state.c +++ b/lttv/lttv/state.c @@ -31,6 +31,7 @@ #include #include #include +#include #define PREALLOCATED_EXECUTION_STACK 10 diff --git a/lttv/lttv/traceset-process.c b/lttv/lttv/traceset-process.c index b49542f9..02b01418 100644 --- a/lttv/lttv/traceset-process.c +++ b/lttv/lttv/traceset-process.c @@ -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); diff --git a/lttv/lttv/traceset.c b/lttv/lttv/traceset.c index 54210160..10108f3c 100644 --- a/lttv/lttv/traceset.c +++ b/lttv/lttv/traceset.c @@ -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(<tv_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; diff --git a/lttv/modules/gui/detailedevents/events.c b/lttv/modules/gui/detailedevents/events.c index 5f132321..1c95569a 100644 --- a/lttv/modules/gui/detailedevents/events.c +++ b/lttv/modules/gui/detailedevents/events.c @@ -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;ilen;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) diff --git a/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c b/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c index 53a1e5ab..9d42fc88 100644 --- a/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c +++ b/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c @@ -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; + } }