X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=src%2Fplugins%2Fctf%2Ffs-sink%2Ftranslate-ctf-ir-to-tsdl.c;h=85f6bee7e51b27c02c6a6ef5f3b220a8a94ad345;hp=2fa7c0fdadfb84ed8eeea5eb47cc983d767b3dfa;hb=0235b0db7de5bcacdb3650c92461f2ce5eb2143d;hpb=c25f8e53dc25a23d21d3e54a171b4c2dee0bd7eb diff --git a/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.c b/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.c index 2fa7c0fd..85f6bee7 100644 --- a/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.c +++ b/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.c @@ -1,25 +1,11 @@ /* - * Copyright 2019 Philippe Proulx - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * Copyright 2019 Philippe Proulx */ +#include "translate-ctf-ir-to-tsdl.h" + #include #include "common/macros.h" #include @@ -136,7 +122,7 @@ void append_integer_field_class_from_props(struct ctx *ctx, unsigned int size, g_string_append(ctx->tsdl, "x"); break; default: - abort(); + bt_common_abort(); } g_string_append_c(ctx->tsdl, ';'); @@ -195,17 +181,31 @@ void append_bool_field_class(struct ctx *ctx, 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) { const bt_field_class *ir_fc = fc->base.base.ir_fc; bt_field_class_type type = bt_field_class_get_type(ir_fc); - bool is_signed = type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION || - type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER; + bool is_signed = bt_field_class_type_is(type, + BT_FIELD_CLASS_TYPE_SIGNED_INTEGER); - if (type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || - type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) { + if (bt_field_class_type_is(type, BT_FIELD_CLASS_TYPE_ENUMERATION)) { g_string_append(ctx->tsdl, "enum : "); } @@ -214,8 +214,7 @@ void append_integer_field_class(struct ctx *ctx, bt_field_class_integer_get_preferred_display_base(ir_fc), NULL, NULL, false); - if (type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || - type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) { + if (bt_field_class_type_is(type, BT_FIELD_CLASS_TYPE_ENUMERATION)) { uint64_t i; g_string_append(ctx->tsdl, " {\n"); @@ -319,7 +318,8 @@ void append_float_field_class(struct ctx *ctx, { unsigned int mant_dig, exp_dig; - if (bt_field_class_real_is_single_precision(fc->base.base.ir_fc)) { + if (bt_field_class_get_type(fc->base.base.ir_fc) == + BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL) { mant_dig = 24; exp_dig = 8; } else { @@ -467,14 +467,14 @@ void append_struct_field_class_members(struct ctx *ctx, ctx->indent_level++; for (i = 0; i < var_fc->options->len; i++) { - struct fs_sink_ctf_named_field_class *named_fc = + struct fs_sink_ctf_named_field_class *option_named_fc = fs_sink_ctf_field_class_variant_borrow_option_by_index( var_fc, i); append_indent(ctx); g_string_append_printf(ctx->tsdl, "\"%s\" = %" PRIu64 ",\n", - named_fc->name->str, i); + option_named_fc->name->str, i); } append_end_block(ctx); @@ -485,6 +485,10 @@ void append_struct_field_class_members(struct ctx *ctx, 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); @@ -547,6 +551,9 @@ void append_field_class(struct ctx *ctx, struct fs_sink_ctf_field_class *fc) 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; @@ -566,7 +573,7 @@ void append_field_class(struct ctx *ctx, struct fs_sink_ctf_field_class *fc) append_variant_field_class(ctx, (void *) fc); break; default: - abort(); + bt_common_abort(); } } @@ -660,7 +667,7 @@ void append_event_class(struct ctx *ctx, struct fs_sink_ctf_event_class *ec) level = 14; break; default: - abort(); + bt_common_abort(); } g_string_append_printf(ctx->tsdl, "%u;\n", level); @@ -953,7 +960,7 @@ void translate_trace_ctf_ir_to_tsdl(struct fs_sink_ctf_trace *trace, * This is checked in * translate_trace_trace_ir_to_ctf_ir(). */ - abort(); + bt_common_abort(); } g_string_append(tsdl, ";\n");