X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt-newlib%2Ftracefile.c;h=312829c9601cbc163989154dac4cc07095c84c14;hb=ea45889aea3f0b25ddd071d82261a733f492e9f1;hp=e0f88554ee87e065185a439535e122e32f6bf729;hpb=54ecbf38947e9b647b11a58b27cf65d3c0985693;p=lttv.git diff --git a/ltt/branches/poly/ltt-newlib/tracefile.c b/ltt/branches/poly/ltt-newlib/tracefile.c index e0f88554..312829c9 100644 --- a/ltt/branches/poly/ltt-newlib/tracefile.c +++ b/ltt/branches/poly/ltt-newlib/tracefile.c @@ -1177,7 +1177,20 @@ void ltt_tracefile_seek_time(LttTracefile *tf, LttTime time) g_error("Can not map block"); goto fail; } - if(ltt_time_compare(time, tf->buffer.start.timestamp) < 0) { + if(high == low) { + /* We cannot divide anymore : this is what would happen if the time + * requested was exactly between two consecutive buffers'end and start + * timestamps. This is also what would happend if we didn't deal with out + * of span cases prior in this function. */ + /* The event is right in the buffer! + * (or in the next buffer first event) */ + while(1) { + ltt_tracefile_read(tf); + if(ltt_time_compare(time, tf->event.event_time) >= 0) + break; + } + + } if(ltt_time_compare(time, tf->buffer.start.timestamp) < 0) { /* go to lower part */ high = block_num; } else if(ltt_time_compare(time, tf->buffer.end.timestamp) > 0) { @@ -1346,6 +1359,13 @@ LttEvent *ltt_tracefile_read(LttTracefile *tf) g_error("Can not map block"); return NULL; } + /* seek to the first event */ + err = ltt_seek_next_event(tf); + if(unlikely(err == ERANGE)) { + g_error("event id is out of range\n"); + return NULL; + } + pos = tf->event.offset; } }