* @returns New visitor context, or NULL on error
*/
static
-struct ctx *ctx_create(
+struct ctx *ctx_create(bt_self_component_source *self_comp,
const struct ctf_metadata_decoder_config *decoder_config)
{
struct ctx *ctx = NULL;
goto error;
}
- ctx->trace_class = bt_trace_class_create();
- if (!ctx->trace_class) {
- BT_LOGE_STR("Cannot create empty trace class.");
- goto error;
+ if (self_comp) {
+ ctx->trace_class = bt_trace_class_create(
+ bt_self_component_source_as_self_component(self_comp));
+ if (!ctx->trace_class) {
+ BT_LOGE_STR("Cannot create empty trace class.");
+ goto error;
+ }
}
ctx->ctf_tc = ctf_trace_class_create();
uint64_t alignment = 0, size = 0;
bt_clock_class *mapped_clock_class = NULL;
enum ctf_encoding encoding = CTF_ENCODING_NONE;
- enum bt_field_class_integer_preferred_display_base base =
+ bt_field_class_integer_preferred_display_base base =
BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL;
enum ctf_byte_order byte_order = ctx->ctf_tc->default_byte_order;
_SET(set, _EVENT_FIELDS_SET);
} else if (!strcmp(left, "loglevel")) {
uint64_t loglevel_value;
- enum bt_event_class_log_level log_level = -1;
+ bt_event_class_log_level log_level = -1;
if (_IS_SET(set, _EVENT_LOG_LEVEL_SET)) {
_BT_LOGE_DUP_ATTR(node, "loglevel",
/*
* Old versions of LTTng forgot to set its clock class
* as absolute, even if it is. This is important because
- * it's a condition to be able to sort notifications
+ * it's a condition to be able to sort messages
* from different sources.
*/
bt_clock_class_set_is_absolute(clock, BT_TRUE);
BT_HIDDEN
struct ctf_visitor_generate_ir *ctf_visitor_generate_ir_create(
+ bt_self_component_source *self_comp,
const struct ctf_metadata_decoder_config *decoder_config)
{
struct ctx *ctx = NULL;
/* Create visitor's context */
- ctx = ctx_create(decoder_config);
+ ctx = ctx_create(self_comp, decoder_config);
if (!ctx) {
BT_LOGE_STR("Cannot create visitor's context.");
goto error;
struct ctx *ctx = (void *) visitor;
BT_ASSERT(ctx);
- BT_ASSERT(ctx->trace_class);
- bt_trace_class_get_ref(ctx->trace_class);
+
+ if (ctx->trace_class) {
+ bt_trace_class_get_ref(ctx->trace_class);
+ }
+
return ctx->trace_class;
}
goto end;
}
- /* Update "in IR" for field classes */
- ret = ctf_trace_class_update_in_ir(ctx->ctf_tc);
- if (ret) {
- ret = -EINVAL;
- goto end;
+ if (ctx->trace_class) {
+ /*
+ * Update "in IR" for field classes.
+ *
+ * If we have no IR trace class, then we'll have no way
+ * to create IR fields anyway, so we leave all the
+ * `in_ir` members false.
+ */
+ ret = ctf_trace_class_update_in_ir(ctx->ctf_tc);
+ if (ret) {
+ ret = -EINVAL;
+ goto end;
+ }
}
/* Update saved value indexes */
goto end;
}
- /* Copy new CTF metadata -> new IR metadata */
- ret = ctf_trace_class_translate(ctx->trace_class, ctx->ctf_tc);
- if (ret) {
- ret = -EINVAL;
- goto end;
+ if (ctx->trace_class) {
+ /* Copy new CTF metadata -> new IR metadata */
+ ret = ctf_trace_class_translate(ctx->trace_class, ctx->ctf_tc);
+ if (ret) {
+ ret = -EINVAL;
+ goto end;
+ }
}
end: