ctf: remove now unused files
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 23 Aug 2022 14:52:58 +0000 (10:52 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 23 Aug 2022 16:06:16 +0000 (12:06 -0400)
Change-Id: Ib66be547edae247049f4d5b0a21233a7c68e0811
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8649
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
24 files changed:
configure.ac
src/plugins/ctf/common/src/Makefile.am
src/plugins/ctf/common/src/bfcr/Makefile.am [deleted file]
src/plugins/ctf/common/src/bfcr/bfcr.cpp [deleted file]
src/plugins/ctf/common/src/bfcr/bfcr.hpp [deleted file]
src/plugins/ctf/common/src/bfcr/btr.gdb [deleted file]
src/plugins/ctf/common/src/metadata/tsdl/Makefile.am
src/plugins/ctf/common/src/metadata/tsdl/ast.hpp
src/plugins/ctf/common/src/metadata/tsdl/ctf-1-metadata-stream-parser.cpp
src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-configure-ir-trace.cpp
src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-translate.cpp [deleted file]
src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-in-ir.cpp [deleted file]
src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-stream-class-config.cpp [deleted file]
src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-value-storing-indexes.cpp [deleted file]
src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-visitors.hpp
src/plugins/ctf/common/src/metadata/tsdl/ctf-meta.hpp
src/plugins/ctf/common/src/metadata/tsdl/decoder-packetized-file-stream-to-buf.cpp [deleted file]
src/plugins/ctf/common/src/metadata/tsdl/decoder-packetized-file-stream-to-buf.hpp [deleted file]
src/plugins/ctf/common/src/metadata/tsdl/decoder.cpp [deleted file]
src/plugins/ctf/common/src/metadata/tsdl/decoder.hpp [deleted file]
src/plugins/ctf/common/src/metadata/tsdl/visitor-generate-ir.cpp
src/plugins/ctf/common/src/msg-iter/Makefile.am [deleted file]
src/plugins/ctf/common/src/msg-iter/msg-iter.cpp [deleted file]
src/plugins/ctf/common/src/msg-iter/msg-iter.hpp [deleted file]

index 8cdf43c38fbd646a103c5bc21dfac8d753b61a37..25c34f53c9c15ad04d634575b4c0cf29655ccb05 100644 (file)
@@ -818,13 +818,11 @@ AC_CONFIG_FILES([
   src/plugins/common/param-validation/Makefile
   src/plugins/ctf/common/Makefile
   src/plugins/ctf/common/metadata/Makefile
-  src/plugins/ctf/common/src/bfcr/Makefile
   src/plugins/ctf/common/src/item-seq/Makefile
   src/plugins/ctf/common/src/Makefile
   src/plugins/ctf/common/src/metadata/json/Makefile
   src/plugins/ctf/common/src/metadata/Makefile
   src/plugins/ctf/common/src/metadata/tsdl/Makefile
-  src/plugins/ctf/common/src/msg-iter/Makefile
   src/plugins/ctf/fs-sink/Makefile
   src/plugins/ctf/fs-src/Makefile
   src/plugins/ctf/lttng-live/Makefile
index 739fdc2731207e634bc3fadce9efe1542d311e38..694ca976d0bf77622701b17cb4da153154fa458a 100644 (file)
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: MIT
 
-SUBDIRS = metadata bfcr msg-iter item-seq
+SUBDIRS = metadata item-seq
 
 noinst_LTLIBRARIES = libbabeltrace2-plugin-ctf-common-src.la
 
@@ -13,6 +13,4 @@ libbabeltrace2_plugin_ctf_common_src_la_SOURCES = \
 
 libbabeltrace2_plugin_ctf_common_src_la_LIBADD =       \
        $(builddir)/metadata/libctf-src-metadata.la     \
-       $(builddir)/bfcr/libctf-bfcr.la                 \
-       $(builddir)/msg-iter/libctf-msg-iter.la         \
        $(builddir)/item-seq/libctf-src-item-seq.la
diff --git a/src/plugins/ctf/common/src/bfcr/Makefile.am b/src/plugins/ctf/common/src/bfcr/Makefile.am
deleted file mode 100644 (file)
index 17b7705..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: MIT
-
-noinst_LTLIBRARIES = libctf-bfcr.la
-libctf_bfcr_la_SOURCES = \
-       bfcr.cpp \
-       bfcr.hpp
diff --git a/src/plugins/ctf/common/src/bfcr/bfcr.cpp b/src/plugins/ctf/common/src/bfcr/bfcr.cpp
deleted file mode 100644 (file)
index a2532fd..0000000
+++ /dev/null
@@ -1,1262 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (c) 2015-2016 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2015-2016 Philippe Proulx <pproulx@efficios.com>
- *
- * Babeltrace - CTF binary field class reader (BFCR)
- */
-
-#define BT_CLOG_CFG (bfcr->logCfg)
-#define BT_LOG_TAG  "PLUGIN/CTF/BFCR"
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <stdbool.h>
-#include "common/assert.h"
-#include <string.h>
-#include "compat/bitfield.h"
-#include "common/common.h"
-#include <babeltrace2/babeltrace.h>
-#include "common/align.h"
-#include <glib.h>
-
-#include "bfcr.hpp"
-#include "../metadata/tsdl/ctf-meta.hpp"
-#include "cpp-common/log-cfg.hpp"
-#include "cpp-common/cfg-logging.hpp"
-
-#define DIV8(_x)                ((_x) >> 3)
-#define BYTES_TO_BITS(_x)       ((_x) *8)
-#define BITS_TO_BYTES_FLOOR(_x) DIV8(_x)
-#define BITS_TO_BYTES_CEIL(_x)  DIV8((_x) + 7)
-#define IN_BYTE_OFFSET(_at)     ((_at) &7)
-
-/* A visit stack entry */
-struct stack_entry
-{
-    /*
-     * Current class of base field, one of:
-     *
-     *   * Structure
-     *   * Array
-     *   * Sequence
-     *   * Variant
-     */
-    struct ctf_field_class *base_class;
-
-    /* Length of base field (always 1 for a variant class) */
-    int64_t base_len;
-
-    /* Index of next field to read */
-    int64_t index;
-};
-
-struct bt_bfcr;
-
-/* Visit stack */
-struct stack
-{
-    struct bt_bfcr *bfcr;
-
-    /* Entries (struct stack_entry) */
-    GArray *entries;
-
-    /* Number of active entries */
-    size_t size;
-};
-
-/* Reading states */
-enum bfcr_state
-{
-    BFCR_STATE_NEXT_FIELD,
-    BFCR_STATE_ALIGN_BASIC,
-    BFCR_STATE_ALIGN_COMPOUND,
-    BFCR_STATE_READ_BASIC_BEGIN,
-    BFCR_STATE_READ_BASIC_CONTINUE,
-    BFCR_STATE_DONE,
-};
-
-/* Binary class reader */
-struct bt_bfcr
-{
-    explicit bt_bfcr(const bt2_common::LogCfg& logCfgParam) noexcept : logCfg {logCfgParam}
-    {
-    }
-
-    const bt2_common::LogCfg logCfg;
-
-    /* BFCR stack */
-    struct stack *stack;
-
-    /* Current basic field class */
-    struct ctf_field_class *cur_basic_field_class;
-
-    /* Current state */
-    enum bfcr_state state;
-
-    /*
-     * Last basic field class's byte order.
-     *
-     * This is used to detect errors since two contiguous basic
-     * classes for which the common boundary is not the boundary of
-     * a byte cannot have different byte orders.
-     *
-     * This is set to CTF_BYTE_ORDER_UNKNOWN on reset and when the last
-     * basic field class was a string class.
-     */
-    enum ctf_byte_order last_bo;
-
-    /* Current byte order (copied to last_bo after a successful read) */
-    enum ctf_byte_order cur_bo;
-
-    /* Stitch buffer infos */
-    struct
-    {
-        /* Stitch buffer */
-        uint8_t buf[16];
-
-        /* Offset, within stitch buffer, of first bit */
-        size_t offset;
-
-        /* Length (bits) of data in stitch buffer from offset */
-        size_t at;
-    } stitch;
-
-    /* User buffer infos */
-    struct
-    {
-        /* Address */
-        const uint8_t *addr;
-
-        /* Offset of data from address (bits) */
-        size_t offset;
-
-        /* Current position from offset (bits) */
-        size_t at;
-
-        /* Offset of offset within whole packet (bits) */
-        size_t packet_offset;
-
-        /* Data size in buffer (bits) */
-        size_t sz;
-
-        /* Buffer size (bytes) */
-        size_t buf_sz;
-    } buf;
-
-    /* User stuff */
-    struct
-    {
-        /* Callback functions */
-        struct bt_bfcr_cbs cbs;
-
-        /* Private data */
-        void *data;
-    } user;
-};
-
-static inline const char *bfcr_state_string(enum bfcr_state state)
-{
-    switch (state) {
-    case BFCR_STATE_NEXT_FIELD:
-        return "NEXT_FIELD";
-    case BFCR_STATE_ALIGN_BASIC:
-        return "ALIGN_BASIC";
-    case BFCR_STATE_ALIGN_COMPOUND:
-        return "ALIGN_COMPOUND";
-    case BFCR_STATE_READ_BASIC_BEGIN:
-        return "READ_BASIC_BEGIN";
-    case BFCR_STATE_READ_BASIC_CONTINUE:
-        return "READ_BASIC_CONTINUE";
-    case BFCR_STATE_DONE:
-        return "DONE";
-    }
-
-    bt_common_abort();
-}
-
-static struct stack *stack_new(struct bt_bfcr *bfcr)
-{
-    struct stack *stack = NULL;
-
-    stack = g_new0(struct stack, 1);
-    if (!stack) {
-        BT_CLOGE_STR("Failed to allocate one stack.");
-        goto error;
-    }
-
-    stack->bfcr = bfcr;
-    stack->entries = g_array_new(FALSE, TRUE, sizeof(struct stack_entry));
-    if (!stack->entries) {
-        BT_CLOGE_STR("Failed to allocate a GArray.");
-        goto error;
-    }
-
-    BT_CLOGD("Created stack: addr=%p", stack);
-    return stack;
-
-error:
-    g_free(stack);
-    return NULL;
-}
-
-static void stack_destroy(struct stack *stack)
-{
-    struct bt_bfcr *bfcr;
-
-    if (!stack) {
-        return;
-    }
-
-    bfcr = stack->bfcr;
-    BT_CLOGD("Destroying stack: addr=%p", stack);
-
-    if (stack->entries) {
-        g_array_free(stack->entries, TRUE);
-    }
-
-    g_free(stack);
-}
-
-static int stack_push(struct stack *stack, struct ctf_field_class *base_class, size_t base_len)
-{
-    struct stack_entry *entry;
-    struct bt_bfcr *bfcr;
-
-    BT_ASSERT_DBG(stack);
-    BT_ASSERT_DBG(base_class);
-    bfcr = stack->bfcr;
-    BT_CLOGT("Pushing field class on stack: stack-addr=%p, "
-             "fc-addr=%p, fc-type=%d, base-length=%zu, "
-             "stack-size-before=%zu, stack-size-after=%zu",
-             stack, base_class, base_class->type, base_len, stack->size, stack->size + 1);
-
-    if (stack->entries->len == stack->size) {
-        g_array_set_size(stack->entries, stack->size + 1);
-    }
-
-    entry = &g_array_index(stack->entries, struct stack_entry, stack->size);
-    entry->base_class = base_class;
-    entry->base_len = base_len;
-    entry->index = 0;
-    stack->size++;
-    return 0;
-}
-
-static inline int64_t get_compound_field_class_length(struct bt_bfcr *bfcr,
-                                                      struct ctf_field_class *fc)
-{
-    int64_t length;
-
-    switch (fc->type) {
-    case CTF_FIELD_CLASS_TYPE_STRUCT:
-    {
-        ctf_field_class_struct *struct_fc = ctf_field_class_as_struct(fc);
-
-        length = (int64_t) struct_fc->members->len;
-        break;
-    }
-    case CTF_FIELD_CLASS_TYPE_VARIANT:
-    {
-        /* Variant field classes always "contain" a single class */
-        length = 1;
-        break;
-    }
-    case CTF_FIELD_CLASS_TYPE_ARRAY:
-    {
-        struct ctf_field_class_array *array_fc = ctf_field_class_as_array(fc);
-
-        length = (int64_t) array_fc->length;
-        break;
-    }
-    case CTF_FIELD_CLASS_TYPE_SEQUENCE:
-        length = bfcr->user.cbs.query.get_sequence_length(fc, bfcr->user.data);
-        break;
-    default:
-        bt_common_abort();
-    }
-
-    return length;
-}
-
-static int stack_push_with_len(struct bt_bfcr *bfcr, struct ctf_field_class *base_class)
-{
-    int ret;
-    int64_t length = get_compound_field_class_length(bfcr, base_class);
-
-    if (length < 0) {
-        BT_CLOGW("Cannot get compound field class's field count: "
-                 "bfcr-addr=%p, fc-addr=%p, fc-type=%d",
-                 bfcr, base_class, base_class->type);
-        ret = BT_BFCR_STATUS_ERROR;
-        goto end;
-    }
-
-    ret = stack_push(bfcr->stack, base_class, (size_t) length);
-
-end:
-    return ret;
-}
-
-static inline unsigned int stack_size(struct stack *stack)
-{
-    BT_ASSERT_DBG(stack);
-    return stack->size;
-}
-
-static void stack_pop(struct stack *stack)
-{
-    struct bt_bfcr *bfcr;
-
-    BT_ASSERT_DBG(stack);
-    BT_ASSERT_DBG(stack_size(stack));
-    bfcr = stack->bfcr;
-    BT_CLOGT("Popping from stack: "
-             "stack-addr=%p, stack-size-before=%u, stack-size-after=%u",
-             stack, stack->entries->len, stack->entries->len - 1);
-    stack->size--;
-}
-
-static inline bool stack_empty(struct stack *stack)
-{
-    return stack_size(stack) == 0;
-}
-
-static void stack_clear(struct stack *stack)
-{
-    BT_ASSERT_DBG(stack);
-    stack->size = 0;
-}
-
-static inline struct stack_entry *stack_top(struct stack *stack)
-{
-    BT_ASSERT_DBG(stack);
-    BT_ASSERT_DBG(stack_size(stack));
-    return &g_array_index(stack->entries, struct stack_entry, stack->size - 1);
-}
-
-static inline size_t available_bits(struct bt_bfcr *bfcr)
-{
-    return bfcr->buf.sz - bfcr->buf.at;
-}
-
-static inline void consume_bits(struct bt_bfcr *bfcr, size_t incr)
-{
-    BT_CLOGT("Advancing cursor: bfcr-addr=%p, cur-before=%zu, cur-after=%zu", bfcr, bfcr->buf.at,
-             bfcr->buf.at + incr);
-    bfcr->buf.at += incr;
-}
-
-static inline bool has_enough_bits(struct bt_bfcr *bfcr, size_t sz)
-{
-    return available_bits(bfcr) >= sz;
-}
-
-static inline bool at_least_one_bit_left(struct bt_bfcr *bfcr)
-{
-    return has_enough_bits(bfcr, 1);
-}
-
-static inline size_t packet_at(struct bt_bfcr *bfcr)
-{
-    return bfcr->buf.packet_offset + bfcr->buf.at;
-}
-
-static inline size_t buf_at_from_addr(struct bt_bfcr *bfcr)
-{
-    /*
-     * Considering this:
-     *
-     *     ====== offset ===== (17)
-     *
-     *     xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
-     *     ^
-     *     addr (0)           ==== at ==== (12)
-     *
-     * We want this:
-     *
-     *     =============================== (29)
-     */
-    return bfcr->buf.offset + bfcr->buf.at;
-}
-
-static void stitch_reset(struct bt_bfcr *bfcr)
-{
-    bfcr->stitch.offset = 0;
-    bfcr->stitch.at = 0;
-}
-
-static inline size_t stitch_at_from_addr(struct bt_bfcr *bfcr)
-{
-    return bfcr->stitch.offset + bfcr->stitch.at;
-}
-
-static void stitch_append_from_buf(struct bt_bfcr *bfcr, size_t sz)
-{
-    size_t stitch_byte_at;
-    size_t buf_byte_at;
-    size_t nb_bytes;
-
-    if (sz == 0) {
-        return;
-    }
-
-    stitch_byte_at = BITS_TO_BYTES_FLOOR(stitch_at_from_addr(bfcr));
-    buf_byte_at = BITS_TO_BYTES_FLOOR(buf_at_from_addr(bfcr));
-    nb_bytes = BITS_TO_BYTES_CEIL(sz);
-    BT_ASSERT(nb_bytes > 0);
-    BT_ASSERT(bfcr->buf.addr);
-    memcpy(&bfcr->stitch.buf[stitch_byte_at], &bfcr->buf.addr[buf_byte_at], nb_bytes);
-    bfcr->stitch.at += sz;
-    consume_bits(bfcr, sz);
-}
-
-static void stitch_append_from_remaining_buf(struct bt_bfcr *bfcr)
-{
-    stitch_append_from_buf(bfcr, available_bits(bfcr));
-}
-
-static void stitch_set_from_remaining_buf(struct bt_bfcr *bfcr)
-{
-    stitch_reset(bfcr);
-    bfcr->stitch.offset = IN_BYTE_OFFSET(buf_at_from_addr(bfcr));
-    stitch_append_from_remaining_buf(bfcr);
-}
-
-static inline void read_unsigned_bitfield(struct bt_bfcr *bfcr, const uint8_t *buf, size_t at,
-                                          unsigned int field_size, enum ctf_byte_order bo,
-                                          uint64_t *v)
-{
-    switch (bo) {
-    case CTF_BYTE_ORDER_BIG:
-        bt_bitfield_read_be(buf, uint8_t, at, field_size, v);
-        break;
-    case CTF_BYTE_ORDER_LITTLE:
-        bt_bitfield_read_le(buf, uint8_t, at, field_size, v);
-        break;
-    default:
-        bt_common_abort();
-    }
-
-    BT_CLOGT("Read unsigned bit array: cur=%zu, size=%u, "
-             "bo=%d, val=%" PRIu64,
-             at, field_size, bo, *v);
-}
-
-static inline void read_signed_bitfield(struct bt_bfcr *bfcr, const uint8_t *buf, size_t at,
-                                        unsigned int field_size, enum ctf_byte_order bo, int64_t *v)
-{
-    switch (bo) {
-    case CTF_BYTE_ORDER_BIG:
-        bt_bitfield_read_be(buf, uint8_t, at, field_size, v);
-        break;
-    case CTF_BYTE_ORDER_LITTLE:
-        bt_bitfield_read_le(buf, uint8_t, at, field_size, v);
-        break;
-    default:
-        bt_common_abort();
-    }
-
-    BT_CLOGT("Read signed bit array: cur=%zu, size=%u, "
-             "bo=%d, val=%" PRId64,
-             at, field_size, bo, *v);
-}
-
-typedef enum bt_bfcr_status (*read_basic_and_call_cb_t)(struct bt_bfcr *, const uint8_t *, size_t);
-
-static inline enum bt_bfcr_status validate_contiguous_bo(struct bt_bfcr *bfcr,
-                                                         enum ctf_byte_order next_bo)
-{
-    enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
-
-    /* Always valid when at a byte boundary */
-    if (packet_at(bfcr) % 8 == 0) {
-        goto end;
-    }
-
-    /* Always valid if last byte order is unknown */
-    if (bfcr->last_bo == CTF_BYTE_ORDER_UNKNOWN) {
-        goto end;
-    }
-
-    /* Always valid if next byte order is unknown */
-    if (next_bo == CTF_BYTE_ORDER_UNKNOWN) {
-        goto end;
-    }
-
-    /* Make sure last byte order is compatible with the next byte order */
-    switch (bfcr->last_bo) {
-    case CTF_BYTE_ORDER_BIG:
-        if (next_bo != CTF_BYTE_ORDER_BIG) {
-            status = BT_BFCR_STATUS_ERROR;
-        }
-        break;
-    case CTF_BYTE_ORDER_LITTLE:
-        if (next_bo != CTF_BYTE_ORDER_LITTLE) {
-            status = BT_BFCR_STATUS_ERROR;
-        }
-        break;
-    default:
-        status = BT_BFCR_STATUS_ERROR;
-    }
-
-end:
-    if (status < 0) {
-        BT_CLOGW("Cannot read bit array: two different byte orders not at a byte boundary: "
-                 "bfcr-addr=%p, last-bo=%d, next-bo=%d",
-                 bfcr, bfcr->last_bo, next_bo);
-    }
-
-    return status;
-}
-
-static enum bt_bfcr_status read_basic_float_and_call_cb(struct bt_bfcr *bfcr, const uint8_t *buf,
-                                                        size_t at)
-{
-    double dblval;
-    unsigned int field_size;
-    enum ctf_byte_order bo;
-    enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
-    ctf_field_class_float *fc = ctf_field_class_as_float(bfcr->cur_basic_field_class);
-
-    BT_ASSERT_DBG(fc);
-    field_size = fc->base.size;
-    bo = fc->base.byte_order;
-    bfcr->cur_bo = bo;
-
-    switch (field_size) {
-    case 32:
-    {
-        uint64_t v;
-        union
-        {
-            uint32_t u;
-            float f;
-        } f32;
-
-        read_unsigned_bitfield(bfcr, buf, at, field_size, bo, &v);
-        f32.u = (uint32_t) v;
-        dblval = (double) f32.f;
-        break;
-    }
-    case 64:
-    {
-        union
-        {
-            uint64_t u;
-            double d;
-        } f64;
-
-        read_unsigned_bitfield(bfcr, buf, at, field_size, bo, &f64.u);
-        dblval = f64.d;
-        break;
-    }
-    default:
-        /* Only 32-bit and 64-bit fields are supported currently */
-        bt_common_abort();
-    }
-
-    BT_CLOGT("Read floating point number value: bfcr=%p, cur=%zu, val=%f", bfcr, at, dblval);
-
-    if (bfcr->user.cbs.classes.floating_point) {
-        BT_CLOGT("Calling user function (floating point number).");
-        status = bfcr->user.cbs.classes.floating_point(dblval, bfcr->cur_basic_field_class,
-                                                       bfcr->user.data);
-        BT_CLOGT("User function returned: status=%s", bt_bfcr_status_string(status));
-        if (status != BT_BFCR_STATUS_OK) {
-            BT_CLOGW("User function failed: bfcr-addr=%p, status=%s", bfcr,
-                     bt_bfcr_status_string(status));
-        }
-    }
-
-    return status;
-}
-
-static inline enum bt_bfcr_status read_basic_int_and_call_cb(struct bt_bfcr *bfcr,
-                                                             const uint8_t *buf, size_t at)
-{
-    unsigned int field_size;
-    enum ctf_byte_order bo;
-    enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
-    ctf_field_class_int *fc = ctf_field_class_as_int(bfcr->cur_basic_field_class);
-
-    field_size = fc->base.size;
-    bo = fc->base.byte_order;
-
-    /*
-     * Update current byte order now because we could be reading
-     * the integer value of an enumeration class, and thus we know
-     * here the actual supporting integer class's byte order.
-     */
-    bfcr->cur_bo = bo;
-
-    if (fc->is_signed) {
-        int64_t v;
-
-        read_signed_bitfield(bfcr, buf, at, field_size, bo, &v);
-
-        if (bfcr->user.cbs.classes.signed_int) {
-            BT_CLOGT("Calling user function (signed integer).");
-            status =
-                bfcr->user.cbs.classes.signed_int(v, bfcr->cur_basic_field_class, bfcr->user.data);
-            BT_CLOGT("User function returned: status=%s", bt_bfcr_status_string(status));
-            if (status != BT_BFCR_STATUS_OK) {
-                BT_CLOGW("User function failed: "
-                         "bfcr-addr=%p, status=%s",
-                         bfcr, bt_bfcr_status_string(status));
-            }
-        }
-    } else {
-        uint64_t v;
-
-        read_unsigned_bitfield(bfcr, buf, at, field_size, bo, &v);
-
-        if (bfcr->user.cbs.classes.unsigned_int) {
-            BT_CLOGT("Calling user function (unsigned integer).");
-            status = bfcr->user.cbs.classes.unsigned_int(v, bfcr->cur_basic_field_class,
-                                                         bfcr->user.data);
-            BT_CLOGT("User function returned: status=%s", bt_bfcr_status_string(status));
-            if (status != BT_BFCR_STATUS_OK) {
-                BT_CLOGW("User function failed: "
-                         "bfcr-addr=%p, status=%s",
-                         bfcr, bt_bfcr_status_string(status));
-            }
-        }
-    }
-
-    return status;
-}
-
-static inline enum bt_bfcr_status
-read_bit_array_class_and_call_continue(struct bt_bfcr *bfcr,
-                                       read_basic_and_call_cb_t read_basic_and_call_cb)
-{
-    size_t available;
-    size_t needed_bits;
-    enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
-    ctf_field_class_bit_array *fc = ctf_field_class_as_bit_array(bfcr->cur_basic_field_class);
-
-    if (!at_least_one_bit_left(bfcr)) {
-        BT_CLOGT("Reached end of data: bfcr-addr=%p", bfcr);
-        status = BT_BFCR_STATUS_EOF;
-        goto end;
-    }
-
-    available = available_bits(bfcr);
-    needed_bits = fc->size - bfcr->stitch.at;
-    BT_CLOGT("Continuing basic field decoding: "
-             "bfcr-addr=%p, field-size=%u, needed-size=%zu, "
-             "available-size=%zu",
-             bfcr, fc->size, needed_bits, available);
-    if (needed_bits <= available) {
-        /* We have all the bits; append to stitch, then decode */
-        stitch_append_from_buf(bfcr, needed_bits);
-        status = read_basic_and_call_cb(bfcr, bfcr->stitch.buf, bfcr->stitch.offset);
-        if (status != BT_BFCR_STATUS_OK) {
-            BT_CLOGW("Cannot read basic field: "
-                     "bfcr-addr=%p, fc-addr=%p, status=%s",
-                     bfcr, bfcr->cur_basic_field_class, bt_bfcr_status_string(status));
-            goto end;
-        }
-
-        if (stack_empty(bfcr->stack)) {
-            /* Root is a basic class */
-            bfcr->state = BFCR_STATE_DONE;
-        } else {
-            /* Go to next field */
-            stack_top(bfcr->stack)->index++;
-            bfcr->state = BFCR_STATE_NEXT_FIELD;
-            bfcr->last_bo = bfcr->cur_bo;
-        }
-        goto end;
-    }
-
-    /* We are here; it means we don't have enough data to decode this */
-    BT_CLOGT_STR("Not enough data to read the next basic field: appending to stitch buffer.");
-    stitch_append_from_remaining_buf(bfcr);
-    status = BT_BFCR_STATUS_EOF;
-
-end:
-    return status;
-}
-
-static inline enum bt_bfcr_status
-read_bit_array_class_and_call_begin(struct bt_bfcr *bfcr,
-                                    read_basic_and_call_cb_t read_basic_and_call_cb)
-{
-    size_t available;
-    enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
-    ctf_field_class_bit_array *fc = ctf_field_class_as_bit_array(bfcr->cur_basic_field_class);
-
-    if (!at_least_one_bit_left(bfcr)) {
-        BT_CLOGT("Reached end of data: bfcr-addr=%p", bfcr);
-        status = BT_BFCR_STATUS_EOF;
-        goto end;
-    }
-
-    status = validate_contiguous_bo(bfcr, fc->byte_order);
-    if (status != BT_BFCR_STATUS_OK) {
-        /* validate_contiguous_bo() logs errors */
-        goto end;
-    }
-
-    available = available_bits(bfcr);
-
-    if (fc->size <= available) {
-        /* We have all the bits; decode and set now */
-        BT_ASSERT_DBG(bfcr->buf.addr);
-        status = read_basic_and_call_cb(bfcr, bfcr->buf.addr, buf_at_from_addr(bfcr));
-        if (status != BT_BFCR_STATUS_OK) {
-            BT_CLOGW("Cannot read basic field: "
-                     "bfcr-addr=%p, fc-addr=%p, status=%s",
-                     bfcr, bfcr->cur_basic_field_class, bt_bfcr_status_string(status));
-            goto end;
-        }
-
-        consume_bits(bfcr, fc->size);
-
-        if (stack_empty(bfcr->stack)) {
-            /* Root is a basic class */
-            bfcr->state = BFCR_STATE_DONE;
-        } else {
-            /* Go to next field */
-            stack_top(bfcr->stack)->index++;
-            bfcr->state = BFCR_STATE_NEXT_FIELD;
-            bfcr->last_bo = bfcr->cur_bo;
-        }
-
-        goto end;
-    }
-
-    /* We are here; it means we don't have enough data to decode this */
-    BT_CLOGT_STR("Not enough data to read the next basic field: setting stitch buffer.");
-    stitch_set_from_remaining_buf(bfcr);
-    bfcr->state = BFCR_STATE_READ_BASIC_CONTINUE;
-    status = BT_BFCR_STATUS_EOF;
-
-end:
-    return status;
-}
-
-static inline enum bt_bfcr_status read_basic_int_class_and_call_begin(struct bt_bfcr *bfcr)
-{
-    return read_bit_array_class_and_call_begin(bfcr, read_basic_int_and_call_cb);
-}
-
-static inline enum bt_bfcr_status read_basic_int_class_and_call_continue(struct bt_bfcr *bfcr)
-{
-    return read_bit_array_class_and_call_continue(bfcr, read_basic_int_and_call_cb);
-}
-
-static inline enum bt_bfcr_status read_basic_float_class_and_call_begin(struct bt_bfcr *bfcr)
-{
-    return read_bit_array_class_and_call_begin(bfcr, read_basic_float_and_call_cb);
-}
-
-static inline enum bt_bfcr_status read_basic_float_class_and_call_continue(struct bt_bfcr *bfcr)
-{
-    return read_bit_array_class_and_call_continue(bfcr, read_basic_float_and_call_cb);
-}
-
-static inline enum bt_bfcr_status read_basic_string_class_and_call(struct bt_bfcr *bfcr, bool begin)
-{
-    size_t buf_at_bytes;
-    const uint8_t *result;
-    size_t available_bytes;
-    const uint8_t *first_chr;
-    enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
-
-    if (!at_least_one_bit_left(bfcr)) {
-        BT_CLOGT("Reached end of data: bfcr-addr=%p", bfcr);
-        status = BT_BFCR_STATUS_EOF;
-        goto end;
-    }
-
-    BT_ASSERT_DBG(buf_at_from_addr(bfcr) % 8 == 0);
-    available_bytes = BITS_TO_BYTES_FLOOR(available_bits(bfcr));
-    buf_at_bytes = BITS_TO_BYTES_FLOOR(buf_at_from_addr(bfcr));
-    BT_ASSERT_DBG(bfcr->buf.addr);
-    first_chr = &bfcr->buf.addr[buf_at_bytes];
-    result = (const uint8_t *) memchr(first_chr, '\0', available_bytes);
-
-    if (begin && bfcr->user.cbs.classes.string_begin) {
-        BT_CLOGT("Calling user function (string, beginning).");
-        status = bfcr->user.cbs.classes.string_begin(bfcr->cur_basic_field_class, bfcr->user.data);
-        BT_CLOGT("User function returned: status=%s", bt_bfcr_status_string(status));
-        if (status != BT_BFCR_STATUS_OK) {
-            BT_CLOGW("User function failed: bfcr-addr=%p, status=%s", bfcr,
-                     bt_bfcr_status_string(status));
-            goto end;
-        }
-    }
-
-    if (!result) {
-        /* No null character yet */
-        if (bfcr->user.cbs.classes.string) {
-            BT_CLOGT("Calling user function (substring).");
-            status = bfcr->user.cbs.classes.string((const char *) first_chr, available_bytes,
-                                                   bfcr->cur_basic_field_class, bfcr->user.data);
-            BT_CLOGT("User function returned: status=%s", bt_bfcr_status_string(status));
-            if (status != BT_BFCR_STATUS_OK) {
-                BT_CLOGW("User function failed: "
-                         "bfcr-addr=%p, status=%s",
-                         bfcr, bt_bfcr_status_string(status));
-                goto end;
-            }
-        }
-
-        consume_bits(bfcr, BYTES_TO_BITS(available_bytes));
-        bfcr->state = BFCR_STATE_READ_BASIC_CONTINUE;
-        status = BT_BFCR_STATUS_EOF;
-    } else {
-        /* Found the null character */
-        size_t result_len = (size_t) (result - first_chr);
-
-        if (bfcr->user.cbs.classes.string && result_len) {
-            BT_CLOGT("Calling user function (substring).");
-            status = bfcr->user.cbs.classes.string((const char *) first_chr, result_len,
-                                                   bfcr->cur_basic_field_class, bfcr->user.data);
-            BT_CLOGT("User function returned: status=%s", bt_bfcr_status_string(status));
-            if (status != BT_BFCR_STATUS_OK) {
-                BT_CLOGW("User function failed: "
-                         "bfcr-addr=%p, status=%s",
-                         bfcr, bt_bfcr_status_string(status));
-                goto end;
-            }
-        }
-
-        if (bfcr->user.cbs.classes.string_end) {
-            BT_CLOGT("Calling user function (string, end).");
-            status =
-                bfcr->user.cbs.classes.string_end(bfcr->cur_basic_field_class, bfcr->user.data);
-            BT_CLOGT("User function returned: status=%s", bt_bfcr_status_string(status));
-            if (status != BT_BFCR_STATUS_OK) {
-                BT_CLOGW("User function failed: "
-                         "bfcr-addr=%p, status=%s",
-                         bfcr, bt_bfcr_status_string(status));
-                goto end;
-            }
-        }
-
-        consume_bits(bfcr, BYTES_TO_BITS(result_len + 1));
-
-        if (stack_empty(bfcr->stack)) {
-            /* Root is a basic class */
-            bfcr->state = BFCR_STATE_DONE;
-        } else {
-            /* Go to next field */
-            stack_top(bfcr->stack)->index++;
-            bfcr->state = BFCR_STATE_NEXT_FIELD;
-            bfcr->last_bo = bfcr->cur_bo;
-        }
-    }
-
-end:
-    return status;
-}
-
-static inline enum bt_bfcr_status read_basic_begin_state(struct bt_bfcr *bfcr)
-{
-    enum bt_bfcr_status status;
-
-    BT_ASSERT_DBG(bfcr->cur_basic_field_class);
-
-    switch (bfcr->cur_basic_field_class->type) {
-    case CTF_FIELD_CLASS_TYPE_INT:
-    case CTF_FIELD_CLASS_TYPE_ENUM:
-        status = read_basic_int_class_and_call_begin(bfcr);
-        break;
-    case CTF_FIELD_CLASS_TYPE_FLOAT:
-        status = read_basic_float_class_and_call_begin(bfcr);
-        break;
-    case CTF_FIELD_CLASS_TYPE_STRING:
-        status = read_basic_string_class_and_call(bfcr, true);
-        break;
-    default:
-        bt_common_abort();
-    }
-
-    return status;
-}
-
-static inline enum bt_bfcr_status read_basic_continue_state(struct bt_bfcr *bfcr)
-{
-    enum bt_bfcr_status status;
-
-    BT_ASSERT_DBG(bfcr->cur_basic_field_class);
-
-    switch (bfcr->cur_basic_field_class->type) {
-    case CTF_FIELD_CLASS_TYPE_INT:
-    case CTF_FIELD_CLASS_TYPE_ENUM:
-        status = read_basic_int_class_and_call_continue(bfcr);
-        break;
-    case CTF_FIELD_CLASS_TYPE_FLOAT:
-        status = read_basic_float_class_and_call_continue(bfcr);
-        break;
-    case CTF_FIELD_CLASS_TYPE_STRING:
-        status = read_basic_string_class_and_call(bfcr, false);
-        break;
-    default:
-        bt_common_abort();
-    }
-
-    return status;
-}
-
-static inline size_t bits_to_skip_to_align_to(struct bt_bfcr *bfcr, size_t align)
-{
-    size_t aligned_packet_at;
-
-    aligned_packet_at = BT_ALIGN(packet_at(bfcr), align);
-    return aligned_packet_at - packet_at(bfcr);
-}
-
-static inline enum bt_bfcr_status align_class_state(struct bt_bfcr *bfcr,
-                                                    struct ctf_field_class *field_class,
-                                                    enum bfcr_state next_state)
-{
-    unsigned int field_alignment;
-    size_t skip_bits;
-    enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
-
-    /* Get field's alignment */
-    field_alignment = field_class->alignment;
-
-    /*
-     * 0 means "undefined" for variants; what we really want is 1
-     * (always aligned)
-     */
-    BT_ASSERT_DBG(field_alignment >= 1);
-
-    /* Compute how many bits we need to skip */
-    skip_bits = bits_to_skip_to_align_to(bfcr, (size_t) field_alignment);
-
-    /* Nothing to skip? aligned */
-    if (skip_bits == 0) {
-        bfcr->state = next_state;
-        goto end;
-    }
-
-    /* Make sure there's at least one bit left */
-    if (!at_least_one_bit_left(bfcr)) {
-        status = BT_BFCR_STATUS_EOF;
-        goto end;
-    }
-
-    /* Consume as many bits as possible in what's left */
-    consume_bits(bfcr, MIN(available_bits(bfcr), skip_bits));
-
-    /* Are we done now? */
-    skip_bits = bits_to_skip_to_align_to(bfcr, field_alignment);
-    if (skip_bits == 0) {
-        /* Yes: go to next state */
-        bfcr->state = next_state;
-        goto end;
-    } else {
-        /* No: need more data */
-        BT_CLOGT("Reached end of data when aligning: bfcr-addr=%p", bfcr);
-        status = BT_BFCR_STATUS_EOF;
-    }
-
-end:
-    return status;
-}
-
-static inline enum bt_bfcr_status next_field_state(struct bt_bfcr *bfcr)
-{
-    int ret;
-    struct stack_entry *top;
-    struct ctf_field_class *next_field_class = NULL;
-    enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
-
-    if (stack_empty(bfcr->stack)) {
-        goto end;
-    }
-
-    top = stack_top(bfcr->stack);
-
-    /* Are we done with this base class? */
-    while (top->index == top->base_len) {
-        if (bfcr->user.cbs.classes.compound_end) {
-            BT_CLOGT("Calling user function (compound, end).");
-            status = bfcr->user.cbs.classes.compound_end(top->base_class, bfcr->user.data);
-            BT_CLOGT("User function returned: status=%s", bt_bfcr_status_string(status));
-            if (status != BT_BFCR_STATUS_OK) {
-                BT_CLOGW("User function failed: bfcr-addr=%p, status=%s", bfcr,
-                         bt_bfcr_status_string(status));
-                goto end;
-            }
-        }
-
-        stack_pop(bfcr->stack);
-
-        /* Are we done with the root class? */
-        if (stack_empty(bfcr->stack)) {
-            bfcr->state = BFCR_STATE_DONE;
-            goto end;
-        }
-
-        top = stack_top(bfcr->stack);
-        top->index++;
-    }
-
-    /* Get next field's class */
-    switch (top->base_class->type) {
-    case CTF_FIELD_CLASS_TYPE_STRUCT:
-        next_field_class = ctf_field_class_struct_borrow_member_by_index(
-                               ctf_field_class_as_struct(top->base_class), (uint64_t) top->index)
-                               ->fc;
-        break;
-    case CTF_FIELD_CLASS_TYPE_ARRAY:
-    case CTF_FIELD_CLASS_TYPE_SEQUENCE:
-    {
-        ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(top->base_class);
-
-        next_field_class = array_fc->elem_fc;
-        break;
-    }
-    case CTF_FIELD_CLASS_TYPE_VARIANT:
-        /* Variant classes are dynamic: the user should know! */
-        next_field_class = bfcr->user.cbs.query.borrow_variant_selected_field_class(
-            top->base_class, bfcr->user.data);
-        break;
-    default:
-        break;
-    }
-
-    if (!next_field_class) {
-        BT_CLOGW("Cannot get the field class of the next field: "
-                 "bfcr-addr=%p, base-fc-addr=%p, base-fc-type=%d, "
-                 "index=%" PRId64,
-                 bfcr, top->base_class, top->base_class->type, top->index);
-        status = BT_BFCR_STATUS_ERROR;
-        goto end;
-    }
-
-    if (next_field_class->is_compound) {
-        if (bfcr->user.cbs.classes.compound_begin) {
-            BT_CLOGT("Calling user function (compound, begin).");
-            status = bfcr->user.cbs.classes.compound_begin(next_field_class, bfcr->user.data);
-            BT_CLOGT("User function returned: status=%s", bt_bfcr_status_string(status));
-            if (status != BT_BFCR_STATUS_OK) {
-                BT_CLOGW("User function failed: bfcr-addr=%p, status=%s", bfcr,
-                         bt_bfcr_status_string(status));
-                goto end;
-            }
-        }
-
-        ret = stack_push_with_len(bfcr, next_field_class);
-        if (ret) {
-            /* stack_push_with_len() logs errors */
-            status = BT_BFCR_STATUS_ERROR;
-            goto end;
-        }
-
-        /* Next state: align a compound class */
-        bfcr->state = BFCR_STATE_ALIGN_COMPOUND;
-    } else {
-        /* Replace current basic field class */
-        BT_CLOGT("Replacing current basic field class: "
-                 "bfcr-addr=%p, cur-basic-fc-addr=%p, "
-                 "next-basic-fc-addr=%p",
-                 bfcr, bfcr->cur_basic_field_class, next_field_class);
-        bfcr->cur_basic_field_class = next_field_class;
-
-        /* Next state: align a basic class */
-        bfcr->state = BFCR_STATE_ALIGN_BASIC;
-    }
-
-end:
-    return status;
-}
-
-static inline enum bt_bfcr_status handle_state(struct bt_bfcr *bfcr)
-{
-    enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
-
-    BT_CLOGT("Handling state: bfcr-addr=%p, state=%s", bfcr, bfcr_state_string(bfcr->state));
-
-    switch (bfcr->state) {
-    case BFCR_STATE_NEXT_FIELD:
-        status = next_field_state(bfcr);
-        break;
-    case BFCR_STATE_ALIGN_BASIC:
-        status = align_class_state(bfcr, bfcr->cur_basic_field_class, BFCR_STATE_READ_BASIC_BEGIN);
-        break;
-    case BFCR_STATE_ALIGN_COMPOUND:
-        status = align_class_state(bfcr, stack_top(bfcr->stack)->base_class, BFCR_STATE_NEXT_FIELD);
-        break;
-    case BFCR_STATE_READ_BASIC_BEGIN:
-        status = read_basic_begin_state(bfcr);
-        break;
-    case BFCR_STATE_READ_BASIC_CONTINUE:
-        status = read_basic_continue_state(bfcr);
-        break;
-    case BFCR_STATE_DONE:
-        break;
-    }
-
-    BT_CLOGT("Handled state: bfcr-addr=%p, status=%s", bfcr, bt_bfcr_status_string(status));
-    return status;
-}
-
-BT_HIDDEN
-struct bt_bfcr *bt_bfcr_create(struct bt_bfcr_cbs cbs, void *data, const bt2_common::LogCfg& logCfg)
-{
-    BT_CLOGD_EX(logCfg, "Creating binary field class reader (BFCR).");
-
-    bt_bfcr *bfcr = new bt_bfcr {logCfg};
-    bfcr->stack = stack_new(bfcr);
-    if (!bfcr->stack) {
-        BT_CLOGE_STR("Cannot create BFCR's stack.");
-        bt_bfcr_destroy(bfcr);
-        bfcr = NULL;
-        goto end;
-    }
-
-    bfcr->state = BFCR_STATE_NEXT_FIELD;
-    bfcr->user.cbs = cbs;
-    bfcr->user.data = data;
-    BT_CLOGD("Created BFCR: addr=%p", bfcr);
-
-end:
-    return bfcr;
-}
-
-BT_HIDDEN
-void bt_bfcr_destroy(struct bt_bfcr *bfcr)
-{
-    if (bfcr->stack) {
-        stack_destroy(bfcr->stack);
-    }
-
-    BT_CLOGD("Destroying BFCR: addr=%p", bfcr);
-    delete bfcr;
-}
-
-static void reset(struct bt_bfcr *bfcr)
-{
-    BT_CLOGD("Resetting BFCR: addr=%p", bfcr);
-    stack_clear(bfcr->stack);
-    stitch_reset(bfcr);
-    bfcr->buf.addr = NULL;
-    bfcr->last_bo = CTF_BYTE_ORDER_UNKNOWN;
-}
-
-static void update_packet_offset(struct bt_bfcr *bfcr)
-{
-    BT_CLOGT("Updating packet offset for next call: "
-             "bfcr-addr=%p, cur-packet-offset=%zu, next-packet-offset=%zu",
-             bfcr, bfcr->buf.packet_offset, bfcr->buf.packet_offset + bfcr->buf.at);
-    bfcr->buf.packet_offset += bfcr->buf.at;
-}
-
-BT_HIDDEN
-size_t bt_bfcr_start(struct bt_bfcr *bfcr, struct ctf_field_class *cls, const uint8_t *buf,
-                     size_t offset, size_t packet_offset, size_t sz, enum bt_bfcr_status *status)
-{
-    BT_ASSERT_DBG(bfcr);
-    BT_ASSERT_DBG(BYTES_TO_BITS(sz) >= offset);
-    reset(bfcr);
-    bfcr->buf.addr = buf;
-    bfcr->buf.offset = offset;
-    bfcr->buf.at = 0;
-    bfcr->buf.packet_offset = packet_offset;
-    bfcr->buf.buf_sz = sz;
-    bfcr->buf.sz = BYTES_TO_BITS(sz) - offset;
-    *status = BT_BFCR_STATUS_OK;
-
-    BT_CLOGT("Starting decoding: bfcr-addr=%p, fc-addr=%p, "
-             "buf-addr=%p, buf-size=%zu, offset=%zu, "
-             "packet-offset=%zu",
-             bfcr, cls, buf, sz, offset, packet_offset);
-
-    /* Set root class */
-    if (cls->is_compound) {
-        /* Compound class: push on visit stack */
-        int stack_ret;
-
-        if (bfcr->user.cbs.classes.compound_begin) {
-            BT_CLOGT("Calling user function (compound, begin).");
-            *status = bfcr->user.cbs.classes.compound_begin(cls, bfcr->user.data);
-            BT_CLOGT("User function returned: status=%s", bt_bfcr_status_string(*status));
-            if (*status != BT_BFCR_STATUS_OK) {
-                BT_CLOGW("User function failed: bfcr-addr=%p, status=%s", bfcr,
-                         bt_bfcr_status_string(*status));
-                goto end;
-            }
-        }
-
-        stack_ret = stack_push_with_len(bfcr, cls);
-        if (stack_ret) {
-            /* stack_push_with_len() logs errors */
-            *status = BT_BFCR_STATUS_ERROR;
-            goto end;
-        }
-
-        bfcr->state = BFCR_STATE_ALIGN_COMPOUND;
-    } else {
-        /* Basic class: set as current basic class */
-        bfcr->cur_basic_field_class = cls;
-        bfcr->state = BFCR_STATE_ALIGN_BASIC;
-    }
-
-    /* Run the machine! */
-    BT_CLOGT_STR("Running the state machine.");
-
-    while (true) {
-        *status = handle_state(bfcr);
-        if (*status != BT_BFCR_STATUS_OK || bfcr->state == BFCR_STATE_DONE) {
-            break;
-        }
-    }
-
-    /* Update packet offset for next time */
-    update_packet_offset(bfcr);
-
-end:
-    return bfcr->buf.at;
-}
-
-BT_HIDDEN
-size_t bt_bfcr_continue(struct bt_bfcr *bfcr, const uint8_t *buf, size_t sz,
-                        enum bt_bfcr_status *status)
-{
-    BT_ASSERT_DBG(bfcr);
-    BT_ASSERT_DBG(buf);
-    BT_ASSERT_DBG(sz > 0);
-    bfcr->buf.addr = buf;
-    bfcr->buf.offset = 0;
-    bfcr->buf.at = 0;
-    bfcr->buf.buf_sz = sz;
-    bfcr->buf.sz = BYTES_TO_BITS(sz);
-    *status = BT_BFCR_STATUS_OK;
-
-    BT_CLOGT("Continuing decoding: bfcr-addr=%p, buf-addr=%p, buf-size=%zu", bfcr, buf, sz);
-
-    /* Continue running the machine */
-    BT_CLOGT_STR("Running the state machine.");
-
-    while (true) {
-        *status = handle_state(bfcr);
-        if (*status != BT_BFCR_STATUS_OK || bfcr->state == BFCR_STATE_DONE) {
-            break;
-        }
-    }
-
-    /* Update packet offset for next time */
-    update_packet_offset(bfcr);
-    return bfcr->buf.at;
-}
-
-BT_HIDDEN
-void bt_bfcr_set_unsigned_int_cb(struct bt_bfcr *bfcr, bt_bfcr_unsigned_int_cb_func cb)
-{
-    BT_ASSERT_DBG(bfcr);
-    BT_ASSERT_DBG(cb);
-    bfcr->user.cbs.classes.unsigned_int = cb;
-}
diff --git a/src/plugins/ctf/common/src/bfcr/bfcr.hpp b/src/plugins/ctf/common/src/bfcr/bfcr.hpp
deleted file mode 100644 (file)
index 7f01732..0000000
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (c) 2015-2016 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2015-2016 Philippe Proulx <pproulx@efficios.com>
- *
- * Babeltrace - CTF binary field class reader (BFCR)
- */
-
-#ifndef CTF_BFCR_H
-#define CTF_BFCR_H
-
-#include <stdint.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <babeltrace2/babeltrace.h>
-#include "common/macros.h"
-
-#include "../metadata/tsdl/ctf-meta.hpp"
-#include "cpp-common/log-cfg.hpp"
-
-/**
- * @file bfcr.h
- *
- * Event-driven CTF binary field class reader (BFCR).
- *
- * This is a common, internal API used by CTF source plugins. It allows
- * a binary CTF IR field class to be decoded from user-provided buffers.
- * As the class is decoded (and, possibly, its nested classes),
- * registered user callback functions are called.
- *
- * This API is only concerned with reading one CTF class at a time from
- * one or more buffer of bytes. It does not know CTF dynamic scopes,
- * events, or streams. Sequence lengths and selected variant classes are
- * requested to the user when needed.
- */
-
-/**
- * Binary class reader API status codes.
- */
-enum bt_bfcr_status
-{
-    /** Out of memory. */
-    BT_BFCR_STATUS_ENOMEM = -5,
-    /**
-     * The binary stream reader reached the end of the user-provided
-     * buffer, but data is still needed to finish decoding the
-     * requested class.
-     *
-     * The user needs to call bt_bfcr_continue() as long as
-     * #BT_BFCR_STATUS_EOF is returned to complete the decoding
-     * process of a given class.
-     */
-    BT_BFCR_STATUS_EOF = 1,
-
-    /** Invalid argument. */
-    BT_BFCR_STATUS_INVAL = -3,
-
-    /** General error. */
-    BT_BFCR_STATUS_ERROR = -1,
-
-    /** Everything okay. */
-    BT_BFCR_STATUS_OK = 0,
-};
-
-/** Field class reader. */
-struct bt_bfcr;
-
-typedef enum bt_bfcr_status (*bt_bfcr_unsigned_int_cb_func)(uint64_t, struct ctf_field_class *,
-                                                            void *);
-
-/*
- * Field class reader user callback functions.
- */
-struct bt_bfcr_cbs
-{
-    /**
-     * Field class callback functions.
-     *
-     * This CTF binary class reader is event-driven. The following
-     * functions are called during the decoding process, either when
-     * a compound class begins/ends, or when a basic class is
-     * completely decoded (along with its value).
-     *
-     * Each function also receives the CTF field class associated
-     * with the call, and user data (registered to the class reader
-     * calling them).
-     *
-     * Actual trace IR fields are \em not created here; this would
-     * be the responsibility of a class reader's user (the provider
-     * of those callback functions).
-     *
-     * All the class callback functions return one of the following
-     * values:
-     *
-     *   - <b>#BT_BFCR_STATUS_OK</b>: Everything is okay;
-     *     continue the decoding process.
-     *   - <b>#BT_BFCR_STATUS_ERROR</b>: General error (reported
-     *     to class reader's user).
-     *
-     * Any member of this structure may be set to \c NULL, should
-     * a specific message be not needed.
-     */
-    struct
-    {
-        /**
-         * Called when a signed integer class is completely
-         * decoded. This could also be the supporting signed
-         * integer class of an enumeration class (\p class will
-         * indicate this).
-         *
-         * @param value                Signed integer value
-         * @param class                Integer or enumeration class
-         * @param data         User data
-         * @returns            #BT_BFCR_STATUS_OK or
-         *                     #BT_BFCR_STATUS_ERROR
-         */
-        enum bt_bfcr_status (*signed_int)(int64_t value, struct ctf_field_class *cls, void *data);
-
-        /**
-         * Called when an unsigned integer class is completely
-         * decoded. This could also be the supporting signed
-         * integer class of an enumeration class (\p class will
-         * indicate this).
-         *
-         * @param value                Unsigned integer value
-         * @param class                Integer or enumeration class
-         * @param data         User data
-         * @returns            #BT_BFCR_STATUS_OK or
-         *                     #BT_BFCR_STATUS_ERROR
-         */
-        bt_bfcr_unsigned_int_cb_func unsigned_int;
-
-        /**
-         * Called when a floating point number class is
-         * completely decoded.
-         *
-         * @param value                Floating point number value
-         * @param class                Floating point number class
-         * @param data         User data
-         * @returns            #BT_BFCR_STATUS_OK or
-         *                     #BT_BFCR_STATUS_ERROR
-         */
-        enum bt_bfcr_status (*floating_point)(double value, struct ctf_field_class *cls,
-                                              void *data);
-
-        /**
-         * Called when a string class begins.
-         *
-         * All the following user callback function calls will
-         * be made to bt_bfcr_cbs::classes::string(), each of
-         * them providing one substring of the complete string
-         * class's value.
-         *
-         * @param class                Beginning string class
-         * @param data         User data
-         * @returns            #BT_BFCR_STATUS_OK or
-         *                     #BT_BFCR_STATUS_ERROR
-         */
-        enum bt_bfcr_status (*string_begin)(struct ctf_field_class *cls, void *data);
-
-        /**
-         * Called when a string class's substring is decoded
-         * (between a call to bt_bfcr_cbs::classes::string_begin()
-         * and a call to bt_bfcr_cbs::classes::string_end()).
-         *
-         * @param value                String value (\em not null-terminated)
-         * @param len          String value length
-         * @param class                String class
-         * @param data         User data
-         * @returns            #BT_BFCR_STATUS_OK or
-         *                     #BT_BFCR_STATUS_ERROR
-         */
-        enum bt_bfcr_status (*string)(const char *value, size_t len, struct ctf_field_class *cls,
-                                      void *data);
-
-        /**
-         * Called when a string class ends.
-         *
-         * @param class                Ending string class
-         * @param data         User data
-         * @returns            #BT_BFCR_STATUS_OK or
-         *                     #BT_BFCR_STATUS_ERROR
-         */
-        enum bt_bfcr_status (*string_end)(struct ctf_field_class *cls, void *data);
-
-        /**
-         * Called when a compound class begins.
-         *
-         * All the following class callback function calls will
-         * signal sequential elements of this compound class,
-         * until the next corresponding
-         * bt_bfcr_cbs::classes::compound_end() is called.
-         *
-         * If \p class is a variant class, then only one class
-         * callback function call will follow before the call to
-         * bt_bfcr_cbs::classes::compound_end(). This single
-         * call indicates the selected class of this variant
-         * class.
-         *
-         * @param class                Beginning compound class
-         * @param data         User data
-         * @returns            #BT_BFCR_STATUS_OK or
-         *                     #BT_BFCR_STATUS_ERROR
-         */
-        enum bt_bfcr_status (*compound_begin)(struct ctf_field_class *cls, void *data);
-
-        /**
-         * Called when a compound class ends.
-         *
-         * @param class                Ending compound class
-         * @param data         User data
-         * @returns            #BT_BFCR_STATUS_OK or
-         *                     #BT_BFCR_STATUS_ERROR
-         */
-        enum bt_bfcr_status (*compound_end)(struct ctf_field_class *cls, void *data);
-    } classes;
-
-    /**
-     * Query callback functions are used when the class reader needs
-     * dynamic information, i.e. a sequence class's current length
-     * or a variant class's current selected class.
-     *
-     * Both functions need to be set unless it is known that no
-     * sequences or variants will have to be decoded.
-     */
-    struct
-    {
-        /**
-         * Called to query the current length of a given sequence
-         * class.
-         *
-         * @param class                Sequence class
-         * @param data         User data
-         * @returns            Sequence length or
-         *                     #BT_BFCR_STATUS_ERROR on error
-         */
-        int64_t (*get_sequence_length)(struct ctf_field_class *cls, void *data);
-
-        /**
-         * Called to query the current selected class of a given
-         * variant class.
-         *
-         * @param class                Variant class
-         * @param data         User data
-         * @returns            Current selected class (owned by
-         *                     this) or \c NULL on error
-         */
-        struct ctf_field_class *(*borrow_variant_selected_field_class)(struct ctf_field_class *cls,
-                                                                       void *data);
-    } query;
-};
-
-/**
- * Creates a CTF binary class reader.
- *
- * @param cbs          User callback functions
- * @param data         User data (passed to user callback functions)
- * @returns            New binary class reader on success, or \c NULL on error
- */
-BT_HIDDEN
-struct bt_bfcr *bt_bfcr_create(struct bt_bfcr_cbs cbs, void *data,
-                               const bt2_common::LogCfg& logCfg);
-
-/**
- * Destroys a CTF binary class reader, freeing all internal resources.
- *
- * @param bfcr Binary class reader
- */
-BT_HIDDEN
-void bt_bfcr_destroy(struct bt_bfcr *bfcr);
-
-/**
- * Decodes a given CTF class from a buffer of bytes.
- *
- * The number of \em bits consumed by this function is returned.
- *
- * The \p status output parameter is where a status is written, amongst
- * the following:
- *
- *   - <b>#BT_BFCR_STATUS_OK</b>: Decoding is done.
- *   - <b>#BT_BFCR_STATUS_EOF</b>: The end of the buffer was reached,
- *     but more data is needed to finish the decoding process of the
- *     requested class. The user needs to call bt_bfcr_continue()
- *     as long as #BT_BFCR_STATUS_EOF is returned to complete the
- *     decoding process of the original class.
- *   - <b>#BT_BFCR_STATUS_INVAL</b>: Invalid argument.
- *   - <b>#BT_BFCR_STATUS_ERROR</b>: General error.
- *
- * Calling this function resets the class reader's internal state. If
- * #BT_BFCR_STATUS_EOF is returned, bt_bfcr_continue() needs to
- * be called next, \em not bt_bfcr_decode().
- *
- * @param bfcr                 Binary class reader
- * @param class                        Field class to decode
- * @param buf                  Buffer
- * @param offset               Offset of first bit from \p buf (bits)
- * @param packet_offset                Offset of \p offset within the CTF
- *                             binary packet containing \p class (bits)
- * @param sz                   Size of buffer in bytes (from \p buf)
- * @param status               Returned status (see description above)
- * @returns                    Number of consumed bits
- */
-BT_HIDDEN
-size_t bt_bfcr_start(struct bt_bfcr *bfcr, struct ctf_field_class *cls, const uint8_t *buf,
-                     size_t offset, size_t packet_offset, size_t sz, enum bt_bfcr_status *status);
-
-/**
- * Continues the decoding process a given CTF class.
- *
- * The number of bits consumed by this function is returned.
- *
- * The \p status output parameter is where a status is placed, amongst
- * the following:
- *
- *   - <b>#BT_BFCR_STATUS_OK</b>: decoding is done.
- *   - <b>#BT_BFCR_STATUS_EOF</b>: the end of the buffer was reached,
- *     but more data is needed to finish the decoding process of the
- *     requested class. The user needs to call bt_bfcr_continue()
- *     as long as #BT_BFCR_STATUS_EOF is returned to complete the
- *     decoding process of the original class.
- *   - <b>#BT_BFCR_STATUS_INVAL</b>: invalid argument.
- *   - <b>#BT_BFCR_STATUS_ERROR</b>: general error.
- *
- * @param bfcr         Binary class reader
- * @param buf          Buffer
- * @param sz           Size of buffer in bytes (from \p offset)
- * @param status       Returned status (see description above)
- * @returns            Number of consumed bits
- */
-BT_HIDDEN
-size_t bt_bfcr_continue(struct bt_bfcr *bfcr, const uint8_t *buf, size_t sz,
-                        enum bt_bfcr_status *status);
-
-BT_HIDDEN
-void bt_bfcr_set_unsigned_int_cb(struct bt_bfcr *bfcr, bt_bfcr_unsigned_int_cb_func cb);
-
-static inline const char *bt_bfcr_status_string(enum bt_bfcr_status status)
-{
-    switch (status) {
-    case BT_BFCR_STATUS_ENOMEM:
-        return "ENOMEM";
-    case BT_BFCR_STATUS_EOF:
-        return "EOF";
-    case BT_BFCR_STATUS_INVAL:
-        return "INVAL";
-    case BT_BFCR_STATUS_ERROR:
-        return "ERROR";
-    case BT_BFCR_STATUS_OK:
-        return "OK";
-    }
-
-    bt_common_abort();
-}
-
-#endif /* CTF_BFCR_H */
diff --git a/src/plugins/ctf/common/src/bfcr/btr.gdb b/src/plugins/ctf/common/src/bfcr/btr.gdb
deleted file mode 100644 (file)
index 71cc0f6..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-define ctf-btr-show-stack
-    if (stack_empty($arg0))
-        printf "stack is empty!\n"
-    else
-        set $stack_size = stack_size($arg0)
-        set $stack_at = (int) ($stack_size - 1)
-        printf "%3s    %10s   %4s    %3s\n", "pos", "base addr", "blen", "idx"
-
-        while ($stack_at >= 0)
-            set $stack_entry = (struct stack_entry *) g_ptr_array_index($arg0->entries, $stack_at)
-
-            if ($stack_at == $stack_size - 1)
-                printf "%3d    %10p    %3d    %3d  <-- top\n", $stack_at, \
-                    $stack_entry->base_class, $stack_entry->base_len, \
-                    $stack_entry->index
-            else
-                printf "%3d    %10p    %3d    %3d\n", $stack_at, \
-                    $stack_entry->base_class, $stack_entry->base_len, \
-                    $stack_entry->index
-            end
-            set $stack_at = $stack_at - 1
-        end
-    end
-end
index a269b702d7627c3e548380034726416e7e14578e..25e1f4f7e75a38c293cc2bd74410e695a9ec5689 100644 (file)
@@ -29,28 +29,20 @@ libctf_ast_la_SOURCES = \
        parser-wrap.hpp \
        scanner.hpp \
        scanner-symbols.hpp \
-       decoder.cpp \
-       decoder.hpp \
        metadata-stream-decoder.cpp \
        metadata-stream-decoder.hpp \
        ctf-1-metadata-stream-parser.cpp \
        ctf-1-metadata-stream-parser.hpp \
-       decoder-packetized-file-stream-to-buf.cpp \
-       decoder-packetized-file-stream-to-buf.hpp \
        logging.cpp \
        logging.hpp \
        ctf-meta.hpp \
        ctf-meta-visitors.hpp \
        ctf-meta-validate.cpp \
        ctf-meta-update-meanings.cpp \
-       ctf-meta-update-in-ir.cpp \
        ctf-meta-update-default-clock-classes.cpp \
        ctf-meta-update-text-array-sequence.cpp \
        ctf-meta-update-alignments.cpp \
-       ctf-meta-update-value-storing-indexes.cpp \
-       ctf-meta-update-stream-class-config.cpp \
        ctf-meta-warn-meaningless-header-fields.cpp \
-       ctf-meta-translate.cpp \
        ctf-meta-resolve.cpp \
        ctf-meta-configure-ir-trace.cpp \
        ctf-meta-configure-ir-trace.hpp
index 10348a353fa9c397d57b9240a09003da6c9dd389..46afac0372d8c656ec3c7d85607506d9ebd2731a 100644 (file)
 
 #include "cpp-common/optional.hpp"
 #include "cpp-common/bt2/trace-ir.hpp"
-#include "decoder.hpp"
+#include "cpp-common/log-cfg.hpp"
 #include "ctf-meta.hpp"
 
+#include "../../clk-cls-cfg.hpp"
+
 // the parameter name (of the reentrant 'yyparse' function)
 // data is a pointer to a 'SParserParam' structure
 //#define YYPARSE_PARAM        scanner
@@ -358,10 +360,8 @@ struct ctf_visitor_generate_ir
 {
     using UP = std::unique_ptr<ctf_visitor_generate_ir>;
 
-    explicit ctf_visitor_generate_ir(bt_self_component *selfCompParam,
-                                     const bt2_common::LogCfg& logCfgParam) noexcept :
-        logCfg {logCfgParam},
-        selfComp {selfCompParam}
+    explicit ctf_visitor_generate_ir(const bt2_common::LogCfg& logCfgParam) noexcept :
+        logCfg {logCfgParam}
     {
     }
 
@@ -369,12 +369,6 @@ struct ctf_visitor_generate_ir
 
     const bt2_common::LogCfg logCfg;
 
-    /* Weak, used to create a bt_trace_class, if not nullptr. */
-    bt_self_component *selfComp = nullptr;
-
-    /* Trace IR trace class being filled (owned by this) */
-    nonstd::optional<bt2::TraceClass::Shared> trace_class;
-
     /* CTF meta trace being filled (owned by this) */
     struct ctf_trace_class *ctf_tc = nullptr;
 
@@ -389,16 +383,7 @@ struct ctf_visitor_generate_ir
 };
 
 BT_HIDDEN
-ctf_visitor_generate_ir::UP ctf_visitor_generate_ir_create(bt_self_component *selfComp,
-                                                           const bt2_common::LogCfg& logCfg);
-
-BT_HIDDEN
-nonstd::optional<bt2::TraceClass::Shared>
-ctf_visitor_generate_ir_get_ir_trace_class(struct ctf_visitor_generate_ir *visitor);
-
-BT_HIDDEN
-struct ctf_trace_class *
-ctf_visitor_generate_ir_borrow_ctf_trace_class(struct ctf_visitor_generate_ir *visitor);
+ctf_visitor_generate_ir::UP ctf_visitor_generate_ir_create(const bt2_common::LogCfg& logCfg);
 
 BT_HIDDEN
 int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
index e27d3beaefa1a3bc6de8b6973758a66d5f9f661c..2cec6f229035189109d5deaee0e27a829ddec884 100644 (file)
@@ -686,7 +686,7 @@ Ctf1MetadataStreamParser::Ctf1MetadataStreamParser(const ClkClsCfg& clkClsCfg,
                                                    bt_self_component * const selfComp,
                                                    const bt2c::LogCfg& logCfg) :
     MetadataStreamParser {clkClsCfg, selfComp},
-    _mLogCfg {logCfg}, _mOrigCtfIrGenerator {ctf_visitor_generate_ir_create(nullptr, logCfg)},
+    _mLogCfg {logCfg}, _mOrigCtfIrGenerator {ctf_visitor_generate_ir_create(logCfg)},
     _mScanner {ctf_scanner_alloc()}, _mStreamDecoder {logCfg}
 {
 }
index 453441c5f6d500e251c0f3716f06cae38615ea70..53f86bb80255fb5057192c6d3bc7e8ce1758f985 100644 (file)
 #include "cpp-common/cfg-logging.hpp"
 #include "cpp-common/uuid.hpp"
 
-BT_HIDDEN
-void ctf_trace_class_configure_ir_trace(struct ctf_trace_class *tc, bt2::Trace ir_trace)
-{
-    uint64_t i;
-
-    BT_ASSERT(tc);
-
-    if (tc->is_uuid_set) {
-        bt2_common::Uuid uuid {tc->uuid};
-        ir_trace.uuid(uuid);
-    }
-
-    for (i = 0; i < tc->env_entries->len; i++) {
-        struct ctf_trace_class_env_entry *env_entry =
-            ctf_trace_class_borrow_env_entry_by_index(tc, i);
-
-        switch (env_entry->type) {
-        case CTF_TRACE_CLASS_ENV_ENTRY_TYPE_INT:
-            ir_trace.environmentEntry(env_entry->name->str, env_entry->value.i);
-            break;
-        case CTF_TRACE_CLASS_ENV_ENTRY_TYPE_STR:
-            ir_trace.environmentEntry(env_entry->name->str, env_entry->value.str->str);
-            break;
-        default:
-            bt_common_abort();
-        }
-    }
-}
-
 BT_HIDDEN
 void ctf_trace_class_configure_ir_trace(const ctf::src::TraceCls& tc, bt2::Trace irTrace,
                                         const bt2_common::LogCfg& logCfg)
diff --git a/src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-translate.cpp b/src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-translate.cpp
deleted file mode 100644 (file)
index 62a7f56..0000000
+++ /dev/null
@@ -1,661 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
- */
-
-#include <babeltrace2/babeltrace.h>
-#include "common/macros.h"
-#include "common/assert.h"
-#include <glib.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <string.h>
-#include <inttypes.h>
-
-#include "ctf-meta-visitors.hpp"
-
-namespace ctf {
-
-struct MetaTranslateCtx
-{
-    bt_self_component *self_comp;
-    bt_trace_class *ir_tc;
-    bt_stream_class *ir_sc;
-    struct ctf_trace_class *tc;
-    struct ctf_stream_class *sc;
-    struct ctf_event_class *ec;
-    enum ctf_scope scope;
-};
-
-} /* namespace ctf */
-
-static inline bt_field_class *ctf_field_class_to_ir(ctf::MetaTranslateCtx *ctx,
-                                                    struct ctf_field_class *fc);
-
-static inline void ctf_field_class_int_set_props(struct ctf_field_class_int *fc,
-                                                 bt_field_class *ir_fc)
-{
-    bt_field_class_integer_set_field_value_range(ir_fc, fc->base.size);
-    bt_field_class_integer_set_preferred_display_base(ir_fc, fc->disp_base);
-}
-
-static inline bt_field_class *ctf_field_class_int_to_ir(ctf::MetaTranslateCtx *ctx,
-                                                        struct ctf_field_class_int *fc)
-{
-    bt_field_class *ir_fc;
-
-    if (fc->is_signed) {
-        ir_fc = bt_field_class_integer_signed_create(ctx->ir_tc);
-    } else {
-        ir_fc = bt_field_class_integer_unsigned_create(ctx->ir_tc);
-    }
-
-    BT_ASSERT(ir_fc);
-    ctf_field_class_int_set_props(fc, ir_fc);
-    return ir_fc;
-}
-
-static inline bt_field_class *ctf_field_class_enum_to_ir(ctf::MetaTranslateCtx *ctx,
-                                                         struct ctf_field_class_enum *fc)
-{
-    int ret;
-    bt_field_class *ir_fc;
-    uint64_t i;
-
-    if (fc->base.is_signed) {
-        ir_fc = bt_field_class_enumeration_signed_create(ctx->ir_tc);
-    } else {
-        ir_fc = bt_field_class_enumeration_unsigned_create(ctx->ir_tc);
-    }
-
-    BT_ASSERT(ir_fc);
-    ctf_field_class_int_set_props(&fc->base, ir_fc);
-
-    for (i = 0; i < fc->mappings->len; i++) {
-        struct ctf_field_class_enum_mapping *mapping =
-            ctf_field_class_enum_borrow_mapping_by_index(fc, i);
-        bt_integer_range_set_signed *range_set_signed = NULL;
-        bt_integer_range_set_unsigned *range_set_unsigned = NULL;
-        uint64_t range_i;
-
-        if (fc->base.is_signed) {
-            range_set_signed = bt_integer_range_set_signed_create();
-            BT_ASSERT(range_set_signed);
-        } else {
-            range_set_unsigned = bt_integer_range_set_unsigned_create();
-            BT_ASSERT(range_set_unsigned);
-        }
-
-        for (range_i = 0; range_i < mapping->ranges->len; range_i++) {
-            struct ctf_range *range =
-                ctf_field_class_enum_mapping_borrow_range_by_index(mapping, range_i);
-
-            if (fc->base.is_signed) {
-                ret = bt_integer_range_set_signed_add_range(range_set_signed, range->lower.i,
-                                                            range->upper.i);
-            } else {
-                ret = bt_integer_range_set_unsigned_add_range(range_set_unsigned, range->lower.u,
-                                                              range->upper.u);
-            }
-
-            BT_ASSERT(ret == 0);
-        }
-
-        if (fc->base.is_signed) {
-            ret = bt_field_class_enumeration_signed_add_mapping(ir_fc, mapping->label->str,
-                                                                range_set_signed);
-            BT_INTEGER_RANGE_SET_SIGNED_PUT_REF_AND_RESET(range_set_signed);
-        } else {
-            ret = bt_field_class_enumeration_unsigned_add_mapping(ir_fc, mapping->label->str,
-                                                                  range_set_unsigned);
-            BT_INTEGER_RANGE_SET_UNSIGNED_PUT_REF_AND_RESET(range_set_unsigned);
-        }
-
-        BT_ASSERT(ret == 0);
-    }
-
-    return ir_fc;
-}
-
-static inline bt_field_class *ctf_field_class_float_to_ir(ctf::MetaTranslateCtx *ctx,
-                                                          struct ctf_field_class_float *fc)
-{
-    bt_field_class *ir_fc;
-
-    if (fc->base.size == 32) {
-        ir_fc = bt_field_class_real_single_precision_create(ctx->ir_tc);
-    } else {
-        ir_fc = bt_field_class_real_double_precision_create(ctx->ir_tc);
-    }
-    BT_ASSERT(ir_fc);
-
-    return ir_fc;
-}
-
-static inline bt_field_class *ctf_field_class_string_to_ir(ctf::MetaTranslateCtx *ctx,
-                                                           struct ctf_field_class_string *fc)
-{
-    bt_field_class *ir_fc = bt_field_class_string_create(ctx->ir_tc);
-
-    BT_ASSERT(ir_fc);
-    return ir_fc;
-}
-
-static inline void translate_struct_field_class_members(ctf::MetaTranslateCtx *ctx,
-                                                        struct ctf_field_class_struct *fc,
-                                                        bt_field_class *ir_fc,
-                                                        bool with_header_prefix,
-                                                        struct ctf_field_class_struct *context_fc)
-{
-    uint64_t i;
-    int ret;
-
-    for (i = 0; i < fc->members->len; i++) {
-        struct ctf_named_field_class *named_fc =
-            ctf_field_class_struct_borrow_member_by_index(fc, i);
-        bt_field_class *member_ir_fc;
-        const char *name = named_fc->name->str;
-
-        if (!named_fc->fc->in_ir) {
-            continue;
-        }
-
-        member_ir_fc = ctf_field_class_to_ir(ctx, named_fc->fc);
-        BT_ASSERT(member_ir_fc);
-        ret = bt_field_class_structure_append_member(ir_fc, name, member_ir_fc);
-        BT_ASSERT(ret == 0);
-        bt_field_class_put_ref(member_ir_fc);
-    }
-}
-
-static inline bt_field_class *ctf_field_class_struct_to_ir(ctf::MetaTranslateCtx *ctx,
-                                                           struct ctf_field_class_struct *fc)
-{
-    bt_field_class *ir_fc = bt_field_class_structure_create(ctx->ir_tc);
-
-    BT_ASSERT(ir_fc);
-    translate_struct_field_class_members(ctx, fc, ir_fc, false, NULL);
-    return ir_fc;
-}
-
-static inline bt_field_class *borrow_ir_fc_from_field_path(ctf::MetaTranslateCtx *ctx,
-                                                           struct ctf_field_path *field_path)
-{
-    bt_field_class *ir_fc = NULL;
-    struct ctf_field_class *fc =
-        ctf_field_path_borrow_field_class(field_path, ctx->tc, ctx->sc, ctx->ec);
-
-    BT_ASSERT(fc);
-
-    if (fc->in_ir) {
-        ir_fc = fc->ir_fc;
-    }
-
-    return ir_fc;
-}
-
-static inline const bt_field_class_enumeration_mapping *
-find_ir_enum_field_class_mapping_by_label(const bt_field_class *fc, const char *label,
-                                          bool is_signed)
-{
-    const bt_field_class_enumeration_mapping *mapping = NULL;
-    uint64_t i;
-
-    for (i = 0; i < bt_field_class_enumeration_get_mapping_count(fc); i++) {
-        const bt_field_class_enumeration_mapping *this_mapping;
-        const bt_field_class_enumeration_signed_mapping *signed_this_mapping = NULL;
-        const bt_field_class_enumeration_unsigned_mapping *unsigned_this_mapping = NULL;
-
-        if (is_signed) {
-            signed_this_mapping =
-                bt_field_class_enumeration_signed_borrow_mapping_by_index_const(fc, i);
-            BT_ASSERT(signed_this_mapping);
-            this_mapping =
-                bt_field_class_enumeration_signed_mapping_as_mapping_const(signed_this_mapping);
-        } else {
-            unsigned_this_mapping =
-                bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const(fc, i);
-            BT_ASSERT(unsigned_this_mapping);
-            this_mapping =
-                bt_field_class_enumeration_unsigned_mapping_as_mapping_const(unsigned_this_mapping);
-        }
-
-        BT_ASSERT(this_mapping);
-
-        if (strcmp(bt_field_class_enumeration_mapping_get_label(this_mapping), label) == 0) {
-            mapping = this_mapping;
-            goto end;
-        }
-    }
-
-end:
-    return mapping;
-}
-
-static inline bt_field_class *ctf_field_class_variant_to_ir(ctf::MetaTranslateCtx *ctx,
-                                                            struct ctf_field_class_variant *fc)
-{
-    int ret;
-    bt_field_class *ir_fc;
-    uint64_t i;
-    bt_field_class *ir_tag_fc = NULL;
-
-    if (fc->tag_path.root != CTF_SCOPE_PACKET_HEADER &&
-        fc->tag_path.root != CTF_SCOPE_EVENT_HEADER) {
-        ir_tag_fc = borrow_ir_fc_from_field_path(ctx, &fc->tag_path);
-        BT_ASSERT(ir_tag_fc);
-    }
-
-    ir_fc = bt_field_class_variant_create(ctx->ir_tc, ir_tag_fc);
-    BT_ASSERT(ir_fc);
-
-    for (i = 0; i < fc->options->len; i++) {
-        struct ctf_named_field_class *named_fc =
-            ctf_field_class_variant_borrow_option_by_index(fc, i);
-        bt_field_class *option_ir_fc;
-
-        BT_ASSERT(named_fc->fc->in_ir);
-        option_ir_fc = ctf_field_class_to_ir(ctx, named_fc->fc);
-        BT_ASSERT(option_ir_fc);
-
-        if (ir_tag_fc) {
-            /*
-             * At this point the trace IR selector
-             * (enumeration) field class already exists if
-             * the variant is tagged (`ir_tag_fc`). This one
-             * already contains range sets for its mappings,
-             * so we just reuse the same, finding them by
-             * matching a variant field class's option's
-             * _original_ name (with a leading underscore,
-             * possibly) with a selector field class's
-             * mapping name.
-             */
-            if (fc->tag_fc->base.is_signed) {
-                const bt_field_class_enumeration_signed_mapping *mapping =
-                    (bt_field_class_enumeration_signed_mapping *)
-                        find_ir_enum_field_class_mapping_by_label(ir_tag_fc,
-                                                                  named_fc->orig_name->str, true);
-                const bt_integer_range_set_signed *range_set;
-
-                BT_ASSERT(mapping);
-                range_set = bt_field_class_enumeration_signed_mapping_borrow_ranges_const(mapping);
-                BT_ASSERT(range_set);
-                ret = bt_field_class_variant_with_selector_field_integer_signed_append_option(
-                    ir_fc, named_fc->name->str, option_ir_fc, range_set);
-            } else {
-                const bt_field_class_enumeration_unsigned_mapping *mapping =
-                    (bt_field_class_enumeration_unsigned_mapping *)
-                        find_ir_enum_field_class_mapping_by_label(ir_tag_fc,
-                                                                  named_fc->orig_name->str, false);
-                const bt_integer_range_set_unsigned *range_set;
-
-                BT_ASSERT(mapping);
-                range_set =
-                    bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const(mapping);
-                BT_ASSERT(range_set);
-                ret = bt_field_class_variant_with_selector_field_integer_unsigned_append_option(
-                    ir_fc, named_fc->name->str, option_ir_fc, range_set);
-            }
-        } else {
-            ret = bt_field_class_variant_without_selector_append_option(ir_fc, named_fc->name->str,
-                                                                        option_ir_fc);
-        }
-
-        BT_ASSERT(ret == 0);
-        bt_field_class_put_ref(option_ir_fc);
-    }
-
-    return ir_fc;
-}
-
-static inline bt_field_class *ctf_field_class_array_to_ir(ctf::MetaTranslateCtx *ctx,
-                                                          struct ctf_field_class_array *fc)
-{
-    bt_field_class *ir_fc;
-    bt_field_class *elem_ir_fc;
-
-    if (fc->base.is_text) {
-        ir_fc = bt_field_class_string_create(ctx->ir_tc);
-        BT_ASSERT(ir_fc);
-        goto end;
-    }
-
-    elem_ir_fc = ctf_field_class_to_ir(ctx, fc->base.elem_fc);
-    BT_ASSERT(elem_ir_fc);
-    ir_fc = bt_field_class_array_static_create(ctx->ir_tc, elem_ir_fc, fc->length);
-    BT_ASSERT(ir_fc);
-    bt_field_class_put_ref(elem_ir_fc);
-
-end:
-    return ir_fc;
-}
-
-static inline bt_field_class *ctf_field_class_sequence_to_ir(ctf::MetaTranslateCtx *ctx,
-                                                             struct ctf_field_class_sequence *fc)
-{
-    bt_field_class *ir_fc;
-    bt_field_class *elem_ir_fc;
-    bt_field_class *length_fc = NULL;
-
-    if (fc->base.is_text) {
-        ir_fc = bt_field_class_string_create(ctx->ir_tc);
-        BT_ASSERT(ir_fc);
-        goto end;
-    }
-
-    elem_ir_fc = ctf_field_class_to_ir(ctx, fc->base.elem_fc);
-    BT_ASSERT(elem_ir_fc);
-
-    if (fc->length_path.root != CTF_SCOPE_PACKET_HEADER &&
-        fc->length_path.root != CTF_SCOPE_EVENT_HEADER) {
-        length_fc = borrow_ir_fc_from_field_path(ctx, &fc->length_path);
-        BT_ASSERT(length_fc);
-    }
-
-    ir_fc = bt_field_class_array_dynamic_create(ctx->ir_tc, elem_ir_fc, length_fc);
-    BT_ASSERT(ir_fc);
-    bt_field_class_put_ref(elem_ir_fc);
-    BT_ASSERT(ir_fc);
-
-end:
-    return ir_fc;
-}
-
-static inline bt_field_class *ctf_field_class_to_ir(ctf::MetaTranslateCtx *ctx,
-                                                    struct ctf_field_class *fc)
-{
-    bt_field_class *ir_fc = NULL;
-
-    BT_ASSERT(fc);
-    BT_ASSERT(fc->in_ir);
-
-    switch (fc->type) {
-    case CTF_FIELD_CLASS_TYPE_INT:
-        ir_fc = ctf_field_class_int_to_ir(ctx, ctf_field_class_as_int(fc));
-        break;
-    case CTF_FIELD_CLASS_TYPE_ENUM:
-        ir_fc = ctf_field_class_enum_to_ir(ctx, ctf_field_class_as_enum(fc));
-        break;
-    case CTF_FIELD_CLASS_TYPE_FLOAT:
-        ir_fc = ctf_field_class_float_to_ir(ctx, ctf_field_class_as_float(fc));
-        break;
-    case CTF_FIELD_CLASS_TYPE_STRING:
-        ir_fc = ctf_field_class_string_to_ir(ctx, ctf_field_class_as_string(fc));
-        break;
-    case CTF_FIELD_CLASS_TYPE_STRUCT:
-        ir_fc = ctf_field_class_struct_to_ir(ctx, ctf_field_class_as_struct(fc));
-        break;
-    case CTF_FIELD_CLASS_TYPE_ARRAY:
-        ir_fc = ctf_field_class_array_to_ir(ctx, ctf_field_class_as_array(fc));
-        break;
-    case CTF_FIELD_CLASS_TYPE_SEQUENCE:
-        ir_fc = ctf_field_class_sequence_to_ir(ctx, ctf_field_class_as_sequence(fc));
-        break;
-    case CTF_FIELD_CLASS_TYPE_VARIANT:
-        ir_fc = ctf_field_class_variant_to_ir(ctx, ctf_field_class_as_variant(fc));
-        break;
-    default:
-        bt_common_abort();
-    }
-
-    fc->ir_fc = ir_fc;
-    return ir_fc;
-}
-
-static inline bool
-ctf_field_class_struct_has_immediate_member_in_ir(struct ctf_field_class_struct *fc)
-{
-    uint64_t i;
-    bool has_immediate_member_in_ir = false;
-
-    /*
-     * If the structure field class has no members at all, then it
-     * was an empty structure in the beginning, so leave it existing
-     * and empty.
-     */
-    if (fc->members->len == 0) {
-        has_immediate_member_in_ir = true;
-        goto end;
-    }
-
-    for (i = 0; i < fc->members->len; i++) {
-        struct ctf_named_field_class *named_fc =
-            ctf_field_class_struct_borrow_member_by_index(fc, i);
-
-        if (named_fc->fc->in_ir) {
-            has_immediate_member_in_ir = true;
-            goto end;
-        }
-    }
-
-end:
-    return has_immediate_member_in_ir;
-}
-
-static inline bt_field_class *scope_ctf_field_class_to_ir(ctf::MetaTranslateCtx *ctx)
-{
-    bt_field_class *ir_fc = NULL;
-    struct ctf_field_class *fc = NULL;
-
-    switch (ctx->scope) {
-    case CTF_SCOPE_PACKET_CONTEXT:
-        fc = ctx->sc->packet_context_fc;
-        break;
-    case CTF_SCOPE_EVENT_COMMON_CONTEXT:
-        fc = ctx->sc->event_common_context_fc;
-        break;
-    case CTF_SCOPE_EVENT_SPECIFIC_CONTEXT:
-        fc = ctx->ec->spec_context_fc;
-        break;
-    case CTF_SCOPE_EVENT_PAYLOAD:
-        fc = ctx->ec->payload_fc;
-        break;
-    default:
-        bt_common_abort();
-    }
-
-    if (fc && ctf_field_class_struct_has_immediate_member_in_ir(ctf_field_class_as_struct(fc))) {
-        ir_fc = ctf_field_class_to_ir(ctx, fc);
-    }
-
-    return ir_fc;
-}
-
-static inline void ctf_event_class_to_ir(ctf::MetaTranslateCtx *ctx)
-{
-    int ret;
-    bt_event_class *ir_ec = NULL;
-    bt_field_class *ir_fc;
-
-    BT_ASSERT(ctx->ec);
-
-    if (ctx->ec->is_translated) {
-        ir_ec = bt_stream_class_borrow_event_class_by_id(ctx->ir_sc, ctx->ec->id);
-        BT_ASSERT(ir_ec);
-        goto end;
-    }
-
-    ir_ec = bt_event_class_create_with_id(ctx->ir_sc, ctx->ec->id);
-    BT_ASSERT(ir_ec);
-    bt_event_class_put_ref(ir_ec);
-    ctx->scope = CTF_SCOPE_EVENT_SPECIFIC_CONTEXT;
-    ir_fc = scope_ctf_field_class_to_ir(ctx);
-    if (ir_fc) {
-        ret = bt_event_class_set_specific_context_field_class(ir_ec, ir_fc);
-        BT_ASSERT(ret == 0);
-        bt_field_class_put_ref(ir_fc);
-    }
-
-    ctx->scope = CTF_SCOPE_EVENT_PAYLOAD;
-    ir_fc = scope_ctf_field_class_to_ir(ctx);
-    if (ir_fc) {
-        ret = bt_event_class_set_payload_field_class(ir_ec, ir_fc);
-        BT_ASSERT(ret == 0);
-        bt_field_class_put_ref(ir_fc);
-    }
-
-    if (ctx->ec->name->len > 0) {
-        ret = bt_event_class_set_name(ir_ec, ctx->ec->name->str);
-        BT_ASSERT(ret == 0);
-    }
-
-    if (ctx->ec->emf_uri->len > 0) {
-        ret = bt_event_class_set_emf_uri(ir_ec, ctx->ec->emf_uri->str);
-        BT_ASSERT(ret == 0);
-    }
-
-    if (ctx->ec->is_log_level_set) {
-        bt_event_class_set_log_level(ir_ec, ctx->ec->log_level);
-    }
-
-    ctx->ec->is_translated = true;
-    ctx->ec->ir_ec = ir_ec;
-
-end:
-    return;
-}
-
-static inline void ctf_stream_class_to_ir(ctf::MetaTranslateCtx *ctx)
-{
-    int ret;
-    bt_field_class *ir_fc;
-
-    BT_ASSERT(ctx->sc);
-
-    if (ctx->sc->is_translated) {
-        ctx->ir_sc = bt_trace_class_borrow_stream_class_by_id(ctx->ir_tc, ctx->sc->id);
-        BT_ASSERT(ctx->ir_sc);
-        goto end;
-    }
-
-    ctx->ir_sc = bt_stream_class_create_with_id(ctx->ir_tc, ctx->sc->id);
-    BT_ASSERT(ctx->ir_sc);
-    bt_stream_class_put_ref(ctx->ir_sc);
-
-    if (ctx->sc->default_clock_class) {
-        BT_ASSERT(ctx->sc->default_clock_class->ir_cc);
-        ret = bt_stream_class_set_default_clock_class(ctx->ir_sc,
-                                                      ctx->sc->default_clock_class->ir_cc);
-        BT_ASSERT(ret == 0);
-    }
-
-    bt_stream_class_set_supports_packets(ctx->ir_sc, BT_TRUE, ctx->sc->packets_have_ts_begin,
-                                         ctx->sc->packets_have_ts_end);
-    bt_stream_class_set_supports_discarded_events(ctx->ir_sc, ctx->sc->has_discarded_events,
-                                                  ctx->sc->discarded_events_have_default_cs);
-    bt_stream_class_set_supports_discarded_packets(ctx->ir_sc, ctx->sc->has_discarded_packets,
-                                                   ctx->sc->discarded_packets_have_default_cs);
-    ctx->scope = CTF_SCOPE_PACKET_CONTEXT;
-    ir_fc = scope_ctf_field_class_to_ir(ctx);
-    if (ir_fc) {
-        ret = bt_stream_class_set_packet_context_field_class(ctx->ir_sc, ir_fc);
-        BT_ASSERT(ret == 0);
-        bt_field_class_put_ref(ir_fc);
-    }
-
-    ctx->scope = CTF_SCOPE_EVENT_COMMON_CONTEXT;
-    ir_fc = scope_ctf_field_class_to_ir(ctx);
-    if (ir_fc) {
-        ret = bt_stream_class_set_event_common_context_field_class(ctx->ir_sc, ir_fc);
-        BT_ASSERT(ret == 0);
-        bt_field_class_put_ref(ir_fc);
-    }
-
-    bt_stream_class_set_assigns_automatic_event_class_id(ctx->ir_sc, BT_FALSE);
-    bt_stream_class_set_assigns_automatic_stream_id(ctx->ir_sc, BT_FALSE);
-
-    ctx->sc->is_translated = true;
-    ctx->sc->ir_sc = ctx->ir_sc;
-
-end:
-    return;
-}
-
-static inline void ctf_clock_class_to_ir(bt_clock_class *ir_cc, struct ctf_clock_class *cc)
-{
-    int ret;
-
-    if (strlen(cc->name->str) > 0) {
-        ret = bt_clock_class_set_name(ir_cc, cc->name->str);
-        BT_ASSERT(ret == 0);
-    }
-
-    if (strlen(cc->description->str) > 0) {
-        ret = bt_clock_class_set_description(ir_cc, cc->description->str);
-        BT_ASSERT(ret == 0);
-    }
-
-    bt_clock_class_set_frequency(ir_cc, cc->frequency);
-    bt_clock_class_set_precision(ir_cc, cc->precision);
-    bt_clock_class_set_offset(ir_cc, cc->offset_seconds, cc->offset_cycles);
-
-    if (cc->has_uuid) {
-        bt_clock_class_set_uuid(ir_cc, cc->uuid);
-    }
-
-    bt_clock_class_set_origin_is_unix_epoch(ir_cc, cc->is_absolute);
-}
-
-static inline int ctf_trace_class_to_ir(ctf::MetaTranslateCtx *ctx)
-{
-    int ret = 0;
-    uint64_t i;
-
-    BT_ASSERT(ctx->tc);
-    BT_ASSERT(ctx->ir_tc);
-
-    if (ctx->tc->is_translated) {
-        goto end;
-    }
-
-    for (i = 0; i < ctx->tc->clock_classes->len; i++) {
-        ctf_clock_class *cc = (ctf_clock_class *) ctx->tc->clock_classes->pdata[i];
-
-        cc->ir_cc = bt_clock_class_create(ctx->self_comp);
-        ctf_clock_class_to_ir(cc->ir_cc, cc);
-    }
-
-    bt_trace_class_set_assigns_automatic_stream_class_id(ctx->ir_tc, BT_FALSE);
-    ctx->tc->is_translated = true;
-    ctx->tc->ir_tc = ctx->ir_tc;
-
-end:
-    return ret;
-}
-
-BT_HIDDEN
-int ctf_trace_class_translate(bt_self_component *self_comp, bt_trace_class *ir_tc,
-                              struct ctf_trace_class *tc)
-{
-    int ret = 0;
-    uint64_t i;
-    ctf::MetaTranslateCtx ctx = {0};
-
-    ctx.self_comp = self_comp;
-    ctx.tc = tc;
-    ctx.ir_tc = ir_tc;
-    ret = ctf_trace_class_to_ir(&ctx);
-    if (ret) {
-        goto end;
-    }
-
-    for (i = 0; i < tc->stream_classes->len; i++) {
-        uint64_t j;
-        ctx.sc = (ctf_stream_class *) tc->stream_classes->pdata[i];
-
-        ctf_stream_class_to_ir(&ctx);
-
-        for (j = 0; j < ctx.sc->event_classes->len; j++) {
-            ctx.ec = (ctf_event_class *) ctx.sc->event_classes->pdata[j];
-
-            ctf_event_class_to_ir(&ctx);
-            ctx.ec = NULL;
-        }
-
-        ctx.sc = NULL;
-    }
-
-end:
-    return ret;
-}
diff --git a/src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-in-ir.cpp b/src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-in-ir.cpp
deleted file mode 100644 (file)
index 6967c44..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
- */
-
-#include <babeltrace2/babeltrace.h>
-#include "common/macros.h"
-#include "common/assert.h"
-#include "compat/glib.h"
-#include <glib.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <string.h>
-#include <inttypes.h>
-#include "common/assert.h"
-
-#include "ctf-meta-visitors.hpp"
-
-static void force_update_field_class_in_ir(struct ctf_field_class *fc, bool in_ir)
-{
-    uint64_t i;
-
-    if (!fc) {
-        goto end;
-    }
-
-    fc->in_ir = in_ir;
-
-    switch (fc->type) {
-    case CTF_FIELD_CLASS_TYPE_STRUCT:
-    {
-        struct ctf_field_class_struct *struct_fc = ctf_field_class_as_struct(fc);
-
-        for (i = 0; i < struct_fc->members->len; i++) {
-            struct ctf_named_field_class *named_fc =
-                ctf_field_class_struct_borrow_member_by_index(struct_fc, i);
-
-            force_update_field_class_in_ir(named_fc->fc, in_ir);
-        }
-
-        break;
-    }
-    case CTF_FIELD_CLASS_TYPE_VARIANT:
-    {
-        struct ctf_named_field_class *named_fc;
-        struct ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc);
-
-        for (i = 0; i < var_fc->options->len; i++) {
-            named_fc = ctf_field_class_variant_borrow_option_by_index(var_fc, i);
-
-            force_update_field_class_in_ir(named_fc->fc, in_ir);
-        }
-
-        break;
-    }
-    case CTF_FIELD_CLASS_TYPE_ARRAY:
-    case CTF_FIELD_CLASS_TYPE_SEQUENCE:
-    {
-        struct ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(fc);
-
-        force_update_field_class_in_ir(array_fc->elem_fc, in_ir);
-        break;
-    }
-    default:
-        break;
-    }
-
-end:
-    return;
-}
-
-static void update_field_class_in_ir(struct ctf_field_class *fc, GHashTable *ft_dependents)
-{
-    int64_t i;
-
-    if (!fc) {
-        goto end;
-    }
-
-    switch (fc->type) {
-    case CTF_FIELD_CLASS_TYPE_INT:
-    case CTF_FIELD_CLASS_TYPE_ENUM:
-    {
-        struct ctf_field_class_int *int_fc = ctf_field_class_as_int(fc);
-
-        /*
-         * Conditions to be in trace IR; one of:
-         *
-         * 1. Does NOT have a mapped clock class AND does not
-         *    have a special meaning.
-         * 2. Another field class depends on it.
-         */
-        if ((!int_fc->mapped_clock_class && int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE) ||
-            bt_g_hash_table_contains(ft_dependents, fc)) {
-            fc->in_ir = true;
-        }
-
-        break;
-    }
-    case CTF_FIELD_CLASS_TYPE_STRUCT:
-    {
-        struct ctf_field_class_struct *struct_fc = ctf_field_class_as_struct(fc);
-
-        /*
-         * Make it part of IR if it's empty because it was
-         * originally empty.
-         */
-        if (struct_fc->members->len == 0) {
-            fc->in_ir = true;
-        }
-
-        /* Reverse order */
-        for (i = (int64_t) struct_fc->members->len - 1; i >= 0; i--) {
-            struct ctf_named_field_class *named_fc =
-                ctf_field_class_struct_borrow_member_by_index(struct_fc, i);
-
-            update_field_class_in_ir(named_fc->fc, ft_dependents);
-
-            if (named_fc->fc->in_ir) {
-                /* At least one member is part of IR */
-                fc->in_ir = true;
-            }
-        }
-
-        break;
-    }
-    case CTF_FIELD_CLASS_TYPE_VARIANT:
-    {
-        struct ctf_named_field_class *named_fc;
-        struct ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc);
-
-        /*
-         * Reverse order, although it is not important for this
-         * loop because a field class within a variant field
-         * type's option cannot depend on a field class in
-         * another option of the same variant field class.
-         */
-        for (i = (int64_t) var_fc->options->len - 1; i >= 0; i--) {
-            named_fc = ctf_field_class_variant_borrow_option_by_index(var_fc, i);
-
-            update_field_class_in_ir(named_fc->fc, ft_dependents);
-
-            if (named_fc->fc->in_ir) {
-                /* At least one option is part of IR */
-                fc->in_ir = true;
-            }
-        }
-
-        if (fc->in_ir) {
-            /*
-             * At least one option will make it to IR. In
-             * this case, make all options part of IR
-             * because the variant's tag could still select
-             * (dynamically) a removed option. This can mean
-             * having an empty structure as an option, for
-             * example, but at least all the options are
-             * selectable.
-             */
-            for (i = 0; i < var_fc->options->len; i++) {
-                ctf_field_class_variant_borrow_option_by_index(var_fc, i)->fc->in_ir = true;
-            }
-
-            /*
-             * This variant field class is part of IR and
-             * depends on a tag field class (which must also
-             * be part of IR).
-             */
-            g_hash_table_insert(ft_dependents, var_fc->tag_fc, var_fc->tag_fc);
-        }
-
-        break;
-    }
-    case CTF_FIELD_CLASS_TYPE_ARRAY:
-    case CTF_FIELD_CLASS_TYPE_SEQUENCE:
-    {
-        struct ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(fc);
-
-        update_field_class_in_ir(array_fc->elem_fc, ft_dependents);
-        fc->in_ir = array_fc->elem_fc->in_ir;
-
-        if (fc->type == CTF_FIELD_CLASS_TYPE_ARRAY) {
-            struct ctf_field_class_array *arr_fc = ctf_field_class_as_array(fc);
-
-            assert(arr_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE ||
-                   arr_fc->meaning == CTF_FIELD_CLASS_MEANING_UUID);
-
-            /*
-             * UUID field class: nothing depends on this, so
-             * it's not part of IR.
-             */
-            if (arr_fc->meaning == CTF_FIELD_CLASS_MEANING_UUID) {
-                fc->in_ir = false;
-                array_fc->elem_fc->in_ir = false;
-            }
-        } else if (fc->type == CTF_FIELD_CLASS_TYPE_SEQUENCE) {
-            if (fc->in_ir) {
-                struct ctf_field_class_sequence *seq_fc = ctf_field_class_as_sequence(fc);
-
-                /*
-                 * This sequence field class is part of
-                 * IR and depends on a length field class
-                 * (which must also be part of IR).
-                 */
-                g_hash_table_insert(ft_dependents, seq_fc->length_fc, seq_fc->length_fc);
-            }
-        }
-
-        break;
-    }
-    default:
-        fc->in_ir = true;
-        break;
-    }
-
-end:
-    return;
-}
-
-/*
- * Scopes and field classes are processed in reverse order because we need
- * to know if a given integer field class has dependents (sequence or
- * variant field classes) when we reach it. Dependents can only be located
- * after the length/tag field class in the metadata tree.
- */
-BT_HIDDEN
-int ctf_trace_class_update_in_ir(struct ctf_trace_class *ctf_tc)
-{
-    int ret = 0;
-    uint64_t i;
-
-    GHashTable *ft_dependents = g_hash_table_new(g_direct_hash, g_direct_equal);
-
-    BT_ASSERT(ft_dependents);
-
-    for (i = 0; i < ctf_tc->stream_classes->len; i++) {
-        ctf_stream_class *sc = (ctf_stream_class *) ctf_tc->stream_classes->pdata[i];
-        uint64_t j;
-
-        for (j = 0; j < sc->event_classes->len; j++) {
-            ctf_event_class *ec = (ctf_event_class *) sc->event_classes->pdata[j];
-
-            if (ec->is_translated) {
-                continue;
-            }
-
-            update_field_class_in_ir(ec->payload_fc, ft_dependents);
-            update_field_class_in_ir(ec->spec_context_fc, ft_dependents);
-        }
-
-        if (!sc->is_translated) {
-            update_field_class_in_ir(sc->event_common_context_fc, ft_dependents);
-            force_update_field_class_in_ir(sc->event_header_fc, false);
-            update_field_class_in_ir(sc->packet_context_fc, ft_dependents);
-        }
-    }
-
-    if (!ctf_tc->is_translated) {
-        force_update_field_class_in_ir(ctf_tc->packet_header_fc, false);
-    }
-
-    g_hash_table_destroy(ft_dependents);
-    return ret;
-}
diff --git a/src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-stream-class-config.cpp b/src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-stream-class-config.cpp
deleted file mode 100644 (file)
index f783a7e..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
- */
-
-#include <babeltrace2/babeltrace.h>
-#include "common/macros.h"
-#include "common/assert.h"
-#include <glib.h>
-#include <stdint.h>
-#include <string.h>
-#include <inttypes.h>
-
-#include "ctf-meta-visitors.hpp"
-
-BT_HIDDEN
-int ctf_trace_class_update_stream_class_config(struct ctf_trace_class *ctf_tc)
-{
-    struct ctf_field_class_int *int_fc;
-    uint64_t i;
-
-    for (i = 0; i < ctf_tc->stream_classes->len; i++) {
-        struct ctf_stream_class *sc = (ctf_stream_class *) ctf_tc->stream_classes->pdata[i];
-
-        if (sc->is_translated) {
-            continue;
-        }
-
-        if (!sc->packet_context_fc) {
-            continue;
-        }
-
-        int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
-            ctf_field_class_as_struct(sc->packet_context_fc), "timestamp_begin");
-        if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME) {
-            sc->packets_have_ts_begin = true;
-        }
-
-        int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
-            ctf_field_class_as_struct(sc->packet_context_fc), "timestamp_end");
-        if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_END_TIME) {
-            sc->packets_have_ts_end = true;
-        }
-
-        int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
-            ctf_field_class_as_struct(sc->packet_context_fc), "events_discarded");
-        if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT) {
-            sc->has_discarded_events = true;
-        }
-
-        sc->discarded_events_have_default_cs =
-            sc->has_discarded_events && sc->packets_have_ts_begin && sc->packets_have_ts_end;
-        int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
-            ctf_field_class_as_struct(sc->packet_context_fc), "packet_seq_num");
-        if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT) {
-            sc->has_discarded_packets = true;
-        }
-
-        sc->discarded_packets_have_default_cs =
-            sc->has_discarded_packets && sc->packets_have_ts_begin && sc->packets_have_ts_end;
-    }
-
-    return 0;
-}
diff --git a/src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-value-storing-indexes.cpp b/src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-value-storing-indexes.cpp
deleted file mode 100644 (file)
index 5962ae2..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
- */
-
-#include <babeltrace2/babeltrace.h>
-#include "common/macros.h"
-#include "common/assert.h"
-#include <glib.h>
-#include <stdint.h>
-#include <string.h>
-#include <inttypes.h>
-
-#include "ctf-meta-visitors.hpp"
-
-static int update_field_class_stored_value_index(struct ctf_field_class *fc,
-                                                 struct ctf_trace_class *tc,
-                                                 struct ctf_stream_class *sc,
-                                                 struct ctf_event_class *ec)
-{
-    int ret = 0;
-    uint64_t i;
-    struct ctf_field_path *field_path = NULL;
-    struct ctf_field_class_int *tgt_fc = NULL;
-    uint64_t *stored_value_index = NULL;
-
-    if (!fc) {
-        goto end;
-    }
-
-    switch (fc->type) {
-    case CTF_FIELD_CLASS_TYPE_VARIANT:
-    {
-        ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc);
-
-        field_path = &var_fc->tag_path;
-        stored_value_index = &var_fc->stored_tag_index;
-        tgt_fc = &var_fc->tag_fc->base;
-        break;
-    }
-    case CTF_FIELD_CLASS_TYPE_SEQUENCE:
-    {
-        struct ctf_field_class_sequence *seq_fc = ctf_field_class_as_sequence(fc);
-
-        field_path = &seq_fc->length_path;
-        stored_value_index = &seq_fc->stored_length_index;
-        tgt_fc = seq_fc->length_fc;
-        break;
-    }
-    default:
-        break;
-    }
-
-    if (field_path) {
-        BT_ASSERT(tgt_fc);
-        BT_ASSERT(tgt_fc->base.base.type == CTF_FIELD_CLASS_TYPE_INT ||
-                  tgt_fc->base.base.type == CTF_FIELD_CLASS_TYPE_ENUM);
-        if (tgt_fc->storing_index >= 0) {
-            /* Already storing its value */
-            *stored_value_index = (uint64_t) tgt_fc->storing_index;
-        } else {
-            /* Not storing its value: allocate new index */
-            tgt_fc->storing_index = tc->stored_value_count;
-            *stored_value_index = (uint64_t) tgt_fc->storing_index;
-            tc->stored_value_count++;
-        }
-    }
-
-    switch (fc->type) {
-    case CTF_FIELD_CLASS_TYPE_STRUCT:
-    {
-        struct ctf_field_class_struct *struct_fc = ctf_field_class_as_struct(fc);
-
-        for (i = 0; i < struct_fc->members->len; i++) {
-            struct ctf_named_field_class *named_fc =
-                ctf_field_class_struct_borrow_member_by_index(struct_fc, i);
-
-            ret = update_field_class_stored_value_index(named_fc->fc, tc, sc, ec);
-            if (ret) {
-                goto end;
-            }
-        }
-
-        break;
-    }
-    case CTF_FIELD_CLASS_TYPE_VARIANT:
-    {
-        struct ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc);
-
-        for (i = 0; i < var_fc->options->len; i++) {
-            struct ctf_named_field_class *named_fc =
-                ctf_field_class_variant_borrow_option_by_index(var_fc, i);
-
-            ret = update_field_class_stored_value_index(named_fc->fc, tc, sc, ec);
-            if (ret) {
-                goto end;
-            }
-        }
-
-        break;
-    }
-    case CTF_FIELD_CLASS_TYPE_ARRAY:
-    case CTF_FIELD_CLASS_TYPE_SEQUENCE:
-    {
-        struct ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(fc);
-
-        ret = update_field_class_stored_value_index(array_fc->elem_fc, tc, sc, ec);
-        if (ret) {
-            goto end;
-        }
-
-        break;
-    }
-    default:
-        break;
-    }
-
-end:
-    return ret;
-}
-
-BT_HIDDEN
-int ctf_trace_class_update_value_storing_indexes(struct ctf_trace_class *ctf_tc)
-{
-    uint64_t i;
-
-    if (!ctf_tc->is_translated) {
-        update_field_class_stored_value_index(ctf_tc->packet_header_fc, ctf_tc, NULL, NULL);
-    }
-
-    for (i = 0; i < ctf_tc->stream_classes->len; i++) {
-        uint64_t j;
-        ctf_stream_class *sc = (ctf_stream_class *) ctf_tc->stream_classes->pdata[i];
-
-        if (!sc->is_translated) {
-            update_field_class_stored_value_index(sc->packet_context_fc, ctf_tc, sc, NULL);
-            update_field_class_stored_value_index(sc->event_header_fc, ctf_tc, sc, NULL);
-            update_field_class_stored_value_index(sc->event_common_context_fc, ctf_tc, sc, NULL);
-        }
-
-        for (j = 0; j < sc->event_classes->len; j++) {
-            struct ctf_event_class *ec = (ctf_event_class *) sc->event_classes->pdata[j];
-
-            if (!ec->is_translated) {
-                update_field_class_stored_value_index(ec->spec_context_fc, ctf_tc, sc, ec);
-                update_field_class_stored_value_index(ec->payload_fc, ctf_tc, sc, ec);
-            }
-        }
-    }
-
-    return 0;
-}
index d1ff2dc3af56a17a1ffebb44862766f373d7a56d..87b8ed31b98565b0413ec9927f4675c3d4a726f1 100644 (file)
@@ -17,17 +17,10 @@ BT_HIDDEN
 int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc,
                                           const bt2_common::LogCfg& logCfg);
 
-BT_HIDDEN
-int ctf_trace_class_translate(bt_self_component *self_comp, bt_trace_class *ir_tc,
-                              struct ctf_trace_class *tc);
-
 BT_HIDDEN
 int ctf_trace_class_update_default_clock_classes(struct ctf_trace_class *ctf_tc,
                                                  const bt2_common::LogCfg& logCfg);
 
-BT_HIDDEN
-int ctf_trace_class_update_in_ir(struct ctf_trace_class *ctf_tc);
-
 BT_HIDDEN
 int ctf_trace_class_update_meanings(struct ctf_trace_class *ctf_tc);
 
@@ -37,12 +30,6 @@ int ctf_trace_class_update_text_array_sequence(struct ctf_trace_class *ctf_tc);
 BT_HIDDEN
 int ctf_trace_class_update_alignments(struct ctf_trace_class *ctf_tc);
 
-BT_HIDDEN
-int ctf_trace_class_update_value_storing_indexes(struct ctf_trace_class *ctf_tc);
-
-BT_HIDDEN
-int ctf_trace_class_update_stream_class_config(struct ctf_trace_class *ctf_tc);
-
 BT_HIDDEN
 int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, const bt2_common::LogCfg& logCfg);
 
index db82ae8bf5910ebe0a9b2bd8b6d4895bd1defd04..3ab755e5f230598904e4a533461e721ff9914055 100644 (file)
@@ -80,20 +80,12 @@ struct ctf_clock_class
     bt_uuid_t uuid;
     bool has_uuid;
     bool is_absolute;
-
-    /* Weak, set during translation */
-    bt_clock_class *ir_cc;
 };
 
 struct ctf_field_class
 {
     enum ctf_field_class_type type;
     unsigned int alignment;
-    bool is_compound;
-    bool in_ir;
-
-    /* Weak, set during translation. NULL if `in_ir` is false below. */
-    bt_field_class *ir_fc;
 };
 
 struct ctf_field_class_bit_array
@@ -110,7 +102,6 @@ struct ctf_field_class_int
     bool is_signed;
     bt_field_class_integer_preferred_display_base disp_base;
     enum ctf_encoding encoding;
-    int64_t storing_index;
 
     /* Weak */
     struct ctf_clock_class *mapped_clock_class;
@@ -155,7 +146,6 @@ struct ctf_field_class_float
 struct ctf_field_class_string
 {
     struct ctf_field_class base;
-    enum ctf_encoding encoding;
 };
 
 struct ctf_named_field_class
@@ -197,7 +187,6 @@ struct ctf_field_class_variant
     struct ctf_field_class base;
     GString *tag_ref;
     struct ctf_field_path tag_path;
-    uint64_t stored_tag_index;
 
     /* Array of `struct ctf_named_field_class` */
     GArray *options;
@@ -228,7 +217,6 @@ struct ctf_field_class_sequence
     struct ctf_field_class_array_base base;
     GString *length_ref;
     struct ctf_field_path length_path;
