From: julien.desfossez@polymtl.ca (Julien Desfossez)
Subject: [ltt-dev] [BABELTRACE PATCH] Basic seek support
Date: Sun, 4 Sep 2011 14:00:41 -0400 [thread overview]
Message-ID: <1315159241-8221-1-git-send-email-julien.desfossez@polymtl.ca> (raw)
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..c8f71c0 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:
+ ctf_move_pos_slow(&file_stream->pos, 0, SEEK_SET);
+ 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
next reply other threads:[~2011-09-04 18:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-04 18:00 Julien Desfossez [this message]
2011-09-04 19:10 ` Mathieu Desnoyers
-- strict thread matches above, loose matches on Subject: below --
2011-09-12 15:18 Julien Desfossez
2011-09-13 17:57 ` Mathieu Desnoyers
2011-09-07 22:16 Julien Desfossez
2011-09-10 18:03 ` Mathieu Desnoyers
2011-09-02 14:45 Julien Desfossez
2011-09-03 13:55 ` Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1315159241-8221-1-git-send-email-julien.desfossez@polymtl.ca \
--to=julien.desfossez@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox