#include <babeltrace/ctf/events-internal.h>
#include <babeltrace/trace-handle-internal.h>
#include <babeltrace/context-internal.h>
-#include <babeltrace/uuid.h>
+#include <babeltrace/compat/uuid.h>
#include <babeltrace/endian.h>
#include <inttypes.h>
#include <stdio.h>
#include "metadata/ctf-parser.h"
#include "metadata/ctf-ast.h"
#include "events-private.h"
-#include "memstream.h"
+#include <babeltrace/compat/memstream.h>
#define LOG2_CHAR_BIT 3
/*
* for SEEK_CUR: go to next packet.
- * for SEEK_POS: go to packet numer (index).
+ * for SEEK_SET: go to packet numer (index).
*/
void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence)
{
pos->offset = 0;
} else {
read_next_packet:
- if (pos->cur_index >= pos->packet_cycles_index->len) {
- pos->offset = EOF;
- return;
- }
- if (pos->cur_index >= pos->packet_real_index->len) {
- pos->offset = EOF;
- return;
- }
switch (whence) {
case SEEK_CUR:
{
if (pos->offset == EOF) {
return;
}
+ assert(pos->cur_index < pos->packet_cycles_index->len);
+ assert(pos->cur_index < pos->packet_real_index->len);
+
/* For printing discarded event count */
packet_index = &g_array_index(pos->packet_cycles_index,
struct packet_index, pos->cur_index);
break;
}
case SEEK_SET:
+ if (index >= pos->packet_cycles_index->len) {
+ pos->offset = EOF;
+ return;
+ }
packet_index = &g_array_index(pos->packet_cycles_index,
struct packet_index, index);
pos->last_events_discarded = packet_index->events_discarded;