-    uint64_t stored_length_index;
 
     /* Weak */
     struct ctf_field_class_int *length_fc;
@@ -248,21 +236,12 @@ struct ctf_event_class
 
     /* Owned by this */
     struct ctf_field_class *payload_fc;
-
-    /* Weak, set during translation */
-    bt_event_class *ir_ec;
 };
 
 struct ctf_stream_class
 {
     uint64_t id;
     bool is_translated;
-    bool packets_have_ts_begin;
-    bool packets_have_ts_end;
-    bool has_discarded_events;
-    bool has_discarded_packets;
-    bool discarded_events_have_default_cs;
-    bool discarded_packets_have_default_cs;
 
     /* Owned by this */
     struct ctf_field_class *packet_context_fc;
@@ -284,9 +263,6 @@ struct ctf_stream_class
 
     /* Weak */
     struct ctf_clock_class *default_clock_class;
-
-    /* Weak, set during translation */
-    bt_stream_class *ir_sc;
 };
 
 enum ctf_trace_class_env_entry_type
@@ -318,8 +294,6 @@ struct ctf_trace_class
     /* Owned by this */
     struct ctf_field_class *packet_header_fc;
 
-    uint64_t stored_value_count;
-
     /* Array of `struct ctf_clock_class *` (owned by this) */
     GPtrArray *clock_classes;
 
@@ -331,9 +305,6 @@ struct ctf_trace_class
 
     bool is_translated;
 
-    /* Weak, set during translation */
-    bt_trace_class *ir_tc;
-
     struct
     {
         bool lttng_crash;
@@ -414,7 +385,6 @@ static inline void _ctf_field_class_init(struct ctf_field_class *fc, enum ctf_fi
     BT_ASSERT(fc);
     fc->type = type;
     fc->alignment = alignment;
-    fc->in_ir = false;
 }
 
 static inline void _ctf_field_class_bit_array_init(struct ctf_field_class_bit_array *fc,
@@ -428,7 +398,6 @@ static inline void _ctf_field_class_int_init(struct ctf_field_class_int *fc,
 {
     _ctf_field_class_bit_array_init(&fc->base, type);
     fc->meaning = CTF_FIELD_CLASS_MEANING_NONE;
-    fc->storing_index = -1;
 }
 
 static inline void ctf_field_path_init(struct ctf_field_path *field_path)
@@ -539,7 +508,6 @@ static inline struct ctf_field_class_struct *ctf_field_class_struct_create(void)
     _ctf_field_class_init(&fc->base, CTF_FIELD_CLASS_TYPE_STRUCT, 1);
     fc->members = g_array_new(FALSE, TRUE, sizeof(struct ctf_named_field_class));
     BT_ASSERT(fc->members);
-    fc->base.is_compound = true;
     return fc;
 }
 
@@ -556,7 +524,6 @@ static inline struct ctf_field_class_variant *ctf_field_class_variant_create(voi
     fc->tag_ref = g_string_new(NULL);
     BT_ASSERT(fc->tag_ref);
     ctf_field_path_init(&fc->tag_path);
-    fc->base.is_compound = true;
     return fc;
 }
 
@@ -566,7 +533,6 @@ static inline struct ctf_field_class_array *ctf_field_class_array_create(void)
 
     BT_ASSERT(fc);
     _ctf_field_class_init(&fc->base.base, CTF_FIELD_CLASS_TYPE_ARRAY, 1);
-    fc->base.base.is_compound = true;
     return fc;
 }
 
@@ -579,7 +545,6 @@ static inline struct ctf_field_class_sequence *ctf_field_class_sequence_create(v
     fc->length_ref = g_string_new(NULL);
     BT_ASSERT(fc->length_ref);
     ctf_field_path_init(&fc->length_path);
-    fc->base.base.is_compound = true;
     return fc;
 }
 
@@ -1328,7 +1293,6 @@ static inline void ctf_field_class_int_copy_content(struct ctf_field_class_int *
     dst_fc->disp_base = src_fc->disp_base;
     dst_fc->encoding = src_fc->encoding;
     dst_fc->mapped_clock_class = src_fc->mapped_clock_class;
-    dst_fc->storing_index = src_fc->storing_index;
 }
 
 static inline struct ctf_field_class_int *_ctf_field_class_int_copy(struct ctf_field_class_int *fc)
@@ -1446,7 +1410,6 @@ _ctf_field_class_variant_copy(struct ctf_field_class_variant *fc)
 
     ctf_field_path_copy_content(&copy_fc->tag_path, &fc->tag_path);
     g_string_assign(copy_fc->tag_ref, fc->tag_ref->str);
-    copy_fc->stored_tag_index = fc->stored_tag_index;
     return copy_fc;
 }
 
@@ -1480,7 +1443,6 @@ _ctf_field_class_sequence_copy(struct ctf_field_class_sequence *fc)
     ctf_field_class_array_base_copy_content(&copy_fc->base, &fc->base);
     ctf_field_path_copy_content(&copy_fc->length_path, &fc->length_path);
     g_string_assign(copy_fc->length_ref, fc->length_ref->str);
-    copy_fc->stored_length_index = fc->stored_length_index;
     return copy_fc;
 }
 
@@ -1492,11 +1454,6 @@ static inline struct ctf_field_class *ctf_field_class_copy(struct ctf_field_clas
         goto end;
     }
 
-    /*
-     * Translation should not have happened yet.
-     */
-    BT_ASSERT(!fc->ir_fc);
-
     switch (fc->type) {
     case CTF_FIELD_CLASS_TYPE_INT:
         copy_fc = &_ctf_field_class_int_copy(ctf_field_class_as_int(fc))->base.base;
@@ -1528,7 +1485,6 @@ static inline struct ctf_field_class *ctf_field_class_copy(struct ctf_field_clas
 
     copy_fc->type = fc->type;
     copy_fc->alignment = fc->alignment;
-    copy_fc->in_ir = fc->in_ir;
 
 end:
     return copy_fc;
@@ -1669,7 +1625,6 @@ static inline void ctf_clock_class_destroy(struct ctf_clock_class *cc)
         g_string_free(cc->description, TRUE);
     }
 
-    bt_clock_class_put_ref(cc->ir_cc);
     g_free(cc);
 }
 
diff --git a/src/plugins/ctf/common/src/metadata/tsdl/decoder-packetized-file-stream-to-buf.cpp b/src/plugins/ctf/common/src/metadata/tsdl/decoder-packetized-file-stream-to-buf.cpp
deleted file mode 100644 (file)
index fc7dceb..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright 2016-2017 Philippe Proulx <pproulx@efficios.com>
- */
-
-#define BT_CLOG_CFG logCfg
-#define BT_LOG_TAG  "PLUGIN/CTF/META/DECODER-DECODE-PACKET"
-
-#include "decoder-packetized-file-stream-to-buf.hpp"
-
-#include <stdio.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include "common/assert.h"
-#include "common/uuid.h"
-#include "compat/memstream.h"
-#include <babeltrace2/babeltrace.h>
-#include <glib.h>
-#include <string.h>
-
-#include "ast.hpp"
-#include "decoder.hpp"
-#include "scanner.hpp"
-#include "logging.hpp"
-#include "cpp-common/cfg-logging-error-reporting.hpp"
-
-#define TSDL_MAGIC 0x75d11d57
-
-struct packet_header
-{
-    uint32_t magic;
-    bt_uuid_t uuid;
-    uint32_t checksum;
-    uint32_t content_size;
-    uint32_t packet_size;
-    uint8_t compression_scheme;
-    uint8_t encryption_scheme;
-    uint8_t checksum_scheme;
-    uint8_t major;
-    uint8_t minor;
-} __attribute__((__packed__));
-
-static int decode_packet(FILE *in_fp, FILE *out_fp, int byte_order, bool *is_uuid_set,
-                         uint8_t *uuid, const bt2_common::LogCfg& logCfg)
-{
-    struct packet_header header;
-    size_t readlen, writelen, toread;
-    uint8_t buf[512 + 1]; /* + 1 for debug-mode \0 */
-    int ret = 0;
-    const long offset = ftell(in_fp);
-
-    if (offset < 0) {
-        BT_CLOGE_ERRNO_APPEND_CAUSE("Failed to get current metadata file position", ".");
-        goto error;
-    }
-    BT_CLOGD("Decoding metadata packet: offset=%ld", offset);
-    readlen = fread(&header, sizeof(header), 1, in_fp);
-    if (feof(in_fp) != 0) {
-        BT_CLOGI("Reached end of file: offset=%ld", ftell(in_fp));
-        goto end;
-    }
-    if (readlen < 1) {
-        BT_CLOGE_APPEND_CAUSE("Cannot decode metadata packet: offset=%ld", offset);
-        goto error;
-    }
-
-    if (byte_order != BYTE_ORDER) {
-        header.magic = GUINT32_SWAP_LE_BE(header.magic);
-        header.checksum = GUINT32_SWAP_LE_BE(header.checksum);
-        header.content_size = GUINT32_SWAP_LE_BE(header.content_size);
-        header.packet_size = GUINT32_SWAP_LE_BE(header.packet_size);
-    }
-
-    if (header.compression_scheme) {
-        BT_CLOGE_APPEND_CAUSE("Metadata packet compression is not supported as of this version: "
-                              "compression-scheme=%u, offset=%ld",
-                              (unsigned int) header.compression_scheme, offset);
-        goto error;
-    }
-
-    if (header.encryption_scheme) {
-        BT_CLOGE_APPEND_CAUSE("Metadata packet encryption is not supported as of this version: "
-                              "encryption-scheme=%u, offset=%ld",
-                              (unsigned int) header.encryption_scheme, offset);
-        goto error;
-    }
-
-    if (header.checksum || header.checksum_scheme) {
-        BT_CLOGE_APPEND_CAUSE(
-            "Metadata packet checksum verification is not supported as of this version: "
-            "checksum-scheme=%u, checksum=%x, offset=%ld",
-            (unsigned int) header.checksum_scheme, header.checksum, offset);
-        goto error;
-    }
-
-    if (!ctf_metadata_decoder_is_packet_version_valid(header.major, header.minor)) {
-        BT_CLOGE_APPEND_CAUSE("Invalid metadata packet version: "
-                              "version=%u.%u, offset=%ld",
-                              header.major, header.minor, offset);
-        goto error;
-    }
-
-    /* Set expected trace UUID if not set; otherwise validate it */
-    if (is_uuid_set) {
-        if (!*is_uuid_set) {
-            bt_uuid_copy(uuid, header.uuid);
-            *is_uuid_set = true;
-        } else if (bt_uuid_compare(header.uuid, uuid)) {
-            BT_CLOGE_APPEND_CAUSE("Metadata UUID mismatch between packets of the same stream: "
-                                  "packet-uuid=\"" BT_UUID_FMT "\", "
-                                  "expected-uuid=\"" BT_UUID_FMT "\", "
-                                  "offset=%ld",
-                                  BT_UUID_FMT_VALUES(header.uuid), BT_UUID_FMT_VALUES(uuid),
-                                  offset);
-            goto error;
-        }
-    }
-
-    if ((header.content_size / CHAR_BIT) < sizeof(header)) {
-        BT_CLOGE_APPEND_CAUSE("Bad metadata packet content size: content-size=%u, "
-                              "offset=%ld",
-                              header.content_size, offset);
-        goto error;
-    }
-
-    toread = header.content_size / CHAR_BIT - sizeof(header);
-
-    for (;;) {
-        size_t loop_read;
-
-        loop_read = MIN(sizeof(buf) - 1, toread);
-        readlen = fread(buf, sizeof(uint8_t), loop_read, in_fp);
-        if (ferror(in_fp)) {
-            BT_CLOGE_APPEND_CAUSE("Cannot read metadata packet buffer: "
-                                  "offset=%ld, read-size=%zu",
-                                  ftell(in_fp), loop_read);
-            goto error;
-        }
-        if (readlen > loop_read) {
-            BT_CLOGE_APPEND_CAUSE("fread returned more byte than expected: "
-                                  "read-size-asked=%zu, read-size-returned=%zu",
-                                  loop_read, readlen);
-            goto error;
-        }
-
-        writelen = fwrite(buf, sizeof(uint8_t), readlen, out_fp);
-        if (writelen < readlen || ferror(out_fp)) {
-            BT_CLOGE_APPEND_CAUSE("Cannot write decoded metadata text to buffer: "
-                                  "read-offset=%ld, write-size=%zu",
-                                  ftell(in_fp), readlen);
-            goto error;
-        }
-
-        toread -= readlen;
-        if (toread == 0) {
-            int fseek_ret;
-
-            /* Read leftover padding */
-            toread = (header.packet_size - header.content_size) / CHAR_BIT;
-            fseek_ret = fseek(in_fp, toread, SEEK_CUR);
-            if (fseek_ret < 0) {
-                BT_CLOGW_STR("Missing padding at the end of the metadata stream.");
-            }
-            break;
-        }
-    }
-
-    goto end;
-
-error:
-    ret = -1;
-
-end:
-    return ret;
-}
-
-BT_HIDDEN
-int ctf_metadata_decoder_packetized_file_stream_to_buf(FILE *fp, char **buf, int byte_order,
-                                                       bool *is_uuid_set, uint8_t *uuid,
-                                                       const bt2_common::LogCfg& logCfg)
-{
-    FILE *out_fp;
-    size_t size;
-    int ret = 0;
-    int tret;
-    size_t packet_index = 0;
-
-    out_fp = bt_open_memstream(buf, &size);
-    if (!out_fp) {
-        BT_CLOGE_APPEND_CAUSE("Cannot open memory stream: %s.", strerror(errno));
-        goto error;
-    }
-
-    for (;;) {
-        if (feof(fp) != 0) {
-            break;
-        }
-
-        tret = decode_packet(fp, out_fp, byte_order, is_uuid_set, uuid, logCfg);
-        if (tret) {
-            BT_CLOGE_APPEND_CAUSE("Cannot decode packet: index=%zu", packet_index);
-            goto error;
-        }
-
-        packet_index++;
-    }
-
-    /* Make sure the whole string ends with a null character */
-    tret = fputc('\0', out_fp);
-    if (tret == EOF) {
-        BT_CLOGE_APPEND_CAUSE("Cannot append '\\0' to the decoded metadata buffer.");
-        goto error;
-    }
-
-    /* Close stream, which also flushes the buffer */
-    ret = bt_close_memstream(buf, &size, out_fp);
-    /*
-     * See fclose(3). Further access to out_fp after both success
-     * and error, even through another bt_close_memstream(), results
-     * in undefined behavior. Nullify out_fp to ensure we don't
-     * fclose it twice on error.
-     */
-    out_fp = NULL;
-    if (ret < 0) {
-        BT_CLOGE_ERRNO_APPEND_CAUSE("Cannot close memory stream", ".");
-        goto error;
-    }
-
-    goto end;
-
-error:
-    ret = -1;
-
-    if (out_fp) {
-        if (bt_close_memstream(buf, &size, out_fp)) {
-            BT_CLOGE_ERRNO("Cannot close memory stream", ".");
-        }
-    }
-
-    if (*buf) {
-        free(*buf);
-        *buf = NULL;
-    }
-
-end:
-    return ret;
-}
diff --git a/src/plugins/ctf/common/src/metadata/tsdl/decoder-packetized-file-stream-to-buf.hpp b/src/plugins/ctf/common/src/metadata/tsdl/decoder-packetized-file-stream-to-buf.hpp
deleted file mode 100644 (file)
index 13f1644..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright 2019 Efficios Inc.
- */
-
-#ifndef SRC_PLUGINS_CTF_COMMON_METADATA_DECODER_PACKETIZED_FILE_STREAM_TO_BUF
-#define SRC_PLUGINS_CTF_COMMON_METADATA_DECODER_PACKETIZED_FILE_STREAM_TO_BUF
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdio.h>
-
-#include <babeltrace2/babeltrace.h>
-#include "cpp-common/log-cfg.hpp"
-
-BT_HIDDEN
-int ctf_metadata_decoder_packetized_file_stream_to_buf(FILE *fp, char **buf, int byte_order,
-                                                       bool *is_uuid_set, uint8_t *uuid,
-                                                       const bt2_common::LogCfg& logCfg);
-
-#endif /* SRC_PLUGINS_CTF_COMMON_METADATA_DECODER_PACKETIZED_FILE_STREAM_TO_BUF */
diff --git a/src/plugins/ctf/common/src/metadata/tsdl/decoder.cpp b/src/plugins/ctf/common/src/metadata/tsdl/decoder.cpp
deleted file mode 100644 (file)
index 9f40cb4..0000000
+++ /dev/null
@@ -1,436 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright 2016-2017 Philippe Proulx <pproulx@efficios.com>
- */
-
-#define BT_CLOG_CFG (mdec->config.logCfg)
-#define BT_LOG_TAG  "PLUGIN/CTF/META/DECODER"
-
-#include <stdio.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include "common/assert.h"
-#include "common/uuid.h"
-#include "compat/memstream.h"
-#include <babeltrace2/babeltrace.h>
-#include <glib.h>
-#include <string.h>
-
-#include "ast.hpp"
-#include "decoder.hpp"
-#include "scanner.hpp"
-#include "logging.hpp"
-#include "parser-wrap.hpp"
-#include "decoder-packetized-file-stream-to-buf.hpp"
-#include "cpp-common/cfg-logging-error-reporting.hpp"
-
-#define TSDL_MAGIC 0x75d11d57
-
-struct ctf_metadata_decoder
-{
-    explicit ctf_metadata_decoder(const bt2_common::LogCfg& logCfg) noexcept : config {logCfg}
-    {
-    }
-
-    struct ctf_scanner *scanner = nullptr;
-    GString *text = nullptr;
-    ctf_visitor_generate_ir::UP visitor;
-    bt_uuid_t uuid {};
-    bool is_uuid_set = false;
-    int bo = 0;
-    struct ctf_metadata_decoder_config config;
-    bool has_checked_plaintext_signature = false;
-};
-
-struct packet_header
-{
-    uint32_t magic;
-    bt_uuid_t uuid;
-    uint32_t checksum;
-    uint32_t content_size;
-    uint32_t packet_size;
-    uint8_t compression_scheme;
-    uint8_t encryption_scheme;
-    uint8_t checksum_scheme;
-    uint8_t major;
-    uint8_t minor;
-} __attribute__((__packed__));
-
-BT_HIDDEN
-int ctf_metadata_decoder_is_packetized(FILE *fp, bool *is_packetized, int *byte_order,
-                                       const bt2_common::LogCfg& logCfg)
-{
-    uint32_t magic;
-    size_t len;
-    int ret = 0;
-
-    *is_packetized = false;
-    len = fread(&magic, sizeof(magic), 1, fp);
-    if (len != 1) {
-        BT_CLOGI_EX(
-            logCfg,
-            "Cannot read first metadata packet header: assuming the stream is not packetized.");
-        ret = -1;
-        goto end;
-    }
-
-    if (byte_order) {
-        if (magic == TSDL_MAGIC) {
-            *is_packetized = true;
-            *byte_order = BYTE_ORDER;
-        } else if (magic == GUINT32_SWAP_LE_BE(TSDL_MAGIC)) {
-            *is_packetized = true;
-            *byte_order = BYTE_ORDER == BIG_ENDIAN ? LITTLE_ENDIAN : BIG_ENDIAN;
-        }
-    }
-
-end:
-    rewind(fp);
-
-    return ret;
-}
-
-BT_HIDDEN
-ctf_metadata_decoder_up
-ctf_metadata_decoder_create(const struct ctf_metadata_decoder_config *config)
-{
-    BT_ASSERT(config);
-    BT_CLOGD_EX(config->logCfg, "Creating CTF metadata decoder");
-
-    ctf_metadata_decoder *mdec = new ctf_metadata_decoder {config->logCfg};
-    mdec->scanner = ctf_scanner_alloc();
-    if (!mdec->scanner) {
-        BT_CLOGE_APPEND_CAUSE("Cannot allocate a metadata lexical scanner: "
-                              "mdec-addr=%p",
-                              mdec);
-        goto error;
-    }
-
-    mdec->text = g_string_new(NULL);
-    if (!mdec->text) {
-        BT_CLOGE_APPEND_CAUSE("Failed to allocate one GString: "
-                              "mdec-addr=%p",
-                              mdec);
-        goto error;
-    }
-
-    mdec->bo = -1;
-    mdec->config = *config;
-    mdec->visitor = ctf_visitor_generate_ir_create(config->self_comp, config->logCfg);
-    if (!mdec->visitor) {
-        BT_CLOGE_APPEND_CAUSE("Failed to create a CTF IR metadata AST visitor: "
-                              "mdec-addr=%p",
-                              mdec);
-        goto error;
-    }
-
-    BT_CLOGD("Created CTF metadata decoder: addr=%p", mdec);
-    goto end;
-
-error:
-    ctf_metadata_decoder_destroy(mdec);
-    mdec = NULL;
-
-end:
-    return ctf_metadata_decoder_up {mdec};
-}
-
-BT_HIDDEN
-void ctf_metadata_decoder_destroy(struct ctf_metadata_decoder *mdec)
-{
-    if (!mdec) {
-        return;
-    }
-
-    if (mdec->scanner) {
-        ctf_scanner_free(mdec->scanner);
-    }
-
-    if (mdec->text) {
-        g_string_free(mdec->text, TRUE);
-    }
-
-    BT_CLOGD("Destroying CTF metadata decoder: addr=%p", mdec);
-    delete mdec;
-}
-
-void ctf_metadata_decoder_deleter::operator()(ctf_metadata_decoder *decoder)
-{
-    ctf_metadata_decoder_destroy(decoder);
-}
-
-BT_HIDDEN
-enum ctf_metadata_decoder_status
-ctf_metadata_decoder_append_content(struct ctf_metadata_decoder *mdec, FILE *fp)
-{
-    enum ctf_metadata_decoder_status status = CTF_METADATA_DECODER_STATUS_OK;
-    int ret;
-    char *buf = NULL;
-    bool close_fp = false;
-    long start_pos = -1;
-    bool is_packetized;
-
-    BT_ASSERT(mdec);
-    ret = ctf_metadata_decoder_is_packetized(fp, &is_packetized, &mdec->bo, mdec->config.logCfg);
-    if (ret) {
-        status = CTF_METADATA_DECODER_STATUS_ERROR;
-        goto end;
-    }
-
-    if (is_packetized) {
-        BT_CLOGI("Metadata stream is packetized: mdec-addr=%p", mdec);
-        ret = ctf_metadata_decoder_packetized_file_stream_to_buf(
-            fp, &buf, mdec->bo, &mdec->is_uuid_set, mdec->uuid, mdec->config.logCfg);
-        if (ret) {
-            BT_CLOGE_APPEND_CAUSE("Cannot decode packetized metadata packets to metadata text: "
-                                  "mdec-addr=%p, ret=%d",
-                                  mdec, ret);
-            status = CTF_METADATA_DECODER_STATUS_ERROR;
-            goto end;
-        }
-
-        if (strlen(buf) == 0) {
-            /* An empty metadata packet is OK. */
-            goto end;
-        }
-
-        /* Convert the real file pointer to a memory file pointer */
-        fp = bt_fmemopen(buf, strlen(buf), "rb");
-        close_fp = true;
-        if (!fp) {
-            BT_CLOGE_APPEND_CAUSE("Cannot memory-open metadata buffer: %s: "
-                                  "mdec-addr=%p",
-                                  strerror(errno), mdec);
-            status = CTF_METADATA_DECODER_STATUS_ERROR;
-            goto end;
-        }
-    } else if (!mdec->has_checked_plaintext_signature) {
-        unsigned int major, minor;
-        ssize_t nr_items;
-        const long init_pos = ftell(fp);
-
-        BT_CLOGI("Metadata stream is plain text: mdec-addr=%p", mdec);
-
-        if (init_pos < 0) {
-            BT_CLOGE_ERRNO_APPEND_CAUSE("Failed to get current file position", ".");
-            status = CTF_METADATA_DECODER_STATUS_ERROR;
-            goto end;
-        }
-
-        /* Check text-only metadata header and version */
-        nr_items = fscanf(fp, "/* CTF %10u.%10u", &major, &minor);
-        if (nr_items < 2) {
-            BT_CLOGW("Missing \"/* CTF major.minor\" signature in plain text metadata file stream: "
-                     "mdec-addr=%p",
-                     mdec);
-        }
-
-        BT_CLOGI("Found metadata stream version in signature: version=%u.%u", major, minor);
-
-        if (!ctf_metadata_decoder_is_packet_version_valid(major, minor)) {
-            BT_CLOGE_APPEND_CAUSE("Invalid metadata version found in plain text signature: "
-                                  "version=%u.%u, mdec-addr=%p",
-                                  major, minor, mdec);
-            status = CTF_METADATA_DECODER_STATUS_INVAL_VERSION;
-            goto end;
-        }
-
-        if (fseek(fp, init_pos, SEEK_SET)) {
-            BT_CLOGE_APPEND_CAUSE("Cannot seek metadata file stream to initial position: %s: "
-                                  "mdec-addr=%p",
-                                  strerror(errno), mdec);
-            status = CTF_METADATA_DECODER_STATUS_ERROR;
-            goto end;
-        }
-
-        mdec->has_checked_plaintext_signature = true;
-    }
-
-#if YYDEBUG
-    if (BT_LOG_ON_TRACE) {
-        yydebug = 1;
-    }
-#endif
-
-    /* Save the file's position: we'll seek back to append the plain text */
-    BT_ASSERT(fp);
-
-    if (mdec->config.keep_plain_text) {
-        start_pos = ftell(fp);
-    }
-
-    /* Append the metadata text content */
-    ret = ctf_scanner_append_ast(mdec->scanner, fp);
-    if (ret) {
-        BT_CLOGE_APPEND_CAUSE("Cannot create the metadata AST out of the metadata text: "
-                              "mdec-addr=%p",
-                              mdec);
-        status = CTF_METADATA_DECODER_STATUS_INCOMPLETE;
-        goto end;
-    }
-
-    /* We know it's complete: append plain text */
-    if (mdec->config.keep_plain_text) {
-        BT_ASSERT(start_pos != -1);
-        ret = fseek(fp, start_pos, SEEK_SET);
-        if (ret) {
-            BT_CLOGE_APPEND_CAUSE("Failed to seek file: ret=%d, mdec-addr=%p", ret, mdec);
-            status = CTF_METADATA_DECODER_STATUS_ERROR;
-            goto end;
-        }
-
-        ret = bt_common_append_file_content_to_g_string(mdec->text, fp);
-        if (ret) {
-            BT_CLOGE_APPEND_CAUSE("Failed to append to current plain text: "
-                                  "ret=%d, mdec-addr=%p",
-                                  ret, mdec);
-            status = CTF_METADATA_DECODER_STATUS_ERROR;
-            goto end;
-        }
-    }
-
-    ret = ctf_visitor_semantic_check(0, &mdec->scanner->ast->root, mdec->config.logCfg);
-    if (ret) {
-        BT_CLOGE_APPEND_CAUSE("Validation of the metadata semantics failed: "
-                              "mdec-addr=%p",
-                              mdec);
-        status = CTF_METADATA_DECODER_STATUS_ERROR;
-        goto end;
-    }
-
-    if (mdec->config.create_trace_class) {
-        ret = ctf_visitor_generate_ir_visit_node(mdec->visitor.get(), &mdec->scanner->ast->root);
-        switch (ret) {
-        case 0:
-            /* Success */
-            break;
-        case -EINCOMPLETE:
-            BT_CLOGD("While visiting metadata AST: incomplete data: "
-                     "mdec-addr=%p",
-                     mdec);
-            status = CTF_METADATA_DECODER_STATUS_INCOMPLETE;
-            goto end;
-        default:
-            BT_CLOGE_APPEND_CAUSE("Failed to visit AST node to create CTF IR objects: "
-                                  "mdec-addr=%p, ret=%d",
-                                  mdec, ret);
-            status = CTF_METADATA_DECODER_STATUS_IR_VISITOR_ERROR;
-            goto end;
-        }
-    }
-
-end:
-#if YYDEBUG
-    yydebug = 0;
-#endif
-
-    if (fp && close_fp) {
-        if (fclose(fp)) {
-            BT_CLOGE("Cannot close metadata file stream: "
-                     "mdec-addr=%p",
-                     mdec);
-        }
-    }
-
-    free(buf);
-
-    return status;
-}
-
-BT_HIDDEN
-nonstd::optional<bt2::TraceClass::Shared>
-ctf_metadata_decoder_get_ir_trace_class(struct ctf_metadata_decoder *mdec)
-{
-    BT_ASSERT_DBG(mdec);
-    BT_ASSERT_DBG(mdec->config.create_trace_class);
-    return ctf_visitor_generate_ir_get_ir_trace_class(mdec->visitor.get());
-}
-
-BT_HIDDEN
-struct ctf_trace_class *
-ctf_metadata_decoder_borrow_ctf_trace_class(struct ctf_metadata_decoder *mdec)
-{
-    BT_ASSERT_DBG(mdec);
-    BT_ASSERT_DBG(mdec->config.create_trace_class);
-    return ctf_visitor_generate_ir_borrow_ctf_trace_class(mdec->visitor.get());
-}
-
-BT_HIDDEN
-const char *ctf_metadata_decoder_get_text(struct ctf_metadata_decoder *mdec)
-{
-    BT_ASSERT_DBG(mdec);
-    BT_ASSERT_DBG(mdec->config.keep_plain_text);
-    return mdec->text->str;
-}
-
-static enum ctf_metadata_decoder_status find_uuid_in_trace_decl(struct ctf_metadata_decoder *mdec,
-                                                                struct ctf_node *trace_node,
-                                                                bt_uuid_t uuid)
-{
-    enum ctf_metadata_decoder_status status = CTF_METADATA_DECODER_STATUS_OK;
-    struct ctf_node *entry_node;
-    struct bt_list_head *decl_list = &trace_node->u.trace.declaration_list;
-    char *left = NULL;
-
-    bt_list_for_each_entry (entry_node, decl_list, siblings) {
-        if (entry_node->type == NODE_CTF_EXPRESSION) {
-            int ret;
-
-            left = ctf_ast_concatenate_unary_strings(&entry_node->u.ctf_expression.left);
-            if (!left) {
-                BT_CLOGE_APPEND_CAUSE("Cannot concatenate unary strings.");
-                status = CTF_METADATA_DECODER_STATUS_ERROR;
-                goto end;
-            }
-
-            if (strcmp(left, "uuid") == 0) {
-                ret = ctf_ast_get_unary_uuid(&entry_node->u.ctf_expression.right, uuid,
-                                             mdec->config.logCfg);
-                if (ret) {
-                    BT_CLOGE_APPEND_CAUSE("Invalid trace's `uuid` attribute.");
-                    status = CTF_METADATA_DECODER_STATUS_ERROR;
-                    goto end;
-                }
-
-                goto end;
-            }
-
-            g_free(left);
-            left = NULL;
-        }
-    }
-
-    status = CTF_METADATA_DECODER_STATUS_NONE;
-
-end:
-    g_free(left);
-    return status;
-}
-
-BT_HIDDEN
-enum ctf_metadata_decoder_status
-ctf_metadata_decoder_get_trace_class_uuid(struct ctf_metadata_decoder *mdec, bt_uuid_t uuid)
-{
-    enum ctf_metadata_decoder_status status = CTF_METADATA_DECODER_STATUS_INCOMPLETE;
-    struct ctf_node *root_node = &mdec->scanner->ast->root;
-    struct ctf_node *trace_node;
-
-    if (!root_node) {
-        status = CTF_METADATA_DECODER_STATUS_INCOMPLETE;
-        goto end;
-    }
-
-    trace_node = bt_list_entry(root_node->u.root.trace.next, struct ctf_node, siblings);
-    if (!trace_node) {
-        status = CTF_METADATA_DECODER_STATUS_INCOMPLETE;
-        goto end;
-    }
-
-    status = find_uuid_in_trace_decl(mdec, trace_node, uuid);
-
-end:
-    return status;
-}
diff --git a/src/plugins/ctf/common/src/metadata/tsdl/decoder.hpp b/src/plugins/ctf/common/src/metadata/tsdl/decoder.hpp
deleted file mode 100644 (file)
index d5384e3..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright 2016-2017 Philippe Proulx <pproulx@efficios.com>
- */
-
-#ifndef _METADATA_DECODER_H
-#define _METADATA_DECODER_H
-
-#include <memory>
-#include <stdint.h>
-#include <stdbool.h>
-#include <stdio.h>
-
-#include <babeltrace2/babeltrace.h>
-
-#include "common/macros.h"
-#include "common/uuid.h"
-#include "cpp-common/log-cfg.hpp"
-#include "../../clk-cls-cfg.hpp"
-#include "cpp-common/optional.hpp"
-#include "cpp-common/bt2/trace-ir.hpp"
-
-struct ctf_trace_class;
-
-/* A CTF metadata decoder object */
-struct ctf_metadata_decoder;
-
-/* CTF metadata decoder status */
-enum ctf_metadata_decoder_status
-{
-    CTF_METADATA_DECODER_STATUS_OK = 0,
-    CTF_METADATA_DECODER_STATUS_NONE = 1,
-    CTF_METADATA_DECODER_STATUS_ERROR = -1,
-    CTF_METADATA_DECODER_STATUS_INCOMPLETE = -2,
-    CTF_METADATA_DECODER_STATUS_INVAL_VERSION = -3,
-    CTF_METADATA_DECODER_STATUS_IR_VISITOR_ERROR = -4,
-};
-
-/* Decoding configuration */
-struct ctf_metadata_decoder_config
-{
-    explicit ctf_metadata_decoder_config(const bt2_common::LogCfg& logCfgParam) noexcept :
-        logCfg {logCfgParam}
-    {
-    }
-
-    bt2_common::LogCfg logCfg;
-
-    /* Weak, used to create a bt_trace_class, if not nullptr. */
-    bt_self_component *self_comp = nullptr;
-
-    /* True to create trace class objects */
-    bool create_trace_class = false;
-
-    /*
-     * True to keep the plain text when content is appended with
-     * ctf_metadata_decoder_append_content().
-     */
-    bool keep_plain_text = false;
-};
-
-struct ctf_metadata_decoder_deleter
-{
-    void operator()(ctf_metadata_decoder *decoder);
-};
-
-using ctf_metadata_decoder_up = std::unique_ptr<ctf_metadata_decoder, ctf_metadata_decoder_deleter>;
-
-/*
- * Creates a CTF metadata decoder.
- *
- * Returns `NULL` on error.
- */
-BT_HIDDEN
-ctf_metadata_decoder_up
-ctf_metadata_decoder_create(const struct ctf_metadata_decoder_config *config);
-
-/*
- * Destroys a CTF metadata decoder that you created with
- * ctf_metadata_decoder_create().
- */
-BT_HIDDEN
-void ctf_metadata_decoder_destroy(struct ctf_metadata_decoder *metadata_decoder);
-
-/*
- * Appends content to the metadata decoder.
- *
- * This function reads the metadata from the current position of `fp`
- * until the end of this file stream.
- *
- * The metadata can be packetized or not.
- *
- * The metadata chunk needs to be complete and lexically scannable, that
- * is, zero or more complete top-level blocks. If it's incomplete, this
- * function returns `CTF_METADATA_DECODER_STATUS_INCOMPLETE`. If this
- * function returns `CTF_METADATA_DECODER_STATUS_INCOMPLETE`, then you
- * need to call it again with the _same_ metadata and more to make it
- * complete. For example:
- *
- *     First call:  event { name = hell
- *     Second call: event { name = hello_world; ... };
- *
- * If everything goes as expected, this function returns
- * `CTF_METADATA_DECODER_STATUS_OK`.
- */
-BT_HIDDEN
-enum ctf_metadata_decoder_status
-ctf_metadata_decoder_append_content(struct ctf_metadata_decoder *metadata_decoder, FILE *fp);
-
-/*
- * Returns the trace IR trace class of this metadata decoder (new
- * reference).
- *
- * Returns `NULL` if there's none yet or if the metadata decoder is not
- * configured to create trace classes.
- */
-BT_HIDDEN
-nonstd::optional<bt2::TraceClass::Shared>
-ctf_metadata_decoder_get_ir_trace_class(struct ctf_metadata_decoder *mdec);
-
-/*
- * Returns the CTF IR trace class of this metadata decoder.
- *
- * Returns `NULL` if there's none yet or if the metadata decoder is not
- * configured to create trace classes.
- */
-BT_HIDDEN
-struct ctf_trace_class *
-ctf_metadata_decoder_borrow_ctf_trace_class(struct ctf_metadata_decoder *mdec);
-
-/*
- * Checks whether or not a given metadata file stream `fp` is
- * packetized, setting `is_packetized` accordingly on success. On
- * success, also sets `*byte_order` to the byte order of the first
- * packet.
- *
- * This function uses `log_level` and `self_comp` for logging purposes.
- * `self_comp` can be `NULL` if not available.
- */
-BT_HIDDEN
-int ctf_metadata_decoder_is_packetized(FILE *fp, bool *is_packetized, int *byte_order,
-                                       const bt2_common::LogCfg& logCfg);
-
-/*
- * Returns the UUID of the decoder's trace class, if available.
- *
- * Returns:
- *
- * * `CTF_METADATA_DECODER_STATUS_OK`: success.
- * * `CTF_METADATA_DECODER_STATUS_NONE`: no UUID.
- * * `CTF_METADATA_DECODER_STATUS_INCOMPLETE`: missing metadata content.
- */
-BT_HIDDEN
-enum ctf_metadata_decoder_status
-ctf_metadata_decoder_get_trace_class_uuid(struct ctf_metadata_decoder *mdec, bt_uuid_t uuid);
-
-/*
- * Returns the metadata decoder's current metadata text.
- */
-BT_HIDDEN
-const char *ctf_metadata_decoder_get_text(struct ctf_metadata_decoder *mdec);
-
-static inline bool ctf_metadata_decoder_is_packet_version_valid(unsigned int major,
-                                                                unsigned int minor)
-{
-    return major == 1 && minor == 8;
-}
-
-#endif /* _METADATA_DECODER_H */
index ac33e471d46c352367bac1ab569b17182d128404..020ea282c23047626006471c61a458c816de55a7 100644 (file)
@@ -28,7 +28,6 @@
 #include "logging.hpp"
 #include "scanner.hpp"
 #include "ast.hpp"
