enum fs_sink_ctf_field_class_type {
FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL,
+ FS_SINK_CTF_FIELD_CLASS_TYPE_BIT_ARRAY,
FS_SINK_CTF_FIELD_CLASS_TYPE_INT,
FS_SINK_CTF_FIELD_CLASS_TYPE_FLOAT,
FS_SINK_CTF_FIELD_CLASS_TYPE_STRING,
named_fc->fc = NULL;
}
+static inline
+struct fs_sink_ctf_field_class_bit_array *
+fs_sink_ctf_field_class_bit_array_create(
+ const bt_field_class *ir_fc, uint64_t index_in_parent)
+{
+ struct fs_sink_ctf_field_class_bit_array *fc =
+ g_new0(struct fs_sink_ctf_field_class_bit_array, 1);
+
+ BT_ASSERT(fc);
+ _fs_sink_ctf_field_class_bit_array_init((void *) fc,
+ FS_SINK_CTF_FIELD_CLASS_TYPE_BIT_ARRAY, ir_fc,
+ (unsigned int) bt_field_class_bit_array_get_length(ir_fc),
+ index_in_parent);
+ return fc;
+}
+
static inline
struct fs_sink_ctf_field_class_bool *fs_sink_ctf_field_class_bool_create(
const bt_field_class *ir_fc, uint64_t index_in_parent)
BT_ASSERT(fc);
}
+static inline
+void _fs_sink_ctf_field_class_bit_array_destroy(
+ struct fs_sink_ctf_field_class_int *fc)
+{
+ BT_ASSERT(fc);
+ _fs_sink_ctf_field_class_fini((void *) fc);
+ g_free(fc);
+}
+
static inline
void _fs_sink_ctf_field_class_bool_destroy(
struct fs_sink_ctf_field_class_int *fc)
case FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL:
_fs_sink_ctf_field_class_bool_destroy((void *) fc);
break;
+ case FS_SINK_CTF_FIELD_CLASS_TYPE_BIT_ARRAY:
+ _fs_sink_ctf_field_class_bit_array_destroy((void *) fc);
+ break;
case FS_SINK_CTF_FIELD_CLASS_TYPE_INT:
_fs_sink_ctf_field_class_int_destroy((void *) fc);
break;
fc->base.base.alignment, fc->base.size, BYTE_ORDER);
}
+static inline
+int write_bit_array_field(struct fs_sink_stream *stream,
+ struct fs_sink_ctf_field_class_bit_array *fc,
+ const bt_field *field)
+{
+ /*
+ * CTF 1.8 has no bit array field class type, so this component
+ * translates this bit array field to an unsigned integer field.
+ */
+ return bt_ctfser_write_unsigned_int(&stream->ctfser,
+ bt_field_bit_array_get_value_as_integer(field),
+ fc->base.alignment, fc->size, BYTE_ORDER);
+}
+
static inline
int write_int_field(struct fs_sink_stream *stream,
struct fs_sink_ctf_field_class_int *fc, const bt_field *field)
case FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL:
ret = write_bool_field(stream, (void *) fc, field);
break;
+ case FS_SINK_CTF_FIELD_CLASS_TYPE_BIT_ARRAY:
+ ret = write_bit_array_field(stream, (void *) fc, field);
+ break;
case FS_SINK_CTF_FIELD_CLASS_TYPE_INT:
ret = write_int_field(stream, (void *) fc, field);
break;
NULL, NULL, false);
}
+static
+void append_bit_array_field_class(struct ctx *ctx,
+ struct fs_sink_ctf_field_class_bit_array *fc)
+{
+ /*
+ * CTF 1.8 has no bit array field class type, so this component
+ * translates it to an unsigned integer field class with an
+ * hexadecimal base.
+ */
+ append_integer_field_class_from_props(ctx, fc->size,
+ fc->base.alignment, false,
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL,
+ NULL, NULL, false);
+}
+
static
void append_integer_field_class(struct ctx *ctx,
struct fs_sink_ctf_field_class_int *fc)
append_indent(ctx);
g_string_append(ctx->tsdl,
"/* The integer field class below was a trace IR boolean field class. */\n");
+ } else if (fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_BIT_ARRAY) {
+ append_indent(ctx);
+ g_string_append(ctx->tsdl,
+ "/* The integer field class below was a trace IR bit array field class. */\n");
}
append_indent(ctx);
case FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL:
append_bool_field_class(ctx, (void *) fc);
break;
+ case FS_SINK_CTF_FIELD_CLASS_TYPE_BIT_ARRAY:
+ append_bit_array_field_class(ctx, (void *) fc);
+ break;
case FS_SINK_CTF_FIELD_CLASS_TYPE_INT:
append_integer_field_class(ctx, (void *) fc);
break;
return 0;
}
+static inline
+int translate_bit_array_field_class(struct ctx *ctx)
+{
+ struct fs_sink_ctf_field_class_bit_array *fc =
+ fs_sink_ctf_field_class_bit_array_create(
+ cur_path_stack_top(ctx)->ir_fc,
+ cur_path_stack_top(ctx)->index_in_parent);
+
+ BT_ASSERT(fc);
+ append_to_parent_field_class(ctx, (void *) fc);
+ return 0;
+}
+
static inline
int translate_integer_field_class(struct ctx *ctx)
{
case BT_FIELD_CLASS_TYPE_BOOL:
ret = translate_bool_field_class(ctx);
break;
+ case BT_FIELD_CLASS_TYPE_BIT_ARRAY:
+ ret = translate_bit_array_field_class(ctx);
+ break;
case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER:
case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION: