lib: have dedicated "dynamic array FC with/without length field" types
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 10 Oct 2019 15:35:29 +0000 (11:35 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 17 Oct 2019 16:13:27 +0000 (12:13 -0400)
This is to match what is already done for option and variant field
classes: you can know with their type enumerator whether or not they
have a selector and which type it is.

Now, when you pass `NULL` as the length FC to
bt_field_class_array_dynamic_create(), you get a FC with the type
`BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD`. Otherwise
it is `BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD`.

Now you can only call
bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const()
with a FC having the type
`BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD`. The way to know
whether or not the dynamic array FC has a length field path is to check
its type.

In the Python bindings, there are dedicated
`_DynamicArrayWithLengthFieldFieldClass` and
`_DynamicArrayWithLengthFieldFieldClassConst` classes to match the
library changes. The `length_field_path` property is only available in
those.

A `sink.text.details` component now writes

    Dynamic array (no length field)

and

    Dynamic array (with length field)

depending on the dynamic array FC's type.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ibdc0ef1110bf05d517b241ba4f6a9a631ade8a0c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2169
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
24 files changed:
include/babeltrace2/trace-ir/field-class-const.h
src/bindings/python/bt2/bt2/__init__.py
src/bindings/python/bt2/bt2/field.py
src/bindings/python/bt2/bt2/field_class.py
src/bindings/python/bt2/bt2/trace_class.py
src/common/common.h
src/lib/lib-logging.c
src/lib/trace-ir/field-class.c
src/lib/trace-ir/field-class.h
src/lib/trace-ir/field.c
src/lib/trace-ir/field.h
src/lib/trace-ir/resolve-field-path.c
src/plugins/ctf/common/msg-iter/msg-iter.c
src/plugins/ctf/fs-sink/fs-sink-ctf-meta.h
src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c
src/plugins/lttng-utils/debug-info/debug-info.c
src/plugins/lttng-utils/debug-info/trace-ir-data-copy.c
src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c
src/plugins/text/details/write.c
src/plugins/text/pretty/print.c
tests/bindings/python/bt2/test_field_class.py
tests/bindings/python/bt2/test_package.py
tests/data/plugins/src.ctf.fs/succeed/trace-session-rotation.expect
tests/data/plugins/src.ctf.lttng-live/cli-multi-domains.expect

index 3110242daad76f521ddeca615b952af3cb5f37fd..58820f3fa00a319050b9cfded5bf1ecfb70b161d 100644 (file)
@@ -48,14 +48,15 @@ typedef enum bt_field_class_type {
        BT_FIELD_CLASS_TYPE_STRING                                      = 8,
        BT_FIELD_CLASS_TYPE_STRUCTURE                                   = 9,
        BT_FIELD_CLASS_TYPE_STATIC_ARRAY                                = 10,
-       BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY                               = 11,
-       BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR                     = 12,
-       BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR                   = 13,
-       BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR       = 14,
-       BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR         = 15,
-       BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR                    = 16,
-       BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR      = 17,
-       BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR        = 18,
+       BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD          = 11,
+       BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD             = 12,
+       BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR                     = 13,
+       BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR                   = 14,
+       BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR       = 15,
+       BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR         = 16,
+       BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR                    = 17,
+       BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR      = 18,
+       BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR        = 19,
 } bt_field_class_type;
 
 typedef enum bt_field_class_integer_preferred_display_base {
@@ -173,7 +174,7 @@ extern uint64_t bt_field_class_array_static_get_length(
                const bt_field_class *field_class);
 
 extern const bt_field_path *
-bt_field_class_array_dynamic_borrow_length_field_path_const(
+bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
                const bt_field_class *field_class);
 
 extern const bt_field_class *
index 0b7beefa3d364cba62cc03478813f2e2c08e629d..f1c0954b273b5c135d6695493bc20dc60bf9f738 100644 (file)
@@ -105,6 +105,7 @@ from bt2.field_class import _VariantFieldClassWithSignedIntegerSelector
 from bt2.field_class import _ArrayFieldClass
 from bt2.field_class import _StaticArrayFieldClass
 from bt2.field_class import _DynamicArrayFieldClass
+from bt2.field_class import _DynamicArrayWithLengthFieldFieldClass
 from bt2.field_class import _BoolFieldClassConst
 from bt2.field_class import _BitArrayFieldClassConst
 from bt2.field_class import _IntegerFieldClassConst
@@ -130,6 +131,7 @@ from bt2.field_class import _VariantFieldClassWithSignedIntegerSelectorConst
 from bt2.field_class import _ArrayFieldClassConst
 from bt2.field_class import _StaticArrayFieldClassConst
 from bt2.field_class import _DynamicArrayFieldClassConst
+from bt2.field_class import _DynamicArrayWithLengthFieldFieldClassConst
 from bt2.field_path import FieldPathScope
 from bt2.field_path import _IndexFieldPathItem
 from bt2.field_path import _CurrentArrayElementFieldPathItem
index f1a632f38c8495fe28830289fbc55b6202960dfe..7228db92b8f572eef51c4c137fb35ca720f15aca 100644 (file)
@@ -934,7 +934,8 @@ _TYPE_ID_TO_CONST_OBJ = {
     native_bt.FIELD_CLASS_TYPE_STRING: _StringFieldConst,
     native_bt.FIELD_CLASS_TYPE_STRUCTURE: _StructureFieldConst,
     native_bt.FIELD_CLASS_TYPE_STATIC_ARRAY: _StaticArrayFieldConst,
-    native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY: _DynamicArrayFieldConst,
+    native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD: _DynamicArrayFieldConst,
+    native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD: _DynamicArrayFieldConst,
     native_bt.FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR: _OptionFieldConst,
     native_bt.FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR: _OptionFieldConst,
     native_bt.FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR: _OptionFieldConst,
@@ -956,7 +957,8 @@ _TYPE_ID_TO_OBJ = {
     native_bt.FIELD_CLASS_TYPE_STRING: _StringField,
     native_bt.FIELD_CLASS_TYPE_STRUCTURE: _StructureField,
     native_bt.FIELD_CLASS_TYPE_STATIC_ARRAY: _StaticArrayField,
-    native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY: _DynamicArrayField,
+    native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD: _DynamicArrayField,
+    native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD: _DynamicArrayField,
     native_bt.FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR: _OptionField,
     native_bt.FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR: _OptionField,
     native_bt.FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR: _OptionField,
index b7fbfc65eb670d5a687d2a249b82eb2abc6eb66d..6091d24de8130da1261186c61df1c85a4d383a0f 100644 (file)
@@ -982,9 +982,13 @@ class _StaticArrayFieldClass(_StaticArrayFieldClassConst, _ArrayFieldClass):
 class _DynamicArrayFieldClassConst(_ArrayFieldClassConst):
     _NAME = 'Const dynamic array'
 
+
+class _DynamicArrayWithLengthFieldFieldClassConst(_DynamicArrayFieldClassConst):
+    _NAME = 'Const dynamic array (with length field)'
+
     @property
     def length_field_path(self):
-        ptr = native_bt.field_class_array_dynamic_borrow_length_field_path_const(
+        ptr = native_bt.field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
             self._ptr
         )
         if ptr is None:
@@ -997,6 +1001,12 @@ class _DynamicArrayFieldClass(_DynamicArrayFieldClassConst, _ArrayFieldClass):
     _NAME = 'Dynamic array'
 
 
+class _DynamicArrayWithLengthFieldFieldClass(
+    _DynamicArrayWithLengthFieldFieldClassConst, _DynamicArrayFieldClass
+):
+    _NAME = 'Dynamic array (with length field)'
+
+
 _FIELD_CLASS_TYPE_TO_CONST_OBJ = {
     native_bt.FIELD_CLASS_TYPE_BOOL: _BoolFieldClassConst,
     native_bt.FIELD_CLASS_TYPE_BIT_ARRAY: _BitArrayFieldClassConst,
@@ -1009,7 +1019,8 @@ _FIELD_CLASS_TYPE_TO_CONST_OBJ = {
     native_bt.FIELD_CLASS_TYPE_STRING: _StringFieldClassConst,
     native_bt.FIELD_CLASS_TYPE_STRUCTURE: _StructureFieldClassConst,
     native_bt.FIELD_CLASS_TYPE_STATIC_ARRAY: _StaticArrayFieldClassConst,
-    native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY: _DynamicArrayFieldClassConst,
+    native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD: _DynamicArrayFieldClassConst,
+    native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD: _DynamicArrayWithLengthFieldFieldClassConst,
     native_bt.FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR: _OptionFieldClassConst,
     native_bt.FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR: _OptionWithBoolSelectorFieldClassConst,
     native_bt.FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR: _OptionWithUnsignedIntegerSelectorFieldClassConst,
@@ -1031,7 +1042,8 @@ _FIELD_CLASS_TYPE_TO_OBJ = {
     native_bt.FIELD_CLASS_TYPE_STRING: _StringFieldClass,
     native_bt.FIELD_CLASS_TYPE_STRUCTURE: _StructureFieldClass,
     native_bt.FIELD_CLASS_TYPE_STATIC_ARRAY: _StaticArrayFieldClass,
-    native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY: _DynamicArrayFieldClass,
+    native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD: _DynamicArrayFieldClass,
+    native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD: _DynamicArrayWithLengthFieldFieldClass,
     native_bt.FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR: _OptionFieldClass,
     native_bt.FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR: _OptionWithBoolSelectorFieldClass,
     native_bt.FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR: _OptionWithUnsignedIntegerSelectorFieldClass,
index ccf9f48ef519874d12fa0411c3e28565549be58a..615c410a89ba4ebc674615e9c6cd2a42c28fe42c 100644 (file)
@@ -430,7 +430,7 @@ class _TraceClass(_TraceClassConst):
             self._ptr, elem_fc._ptr, length_fc_ptr
         )
         self._check_field_class_create_status(ptr, 'dynamic array')
-        fc = bt2_field_class._DynamicArrayFieldClass._create_from_ptr(ptr)
+        fc = bt2_field_class._create_field_class_from_ptr_and_get_ref(ptr)
         self._set_field_class_user_attrs(fc, user_attributes)
         return fc
 
index dead87927f8522712d5f15d259df6bf2ab88d4e1..bad17b772a098ada59e0118567ae748e32e99043 100644 (file)
@@ -439,8 +439,10 @@ const char *bt_common_field_class_type_string(enum bt_field_class_type class_typ
                return "STRUCTURE";
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
                return "STATIC_ARRAY";
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
-               return "DYNAMIC_ARRAY";
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+               return "DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD";
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
+               return "DYNAMIC_ARRAY_WITH_LENGTH_FIELD";
        case BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR:
                return "OPTION_WITHOUT_SELECTOR";
        case BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR:
index 51682ed86072712ddae7588204d271803457525c..562b7ce463a2413ca9a3e17d0dc157684a00b7b8 100644 (file)
@@ -239,7 +239,8 @@ static inline void format_field_class(char **buf_ch, bool extended,
                BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_fc->length));
                break;
        }
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
        {
                const struct bt_field_class_array_dynamic *array_fc =
                        (const void *) field_class;
@@ -428,7 +429,8 @@ static inline void format_field(char **buf_ch, bool extended,
                break;
        }
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
        {
                const struct bt_field_array *array_field = (const void *) field;
 
index 02e4ab79913add729746b7204609914b3bcd809d..25d5b7e718e964daa73134d00a5ad0a7f8c13bd0 100644 (file)
@@ -2027,7 +2027,9 @@ struct bt_field_class *bt_field_class_array_dynamic_create(
        }
 
        if (init_array_field_class((void *) array_fc,
-                       BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
+                       length_fc ?
+                               BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD :
+                               BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD,
                        destroy_dynamic_array_field_class, element_fc)) {
                goto error;
        }
@@ -2051,13 +2053,14 @@ end:
 }
 
 const struct bt_field_path *
-bt_field_class_array_dynamic_borrow_length_field_path_const(
+bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
                const struct bt_field_class *fc)
 {
        const struct bt_field_class_array_dynamic *seq_fc = (const void *) fc;
 
        BT_ASSERT_PRE_DEV_NON_NULL(fc, "Field class");
-       BT_ASSERT_PRE_DEV_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
+       BT_ASSERT_PRE_DEV_FC_HAS_ID(fc,
+               BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD,
                "Field class");
        return seq_fc->length_field_path;
 }
@@ -2175,7 +2178,8 @@ void bt_field_class_make_part_of_trace_class(const struct bt_field_class *c_fc)
                break;
        }
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
        {
                struct bt_field_class_array *array_fc = (void *) fc;
 
index 3df7b9aa4a9065c1ba3772ad7141f39f44e76105..3fe793249216a922c24205b711f38276e36aa236 100644 (file)
@@ -67,7 +67,8 @@
 
 #define _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc)                           \
        (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY)
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD)
 
 #define _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name)                          \
        _name " is not an array field class: %![fc-]+F"
index e2e77cc7ca6a219dad7820af90d67da9e73c8be6..e074966290254b3ccc2fea8874b0ae8ee8f9028d 100644 (file)
@@ -188,14 +188,15 @@ struct bt_field *(* const field_create_funcs[])(struct bt_field_class *) = {
        [BT_FIELD_CLASS_TYPE_STRING]                                    = create_string_field,
        [BT_FIELD_CLASS_TYPE_STRUCTURE]                                 = create_structure_field,
        [BT_FIELD_CLASS_TYPE_STATIC_ARRAY]                              = create_static_array_field,
-       [BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY]                             = create_dynamic_array_field,
+       [BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD]        = create_dynamic_array_field,
+       [BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD]           = create_dynamic_array_field,
        [BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR]                   = create_option_field,
        [BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR]                 = create_option_field,
        [BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR]     = create_option_field,
        [BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR]       = create_option_field,
        [BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR]                  = create_variant_field,
-       [BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR]            = create_variant_field,
-       [BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR]              = create_variant_field,
+       [BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR]    = create_variant_field,
+       [BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR]      = create_variant_field,
 };
 
 static
@@ -238,14 +239,15 @@ void (* const field_destroy_funcs[])(struct bt_field *) = {
        [BT_FIELD_CLASS_TYPE_STRING]                                    = destroy_string_field,
        [BT_FIELD_CLASS_TYPE_STRUCTURE]                                 = destroy_structure_field,
        [BT_FIELD_CLASS_TYPE_STATIC_ARRAY]                              = destroy_array_field,
-       [BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY]                             = destroy_array_field,
+       [BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD]        = destroy_array_field,
+       [BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD]           = destroy_array_field,
        [BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR]                   = destroy_option_field,
        [BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR]                 = destroy_option_field,
        [BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR]     = destroy_option_field,
        [BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR]       = destroy_option_field,
        [BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR]                  = destroy_variant_field,
-       [BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR]            = destroy_variant_field,
-       [BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR]              = destroy_variant_field,
+       [BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR]    = destroy_variant_field,
+       [BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR]      = destroy_variant_field,
 };
 
 struct bt_field_class *bt_field_borrow_class(struct bt_field *field)
@@ -935,8 +937,7 @@ enum bt_field_array_dynamic_set_length_status bt_field_array_dynamic_set_length(
        struct bt_field_array *array_field = (void *) field;
 
        BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
-               BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(field, "Field");
        BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
 
        if (G_UNLIKELY(length > array_field->fields->len)) {
index d6fe2bce53f77fc19abadec27d3ebe6448b75328..2352baadbf33f36a0f31b96e9ad63d7adca79173 100644 (file)
 #define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(_field, _name)                        \
        BT_ASSERT_PRE_DEV(                                              \
                ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY, \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \
                _name " is not an array field: %![field-]+f", (_field))
 
+#define BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(_field, _name)                        \
+       BT_ASSERT_PRE_DEV(                                              \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \
+               _name " is not a dynamic array field: %![field-]+f", (_field))
+
 #define BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(_field, _name)               \
        BT_ASSERT_PRE_DEV(                                              \
                ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR || \
index 47da398684587bbb703c770798849343bfa303fc..a1415efb355d7ca1b591826ca0b154eb31159d52 100644 (file)
@@ -98,7 +98,8 @@ bool find_field_class_recursive(struct bt_field_class *fc,
                break;
        }
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
        {
                struct bt_field_class_array *array_fc = (void *) fc;
                struct bt_field_path_item item = {
@@ -289,7 +290,8 @@ struct bt_field_class *borrow_child_field_class(
                break;
        }
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
        {
                struct bt_field_class_array *array_fc = (void *) parent_fc;
 
@@ -328,7 +330,8 @@ bool target_field_path_in_different_scope_has_struct_fc_only(
                                tgt_field_path, i);
 
                if (fc->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY ||
-                               fc->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY ||
+                               fc->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD ||
+                               fc->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD ||
                                fc->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR ||
                                fc->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR ||
                                fc->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR ||
@@ -451,7 +454,8 @@ bool lca_to_target_has_struct_fc_only(struct bt_field_path *src_field_path,
                                tgt_field_path, tgt_i);
 
                if (tgt_fc->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY ||
-                               tgt_fc->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY ||
+                               tgt_fc->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD ||
+                               tgt_fc->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD ||
                                tgt_fc->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR ||
                                tgt_fc->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR ||
                                tgt_fc->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR ||
@@ -574,30 +578,28 @@ int bt_resolve_field_paths(struct bt_field_class *fc,
        {
                struct bt_field_class_option_with_selector *opt_fc = (void *) fc;
 
-               if (opt_fc->selector_fc) {
-                       BT_ASSERT(!opt_fc->selector_field_path);
-                       opt_fc->selector_field_path = resolve_field_path(
-                               fc, opt_fc->selector_fc, ctx);
-                       if (!opt_fc->selector_field_path) {
-                               ret = -1;
-                               goto end;
-                       }
+               BT_ASSERT(opt_fc->selector_fc);
+               BT_ASSERT(!opt_fc->selector_field_path);
+               opt_fc->selector_field_path = resolve_field_path(
+                       fc, opt_fc->selector_fc, ctx);
+               if (!opt_fc->selector_field_path) {
+                       ret = -1;
+                       goto end;
                }
 
                break;
        }
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
        {
                struct bt_field_class_array_dynamic *dyn_array_fc = (void *) fc;
 
-               if (dyn_array_fc->length_fc) {
-                       BT_ASSERT(!dyn_array_fc->length_field_path);
-                       dyn_array_fc->length_field_path = resolve_field_path(
-                               fc, dyn_array_fc->length_fc, ctx);
-                       if (!dyn_array_fc->length_field_path) {
-                               ret = -1;
-                               goto end;
-                       }
+               BT_ASSERT(dyn_array_fc->length_fc);
+               BT_ASSERT(!dyn_array_fc->length_field_path);
+               dyn_array_fc->length_field_path = resolve_field_path(
+                       fc, dyn_array_fc->length_fc, ctx);
+               if (!dyn_array_fc->length_field_path) {
+                       ret = -1;
+                       goto end;
                }
 
                break;
@@ -657,7 +659,8 @@ int bt_resolve_field_paths(struct bt_field_class *fc,
                break;
        }
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
        {
                struct bt_field_class_array *array_fc = (void *) fc;
 
index fa2e8f360bae3ac1f247e72b0a9f8a24ab7fda10..e0d1f4fa85e1c9e2845658a4dee801b35ffd60ac 100644 (file)
@@ -1857,7 +1857,8 @@ bt_field *borrow_next_field(struct bt_msg_iter *notit)
                break;
        }
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
                BT_ASSERT(index < bt_field_array_get_length(base_field));
                next_field = bt_field_array_borrow_element_field_by_index(
                        base_field, index);
@@ -2350,7 +2351,9 @@ int64_t bfcr_get_sequence_length_cb(struct ctf_field_class *fc, void *data)
         */
        if (!seq_fc->base.is_text) {
                BT_ASSERT(bt_field_get_class_type(seq_field) ==
-                       BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY);
+                       BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD ||
+                       bt_field_get_class_type(seq_field) ==
+                       BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD);
                ret = bt_field_array_dynamic_set_length(seq_field,
                        (uint64_t) length);
                if (ret) {
index 81a74ffd5d0b334b2c448d3e8744df13a644ddd2..d525faa8a914361054a332e1b0b452f607a70750 100644 (file)
@@ -410,8 +410,8 @@ struct fs_sink_ctf_field_class_sequence *fs_sink_ctf_field_class_sequence_create
        fc->length_ref = g_string_new(NULL);
        BT_ASSERT(fc->length_ref);
        fc->length_is_before =
-               bt_field_class_array_dynamic_borrow_length_field_path_const(ir_fc) ==
-               NULL;
+               bt_field_class_get_type(ir_fc) ==
+                       BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD;
        return fc;
 }
 
index 90f98e613c805e8e17fbb31e8ddb9b42b7d2d956..ce38ef64528572ec9aee095160324952ec740ab5 100644 (file)
@@ -1202,10 +1202,13 @@ int translate_dynamic_array_field_class(struct ctx *ctx)
        BT_ASSERT(fc);
 
        /* Resolve length field class before appending to parent */
-       resolve_field_class(ctx,
-               bt_field_class_array_dynamic_borrow_length_field_path_const(
-                       fc->base.base.ir_fc),
-               fc->length_ref, &fc->length_is_before, NULL);
+       if (bt_field_class_get_type(cur_path_stack_top(ctx)->ir_fc) ==
+                       BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) {
+               resolve_field_class(ctx,
+                       bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
+                               fc->base.base.ir_fc),
+                       fc->length_ref, &fc->length_is_before, NULL);
+       }
 
        append_to_parent_field_class(ctx, (void *) fc);
        ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, false, elem_ir_fc,
@@ -1331,7 +1334,8 @@ int translate_field_class(struct ctx *ctx)
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
                ret = translate_static_array_field_class(ctx);
                break;
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
                ret = translate_dynamic_array_field_class(ctx);
                break;
        case BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR:
index 044d4f245124cbaf1c13821733cdc18b5a09b9c1..9f1be4bf35ae5645d133c68f0d4e809f787d07d6 100644 (file)
@@ -379,7 +379,9 @@ int event_get_payload_build_id_length(const bt_event *event,
        build_id_field_class = bt_field_borrow_class_const(build_id_field);
 
        BT_ASSERT(bt_field_class_get_type(build_id_field_class) ==
-               BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY);
+               BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD ||
+               bt_field_class_get_type(build_id_field_class) ==
+               BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD);
        BT_ASSERT(bt_field_class_get_type(
                bt_field_class_array_borrow_element_field_class_const(
                        build_id_field_class)) ==
@@ -405,7 +407,9 @@ int event_get_payload_build_id_value(const bt_event *event,
        build_id_field_class = bt_field_borrow_class_const(build_id_field);
 
        BT_ASSERT(bt_field_class_get_type(build_id_field_class) ==
-               BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY);
+               BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD ||
+               bt_field_class_get_type(build_id_field_class) ==
+               BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD);
        BT_ASSERT(bt_field_class_get_type(
                bt_field_class_array_borrow_element_field_class_const(
                        build_id_field_class)) ==
index c106d059f387db5657358d742f34ec565a5335f1..6990c0404eb034672a7777fa42b34bb424a61088 100644 (file)
@@ -305,7 +305,8 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field,
                }
                break;
        }
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
                /* fall through */
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
        {
@@ -316,7 +317,8 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field,
 
                array_len = bt_field_array_get_length(in_field);
 
-               if (in_fc_type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY) {
+               if (in_fc_type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD ||
+                               in_fc_type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) {
                        set_len_status = bt_field_array_dynamic_set_length(
                                out_field, array_len);
                        if (set_len_status !=
index 60903dd661ff8c54a14ba285109a54271f6c987b..2ca790292e6d09eb5caaaa7fec440c2930829337 100644 (file)
@@ -101,7 +101,8 @@ const bt_field_class *walk_field_path(struct trace_ir_metadata_maps *md_maps,
                        break;
                }
                case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
-               case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+               case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+               case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
                {
                        BT_ASSERT(bt_field_path_item_get_type(fp_item) ==
                                BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT);
@@ -716,24 +717,25 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps *
                        out_elem_fc, array_len);
                break;
        }
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
        {
                const bt_field_class *in_elem_fc =
                        bt_field_class_array_borrow_element_field_class_const(
                                        in_field_class);
-               const bt_field_path *length_fp =
-                       bt_field_class_array_dynamic_borrow_length_field_path_const(
-                               in_field_class);
                bt_field_class *out_length_fc = NULL;
-
                bt_field_class *out_elem_fc = copy_field_class_array_element(
                        md_maps, in_elem_fc);
+
                if (!out_elem_fc) {
                        out_field_class = NULL;
                        goto error;
                }
 
-               if (length_fp) {
+               if (fc_type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) {
+                       const bt_field_path *length_fp =
+                               bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
+                                       in_field_class);
                        const bt_field_class *in_length_fc =
                                resolve_field_path_to_field_class(length_fp,
                                        md_maps);
@@ -938,7 +940,8 @@ int copy_field_class_content_internal(
                ret = field_class_static_array_copy(md_maps,
                                in_field_class, out_field_class);
                break;
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
                ret = field_class_dynamic_array_copy(md_maps,
                                in_field_class, out_field_class);
                break;
index 49b7b3145044a2f65a3c71fa1816c42aed447fc4..7431be658bf90da71bf6beeadc8141d5040a0216 100644 (file)
@@ -946,8 +946,11 @@ void write_field_class(struct details_write_ctx *ctx, const bt_field_class *fc)
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
                type = "Static array";
                break;
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
-               type = "Dynamic array";
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+               type = "Dynamic array (no length field)";
+               break;
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
+               type = "Dynamic array (with length field)";
                break;
        case BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR:
                type = "Option (no selector)";
@@ -1010,22 +1013,21 @@ void write_field_class(struct details_write_ctx *ctx, const bt_field_class *fc)
                break;
        }
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
                if (fc_type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY) {
                        g_string_append(ctx->str, " (Length ");
                        write_uint_prop_value(ctx,
                                bt_field_class_array_static_get_length(fc));
                        g_string_append_c(ctx->str, ')');
-               } else {
+               } else if (fc_type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) {
                        const bt_field_path *length_field_path =
-                               bt_field_class_array_dynamic_borrow_length_field_path_const(
+                               bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
                                        fc);
 
-                       if (length_field_path) {
-                               g_string_append(ctx->str, " (Length field path ");
-                               write_field_path(ctx, length_field_path);
-                               g_string_append_c(ctx->str, ')');
-                       }
+                       g_string_append(ctx->str, " (Length field path ");
+                       write_field_path(ctx, length_field_path);
+                       g_string_append_c(ctx->str, ')');
                }
 
                break;
@@ -1172,7 +1174,8 @@ void write_field_class(struct details_write_ctx *ctx, const bt_field_class *fc)
                break;
        }
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
                if (wrote_user_attrs) {
                        write_nl(ctx);
                } else {
@@ -1940,7 +1943,8 @@ void write_field(struct details_write_ctx *ctx, const bt_field *field,
                break;
        }
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
        {
                uint64_t length = bt_field_array_get_length(field);
 
index 5d03c5727744fb280be3adccaee84dbae095d5c5..78e8fdbbf49e835dba5be21ab96f8fde849c20df 100644 (file)
@@ -1070,7 +1070,8 @@ int print_field(struct pretty_component *pretty,
                return print_variant(pretty, field, print_names);
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
                return print_array(pretty, field, print_names);
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
                return print_sequence(pretty, field, print_names);
        default:
                // TODO: log instead
index d980548f675aeee04dd8736a5f75ccca1943d8d9..be4a71f1f8065c9742f7e66b2f00fa3144a09d4f 100644 (file)
@@ -1307,6 +1307,8 @@ class _ArrayFieldClassTestCase:
             type(fc.element_field_class), bt2_field_class._SignedIntegerFieldClass
         )
 
+
+class _ArrayFieldClassConstTestCase:
     def test_const_attr_element_field_class(self):
         fc = self._create_const_array()
         self.assertIs(
@@ -1314,7 +1316,9 @@ class _ArrayFieldClassTestCase:
         )
 
 
-class StaticArrayFieldClassTestCase(_ArrayFieldClassTestCase, unittest.TestCase):
+class StaticArrayFieldClassTestCase(
+    _ArrayFieldClassTestCase, _ArrayFieldClassConstTestCase, unittest.TestCase
+):
     @staticmethod
     def _const_value_setter(field):
         field.value = [9] * 45
@@ -1353,7 +1357,9 @@ class StaticArrayFieldClassTestCase(_ArrayFieldClassTestCase, unittest.TestCase)
             )
 
 
-class DynamicArrayFieldClassTestCase(_ArrayFieldClassTestCase, unittest.TestCase):
+class DynamicArrayFieldClassTestCase(
+    _ArrayFieldClassTestCase, _ArrayFieldClassConstTestCase, unittest.TestCase
+):
     @staticmethod
     def _const_value_setter(field):
         field.value = []
@@ -1368,11 +1374,35 @@ class DynamicArrayFieldClassTestCase(_ArrayFieldClassTestCase, unittest.TestCase
     def setUp(self):
         self._tc = get_default_trace_class()
         self._elem_fc = self._tc.create_signed_integer_field_class(23)
-        self._len_fc = self._tc.create_unsigned_integer_field_class(12)
 
     def test_create_default(self):
         fc = self._tc.create_dynamic_array_field_class(self._elem_fc)
         self.assertEqual(fc.element_field_class.addr, self._elem_fc.addr)
+        self.assertEqual(len(fc.user_attributes), 0)
+
+    def test_create_invalid_field_class(self):
+        with self.assertRaises(TypeError):
+            self._tc.create_dynamic_array_field_class(object())
+
+
+class DynamicArrayWithLengthFieldFieldClassTestCase(
+    _ArrayFieldClassTestCase, unittest.TestCase
+):
+    @staticmethod
+    def _const_value_setter(field):
+        field.value = []
+
+    def _create_array(self):
+        return self._tc.create_dynamic_array_field_class(self._elem_fc, self._len_fc)
+
+    def setUp(self):
+        self._tc = get_default_trace_class()
+        self._elem_fc = self._tc.create_signed_integer_field_class(23)
+        self._len_fc = self._tc.create_unsigned_integer_field_class(12)
+
+    def test_create_default(self):
+        fc = self._create_array()
+        self.assertEqual(fc.element_field_class.addr, self._elem_fc.addr)
         self.assertIsNone(fc.length_field_path, None)
         self.assertEqual(len(fc.user_attributes), 0)
 
@@ -1389,7 +1419,7 @@ class DynamicArrayFieldClassTestCase(_ArrayFieldClassTestCase, unittest.TestCase
         #   } inner_struct[2];
         # };
 
-        fc = self._tc.create_dynamic_array_field_class(self._elem_fc, self._len_fc)
+        fc = self._create_array()
 
         foo_fc = self._tc.create_single_precision_real_field_class()
         bar_fc = self._tc.create_string_field_class()
@@ -1441,10 +1471,6 @@ class DynamicArrayFieldClassTestCase(_ArrayFieldClassTestCase, unittest.TestCase
             fc.length_field_path.root_scope, bt2.FieldPathScope.PACKET_CONTEXT
         )
 
-    def test_create_invalid_field_class(self):
-        with self.assertRaises(TypeError):
-            self._tc.create_dynamic_array_field_class(object())
-
     def test_create_invalid_length_type(self):
         with self.assertRaises(TypeError):
             self._tc.create_dynamic_array_field_class(
index 6d8f91d1841c17e7e64834b71dbcd0b01358c6a3..36a9f8e6c404b25b93463ff8dddf4345c4617827 100644 (file)
@@ -56,6 +56,8 @@ _public_names = [
     '_DynamicArrayFieldClass',
     '_DynamicArrayFieldClassConst',
     '_DynamicArrayFieldConst',
+    '_DynamicArrayWithLengthFieldFieldClass',
+    '_DynamicArrayWithLengthFieldFieldClassConst',
     '_EnumerationField',
     '_EnumerationFieldClass',
     '_EnumerationFieldClassConst',
index 28032e7239b0dac805a98c2a1cf54e0f559e3214..20a0f9db1b546e571711857928547c1935632b5a 100644 (file)
@@ -35,7 +35,7 @@ Trace class:
       Payload field class: Structure (3 members):
         baddr: Unsigned integer (64-bit, Base 16)
         _build_id_length: Unsigned integer (64-bit, Base 10)
-        build_id: Dynamic array (Length field path [Event payload: 1]):
+        build_id: Dynamic array (with length field) (Length field path [Event payload: 1]):
           Element: Unsigned integer (8-bit, Base 16)
     Event class `lttng_ust_statedump:debug_link` (ID 3):
       Log level: Debug (line)
@@ -59,7 +59,7 @@ Trace class:
       Payload field class: Structure (3 members):
         baddr: Unsigned integer (64-bit, Base 16)
         _build_id_length: Unsigned integer (64-bit, Base 10)
-        build_id: Dynamic array (Length field path [Event payload: 1]):
+        build_id: Dynamic array (with length field) (Length field path [Event payload: 1]):
           Element: Unsigned integer (8-bit, Base 16)
     Event class `lttng_ust_lib:debug_link` (ID 7):
       Log level: Debug (line)
@@ -216,15 +216,15 @@ Trace class:
           Element: Signed integer (64-bit, Base 16)
         arrfield2: String
         _seqfield1_length: Unsigned integer (64-bit, Base 10)
-        seqfield1: Dynamic array (Length field path [Event payload: 11]):
+        seqfield1: Dynamic array (with length field) (Length field path [Event payload: 11]):
           Element: Signed integer (8-bit, Base 10)
         _seqfield1_hex_length: Unsigned integer (64-bit, Base 10)
-        seqfield1_hex: Dynamic array (Length field path [Event payload: 13]):
+        seqfield1_hex: Dynamic array (with length field) (Length field path [Event payload: 13]):
           Element: Signed integer (8-bit, Base 16)
         _seqfield2_length: Unsigned integer (64-bit, Base 10)
         seqfield2: String
         _seqfield_network_3_length: Unsigned integer (64-bit, Base 10)
-        seqfield_network_3: Dynamic array (Length field path [Event payload: 17]):
+        seqfield_network_3: Dynamic array (with length field) (Length field path [Event payload: 17]):
           Element: Signed integer (64-bit, Base 10)
         stringfield: String
         floatfield: Single-precision real
@@ -347,7 +347,7 @@ Trace class:
       Payload field class: Structure (3 members):
         baddr: Unsigned integer (64-bit, Base 16)
         _build_id_length: Unsigned integer (64-bit, Base 10)
-        build_id: Dynamic array (Length field path [Event payload: 1]):
+        build_id: Dynamic array (with length field) (Length field path [Event payload: 1]):
           Element: Unsigned integer (8-bit, Base 16)
     Event class `lttng_ust_statedump:debug_link` (ID 3):
       Log level: Debug (line)
@@ -371,7 +371,7 @@ Trace class:
       Payload field class: Structure (3 members):
         baddr: Unsigned integer (64-bit, Base 16)
         _build_id_length: Unsigned integer (64-bit, Base 10)
-        build_id: Dynamic array (Length field path [Event payload: 1]):
+        build_id: Dynamic array (with length field) (Length field path [Event payload: 1]):
           Element: Unsigned integer (8-bit, Base 16)
     Event class `lttng_ust_lib:debug_link` (ID 7):
       Log level: Debug (line)
@@ -528,15 +528,15 @@ Trace class:
           Element: Signed integer (64-bit, Base 16)
         arrfield2: String
         _seqfield1_length: Unsigned integer (64-bit, Base 10)
-        seqfield1: Dynamic array (Length field path [Event payload: 11]):
+        seqfield1: Dynamic array (with length field) (Length field path [Event payload: 11]):
           Element: Signed integer (8-bit, Base 10)
         _seqfield1_hex_length: Unsigned integer (64-bit, Base 10)
-        seqfield1_hex: Dynamic array (Length field path [Event payload: 13]):
+        seqfield1_hex: Dynamic array (with length field) (Length field path [Event payload: 13]):
           Element: Signed integer (8-bit, Base 16)
         _seqfield2_length: Unsigned integer (64-bit, Base 10)
         seqfield2: String
         _seqfield_network_3_length: Unsigned integer (64-bit, Base 10)
-        seqfield_network_3: Dynamic array (Length field path [Event payload: 17]):
+        seqfield_network_3: Dynamic array (with length field) (Length field path [Event payload: 17]):
           Element: Signed integer (64-bit, Base 10)
         stringfield: String
         floatfield: Single-precision real
index 8763733242cf711715010d58f1a0d1c815526e03..e54486c3020b23abd0c4f7eab2f30523a96d28fb 100644 (file)
@@ -162,21 +162,21 @@ Trace class:
         arrfield3: Static array (Length 3):
           Element: Unsigned integer (32-bit, Base 10)
         _seqfield1_length: Unsigned integer (64-bit, Base 10)
-        seqfield1: Dynamic array (Length field path [Event payload: 8]):
+        seqfield1: Dynamic array (with length field) (Length field path [Event payload: 8]):
           Element: Signed integer (8-bit, Base 10)
         _seqfield2_length: Unsigned integer (64-bit, Base 10)
         seqfield2: String
         _seqfield3_length: Unsigned integer (64-bit, Base 10)
-        seqfield3: Dynamic array (Length field path [Event payload: 12]):
+        seqfield3: Dynamic array (with length field) (Length field path [Event payload: 12]):
           Element: Unsigned integer (32-bit, Base 10)
         _seqfield4_length: Unsigned integer (64-bit, Base 10)
-        seqfield4: Dynamic array (Length field path [Event payload: 14]):
+        seqfield4: Dynamic array (with length field) (Length field path [Event payload: 14]):
           Element: Signed integer (64-bit, Base 10)
         stringfield: String
         stringfield2: String
         _bitfield_seq_length: Unsigned integer (8-bit, Base 10)
         bitfield_seq_padding: Structure (0 members)
-        bitfield_seq: Dynamic array (Length field path [Event payload: 18]):
+        bitfield_seq: Dynamic array (with length field) (Length field path [Event payload: 18]):
           Element: Unsigned integer (1-bit, Base 10)
         bitfield_array_padding: Structure (0 members)
         bitfield_array: Static array (Length 192):
This page took 0.046736 seconds and 4 git commands to generate.