-#include "decoder.hpp"
 #include "ctf-meta.hpp"
 #include "ctf-meta-visitors.hpp"
 #include "cpp-common/cfg-logging-error-reporting.hpp"
@@ -498,41 +497,23 @@ ctf_visitor_generate_ir::~ctf_visitor_generate_ir()
 }
 
 BT_HIDDEN
-ctf_visitor_generate_ir::UP ctf_visitor_generate_ir_create(bt_self_component *selfComp,
-                                                           const bt2_common::LogCfg& logCfg)
+ctf_visitor_generate_ir::UP ctf_visitor_generate_ir_create(const bt2_common::LogCfg& logCfg)
 {
-    ctf_visitor_generate_ir::UP ctx =
-        bt2_common::makeUnique<ctf_visitor_generate_ir>(selfComp, logCfg);
-
-    if (selfComp) {
-        bt_trace_class *trace_class = bt_trace_class_create(selfComp);
-        if (!trace_class) {
-            BT_CLOGE_APPEND_CAUSE("Cannot create empty trace class.");
-            goto error;
-        }
-
-        ctx->trace_class = bt2::TraceClass::Shared::createWithoutRef(trace_class);
-    }
+    ctf_visitor_generate_ir::UP ctx = bt2_common::makeUnique<ctf_visitor_generate_ir>(logCfg);
 
     ctx->ctf_tc = ctf_trace_class_create();
     if (!ctx->ctf_tc) {
         BT_CLOGE_APPEND_CAUSE("Cannot create CTF trace class.");
-        goto error;
+        return nullptr;
     }
 
     /* Root declaration scope */
     ctx->current_scope = ctx_decl_scope_create(ctx.get(), NULL);
     if (!ctx->current_scope) {
         BT_CLOGE_APPEND_CAUSE("Cannot create declaration scope.");
-        goto error;
+        return nullptr;
     }
 
-    goto end;
-
-error:
-    ctx.reset();
-
-end:
     return ctx;
 }
 
