[ltt-dev] [BABELTRACE PATCH] Basic seek support
Julien Desfossez
julien.desfossez at polymtl.ca
Fri Sep 2 10:45:39 EDT 2011
For now just mimic the previous behaviour of babeltrace but with a basic
seek structure.
Signed-off-by: Julien Desfossez <julien.desfossez at polymtl.ca>
---
converter/babeltrace-lib.c | 33 +++++++++++++++++++++++++--------
1 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/converter/babeltrace-lib.c b/converter/babeltrace-lib.c
index d078a69..76e5093 100644
--- a/converter/babeltrace-lib.c
+++ b/converter/babeltrace-lib.c
@@ -156,7 +156,6 @@ int stream_compare(void *a, void *b)
return 0;
}
-/* TODO: use begin_pos/end_pos */
struct babeltrace_iter *babeltrace_iter_create(struct trace_collection *tc,
struct trace_collection_pos *begin_pos,
struct trace_collection_pos *end_pos)
@@ -170,6 +169,7 @@ struct babeltrace_iter *babeltrace_iter_create(struct trace_collection *tc,
goto error_malloc;
iter->stream_heap = g_new(struct ptr_heap, 1);
iter->tc = tc;
+ iter->end_pos = end_pos;
ret = heap_init(iter->stream_heap, 0, stream_compare);
if (ret < 0)
@@ -198,12 +198,27 @@ struct babeltrace_iter *babeltrace_iter_create(struct trace_collection *tc,
file_stream = g_ptr_array_index(stream->streams,
filenr);
- ret = stream_read_event(file_stream);
- if (ret == EOF) {
- ret = 0;
- continue;
- } else if (ret) {
- goto error;
+ if (begin_pos) {
+ switch (begin_pos->type) {
+ case BT_SEEK_CUR:
+ /* just insert into the heap we should already know the timestamps */
+ break;
+ case BT_SEEK_BEGIN:
+ file_stream->pos.cur_index = 0;
+ ret = stream_read_event(file_stream);
+ if (ret == EOF) {
+ ret = 0;
+ continue;
+ } else if (ret) {
+ goto error;
+ }
+ break;
+ case BT_SEEK_TIME:
+ case BT_SEEK_RESTORE:
+ case BT_SEEK_END:
+ default:
+ assert(0); /* Not yet defined */
+ }
}
/* Add to heap */
ret = heap_insert(iter->stream_heap, file_stream);
@@ -286,12 +301,14 @@ int convert_trace(struct trace_descriptor *td_write,
struct ctf_stream *stream;
struct ctf_stream_event *event;
struct ctf_text_stream_pos *sout;
+ struct trace_collection_pos begin_pos;
int ret = 0;
sout = container_of(td_write, struct ctf_text_stream_pos,
trace_descriptor);
- iter = babeltrace_iter_create(trace_collection_read, NULL, NULL);
+ begin_pos.type = BT_SEEK_BEGIN;
+ iter = babeltrace_iter_create(trace_collection_read, &begin_pos, NULL);
while (babeltrace_iter_read_event(iter, &stream, &event) == 0) {
ret = sout->parent.event_cb(&sout->parent, stream);
if (ret) {
--
1.7.4.1
More information about the lttng-dev
mailing list