ctf/visitor-generate-ir: rename struct ctf to ctf_visitor_generate_ir
[babeltrace.git] / src / plugins / ctf / common / metadata / visitor-generate-ir.c
index 810f3ed1fa86ab022d495531aec059f361a81e4a..ca87aad61b4f12b15ae00ce67163686c643f82d7 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #define BT_COMP_LOG_SELF_COMP (ctx->log_cfg.self_comp)
+#define BT_COMP_LOG_SELF_COMP_CLASS (ctx->log_cfg.self_comp_class)
 #define BT_LOG_OUTPUT_LEVEL (ctx->log_cfg.log_level)
 #define BT_LOG_TAG "PLUGIN/CTF/META/IR-VISITOR"
 #include "logging/comp-logging.h"
@@ -48,7 +49,7 @@
        do {                                                            \
                ret = ctx_push_scope(ctx);                              \
                if (ret) {                                              \
-                       BT_COMP_LOGE_STR("Cannot push scope.");         \
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot push scope.");         \
                        goto error;                                     \
                }                                                       \
        } while (0)
@@ -140,14 +141,17 @@ enum loglevel {
 #define _BT_LIST_FIRST_ENTRY(_ptr, _class, _member)                    \
        bt_list_entry((_ptr)->next, _class, _member)
 
-#define _BT_COMP_LOGE_DUP_ATTR(_node, _attr, _entity)                  \
-       _BT_COMP_LOGE_LINENO((_node)->lineno,                           \
+#define _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(_node, _attr, _entity)                     \
+       _BT_COMP_LOGE_APPEND_CAUSE_LINENO((_node)->lineno,                              \
                "Duplicate attribute in %s: attr-name=\"%s\"",          \
                _entity, _attr)
 
 #define _BT_COMP_LOGE_NODE(_node, _msg, args...)                               \
        _BT_COMP_LOGE_LINENO((_node)->lineno, _msg, ## args)
 
+#define _BT_COMP_LOGE_APPEND_CAUSE_NODE(_node, _msg, args...)                          \
+       _BT_COMP_LOGE_APPEND_CAUSE_LINENO((_node)->lineno, _msg, ## args)
+
 #define _BT_COMP_LOGW_NODE(_node, _msg, args...)                               \
        _BT_COMP_LOGW_LINENO((_node)->lineno, _msg, ## args)
 
@@ -174,7 +178,7 @@ struct ctx_decl_scope {
 /*
  * Visitor context (private).
  */
-struct ctx {
+struct ctf_visitor_generate_ir {
        struct meta_log_config log_cfg;
 
        /* Trace IR trace class being filled (owned by this) */
@@ -208,14 +212,14 @@ struct ctf_visitor_generate_ir;
  * @returns            New declaration scope, or NULL on error
  */
 static
-struct ctx_decl_scope *ctx_decl_scope_create(struct ctx *ctx,
+struct ctx_decl_scope *ctx_decl_scope_create(struct ctf_visitor_generate_ir *ctx,
                struct ctx_decl_scope *par_scope)
 {
        struct ctx_decl_scope *scope;
 
        scope = g_new(struct ctx_decl_scope, 1);
        if (!scope) {
-               BT_COMP_LOGE_STR("Failed to allocate one declaration scope.");
+               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Failed to allocate one declaration scope.");
                goto end;
        }
 
@@ -256,7 +260,8 @@ end:
  * @returns            Associated GQuark, or 0 on error
  */
 static
-GQuark get_prefixed_named_quark(struct ctx *ctx, char prefix, const char *name)
+GQuark get_prefixed_named_quark(struct ctf_visitor_generate_ir *ctx, char prefix,
+               const char *name)
 {
        GQuark qname = 0;
 
@@ -265,7 +270,7 @@ GQuark get_prefixed_named_quark(struct ctx *ctx, char prefix, const char *name)
        /* Prefix character + original string + '\0' */
        char *prname = g_new(char, strlen(name) + 2);
        if (!prname) {
-               BT_COMP_LOGE_STR("Failed to allocate a string.");
+               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Failed to allocate a string.");
                goto end;
        }
 
@@ -290,7 +295,7 @@ end:
  */
 static
 struct ctf_field_class *ctx_decl_scope_lookup_prefix_alias(
-               struct ctx *ctx, struct ctx_decl_scope *scope, char prefix,
+               struct ctf_visitor_generate_ir *ctx, struct ctx_decl_scope *scope, char prefix,
                const char *name, int levels, bool copy)
 {
        GQuark qname = 0;
@@ -341,7 +346,7 @@ end:
  *                     or NULL if not found
  */
 static
-struct ctf_field_class *ctx_decl_scope_lookup_alias(struct ctx *ctx,
+struct ctf_field_class *ctx_decl_scope_lookup_alias(struct ctf_visitor_generate_ir *ctx,
                struct ctx_decl_scope *scope, const char *name, int levels,
                bool copy)
 {
@@ -360,7 +365,7 @@ struct ctf_field_class *ctx_decl_scope_lookup_alias(struct ctx *ctx,
  *                     or NULL if not found
  */
 static
-struct ctf_field_class_enum *ctx_decl_scope_lookup_enum(struct ctx *ctx,
+struct ctf_field_class_enum *ctx_decl_scope_lookup_enum(struct ctf_visitor_generate_ir *ctx,
                struct ctx_decl_scope *scope, const char *name, int levels,
                bool copy)
 {
@@ -379,7 +384,7 @@ struct ctf_field_class_enum *ctx_decl_scope_lookup_enum(struct ctx *ctx,
  *                     or NULL if not found
  */
 static
-struct ctf_field_class_struct *ctx_decl_scope_lookup_struct(struct ctx *ctx,
+struct ctf_field_class_struct *ctx_decl_scope_lookup_struct(struct ctf_visitor_generate_ir *ctx,
                struct ctx_decl_scope *scope, const char *name, int levels,
                bool copy)
 {
@@ -398,7 +403,7 @@ struct ctf_field_class_struct *ctx_decl_scope_lookup_struct(struct ctx *ctx,
  *                     or NULL if not found
  */
 static
-struct ctf_field_class_variant *ctx_decl_scope_lookup_variant(struct ctx *ctx,
+struct ctf_field_class_variant *ctx_decl_scope_lookup_variant(struct ctf_visitor_generate_ir *ctx,
                struct ctx_decl_scope *scope, const char *name, int levels,
                bool copy)
 {
@@ -416,7 +421,7 @@ struct ctf_field_class_variant *ctx_decl_scope_lookup_variant(struct ctx *ctx,
  * @returns            0 if registration went okay, negative value otherwise
  */
 static
-int ctx_decl_scope_register_prefix_alias(struct ctx *ctx,
+int ctx_decl_scope_register_prefix_alias(struct ctf_visitor_generate_ir *ctx,
                struct ctx_decl_scope *scope, char prefix, const char *name,
                struct ctf_field_class *decl)
 {
@@ -456,8 +461,8 @@ end:
  * @returns    0 if registration went okay, negative value otherwise
  */
 static
-int ctx_decl_scope_register_alias(struct ctx *ctx, struct ctx_decl_scope *scope,
-               const char *name, struct ctf_field_class *decl)
+int ctx_decl_scope_register_alias(struct ctf_visitor_generate_ir *ctx,
+               struct ctx_decl_scope *scope, const char *name, struct ctf_field_class *decl)
 {
        return ctx_decl_scope_register_prefix_alias(ctx, scope, _PREFIX_ALIAS,
                name, (void *) decl);
@@ -472,8 +477,9 @@ int ctx_decl_scope_register_alias(struct ctx *ctx, struct ctx_decl_scope *scope,
  * @returns    0 if registration went okay, negative value otherwise
  */
 static
-int ctx_decl_scope_register_enum(struct ctx *ctx, struct ctx_decl_scope *scope,
-               const char *name, struct ctf_field_class_enum *decl)
+int ctx_decl_scope_register_enum(struct ctf_visitor_generate_ir *ctx,
+               struct ctx_decl_scope *scope, const char *name,
+               struct ctf_field_class_enum *decl)
 {
        return ctx_decl_scope_register_prefix_alias(ctx, scope, _PREFIX_ENUM,
                name, (void *) decl);
@@ -488,7 +494,7 @@ int ctx_decl_scope_register_enum(struct ctx *ctx, struct ctx_decl_scope *scope,
  * @returns    0 if registration went okay, negative value otherwise
  */
 static
-int ctx_decl_scope_register_struct(struct ctx *ctx,
+int ctx_decl_scope_register_struct(struct ctf_visitor_generate_ir *ctx,
                struct ctx_decl_scope *scope, const char *name,
                struct ctf_field_class_struct *decl)
 {
@@ -505,7 +511,7 @@ int ctx_decl_scope_register_struct(struct ctx *ctx,
  * @returns    0 if registration went okay, negative value otherwise
  */
 static
-int ctx_decl_scope_register_variant(struct ctx *ctx,
+int ctx_decl_scope_register_variant(struct ctf_visitor_generate_ir *ctx,
                struct ctx_decl_scope *scope, const char *name,
                struct ctf_field_class_variant *decl)
 {
@@ -519,7 +525,7 @@ int ctx_decl_scope_register_variant(struct ctx *ctx,
  * @param ctx  Visitor context to destroy
  */
 static
-void ctx_destroy(struct ctx *ctx)
+void ctx_destroy(struct ctf_visitor_generate_ir *ctx)
 {
        struct ctx_decl_scope *scope;
 
@@ -558,13 +564,14 @@ end:
  * @returns    New visitor context, or NULL on error
  */
 static
-struct ctx *ctx_create(const struct ctf_metadata_decoder_config *decoder_config)
+struct ctf_visitor_generate_ir *ctx_create(
+               const struct ctf_metadata_decoder_config *decoder_config)
 {
-       struct ctx *ctx = NULL;
+       struct ctf_visitor_generate_ir *ctx = NULL;
 
        BT_ASSERT(decoder_config);
 
-       ctx = g_new0(struct ctx, 1);
+       ctx = g_new0(struct ctf_visitor_generate_ir, 1);
        if (!ctx) {
                BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, decoder_config->log_level,
                        decoder_config->self_comp,
@@ -574,26 +581,27 @@ struct ctx *ctx_create(const struct ctf_metadata_decoder_config *decoder_config)
 
        ctx->log_cfg.log_level = decoder_config->log_level;
        ctx->log_cfg.self_comp = decoder_config->self_comp;
+       ctx->log_cfg.self_comp_class = decoder_config->self_comp_class;
 
        if (decoder_config->self_comp) {
                ctx->trace_class = bt_trace_class_create(
                        decoder_config->self_comp);
                if (!ctx->trace_class) {
-                       BT_COMP_LOGE_STR("Cannot create empty trace class.");
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot create empty trace class.");
                        goto error;
                }
        }
 
        ctx->ctf_tc = ctf_trace_class_create();
        if (!ctx->ctf_tc) {
-               BT_COMP_LOGE_STR("Cannot create CTF trace class.");
+               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot create CTF trace class.");
                goto error;
        }
 
        /* Root declaration scope */
        ctx->current_scope = ctx_decl_scope_create(ctx, NULL);
        if (!ctx->current_scope) {
-               BT_COMP_LOGE_STR("Cannot create declaration scope.");
+               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot create declaration scope.");
                goto error;
        }
 
@@ -616,7 +624,7 @@ end:
  * @returns    0 on success, or a negative value on error
  */
 static
-int ctx_push_scope(struct ctx *ctx)
+int ctx_push_scope(struct ctf_visitor_generate_ir *ctx)
 {
        int ret = 0;
        struct ctx_decl_scope *new_scope;
@@ -624,7 +632,7 @@ int ctx_push_scope(struct ctx *ctx)
        BT_ASSERT(ctx);
        new_scope = ctx_decl_scope_create(ctx, ctx->current_scope);
        if (!new_scope) {
-               BT_COMP_LOGE_STR("Cannot create declaration scope.");
+               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot create declaration scope.");
                ret = -ENOMEM;
                goto end;
        }
@@ -636,7 +644,7 @@ end:
 }
 
 static
-void ctx_pop_scope(struct ctx *ctx)
+void ctx_pop_scope(struct ctf_visitor_generate_ir *ctx)
 {
        struct ctx_decl_scope *parent_scope = NULL;
 
@@ -655,8 +663,8 @@ end:
 }
 
 static
-int visit_field_class_specifier_list(struct ctx *ctx, struct ctf_node *ts_list,
-               struct ctf_field_class **decl);
+int visit_field_class_specifier_list(struct ctf_visitor_generate_ir *ctx,
+               struct ctf_node *ts_list, struct ctf_field_class **decl);
 
 static
 int is_unary_string(struct bt_list_head *head)
@@ -756,7 +764,7 @@ int is_unary_unsigned(struct bt_list_head *head)
 }
 
 static
-int get_unary_unsigned(struct ctx *ctx, struct bt_list_head *head,
+int get_unary_unsigned(struct ctf_visitor_generate_ir *ctx, struct bt_list_head *head,
                uint64_t *value)
 {
        int i = 0;
@@ -777,7 +785,7 @@ int get_unary_unsigned(struct ctx *ctx, struct bt_list_head *head,
                        uexpr_type != UNARY_UNSIGNED_CONSTANT ||
                        uexpr_link != UNARY_LINK_UNKNOWN || i != 0;
                if (cond) {
-                       _BT_COMP_LOGE_NODE(node, "Invalid constant unsigned integer.");
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Invalid constant unsigned integer.");
                        ret = -EINVAL;
                        goto end;
                }
@@ -849,7 +857,7 @@ end:
 }
 
 static
-int get_unary_uuid(struct ctx *ctx, struct bt_list_head *head,
+int get_unary_uuid(struct ctf_visitor_generate_ir *ctx, struct bt_list_head *head,
                bt_uuid_t uuid)
 {
        return ctf_ast_get_unary_uuid(head, uuid, ctx->log_cfg.log_level,
@@ -857,12 +865,12 @@ int get_unary_uuid(struct ctx *ctx, struct bt_list_head *head,
 }
 
 static
-int get_boolean(struct ctx *ctx, struct ctf_node *unary_expr)
+int get_boolean(struct ctf_visitor_generate_ir *ctx, struct ctf_node *unary_expr)
 {
        int ret = 0;
 
        if (unary_expr->type != NODE_UNARY_EXPRESSION) {
-               _BT_COMP_LOGE_NODE(unary_expr,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(unary_expr,
                        "Expecting unary expression: node-type=%d",
                        unary_expr->type);
                ret = -EINVAL;
@@ -885,7 +893,7 @@ int get_boolean(struct ctx *ctx, struct ctf_node *unary_expr)
                } else if (strcmp(str, "false") == 0 || strcmp(str, "FALSE") == 0) {
                        ret = FALSE;
                } else {
-                       _BT_COMP_LOGE_NODE(unary_expr,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(unary_expr,
                                "Unexpected boolean value: value=\"%s\"", str);
                        ret = -EINVAL;
                        goto end;
@@ -893,7 +901,7 @@ int get_boolean(struct ctx *ctx, struct ctf_node *unary_expr)
                break;
        }
        default:
-               _BT_COMP_LOGE_NODE(unary_expr,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(unary_expr,
                        "Unexpected unary expression type: node-type=%d",
                        unary_expr->u.unary_expression.type);
                ret = -EINVAL;
@@ -905,14 +913,14 @@ end:
 }
 
 static
-enum ctf_byte_order byte_order_from_unary_expr(struct ctx *ctx,
+enum ctf_byte_order byte_order_from_unary_expr(struct ctf_visitor_generate_ir *ctx,
                struct ctf_node *unary_expr)
 {
        const char *str;
        enum ctf_byte_order bo = CTF_BYTE_ORDER_UNKNOWN;
 
        if (unary_expr->u.unary_expression.type != UNARY_STRING) {
-               _BT_COMP_LOGE_NODE(unary_expr,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(unary_expr,
                        "\"byte_order\" attribute: expecting `be`, `le`, `network`, or `native`.");
                goto end;
        }
@@ -926,7 +934,7 @@ enum ctf_byte_order byte_order_from_unary_expr(struct ctx *ctx,
        } else if (strcmp(str, "native") == 0) {
                bo = CTF_BYTE_ORDER_DEFAULT;
        } else {
-               _BT_COMP_LOGE_NODE(unary_expr,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(unary_expr,
                        "Unexpected \"byte_order\" attribute value: "
                        "expecting `be`, `le`, `network`, or `native`: value=\"%s\"",
                        str);
@@ -938,7 +946,7 @@ end:
 }
 
 static
-enum ctf_byte_order get_real_byte_order(struct ctx *ctx,
+enum ctf_byte_order get_real_byte_order(struct ctf_visitor_generate_ir *ctx,
                struct ctf_node *uexpr)
 {
        enum ctf_byte_order bo = byte_order_from_unary_expr(ctx, uexpr);
@@ -957,13 +965,13 @@ int is_align_valid(uint64_t align)
 }
 
 static
-int get_class_specifier_name(struct ctx *ctx, struct ctf_node *cls_specifier,
-               GString *str)
+int get_class_specifier_name(struct ctf_visitor_generate_ir *ctx,
+               struct ctf_node *cls_specifier, GString *str)
 {
        int ret = 0;
 
        if (cls_specifier->type != NODE_TYPE_SPECIFIER) {
-               _BT_COMP_LOGE_NODE(cls_specifier,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(cls_specifier,
                        "Unexpected node type: node-type=%d",
                        cls_specifier->type);
                ret = -EINVAL;
@@ -1021,7 +1029,7 @@ int get_class_specifier_name(struct ctx *ctx, struct ctf_node *cls_specifier,
                struct ctf_node *node = cls_specifier->u.field_class_specifier.node;
 
                if (!node->u._struct.name) {
-                       _BT_COMP_LOGE_NODE(node, "Unexpected empty structure field class name.");
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Unexpected empty structure field class name.");
                        ret = -EINVAL;
                        goto end;
                }
@@ -1035,7 +1043,7 @@ int get_class_specifier_name(struct ctx *ctx, struct ctf_node *cls_specifier,
                struct ctf_node *node = cls_specifier->u.field_class_specifier.node;
 
                if (!node->u.variant.name) {
-                       _BT_COMP_LOGE_NODE(node, "Unexpected empty variant field class name.");
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Unexpected empty variant field class name.");
                        ret = -EINVAL;
                        goto end;
                }
@@ -1049,7 +1057,7 @@ int get_class_specifier_name(struct ctx *ctx, struct ctf_node *cls_specifier,
                struct ctf_node *node = cls_specifier->u.field_class_specifier.node;
 
                if (!node->u._enum.enum_id) {
-                       _BT_COMP_LOGE_NODE(node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                "Unexpected empty enumeration field class (`enum`) name.");
                        ret = -EINVAL;
                        goto end;
@@ -1063,7 +1071,7 @@ int get_class_specifier_name(struct ctx *ctx, struct ctf_node *cls_specifier,
        case TYPESPEC_INTEGER:
        case TYPESPEC_STRING:
        default:
-               _BT_COMP_LOGE_NODE(cls_specifier->u.field_class_specifier.node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(cls_specifier->u.field_class_specifier.node,
                        "Unexpected field class specifier type: %d",
                        cls_specifier->u.field_class_specifier.type);
                ret = -EINVAL;
@@ -1075,7 +1083,7 @@ end:
 }
 
 static
-int get_class_specifier_list_name(struct ctx *ctx,
+int get_class_specifier_list_name(struct ctf_visitor_generate_ir *ctx,
                struct ctf_node *cls_specifier_list, GString *str)
 {
        int ret = 0;
@@ -1101,7 +1109,7 @@ end:
 }
 
 static
-GQuark create_class_alias_identifier(struct ctx *ctx,
+GQuark create_class_alias_identifier(struct ctf_visitor_generate_ir *ctx,
                struct ctf_node *cls_specifier_list,
                struct ctf_node *node_field_class_declarator)
 {
@@ -1137,7 +1145,7 @@ end:
 }
 
 static
-int visit_field_class_declarator(struct ctx *ctx,
+int visit_field_class_declarator(struct ctf_visitor_generate_ir *ctx,
                struct ctf_node *cls_specifier_list,
                GQuark *field_name, struct ctf_node *node_field_class_declarator,
                struct ctf_field_class **field_decl,
@@ -1155,7 +1163,7 @@ int visit_field_class_declarator(struct ctx *ctx,
        if (node_field_class_declarator) {
                if (node_field_class_declarator->u.field_class_declarator.type ==
                                TYPEDEC_UNKNOWN) {
-                       _BT_COMP_LOGE_NODE(node_field_class_declarator,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node_field_class_declarator,
                                "Unexpected field class declarator type: type=%d",
                                node_field_class_declarator->u.field_class_declarator.type);
                        ret = -EINVAL;
@@ -1165,7 +1173,7 @@ int visit_field_class_declarator(struct ctx *ctx,
                /* TODO: GCC bitfields not supported yet */
                if (node_field_class_declarator->u.field_class_declarator.bitfield_len !=
                                NULL) {
-                       _BT_COMP_LOGE_NODE(node_field_class_declarator,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node_field_class_declarator,
                                "GCC bitfields are not supported as of this version.");
                        ret = -EPERM;
                        goto error;
@@ -1192,7 +1200,7 @@ int visit_field_class_declarator(struct ctx *ctx,
                                        ctx->current_scope,
                                        g_quark_to_string(qalias), -1, true);
                        if (!nested_decl) {
-                               _BT_COMP_LOGE_NODE(node_field_class_declarator,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node_field_class_declarator,
                                        "Cannot find class alias: name=\"%s\"",
                                        g_quark_to_string(qalias));
                                ret = -EINVAL;
@@ -1248,7 +1256,7 @@ int visit_field_class_declarator(struct ctx *ctx,
 
                /* Create array/sequence, pass nested_decl as child */
                if (bt_list_empty(length)) {
-                       _BT_COMP_LOGE_NODE(node_field_class_declarator,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node_field_class_declarator,
                                "Expecting length field reference or value.");
                        ret = -EINVAL;
                        goto error;
@@ -1256,7 +1264,7 @@ int visit_field_class_declarator(struct ctx *ctx,
 
                first = _BT_LIST_FIRST_ENTRY(length, struct ctf_node, siblings);
                if (first->type != NODE_UNARY_EXPRESSION) {
-                       _BT_COMP_LOGE_NODE(first,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(first,
                                "Unexpected node type: node-type=%d",
                                first->type);
                        ret = -EINVAL;
@@ -1284,7 +1292,7 @@ int visit_field_class_declarator(struct ctx *ctx,
                        char *length_name = ctf_ast_concatenate_unary_strings(length);
 
                        if (!length_name) {
-                               _BT_COMP_LOGE_NODE(node_field_class_declarator,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node_field_class_declarator,
                                        "Cannot concatenate unary strings.");
                                ret = -EINVAL;
                                goto error;
@@ -1299,7 +1307,7 @@ int visit_field_class_declarator(struct ctx *ctx,
                                struct ctf_field_class_array *array_decl;
 
                                if (!env_entry) {
-                                       _BT_COMP_LOGE_NODE(node_field_class_declarator,
+                                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node_field_class_declarator,
                                                "Cannot find environment entry: "
                                                "name=\"%s\"", env_entry_name);
                                        ret = -EINVAL;
@@ -1307,7 +1315,7 @@ int visit_field_class_declarator(struct ctx *ctx,
                                }
 
                                if (env_entry->type != CTF_TRACE_CLASS_ENV_ENTRY_TYPE_INT) {
-                                       _BT_COMP_LOGE_NODE(node_field_class_declarator,
+                                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node_field_class_declarator,
                                                "Wrong environment entry type "
                                                "(expecting integer): "
                                                "name=\"%s\"", env_entry_name);
@@ -1316,7 +1324,7 @@ int visit_field_class_declarator(struct ctx *ctx,
                                }
 
                                if (env_entry->value.i < 0) {
-                                       _BT_COMP_LOGE_NODE(node_field_class_declarator,
+                                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node_field_class_declarator,
                                                "Invalid, negative array length: "
                                                "env-entry-name=\"%s\", "
                                                "value=%" PRId64,
@@ -1397,7 +1405,7 @@ end:
 }
 
 static
-int visit_struct_decl_field(struct ctx *ctx,
+int visit_struct_decl_field(struct ctf_visitor_generate_ir *ctx,
                struct ctf_field_class_struct *struct_decl,
                struct ctf_node *cls_specifier_list,
                struct bt_list_head *field_class_declarators)
@@ -1415,7 +1423,7 @@ int visit_struct_decl_field(struct ctx *ctx,
                        &qfield_name, iter, &field_decl, NULL);
                if (ret) {
                        BT_ASSERT(!field_decl);
-                       _BT_COMP_LOGE_NODE(cls_specifier_list,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(cls_specifier_list,
                                "Cannot visit field class declarator: ret=%d", ret);
                        goto error;
                }
@@ -1426,7 +1434,7 @@ int visit_struct_decl_field(struct ctx *ctx,
                /* Check if field with same name already exists */
                if (ctf_field_class_struct_borrow_member_by_name(
                                struct_decl, field_name)) {
-                       _BT_COMP_LOGE_NODE(cls_specifier_list,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(cls_specifier_list,
                                "Duplicate field in structure field class: "
                                "field-name=\"%s\"", field_name);
                        ret = -EINVAL;
@@ -1448,7 +1456,7 @@ error:
 }
 
 static
-int visit_variant_decl_field(struct ctx *ctx,
+int visit_variant_decl_field(struct ctf_visitor_generate_ir *ctx,
                struct ctf_field_class_variant *variant_decl,
                struct ctf_node *cls_specifier_list,
                struct bt_list_head *field_class_declarators)
@@ -1466,7 +1474,7 @@ int visit_variant_decl_field(struct ctx *ctx,
                        &qfield_name, iter, &field_decl, NULL);
                if (ret) {
                        BT_ASSERT(!field_decl);
-                       _BT_COMP_LOGE_NODE(cls_specifier_list,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(cls_specifier_list,
                                "Cannot visit field class declarator: ret=%d", ret);
                        goto error;
                }
@@ -1477,7 +1485,7 @@ int visit_variant_decl_field(struct ctx *ctx,
                /* Check if field with same name already exists */
                if (ctf_field_class_variant_borrow_option_by_name(
                                variant_decl, field_name)) {
-                       _BT_COMP_LOGE_NODE(cls_specifier_list,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(cls_specifier_list,
                                "Duplicate field in variant field class: "
                                "field-name=\"%s\"", field_name);
                        ret = -EINVAL;
@@ -1499,7 +1507,8 @@ error:
 }
 
 static
-int visit_field_class_def(struct ctx *ctx, struct ctf_node *cls_specifier_list,
+int visit_field_class_def(struct ctf_visitor_generate_ir *ctx,
+               struct ctf_node *cls_specifier_list,
                struct bt_list_head *field_class_declarators)
 {
        int ret = 0;
@@ -1511,7 +1520,7 @@ int visit_field_class_def(struct ctx *ctx, struct ctf_node *cls_specifier_list,
                ret = visit_field_class_declarator(ctx, cls_specifier_list,
                        &qidentifier, iter, &class_decl, NULL);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(iter,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
                                "Cannot visit field class declarator: ret=%d", ret);
                        ret = -EINVAL;
                        goto end;
@@ -1523,7 +1532,7 @@ int visit_field_class_def(struct ctx *ctx, struct ctf_node *cls_specifier_list,
                                (void *) class_decl;
 
                        if (var_fc->tag_path.path->len == 0) {
-                               _BT_COMP_LOGE_NODE(iter,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
                                        "Type definition of untagged variant field class is not allowed.");
                                ret = -EPERM;
                                goto end;
@@ -1533,7 +1542,7 @@ int visit_field_class_def(struct ctx *ctx, struct ctf_node *cls_specifier_list,
                ret = ctx_decl_scope_register_alias(ctx, ctx->current_scope,
                        g_quark_to_string(qidentifier), class_decl);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(iter,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
                                "Cannot register field class alias: name=\"%s\"",
                                g_quark_to_string(qidentifier));
                        goto end;
@@ -1547,7 +1556,7 @@ end:
 }
 
 static
-int visit_field_class_alias(struct ctx *ctx, struct ctf_node *target,
+int visit_field_class_alias(struct ctf_visitor_generate_ir *ctx, struct ctf_node *target,
                struct ctf_node *alias)
 {
        int ret = 0;
@@ -1570,7 +1579,7 @@ int visit_field_class_alias(struct ctx *ctx, struct ctf_node *target,
                &qdummy_field_name, node, &class_decl, NULL);
        if (ret) {
                BT_ASSERT(!class_decl);
-               _BT_COMP_LOGE_NODE(node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                        "Cannot visit field class declarator: ret=%d", ret);
                goto end;
        }
@@ -1580,7 +1589,7 @@ int visit_field_class_alias(struct ctx *ctx, struct ctf_node *target,
                struct ctf_field_class_variant *var_fc = (void *) class_decl;
 
                if (var_fc->tag_path.path->len == 0) {
-                       _BT_COMP_LOGE_NODE(target,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(target,
                                "Type definition of untagged variant field class is not allowed.");
                        ret = -EPERM;
                        goto end;
@@ -1592,7 +1601,7 @@ int visit_field_class_alias(struct ctx *ctx, struct ctf_node *target,
         * abstract or not (if it has an identifier). Check it here.
         */
        if (qdummy_field_name != 0) {
-               _BT_COMP_LOGE_NODE(target,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(target,
                        "Expecting empty identifier: id=\"%s\"",
                        g_quark_to_string(qdummy_field_name));
                ret = -EINVAL;
@@ -1607,7 +1616,7 @@ int visit_field_class_alias(struct ctx *ctx, struct ctf_node *target,
        ret = ctx_decl_scope_register_alias(ctx, ctx->current_scope,
                g_quark_to_string(qalias), class_decl);
        if (ret) {
-               _BT_COMP_LOGE_NODE(node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                        "Cannot register class alias: name=\"%s\"",
                        g_quark_to_string(qalias));
                goto end;
@@ -1620,7 +1629,7 @@ end:
 }
 
 static
-int visit_struct_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
+int visit_struct_decl_entry(struct ctf_visitor_generate_ir *ctx, struct ctf_node *entry_node,
                struct ctf_field_class_struct *struct_decl)
 {
        int ret = 0;
@@ -1631,7 +1640,7 @@ int visit_struct_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                        entry_node->u.field_class_def.field_class_specifier_list,
                        &entry_node->u.field_class_def.field_class_declarators);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(entry_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                "Cannot add field class found in structure field class: ret=%d",
                                ret);
                        goto end;
@@ -1641,7 +1650,7 @@ int visit_struct_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                ret = visit_field_class_alias(ctx, entry_node->u.field_class_alias.target,
                        entry_node->u.field_class_alias.alias);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(entry_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                "Cannot add field class alias found in structure field class: ret=%d",
                                ret);
                        goto end;
@@ -1659,7 +1668,7 @@ int visit_struct_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                }
                break;
        default:
-               _BT_COMP_LOGE_NODE(entry_node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                        "Unexpected node type: node-type=%d", entry_node->type);
                ret = -EINVAL;
                goto end;
@@ -1670,7 +1679,7 @@ end:
 }
 
 static
-int visit_variant_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
+int visit_variant_decl_entry(struct ctf_visitor_generate_ir *ctx, struct ctf_node *entry_node,
                struct ctf_field_class_variant *variant_decl)
 {
        int ret = 0;
@@ -1681,7 +1690,7 @@ int visit_variant_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                        entry_node->u.field_class_def.field_class_specifier_list,
                        &entry_node->u.field_class_def.field_class_declarators);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(entry_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                "Cannot add field class found in variant field class: ret=%d",
                                ret);
                        goto end;
@@ -1691,7 +1700,7 @@ int visit_variant_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                ret = visit_field_class_alias(ctx, entry_node->u.field_class_alias.target,
                        entry_node->u.field_class_alias.alias);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(entry_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                "Cannot add field class alias found in variant field class: ret=%d",
                                ret);
                        goto end;
@@ -1709,7 +1718,7 @@ int visit_variant_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                }
                break;
        default:
-               _BT_COMP_LOGE_NODE(entry_node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                        "Unexpected node type: node-type=%d",
                        entry_node->type);
                ret = -EINVAL;
@@ -1721,7 +1730,7 @@ end:
 }
 
 static
-int visit_struct_decl(struct ctx *ctx, const char *name,
+int visit_struct_decl(struct ctf_visitor_generate_ir *ctx, const char *name,
                struct bt_list_head *decl_list, int has_body,
                struct bt_list_head *min_align,
                struct ctf_field_class_struct **struct_decl)
@@ -1734,7 +1743,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name,
        /* For named struct (without body), lookup in declaration scope */
        if (!has_body) {
                if (!name) {
-                       BT_COMP_LOGE_STR("Bodyless structure field class: missing name.");
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Bodyless structure field class: missing name.");
                        ret = -EPERM;
                        goto error;
                }
@@ -1742,7 +1751,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name,
                *struct_decl = ctx_decl_scope_lookup_struct(ctx, ctx->current_scope,
                        name, -1, true);
                if (!*struct_decl) {
-                       BT_COMP_LOGE("Cannot find structure field class: name=\"struct %s\"",
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot find structure field class: name=\"struct %s\"",
                                name);
                        ret = -EINVAL;
                        goto error;
@@ -1754,7 +1763,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name,
                if (name) {
                        if (ctx_decl_scope_lookup_struct(ctx,
                                        ctx->current_scope, name, 1, false)) {
-                               BT_COMP_LOGE("Structure field class already declared in local scope: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Structure field class already declared in local scope: "
                                        "name=\"struct %s\"", name);
                                ret = -EINVAL;
                                goto error;
@@ -1765,7 +1774,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name,
                        ret = get_unary_unsigned(ctx, min_align,
                                &min_align_value);
                        if (ret) {
-                               BT_COMP_LOGE("Unexpected unary expression for structure field class's `align` attribute: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Unexpected unary expression for structure field class's `align` attribute: "
                                        "ret=%d", ret);
                                goto error;
                        }
@@ -1784,7 +1793,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name,
                        ret = visit_struct_decl_entry(ctx, entry_node,
                                *struct_decl);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(entry_node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                        "Cannot visit structure field class entry: "
                                        "ret=%d", ret);
                                ctx_pop_scope(ctx);
@@ -1798,7 +1807,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name,
                        ret = ctx_decl_scope_register_struct(ctx,
                                ctx->current_scope, name, *struct_decl);
                        if (ret) {
-                               BT_COMP_LOGE("Cannot register structure field class in declaration scope: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot register structure field class in declaration scope: "
                                        "name=\"struct %s\", ret=%d", name, ret);
                                goto error;
                        }
@@ -1814,7 +1823,7 @@ error:
 }
 
 static
-int visit_variant_decl(struct ctx *ctx, const char *name,
+int visit_variant_decl(struct ctf_visitor_generate_ir *ctx, const char *name,
        const char *tag, struct bt_list_head *decl_list,
        int has_body, struct ctf_field_class_variant **variant_decl)
 {
@@ -1827,7 +1836,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name,
        /* For named variant (without body), lookup in declaration scope */
        if (!has_body) {
                if (!name) {
-                       BT_COMP_LOGE_STR("Bodyless variant field class: missing name.");
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Bodyless variant field class: missing name.");
                        ret = -EPERM;
                        goto error;
                }
@@ -1836,7 +1845,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name,
                        ctx_decl_scope_lookup_variant(ctx, ctx->current_scope,
                                name, -1, true);
                if (!untagged_variant_decl) {
-                       BT_COMP_LOGE("Cannot find variant field class: name=\"variant %s\"",
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot find variant field class: name=\"variant %s\"",
                                name);
                        ret = -EINVAL;
                        goto error;
@@ -1847,7 +1856,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name,
                if (name) {
                        if (ctx_decl_scope_lookup_variant(ctx,
                                        ctx->current_scope, name, 1, false)) {
-                               BT_COMP_LOGE("Variant field class already declared in local scope: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Variant field class already declared in local scope: "
                                        "name=\"variant %s\"", name);
                                ret = -EINVAL;
                                goto error;
@@ -1862,7 +1871,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name,
                        ret = visit_variant_decl_entry(ctx, entry_node,
                                untagged_variant_decl);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(entry_node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                        "Cannot visit variant field class entry: "
                                        "ret=%d", ret);
                                ctx_pop_scope(ctx);
@@ -1877,7 +1886,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name,
                                ctx->current_scope, name,
                                untagged_variant_decl);
                        if (ret) {
-                               BT_COMP_LOGE("Cannot register variant field class in declaration scope: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot register variant field class in declaration scope: "
                                        "name=\"variant %s\", ret=%d", name, ret);
                                goto error;
                        }
@@ -1922,7 +1931,7 @@ struct uori {
 };
 
 static
-int visit_enum_decl_entry(struct ctx *ctx, struct ctf_node *enumerator,
+int visit_enum_decl_entry(struct ctf_visitor_generate_ir *ctx, struct ctf_node *enumerator,
                struct ctf_field_class_enum *enum_decl, struct uori *last)
 {
        int ret = 0;
@@ -1943,7 +1952,7 @@ int visit_enum_decl_entry(struct ctx *ctx, struct ctf_node *enumerator,
                struct uori *target;
 
                if (iter->type != NODE_UNARY_EXPRESSION) {
-                       _BT_COMP_LOGE_NODE(iter,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
                                "Wrong expression for enumeration field class label: "
                                "node-type=%d, label=\"%s\"", iter->type,
                                label);
@@ -1969,7 +1978,7 @@ int visit_enum_decl_entry(struct ctx *ctx, struct ctf_node *enumerator,
                                iter->u.unary_expression.u.unsigned_constant;
                        break;
                default:
-                       _BT_COMP_LOGE_NODE(iter,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
                                "Invalid enumeration field class entry: "
                                "expecting constant signed or unsigned integer: "
                                "node-type=%d, label=\"%s\"",
@@ -1979,7 +1988,7 @@ int visit_enum_decl_entry(struct ctx *ctx, struct ctf_node *enumerator,
                }
 
                if (nr_vals > 1) {
-                       _BT_COMP_LOGE_NODE(iter,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
                                "Invalid enumeration field class entry: label=\"%s\"",
                                label);
                        ret = -EINVAL;
@@ -2012,7 +2021,7 @@ error:
 }
 
 static
-int visit_enum_decl(struct ctx *ctx, const char *name,
+int visit_enum_decl(struct ctf_visitor_generate_ir *ctx, const char *name,
                struct ctf_node *container_cls,
                struct bt_list_head *enumerator_list,
                int has_body, struct ctf_field_class_enum **enum_decl)
@@ -2027,7 +2036,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name,
        /* For named enum (without body), lookup in declaration scope */
        if (!has_body) {
                if (!name) {
-                       BT_COMP_LOGE_STR("Bodyless enumeration field class: missing name.");
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Bodyless enumeration field class: missing name.");
                        ret = -EPERM;
                        goto error;
                }
@@ -2035,7 +2044,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name,
                *enum_decl = ctx_decl_scope_lookup_enum(ctx, ctx->current_scope,
                        name, -1, true);
                if (!*enum_decl) {
-                       BT_COMP_LOGE("Cannot find enumeration field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot find enumeration field class: "
                                "name=\"enum %s\"", name);
                        ret = -EINVAL;
                        goto error;
@@ -2050,7 +2059,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name,
                if (name) {
                        if (ctx_decl_scope_lookup_enum(ctx, ctx->current_scope,
                                        name, 1, false)) {
-                               BT_COMP_LOGE("Enumeration field class already declared in local scope: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Enumeration field class already declared in local scope: "
                                        "name=\"enum %s\"", name);
                                ret = -EINVAL;
                                goto error;
@@ -2061,7 +2070,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name,
                        integer_decl = (void *) ctx_decl_scope_lookup_alias(ctx,
                                ctx->current_scope, "int", -1, true);
                        if (!integer_decl) {
-                               BT_COMP_LOGE_STR("Cannot find implicit `int` field class alias for enumeration field class.");
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot find implicit `int` field class alias for enumeration field class.");
                                ret = -EINVAL;
                                goto error;
                        }
@@ -2079,7 +2088,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name,
                BT_ASSERT(integer_decl);
 
                if (integer_decl->base.base.type != CTF_FIELD_CLASS_TYPE_INT) {
-                       BT_COMP_LOGE("Container field class for enumeration field class is not an integer field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Container field class for enumeration field class is not an integer field class: "
                                "fc-type=%d", integer_decl->base.base.type);
                        ret = -EINVAL;
                        goto error;
@@ -2097,7 +2106,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name,
                        ret = visit_enum_decl_entry(ctx, iter, *enum_decl,
                                &last_value);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(iter,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
                                        "Cannot visit enumeration field class entry: "
                                        "ret=%d", ret);
                                goto error;
@@ -2108,7 +2117,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name,
                        ret = ctx_decl_scope_register_enum(ctx,
                                ctx->current_scope, name, *enum_decl);
                        if (ret) {
-                               BT_COMP_LOGE("Cannot register enumeration field class in declaration scope: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot register enumeration field class in declaration scope: "
                                        "ret=%d", ret);
                                goto error;
                        }
@@ -2128,7 +2137,7 @@ end:
 }
 
 static
-int visit_field_class_specifier(struct ctx *ctx,
+int visit_field_class_specifier(struct ctf_visitor_generate_ir *ctx,
                struct ctf_node *cls_specifier_list,
                struct ctf_field_class **decl)
 {
@@ -2139,7 +2148,7 @@ int visit_field_class_specifier(struct ctx *ctx,
        str = g_string_new("");
        ret = get_class_specifier_list_name(ctx, cls_specifier_list, str);
        if (ret) {
-               _BT_COMP_LOGE_NODE(cls_specifier_list,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(cls_specifier_list,
                        "Cannot get field class specifier list's name: ret=%d", ret);
                goto error;
        }
@@ -2147,7 +2156,7 @@ int visit_field_class_specifier(struct ctx *ctx,
        *decl = ctx_decl_scope_lookup_alias(ctx, ctx->current_scope, str->str,
                -1, true);
        if (!*decl) {
-               _BT_COMP_LOGE_NODE(cls_specifier_list,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(cls_specifier_list,
                        "Cannot find field class alias: name=\"%s\"", str->str);
                ret = -EINVAL;
                goto error;
@@ -2168,7 +2177,7 @@ end:
 }
 
 static
-int visit_integer_decl(struct ctx *ctx,
+int visit_integer_decl(struct ctf_visitor_generate_ir *ctx,
                struct bt_list_head *expressions,
                struct ctf_field_class_int **integer_decl)
 {
@@ -2195,7 +2204,7 @@ int visit_integer_decl(struct ctx *ctx,
                        siblings);
 
                if (left->u.unary_expression.type != UNARY_STRING) {
-                       _BT_COMP_LOGE_NODE(left,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(left,
                                "Unexpected unary expression type: type=%d",
                                left->u.unary_expression.type);
                        ret = -EINVAL;
@@ -2204,7 +2213,7 @@ int visit_integer_decl(struct ctx *ctx,
 
                if (strcmp(left->u.unary_expression.u.string, "signed") == 0) {
                        if (_IS_SET(&set, _INTEGER_SIGNED_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(left, "signed",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "signed",
                                        "integer field class");
                                ret = -EPERM;
                                goto error;
@@ -2212,7 +2221,7 @@ int visit_integer_decl(struct ctx *ctx,
 
                        signedness = get_boolean(ctx, right);
                        if (signedness < 0) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid boolean value for integer field class's `signed` attribute: "
                                        "ret=%d", ret);
                                ret = -EINVAL;
@@ -2222,7 +2231,7 @@ int visit_integer_decl(struct ctx *ctx,
                        _SET(&set, _INTEGER_SIGNED_SET);
                } else if (strcmp(left->u.unary_expression.u.string, "byte_order") == 0) {
                        if (_IS_SET(&set, _INTEGER_BYTE_ORDER_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(left, "byte_order",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "byte_order",
                                        "integer field class");
                                ret = -EPERM;
                                goto error;
@@ -2230,7 +2239,7 @@ int visit_integer_decl(struct ctx *ctx,
 
                        byte_order = get_real_byte_order(ctx, right);
                        if (byte_order == CTF_BYTE_ORDER_UNKNOWN) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `byte_order` attribute in integer field class: "
                                        "ret=%d", ret);
                                ret = -EINVAL;
@@ -2240,7 +2249,7 @@ int visit_integer_decl(struct ctx *ctx,
                        _SET(&set, _INTEGER_BYTE_ORDER_SET);
                } else if (strcmp(left->u.unary_expression.u.string, "size") == 0) {
                        if (_IS_SET(&set, _INTEGER_SIZE_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(left, "size",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "size",
                                        "integer field class");
                                ret = -EPERM;
                                goto error;
@@ -2248,7 +2257,7 @@ int visit_integer_decl(struct ctx *ctx,
 
                        if (right->u.unary_expression.type !=
                                        UNARY_UNSIGNED_CONSTANT) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `size` attribute in integer field class: "
                                        "expecting unsigned constant integer: "
                                        "node-type=%d",
@@ -2259,14 +2268,14 @@ int visit_integer_decl(struct ctx *ctx,
 
                        size = right->u.unary_expression.u.unsigned_constant;
                        if (size == 0) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `size` attribute in integer field class: "
                                        "expecting positive constant integer: "
                                        "size=%" PRIu64, size);
                                ret = -EINVAL;
                                goto error;
                        } else if (size > 64) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `size` attribute in integer field class: "
                                        "integer fields over 64 bits are not supported as of this version: "
                                        "size=%" PRIu64, size);
@@ -2277,7 +2286,7 @@ int visit_integer_decl(struct ctx *ctx,
                        _SET(&set, _INTEGER_SIZE_SET);
                } else if (strcmp(left->u.unary_expression.u.string, "align") == 0) {
                        if (_IS_SET(&set, _INTEGER_ALIGN_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(left, "align",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "align",
                                        "integer field class");
                                ret = -EPERM;
                                goto error;
@@ -2285,7 +2294,7 @@ int visit_integer_decl(struct ctx *ctx,
 
                        if (right->u.unary_expression.type !=
                                        UNARY_UNSIGNED_CONSTANT) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `align` attribute in integer field class: "
                                        "expecting unsigned constant integer: "
                                        "node-type=%d",
@@ -2297,7 +2306,7 @@ int visit_integer_decl(struct ctx *ctx,
                        alignment =
                                right->u.unary_expression.u.unsigned_constant;
                        if (!is_align_valid(alignment)) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `align` attribute in integer field class: "
                                        "expecting power of two: "
                                        "align=%" PRIu64, alignment);
@@ -2308,7 +2317,7 @@ int visit_integer_decl(struct ctx *ctx,
                        _SET(&set, _INTEGER_ALIGN_SET);
                } else if (strcmp(left->u.unary_expression.u.string, "base") == 0) {
                        if (_IS_SET(&set, _INTEGER_BASE_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(left, "base",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "base",
                                        "integer field class");
                                ret = -EPERM;
                                goto error;
@@ -2334,7 +2343,7 @@ int visit_integer_decl(struct ctx *ctx,
                                        base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL;
                                        break;
                                default:
-                                       _BT_COMP_LOGE_NODE(right,
+                                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                                "Invalid `base` attribute in integer field class: "
                                                "base=%" PRIu64,
                                                right->u.unary_expression.u.unsigned_constant);
@@ -2348,7 +2357,7 @@ int visit_integer_decl(struct ctx *ctx,
                                char *s_right = ctf_ast_concatenate_unary_strings(
                                        &expression->u.ctf_expression.right);
                                if (!s_right) {
-                                       _BT_COMP_LOGE_NODE(right,
+                                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                                "Unexpected unary expression for integer field class's `base` attribute.");
                                        ret = -EINVAL;
                                        goto error;
@@ -2374,7 +2383,7 @@ int visit_integer_decl(struct ctx *ctx,
                                                strcmp(s_right, "b") == 0) {
                                        base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY;
                                } else {
-                                       _BT_COMP_LOGE_NODE(right,
+                                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                                "Unexpected unary expression for integer field class's `base` attribute: "
                                                "base=\"%s\"", s_right);
                                        g_free(s_right);
@@ -2386,7 +2395,7 @@ int visit_integer_decl(struct ctx *ctx,
                                break;
                        }
                        default:
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `base` attribute in integer field class: "
                                        "expecting unsigned constant integer or unary string.");
                                ret = -EINVAL;
@@ -2398,14 +2407,14 @@ int visit_integer_decl(struct ctx *ctx,
                        char *s_right;
 
                        if (_IS_SET(&set, _INTEGER_ENCODING_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(left, "encoding",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "encoding",
                                        "integer field class");
                                ret = -EPERM;
                                goto error;
                        }
 
                        if (right->u.unary_expression.type != UNARY_STRING) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `encoding` attribute in integer field class: "
                                        "expecting unary string.");
                                ret = -EINVAL;
@@ -2415,7 +2424,7 @@ int visit_integer_decl(struct ctx *ctx,
                        s_right = ctf_ast_concatenate_unary_strings(
                                &expression->u.ctf_expression.right);
                        if (!s_right) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Unexpected unary expression for integer field class's `encoding` attribute.");
                                ret = -EINVAL;
                                goto error;
@@ -2431,7 +2440,7 @@ int visit_integer_decl(struct ctx *ctx,
                        } else if (strcmp(s_right, "none") == 0) {
                                encoding = CTF_ENCODING_NONE;
                        } else {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `encoding` attribute in integer field class: "
                                        "unknown encoding: encoding=\"%s\"",
                                        s_right);
@@ -2446,14 +2455,14 @@ int visit_integer_decl(struct ctx *ctx,
                        const char *clock_name;
 
                        if (_IS_SET(&set, _INTEGER_MAP_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(left, "map",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "map",
                                        "integer field class");
                                ret = -EPERM;
                                goto error;
                        }
 
                        if (right->u.unary_expression.type != UNARY_STRING) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `map` attribute in integer field class: "
                                        "expecting unary string.");
                                ret = -EINVAL;
@@ -2468,7 +2477,7 @@ int visit_integer_decl(struct ctx *ctx,
                                        &expression->u.ctf_expression.right);
 
                                if (!s_right) {
-                                       _BT_COMP_LOGE_NODE(right,
+                                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                                "Unexpected unary expression for integer field class's `map` attribute.");
                                        ret = -EINVAL;
                                        goto error;
@@ -2487,7 +2496,7 @@ int visit_integer_decl(struct ctx *ctx,
                                ctf_trace_class_borrow_clock_class_by_name(
                                        ctx->ctf_tc, clock_name);
                        if (!mapped_clock_class) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `map` attribute in integer field class: "
                                        "cannot find clock class at this point: name=\"%s\"",
                                        clock_name);
@@ -2505,7 +2514,7 @@ int visit_integer_decl(struct ctx *ctx,
        }
 
        if (!_IS_SET(&set, _INTEGER_SIZE_SET)) {
-               BT_COMP_LOGE_STR("Missing `size` attribute in integer field class.");
+               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Missing `size` attribute in integer field class.");
                ret = -EPERM;
                goto error;
        }
@@ -2538,7 +2547,7 @@ error:
 }
 
 static
-int visit_floating_point_number_decl(struct ctx *ctx,
+int visit_floating_point_number_decl(struct ctf_visitor_generate_ir *ctx,
                struct bt_list_head *expressions,
                struct ctf_field_class_float **float_decl)
 {
@@ -2560,7 +2569,7 @@ int visit_floating_point_number_decl(struct ctx *ctx,
                        siblings);
 
                if (left->u.unary_expression.type != UNARY_STRING) {
-                       _BT_COMP_LOGE_NODE(left,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(left,
                                "Unexpected unary expression type: type=%d",
                                left->u.unary_expression.type);
                        ret = -EINVAL;
@@ -2569,7 +2578,7 @@ int visit_floating_point_number_decl(struct ctx *ctx,
 
                if (strcmp(left->u.unary_expression.u.string, "byte_order") == 0) {
                        if (_IS_SET(&set, _FLOAT_BYTE_ORDER_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(left, "byte_order",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "byte_order",
                                        "floating point number field class");
                                ret = -EPERM;
                                goto error;
@@ -2577,7 +2586,7 @@ int visit_floating_point_number_decl(struct ctx *ctx,
 
                        byte_order = get_real_byte_order(ctx, right);
                        if (byte_order == CTF_BYTE_ORDER_UNKNOWN) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `byte_order` attribute in floating point number field class: "
                                        "ret=%d", ret);
                                ret = -EINVAL;
@@ -2587,7 +2596,7 @@ int visit_floating_point_number_decl(struct ctx *ctx,
                        _SET(&set, _FLOAT_BYTE_ORDER_SET);
                } else if (strcmp(left->u.unary_expression.u.string, "exp_dig") == 0) {
                        if (_IS_SET(&set, _FLOAT_EXP_DIG_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(left, "exp_dig",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "exp_dig",
                                        "floating point number field class");
                                ret = -EPERM;
                                goto error;
@@ -2595,7 +2604,7 @@ int visit_floating_point_number_decl(struct ctx *ctx,
 
                        if (right->u.unary_expression.type !=
                                        UNARY_UNSIGNED_CONSTANT) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `exp_dig` attribute in floating point number field class: "
                                        "expecting unsigned constant integer: "
                                        "node-type=%d",
@@ -2608,7 +2617,7 @@ int visit_floating_point_number_decl(struct ctx *ctx,
                        _SET(&set, _FLOAT_EXP_DIG_SET);
                } else if (strcmp(left->u.unary_expression.u.string, "mant_dig") == 0) {
                        if (_IS_SET(&set, _FLOAT_MANT_DIG_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(left, "mant_dig",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "mant_dig",
                                        "floating point number field class");
                                ret = -EPERM;
                                goto error;
@@ -2616,7 +2625,7 @@ int visit_floating_point_number_decl(struct ctx *ctx,
 
                        if (right->u.unary_expression.type !=
                                        UNARY_UNSIGNED_CONSTANT) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `mant_dig` attribute in floating point number field class: "
                                        "expecting unsigned constant integer: "
                                        "node-type=%d",
@@ -2630,7 +2639,7 @@ int visit_floating_point_number_decl(struct ctx *ctx,
                        _SET(&set, _FLOAT_MANT_DIG_SET);
                } else if (strcmp(left->u.unary_expression.u.string, "align") == 0) {
                        if (_IS_SET(&set, _FLOAT_ALIGN_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(left, "align",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "align",
                                        "floating point number field class");
                                ret = -EPERM;
                                goto error;
@@ -2638,7 +2647,7 @@ int visit_floating_point_number_decl(struct ctx *ctx,
 
                        if (right->u.unary_expression.type !=
                                        UNARY_UNSIGNED_CONSTANT) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `align` attribute in floating point number field class: "
                                        "expecting unsigned constant integer: "
                                        "node-type=%d",
@@ -2651,7 +2660,7 @@ int visit_floating_point_number_decl(struct ctx *ctx,
                                unsigned_constant;
 
                        if (!is_align_valid(alignment)) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `align` attribute in floating point number field class: "
                                        "expecting power of two: "
                                        "align=%" PRIu64, alignment);
@@ -2669,31 +2678,31 @@ int visit_floating_point_number_decl(struct ctx *ctx,
        }
 
        if (!_IS_SET(&set, _FLOAT_MANT_DIG_SET)) {
-               BT_COMP_LOGE_STR("Missing `mant_dig` attribute in floating point number field class.");
+               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Missing `mant_dig` attribute in floating point number field class.");
                ret = -EPERM;
                goto error;
        }
 
        if (!_IS_SET(&set, _FLOAT_EXP_DIG_SET)) {
-               BT_COMP_LOGE_STR("Missing `exp_dig` attribute in floating point number field class.");
+               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Missing `exp_dig` attribute in floating point number field class.");
                ret = -EPERM;
                goto error;
        }
 
        if (mant_dig != 24 && mant_dig != 53) {
-               BT_COMP_LOGE_STR("`mant_dig` attribute: expecting 24 or 53.");
+               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("`mant_dig` attribute: expecting 24 or 53.");
                ret = -EPERM;
                goto error;
        }
 
        if (mant_dig == 24 && exp_dig != 8) {
-               BT_COMP_LOGE_STR("`exp_dig` attribute: expecting 8 because `mant_dig` is 24.");
+               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("`exp_dig` attribute: expecting 8 because `mant_dig` is 24.");
                ret = -EPERM;
                goto error;
        }
 
        if (mant_dig == 53 && exp_dig != 11) {
-               BT_COMP_LOGE_STR("`exp_dig` attribute: expecting 11 because `mant_dig` is 53.");
+               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("`exp_dig` attribute: expecting 11 because `mant_dig` is 53.");
                ret = -EPERM;
                goto error;
        }
@@ -2722,7 +2731,7 @@ error:
 }
 
 static
-int visit_string_decl(struct ctx *ctx,
+int visit_string_decl(struct ctf_visitor_generate_ir *ctx,
                struct bt_list_head *expressions,
                struct ctf_field_class_string **string_decl)
 {
@@ -2743,7 +2752,7 @@ int visit_string_decl(struct ctx *ctx,
                        siblings);
 
                if (left->u.unary_expression.type != UNARY_STRING) {
-                       _BT_COMP_LOGE_NODE(left,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(left,
                                "Unexpected unary expression type: type=%d",
                                left->u.unary_expression.type);
                        ret = -EINVAL;
@@ -2754,14 +2763,14 @@ int visit_string_decl(struct ctx *ctx,
                        char *s_right;
 
                        if (_IS_SET(&set, _STRING_ENCODING_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(left, "encoding",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "encoding",
                                        "string field class");
                                ret = -EPERM;
                                goto error;
                        }
 
                        if (right->u.unary_expression.type != UNARY_STRING) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `encoding` attribute in string field class: "
                                        "expecting unary string.");
                                ret = -EINVAL;
@@ -2771,7 +2780,7 @@ int visit_string_decl(struct ctx *ctx,
                        s_right = ctf_ast_concatenate_unary_strings(
                                &expression->u.ctf_expression.right);
                        if (!s_right) {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Unexpected unary expression for string field class's `encoding` attribute.");
                                ret = -EINVAL;
                                goto error;
@@ -2787,7 +2796,7 @@ int visit_string_decl(struct ctx *ctx,
                        } else if (strcmp(s_right, "none") == 0) {
                                encoding = CTF_ENCODING_NONE;
                        } else {
-                               _BT_COMP_LOGE_NODE(right,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
                                        "Invalid `encoding` attribute in string field class: "
                                        "unknown encoding: encoding=\"%s\"",
                                        s_right);
@@ -2818,7 +2827,7 @@ error:
 }
 
 static
-int visit_field_class_specifier_list(struct ctx *ctx,
+int visit_field_class_specifier_list(struct ctf_visitor_generate_ir *ctx,
                struct ctf_node *ts_list, struct ctf_field_class **decl)
 {
        int ret = 0;
@@ -2827,7 +2836,7 @@ int visit_field_class_specifier_list(struct ctx *ctx,
        *decl = NULL;
 
        if (ts_list->type != NODE_TYPE_SPECIFIER_LIST) {
-               _BT_COMP_LOGE_NODE(ts_list,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(ts_list,
                        "Unexpected node type: node-type=%d", ts_list->type);
                ret = -EINVAL;
                goto error;
@@ -2836,7 +2845,7 @@ int visit_field_class_specifier_list(struct ctx *ctx,
        first = _BT_LIST_FIRST_ENTRY(&ts_list->u.field_class_specifier_list.head,
                struct ctf_node, siblings);
        if (first->type != NODE_TYPE_SPECIFIER) {
-               _BT_COMP_LOGE_NODE(first,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(first,
                        "Unexpected node type: node-type=%d", first->type);
                ret = -EINVAL;
                goto error;
@@ -2915,7 +2924,7 @@ int visit_field_class_specifier_list(struct ctx *ctx,
        case TYPESPEC_ID_TYPE:
                ret = visit_field_class_specifier(ctx, ts_list, decl);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(first,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(first,
                                "Cannot visit field class specifier: ret=%d",
                                ret);
                        BT_ASSERT(!*decl);
@@ -2923,7 +2932,7 @@ int visit_field_class_specifier_list(struct ctx *ctx,
                }
                break;
        default:
-               _BT_COMP_LOGE_NODE(first,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(first,
                        "Unexpected field class specifier type: node-type=%d",
                        first->u.field_class_specifier.type);
                ret = -EINVAL;
@@ -2940,7 +2949,7 @@ error:
 }
 
 static
-int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
+int visit_event_decl_entry(struct ctf_visitor_generate_ir *ctx, struct ctf_node *node,
                struct ctf_event_class *event_class, uint64_t *stream_id,
                int *set)
 {
@@ -2952,7 +2961,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                ret = visit_field_class_def(ctx, node->u.field_class_def.field_class_specifier_list,
                        &node->u.field_class_def.field_class_declarators);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                "Cannot add field class found in event class.");
                        goto error;
                }
@@ -2961,7 +2970,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                ret = visit_field_class_alias(ctx, node->u.field_class_alias.target,
                        node->u.field_class_alias.alias);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                "Cannot add field class alias found in event class.");
                        goto error;
                }
@@ -2970,7 +2979,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
        {
                left = ctf_ast_concatenate_unary_strings(&node->u.ctf_expression.left);
                if (!left) {
-                       _BT_COMP_LOGE_NODE(node, "Cannot concatenate unary strings.");
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Cannot concatenate unary strings.");
                        ret = -EINVAL;
                        goto error;
                }
@@ -2978,7 +2987,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                if (strcmp(left, "name") == 0) {
                        /* This is already known at this stage */
                        if (_IS_SET(set, _EVENT_NAME_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(node, "name", "event class");
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "name", "event class");
                                ret = -EPERM;
                                goto error;
                        }
@@ -2988,7 +2997,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                        int64_t id = -1;
 
                        if (_IS_SET(set, _EVENT_ID_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(node, "id", "event class");
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "id", "event class");
                                ret = -EPERM;
                                goto error;
                        }
@@ -2998,7 +3007,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                                (uint64_t *) &id);
                        /* Only read "id" if get_unary_unsigned() succeeded. */
                        if (ret || (!ret && id < 0)) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Unexpected unary expression for event class's `id` attribute.");
                                ret = -EINVAL;
                                goto error;
@@ -3008,7 +3017,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                        _SET(set, _EVENT_ID_SET);
                } else if (strcmp(left, "stream_id") == 0) {
                        if (_IS_SET(set, _EVENT_STREAM_ID_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(node, "stream_id",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "stream_id",
                                        "event class");
                                ret = -EPERM;
                                goto error;
@@ -3022,7 +3031,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                         * succeeded.
                         */
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Unexpected unary expression for event class's `stream_id` attribute.");
                                ret = -EINVAL;
                                goto error;
@@ -3031,7 +3040,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                        _SET(set, _EVENT_STREAM_ID_SET);
                } else if (strcmp(left, "context") == 0) {
                        if (_IS_SET(set, _EVENT_CONTEXT_SET)) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Duplicate `context` entry in event class.");
                                ret = -EPERM;
                                goto error;
@@ -3043,7 +3052,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                                        struct ctf_node, siblings),
                                &event_class->spec_context_fc);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Cannot create event class's context field class.");
                                goto error;
                        }
@@ -3052,7 +3061,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                        _SET(set, _EVENT_CONTEXT_SET);
                } else if (strcmp(left, "fields") == 0) {
                        if (_IS_SET(set, _EVENT_FIELDS_SET)) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Duplicate `fields` entry in event class.");
                                ret = -EPERM;
                                goto error;
@@ -3064,7 +3073,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                                        struct ctf_node, siblings),
                                &event_class->payload_fc);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Cannot create event class's payload field class.");
                                goto error;
                        }
@@ -3077,7 +3086,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                        bt_event_class_log_level log_level = -1;
 
                        if (_IS_SET(set, _EVENT_LOG_LEVEL_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(node, "loglevel",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "loglevel",
                                        "event class");
                                ret = -EPERM;
                                goto error;
@@ -3086,7 +3095,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                        ret = get_unary_unsigned(ctx,
                                &node->u.ctf_expression.right, &loglevel_value);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Unexpected unary expression for event class's `loglevel` attribute.");
                                ret = -EINVAL;
                                goto error;
@@ -3153,7 +3162,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                        char *right;
 
                        if (_IS_SET(set, _EVENT_MODEL_EMF_URI_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(node, "model.emf.uri",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "model.emf.uri",
                                        "event class");
                                ret = -EPERM;
                                goto error;
@@ -3162,7 +3171,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                        right = ctf_ast_concatenate_unary_strings(
                                &node->u.ctf_expression.right);
                        if (!right) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Unexpected unary expression for event class's `model.emf.uri` attribute.");
                                ret = -EINVAL;
                                goto error;
@@ -3203,7 +3212,7 @@ end:
 }
 
 static
-char *get_event_decl_name(struct ctx *ctx, struct ctf_node *node)
+char *get_event_decl_name(struct ctf_visitor_generate_ir *ctx, struct ctf_node *node)
 {
        char *left = NULL;
        char *name = NULL;
@@ -3217,7 +3226,7 @@ char *get_event_decl_name(struct ctx *ctx, struct ctf_node *node)
 
                left = ctf_ast_concatenate_unary_strings(&iter->u.ctf_expression.left);
                if (!left) {
-                       _BT_COMP_LOGE_NODE(iter,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
                                "Cannot concatenate unary strings.");
                        goto error;
                }
@@ -3226,7 +3235,7 @@ char *get_event_decl_name(struct ctx *ctx, struct ctf_node *node)
                        name = ctf_ast_concatenate_unary_strings(
                                &iter->u.ctf_expression.right);
                        if (!name) {
-                               _BT_COMP_LOGE_NODE(iter,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
                                        "Unexpected unary expression for event class's `name` attribute.");
                                goto error;
                        }
@@ -3248,7 +3257,7 @@ error:
 }
 
 static
-int visit_event_decl(struct ctx *ctx, struct ctf_node *node)
+int visit_event_decl(struct ctf_visitor_generate_ir *ctx, struct ctf_node *node)
 {
        int ret = 0;
        int set = 0;
@@ -3267,7 +3276,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node)
        node->visited = TRUE;
        event_name = get_event_decl_name(ctx, node);
        if (!event_name) {
-               _BT_COMP_LOGE_NODE(node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                        "Missing `name` attribute in event class.");
                ret = -EPERM;
                goto error;
@@ -3283,7 +3292,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node)
                ret = visit_event_decl_entry(ctx, iter, event_class,
                        &stream_id, &set);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(iter, "Cannot visit event class's entry: "
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter, "Cannot visit event class's entry: "
                                "ret=%d", ret);
                        goto error;
                }
@@ -3310,7 +3319,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node)
                        stream_id = stream_class->id;
                        break;
                default:
-                       _BT_COMP_LOGE_NODE(node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                "Missing `stream_id` attribute in event class.");
                        ret = -EPERM;
                        goto error;
@@ -3322,7 +3331,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node)
                stream_class = ctf_trace_class_borrow_stream_class_by_id(
                        ctx->ctf_tc, stream_id);
                if (!stream_class) {
-                       _BT_COMP_LOGE_NODE(node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                "Cannot find stream class at this point: "
                                "id=%" PRId64, stream_id);
                        ret = -EINVAL;
@@ -3335,7 +3344,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node)
        if (!_IS_SET(&set, _EVENT_ID_SET)) {
                /* Allow only one event without ID per stream */
                if (stream_class->event_classes->len != 0) {
-                       _BT_COMP_LOGE_NODE(node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                "Missing `id` attribute in event class.");
                        ret = -EPERM;
                        goto error;
@@ -3347,7 +3356,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node)
 
        if (ctf_stream_class_borrow_event_class_by_id(stream_class,
                        event_class->id)) {
-               _BT_COMP_LOGE_NODE(node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                        "Duplicate event class (same ID) in the same stream class: "
                        "id=%" PRId64, event_class->id);
                ret = -EEXIST;
@@ -3377,7 +3386,7 @@ end:
 }
 
 static
-int auto_map_field_to_trace_clock_class(struct ctx *ctx,
+int auto_map_field_to_trace_clock_class(struct ctf_visitor_generate_ir *ctx,
                struct ctf_field_class *fc)
 {
        struct ctf_clock_class *clock_class_to_map_to = NULL;
@@ -3428,7 +3437,7 @@ int auto_map_field_to_trace_clock_class(struct ctx *ctx,
                 * Timestamp field not mapped to a clock class and there's more
                 * than one clock class in the trace: this is an error.
                 */
-               BT_COMP_LOGE_STR("Timestamp field found with no mapped clock class, "
+               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Timestamp field found with no mapped clock class, "
                        "but there's more than one clock class in the trace at this point.");
                ret = -1;
                goto end;
@@ -3442,7 +3451,7 @@ end:
 }
 
 static
-int auto_map_fields_to_trace_clock_class(struct ctx *ctx,
+int auto_map_fields_to_trace_clock_class(struct ctf_visitor_generate_ir *ctx,
                struct ctf_field_class *root_fc, const char *field_name)
 {
        int ret = 0;
@@ -3482,7 +3491,7 @@ int auto_map_fields_to_trace_clock_class(struct ctx *ctx,
                        ret = auto_map_field_to_trace_clock_class(ctx,
                                named_fc->fc);
                        if (ret) {
-                               BT_COMP_LOGE("Cannot automatically map field to trace's clock class: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot automatically map field to trace's clock class: "
                                        "field-name=\"%s\"", field_name);
                                goto end;
                        }
@@ -3491,7 +3500,7 @@ int auto_map_fields_to_trace_clock_class(struct ctx *ctx,
                ret = auto_map_fields_to_trace_clock_class(ctx, named_fc->fc,
                        field_name);
                if (ret) {
-                       BT_COMP_LOGE("Cannot automatically map structure or variant field class's fields to trace's clock class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot automatically map structure or variant field class's fields to trace's clock class: "
                                "field-name=\"%s\", root-field-name=\"%s\"",
                                field_name, named_fc->name->str);
                        goto end;
@@ -3503,7 +3512,7 @@ end:
 }
 
 static
-int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
+int visit_stream_decl_entry(struct ctf_visitor_generate_ir *ctx, struct ctf_node *node,
                struct ctf_stream_class *stream_class, int *set)
 {
        int ret = 0;
@@ -3514,7 +3523,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
                ret = visit_field_class_def(ctx, node->u.field_class_def.field_class_specifier_list,
                        &node->u.field_class_def.field_class_declarators);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                "Cannot add field class found in stream class.");
                        goto error;
                }
@@ -3523,7 +3532,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
                ret = visit_field_class_alias(ctx, node->u.field_class_alias.target,
                        node->u.field_class_alias.alias);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                "Cannot add field class alias found in stream class.");
                        goto error;
                }
@@ -3532,7 +3541,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
        {
                left = ctf_ast_concatenate_unary_strings(&node->u.ctf_expression.left);
                if (!left) {
-                       _BT_COMP_LOGE_NODE(node, "Cannot concatenate unary strings.");
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Cannot concatenate unary strings.");
                        ret = -EINVAL;
                        goto error;
                }
@@ -3541,7 +3550,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
                        int64_t id;
 
                        if (_IS_SET(set, _STREAM_ID_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(node, "id",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "id",
                                        "stream declaration");
                                ret = -EPERM;
                                goto error;
@@ -3553,7 +3562,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
 
                        /* Only read "id" if get_unary_unsigned() succeeded. */
                        if (ret || (!ret && id < 0)) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Unexpected unary expression for stream class's `id` attribute.");
                                ret = -EINVAL;
                                goto error;
@@ -3561,7 +3570,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
 
                        if (ctf_trace_class_borrow_stream_class_by_id(
                                        ctx->ctf_tc, id)) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Duplicate stream class (same ID): id=%" PRId64,
                                        id);
                                ret = -EEXIST;
@@ -3572,7 +3581,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
                        _SET(set, _STREAM_ID_SET);
                } else if (strcmp(left, "event.header") == 0) {
                        if (_IS_SET(set, _STREAM_EVENT_HEADER_SET)) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Duplicate `event.header` entry in stream class.");
                                ret = -EPERM;
                                goto error;
@@ -3584,7 +3593,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
                                        struct ctf_node, siblings),
                                &stream_class->event_header_fc);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Cannot create stream class's event header field class.");
                                goto error;
                        }
@@ -3593,7 +3602,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
                        ret = auto_map_fields_to_trace_clock_class(ctx,
                                stream_class->event_header_fc, "timestamp");
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Cannot automatically map specific event header field class fields named `timestamp` to trace's clock class.");
                                goto error;
                        }
@@ -3601,7 +3610,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
                        _SET(set, _STREAM_EVENT_HEADER_SET);
                } else if (strcmp(left, "event.context") == 0) {
                        if (_IS_SET(set, _STREAM_EVENT_CONTEXT_SET)) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Duplicate `event.context` entry in stream class.");
                                ret = -EPERM;
                                goto error;
@@ -3613,7 +3622,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
                                        struct ctf_node, siblings),
                                &stream_class->event_common_context_fc);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Cannot create stream class's event context field class.");
                                goto error;
                        }
@@ -3622,7 +3631,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
                        _SET(set, _STREAM_EVENT_CONTEXT_SET);
                } else if (strcmp(left, "packet.context") == 0) {
                        if (_IS_SET(set, _STREAM_PACKET_CONTEXT_SET)) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Duplicate `packet.context` entry in stream class.");
                                ret = -EPERM;
                                goto error;
@@ -3634,7 +3643,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
                                        struct ctf_node, siblings),
                                &stream_class->packet_context_fc);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Cannot create stream class's packet context field class.");
                                goto error;
                        }
@@ -3644,7 +3653,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
                                stream_class->packet_context_fc,
                                "timestamp_begin");
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Cannot automatically map specific packet context field class fields named `timestamp_begin` to trace's clock class.");
                                goto error;
                        }
@@ -3653,7 +3662,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
                                stream_class->packet_context_fc,
                                "timestamp_end");
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Cannot automatically map specific packet context field class fields named `timestamp_end` to trace's clock class.");
                                goto error;
                        }
@@ -3683,7 +3692,7 @@ error:
 }
 
 static
-int visit_stream_decl(struct ctx *ctx, struct ctf_node *node)
+int visit_stream_decl(struct ctf_visitor_generate_ir *ctx, struct ctf_node *node)
 {
        int set = 0;
        int ret = 0;
@@ -3703,7 +3712,7 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node)
        bt_list_for_each_entry(iter, decl_list, siblings) {
                ret = visit_stream_decl_entry(ctx, iter, stream_class, &set);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(iter,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
                                "Cannot visit stream class's entry: "
                                "ret=%d", ret);
                        ctx_pop_scope(ctx);
@@ -3718,32 +3727,35 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node)
                struct ctf_named_field_class *named_fc = NULL;
 
                if (!ctx->ctf_tc->packet_header_fc) {
-                       _BT_COMP_LOGE_NODE(node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                "Stream class has a `id` attribute, "
                                "but trace has no packet header field class.");
+                       ret = -EINVAL;
                        goto error;
                }
 
                named_fc = ctf_field_class_struct_borrow_member_by_name(
                        (void *) ctx->ctf_tc->packet_header_fc, "stream_id");
                if (!named_fc) {
-                       _BT_COMP_LOGE_NODE(node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                "Stream class has a `id` attribute, "
                                "but trace's packet header field class has no `stream_id` field.");
+                       ret = -EINVAL;
                        goto error;
                }
 
                if (named_fc->fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                named_fc->fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                       _BT_COMP_LOGE_NODE(node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                "Stream class has a `id` attribute, "
                                "but trace's packet header field class's `stream_id` field is not an integer field class.");
+                       ret = -EINVAL;
                        goto error;
                }
        } else {
                /* Allow only _one_ ID-less stream */
                if (ctx->ctf_tc->stream_classes->len != 0) {
-                       _BT_COMP_LOGE_NODE(node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                "Missing `id` attribute in stream class as there's more than one stream class in the trace.");
                        ret = -EPERM;
                        goto error;
@@ -3759,7 +3771,7 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node)
         */
        if (ctf_trace_class_borrow_stream_class_by_id(ctx->ctf_tc,
                        stream_class->id)) {
-               _BT_COMP_LOGE_NODE(node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                        "Duplicate stream class (same ID): id=%" PRId64,
                        stream_class->id);
                ret = -EINVAL;
@@ -3779,7 +3791,8 @@ end:
 }
 
 static
-int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set)
+int visit_trace_decl_entry(struct ctf_visitor_generate_ir *ctx, struct ctf_node *node,
+               int *set)
 {
        int ret = 0;
        char *left = NULL;
@@ -3790,7 +3803,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set)
                ret = visit_field_class_def(ctx, node->u.field_class_def.field_class_specifier_list,
                        &node->u.field_class_def.field_class_declarators);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                "Cannot add field class found in trace (`trace` block).");
                        goto error;
                }
@@ -3799,7 +3812,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set)
                ret = visit_field_class_alias(ctx, node->u.field_class_alias.target,
                        node->u.field_class_alias.alias);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                "Cannot add field class alias found in trace (`trace` block).");
                        goto error;
                }
@@ -3808,14 +3821,14 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set)
        {
                left = ctf_ast_concatenate_unary_strings(&node->u.ctf_expression.left);
                if (!left) {
-                       _BT_COMP_LOGE_NODE(node, "Cannot concatenate unary strings.");
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Cannot concatenate unary strings.");
                        ret = -EINVAL;
                        goto error;
                }
 
                if (strcmp(left, "major") == 0) {
                        if (_IS_SET(set, _TRACE_MAJOR_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(node, "major", "trace");
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "major", "trace");
                                ret = -EPERM;
                                goto error;
                        }
@@ -3823,15 +3836,16 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set)
                        ret = get_unary_unsigned(ctx,
                                &node->u.ctf_expression.right, &val);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Unexpected unary expression for trace's `major` attribute.");
                                ret = -EINVAL;
                                goto error;
                        }
 
                        if (val != 1) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Invalid trace's `minor` attribute: expecting 1.");
+                               ret = -EINVAL;
                                goto error;
                        }
 
@@ -3839,7 +3853,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set)
                        _SET(set, _TRACE_MAJOR_SET);
                } else if (strcmp(left, "minor") == 0) {
                        if (_IS_SET(set, _TRACE_MINOR_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(node, "minor", "trace");
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "minor", "trace");
                                ret = -EPERM;
                                goto error;
                        }
@@ -3847,15 +3861,16 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set)
                        ret = get_unary_unsigned(ctx,
                                &node->u.ctf_expression.right, &val);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Unexpected unary expression for trace's `minor` attribute.");
                                ret = -EINVAL;
                                goto error;
                        }
 
                        if (val != 8) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Invalid trace's `minor` attribute: expecting 8.");
+                               ret = -EINVAL;
                                goto error;
                        }
 
@@ -3863,7 +3878,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set)
                        _SET(set, _TRACE_MINOR_SET);
                } else if (strcmp(left, "uuid") == 0) {
                        if (_IS_SET(set, _TRACE_UUID_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(node, "uuid", "trace");
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "uuid", "trace");
                                ret = -EPERM;
                                goto error;
                        }
@@ -3872,7 +3887,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set)
                                &node->u.ctf_expression.right,
                                ctx->ctf_tc->uuid);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Invalid trace's `uuid` attribute.");
                                goto error;
                        }
@@ -3882,7 +3897,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set)
                } else if (strcmp(left, "byte_order") == 0) {
                        /* Default byte order is already known at this stage */
                        if (_IS_SET(set, _TRACE_BYTE_ORDER_SET)) {
-                               _BT_COMP_LOGE_DUP_ATTR(node, "byte_order",
+                               _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "byte_order",
                                        "trace");
                                ret = -EPERM;
                                goto error;
@@ -3892,7 +3907,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set)
                        _SET(set, _TRACE_BYTE_ORDER_SET);
                } else if (strcmp(left, "packet.header") == 0) {
                        if (_IS_SET(set, _TRACE_PACKET_HEADER_SET)) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Duplicate `packet.header` entry in trace.");
                                ret = -EPERM;
                                goto error;
@@ -3904,7 +3919,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set)
                                        struct ctf_node, siblings),
                                &ctx->ctf_tc->packet_header_fc);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Cannot create trace's packet header field class.");
                                goto error;
                        }
@@ -3922,7 +3937,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set)
                break;
        }
        default:
-               _BT_COMP_LOGE_NODE(node, "Unknown expression in trace.");
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Unknown expression in trace.");
                ret = -EINVAL;
                goto error;
        }
@@ -3935,7 +3950,7 @@ error:
 }
 
 static
-int visit_trace_decl(struct ctx *ctx, struct ctf_node *node)
+int visit_trace_decl(struct ctf_visitor_generate_ir *ctx, struct ctf_node *node)
 {
        int ret = 0;
        int set = 0;
@@ -3949,7 +3964,7 @@ int visit_trace_decl(struct ctx *ctx, struct ctf_node *node)
        node->visited = TRUE;
 
        if (ctx->is_trace_visited) {
-               _BT_COMP_LOGE_NODE(node, "Duplicate trace (`trace` block).");
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Duplicate trace (`trace` block).");
                ret = -EEXIST;
                goto error;
        }
@@ -3959,7 +3974,7 @@ int visit_trace_decl(struct ctx *ctx, struct ctf_node *node)
        bt_list_for_each_entry(iter, decl_list, siblings) {
                ret = visit_trace_decl_entry(ctx, iter, &set);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(iter, "Cannot visit trace's entry (`trace` block): "
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter, "Cannot visit trace's entry (`trace` block): "
                                "ret=%d", ret);
                        ctx_pop_scope(ctx);
                        goto error;
@@ -3969,21 +3984,21 @@ int visit_trace_decl(struct ctx *ctx, struct ctf_node *node)
        ctx_pop_scope(ctx);
 
        if (!_IS_SET(&set, _TRACE_MAJOR_SET)) {
-               _BT_COMP_LOGE_NODE(node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                        "Missing `major` attribute in trace (`trace` block).");
                ret = -EPERM;
                goto error;
        }
 
        if (!_IS_SET(&set, _TRACE_MINOR_SET)) {
-               _BT_COMP_LOGE_NODE(node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                        "Missing `minor` attribute in trace (`trace` block).");
                ret = -EPERM;
                goto error;
        }
 
        if (!_IS_SET(&set, _TRACE_BYTE_ORDER_SET)) {
-               _BT_COMP_LOGE_NODE(node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                        "Missing `byte_order` attribute in trace (`trace` block).");
                ret = -EPERM;
                goto error;
@@ -3999,7 +4014,7 @@ error:
 }
 
 static
-int visit_env(struct ctx *ctx, struct ctf_node *node)
+int visit_env(struct ctf_visitor_generate_ir *ctx, struct ctf_node *node)
 {
        int ret = 0;
        char *left = NULL;
@@ -4017,7 +4032,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node)
                        &entry_node->u.ctf_expression.right;
 
                if (entry_node->type != NODE_CTF_EXPRESSION) {
-                       _BT_COMP_LOGE_NODE(entry_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                "Wrong expression in environment entry: "
                                "node-type=%d", entry_node->type);
                        ret = -EPERM;
@@ -4027,7 +4042,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node)
                left = ctf_ast_concatenate_unary_strings(
                        &entry_node->u.ctf_expression.left);
                if (!left) {
-                       _BT_COMP_LOGE_NODE(entry_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                "Cannot get environment entry's name.");
                        ret = -EINVAL;
                        goto error;
@@ -4037,7 +4052,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node)
                        char *right = ctf_ast_concatenate_unary_strings(right_head);
 
                        if (!right) {
-                               _BT_COMP_LOGE_NODE(entry_node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                        "Unexpected unary expression for environment entry's value: "
                                        "name=\"%s\"", left);
                                ret = -EINVAL;
@@ -4068,7 +4083,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node)
                                ret = get_unary_signed(right_head, &v);
                        }
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(entry_node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                        "Unexpected unary expression for environment entry's value: "
                                        "name=\"%s\"", left);
                                ret = -EINVAL;
@@ -4097,7 +4112,7 @@ error:
 }
 
 static
-int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node)
+int set_trace_byte_order(struct ctf_visitor_generate_ir *ctx, struct ctf_node *trace_node)
 {
        int ret = 0;
        int set = 0;
@@ -4112,7 +4127,7 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node)
                        left = ctf_ast_concatenate_unary_strings(
                                &node->u.ctf_expression.left);
                        if (!left) {
-                               _BT_COMP_LOGE_NODE(node,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                        "Cannot concatenate unary strings.");
                                ret = -EINVAL;
                                goto error;
@@ -4122,7 +4137,7 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node)
                                enum ctf_byte_order bo;
 
                                if (_IS_SET(&set, _TRACE_BYTE_ORDER_SET)) {
-                                       _BT_COMP_LOGE_DUP_ATTR(node, "byte_order",
+                                       _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "byte_order",
                                                "trace");
                                        ret = -EPERM;
                                        goto error;
@@ -4135,13 +4150,13 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node)
                                bo = byte_order_from_unary_expr(ctx,
                                        right_node);
                                if (bo == CTF_BYTE_ORDER_UNKNOWN) {
-                                       _BT_COMP_LOGE_NODE(node,
+                                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                                "Invalid `byte_order` attribute in trace (`trace` block): "
                                                "expecting `le`, `be`, or `network`.");
                                        ret = -EINVAL;
                                        goto error;
                                } else if (bo == CTF_BYTE_ORDER_DEFAULT) {
-                                       _BT_COMP_LOGE_NODE(node,
+                                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                                "Invalid `byte_order` attribute in trace (`trace` block): "
                                                "cannot be set to `native` here.");
                                        ret = -EPERM;
@@ -4157,7 +4172,7 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node)
        }
 
        if (!_IS_SET(&set, _TRACE_BYTE_ORDER_SET)) {
-               _BT_COMP_LOGE_NODE(trace_node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(trace_node,
                        "Missing `byte_order` attribute in trace (`trace` block).");
                ret = -EINVAL;
                goto error;
@@ -4171,7 +4186,7 @@ error:
 }
 
 static
-int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
+int visit_clock_decl_entry(struct ctf_visitor_generate_ir *ctx, struct ctf_node *entry_node,
        struct ctf_clock_class *clock, int *set, int64_t *offset_seconds,
        uint64_t *offset_cycles)
 {
@@ -4179,7 +4194,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
        char *left = NULL;
 
        if (entry_node->type != NODE_CTF_EXPRESSION) {
-               _BT_COMP_LOGE_NODE(entry_node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                        "Unexpected node type: node-type=%d",
                        entry_node->type);
                ret = -EPERM;
@@ -4188,7 +4203,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
 
        left = ctf_ast_concatenate_unary_strings(&entry_node->u.ctf_expression.left);
        if (!left) {
-               _BT_COMP_LOGE_NODE(entry_node, "Cannot concatenate unary strings.");
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node, "Cannot concatenate unary strings.");
                ret = -EINVAL;
                goto error;
        }
@@ -4197,7 +4212,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                char *right;
 
                if (_IS_SET(set, _CLOCK_NAME_SET)) {
-                       _BT_COMP_LOGE_DUP_ATTR(entry_node, "name", "clock class");
+                       _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(entry_node, "name", "clock class");
                        ret = -EPERM;
                        goto error;
                }
@@ -4205,7 +4220,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                right = ctf_ast_concatenate_unary_strings(
                        &entry_node->u.ctf_expression.right);
                if (!right) {
-                       _BT_COMP_LOGE_NODE(entry_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                "Unexpected unary expression for clock class's `name` attribute.");
                        ret = -EINVAL;
                        goto error;
@@ -4218,7 +4233,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                bt_uuid_t uuid;
 
                if (_IS_SET(set, _CLOCK_UUID_SET)) {
-                       _BT_COMP_LOGE_DUP_ATTR(entry_node, "uuid", "clock class");
+                       _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(entry_node, "uuid", "clock class");
                        ret = -EPERM;
                        goto error;
                }
@@ -4226,7 +4241,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                ret = get_unary_uuid(ctx, &entry_node->u.ctf_expression.right,
                        uuid);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(entry_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                "Invalid clock class's `uuid` attribute.");
                        goto error;
                }
@@ -4238,7 +4253,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                char *right;
 
                if (_IS_SET(set, _CLOCK_DESCRIPTION_SET)) {
-                       _BT_COMP_LOGE_DUP_ATTR(entry_node, "description",
+                       _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(entry_node, "description",
                                "clock class");
                        ret = -EPERM;
                        goto error;
@@ -4247,7 +4262,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                right = ctf_ast_concatenate_unary_strings(
                        &entry_node->u.ctf_expression.right);
                if (!right) {
-                       _BT_COMP_LOGE_NODE(entry_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                "Unexpected unary expression for clock class's `description` attribute.");
                        ret = -EINVAL;
                        goto error;
@@ -4260,7 +4275,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                uint64_t freq = UINT64_C(-1);
 
                if (_IS_SET(set, _CLOCK_FREQ_SET)) {
-                       _BT_COMP_LOGE_DUP_ATTR(entry_node, "freq", "clock class");
+                       _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(entry_node, "freq", "clock class");
                        ret = -EPERM;
                        goto error;
                }
@@ -4268,14 +4283,14 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                ret = get_unary_unsigned(ctx,
                        &entry_node->u.ctf_expression.right, &freq);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(entry_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                "Unexpected unary expression for clock class's `freq` attribute.");
                        ret = -EINVAL;
                        goto error;
                }
 
                if (freq == UINT64_C(-1) || freq == 0) {
-                       _BT_COMP_LOGE_NODE(entry_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                "Invalid clock class frequency: freq=%" PRIu64,
                                freq);
                        ret = -EINVAL;
@@ -4288,7 +4303,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                uint64_t precision;
 
                if (_IS_SET(set, _CLOCK_PRECISION_SET)) {
-                       _BT_COMP_LOGE_DUP_ATTR(entry_node, "precision",
+                       _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(entry_node, "precision",
                                "clock class");
                        ret = -EPERM;
                        goto error;
@@ -4297,7 +4312,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                ret = get_unary_unsigned(ctx,
                        &entry_node->u.ctf_expression.right, &precision);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(entry_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                "Unexpected unary expression for clock class's `precision` attribute.");
                        ret = -EINVAL;
                        goto error;
@@ -4307,7 +4322,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                _SET(set, _CLOCK_PRECISION_SET);
        } else if (strcmp(left, "offset_s") == 0) {
                if (_IS_SET(set, _CLOCK_OFFSET_S_SET)) {
-                       _BT_COMP_LOGE_DUP_ATTR(entry_node, "offset_s",
+                       _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(entry_node, "offset_s",
                                "clock class");
                        ret = -EPERM;
                        goto error;
@@ -4316,7 +4331,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                ret = get_unary_signed(
                        &entry_node->u.ctf_expression.right, offset_seconds);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(entry_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                "Unexpected unary expression for clock class's `offset_s` attribute.");
                        ret = -EINVAL;
                        goto error;
@@ -4325,7 +4340,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                _SET(set, _CLOCK_OFFSET_S_SET);
        } else if (strcmp(left, "offset") == 0) {
                if (_IS_SET(set, _CLOCK_OFFSET_SET)) {
-                       _BT_COMP_LOGE_DUP_ATTR(entry_node, "offset", "clock class");
+                       _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(entry_node, "offset", "clock class");
                        ret = -EPERM;
                        goto error;
                }
@@ -4333,7 +4348,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                ret = get_unary_unsigned(ctx,
                        &entry_node->u.ctf_expression.right, offset_cycles);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(entry_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                "Unexpected unary expression for clock class's `offset` attribute.");
                        ret = -EINVAL;
                        goto error;
@@ -4344,7 +4359,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                struct ctf_node *right;
 
                if (_IS_SET(set, _CLOCK_ABSOLUTE_SET)) {
-                       _BT_COMP_LOGE_DUP_ATTR(entry_node, "absolute",
+                       _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(entry_node, "absolute",
                                "clock class");
                        ret = -EPERM;
                        goto error;
@@ -4355,7 +4370,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                        struct ctf_node, siblings);
                ret = get_boolean(ctx, right);
                if (ret < 0) {
-                       _BT_COMP_LOGE_NODE(entry_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                "Unexpected unary expression for clock class's `absolute` attribute.");
                        ret = -EINVAL;
                        goto error;
@@ -4406,7 +4421,7 @@ void calibrate_clock_class_offsets(int64_t *offset_seconds,
 }
 
 static
-void apply_clock_class_is_absolute(struct ctx *ctx,
+void apply_clock_class_is_absolute(struct ctf_visitor_generate_ir *ctx,
                struct ctf_clock_class *clock)
 {
        if (ctx->decoder_config.force_clock_class_origin_unix_epoch) {
@@ -4417,7 +4432,7 @@ void apply_clock_class_is_absolute(struct ctx *ctx,
 }
 
 static
-void apply_clock_class_offset(struct ctx *ctx,
+void apply_clock_class_offset(struct ctf_visitor_generate_ir *ctx,
                struct ctf_clock_class *clock)
 {
        uint64_t freq;
@@ -4476,7 +4491,7 @@ end:
 }
 
 static
-int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node)
+int visit_clock_decl(struct ctf_visitor_generate_ir *ctx, struct ctf_node *clock_node)
 {
        int ret = 0;
        int set = 0;
@@ -4497,7 +4512,7 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node)
        /* CTF 1.8's default frequency for a clock class is 1 GHz */
        clock = ctf_clock_class_create();
        if (!clock) {
-               _BT_COMP_LOGE_NODE(clock_node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(clock_node,
                        "Cannot create default clock class.");
                ret = -ENOMEM;
                goto end;
@@ -4507,7 +4522,7 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node)
                ret = visit_clock_decl_entry(ctx, entry_node, clock, &set,
                        &offset_seconds, &offset_cycles);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(entry_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
                                "Cannot visit clock class's entry: ret=%d",
                                ret);
                        goto end;
@@ -4515,7 +4530,7 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node)
        }
 
        if (!_IS_SET(&set, _CLOCK_NAME_SET)) {
-               _BT_COMP_LOGE_NODE(clock_node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(clock_node,
                        "Missing `name` attribute in clock class.");
                ret = -EPERM;
                goto end;
@@ -4556,7 +4571,7 @@ end:
 }
 
 static
-int visit_root_decl(struct ctx *ctx, struct ctf_node *root_decl_node)
+int visit_root_decl(struct ctf_visitor_generate_ir *ctx, struct ctf_node *root_decl_node)
 {
        int ret = 0;
 
@@ -4572,7 +4587,7 @@ int visit_root_decl(struct ctx *ctx, struct ctf_node *root_decl_node)
                        root_decl_node->u.field_class_def.field_class_specifier_list,
                        &root_decl_node->u.field_class_def.field_class_declarators);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(root_decl_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(root_decl_node,
                                "Cannot add field class found in root scope.");
                        goto end;
                }
@@ -4581,7 +4596,7 @@ int visit_root_decl(struct ctx *ctx, struct ctf_node *root_decl_node)
                ret = visit_field_class_alias(ctx, root_decl_node->u.field_class_alias.target,
                        root_decl_node->u.field_class_alias.alias);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(root_decl_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(root_decl_node,
                                "Cannot add field class alias found in root scope.");
                        goto end;
                }
@@ -4596,7 +4611,7 @@ int visit_root_decl(struct ctx *ctx, struct ctf_node *root_decl_node)
                 */
                ret = visit_field_class_specifier_list(ctx, root_decl_node, &decl);
                if (ret) {
-                       _BT_COMP_LOGE_NODE(root_decl_node,
+                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(root_decl_node,
                                "Cannot visit root scope's field class: "
                                "ret=%d", ret);
                        BT_ASSERT(!decl);
@@ -4608,7 +4623,7 @@ int visit_root_decl(struct ctx *ctx, struct ctf_node *root_decl_node)
                break;
        }
        default:
-               _BT_COMP_LOGE_NODE(root_decl_node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(root_decl_node,
                        "Unexpected node type: node-type=%d",
                        root_decl_node->type);
                ret = -EPERM;
@@ -4623,7 +4638,7 @@ BT_HIDDEN
 struct ctf_visitor_generate_ir *ctf_visitor_generate_ir_create(
                const struct ctf_metadata_decoder_config *decoder_config)
 {
-       struct ctx *ctx = NULL;
+       struct ctf_visitor_generate_ir *ctx = NULL;
 
        /* Create visitor's context */
        ctx = ctx_create(decoder_config);
@@ -4641,21 +4656,19 @@ error:
        ctx = NULL;
 
 end:
-       return (void *) ctx;
+       return ctx;
 }
 
 BT_HIDDEN
 void ctf_visitor_generate_ir_destroy(struct ctf_visitor_generate_ir *visitor)
 {
-       ctx_destroy((void *) visitor);
+       ctx_destroy(visitor);
 }
 
 BT_HIDDEN
 bt_trace_class *ctf_visitor_generate_ir_get_ir_trace_class(
-               struct ctf_visitor_generate_ir *visitor)
+               struct ctf_visitor_generate_ir *ctx)
 {
-       struct ctx *ctx = (void *) visitor;
-
        BT_ASSERT_DBG(ctx);
 
        if (ctx->trace_class) {
@@ -4667,21 +4680,18 @@ bt_trace_class *ctf_visitor_generate_ir_get_ir_trace_class(
 
 BT_HIDDEN
 struct ctf_trace_class *ctf_visitor_generate_ir_borrow_ctf_trace_class(
-               struct ctf_visitor_generate_ir *visitor)
+               struct ctf_visitor_generate_ir *ctx)
 {
-       struct ctx *ctx = (void *) visitor;
-
        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 *visitor,
+int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *ctx,
                struct ctf_node *node)
 {
        int ret = 0;
-       struct ctx *ctx = (void *) visitor;
 
        BT_COMP_LOGI_STR("Visiting metadata's AST to generate CTF IR objects.");
 
@@ -4701,7 +4711,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                if (ctx->ctf_tc->default_byte_order == CTF_BYTE_ORDER_UNKNOWN) {
                        bt_list_for_each_entry(iter, &node->u.root.trace, siblings) {
                                if (got_trace_decl) {
-                                       _BT_COMP_LOGE_NODE(node,
+                                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                                "Duplicate trace (`trace` block).");
                                        ret = -1;
                                        goto end;
@@ -4709,7 +4719,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
 
                                ret = set_trace_byte_order(ctx, iter);
                                if (ret) {
-                                       _BT_COMP_LOGE_NODE(node,
+                                       _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                                                "Cannot set trace's native byte order: "
                                                "ret=%d", ret);
                                        goto end;
@@ -4734,7 +4744,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                bt_list_for_each_entry(iter, &node->u.root.env, siblings) {
                        ret = visit_env(ctx, iter);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(iter,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
                                        "Cannot visit trace's environment (`env` block) entry: "
                                        "ret=%d", ret);
                                goto end;
@@ -4750,7 +4760,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                bt_list_for_each_entry(iter, &node->u.root.clock, siblings) {
                        ret = visit_clock_decl(ctx, iter);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(iter,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
                                        "Cannot visit clock class: ret=%d",
                                        ret);
                                goto end;
@@ -4768,7 +4778,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                                siblings) {
                        ret = visit_root_decl(ctx, iter);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(iter,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
                                        "Cannot visit root entry: ret=%d",
                                        ret);
                                goto end;
@@ -4791,7 +4801,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                bt_list_for_each_entry(iter, &node->u.root.trace, siblings) {
                        ret = visit_trace_decl(ctx, iter);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(iter,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
                                        "Cannot visit trace (`trace` block): "
                                        "ret=%d", ret);
                                goto end;
@@ -4805,7 +4815,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                bt_list_for_each_entry(iter, &node->u.root.stream, siblings) {
                        ret = visit_stream_decl(ctx, iter);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(iter,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
                                        "Cannot visit stream class: ret=%d",
                                        ret);
                                goto end;
@@ -4819,7 +4829,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                bt_list_for_each_entry(iter, &node->u.root.event, siblings) {
                        ret = visit_event_decl(ctx, iter);
                        if (ret) {
-                               _BT_COMP_LOGE_NODE(iter,
+                               _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
                                        "Cannot visit event class: ret=%d",
                                        ret);
                                goto end;
@@ -4831,7 +4841,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                break;
        }
        default:
-               _BT_COMP_LOGE_NODE(node,
+               _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
                        "Unexpected node type: node-type=%d",
                        node->type);
                ret = -EINVAL;
This page took 0.071479 seconds and 4 git commands to generate.