@@ -2573,7 +2554,6 @@ static int visit_string_decl(struct ctf_visitor_generate_ir *ctx, struct bt_list
     int set = 0;
     int ret = 0;
     struct ctf_node *expression;
-    enum ctf_encoding encoding = CTF_ENCODING_UTF8;
 
     *string_decl = NULL;
 
@@ -2620,9 +2600,9 @@ static int visit_string_decl(struct ctf_visitor_generate_ir *ctx, struct bt_list
             if (strcmp(s_right, "UTF8") == 0 || strcmp(s_right, "utf8") == 0 ||
                 strcmp(s_right, "utf-8") == 0 || strcmp(s_right, "UTF-8") == 0 ||
                 strcmp(s_right, "ASCII") == 0 || strcmp(s_right, "ascii") == 0) {
-                encoding = CTF_ENCODING_UTF8;
+                /* empty */
             } else if (strcmp(s_right, "none") == 0) {
-                encoding = CTF_ENCODING_NONE;
+                /* empty */
             } else {
                 _BT_CLOGE_APPEND_CAUSE_NODE(right,
                                             "Invalid `encoding` attribute in string field class: "
@@ -2645,7 +2625,6 @@ static int visit_string_decl(struct ctf_visitor_generate_ir *ctx, struct bt_list
 
     *string_decl = ctf_field_class_string_create();
     BT_ASSERT(*string_decl);
-    (*string_decl)->encoding = encoding;
     return 0;
 
 error:
@@ -4322,24 +4301,6 @@ end:
     return ret;
 }
 
-BT_HIDDEN
-nonstd::optional<bt2::TraceClass::Shared>
-ctf_visitor_generate_ir_get_ir_trace_class(struct ctf_visitor_generate_ir *ctx)
-{
-    BT_ASSERT_DBG(ctx);
-
-    return ctx->trace_class;
-}
-
-BT_HIDDEN
-struct ctf_trace_class *
-ctf_visitor_generate_ir_borrow_ctf_trace_class(struct ctf_visitor_generate_ir *ctx)
-{
-    BT_ASSERT_DBG(ctx);
-    BT_ASSERT_DBG(ctx->ctf_tc);
-    return ctx->ctf_tc;
-}
-
 BT_HIDDEN
 int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *ctx, struct ctf_node *node)
 {
@@ -4496,13 +4457,6 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *ctx, stru
         goto end;
     }
 
-    /* Update stream class configuration */
-    ret = ctf_trace_class_update_stream_class_config(ctx->ctf_tc);
-    if (ret) {
-        ret = -EINVAL;
-        goto end;
-    }
-
     /* Update text arrays and sequences */
     ret = ctf_trace_class_update_text_array_sequence(ctx->ctf_tc);
     if (ret) {
@@ -4524,28 +4478,6 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *ctx, stru
         goto end;
     }
 
-    if (ctx->trace_class) {
-        /*
-         * Update "in IR" for field classes.
-         *
-         * If we have no IR trace class, then we'll have no way
-         * to create IR fields anyway, so we leave all the
-         * `in_ir` members false.
-         */
-        ret = ctf_trace_class_update_in_ir(ctx->ctf_tc);
-        if (ret) {
-            ret = -EINVAL;
-            goto end;
-        }
-    }
-
-    /* Update saved value indexes */
-    ret = ctf_trace_class_update_value_storing_indexes(ctx->ctf_tc);
-    if (ret) {
-        ret = -EINVAL;
-        goto end;
-    }
-
     /* Validate what we have so far */
     ret = ctf_trace_class_validate(ctx->ctf_tc, ctx->logCfg);
     if (ret) {
@@ -4560,16 +4492,6 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *ctx, stru
      */
     ctf_trace_class_warn_meaningless_header_fields(ctx->ctf_tc, ctx->logCfg);
 
-    if (ctx->trace_class) {
-        /* Copy new CTF metadata -> new IR metadata */
-        ret =
-            ctf_trace_class_translate(ctx->selfComp, (*ctx->trace_class)->libObjPtr(), ctx->ctf_tc);
-        if (ret) {
-            ret = -EINVAL;
-            goto end;
-        }
-    }
-
 end:
     return ret;
 }
diff --git a/src/plugins/ctf/common/src/msg-iter/Makefile.am b/src/plugins/ctf/common/src/msg-iter/Makefile.am
deleted file mode 100644 (file)
index d963df7..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# SPDX-License-Identifier: MIT
-
-noinst_LTLIBRARIES = libctf-msg-iter.la
-
-libctf_msg_iter_la_SOURCES = \
-       msg-iter.cpp \
-       msg-iter.hpp
diff --git a/src/plugins/ctf/common/src/msg-iter/msg-iter.cpp b/src/plugins/ctf/common/src/msg-iter/msg-iter.cpp
deleted file mode 100644 (file)
index bbd138d..0000000
+++ /dev/null
@@ -1,2930 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (c) 2015-2018 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * Babeltrace - CTF message iterator
- */
-
-#define BT_CLOG_CFG (msg_it->logCfg)
-#define BT_LOG_TAG  "PLUGIN/CTF/MSG-ITER"
-
-#include <stdint.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <stdbool.h>
-#include "common/assert.h"
-#include <string.h>
-#include <babeltrace2/babeltrace.h>
-#include "common/common.h"
-#include <glib.h>
-#include <stdlib.h>
-
-#include "msg-iter.hpp"
-#include "../bfcr/bfcr.hpp"
-#include "cpp-common/log-cfg.hpp"
-#include "cpp-common/cfg-logging.hpp"
-#include "cpp-common/cfg-logging-error-reporting.hpp"
-
-struct ctf_msg_iter;
-
-/* A visit stack entry */
-struct stack_entry
-{
-    /*
-     * Current base field, one of:
-     *
-     *   * string
-     *   * structure
-     *   * array
-     *   * sequence
-     *   * variant
-     *
-     * Field is borrowed.
-     */
-    bt_field *base;
-
-    /* Index of next field to set */
-    size_t index;
-};
-
-struct ctf_msg_iter;
-
-/* Visit stack */
-struct stack
-{
-    struct ctf_msg_iter *msg_it;
-
-    /* Entries (struct stack_entry) */
-    GArray *entries;
-
-    /* Number of active entries */
-    size_t size;
-};
-
-/* State */
-enum state
-{
-    STATE_INIT,
-    STATE_SWITCH_PACKET,
-    STATE_DSCOPE_TRACE_PACKET_HEADER_BEGIN,
-    STATE_DSCOPE_TRACE_PACKET_HEADER_CONTINUE,
-    STATE_AFTER_TRACE_PACKET_HEADER,
-    STATE_DSCOPE_STREAM_PACKET_CONTEXT_BEGIN,
-    STATE_DSCOPE_STREAM_PACKET_CONTEXT_CONTINUE,
-    STATE_AFTER_STREAM_PACKET_CONTEXT,
-    STATE_EMIT_MSG_STREAM_BEGINNING,
-    STATE_CHECK_EMIT_MSG_DISCARDED_EVENTS,
-    STATE_CHECK_EMIT_MSG_DISCARDED_PACKETS,
-    STATE_EMIT_MSG_DISCARDED_EVENTS,
-    STATE_EMIT_MSG_DISCARDED_PACKETS,
-    STATE_EMIT_MSG_PACKET_BEGINNING,
-    STATE_DSCOPE_EVENT_HEADER_BEGIN,
-    STATE_DSCOPE_EVENT_HEADER_CONTINUE,
-    STATE_AFTER_EVENT_HEADER,
-    STATE_DSCOPE_EVENT_COMMON_CONTEXT_BEGIN,
-    STATE_DSCOPE_EVENT_COMMON_CONTEXT_CONTINUE,
-    STATE_DSCOPE_EVENT_SPEC_CONTEXT_BEGIN,
-    STATE_DSCOPE_EVENT_SPEC_CONTEXT_CONTINUE,
-    STATE_DSCOPE_EVENT_PAYLOAD_BEGIN,
-    STATE_DSCOPE_EVENT_PAYLOAD_CONTINUE,
-    STATE_EMIT_MSG_EVENT,
-    STATE_EMIT_QUEUED_MSG_EVENT,
-    STATE_SKIP_PACKET_PADDING,
-    STATE_EMIT_MSG_PACKET_END_MULTI,
-    STATE_EMIT_MSG_PACKET_END_SINGLE,
-    STATE_EMIT_QUEUED_MSG_PACKET_END,
-    STATE_CHECK_EMIT_MSG_STREAM_END,
-    STATE_EMIT_MSG_STREAM_END,
-    STATE_DONE,
-};
-
-struct end_of_packet_snapshots
-{
-    uint64_t discarded_events = 0;
-    uint64_t packets = 0;
-    uint64_t beginning_clock = 0;
-    uint64_t end_clock = 0;
-};
-
-/* CTF message iterator */
-struct ctf_msg_iter
-{
-    explicit ctf_msg_iter(const bt2_common::LogCfg& logCfgParam) noexcept : logCfg {logCfgParam}
-    {
-    }
-
-    /* Visit stack */
-    struct stack *stack = nullptr;
-
-    /* Current message iterator to create messages (weak) */
-    bt_self_message_iterator *self_msg_iter = nullptr;
-
-    /*
-     * True if library objects are unavailable during the decoding and
-     * should not be created/used.
-     */
-    bool dry_run = false;
-
-    /*
-     * Current dynamic scope field pointer.
-     *
-     * This is set by read_dscope_begin_state() and contains the
-     * value of one of the pointers in `dscopes` below.
-     */
-    bt_field *cur_dscope_field = nullptr;
-
-    /*
-     * True if we're done filling a string field from a text
-     * array/sequence payload.
-     */
-    bool done_filling_string = false;
-
-    /* Trace and classes */
-    /* True to set IR fields */
-    bool set_ir_fields = false;
-
-    struct
-    {
-        struct ctf_trace_class *tc = nullptr;
-        struct ctf_stream_class *sc = nullptr;
-        struct ctf_event_class *ec = nullptr;
-    } meta;
-
-    /* Current packet (NULL if not created yet) */
-    bt_packet *packet = nullptr;
-
-    /* Current stream (NULL if not set yet) */
-    bt_stream *stream = nullptr;
-
-    /* Current event (NULL if not created yet) */
-    bt_event *event = nullptr;
-
-    /* Current event message (NULL if not created yet) */
-    bt_message *event_msg = nullptr;
-
-    /*
-     * True if we need to emit a packet beginning message before we emit
-     * the next event message or the packet end message.
-     */
-    bool emit_delayed_packet_beginning_msg = false;
-
-    /*
-     * True if this is the first packet we are reading, and therefore if we
-     * should emit a stream beginning message.
-     */
-    bool emit_stream_beginning_message = false;
-
-    /*
-     * True if we need to emit a stream end message at the end of the
-     * current stream. A live stream may never receive any data and thus
-     * never send a stream beginning message which removes the need to emit
-     * a stream end message.
-     */
-    bool emit_stream_end_message = false;
-
-    /* Database of current dynamic scopes */
-    struct
-    {
-        bt_field *stream_packet_context = nullptr;
-        bt_field *event_common_context = nullptr;
-        bt_field *event_spec_context = nullptr;
-        bt_field *event_payload = nullptr;
-    } dscopes;
-
-    /* Current state */
-    enum state state = STATE_INIT;
-
-    /* Current medium buffer data */
-    struct
-    {
-        /* Last address provided by medium */
-        const uint8_t *addr = nullptr;
-
-        /* Buffer size provided by medium (bytes) */
-        size_t sz = 0;
-
-        /* Offset within whole packet of addr (bits) */
-        size_t packet_offset = 0;
-
-        /* Current position from addr (bits) */
-        size_t at = 0;
-
-        /* Position of the last event header from addr (bits) */
-        size_t last_eh_at = 0;
-    } buf;
-
-    /* Binary type reader */
-    struct bt_bfcr *bfcr = nullptr;
-
-    /* Current medium data */
-    struct
-    {
-        struct ctf_msg_iter_medium_ops medops;
-        size_t max_request_sz = 0;
-        void *data = nullptr;
-    } medium;
-
-    /* Current packet size (bits) (-1 if unknown) */
-    int64_t cur_exp_packet_total_size = 0;
-
-    /* Current content size (bits) (-1 if unknown) */
-    int64_t cur_exp_packet_content_size = 0;
-
-    /* Current stream class ID */
-    int64_t cur_stream_class_id = 0;
-
-    /* Current event class ID */
-    int64_t cur_event_class_id = 0;
-
-    /* Current data stream ID */
-    int64_t cur_data_stream_id = 0;
-
-    /*
-     * Offset, in the underlying media, of the current packet's
-     * start (-1 if unknown).
-     */
-    off_t cur_packet_offset = 0;
-
-    /* Default clock's current value */
-    uint64_t default_clock_snapshot = 0;
-
-    /* End of current packet snapshots */
-    struct end_of_packet_snapshots snapshots;
-
-    /* End of previous packet snapshots */
-    struct end_of_packet_snapshots prev_packet_snapshots;
-
-    /* Stored values (for sequence lengths, variant tags) */
-    GArray *stored_values = nullptr;
-
-    const bt2_common::LogCfg logCfg;
-};
-
-static inline const char *state_string(enum state state)
-{
-    switch (state) {
-    case STATE_INIT:
-        return "INIT";
-    case STATE_SWITCH_PACKET:
-        return "SWITCH_PACKET";
-    case STATE_DSCOPE_TRACE_PACKET_HEADER_BEGIN:
-        return "DSCOPE_TRACE_PACKET_HEADER_BEGIN";
-    case STATE_DSCOPE_TRACE_PACKET_HEADER_CONTINUE:
-        return "DSCOPE_TRACE_PACKET_HEADER_CONTINUE";
-    case STATE_AFTER_TRACE_PACKET_HEADER:
-        return "AFTER_TRACE_PACKET_HEADER";
-    case STATE_DSCOPE_STREAM_PACKET_CONTEXT_BEGIN:
-        return "DSCOPE_STREAM_PACKET_CONTEXT_BEGIN";
-    case STATE_DSCOPE_STREAM_PACKET_CONTEXT_CONTINUE:
-        return "DSCOPE_STREAM_PACKET_CONTEXT_CONTINUE";
-    case STATE_AFTER_STREAM_PACKET_CONTEXT:
-        return "AFTER_STREAM_PACKET_CONTEXT";
-    case STATE_EMIT_MSG_STREAM_BEGINNING:
-        return "EMIT_MSG_STREAM_BEGINNING";
-    case STATE_CHECK_EMIT_MSG_DISCARDED_EVENTS:
-        return "CHECK_EMIT_MSG_DISCARDED_EVENTS";
-    case STATE_CHECK_EMIT_MSG_DISCARDED_PACKETS:
-        return "CHECK_EMIT_MSG_DISCARDED_PACKETS";
-    case STATE_EMIT_MSG_PACKET_BEGINNING:
-        return "EMIT_MSG_PACKET_BEGINNING";
-    case STATE_EMIT_MSG_DISCARDED_EVENTS:
-        return "EMIT_MSG_DISCARDED_EVENTS";
-    case STATE_EMIT_MSG_DISCARDED_PACKETS:
-        return "EMIT_MSG_DISCARDED_PACKETS";
-    case STATE_DSCOPE_EVENT_HEADER_BEGIN:
-        return "DSCOPE_EVENT_HEADER_BEGIN";
-    case STATE_DSCOPE_EVENT_HEADER_CONTINUE:
-        return "DSCOPE_EVENT_HEADER_CONTINUE";
-    case STATE_AFTER_EVENT_HEADER:
-        return "AFTER_EVENT_HEADER";
-    case STATE_DSCOPE_EVENT_COMMON_CONTEXT_BEGIN:
-        return "DSCOPE_EVENT_COMMON_CONTEXT_BEGIN";
-    case STATE_DSCOPE_EVENT_COMMON_CONTEXT_CONTINUE:
-        return "DSCOPE_EVENT_COMMON_CONTEXT_CONTINUE";
-    case STATE_DSCOPE_EVENT_SPEC_CONTEXT_BEGIN:
-        return "DSCOPE_EVENT_SPEC_CONTEXT_BEGIN";
-    case STATE_DSCOPE_EVENT_SPEC_CONTEXT_CONTINUE:
-        return "DSCOPE_EVENT_SPEC_CONTEXT_CONTINUE";
-    case STATE_DSCOPE_EVENT_PAYLOAD_BEGIN:
-        return "DSCOPE_EVENT_PAYLOAD_BEGIN";
-    case STATE_DSCOPE_EVENT_PAYLOAD_CONTINUE:
-        return "DSCOPE_EVENT_PAYLOAD_CONTINUE";
-    case STATE_EMIT_MSG_EVENT:
-        return "EMIT_MSG_EVENT";
-    case STATE_EMIT_QUEUED_MSG_EVENT:
-        return "EMIT_QUEUED_MSG_EVENT";
-    case STATE_SKIP_PACKET_PADDING:
-        return "SKIP_PACKET_PADDING";
-    case STATE_EMIT_MSG_PACKET_END_MULTI:
-        return "EMIT_MSG_PACKET_END_MULTI";
-    case STATE_EMIT_MSG_PACKET_END_SINGLE:
-        return "EMIT_MSG_PACKET_END_SINGLE";
-    case STATE_EMIT_QUEUED_MSG_PACKET_END:
-        return "EMIT_QUEUED_MSG_PACKET_END";
-    case STATE_CHECK_EMIT_MSG_STREAM_END:
-        return "CHECK_EMIT_MSG_STREAM_END";
-    case STATE_EMIT_MSG_STREAM_END:
-        return "EMIT_MSG_STREAM_END";
-    case STATE_DONE:
-        return "DONE";
-    }
-
-    bt_common_abort();
-}
-
-static struct stack *stack_new(struct ctf_msg_iter *msg_it)
-{
-    struct stack *stack = NULL;
-
-    stack = g_new0(struct stack, 1);
-    if (!stack) {
-        BT_CLOGE_APPEND_CAUSE("Failed to allocate one stack.");
-        goto error;
-    }
-
-    stack->msg_it = msg_it;
-    stack->entries = g_array_new(FALSE, TRUE, sizeof(struct stack_entry));
-    if (!stack->entries) {
-        BT_CLOGE_APPEND_CAUSE("Failed to allocate a GArray.");
-        goto error;
-    }
-
-    BT_CLOGD("Created stack: msg-it-addr=%p, stack-addr=%p", msg_it, stack);
-    goto end;
-
-error:
-    g_free(stack);
-    stack = NULL;
-
-end:
-    return stack;
-}
-
-static void stack_destroy(struct stack *stack)
-{
-    struct ctf_msg_iter *msg_it;
-
-    BT_ASSERT_DBG(stack);
-    msg_it = stack->msg_it;
-    BT_CLOGD("Destroying stack: addr=%p", stack);
-
-    if (stack->entries) {
-        g_array_free(stack->entries, TRUE);
-    }
-
-    g_free(stack);
-}
-
-static void stack_push(struct stack *stack, bt_field *base)
-{
-    struct stack_entry *entry;
-    struct ctf_msg_iter *msg_it;
-
-    BT_ASSERT_DBG(stack);
-    msg_it = stack->msg_it;
-    BT_ASSERT_DBG(base);
-    BT_CLOGT("Pushing base field on stack: stack-addr=%p, "
-             "stack-size-before=%zu, stack-size-after=%zu",
-             stack, stack->size, stack->size + 1);
-
-    if (stack->entries->len == stack->size) {
-        g_array_set_size(stack->entries, stack->size + 1);
-    }
-
-    entry = &g_array_index(stack->entries, struct stack_entry, stack->size);
-    entry->base = base;
-    entry->index = 0;
-    stack->size++;
-}
-
-static inline unsigned int stack_size(struct stack *stack)
-{
-    BT_ASSERT_DBG(stack);
-    return stack->size;
-}
-
-static void stack_pop(struct stack *stack)
-{
-    struct ctf_msg_iter *msg_it;
-
-    BT_ASSERT_DBG(stack);
-    BT_ASSERT_DBG(stack_size(stack));
-    msg_it = stack->msg_it;
-    BT_CLOGT("Popping from stack: "
-             "stack-addr=%p, stack-size-before=%zu, stack-size-after=%zu",
-             stack, stack->size, stack->size - 1);
-    stack->size--;
-}
-
-static inline struct stack_entry *stack_top(struct stack *stack)
-{
-    BT_ASSERT_DBG(stack);
-    BT_ASSERT_DBG(stack_size(stack));
-    return &g_array_index(stack->entries, struct stack_entry, stack->size - 1);
-}
-
-static inline bool stack_empty(struct stack *stack)
-{
-    return stack_size(stack) == 0;
-}
-
-static void stack_clear(struct stack *stack)
-{
-    BT_ASSERT_DBG(stack);
-    stack->size = 0;
-}
-
-static inline enum ctf_msg_iter_status
-msg_iter_status_from_m_status(enum ctf_msg_iter_medium_status m_status)
-{
-    /* They are the same */
-    return (ctf_msg_iter_status) m_status;
-}
-
-static inline size_t buf_size_bits(struct ctf_msg_iter *msg_it)
-{
-    return msg_it->buf.sz * 8;
-}
-
-static inline size_t buf_available_bits(struct ctf_msg_iter *msg_it)
-{
-    return buf_size_bits(msg_it) - msg_it->buf.at;
-}
-
-static inline size_t packet_at(struct ctf_msg_iter *msg_it)
-{
-    return msg_it->buf.packet_offset + msg_it->buf.at;
-}
-
-static inline void buf_consume_bits(struct ctf_msg_iter *msg_it, size_t incr)
-{
-    BT_CLOGT("Advancing cursor: msg-it-addr=%p, cur-before=%zu, cur-after=%zu", msg_it,
-             msg_it->buf.at, msg_it->buf.at + incr);
-    msg_it->buf.at += incr;
-}
-
-static enum ctf_msg_iter_status request_medium_bytes(struct ctf_msg_iter *msg_it)
-{
-    uint8_t *buffer_addr = NULL;
-    size_t buffer_sz = 0;
-    enum ctf_msg_iter_medium_status m_status;
-
-    BT_CLOGD("Calling user function (request bytes): msg-it-addr=%p, "
-             "request-size=%zu",
-             msg_it, msg_it->medium.max_request_sz);
-    m_status = msg_it->medium.medops.request_bytes(msg_it->medium.max_request_sz, &buffer_addr,
-                                                   &buffer_sz, msg_it->medium.data);
-    BT_CLOGD("User function returned: status=%s, buf-addr=%p, buf-size=%zu",
-             ctf_msg_iter_medium_status_string(m_status), buffer_addr, buffer_sz);
-    if (m_status == CTF_MSG_ITER_MEDIUM_STATUS_OK) {
-        BT_ASSERT(buffer_sz != 0);
-
-        /* New packet offset is old one + old size (in bits) */
-        msg_it->buf.packet_offset += buf_size_bits(msg_it);
-
-        /* Restart at the beginning of the new medium buffer */
-        msg_it->buf.at = 0;
-        msg_it->buf.last_eh_at = SIZE_MAX;
-
-        /* New medium buffer size */
-        msg_it->buf.sz = buffer_sz;
-
-        /* New medium buffer address */
-        msg_it->buf.addr = buffer_addr;
-
-        BT_CLOGD("User function returned new bytes: "
-                 "packet-offset=%zu, cur=%zu, size=%zu, addr=%p",
-                 msg_it->buf.packet_offset, msg_it->buf.at, msg_it->buf.sz, msg_it->buf.addr);
-        BT_CLOGT_MEM(buffer_addr, buffer_sz, "Returned bytes at %p:", buffer_addr);
-    } else if (m_status == CTF_MSG_ITER_MEDIUM_STATUS_EOF) {
-        /*
-         * User returned end of stream: validate that we're not
-         * in the middle of a packet header, packet context, or
-         * event.
-         */
-        if (msg_it->cur_exp_packet_total_size >= 0) {
-            if (packet_at(msg_it) == msg_it->cur_exp_packet_total_size) {
-                goto end;
-            }
-        } else {
-            if (packet_at(msg_it) == 0) {
-                goto end;
-            }
-
-            if (msg_it->buf.last_eh_at != SIZE_MAX && msg_it->buf.at == msg_it->buf.last_eh_at) {
-                goto end;
-            }
-        }
-
-        /* All other states are invalid */
-        BT_CLOGE_APPEND_CAUSE(
-            "User function returned %s, but message iterator is in an unexpected state: "
-            "state=%s, cur-packet-size=%" PRId64 ", cur=%zu, "
-            "packet-cur=%zu, last-eh-at=%zu",
-            ctf_msg_iter_medium_status_string(m_status), state_string(msg_it->state),
-            msg_it->cur_exp_packet_total_size, msg_it->buf.at, packet_at(msg_it),
-            msg_it->buf.last_eh_at);
-        m_status = CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
-    } else if (m_status < 0) {
-        BT_CLOGE_APPEND_CAUSE("User function failed: "
-                              "status=%s",
-                              ctf_msg_iter_medium_status_string(m_status));
-    }
-
-end:
-    return msg_iter_status_from_m_status(m_status);
-}
-
-static inline enum ctf_msg_iter_status buf_ensure_available_bits(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-
-    if (G_UNLIKELY(buf_available_bits(msg_it) == 0)) {
-        /*
-         * This _cannot_ return CTF_MSG_ITER_STATUS_OK
-         * _and_ no bits.
-         */
-        status = request_medium_bytes(msg_it);
-    }
-
-    return status;
-}
-
-static enum ctf_msg_iter_status
-read_dscope_begin_state(struct ctf_msg_iter *msg_it, struct ctf_field_class *dscope_fc,
-                        enum state done_state, enum state continue_state, bt_field *dscope_field)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-    enum bt_bfcr_status bfcr_status;
-    size_t consumed_bits;
-
-    msg_it->cur_dscope_field = dscope_field;
-    BT_CLOGT("Starting BFCR: msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p", msg_it, msg_it->bfcr,
-             dscope_fc);
-    consumed_bits = bt_bfcr_start(msg_it->bfcr, dscope_fc, msg_it->buf.addr, msg_it->buf.at,
-                                  packet_at(msg_it), msg_it->buf.sz, &bfcr_status);
-    BT_CLOGT("BFCR consumed bits: size=%zu", consumed_bits);
-
-    switch (bfcr_status) {
-    case BT_BFCR_STATUS_OK:
-        /* Field class was read completely */
-        BT_CLOGT_STR("Field was completely decoded.");
-        msg_it->state = done_state;
-        break;
-    case BT_BFCR_STATUS_EOF:
-        BT_CLOGT_STR("BFCR needs more data to decode field completely.");
-        msg_it->state = continue_state;
-        break;
-    default:
-        BT_CLOGE_APPEND_CAUSE("BFCR failed to start: msg-it-addr=%p, bfcr-addr=%p, "
-                              "status=%s",
-                              msg_it, msg_it->bfcr, bt_bfcr_status_string(bfcr_status));
-        status = CTF_MSG_ITER_STATUS_ERROR;
-        goto end;
-    }
-
-    /* Consume bits now since we know we're not in an error state */
-    buf_consume_bits(msg_it, consumed_bits);
-
-end:
-    return status;
-}
-
-static enum ctf_msg_iter_status read_dscope_continue_state(struct ctf_msg_iter *msg_it,
-                                                           enum state done_state)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-    enum bt_bfcr_status bfcr_status;
-    size_t consumed_bits;
-
-    BT_CLOGT("Continuing BFCR: msg-it-addr=%p, bfcr-addr=%p", msg_it, msg_it->bfcr);
-
-    status = buf_ensure_available_bits(msg_it);
-    if (status != CTF_MSG_ITER_STATUS_OK) {
-        if (status < 0) {
-            BT_CLOGE_APPEND_CAUSE("Cannot ensure that buffer has at least one byte: "
-                                  "msg-addr=%p, status=%s",
-                                  msg_it, ctf_msg_iter_status_string(status));
-        } else {
-            BT_CLOGT("Cannot ensure that buffer has at least one byte: "
-                     "msg-addr=%p, status=%s",
-                     msg_it, ctf_msg_iter_status_string(status));
-        }
-
-        goto end;
-    }
-
-    consumed_bits = bt_bfcr_continue(msg_it->bfcr, msg_it->buf.addr, msg_it->buf.sz, &bfcr_status);
-    BT_CLOGT("BFCR consumed bits: size=%zu", consumed_bits);
-
-    switch (bfcr_status) {
-    case BT_BFCR_STATUS_OK:
-        /* Type was read completely. */
-        BT_CLOGT_STR("Field was completely decoded.");
-        msg_it->state = done_state;
-        break;
-    case BT_BFCR_STATUS_EOF:
-        /* Stay in this continue state. */
-        BT_CLOGT_STR("BFCR needs more data to decode field completely.");
-        break;
-    default:
-        BT_CLOGE_APPEND_CAUSE("BFCR failed to continue: msg-it-addr=%p, bfcr-addr=%p, "
-                              "status=%s",
-                              msg_it, msg_it->bfcr, bt_bfcr_status_string(bfcr_status));
-        status = CTF_MSG_ITER_STATUS_ERROR;
-        goto end;
-    }
-
-    /* Consume bits now since we know we're not in an error state. */
-    buf_consume_bits(msg_it, consumed_bits);
-end:
-    return status;
-}
-
-static void release_event_dscopes(struct ctf_msg_iter *msg_it)
-{
-    msg_it->dscopes.event_common_context = NULL;
-    msg_it->dscopes.event_spec_context = NULL;
-    msg_it->dscopes.event_payload = NULL;
-}
-
-static void release_all_dscopes(struct ctf_msg_iter *msg_it)
-{
-    msg_it->dscopes.stream_packet_context = NULL;
-
-    release_event_dscopes(msg_it);
-}
-
-static enum ctf_msg_iter_status switch_packet_state(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status;
-
-    /*
-     * We don't put the stream class here because we need to make
-     * sure that all the packets processed by the same message
-     * iterator refer to the same stream class (the first one).
-     */
-    BT_ASSERT(msg_it);
-
-    if (msg_it->cur_exp_packet_total_size != -1) {
-        msg_it->cur_packet_offset += msg_it->cur_exp_packet_total_size;
-    }
-
-    BT_CLOGD("Switching packet: msg-it-addr=%p, cur=%zu, "
-             "packet-offset=%" PRId64,
-             msg_it, msg_it->buf.at, msg_it->cur_packet_offset);
-    stack_clear(msg_it->stack);
-    msg_it->meta.ec = NULL;
-    BT_PACKET_PUT_REF_AND_RESET(msg_it->packet);
-    BT_MESSAGE_PUT_REF_AND_RESET(msg_it->event_msg);
-    release_all_dscopes(msg_it);
-    msg_it->cur_dscope_field = NULL;
-
-    if (msg_it->medium.medops.switch_packet) {
-        enum ctf_msg_iter_medium_status medium_status;
-
-        medium_status = msg_it->medium.medops.switch_packet(msg_it->medium.data);
-        if (medium_status == CTF_MSG_ITER_MEDIUM_STATUS_EOF) {
-            /* No more packets. */
-            msg_it->state = STATE_CHECK_EMIT_MSG_STREAM_END;
-            status = CTF_MSG_ITER_STATUS_OK;
-            goto end;
-        } else if (medium_status != CTF_MSG_ITER_MEDIUM_STATUS_OK) {
-            status = msg_iter_status_from_m_status(medium_status);
-            goto end;
-        }
-
-        /*
-         * After the packet switch, the medium might want to give us a
-         * different buffer for the new packet.
-         */
-        status = request_medium_bytes(msg_it);
-        if (status != CTF_MSG_ITER_STATUS_OK) {
-            goto end;
-        }
-    }
-
-    /*
-     * Adjust current buffer so that addr points to the beginning of the new
-     * packet.
-     */
-    if (msg_it->buf.addr) {
-        size_t consumed_bytes = (size_t) (msg_it->buf.at / CHAR_BIT);
-
-        /* Packets are assumed to start on a byte frontier. */
-        if (msg_it->buf.at % CHAR_BIT) {
-            BT_CLOGE_APPEND_CAUSE("Cannot switch packet: current position is not a multiple of 8: "
-                                  "msg-it-addr=%p, cur=%zu",
-                                  msg_it, msg_it->buf.at);
-            status = CTF_MSG_ITER_STATUS_ERROR;
-            goto end;
-        }
-
-        msg_it->buf.addr += consumed_bytes;
-        msg_it->buf.sz -= consumed_bytes;
-        msg_it->buf.at = 0;
-        msg_it->buf.packet_offset = 0;
-        BT_CLOGD("Adjusted buffer: addr=%p, size=%zu", msg_it->buf.addr, msg_it->buf.sz);
-    }
-
-    msg_it->cur_exp_packet_content_size = -1;
-    msg_it->cur_exp_packet_total_size = -1;
-    msg_it->cur_stream_class_id = -1;
-    msg_it->cur_event_class_id = -1;
-    msg_it->cur_data_stream_id = -1;
-    msg_it->prev_packet_snapshots = msg_it->snapshots;
-    msg_it->snapshots.discarded_events = UINT64_C(-1);
-    msg_it->snapshots.packets = UINT64_C(-1);
-    msg_it->snapshots.beginning_clock = UINT64_C(-1);
-    msg_it->snapshots.end_clock = UINT64_C(-1);
-    msg_it->state = STATE_DSCOPE_TRACE_PACKET_HEADER_BEGIN;
-
-    status = CTF_MSG_ITER_STATUS_OK;
-end:
-    return status;
-}
-
-static enum ctf_msg_iter_status read_packet_header_begin_state(struct ctf_msg_iter *msg_it)
-{
-    struct ctf_field_class *packet_header_fc = NULL;
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-
-    /*
-     * Make sure at least one bit is available for this packet. An
-     * empty packet is impossible. If we reach the end of the medium
-     * at this point, then it's considered the end of the stream.
-     */
-    status = buf_ensure_available_bits(msg_it);
-    switch (status) {
-    case CTF_MSG_ITER_STATUS_OK:
-        break;
-    case CTF_MSG_ITER_STATUS_EOF:
-        status = CTF_MSG_ITER_STATUS_OK;
-        msg_it->state = STATE_CHECK_EMIT_MSG_STREAM_END;
-        goto end;
-    default:
-        goto end;
-    }
-
-    /* Packet header class is common to the whole trace class. */
-    packet_header_fc = msg_it->meta.tc->packet_header_fc;
-    if (!packet_header_fc) {
-        msg_it->state = STATE_AFTER_TRACE_PACKET_HEADER;
-        goto end;
-    }
-
-    msg_it->cur_stream_class_id = -1;
-    msg_it->cur_event_class_id = -1;
-    msg_it->cur_data_stream_id = -1;
-    BT_CLOGD("Decoding packet header field: "
-             "msg-it-addr=%p, trace-class-addr=%p, fc-addr=%p",
-             msg_it, msg_it->meta.tc, packet_header_fc);
-    status = read_dscope_begin_state(msg_it, packet_header_fc, STATE_AFTER_TRACE_PACKET_HEADER,
-                                     STATE_DSCOPE_TRACE_PACKET_HEADER_CONTINUE, NULL);
-    if (status < 0) {
-        BT_CLOGE_APPEND_CAUSE("Cannot decode packet header field: "
-                              "msg-it-addr=%p, trace-class-addr=%p, "
-                              "fc-addr=%p",
-                              msg_it, msg_it->meta.tc, packet_header_fc);
-    }
-
-end:
-    return status;
-}
-
-static enum ctf_msg_iter_status read_packet_header_continue_state(struct ctf_msg_iter *msg_it)
-{
-    return read_dscope_continue_state(msg_it, STATE_AFTER_TRACE_PACKET_HEADER);
-}
-
-static inline enum ctf_msg_iter_status set_current_stream_class(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-    struct ctf_stream_class *new_stream_class = NULL;
-
-    if (msg_it->cur_stream_class_id == -1) {
-        /*
-         * No current stream class ID field, therefore only one
-         * stream class.
-         */
-        if (msg_it->meta.tc->stream_classes->len != 1) {
-            BT_CLOGE_APPEND_CAUSE("Need exactly one stream class since there's "
-                                  "no stream class ID field: "
-                                  "msg-it-addr=%p",
-                                  msg_it);
-            status = CTF_MSG_ITER_STATUS_ERROR;
-            goto end;
-        }
-
-        new_stream_class = (ctf_stream_class *) msg_it->meta.tc->stream_classes->pdata[0];
-        msg_it->cur_stream_class_id = new_stream_class->id;
-    }
-
-    new_stream_class =
-        ctf_trace_class_borrow_stream_class_by_id(msg_it->meta.tc, msg_it->cur_stream_class_id);
-    if (!new_stream_class) {
-        BT_CLOGE_APPEND_CAUSE("No stream class with ID of stream class ID to use in trace class: "
-                              "msg-it-addr=%p, stream-class-id=%" PRIu64 ", "
-                              "trace-class-addr=%p",
-                              msg_it, msg_it->cur_stream_class_id, msg_it->meta.tc);
-        status = CTF_MSG_ITER_STATUS_ERROR;
-        goto end;
-    }
-
-    if (msg_it->meta.sc) {
-        if (new_stream_class != msg_it->meta.sc) {
-            BT_CLOGE_APPEND_CAUSE(
-                "Two packets refer to two different stream classes within the same packet sequence: "
-                "msg-it-addr=%p, prev-stream-class-addr=%p, "
-                "prev-stream-class-id=%" PRId64 ", "
-                "next-stream-class-addr=%p, "
-                "next-stream-class-id=%" PRId64 ", "
-                "trace-addr=%p",
-                msg_it, msg_it->meta.sc, msg_it->meta.sc->id, new_stream_class,
-                new_stream_class->id, msg_it->meta.tc);
-            status = CTF_MSG_ITER_STATUS_ERROR;
-            goto end;
-        }
-    } else {
-        msg_it->meta.sc = new_stream_class;
-    }
-
-    BT_CLOGD("Set current stream class: "
-             "msg-it-addr=%p, stream-class-addr=%p, "
-             "stream-class-id=%" PRId64,
-             msg_it, msg_it->meta.sc, msg_it->meta.sc->id);
-
-end:
-    return status;
-}
-
-static inline enum ctf_msg_iter_status set_current_stream(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-    bt_stream *stream = NULL;
-
-    BT_CLOGD("Calling user function (get stream): msg-it-addr=%p, "
-             "stream-class-addr=%p, stream-class-id=%" PRId64,
-             msg_it, msg_it->meta.sc, msg_it->meta.sc->id);
-    stream = msg_it->medium.medops.borrow_stream(msg_it->meta.sc->ir_sc, msg_it->cur_data_stream_id,
-                                                 msg_it->medium.data);
-    bt_stream_get_ref(stream);
-    BT_CLOGD("User function returned: stream-addr=%p", stream);
-    if (!stream) {
-        BT_CLOGE_APPEND_CAUSE(
-            "User function failed to return a stream object for the given stream class.");
-        status = CTF_MSG_ITER_STATUS_ERROR;
-        goto end;
-    }
-
-    if (msg_it->stream && stream != msg_it->stream) {
-        BT_CLOGE_APPEND_CAUSE(
-            "User function returned a different stream than the previous one for the same sequence of packets.");
-        status = CTF_MSG_ITER_STATUS_ERROR;
-        goto end;
-    }
-
-    BT_STREAM_MOVE_REF(msg_it->stream, stream);
-
-end:
-    bt_stream_put_ref(stream);
-    return status;
-}
-
-static inline enum ctf_msg_iter_status set_current_packet(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-    bt_packet *packet = NULL;
-
-    BT_CLOGD("Creating packet from stream: "
-             "msg-it-addr=%p, stream-addr=%p, "
-             "stream-class-addr=%p, "
-             "stream-class-id=%" PRId64,
-             msg_it, msg_it->stream, msg_it->meta.sc, msg_it->meta.sc->id);
-
-    /* Create packet */
-    BT_ASSERT(msg_it->stream);
-    packet = bt_packet_create(msg_it->stream);
-    if (!packet) {
-        BT_CLOGE_APPEND_CAUSE("Cannot create packet from stream: "
-                              "msg-it-addr=%p, stream-addr=%p, "
-                              "stream-class-addr=%p, "
-                              "stream-class-id=%" PRId64,
-                              msg_it, msg_it->stream, msg_it->meta.sc, msg_it->meta.sc->id);
-        goto error;
-    }
-
-    goto end;
-
-error:
-    BT_PACKET_PUT_REF_AND_RESET(packet);
-    status = CTF_MSG_ITER_STATUS_ERROR;
-
-end:
-    BT_PACKET_MOVE_REF(msg_it->packet, packet);
-    return status;
-}
-
-static enum ctf_msg_iter_status after_packet_header_state(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status;
-
-    status = set_current_stream_class(msg_it);
-    if (status != CTF_MSG_ITER_STATUS_OK) {
-        goto end;
-    }
-
-    if (!msg_it->dry_run) {
-        status = set_current_stream(msg_it);
-        if (status != CTF_MSG_ITER_STATUS_OK) {
-            goto end;
-        }
-
-        status = set_current_packet(msg_it);
-        if (status != CTF_MSG_ITER_STATUS_OK) {
-            goto end;
-        }
-    }
-
-    msg_it->state = STATE_DSCOPE_STREAM_PACKET_CONTEXT_BEGIN;
-
-    status = CTF_MSG_ITER_STATUS_OK;
-
-end:
-    return status;
-}
-
-static enum ctf_msg_iter_status read_packet_context_begin_state(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-    struct ctf_field_class *packet_context_fc;
-
-    BT_ASSERT(msg_it->meta.sc);
-    packet_context_fc = msg_it->meta.sc->packet_context_fc;
-    if (!packet_context_fc) {
-        BT_CLOGD("No packet packet context field class in stream class: continuing: "
-                 "msg-it-addr=%p, stream-class-addr=%p, "
-                 "stream-class-id=%" PRId64,
-                 msg_it, msg_it->meta.sc, msg_it->meta.sc->id);
-        msg_it->state = STATE_AFTER_STREAM_PACKET_CONTEXT;
-        goto end;
-    }
-
-    if (packet_context_fc->in_ir && !msg_it->dry_run) {
-        BT_ASSERT(!msg_it->dscopes.stream_packet_context);
-        BT_ASSERT(msg_it->packet);
-        msg_it->dscopes.stream_packet_context = bt_packet_borrow_context_field(msg_it->packet);
-        BT_ASSERT(msg_it->dscopes.stream_packet_context);
-    }
-
-    BT_CLOGD("Decoding packet context field: "
-             "msg-it-addr=%p, stream-class-addr=%p, "
-             "stream-class-id=%" PRId64 ", fc-addr=%p",
-             msg_it, msg_it->meta.sc, msg_it->meta.sc->id, packet_context_fc);
-    status = read_dscope_begin_state(msg_it, packet_context_fc, STATE_AFTER_STREAM_PACKET_CONTEXT,
-                                     STATE_DSCOPE_STREAM_PACKET_CONTEXT_CONTINUE,
-                                     msg_it->dscopes.stream_packet_context);
-    if (status < 0) {
-        BT_CLOGE_APPEND_CAUSE("Cannot decode packet context field: "
-                              "msg-it-addr=%p, stream-class-addr=%p, "
-                              "stream-class-id=%" PRId64 ", fc-addr=%p",
-                              msg_it, msg_it->meta.sc, msg_it->meta.sc->id, packet_context_fc);
-    }
-
-end:
-    return status;
-}
-
-static enum ctf_msg_iter_status read_packet_context_continue_state(struct ctf_msg_iter *msg_it)
-{
-    return read_dscope_continue_state(msg_it, STATE_AFTER_STREAM_PACKET_CONTEXT);
-}
-
-static enum ctf_msg_iter_status set_current_packet_content_sizes(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-
-    if (msg_it->cur_exp_packet_total_size == -1) {
-        if (msg_it->cur_exp_packet_content_size != -1) {
-            msg_it->cur_exp_packet_total_size = msg_it->cur_exp_packet_content_size;
-        }
-    } else {
-        if (msg_it->cur_exp_packet_content_size == -1) {
-            msg_it->cur_exp_packet_content_size = msg_it->cur_exp_packet_total_size;
-        }
-    }
-
-    BT_ASSERT(
-        (msg_it->cur_exp_packet_total_size >= 0 && msg_it->cur_exp_packet_content_size >= 0) ||
-        (msg_it->cur_exp_packet_total_size < 0 && msg_it->cur_exp_packet_content_size < 0));
-
-    if (msg_it->cur_exp_packet_content_size > msg_it->cur_exp_packet_total_size) {
-        BT_CLOGE_APPEND_CAUSE("Invalid packet or content size: "
-                              "content size is greater than packet size: "
-                              "msg-it-addr=%p, packet-context-field-addr=%p, "
-                              "packet-size=%" PRId64 ", content-size=%" PRId64,
-                              msg_it, msg_it->dscopes.stream_packet_context,
-                              msg_it->cur_exp_packet_total_size,
-                              msg_it->cur_exp_packet_content_size);
-        status = CTF_MSG_ITER_STATUS_ERROR;
-        goto end;
-    }
-
-    BT_CLOGD("Set current packet and content sizes: "
-             "msg-it-addr=%p, packet-size=%" PRIu64 ", content-size=%" PRIu64,
-             msg_it, msg_it->cur_exp_packet_total_size, msg_it->cur_exp_packet_content_size);
-
-end:
-    return status;
-}
-
-static enum ctf_msg_iter_status after_packet_context_state(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status;
-
-    status = set_current_packet_content_sizes(msg_it);
-    if (status != CTF_MSG_ITER_STATUS_OK) {
-        goto end;
-    }
-
-    if (msg_it->emit_stream_beginning_message) {
-        msg_it->state = STATE_EMIT_MSG_STREAM_BEGINNING;
-    } else {
-        msg_it->state = STATE_CHECK_EMIT_MSG_DISCARDED_EVENTS;
-    }
-
-end:
-    return status;
-}
-
-static enum ctf_msg_iter_status read_event_header_begin_state(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-    struct ctf_field_class *event_header_fc = NULL;
-
-    /* Reset the position of the last event header */
-    msg_it->buf.last_eh_at = msg_it->buf.at;
-    msg_it->cur_event_class_id = -1;
-
-    /* Check if we have some content left */
-    if (msg_it->cur_exp_packet_content_size >= 0) {
-        if (G_UNLIKELY(packet_at(msg_it) == msg_it->cur_exp_packet_content_size)) {
-            /* No more events! */
-            BT_CLOGD("Reached end of packet: msg-it-addr=%p, "
-                     "cur=%zu",
-                     msg_it, packet_at(msg_it));
-            msg_it->state = STATE_EMIT_MSG_PACKET_END_MULTI;
-            goto end;
-        } else if (G_UNLIKELY(packet_at(msg_it) > msg_it->cur_exp_packet_content_size)) {
-            /* That's not supposed to happen */
-            BT_CLOGD("Before decoding event header field: cursor is passed the packet's content: "
-                     "msg-it-addr=%p, content-size=%" PRId64 ", "
-                     "cur=%zu",
-                     msg_it, msg_it->cur_exp_packet_content_size, packet_at(msg_it));
-            status = CTF_MSG_ITER_STATUS_ERROR;
-            goto end;
-        }
-    } else {
-        /*
-         * "Infinite" content: we're done when the medium has
-         * nothing else for us.
-         */
-        status = buf_ensure_available_bits(msg_it);
-        switch (status) {
-        case CTF_MSG_ITER_STATUS_OK:
-            break;
-        case CTF_MSG_ITER_STATUS_EOF:
-            status = CTF_MSG_ITER_STATUS_OK;
-            msg_it->state = STATE_EMIT_MSG_PACKET_END_SINGLE;
-            goto end;
-        default:
-            goto end;
-        }
-    }
-
-    release_event_dscopes(msg_it);
-    BT_ASSERT(msg_it->meta.sc);
-    event_header_fc = msg_it->meta.sc->event_header_fc;
-    if (!event_header_fc) {
-        msg_it->state = STATE_AFTER_EVENT_HEADER;
-        goto end;
-    }
-
-    BT_CLOGD("Decoding event header field: "
-             "msg-it-addr=%p, stream-class-addr=%p, "
-             "stream-class-id=%" PRId64 ", "
-             "fc-addr=%p",
-             msg_it, msg_it->meta.sc, msg_it->meta.sc->id, event_header_fc);
-    status = read_dscope_begin_state(msg_it, event_header_fc, STATE_AFTER_EVENT_HEADER,
-                                     STATE_DSCOPE_EVENT_HEADER_CONTINUE, NULL);
-    if (status < 0) {
-        BT_CLOGE_APPEND_CAUSE("Cannot decode event header field: "
-                              "msg-it-addr=%p, stream-class-addr=%p, "
-                              "stream-class-id=%" PRId64 ", fc-addr=%p",
-                              msg_it, msg_it->meta.sc, msg_it->meta.sc->id, event_header_fc);
-    }
-
-end:
-    return status;
-}
-
-static enum ctf_msg_iter_status read_event_header_continue_state(struct ctf_msg_iter *msg_it)
-{
-    return read_dscope_continue_state(msg_it, STATE_AFTER_EVENT_HEADER);
-}
-
-static inline enum ctf_msg_iter_status set_current_event_class(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-
-    struct ctf_event_class *new_event_class = NULL;
-
-    if (msg_it->cur_event_class_id == -1) {
-        /*
-         * No current event class ID field, therefore only one
-         * event class.
-         */
-        if (msg_it->meta.sc->event_classes->len != 1) {
-            BT_CLOGE_APPEND_CAUSE(
-                "Need exactly one event class since there's no event class ID field: "
-                "msg-it-addr=%p",
-                msg_it);
-            status = CTF_MSG_ITER_STATUS_ERROR;
-            goto end;
-        }
-
-        new_event_class = (ctf_event_class *) msg_it->meta.sc->event_classes->pdata[0];
-        msg_it->cur_event_class_id = new_event_class->id;
-    }
-
-    new_event_class =
-        ctf_stream_class_borrow_event_class_by_id(msg_it->meta.sc, msg_it->cur_event_class_id);
-    if (!new_event_class) {
-        BT_CLOGE_APPEND_CAUSE("No event class with ID of event class ID to use in stream class: "
-                              "msg-it-addr=%p, stream-class-id=%" PRIu64 ", "
-                              "event-class-id=%" PRIu64 ", "
-                              "trace-class-addr=%p",
-                              msg_it, msg_it->meta.sc->id, msg_it->cur_event_class_id,
-                              msg_it->meta.tc);
-        status = CTF_MSG_ITER_STATUS_ERROR;
-        goto end;
-    }
-
-    msg_it->meta.ec = new_event_class;
-    BT_CLOGD("Set current event class: "
-             "msg-it-addr=%p, event-class-addr=%p, "
-             "event-class-id=%" PRId64 ", "
-             "event-class-name=\"%s\"",
-             msg_it, msg_it->meta.ec, msg_it->meta.ec->id, msg_it->meta.ec->name->str);
-
-end:
-    return status;
-}
-
-static inline enum ctf_msg_iter_status set_current_event_message(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-    bt_message *msg = NULL;
-
-    BT_ASSERT_DBG(msg_it->meta.ec);
-    BT_ASSERT_DBG(msg_it->packet);
-    BT_CLOGD("Creating event message from event class and packet: "
-             "msg-it-addr=%p, ec-addr=%p, ec-name=\"%s\", packet-addr=%p",
-             msg_it, msg_it->meta.ec, msg_it->meta.ec->name->str, msg_it->packet);
-    BT_ASSERT_DBG(msg_it->self_msg_iter);
-    BT_ASSERT_DBG(msg_it->meta.sc);
-
-    if (bt_stream_class_borrow_default_clock_class(msg_it->meta.sc->ir_sc)) {
-        msg = bt_message_event_create_with_packet_and_default_clock_snapshot(
-            msg_it->self_msg_iter, msg_it->meta.ec->ir_ec, msg_it->packet,
-            msg_it->default_clock_snapshot);
-    } else {
-        msg = bt_message_event_create_with_packet(msg_it->self_msg_iter, msg_it->meta.ec->ir_ec,
-                                                  msg_it->packet);
-    }
-
-    if (!msg) {
-        BT_CLOGE_APPEND_CAUSE("Cannot create event message: "
-                              "msg-it-addr=%p, ec-addr=%p, ec-name=\"%s\", "
-                              "packet-addr=%p",
-                              msg_it, msg_it->meta.ec, msg_it->meta.ec->name->str, msg_it->packet);
-        goto error;
-    }
-
-    goto end;
-
-error:
-    BT_MESSAGE_PUT_REF_AND_RESET(msg);
-    status = CTF_MSG_ITER_STATUS_ERROR;
-
-end:
-    BT_MESSAGE_MOVE_REF(msg_it->event_msg, msg);
-    return status;
-}
-
-static enum ctf_msg_iter_status after_event_header_state(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status;
-
-    status = set_current_event_class(msg_it);
-    if (status != CTF_MSG_ITER_STATUS_OK) {
-        goto end;
-    }
-
-    if (G_UNLIKELY(msg_it->dry_run)) {
-        goto next_state;
-    }
-
-    status = set_current_event_message(msg_it);
-    if (status != CTF_MSG_ITER_STATUS_OK) {
-        goto end;
-    }
-
-    msg_it->event = bt_message_event_borrow_event(msg_it->event_msg);
-    BT_ASSERT_DBG(msg_it->event);
-
-next_state:
-    msg_it->state = STATE_DSCOPE_EVENT_COMMON_CONTEXT_BEGIN;
-
-end:
-    return status;
-}
-
-static enum ctf_msg_iter_status read_event_common_context_begin_state(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-    struct ctf_field_class *event_common_context_fc;
-
-    event_common_context_fc = msg_it->meta.sc->event_common_context_fc;
-    if (!event_common_context_fc) {
-        msg_it->state = STATE_DSCOPE_EVENT_SPEC_CONTEXT_BEGIN;
-        goto end;
-    }
-
-    if (event_common_context_fc->in_ir && !msg_it->dry_run) {
-        BT_ASSERT_DBG(!msg_it->dscopes.event_common_context);
-        msg_it->dscopes.event_common_context = bt_event_borrow_common_context_field(msg_it->event);
-        BT_ASSERT_DBG(msg_it->dscopes.event_common_context);
-    }
-
-    BT_CLOGT("Decoding event common context field: "
-             "msg-it-addr=%p, stream-class-addr=%p, "
-             "stream-class-id=%" PRId64 ", "
-             "fc-addr=%p",
-             msg_it, msg_it->meta.sc, msg_it->meta.sc->id, event_common_context_fc);
-    status = read_dscope_begin_state(
-        msg_it, event_common_context_fc, STATE_DSCOPE_EVENT_SPEC_CONTEXT_BEGIN,
-        STATE_DSCOPE_EVENT_COMMON_CONTEXT_CONTINUE, msg_it->dscopes.event_common_context);
-    if (status < 0) {
-        BT_CLOGE_APPEND_CAUSE("Cannot decode event common context field: "
-                              "msg-it-addr=%p, stream-class-addr=%p, "
-                              "stream-class-id=%" PRId64 ", fc-addr=%p",
-                              msg_it, msg_it->meta.sc, msg_it->meta.sc->id,
-                              event_common_context_fc);
-    }
-
-end:
-    return status;
-}
-
-static enum ctf_msg_iter_status
-read_event_common_context_continue_state(struct ctf_msg_iter *msg_it)
-{
-    return read_dscope_continue_state(msg_it, STATE_DSCOPE_EVENT_SPEC_CONTEXT_BEGIN);
-}
-
-static enum ctf_msg_iter_status read_event_spec_context_begin_state(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-    struct ctf_field_class *event_spec_context_fc;
-
-    event_spec_context_fc = msg_it->meta.ec->spec_context_fc;
-    if (!event_spec_context_fc) {
-        msg_it->state = STATE_DSCOPE_EVENT_PAYLOAD_BEGIN;
-        goto end;
-    }
-
-    if (event_spec_context_fc->in_ir && !msg_it->dry_run) {
-        BT_ASSERT_DBG(!msg_it->dscopes.event_spec_context);
-        msg_it->dscopes.event_spec_context = bt_event_borrow_specific_context_field(msg_it->event);
-        BT_ASSERT_DBG(msg_it->dscopes.event_spec_context);
-    }
-
-    BT_CLOGT("Decoding event specific context field: "
-             "msg-it-addr=%p, event-class-addr=%p, "
-             "event-class-name=\"%s\", event-class-id=%" PRId64 ", "
-             "fc-addr=%p",
-             msg_it, msg_it->meta.ec, msg_it->meta.ec->name->str, msg_it->meta.ec->id,
-             event_spec_context_fc);
-    status = read_dscope_begin_state(
-        msg_it, event_spec_context_fc, STATE_DSCOPE_EVENT_PAYLOAD_BEGIN,
-        STATE_DSCOPE_EVENT_SPEC_CONTEXT_CONTINUE, msg_it->dscopes.event_spec_context);
-    if (status < 0) {
-        BT_CLOGE_APPEND_CAUSE("Cannot decode event specific context field: "
-                              "msg-it-addr=%p, event-class-addr=%p, "
-                              "event-class-name=\"%s\", "
-                              "event-class-id=%" PRId64 ", fc-addr=%p",
-                              msg_it, msg_it->meta.ec, msg_it->meta.ec->name->str,
-                              msg_it->meta.ec->id, event_spec_context_fc);
-    }
-
-end:
-    return status;
-}
-
-static enum ctf_msg_iter_status read_event_spec_context_continue_state(struct ctf_msg_iter *msg_it)
-{
-    return read_dscope_continue_state(msg_it, STATE_DSCOPE_EVENT_PAYLOAD_BEGIN);
-}
-
-static enum ctf_msg_iter_status read_event_payload_begin_state(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-    struct ctf_field_class *event_payload_fc;
-
-    event_payload_fc = msg_it->meta.ec->payload_fc;
-    if (!event_payload_fc) {
-        msg_it->state = STATE_EMIT_MSG_EVENT;
-        goto end;
-    }
-
-    if (event_payload_fc->in_ir && !msg_it->dry_run) {
-        BT_ASSERT_DBG(!msg_it->dscopes.event_payload);
-        msg_it->dscopes.event_payload = bt_event_borrow_payload_field(msg_it->event);
-        BT_ASSERT_DBG(msg_it->dscopes.event_payload);
-    }
-
-    BT_CLOGT("Decoding event payload field: "
-             "msg-it-addr=%p, event-class-addr=%p, "
-             "event-class-name=\"%s\", event-class-id=%" PRId64 ", "
-             "fc-addr=%p",
-             msg_it, msg_it->meta.ec, msg_it->meta.ec->name->str, msg_it->meta.ec->id,
-             event_payload_fc);
-    status =
-        read_dscope_begin_state(msg_it, event_payload_fc, STATE_EMIT_MSG_EVENT,
-                                STATE_DSCOPE_EVENT_PAYLOAD_CONTINUE, msg_it->dscopes.event_payload);
-    if (status < 0) {
-        BT_CLOGE_APPEND_CAUSE("Cannot decode event payload field: "
-                              "msg-it-addr=%p, event-class-addr=%p, "
-                              "event-class-name=\"%s\", "
-                              "event-class-id=%" PRId64 ", fc-addr=%p",
-                              msg_it, msg_it->meta.ec, msg_it->meta.ec->name->str,
-                              msg_it->meta.ec->id, event_payload_fc);
-    }
-
-end:
-    return status;
-}
-
-static enum ctf_msg_iter_status read_event_payload_continue_state(struct ctf_msg_iter *msg_it)
-{
-    return read_dscope_continue_state(msg_it, STATE_EMIT_MSG_EVENT);
-}
-
-static enum ctf_msg_iter_status skip_packet_padding_state(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-    size_t bits_to_skip;
-    const enum state next_state = STATE_SWITCH_PACKET;
-
-    BT_ASSERT(msg_it->cur_exp_packet_total_size > 0);
-    bits_to_skip = msg_it->cur_exp_packet_total_size - packet_at(msg_it);
-    if (bits_to_skip == 0) {
-        msg_it->state = next_state;
-        goto end;
-    } else {
-        size_t bits_to_consume;
-
-        BT_CLOGD("Trying to skip %zu bits of padding: msg-it-addr=%p, size=%zu", bits_to_skip,
-                 msg_it, bits_to_skip);
-        status = buf_ensure_available_bits(msg_it);
-        if (status != CTF_MSG_ITER_STATUS_OK) {
-            goto end;
-        }
-
-        bits_to_consume = MIN(buf_available_bits(msg_it), bits_to_skip);
-        BT_CLOGD("Skipping %zu bits of padding: msg-it-addr=%p, size=%zu", bits_to_consume, msg_it,
-                 bits_to_consume);
-        buf_consume_bits(msg_it, bits_to_consume);
-        bits_to_skip = msg_it->cur_exp_packet_total_size - packet_at(msg_it);
-        if (bits_to_skip == 0) {
-            msg_it->state = next_state;
-            goto end;
-        }
-    }
-
-end:
-    return status;
-}
-
-static enum ctf_msg_iter_status check_emit_msg_discarded_events(struct ctf_msg_iter *msg_it)
-{
-    msg_it->state = STATE_EMIT_MSG_DISCARDED_EVENTS;
-
-    if (!msg_it->meta.sc->has_discarded_events) {
-        msg_it->state = STATE_CHECK_EMIT_MSG_DISCARDED_PACKETS;
-        goto end;
-    }
-
-    if (msg_it->prev_packet_snapshots.discarded_events == UINT64_C(-1)) {
-        if (msg_it->snapshots.discarded_events == 0 ||
-            msg_it->snapshots.discarded_events == UINT64_C(-1)) {
-            /*
-             * Stream's first packet with no discarded
-             * events or no information about discarded
-             * events: do not emit.
-             */
-            msg_it->state = STATE_CHECK_EMIT_MSG_DISCARDED_PACKETS;
-        }
-    } else {
-        /*
-         * If the previous packet has a value for this counter,
-         * then this counter is defined for the whole stream.
-         */
-        BT_ASSERT(msg_it->snapshots.discarded_events != UINT64_C(-1));
-
-        if (msg_it->snapshots.discarded_events - msg_it->prev_packet_snapshots.discarded_events ==
-            0) {
-            /*
-             * No discarded events since previous packet: do
-             * not emit.
-             */
-            msg_it->state = STATE_CHECK_EMIT_MSG_DISCARDED_PACKETS;
-        }
-    }
-
-end:
-    return CTF_MSG_ITER_STATUS_OK;
-}
-
-static enum ctf_msg_iter_status check_emit_msg_discarded_packets(struct ctf_msg_iter *msg_it)
-{
-    msg_it->state = STATE_EMIT_MSG_DISCARDED_PACKETS;
-
-    if (!msg_it->meta.sc->has_discarded_packets) {
-        msg_it->state = STATE_EMIT_MSG_PACKET_BEGINNING;
-        goto end;
-    }
-
-    if (msg_it->prev_packet_snapshots.packets == UINT64_C(-1)) {
-        /*
-         * Stream's first packet or no information about
-         * discarded packets: do not emit. In other words, if
-         * this is the first packet and its sequence number is
-         * not 0, do not consider that packets were previously
-         * lost: we might be reading a partial stream (LTTng
-         * snapshot for example).
-         */
-        msg_it->state = STATE_EMIT_MSG_PACKET_BEGINNING;
-    } else {
-        /*
-         * If the previous packet has a value for this counter,
-         * then this counter is defined for the whole stream.
-         */
-        BT_ASSERT(msg_it->snapshots.packets != UINT64_C(-1));
-
-        if (msg_it->snapshots.packets - msg_it->prev_packet_snapshots.packets <= 1) {
-            /*
-             * No discarded packets since previous packet:
-             * do not emit.
-             */
-            msg_it->state = STATE_EMIT_MSG_PACKET_BEGINNING;
-        }
-    }
-
-end:
-    return CTF_MSG_ITER_STATUS_OK;
-}
-
-static inline enum state check_emit_msg_stream_end(struct ctf_msg_iter *msg_it)
-{
-    enum state next_state;
-
-    if (msg_it->emit_stream_end_message) {
-        next_state = STATE_EMIT_MSG_STREAM_END;
-    } else {
-        next_state = STATE_DONE;
-    }
-
-    return next_state;
-}
-
-static inline enum ctf_msg_iter_status handle_state(struct ctf_msg_iter *msg_it)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-    const enum state state = msg_it->state;
-
-    BT_CLOGT("Handling state: msg-it-addr=%p, state=%s", msg_it, state_string(state));
-
-    // TODO: optimalize!
-    switch (state) {
-    case STATE_INIT:
-        msg_it->state = STATE_SWITCH_PACKET;
-        break;
-    case STATE_SWITCH_PACKET:
-        status = switch_packet_state(msg_it);
-        break;
-    case STATE_DSCOPE_TRACE_PACKET_HEADER_BEGIN:
-        status = read_packet_header_begin_state(msg_it);
-        break;
-    case STATE_DSCOPE_TRACE_PACKET_HEADER_CONTINUE:
-        status = read_packet_header_continue_state(msg_it);
-        break;
-    case STATE_AFTER_TRACE_PACKET_HEADER:
-        status = after_packet_header_state(msg_it);
-        break;
-    case STATE_DSCOPE_STREAM_PACKET_CONTEXT_BEGIN:
-        status = read_packet_context_begin_state(msg_it);
-        break;
-    case STATE_DSCOPE_STREAM_PACKET_CONTEXT_CONTINUE:
-        status = read_packet_context_continue_state(msg_it);
-        break;
-    case STATE_AFTER_STREAM_PACKET_CONTEXT:
-        status = after_packet_context_state(msg_it);
-        break;
-    case STATE_EMIT_MSG_STREAM_BEGINNING:
-        msg_it->state = STATE_CHECK_EMIT_MSG_DISCARDED_EVENTS;
-        break;
-    case STATE_CHECK_EMIT_MSG_DISCARDED_EVENTS:
-        status = check_emit_msg_discarded_events(msg_it);
-        break;
-    case STATE_EMIT_MSG_DISCARDED_EVENTS:
-        msg_it->state = STATE_CHECK_EMIT_MSG_DISCARDED_PACKETS;
-        break;
-    case STATE_CHECK_EMIT_MSG_DISCARDED_PACKETS:
-        status = check_emit_msg_discarded_packets(msg_it);
-        break;
-    case STATE_EMIT_MSG_DISCARDED_PACKETS:
-        msg_it->state = STATE_EMIT_MSG_PACKET_BEGINNING;
-        break;
-    case STATE_EMIT_MSG_PACKET_BEGINNING:
-        msg_it->state = STATE_DSCOPE_EVENT_HEADER_BEGIN;
-        break;
-    case STATE_DSCOPE_EVENT_HEADER_BEGIN:
-        status = read_event_header_begin_state(msg_it);
-        break;
-    case STATE_DSCOPE_EVENT_HEADER_CONTINUE:
-        status = read_event_header_continue_state(msg_it);
-        break;
-    case STATE_AFTER_EVENT_HEADER:
-        status = after_event_header_state(msg_it);
-        break;
-    case STATE_DSCOPE_EVENT_COMMON_CONTEXT_BEGIN:
-        status = read_event_common_context_begin_state(msg_it);
-        break;
-    case STATE_DSCOPE_EVENT_COMMON_CONTEXT_CONTINUE:
-        status = read_event_common_context_continue_state(msg_it);
-        break;
-    case STATE_DSCOPE_EVENT_SPEC_CONTEXT_BEGIN:
-        status = read_event_spec_context_begin_state(msg_it);
-        break;
-    case STATE_DSCOPE_EVENT_SPEC_CONTEXT_CONTINUE:
-        status = read_event_spec_context_continue_state(msg_it);
-        break;
-    case STATE_DSCOPE_EVENT_PAYLOAD_BEGIN:
-        status = read_event_payload_begin_state(msg_it);
-        break;
-    case STATE_DSCOPE_EVENT_PAYLOAD_CONTINUE:
-        status = read_event_payload_continue_state(msg_it);
-        break;
-    case STATE_EMIT_MSG_EVENT:
-        msg_it->state = STATE_DSCOPE_EVENT_HEADER_BEGIN;
-        break;
-    case STATE_EMIT_QUEUED_MSG_EVENT:
-        msg_it->state = STATE_EMIT_MSG_EVENT;
-        break;
-    case STATE_SKIP_PACKET_PADDING:
-        status = skip_packet_padding_state(msg_it);
-        break;
-    case STATE_EMIT_MSG_PACKET_END_MULTI:
-        msg_it->state = STATE_SKIP_PACKET_PADDING;
-        break;
-    case STATE_EMIT_MSG_PACKET_END_SINGLE:
-        msg_it->state = STATE_EMIT_MSG_STREAM_END;
-        break;
-    case STATE_EMIT_QUEUED_MSG_PACKET_END:
-        msg_it->state = STATE_EMIT_MSG_PACKET_END_SINGLE;
-        break;
-    case STATE_CHECK_EMIT_MSG_STREAM_END:
-        msg_it->state = check_emit_msg_stream_end(msg_it);
-        break;
-    case STATE_EMIT_MSG_STREAM_END:
-        msg_it->state = STATE_DONE;
-        break;
-    case STATE_DONE:
-        break;
-    default:
-        BT_CLOGF("Unknown CTF plugin message iterator state: "
-                 "msg-it-addr=%p, state=%d",
-                 msg_it, msg_it->state);
-        bt_common_abort();
-    }
-
-    BT_CLOGT("Handled state: msg-it-addr=%p, status=%s, "
-             "prev-state=%s, cur-state=%s",
-             msg_it, ctf_msg_iter_status_string(status), state_string(state),
-             state_string(msg_it->state));
-    return status;
-}
-
-BT_HIDDEN
-void ctf_msg_iter_reset_for_next_stream_file(struct ctf_msg_iter *msg_it)
-{
-    BT_ASSERT(msg_it);
-    BT_CLOGD("Resetting message iterator: addr=%p", msg_it);
-    stack_clear(msg_it->stack);
-    msg_it->meta.sc = NULL;
-    msg_it->meta.ec = NULL;
-    BT_PACKET_PUT_REF_AND_RESET(msg_it->packet);
-    BT_STREAM_PUT_REF_AND_RESET(msg_it->stream);
-    BT_MESSAGE_PUT_REF_AND_RESET(msg_it->event_msg);
-    release_all_dscopes(msg_it);
-    msg_it->cur_dscope_field = NULL;
-
-    msg_it->buf.addr = NULL;
-    msg_it->buf.sz = 0;
-    msg_it->buf.at = 0;
-    msg_it->buf.last_eh_at = SIZE_MAX;
-    msg_it->buf.packet_offset = 0;
-    msg_it->state = STATE_INIT;
-    msg_it->cur_exp_packet_content_size = -1;
-    msg_it->cur_exp_packet_total_size = -1;
-    msg_it->cur_packet_offset = -1;
-    msg_it->cur_event_class_id = -1;
-    msg_it->snapshots.beginning_clock = UINT64_C(-1);
-    msg_it->snapshots.end_clock = UINT64_C(-1);
-}
-
-/**
- * Resets the internal state of a CTF message iterator.
- */
-BT_HIDDEN
-void ctf_msg_iter_reset(struct ctf_msg_iter *msg_it)
-{
-    ctf_msg_iter_reset_for_next_stream_file(msg_it);
-    msg_it->cur_stream_class_id = -1;
-    msg_it->cur_data_stream_id = -1;
-    msg_it->snapshots.discarded_events = UINT64_C(-1);
-    msg_it->snapshots.packets = UINT64_C(-1);
-    msg_it->prev_packet_snapshots.discarded_events = UINT64_C(-1);
-    msg_it->prev_packet_snapshots.packets = UINT64_C(-1);
-    msg_it->prev_packet_snapshots.beginning_clock = UINT64_C(-1);
-    msg_it->prev_packet_snapshots.end_clock = UINT64_C(-1);
-    msg_it->emit_stream_beginning_message = true;
-    msg_it->emit_stream_end_message = false;
-}
-
-static bt_field *borrow_next_field(struct ctf_msg_iter *msg_it)
-{
-    bt_field *next_field = NULL;
-    bt_field *base_field;
-    const bt_field_class *base_fc;
-    bt_field_class_type base_fc_type;
-    size_t index;
-
-    BT_ASSERT_DBG(!stack_empty(msg_it->stack));
-    index = stack_top(msg_it->stack)->index;
-    base_field = stack_top(msg_it->stack)->base;
-    BT_ASSERT_DBG(base_field);
-    base_fc = bt_field_borrow_class_const(base_field);
-    BT_ASSERT_DBG(base_fc);
-    base_fc_type = bt_field_class_get_type(base_fc);
-
-    if (base_fc_type == BT_FIELD_CLASS_TYPE_STRUCTURE) {
-        BT_ASSERT_DBG(index < bt_field_class_structure_get_member_count(
-                                  bt_field_borrow_class_const(base_field)));
-        next_field = bt_field_structure_borrow_member_field_by_index(base_field, index);
-    } else if (bt_field_class_type_is(base_fc_type, BT_FIELD_CLASS_TYPE_ARRAY)) {
-        BT_ASSERT_DBG(index < bt_field_array_get_length(base_field));
-        next_field = bt_field_array_borrow_element_field_by_index(base_field, index);
-    } else if (bt_field_class_type_is(base_fc_type, BT_FIELD_CLASS_TYPE_VARIANT)) {
-        BT_ASSERT_DBG(index == 0);
-        next_field = bt_field_variant_borrow_selected_option_field(base_field);
-    } else {
-        bt_common_abort();
-    }
-
-    BT_ASSERT_DBG(next_field);
-    return next_field;
-}
-
-static void update_default_clock(struct ctf_msg_iter *msg_it, uint64_t new_val,
-                                 uint64_t new_val_size)
-{
-    uint64_t new_val_mask;
-    uint64_t cur_value_masked;
-
-    BT_ASSERT_DBG(new_val_size > 0);
-
-    /*
-     * Special case for a 64-bit new value, which is the limit
-     * of a clock value as of this version: overwrite the
-     * current value directly.
-     */
-    if (new_val_size == 64) {
-        msg_it->default_clock_snapshot = new_val;
-        goto end;
-    }
-
-    new_val_mask = (1ULL << new_val_size) - 1;
-    cur_value_masked = msg_it->default_clock_snapshot & new_val_mask;
-
-    if (new_val < cur_value_masked) {
-        /*
-         * It looks like a wrap happened on the number of bits
-         * of the requested new value. Assume that the clock
-         * value wrapped only one time.
-         */
-        msg_it->default_clock_snapshot += new_val_mask + 1;
-    }
-
-    /* Clear the low bits of the current clock value. */
-    msg_it->default_clock_snapshot &= ~new_val_mask;
-
-    /* Set the low bits of the current clock value. */
-    msg_it->default_clock_snapshot |= new_val;
-
-end:
-    BT_CLOGT("Updated default clock's value from integer field's value: "
-             "value=%" PRIu64,
-             msg_it->default_clock_snapshot);
-}
-
-static enum bt_bfcr_status bfcr_unsigned_int_cb(uint64_t value, struct ctf_field_class *fc,
-                                                void *data)
-{
-    ctf_msg_iter *msg_it = (ctf_msg_iter *) data;
-    enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
-
-    bt_field *field = NULL;
-    ctf_field_class_int *int_fc = ctf_field_class_as_int(fc);
-
-    BT_CLOGT("Unsigned integer function called from BFCR: "
-             "msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, "
-             "fc-type=%d, fc-in-ir=%d, value=%" PRIu64,
-             msg_it, msg_it->bfcr, fc, fc->type, fc->in_ir, value);
-
-    if (G_LIKELY(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE)) {
-        goto update_def_clock;
-    }
-
-    switch (int_fc->meaning) {
-    case CTF_FIELD_CLASS_MEANING_EVENT_CLASS_ID:
-        msg_it->cur_event_class_id = value;
-        break;
-    case CTF_FIELD_CLASS_MEANING_DATA_STREAM_ID:
-        msg_it->cur_data_stream_id = value;
-        break;
-    case CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME:
-        msg_it->snapshots.beginning_clock = value;
-        break;
-    case CTF_FIELD_CLASS_MEANING_PACKET_END_TIME:
-        msg_it->snapshots.end_clock = value;
-        break;
-    case CTF_FIELD_CLASS_MEANING_STREAM_CLASS_ID:
-        msg_it->cur_stream_class_id = value;
-        break;
-    case CTF_FIELD_CLASS_MEANING_MAGIC:
-        if (value != 0xc1fc1fc1) {
-            BT_CLOGE_APPEND_CAUSE("Invalid CTF magic number: msg-it-addr=%p, "
-                                  "magic=%" PRIx64,
-                                  msg_it, value);
-            status = BT_BFCR_STATUS_ERROR;
-            goto end;
-        }
-
-        break;
-    case CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT:
-        msg_it->snapshots.packets = value;
-        break;
-    case CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT:
-        msg_it->snapshots.discarded_events = value;
-        break;
-    case CTF_FIELD_CLASS_MEANING_EXP_PACKET_TOTAL_SIZE:
-        msg_it->cur_exp_packet_total_size = value;
-        break;
-    case CTF_FIELD_CLASS_MEANING_EXP_PACKET_CONTENT_SIZE:
-        msg_it->cur_exp_packet_content_size = value;
-        break;
-    default:
-        bt_common_abort();
-    }
-
-update_def_clock:
-    if (G_UNLIKELY(int_fc->mapped_clock_class)) {
-        update_default_clock(msg_it, value, int_fc->base.size);
-    }
-
-    if (G_UNLIKELY(int_fc->storing_index >= 0)) {
-        g_array_index(msg_it->stored_values, uint64_t, (uint64_t) int_fc->storing_index) = value;
-    }
-
-    if (G_UNLIKELY(!fc->in_ir || msg_it->dry_run)) {
-        goto end;
-    }
-
-    field = borrow_next_field(msg_it);
-    BT_ASSERT_DBG(field);
-    BT_ASSERT_DBG(bt_field_borrow_class_const(field) == fc->ir_fc);
-    BT_ASSERT_DBG(bt_field_class_type_is(bt_field_get_class_type(field),
-                                         BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER));
-    bt_field_integer_unsigned_set_value(field, value);
-    stack_top(msg_it->stack)->index++;
-
-end:
-    return status;
-}
-
-static enum bt_bfcr_status bfcr_unsigned_int_char_cb(uint64_t value, struct ctf_field_class *fc,
-                                                     void *data)
-{
-    int ret;
-    ctf_msg_iter *msg_it = (ctf_msg_iter *) data;
-    enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
-    bt_field *string_field = NULL;
-    ctf_field_class_int *int_fc = ctf_field_class_as_int(fc);
-    char str[2] = {'\0', '\0'};
-
-    BT_CLOGT("Unsigned integer character function called from BFCR: "
-             "msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, "
-             "fc-type=%d, fc-in-ir=%d, value=%" PRIu64,
-             msg_it, msg_it->bfcr, fc, fc->type, fc->in_ir, value);
-    BT_ASSERT_DBG(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE);
-    BT_ASSERT_DBG(!int_fc->mapped_clock_class);
-    BT_ASSERT_DBG(int_fc->storing_index < 0);
-
-    if (G_UNLIKELY(!fc->in_ir || msg_it->dry_run)) {
-        goto end;
-    }
-
-    if (msg_it->done_filling_string) {
-        goto end;
-    }
-
-    if (value == 0) {
-        msg_it->done_filling_string = true;
-        goto end;
-    }
-
-    string_field = stack_top(msg_it->stack)->base;
-    BT_ASSERT_DBG(bt_field_get_class_type(string_field) == BT_FIELD_CLASS_TYPE_STRING);
-
-    /* Append character */
-    str[0] = (char) value;
-    ret = bt_field_string_append_with_length(string_field, str, 1);
-    if (ret) {
-        BT_CLOGE_APPEND_CAUSE("Cannot append character to string field's value: "
-                              "msg-it-addr=%p, field-addr=%p, ret=%d",
-                              msg_it, string_field, ret);
-        status = BT_BFCR_STATUS_ERROR;
-        goto end;
-    }
-
-end:
-    return status;
-}
-
-static enum bt_bfcr_status bfcr_signed_int_cb(int64_t value, struct ctf_field_class *fc, void *data)
-{
-    enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
-    bt_field *field = NULL;
-    ctf_msg_iter *msg_it = (ctf_msg_iter *) data;
-    ctf_field_class_int *int_fc = ctf_field_class_as_int(fc);
-
-    BT_CLOGT("Signed integer function called from BFCR: "
-             "msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, "
-             "fc-type=%d, fc-in-ir=%d, value=%" PRId64,
-             msg_it, msg_it->bfcr, fc, fc->type, fc->in_ir, value);
-    BT_ASSERT_DBG(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE);
-
-    if (G_UNLIKELY(int_fc->storing_index >= 0)) {
-        g_array_index(msg_it->stored_values, uint64_t, (uint64_t) int_fc->storing_index) =
-            (uint64_t) value;
-    }
-
-    if (G_UNLIKELY(!fc->in_ir || msg_it->dry_run)) {
-        goto end;
-    }
-
-    field = borrow_next_field(msg_it);
-    BT_ASSERT_DBG(field);
-    BT_ASSERT_DBG(bt_field_borrow_class_const(field) == fc->ir_fc);
-    BT_ASSERT_DBG(
-        bt_field_class_type_is(bt_field_get_class_type(field), BT_FIELD_CLASS_TYPE_SIGNED_INTEGER));
-    bt_field_integer_signed_set_value(field, value);
-    stack_top(msg_it->stack)->index++;
-
-end:
-    return status;
-}
-
-static enum bt_bfcr_status bfcr_floating_point_cb(double value, struct ctf_field_class *fc,
-                                                  void *data)
-{
-    enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
-    bt_field *field = NULL;
-    ctf_msg_iter *msg_it = (ctf_msg_iter *) data;
-    bt_field_class_type type;
-
-    BT_CLOGT("Floating point number function called from BFCR: "
-             "msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, "
-             "fc-type=%d, fc-in-ir=%d, value=%f",
-             msg_it, msg_it->bfcr, fc, fc->type, fc->in_ir, value);
-
-    if (G_UNLIKELY(!fc->in_ir || msg_it->dry_run)) {
-        goto end;
-    }
-
-    field = borrow_next_field(msg_it);
-    type = bt_field_get_class_type(field);
-    BT_ASSERT_DBG(field);
-    BT_ASSERT_DBG(bt_field_borrow_class_const(field) == fc->ir_fc);
-    BT_ASSERT_DBG(bt_field_class_type_is(type, BT_FIELD_CLASS_TYPE_REAL));
-
-    if (type == BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL) {
-        bt_field_real_single_precision_set_value(field, (float) value);
-    } else {
-        bt_field_real_double_precision_set_value(field, value);
-    }
-    stack_top(msg_it->stack)->index++;
-
-end:
-    return status;
-}
-
-static enum bt_bfcr_status bfcr_string_begin_cb(struct ctf_field_class *fc, void *data)
-{
-    bt_field *field = NULL;
-    ctf_msg_iter *msg_it = (ctf_msg_iter *) data;
-
-    BT_CLOGT("String (beginning) function called from BFCR: "
-             "msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, "
-             "fc-type=%d, fc-in-ir=%d",
-             msg_it, msg_it->bfcr, fc, fc->type, fc->in_ir);
-
-    if (G_UNLIKELY(!fc->in_ir || msg_it->dry_run)) {
-        goto end;
-    }
-
-    field = borrow_next_field(msg_it);
-    BT_ASSERT_DBG(field);
-    BT_ASSERT_DBG(bt_field_borrow_class_const(field) == fc->ir_fc);
-    BT_ASSERT_DBG(bt_field_get_class_type(field) == BT_FIELD_CLASS_TYPE_STRING);
-    bt_field_string_clear(field);
-
-    /*
-     * Push on stack. Not a compound class per se, but we know that
-     * only bfcr_string_cb() may be called between this call and a
-     * subsequent call to bfcr_string_end_cb().
-     */
-    stack_push(msg_it->stack, field);
-
-end:
-    return BT_BFCR_STATUS_OK;
-}
-
-static enum bt_bfcr_status bfcr_string_cb(const char *value, size_t len, struct ctf_field_class *fc,
-                                          void *data)
-{
-    enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
-    bt_field *field = NULL;
-    ctf_msg_iter *msg_it = (ctf_msg_iter *) data;
-    int ret;
-
-    BT_CLOGT("String (substring) function called from BFCR: "
-             "msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, "
-             "fc-type=%d, fc-in-ir=%d, string-length=%zu",
-             msg_it, msg_it->bfcr, fc, fc->type, fc->in_ir, len);
-
-    if (G_UNLIKELY(!fc->in_ir || msg_it->dry_run)) {
-        goto end;
-    }
-
-    field = stack_top(msg_it->stack)->base;
-    BT_ASSERT_DBG(field);
-
-    /* Append current substring */
-    ret = bt_field_string_append_with_length(field, value, len);
-    if (ret) {
-        BT_CLOGE_APPEND_CAUSE("Cannot append substring to string field's value: "
-                              "msg-it-addr=%p, field-addr=%p, string-length=%zu, "
-                              "ret=%d",
-                              msg_it, field, len, ret);
-        status = BT_BFCR_STATUS_ERROR;
-        goto end;
-    }
-
-end:
-    return status;
-}
-
-static enum bt_bfcr_status bfcr_string_end_cb(struct ctf_field_class *fc, void *data)
-{
-    ctf_msg_iter *msg_it = (ctf_msg_iter *) data;
-
-    BT_CLOGT("String (end) function called from BFCR: "
-             "msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, "
-             "fc-type=%d, fc-in-ir=%d",
-             msg_it, msg_it->bfcr, fc, fc->type, fc->in_ir);
-
-    if (G_UNLIKELY(!fc->in_ir || msg_it->dry_run)) {
-        goto end;
-    }
-
-    /* Pop string field */
-    stack_pop(msg_it->stack);
-
-    /* Go to next field */
-    stack_top(msg_it->stack)->index++;
-
-end:
-    return BT_BFCR_STATUS_OK;
-}
-
-static enum bt_bfcr_status bfcr_compound_begin_cb(struct ctf_field_class *fc, void *data)
-{
-    ctf_msg_iter *msg_it = (ctf_msg_iter *) data;
-    bt_field *field;
-
-    BT_CLOGT("Compound (beginning) function called from BFCR: "
-             "msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, "
-             "fc-type=%d, fc-in-ir=%d",
-             msg_it, msg_it->bfcr, fc, fc->type, fc->in_ir);
-
-    if (G_UNLIKELY(!fc->in_ir || msg_it->dry_run)) {
-        goto end;
-    }
-
-    /* Borrow field */
-    if (stack_empty(msg_it->stack)) {
-        /* Root: already set by read_dscope_begin_state() */
-        field = msg_it->cur_dscope_field;
-    } else {
-        field = borrow_next_field(msg_it);
-        BT_ASSERT_DBG(field);
-    }
-
-    /* Push field */
-    BT_ASSERT_DBG(field);
-    BT_ASSERT_DBG(bt_field_borrow_class_const(field) == fc->ir_fc);
-    stack_push(msg_it->stack, field);
-
-    /*
-     * Change BFCR "unsigned int" callback if it's a text
-     * array/sequence.
-     */
-    if (fc->type == CTF_FIELD_CLASS_TYPE_ARRAY || fc->type == CTF_FIELD_CLASS_TYPE_SEQUENCE) {
-        ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(fc);
-
-        if (array_fc->is_text) {
-            BT_ASSERT_DBG(bt_field_get_class_type(field) == BT_FIELD_CLASS_TYPE_STRING);
-            msg_it->done_filling_string = false;
-            bt_field_string_clear(field);
-            bt_bfcr_set_unsigned_int_cb(msg_it->bfcr, bfcr_unsigned_int_char_cb);
-        }
-    }
-
-end:
-    return BT_BFCR_STATUS_OK;
-}
-
-static enum bt_bfcr_status bfcr_compound_end_cb(struct ctf_field_class *fc, void *data)
-{
-    ctf_msg_iter *msg_it = (ctf_msg_iter *) data;
-
-    BT_CLOGT("Compound (end) function called from BFCR: "
-             "msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, "
-             "fc-type=%d, fc-in-ir=%d",
-             msg_it, msg_it->bfcr, fc, fc->type, fc->in_ir);
-
-    if (G_UNLIKELY(!fc->in_ir || msg_it->dry_run)) {
-        goto end;
-    }
-
-    BT_ASSERT_DBG(!stack_empty(msg_it->stack));
-    BT_ASSERT_DBG(bt_field_borrow_class_const(stack_top(msg_it->stack)->base) == fc->ir_fc);
-
-    /*
-     * Reset BFCR "unsigned int" callback if it's a text
-     * array/sequence.
-     */
-    if (fc->type == CTF_FIELD_CLASS_TYPE_ARRAY || fc->type == CTF_FIELD_CLASS_TYPE_SEQUENCE) {
-        ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(fc);
-
-        if (array_fc->is_text) {
-            BT_ASSERT_DBG(bt_field_get_class_type(stack_top(msg_it->stack)->base) ==
-                          BT_FIELD_CLASS_TYPE_STRING);
-            bt_bfcr_set_unsigned_int_cb(msg_it->bfcr, bfcr_unsigned_int_cb);
-        }
-    }
-
-    /* Pop stack */
-    stack_pop(msg_it->stack);
-
-    /* If the stack is not empty, increment the base's index */
-    if (!stack_empty(msg_it->stack)) {
-        stack_top(msg_it->stack)->index++;
-    }
-
-end:
-    return BT_BFCR_STATUS_OK;
-}
-
-static int64_t bfcr_get_sequence_length_cb(struct ctf_field_class *fc, void *data)
-{
-    bt_field *seq_field;
-    ctf_msg_iter *msg_it = (ctf_msg_iter *) data;
-    struct ctf_field_class_sequence *seq_fc = ctf_field_class_as_sequence(fc);
-    int64_t length;
-    int ret;
-
-    length = (uint64_t) g_array_index(msg_it->stored_values, uint64_t, seq_fc->stored_length_index);
-
-    if (G_UNLIKELY(msg_it->dry_run)) {
-        goto end;
-    }
-
-    seq_field = stack_top(msg_it->stack)->base;
-    BT_ASSERT_DBG(seq_field);
-
-    /*
-     * bfcr_get_sequence_length_cb() also gets called back for a
-     * text sequence, but the destination field is a string field.
-     * Only set the field's sequence length if the destination field
-     * is a sequence field.
-     */
-    if (!seq_fc->base.is_text) {
-        BT_ASSERT_DBG(bt_field_class_type_is(bt_field_get_class_type(seq_field),
-                                             BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY));
-        ret = bt_field_array_dynamic_set_length(seq_field, (uint64_t) length);
-        if (ret) {
-            BT_CLOGE_APPEND_CAUSE("Cannot set dynamic array field's length field: "
-                                  "msg-it-addr=%p, field-addr=%p, "
-                                  "length=%" PRIu64,
-                                  msg_it, seq_field, length);
-            length = -1;
-        }
-    }
-
-end:
-    return length;
-}
-
-static struct ctf_field_class *
-bfcr_borrow_variant_selected_field_class_cb(struct ctf_field_class *fc, void *data)
-{
-    int ret;
-    uint64_t i;
-    int64_t option_index = -1;
-    ctf_msg_iter *msg_it = (ctf_msg_iter *) data;
-    ctf_field_class_variant *var_fc = ctf_field_class_as_variant(fc);
-    struct ctf_named_field_class *selected_option = NULL;
-    struct ctf_field_class *ret_fc = NULL;
-    union
-    {
-        uint64_t u;
-        int64_t i;
-    } tag;
-
-    /* Get variant's tag */
-    tag.u = g_array_index(msg_it->stored_values, uint64_t, var_fc->stored_tag_index);
-
-    /*
-     * Check each range to find the selected option's index.
-     */
-    if (var_fc->tag_fc->base.is_signed) {
-        for (i = 0; i < var_fc->ranges->len; i++) {
-            struct ctf_field_class_variant_range *range =
-                ctf_field_class_variant_borrow_range_by_index(var_fc, i);
-
-            if (tag.i >= range->range.lower.i && tag.i <= range->range.upper.i) {
-                option_index = (int64_t) range->option_index;
-                break;
-            }
-        }
-    } else {
-        for (i = 0; i < var_fc->ranges->len; i++) {
-            struct ctf_field_class_variant_range *range =
-                ctf_field_class_variant_borrow_range_by_index(var_fc, i);
-
-            if (tag.u >= range->range.lower.u && tag.u <= range->range.upper.u) {
-                option_index = (int64_t) range->option_index;
-                break;
-            }
-        }
-    }
-
-    if (option_index < 0) {
-        BT_CLOGE_APPEND_CAUSE("Cannot find variant field class's option: "
-                              "msg-it-addr=%p, var-fc-addr=%p, u-tag=%" PRIu64 ", "
-                              "i-tag=%" PRId64,
-                              msg_it, var_fc, tag.u, tag.i);
-        ret_fc = NULL;
-        goto end;
-    }
-
-    selected_option =
-        ctf_field_class_variant_borrow_option_by_index(var_fc, (uint64_t) option_index);
-
-    if (selected_option->fc->in_ir && !msg_it->dry_run) {
-        bt_field *var_field = stack_top(msg_it->stack)->base;
-
-        ret = bt_field_variant_select_option_by_index(var_field, option_index);
-        if (ret) {
-            BT_CLOGE_APPEND_CAUSE("Cannot select variant field's option field: "
-                                  "msg-it-addr=%p, var-field-addr=%p, "
-                                  "opt-index=%" PRId64,
-                                  msg_it, var_field, option_index);
-            ret_fc = NULL;
-            goto end;
-        }
-    }
-
-    ret_fc = selected_option->fc;
-
-end:
-    return ret_fc;
-}
-
-static bt_message *create_msg_stream_beginning(struct ctf_msg_iter *msg_it)
-{
-    bt_message *msg;
-
-    BT_ASSERT(msg_it->stream);
-    BT_ASSERT(msg_it->self_msg_iter);
-    msg = bt_message_stream_beginning_create(msg_it->self_msg_iter, msg_it->stream);
-    if (!msg) {
-        BT_CLOGE_APPEND_CAUSE("Cannot create stream beginning message: "
-                              "msg-it-addr=%p, stream-addr=%p",
-                              msg_it, msg_it->stream);
-    }
-
-    return msg;
-}
-
-static bt_message *create_msg_stream_end(struct ctf_msg_iter *msg_it)
-{
-    bt_message *msg;
-
-    if (!msg_it->stream) {
-        BT_CLOGE_APPEND_CAUSE("Cannot create stream end message because stream is NULL: "
-                              "msg-it-addr=%p",
-                              msg_it);
-        msg = NULL;
-        goto end;
-    }
-
-    BT_ASSERT(msg_it->self_msg_iter);
-    msg = bt_message_stream_end_create(msg_it->self_msg_iter, msg_it->stream);
-    if (!msg) {
-        BT_CLOGE_APPEND_CAUSE("Cannot create stream end message: "
-                              "msg-it-addr=%p, stream-addr=%p",
-                              msg_it, msg_it->stream);
-    }
-
-end:
-    return msg;
-}
-
-static bt_message *create_msg_packet_beginning(struct ctf_msg_iter *msg_it, bool use_default_cs)
-{
-    bt_message *msg;
-    const bt_stream_class *sc = msg_it->meta.sc->ir_sc;
-
-    BT_ASSERT(msg_it->packet);
-    BT_ASSERT(sc);
-    BT_ASSERT(msg_it->self_msg_iter);
-
-    if (msg_it->meta.sc->packets_have_ts_begin) {
-        BT_ASSERT(msg_it->snapshots.beginning_clock != UINT64_C(-1));
-        uint64_t raw_cs_value;
-
-        /*
-         * Either use the decoded packet `timestamp_begin` field or the
-         * current stream's default clock_snapshot.
-         */
-        if (use_default_cs) {
-            raw_cs_value = msg_it->default_clock_snapshot;
-        } else {
-            raw_cs_value = msg_it->snapshots.beginning_clock;
-        }
-
-        msg = bt_message_packet_beginning_create_with_default_clock_snapshot(
-            msg_it->self_msg_iter, msg_it->packet, raw_cs_value);
-    } else {
-        msg = bt_message_packet_beginning_create(msg_it->self_msg_iter, msg_it->packet);
-    }
-
-    if (!msg) {
-        BT_CLOGE_APPEND_CAUSE("Cannot create packet beginning message: "
-                              "msg-it-addr=%p, packet-addr=%p",
-                              msg_it, msg_it->packet);
-        goto end;
-    }
-
-end:
-    return msg;
-}
-
-static bt_message *emit_delayed_packet_beg_msg(struct ctf_msg_iter *msg_it)
-{
-    bool packet_beg_ts_need_fix_up;
-
-    msg_it->emit_delayed_packet_beginning_msg = false;
-
-    /*
-     * Only fix the packet's timestamp_begin if it's larger than the first
-     * event of the packet. If there was no event in the packet, the
-     * `default_clock_snapshot` field will be either equal or greater than
-     * `snapshots.beginning_clock` so there is not fix needed.
-     */
-    packet_beg_ts_need_fix_up = msg_it->default_clock_snapshot < msg_it->snapshots.beginning_clock;
-
-    /* create_msg_packet_beginning() logs errors */
-    return create_msg_packet_beginning(msg_it, packet_beg_ts_need_fix_up);
-}
-
-static bt_message *create_msg_packet_end(struct ctf_msg_iter *msg_it)
-{
-    bt_message *msg;
-    bool update_default_cs = true;
-
-    if (!msg_it->packet) {
-        msg = NULL;
-        goto end;
-    }
-
-    /*
-     * Check if we need to emit the delayed packet
-     * beginning message instead of the packet end message.
-     */
-    if (G_UNLIKELY(msg_it->emit_delayed_packet_beginning_msg)) {
-        msg = emit_delayed_packet_beg_msg(msg_it);
-        /* Don't forget to emit the packet end message. */
-        msg_it->state = STATE_EMIT_QUEUED_MSG_PACKET_END;
-        goto end;
-    }
-
-    /* Check if may be affected by lttng-crash timestamp_end quirk. */
-    if (G_UNLIKELY(msg_it->meta.tc->quirks.lttng_crash)) {
-        /*
-         * Check if the `timestamp_begin` field is non-zero but
-         * `timestamp_end` is zero. It means the trace is affected by
-         * the lttng-crash packet `timestamp_end` quirk and must be
-         * fixed up by omitting to update the default clock snapshot to
-         * the `timestamp_end` as is typically done.
-         */
-        if (msg_it->snapshots.beginning_clock != 0 && msg_it->snapshots.end_clock == 0) {
-            update_default_cs = false;
-        }
-    }
-
-    /*
-     * Check if may be affected by lttng event-after-packet `timestamp_end`
-     * quirk.
-     */
-    if (msg_it->meta.tc->quirks.lttng_event_after_packet) {
-        /*
-         * Check if `timestamp_end` is smaller then the current
-         * default_clock_snapshot (which is set to the last event
-         * decoded). It means the trace is affected by the lttng
-         * `event-after-packet` packet `timestamp_end` quirk and must
-         * be fixed up by omitting to update the default clock snapshot
-         * to the `timestamp_end` as is typically done.
-         */
-        if (msg_it->snapshots.end_clock < msg_it->default_clock_snapshot) {
-            update_default_cs = false;
-        }
-    }
-
-    /* Update default clock from packet's end time. */
-    if (msg_it->snapshots.end_clock != UINT64_C(-1) && update_default_cs) {
-        msg_it->default_clock_snapshot = msg_it->snapshots.end_clock;
-    }
-
-    BT_ASSERT(msg_it->self_msg_iter);
-
-    if (msg_it->meta.sc->packets_have_ts_end) {
-        BT_ASSERT(msg_it->snapshots.end_clock != UINT64_C(-1));
-        msg = bt_message_packet_end_create_with_default_clock_snapshot(
-            msg_it->self_msg_iter, msg_it->packet, msg_it->default_clock_snapshot);
-    } else {
-        msg = bt_message_packet_end_create(msg_it->self_msg_iter, msg_it->packet);
-    }
-
-    if (!msg) {
-        BT_CLOGE_APPEND_CAUSE("Cannot create packet end message: "
-                              "msg-it-addr=%p, packet-addr=%p",
-                              msg_it, msg_it->packet);
-        goto end;
-    }
-
-    BT_PACKET_PUT_REF_AND_RESET(msg_it->packet);
-
-end:
-    return msg;
-}
-
-static bt_message *create_msg_discarded_events(struct ctf_msg_iter *msg_it)
-{
-    bt_message *msg;
-    uint64_t beginning_raw_value = UINT64_C(-1);
-    uint64_t end_raw_value = UINT64_C(-1);
-
-    BT_ASSERT(msg_it->self_msg_iter);
-    BT_ASSERT(msg_it->stream);
-    BT_ASSERT(msg_it->meta.sc->has_discarded_events);
-
-    if (msg_it->meta.sc->discarded_events_have_default_cs) {
-        if (msg_it->prev_packet_snapshots.discarded_events == UINT64_C(-1)) {
-            /*
-             * We discarded events, but before (and possibly
-             * including) the current packet: use this packet's time
-             * range, and do not have a specific count.
-             */
-            beginning_raw_value = msg_it->snapshots.beginning_clock;
-            end_raw_value = msg_it->snapshots.end_clock;
-        } else {
-            beginning_raw_value = msg_it->prev_packet_snapshots.end_clock;
-            end_raw_value = msg_it->snapshots.end_clock;
-        }
-
-        BT_ASSERT(beginning_raw_value != UINT64_C(-1));
-        BT_ASSERT(end_raw_value != UINT64_C(-1));
-        msg = bt_message_discarded_events_create_with_default_clock_snapshots(
-            msg_it->self_msg_iter, msg_it->stream, beginning_raw_value, end_raw_value);
-    } else {
-        msg = bt_message_discarded_events_create(msg_it->self_msg_iter, msg_it->stream);
-    }
-
-    if (!msg) {
-        BT_CLOGE_APPEND_CAUSE("Cannot create discarded events message: "
-                              "msg-it-addr=%p, stream-addr=%p",
-                              msg_it, msg_it->stream);
-        goto end;
-    }
-
-    if (msg_it->prev_packet_snapshots.discarded_events != UINT64_C(-1)) {
-        bt_message_discarded_events_set_count(msg,
-                                              msg_it->snapshots.discarded_events -
-                                                  msg_it->prev_packet_snapshots.discarded_events);
-    }
-
-end:
-    return msg;
-}
-
-static bt_message *create_msg_discarded_packets(struct ctf_msg_iter *msg_it)
-{
-    bt_message *msg;
-
-    BT_ASSERT(msg_it->self_msg_iter);
-    BT_ASSERT(msg_it->stream);
-    BT_ASSERT(msg_it->meta.sc->has_discarded_packets);
-    BT_ASSERT(msg_it->prev_packet_snapshots.packets != UINT64_C(-1));
-
-    if (msg_it->meta.sc->discarded_packets_have_default_cs) {
-        BT_ASSERT(msg_it->prev_packet_snapshots.end_clock != UINT64_C(-1));
-        BT_ASSERT(msg_it->snapshots.beginning_clock != UINT64_C(-1));
-        msg = bt_message_discarded_packets_create_with_default_clock_snapshots(
-            msg_it->self_msg_iter, msg_it->stream, msg_it->prev_packet_snapshots.end_clock,
-            msg_it->snapshots.beginning_clock);
-    } else {
-        msg = bt_message_discarded_packets_create(msg_it->self_msg_iter, msg_it->stream);
-    }
-
-    if (!msg) {
-        BT_CLOGE_APPEND_CAUSE("Cannot create discarded packets message: "
-                              "msg-it-addr=%p, stream-addr=%p",
-                              msg_it, msg_it->stream);
-        goto end;
-    }
-
-    bt_message_discarded_packets_set_count(msg, msg_it->snapshots.packets -
-                                                    msg_it->prev_packet_snapshots.packets - 1);
-
-end:
-    return msg;
-}
-
-BT_HIDDEN
-ctf_msg_iter_up ctf_msg_iter_create(struct ctf_trace_class *tc, size_t max_request_sz,
-                                    struct ctf_msg_iter_medium_ops medops, void *data,
-                                    bt_self_message_iterator *self_msg_iter,
-                                    const bt2_common::LogCfg& logCfg)
-{
-    struct bt_bfcr_cbs cbs = {
-        .classes =
-            {
-                .signed_int = bfcr_signed_int_cb,
-                .unsigned_int = bfcr_unsigned_int_cb,
-                .floating_point = bfcr_floating_point_cb,
-                .string_begin = bfcr_string_begin_cb,
-                .string = bfcr_string_cb,
-                .string_end = bfcr_string_end_cb,
-                .compound_begin = bfcr_compound_begin_cb,
-                .compound_end = bfcr_compound_end_cb,
-            },
-        .query =
-            {
-                .get_sequence_length = bfcr_get_sequence_length_cb,
-                .borrow_variant_selected_field_class = bfcr_borrow_variant_selected_field_class_cb,
-            },
-    };
-
-    BT_ASSERT(tc);
-    BT_ASSERT(medops.request_bytes);
-    BT_ASSERT(medops.borrow_stream);
-    BT_ASSERT(max_request_sz > 0);
-
-    BT_CLOGD_EX(logCfg,
-                "Creating CTF plugin message iterator: "
-                "trace-addr=%p, max-request-size=%zu, "
-                "data=%p, log-level=%s",
-                tc, max_request_sz, data, bt_common_logging_level_string(logCfg.logLevel()));
-
-    ctf_msg_iter_up msg_it {new ctf_msg_iter {logCfg}};
-    msg_it->self_msg_iter = self_msg_iter;
-    msg_it->meta.tc = tc;
-    msg_it->medium.medops = medops;
-    msg_it->medium.max_request_sz = max_request_sz;
-    msg_it->medium.data = data;
-    msg_it->stack = stack_new(msg_it.get());
-    msg_it->stored_values = g_array_new(FALSE, TRUE, sizeof(uint64_t));
-    g_array_set_size(msg_it->stored_values, tc->stored_value_count);
-
-    if (!msg_it->stack) {
-        BT_CLOGE_APPEND_CAUSE("Failed to create field stack.");
-        goto error;
-    }
-
-    msg_it->bfcr = bt_bfcr_create(cbs, msg_it.get(), msg_it->logCfg);
-    if (!msg_it->bfcr) {
-        BT_CLOGE_APPEND_CAUSE("Failed to create binary class reader (BFCR).");
-        goto error;
-    }
-
-    ctf_msg_iter_reset(msg_it.get());
-    BT_CLOGD("Created CTF plugin message iterator: "
-             "trace-addr=%p, max-request-size=%zu, "
-             "data=%p, msg-it-addr=%p, log-level=%s",
-             tc, max_request_sz, data, msg_it.get(),
-             bt_common_logging_level_string(logCfg.logLevel()));
-    msg_it->cur_packet_offset = 0;
-
-end:
-    return msg_it;
-
-error:
-    msg_it.reset();
-    goto end;
-}
-
-void ctf_msg_iter_destroy(struct ctf_msg_iter *msg_it)
-{
-    BT_PACKET_PUT_REF_AND_RESET(msg_it->packet);
-    BT_STREAM_PUT_REF_AND_RESET(msg_it->stream);
-    release_all_dscopes(msg_it);
-
-    BT_CLOGD("Destroying CTF plugin message iterator: addr=%p", msg_it);
-
-    if (msg_it->stack) {
-        BT_CLOGD_STR("Destroying field stack.");
-        stack_destroy(msg_it->stack);
-    }
-
-    if (msg_it->bfcr) {
-        BT_CLOGD("Destroying BFCR: bfcr-addr=%p", msg_it->bfcr);
-        bt_bfcr_destroy(msg_it->bfcr);
-    }
-
-    if (msg_it->stored_values) {
-        g_array_free(msg_it->stored_values, TRUE);
-    }
-
-    delete msg_it;
-}
-
-void ctf_msg_iter_deleter::operator()(ctf_msg_iter *iter)
-{
-    ctf_msg_iter_destroy(iter);
-}
-
-enum ctf_msg_iter_status ctf_msg_iter_get_next_message(struct ctf_msg_iter *msg_it,
-                                                       const bt_message **message)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-
-    BT_ASSERT_DBG(msg_it);
-    BT_ASSERT_DBG(message);
-    BT_CLOGD("Getting next message: msg-it-addr=%p", msg_it);
-
-    while (true) {
-        status = handle_state(msg_it);
-        if (G_UNLIKELY(status == CTF_MSG_ITER_STATUS_AGAIN)) {
-            BT_CLOGD_STR("Medium returned CTF_MSG_ITER_STATUS_AGAIN.");
-            goto end;
-        } else if (G_UNLIKELY(status != CTF_MSG_ITER_STATUS_OK)) {
-            BT_CLOGE_APPEND_CAUSE("Cannot handle state: msg-it-addr=%p, state=%s", msg_it,
-                                  state_string(msg_it->state));
-            goto end;
-        }
-
-        switch (msg_it->state) {
-        case STATE_EMIT_MSG_EVENT:
-            BT_ASSERT_DBG(msg_it->event_msg);
-
-            /*
-             * Check if we need to emit the delayed packet
-             * beginning message instead of the event message.
-             */
-            if (G_UNLIKELY(msg_it->emit_delayed_packet_beginning_msg)) {
-                *message = emit_delayed_packet_beg_msg(msg_it);
-                if (!*message) {
-                    status = CTF_MSG_ITER_STATUS_ERROR;
-                }
-
-                /*
-                 * Don't forget to emit the event message of
-                 * the event record that was just decoded.
-                 */
-                msg_it->state = STATE_EMIT_QUEUED_MSG_EVENT;
-
-            } else {
-                *message = msg_it->event_msg;
-                msg_it->event_msg = NULL;
-            }
-            goto end;
-        case STATE_EMIT_MSG_DISCARDED_EVENTS:
-            /* create_msg_discared_events() logs errors */
-            *message = create_msg_discarded_events(msg_it);
-
-            if (!*message) {
-                status = CTF_MSG_ITER_STATUS_ERROR;
-            }
-
-            goto end;
-        case STATE_EMIT_MSG_DISCARDED_PACKETS:
-            /* create_msg_discared_packets() logs errors */
-            *message = create_msg_discarded_packets(msg_it);
-
-            if (!*message) {
-                status = CTF_MSG_ITER_STATUS_ERROR;
-            }
-
-            goto end;
-        case STATE_EMIT_MSG_PACKET_BEGINNING:
-            if (G_UNLIKELY(msg_it->meta.tc->quirks.barectf_event_before_packet)) {
-                msg_it->emit_delayed_packet_beginning_msg = true;
-                /*
-                 * There is no message to return yet as this
-                 * packet beginning message is delayed until we
-                 * decode the first event message of the
-                 * packet.
-                 */
-                break;
-            } else {
-                /* create_msg_packet_beginning() logs errors */
-                *message = create_msg_packet_beginning(msg_it, false);
-                if (!*message) {
-                    status = CTF_MSG_ITER_STATUS_ERROR;
-                }
-            }
-
-            goto end;
-        case STATE_EMIT_MSG_PACKET_END_SINGLE:
-        case STATE_EMIT_MSG_PACKET_END_MULTI:
-            /* create_msg_packet_end() logs errors */
-            *message = create_msg_packet_end(msg_it);
-
-            if (!*message) {
-                status = CTF_MSG_ITER_STATUS_ERROR;
-            }
-
-            goto end;
-        case STATE_EMIT_MSG_STREAM_BEGINNING:
-            /* create_msg_stream_beginning() logs errors */
-            *message = create_msg_stream_beginning(msg_it);
-            msg_it->emit_stream_beginning_message = false;
-            msg_it->emit_stream_end_message = true;
-
-            if (!*message) {
-                status = CTF_MSG_ITER_STATUS_ERROR;
-            }
-
-            goto end;
-        case STATE_EMIT_MSG_STREAM_END:
-            /* create_msg_stream_end() logs errors */
-            *message = create_msg_stream_end(msg_it);
-            msg_it->emit_stream_end_message = false;
-
-            if (!*message) {
-                status = CTF_MSG_ITER_STATUS_ERROR;
-            }
-
-            goto end;
-        case STATE_DONE:
-            status = CTF_MSG_ITER_STATUS_EOF;
-            goto end;
-        default:
-            /* Non-emitting state: continue */
-            break;
-        }
-    }
-
-end:
-    return status;
-}
-
-static enum ctf_msg_iter_status decode_until_state(struct ctf_msg_iter *msg_it,
-                                                   enum state target_state_1,
-                                                   enum state target_state_2)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-
-    BT_ASSERT_DBG(msg_it);
-
-    do {
-        /*
-         * Check if we reached the state at which we want to stop
-         * decoding.
-         */
-        if (msg_it->state == target_state_1 || msg_it->state == target_state_2) {
-            goto end;
-        }
-
-        status = handle_state(msg_it);
-        if (G_UNLIKELY(status == CTF_MSG_ITER_STATUS_AGAIN)) {
-            BT_CLOGD_STR("Medium returned CTF_MSG_ITER_STATUS_AGAIN.");
-            goto end;
-        } else if (G_UNLIKELY(status != CTF_MSG_ITER_STATUS_OK)) {
-            BT_CLOGE_APPEND_CAUSE("Cannot handle state: msg-it-addr=%p, state=%s", msg_it,
-                                  state_string(msg_it->state));
-            goto end;
-        }
-
-        switch (msg_it->state) {
-        case STATE_INIT:
-        case STATE_SWITCH_PACKET:
-        case STATE_DSCOPE_TRACE_PACKET_HEADER_BEGIN:
-        case STATE_DSCOPE_TRACE_PACKET_HEADER_CONTINUE:
-        case STATE_AFTER_TRACE_PACKET_HEADER:
-        case STATE_DSCOPE_STREAM_PACKET_CONTEXT_BEGIN:
-        case STATE_DSCOPE_STREAM_PACKET_CONTEXT_CONTINUE:
-        case STATE_AFTER_STREAM_PACKET_CONTEXT:
-        case STATE_EMIT_MSG_STREAM_BEGINNING:
-        case STATE_CHECK_EMIT_MSG_DISCARDED_EVENTS:
-        case STATE_EMIT_MSG_DISCARDED_EVENTS:
-        case STATE_CHECK_EMIT_MSG_DISCARDED_PACKETS:
-        case STATE_EMIT_MSG_DISCARDED_PACKETS:
-        case STATE_EMIT_MSG_PACKET_BEGINNING:
-        case STATE_DSCOPE_EVENT_HEADER_BEGIN:
-        case STATE_DSCOPE_EVENT_HEADER_CONTINUE:
-        case STATE_AFTER_EVENT_HEADER:
-        case STATE_DSCOPE_EVENT_COMMON_CONTEXT_BEGIN:
-        case STATE_DSCOPE_EVENT_COMMON_CONTEXT_CONTINUE:
-        case STATE_DSCOPE_EVENT_SPEC_CONTEXT_BEGIN:
-        case STATE_DSCOPE_EVENT_SPEC_CONTEXT_CONTINUE:
-        case STATE_DSCOPE_EVENT_PAYLOAD_BEGIN:
-        case STATE_DSCOPE_EVENT_PAYLOAD_CONTINUE:
-        case STATE_EMIT_MSG_EVENT:
-        case STATE_EMIT_QUEUED_MSG_EVENT:
-        case STATE_SKIP_PACKET_PADDING:
-        case STATE_EMIT_MSG_PACKET_END_MULTI:
-        case STATE_EMIT_MSG_PACKET_END_SINGLE:
-        case STATE_EMIT_QUEUED_MSG_PACKET_END:
-        case STATE_EMIT_MSG_STREAM_END:
-            break;
-        case STATE_DONE:
-            /* fall-through */
-        default:
-            /* We should never get to the STATE_DONE state. */
-            BT_CLOGF("Unexpected state: msg-it-addr=%p, state=%s", msg_it,
-                     state_string(msg_it->state));
-            bt_common_abort();
-        }
-    } while (true);
-
-end:
-    return status;
-}
-
-static enum ctf_msg_iter_status read_packet_header_context_fields(struct ctf_msg_iter *msg_it)
-{
-    int ret;
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-
-    status = decode_until_state(msg_it, STATE_EMIT_MSG_PACKET_BEGINNING, (state) -1);
-    if (status != CTF_MSG_ITER_STATUS_OK) {
-        goto end;
-    }
-
-    ret = set_current_packet_content_sizes(msg_it);
-    if (ret) {
-        status = CTF_MSG_ITER_STATUS_ERROR;
-        goto end;
-    }
-
-end:
-    return status;
-}
-
-BT_HIDDEN
-enum ctf_msg_iter_status ctf_msg_iter_seek(struct ctf_msg_iter *msg_it, off_t offset)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-    enum ctf_msg_iter_medium_status medium_status;
-
-    BT_ASSERT(msg_it);
-    BT_ASSERT(offset >= 0);
-    BT_ASSERT(msg_it->medium.medops.seek);
-
-    medium_status = msg_it->medium.medops.seek(offset, msg_it->medium.data);
-    if (medium_status != CTF_MSG_ITER_MEDIUM_STATUS_OK) {
-        if (medium_status == CTF_MSG_ITER_MEDIUM_STATUS_EOF) {
-            status = CTF_MSG_ITER_STATUS_EOF;
-        } else {
-            status = CTF_MSG_ITER_STATUS_ERROR;
-            goto end;
-        }
-    }
-
-    ctf_msg_iter_reset(msg_it);
-    msg_it->cur_packet_offset = offset;
-
-end:
-    return status;
-}
-
-static enum ctf_msg_iter_status clock_snapshot_at_msg_iter_state(struct ctf_msg_iter *msg_it,
-                                                                 enum state target_state_1,
-                                                                 enum state target_state_2,
-                                                                 uint64_t *clock_snapshot)
-{
-    enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
-
-    BT_ASSERT_DBG(msg_it);
-    BT_ASSERT_DBG(clock_snapshot);
-    status = decode_until_state(msg_it, target_state_1, target_state_2);
-    if (status != CTF_MSG_ITER_STATUS_OK) {
-        goto end;
-    }
-
-    *clock_snapshot = msg_it->default_clock_snapshot;
-end:
-    return status;
-}
-
-BT_HIDDEN
-enum ctf_msg_iter_status
-ctf_msg_iter_curr_packet_first_event_clock_snapshot(struct ctf_msg_iter *msg_it,
-                                                    uint64_t *first_clock_snapshot)
-{
-    return clock_snapshot_at_msg_iter_state(msg_it, STATE_AFTER_EVENT_HEADER, (state) -1,
-                                            first_clock_snapshot);
-}
-
-BT_HIDDEN
-enum ctf_msg_iter_status
-ctf_msg_iter_curr_packet_last_event_clock_snapshot(struct ctf_msg_iter *msg_it,
-                                                   uint64_t *last_clock_snapshot)
-{
-    return clock_snapshot_at_msg_iter_state(msg_it, STATE_EMIT_MSG_PACKET_END_SINGLE,
-                                            STATE_EMIT_MSG_PACKET_END_MULTI, last_clock_snapshot);
-}
-
-BT_HIDDEN
-enum ctf_msg_iter_status
-ctf_msg_iter_get_packet_properties(struct ctf_msg_iter *msg_it,
-                                   struct ctf_msg_iter_packet_properties *props)
-{
-    enum ctf_msg_iter_status status;
-
-    BT_ASSERT_DBG(msg_it);
-    BT_ASSERT_DBG(props);
-    status = read_packet_header_context_fields(msg_it);
-    if (status != CTF_MSG_ITER_STATUS_OK) {
-        goto end;
-    }
-
-    props->exp_packet_total_size = msg_it->cur_exp_packet_total_size;
-    props->exp_packet_content_size = msg_it->cur_exp_packet_content_size;
-    props->stream_class_id = (uint64_t) msg_it->cur_stream_class_id;
-    props->data_stream_id = msg_it->cur_data_stream_id;
-    props->snapshots.discarded_events = msg_it->snapshots.discarded_events;
-    props->snapshots.packets = msg_it->snapshots.packets;
-    props->snapshots.beginning_clock = msg_it->snapshots.beginning_clock;
-    props->snapshots.end_clock = msg_it->snapshots.end_clock;
-
-end:
-    return status;
-}
-
-BT_HIDDEN
-void ctf_msg_iter_set_dry_run(struct ctf_msg_iter *msg_it, bool val)
-{
-    msg_it->dry_run = val;
-}
diff --git a/src/plugins/ctf/common/src/msg-iter/msg-iter.hpp b/src/plugins/ctf/common/src/msg-iter/msg-iter.hpp
deleted file mode 100644 (file)
index 90aee25..0000000
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (c) 2015-2016 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2015-2016 Philippe Proulx <pproulx@efficios.com>
- *
- * Babeltrace - CTF message iterator
- */
-
-#ifndef CTF_MSG_ITER_H
-#define CTF_MSG_ITER_H
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <babeltrace2/babeltrace.h>
-#include "common/macros.h"
-#include <memory>
-
-#include "../metadata/tsdl/ctf-meta.hpp"
-#include "cpp-common/log-cfg.hpp"
-
-/**
- * @file ctf-msg-iter.h
- *
- * CTF message iterator
- *
- * This is a common internal API used by CTF source plugins. It allows
- * one to get messages from a user-provided medium.
- */
-
-/**
- * Medium operations status codes.  These use the same values as
- * libbabeltrace2.
- */
-enum ctf_msg_iter_medium_status
-{
-    /**
-     * End of file.
-     *
-     * The medium function called by the message iterator
-     * function reached the end of the file.
-     */
-    CTF_MSG_ITER_MEDIUM_STATUS_EOF = 1,
-
-    /**
-     * There is no data available right now, try again later.
-     */
-    CTF_MSG_ITER_MEDIUM_STATUS_AGAIN = 11,
-
-    /** General error. */
-    CTF_MSG_ITER_MEDIUM_STATUS_ERROR = -1,
-
-    /** Memory error. */
-    CTF_MSG_ITER_MEDIUM_STATUS_MEMORY_ERROR = -12,
-
-    /** Everything okay. */
-    CTF_MSG_ITER_MEDIUM_STATUS_OK = 0,
-};
-
-/**
- * CTF message iterator API status code.
- */
-enum ctf_msg_iter_status
-{
-    /**
-     * End of file.
-     *
-     * The medium function called by the message iterator
-     * function reached the end of the file.
-     */
-    CTF_MSG_ITER_STATUS_EOF = CTF_MSG_ITER_MEDIUM_STATUS_EOF,
-
-    /**
-     * There is no data available right now, try again later.
-     *
-     * Some condition resulted in the
-     * ctf_msg_iter_medium_ops::request_bytes() user function not
-     * having access to any data now. You should retry calling the
-     * last called message iterator function once the situation
-     * is resolved.
-     */
-    CTF_MSG_ITER_STATUS_AGAIN = CTF_MSG_ITER_MEDIUM_STATUS_AGAIN,
-
-    /** General error. */
-    CTF_MSG_ITER_STATUS_ERROR = CTF_MSG_ITER_MEDIUM_STATUS_ERROR,
-
-    /** Memory error. */
-    CTF_MSG_ITER_STATUS_MEMORY_ERROR = CTF_MSG_ITER_MEDIUM_STATUS_MEMORY_ERROR,
-
-    /** Everything okay. */
-    CTF_MSG_ITER_STATUS_OK = CTF_MSG_ITER_MEDIUM_STATUS_OK,
-};
-
-/**
- * Medium operations.
- *
- * Those user functions are called by the message iterator
- * functions to request medium actions.
- */
-struct ctf_msg_iter_medium_ops
-{
-    /**
-     * Returns the next byte buffer to be used by the binary file
-     * reader to deserialize binary data.
-     *
-     * This function \em must be defined.
-     *
-     * The purpose of this function is to return a buffer of bytes
-     * to the message iterator, of a maximum of \p request_sz
-     * bytes. If this function cannot return a buffer of at least
-     * \p request_sz bytes, it may return a smaller buffer. In
-     * either cases, \p buffer_sz must be set to the returned buffer
-     * size (in bytes).
-     *
-     * The returned buffer's ownership remains the medium, in that
-     * it won't be freed by the message iterator functions. The
-     * returned buffer won't be modified by the message
-     * iterator functions either.
-     *
-     * When this function is called for the first time for a given
-     * file, the offset within the file is considered to be 0. The
-     * next times this function is called, the returned buffer's
-     * byte offset within the complete file must be the previous
-     * offset plus the last returned value of \p buffer_sz by this
-     * medium.
-     *
-     * This function must return one of the following statuses:
-     *
-     *   - <b>#CTF_MSG_ITER_MEDIUM_STATUS_OK</b>: Everything
-     *     is okay, i.e. \p buffer_sz is set to a positive value
-     *     reflecting the number of available bytes in the buffer
-     *     starting at the address written in \p buffer_addr.
-     *   - <b>#CTF_MSG_ITER_MEDIUM_STATUS_AGAIN</b>: No data is
-     *     available right now. In this case, the message
-     *     iterator function called by the user returns
-     *     #CTF_MSG_ITER_STATUS_AGAIN, and it is the user's
-     *     responsibility to make sure enough data becomes available
-     *     before calling the \em same message iterator
-     *     function again to continue the decoding process.
-     *   - <b>#CTF_MSG_ITER_MEDIUM_STATUS_EOF</b>: The end of
-     *     the file was reached, and no more data will ever be
-     *     available for this file. In this case, the message
-     *     iterator function called by the user returns
-     *     #CTF_MSG_ITER_STATUS_EOF. This must \em not be
-     *     returned when returning at least one byte of data to the
-     *     caller, i.e. this must be returned when there's
-     *     absolutely nothing left; should the request size be
-     *     larger than what's left in the file, this function must
-     *     return what's left, setting \p buffer_sz to the number of
-     *     remaining bytes, and return
-     *     #CTF_MSG_ITER_MEDIUM_STATUS_EOF on the \em following
-     *     call.
-     *   - <b>#CTF_MSG_ITER_MEDIUM_STATUS_ERROR</b>: A fatal
-     *     error occurred during this operation. In this case, the
-     *     message iterator function called by the user returns
-     *     #CTF_MSG_ITER_STATUS_ERROR.
-     *
-     * If #CTF_MSG_ITER_MEDIUM_STATUS_OK is not returned, the
-     * values of \p buffer_sz and \p buffer_addr are \em ignored by
-     * the caller.
-     *
-     * @param request_sz       Requested buffer size (bytes)
-     * @param buffer_addr      Returned buffer address
-     * @param buffer_sz        Returned buffer's size (bytes)
-     * @param data             User data
-     * @returns                Status code (see description above)
-     */
-    enum ctf_msg_iter_medium_status (*request_bytes)(size_t request_sz, uint8_t **buffer_addr,
-                                                     size_t *buffer_sz, void *data);
-
-    /**
-     * Repositions the underlying stream's position.
-     *
-     * This *optional* method repositions the underlying stream
-     * to a given absolute position in the medium.
-     *
-     * @param offset   Offset to use for the given directive
-     * @param data             User data
-     * @returns                One of #ctf_msg_iter_medium_status values
-     */
-    enum ctf_msg_iter_medium_status (*seek)(off_t offset, void *data);
-
-    /**
-     * Called when the message iterator wishes to inform the medium that it
-     * is about to start a new packet.
-     *
-     * After the iterator has called switch_packet, the following call to
-     * request_bytes must return the content at the start of the next
-     * packet.  */
-    enum ctf_msg_iter_medium_status (*switch_packet)(void *data);
-
-    /**
-     * Returns a stream instance (weak reference) for the given
-     * stream class.
-     *
-     * This is called after a packet header is read, and the
-     * corresponding stream class is found by the message
-     * iterator.
-     *
-     * @param stream_class     Stream class of the stream to get
-     * @param stream_id        Stream (instance) ID of the stream
-     *                 to get (-1ULL if not available)
-     * @param data             User data
-     * @returns                Stream instance (weak reference) or
-     *                 \c NULL on error
-     */
-    bt_stream *(*borrow_stream)(bt_stream_class *stream_class, int64_t stream_id, void *data);
-};
-
-/** CTF message iterator. */
-struct ctf_msg_iter;
-
-struct ctf_msg_iter_deleter
-{
-    void operator()(ctf_msg_iter *iter);
-};
-
-using ctf_msg_iter_up = std::unique_ptr<ctf_msg_iter, ctf_msg_iter_deleter>;
-
-/**
- * Creates a CTF message iterator.
- *
- * Upon successful completion, the reference count of \p trace is
- * incremented.
- *
- * @param trace                        Trace to read
- * @param max_request_sz       Maximum buffer size, in bytes, to
- *                             request to
- *                             ctf_msg_iter_medium_ops::request_bytes()
- *                             at a time
- * @param medops               Medium operations
- * @param medops_data          User data (passed to medium operations)
- * @returns                    New CTF message iterator on
- *                             success, or \c NULL on error
- */
-BT_HIDDEN
-ctf_msg_iter_up ctf_msg_iter_create(struct ctf_trace_class *tc, size_t max_request_sz,
-                                    struct ctf_msg_iter_medium_ops medops, void *medops_data,
-                                    bt_self_message_iterator *self_msg_iter,
-                                    const bt2_common::LogCfg& logCfg);
-
-/**
- * Destroys a CTF message iterator, freeing all internal resources.
- *
- * The registered trace's reference count is decremented.
- *
- * @param msg_iter             CTF message iterator
- */
-BT_HIDDEN
-void ctf_msg_iter_destroy(struct ctf_msg_iter *msg_iter);
-
-/**
- * Returns the next message from a CTF message iterator.
- *
- * Upon successful completion, #CTF_MSG_ITER_STATUS_OK is
- * returned, and the next message is written to \p msg.
- * In this case, the caller is responsible for calling
- * bt_message_put() on the returned message.
- *
- * If this function returns #CTF_MSG_ITER_STATUS_AGAIN, the caller
- * should make sure that data becomes available to its medium, and
- * call this function again, until another status is returned.
- *
- * @param msg_iter             CTF message iterator
- * @param message              Returned message if the function's
- *                             return value is #CTF_MSG_ITER_STATUS_OK
- * @returns                    One of #ctf_msg_iter_status values
- */
-BT_HIDDEN
-enum ctf_msg_iter_status ctf_msg_iter_get_next_message(struct ctf_msg_iter *msg_it,
-                                                       const bt_message **message);
-
-struct ctf_msg_iter_packet_properties
-{
-    int64_t exp_packet_total_size;
-    int64_t exp_packet_content_size;
-    uint64_t stream_class_id;
-    int64_t data_stream_id;
-
-    struct
-    {
-        uint64_t discarded_events;
-        uint64_t packets;
-        uint64_t beginning_clock;
-        uint64_t end_clock;
-    } snapshots;
-};
-
-BT_HIDDEN
-enum ctf_msg_iter_status
-ctf_msg_iter_get_packet_properties(struct ctf_msg_iter *msg_it,
-                                   struct ctf_msg_iter_packet_properties *props);
-
-BT_HIDDEN
-enum ctf_msg_iter_status
-ctf_msg_iter_curr_packet_first_event_clock_snapshot(struct ctf_msg_iter *msg_it,
-                                                    uint64_t *first_event_cs);
-
-BT_HIDDEN
-enum ctf_msg_iter_status
-ctf_msg_iter_curr_packet_last_event_clock_snapshot(struct ctf_msg_iter *msg_it,
-                                                   uint64_t *last_event_cs);
-
-BT_HIDDEN
-enum ctf_msg_iter_status ctf_msg_iter_seek(struct ctf_msg_iter *msg_it, off_t offset);
-
-/*
- * Resets the iterator so that the next requested medium bytes are
- * assumed to be the first bytes of a new stream. Depending on
- * ctf_msg_iter_set_emit_stream_beginning_message(), the first message
- * which this iterator emits after calling ctf_msg_iter_reset() is of
- * type `CTF_MESSAGE_TYPE_STREAM_BEGINNING`.
- */
-BT_HIDDEN
-void ctf_msg_iter_reset(struct ctf_msg_iter *msg_it);
-
-/*
- * Like ctf_msg_iter_reset(), but preserves stream-dependent state.
- */
-BT_HIDDEN
-void ctf_msg_iter_reset_for_next_stream_file(struct ctf_msg_iter *msg_it);
-
-BT_HIDDEN
-void ctf_msg_iter_set_dry_run(struct ctf_msg_iter *msg_it, bool val);
-
-static inline const char *ctf_msg_iter_medium_status_string(enum ctf_msg_iter_medium_status status)
-{
-    switch (status) {
-    case CTF_MSG_ITER_MEDIUM_STATUS_EOF:
-        return "EOF";
-    case CTF_MSG_ITER_MEDIUM_STATUS_AGAIN:
-        return "AGAIN";
-    case CTF_MSG_ITER_MEDIUM_STATUS_ERROR:
-        return "ERROR";
-    case CTF_MSG_ITER_MEDIUM_STATUS_MEMORY_ERROR:
-        return "MEMORY_ERROR";
-    case CTF_MSG_ITER_MEDIUM_STATUS_OK:
-        return "OK";
-    }
-
-    bt_common_abort();
-}
-
-static inline const char *ctf_msg_iter_status_string(enum ctf_msg_iter_status status)
-{
-    switch (status) {
-    case CTF_MSG_ITER_STATUS_EOF:
-        return "EOF";
-    case CTF_MSG_ITER_STATUS_AGAIN:
-        return "AGAIN";
-    case CTF_MSG_ITER_STATUS_ERROR:
-        return "ERROR";
-    case CTF_MSG_ITER_STATUS_MEMORY_ERROR:
-        return "MEMORY_ERROR";
-    case CTF_MSG_ITER_STATUS_OK:
-        return "OK";
-    }
-
-    bt_common_abort();
-}
-
-#endif /* CTF_MSG_ITER_H */
This page took 0.101525 seconds and 5 git commands to generate.