#include <ctype.h>
enum fs_sink_ctf_field_class_type {
+ FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL,
FS_SINK_CTF_FIELD_CLASS_TYPE_INT,
FS_SINK_CTF_FIELD_CLASS_TYPE_FLOAT,
FS_SINK_CTF_FIELD_CLASS_TYPE_STRING,
unsigned int size;
};
+struct fs_sink_ctf_field_class_bool {
+ struct fs_sink_ctf_field_class_bit_array base;
+};
+
struct fs_sink_ctf_field_class_int {
struct fs_sink_ctf_field_class_bit_array base;
bool is_signed;
named_fc->fc = NULL;
}
+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)
+{
+ struct fs_sink_ctf_field_class_bool *fc =
+ g_new0(struct fs_sink_ctf_field_class_bool, 1);
+
+ BT_ASSERT(fc);
+
+ /*
+ * CTF 1.8 has no boolean field class type, so this component
+ * translates it to an 8-bit unsigned integer field class.
+ */
+ _fs_sink_ctf_field_class_bit_array_init((void *) fc,
+ FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL, ir_fc,
+ 8, index_in_parent);
+ return fc;
+}
+
static inline
struct fs_sink_ctf_field_class_int *fs_sink_ctf_field_class_int_create(
const bt_field_class *ir_fc, uint64_t index_in_parent)
BT_ASSERT(fc);
}
+static inline
+void _fs_sink_ctf_field_class_bool_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_int_destroy(
struct fs_sink_ctf_field_class_int *fc)
}
switch (fc->type) {
+ 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_INT:
_fs_sink_ctf_field_class_int_destroy((void *) fc);
break;
int write_field(struct fs_sink_stream *stream,
struct fs_sink_ctf_field_class *fc, const bt_field *field);
+static inline
+int write_bool_field(struct fs_sink_stream *stream,
+ struct fs_sink_ctf_field_class_int *fc, const bt_field *field)
+{
+ /*
+ * CTF 1.8 has no boolean field class type, so this component
+ * translates this boolean field to an 8-bit unsigned integer
+ * field which has the value 0 (false) or 1 (true).
+ */
+ return bt_ctfser_write_unsigned_int(&stream->ctfser,
+ bt_field_bool_get_value(field) ? 1 : 0,
+ fc->base.base.alignment, fc->base.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)
int ret;
switch (fc->type) {
+ case FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL:
+ ret = write_bool_field(stream, (void *) fc, field);
+ break;
case FS_SINK_CTF_FIELD_CLASS_TYPE_INT:
ret = write_int_field(stream, (void *) fc, field);
break;
g_string_append_c(ctx->tsdl, '\n');
}
+static
+void append_bool_field_class(struct ctx *ctx,
+ __attribute__((unused)) struct fs_sink_ctf_field_class_bool *fc)
+{
+ /*
+ * CTF 1.8 has no boolean field class type, so this component
+ * translates it to an 8-bit unsigned integer field class.
+ */
+ append_integer_field_class_from_props(ctx, fc->base.size,
+ fc->base.base.alignment, false,
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
+ NULL, NULL, false);
+}
+
static
void append_integer_field_class(struct ctx *ctx,
struct fs_sink_ctf_field_class_int *fc)
g_string_append_printf(ctx->tsdl, " %s;\n",
var_fc->tag_ref->str);
}
+ } else if (fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL) {
+ append_indent(ctx);
+ g_string_append(ctx->tsdl,
+ "/* The integer field class below was a trace IR boolean field class. */\n");
}
append_indent(ctx);
void append_field_class(struct ctx *ctx, struct fs_sink_ctf_field_class *fc)
{
switch (fc->type) {
+ case FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL:
+ append_bool_field_class(ctx, (void *) fc);
+ break;
case FS_SINK_CTF_FIELD_CLASS_TYPE_INT:
append_integer_field_class(ctx, (void *) fc);
break;
return ret;
}
+static inline
+int translate_bool_field_class(struct ctx *ctx)
+{
+ struct fs_sink_ctf_field_class_bool *fc =
+ fs_sink_ctf_field_class_bool_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)
{
int ret;
switch (bt_field_class_get_type(cur_path_stack_top(ctx)->ir_fc)) {
+ case BT_FIELD_CLASS_TYPE_BOOL:
+ ret = translate_bool_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: