struct ctf_file_stream *file_stream;
size_t cur_index; /* current index in packet index */
ssize_t offset; /* offset from base, in bits. EOF for end of file. */
- uint64_t current_timestamp;
+ uint64_t current_real_timestamp;
+ uint64_t current_cycles_timestamp;
};
struct bt_saved_pos {
/*
* returns true if a < b, false otherwise.
*/
-int stream_compare(void *a, void *b)
+static int stream_compare(void *a, void *b)
{
struct ctf_file_stream *s_a = a, *s_b = b;
- if (s_a->parent.timestamp < s_b->parent.timestamp)
+ if (s_a->parent.real_timestamp < s_b->parent.real_timestamp)
return 1;
else
return 0;
int i, ret;
stream_pos = &cfs->pos;
- for (i = 0; i < stream_pos->packet_index->len; i++) {
- index = &g_array_index(stream_pos->packet_index,
+ for (i = 0; i < stream_pos->packet_real_index->len; i++) {
+ index = &g_array_index(stream_pos->packet_real_index,
struct packet_index, i);
if (index->timestamp_end < timestamp)
continue;
stream_pos->packet_seek(&stream_pos->parent, i, SEEK_SET);
do {
ret = stream_read_event(cfs);
- } while (cfs->parent.timestamp < timestamp && ret == 0);
+ } while (cfs->parent.real_timestamp < timestamp && ret == 0);
/* Can return either EOF, 0, or error (> 0). */
return ret;
heap_free(iter->stream_heap);
ret = heap_init(iter->stream_heap, 0, stream_compare);
if (ret < 0)
- goto error;
+ goto error_heap_init;
for (i = 0; i < iter_pos->u.restore->stream_saved_pos->len;
i++) {
* packet_seek, because this function resets
* the timestamp to the beginning of the packet
*/
- stream->timestamp = saved_pos->current_timestamp;
+ stream->real_timestamp = saved_pos->current_real_timestamp;
+ stream->cycles_timestamp = saved_pos->current_cycles_timestamp;
stream_pos->offset = saved_pos->offset;
stream_pos->last_offset = LAST_OFFSET_POISON;
- stream->prev_timestamp = 0;
- stream->prev_timestamp_end = 0;
+ stream->prev_real_timestamp = 0;
+ stream->prev_real_timestamp_end = 0;
+ stream->prev_cycles_timestamp = 0;
+ stream->prev_cycles_timestamp_end = 0;
printf_debug("restored to cur_index = %zd and "
"offset = %zd, timestamp = %" PRIu64 "\n",
stream_pos->cur_index,
- stream_pos->offset, stream->timestamp);
+ stream_pos->offset, stream->real_timestamp);
stream_read_event(saved_pos->file_stream);
heap_free(iter->stream_heap);
ret = heap_init(iter->stream_heap, 0, stream_compare);
if (ret < 0)
- goto error;
+ goto error_heap_init;
/* for each trace in the trace_collection */
for (i = 0; i < tc->array->len; i++) {
heap_free(iter->stream_heap);
ret = heap_init(iter->stream_heap, 0, stream_compare);
if (ret < 0)
- goto error;
+ goto error_heap_init;
for (i = 0; i < tc->array->len; i++) {
struct ctf_trace *tin;
error:
heap_free(iter->stream_heap);
+error_heap_init:
if (heap_init(iter->stream_heap, 0, stream_compare) < 0) {
heap_free(iter->stream_heap);
g_free(iter->stream_heap);
iter->stream_heap = NULL;
ret = -ENOMEM;
}
+
return ret;
}
saved_pos.file_stream = file_stream;
saved_pos.cur_index = file_stream->pos.cur_index;
- saved_pos.current_timestamp = file_stream->parent.timestamp;
+ saved_pos.current_real_timestamp = file_stream->parent.real_timestamp;
+ saved_pos.current_cycles_timestamp = file_stream->parent.cycles_timestamp;
g_array_append_val(
pos->u.restore->stream_saved_pos,
"timestamp = %" PRIu64 "\n",
file_stream->parent.stream_id,
saved_pos.cur_index, saved_pos.offset,
- saved_pos.current_timestamp);
+ saved_pos.current_real_timestamp);
/* remove the stream from the heap copy */
removed = heap_remove(&iter_heap_copy);
heap_free(iter->stream_heap);
error_heap_init:
g_free(iter->stream_heap);
+ iter->stream_heap = NULL;
error_ctx:
return ret;
}