X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=lttv%2Flttv%2Ftraceset.c;h=8743d70825d54a51549a2f783373f78fca33ff68;hb=3200b7f3658f4098c45bdf54a667e44dccac8113;hp=b40ca4e7a50434b0baac0537b2bf5c2002237c60;hpb=8924e3e4b9f77267572f4fe0d4430748c27e66ea;p=lttv.git diff --git a/lttv/lttv/traceset.c b/lttv/lttv/traceset.c index b40ca4e7..8743d708 100644 --- a/lttv/lttv/traceset.c +++ b/lttv/lttv/traceset.c @@ -70,9 +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); - + ts->time_span.start_time = ltt_time_zero; + ts->time_span.end_time = ltt_time_zero; + lttv_traceset_get_time_span_real(ts); return ts; } @@ -520,7 +520,7 @@ guint64 lttv_traceset_get_timestamp_last_event(LttvTraceset *ts) 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; @@ -550,7 +550,8 @@ guint64 lttv_traceset_get_timestamp_begin(LttvTraceset *traceset) { currentTrace = g_ptr_array_index(traceset->traces,i); timestamp_cur = bt_trace_handle_get_timestamp_begin(bt_ctx, - currentTrace->id); + currentTrace->id, + BT_CLOCK_REAL); if(timestamp_cur < timestamp_min) timestamp_min = timestamp_cur; } @@ -582,7 +583,8 @@ 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, + BT_CLOCK_REAL); if(timestamp_cur > timestamp_max){ timestamp_max = timestamp_cur; } @@ -597,12 +599,14 @@ guint64 lttv_traceset_get_timestamp_end(LttvTraceset *traceset) */ TimeInterval lttv_traceset_get_time_span_real(LttvTraceset *ts) { + + if(ltt_time_compare(ts->time_span.start_time, - ltt_time_from_uint64(0)) == 0 && ts->traces->len > 0){ + ltt_time_zero) == 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)); + lttv_traceset_get_timestamp_last_event(ts)); } return ts->time_span; } @@ -614,7 +618,7 @@ TimeInterval lttv_traceset_get_time_span_real(LttvTraceset *ts) */ TimeInterval lttv_traceset_get_time_span(LttvTraceset *ts) { - if(ltt_time_compare(ts->time_span.start_time, ltt_time_from_uint64(0)) == 0){ + if(ltt_time_compare(ts->time_span.start_time, ltt_time_zero) == 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( @@ -639,7 +643,7 @@ int set_values_position(const LttvTracesetPosition *pos) struct bt_ctf_event *event = bt_ctf_iter_read_event(pos->iter); if(event != NULL){ - ((LttvTracesetPosition *)pos)->timestamp = bt_ctf_get_timestamp_raw(event); + ((LttvTracesetPosition *)pos)->timestamp = bt_ctf_get_timestamp(event); LttvEvent lttv_event; lttv_event.bt_event = event; @@ -654,6 +658,10 @@ int set_values_position(const LttvTracesetPosition *pos) 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); + if (pos->timestamp == G_MAXUINT64) { + return 0; + } + return 1; } guint64 lttv_traceset_position_get_timestamp(const LttvTracesetPosition *pos) @@ -682,29 +690,37 @@ LttTime lttv_traceset_position_get_time(const LttvTracesetPosition *pos) } - +/* 0 if equals, other is different */ int lttv_traceset_position_compare(const LttvTracesetPosition *pos1, const LttvTracesetPosition *pos2) { #warning " TODO :Rename for lttv_traceset_position_equals && Must return COMPARAISON OF THE 2 POSITION && verify if it is the best way to compare position" if(pos1 == NULL || pos2 == NULL){ return -1; } - - guint64 timeStampPos1,timeStampPos2; - guint cpuId1, cpuId2; - - timeStampPos1 = lttv_traceset_position_get_timestamp(pos1); - timeStampPos2 = lttv_traceset_position_get_timestamp(pos2); - - - cpuId1 = lttv_traceset_position_get_cpuid(pos1); - cpuId2 = lttv_traceset_position_get_cpuid(pos2); - - if(timeStampPos1 == timeStampPos2 && cpuId1 == cpuId2){ - return 0; - } - else{ - return 1; + + int res = bt_iter_equals_pos(pos1->bt_pos, pos2->bt_pos); + + if (res < 0) { + + guint64 timeStampPos1,timeStampPos2; + guint cpuId1, cpuId2; + + timeStampPos1 = lttv_traceset_position_get_timestamp(pos1); + timeStampPos2 = lttv_traceset_position_get_timestamp(pos2); + + + cpuId1 = lttv_traceset_position_get_cpuid(pos1); + cpuId2 = lttv_traceset_position_get_cpuid(pos2); + + if(timeStampPos1 == timeStampPos2 && cpuId1 == cpuId2){ + return 0; + } + else{ + return 1; + } + } else { + + return !res; } }