- struct ctf_stream_pos *pos;
- struct ctf_file_stream *file_stream;
- struct packet_index packet_index;
- int ret;
-
- pos = ctf_pos(stream_pos);
- file_stream = container_of(pos, struct ctf_file_stream, pos);
-
- fprintf(stderr, "BT GET_NEXT_INDEX %d\n", pos->fd);
- ret = get_next_index(pos->fd, &packet_index);
- if (ret < 0) {
- fprintf(stderr, "get_next_index failed\n");
- return;
- }
-
- pos->packet_size = packet_index.packet_size;
- pos->content_size = packet_index.content_size;
- pos->mmap_base_offset = 0;
- pos->offset = 0;
- if (packet_index.offset == EOF) {
- pos->offset = EOF;
- } else {
- pos->offset = 0;
- }
-
- file_stream->parent.cycles_timestamp = packet_index.timestamp_end;
- file_stream->parent.real_timestamp = ctf_get_real_timestamp(
- &file_stream->parent, packet_index.timestamp_end);
-
- if (pos->packet_size == 0) {
- goto end;
- }
-
- fprintf(stderr, "BT GET_DATA_PACKET\n");
- ret = get_data_packet(pos->fd, be64toh(packet_index.offset),
- packet_index.packet_size / CHAR_BIT);
- if (ret < 0) {
- fprintf(stderr, "get_data_packet failed");
- return;
- }
-
- fprintf(stderr, "BT MMAP %d\n", pos->fd);
- fprintf(stderr, "packet_size : %lu, offset %lu, content_size %lu, timestamp_end : %lu, real : %lu\n",
- packet_index.packet_size,
- packet_index.offset,
- packet_index.content_size,
- packet_index.timestamp_end,
- ctf_get_real_timestamp(
- &file_stream->parent, packet_index.timestamp_end));
- if (!pos->base_mma) {
- pos->base_mma = zmalloc(sizeof(*pos->base_mma));
- if (!pos->base_mma) {
- fprintf(stderr, "alloc pos->base_mma\n");
- return;
- }
- }
-
- mmap_align_set_addr(pos->base_mma, session->streams[pos->fd].mmap_base);
- if (pos->base_mma == MAP_FAILED) {
- perror("Error mmaping");
- return;
- }
-
- /* update trace_packet_header and stream_packet_context */
- if (pos->prot != PROT_WRITE && file_stream->parent.trace_packet_header) {
- /* Read packet header */
- ret = generic_rw(&pos->parent, &file_stream->parent.trace_packet_header->p);
- assert(!ret);
- }
- if (pos->prot != PROT_WRITE && file_stream->parent.stream_packet_context) {
- /* Read packet context */
- ret = generic_rw(&pos->parent, &file_stream->parent.stream_packet_context->p);
- assert(!ret);
- }
-
-end:
- return;