lib: add field location-related functions
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 23 May 2024 20:22:52 +0000 (16:22 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 4 Sep 2024 19:05:14 +0000 (15:05 -0400)
For each API function accepting a bt_field_class to refer to a length or
selector field, to create a variant, dynamic array or option field
class, add one or more equivalent ones accepting a bt_field_location.
For symmetry between the various field classes, go with separate
functions for "with" and "without" length/selector field locations,
rather than having one function that can take a NULL field location.

Add functions to borrow a field location from a variant, option or
dynamic array field class.

All the new functions have preconditions to require MIP version >= 1.
All the old functions dealing with field paths have preconditions to
require MIP version == 0.

Philippe updated the documentation.

Variants
--------

The existing bt_field_class_variant_create function deduces the type of
variant (without selector, with unsigned int selector, with signed int
selector) by looking at the selector field class' type.  This is not
possible by looking at a selector field location, since the field
class(es) the field location points to is/are not known at this time.
So, introduce three new functions to create a variant field class
(without, with unsigned, with signed).

Dynamic arrays
--------------

For symmetry with the other field classes, go with two separate
functions for with a length field location and without a length field
location, rather than a single function that can accept a NULL field
location.

Options
-------

For consistency in the naming with the other field classes, add the
bt_field_class_option_without_selector_field_location_create function.
It is functionally equivalent to the existing
bt_field_class_option_without_selector_create function.  Add three other
functions to match the three existing ones (with bool, with unsigned,
with signed).

Change-Id: Ib2df27fedc9aab3fefee3bd6d4dfb41fc359654b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7302
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7208

doc/api/libbabeltrace2/Doxyfile.in
include/babeltrace2/trace-ir/field-class.h
include/babeltrace2/trace-ir/field-location.h
src/lib/assert-cond.h
src/lib/lib-logging.c
src/lib/trace-ir/field-class.c
src/lib/trace-ir/field-class.h
src/lib/trace-ir/resolve-field-path.c

index 283f7a1cd6fa1edb7dff449c2137bc4d9e568095..638c0e3c9aca7165568011139c0789e3fcef3a6f 100644 (file)
@@ -67,17 +67,17 @@ ALIASES                += bt_pre_is_struct_fc{1}="@pre \bt_p{\1} is a \link api-
 ALIASES                += bt_pre_is_array_fc{1}="@pre \bt_p{\1} is an array \link api-tir-fc-array field class\endlink."
 ALIASES                += bt_pre_is_sarray_fc{1}="@pre \bt_p{\1} is a static \link api-tir-fc-array array field class\endlink."
 ALIASES                += bt_pre_is_darray_fc{1}="@pre \bt_p{\1} is a dynamic \link api-tir-fc-array array field class\endlink."
-ALIASES                += bt_pre_is_darray_wl_fc{1}="@pre \bt_p{\1} is a dynamic \link api-tir-fc-array array field class\endlink (with a length field)."
+ALIASES                += bt_pre_is_darray_wl_fc{1}="@pre \bt_p{\1} is a dynamic \link api-tir-fc-array array field class\endlink (instances with a linked length field)."
 ALIASES                += bt_pre_is_opt_fc{1}="@pre \bt_p{\1} is an \link api-tir-fc-opt option field class\endlink."
-ALIASES                += bt_pre_is_opt_ws_fc{1}="@pre \bt_p{\1} is an \link api-tir-fc-opt option field class\endlink (with a selector field)."
-ALIASES                += bt_pre_is_opt_wbs_fc{1}="@pre \bt_p{\1} is an \link api-tir-fc-opt option field class\endlink (with a boolean selector field)."
-ALIASES                += bt_pre_is_opt_wsis_fc{1}="@pre \bt_p{\1} is an \link api-tir-fc-opt option field class\endlink (with a signed integer selector field)."
-ALIASES                += bt_pre_is_opt_wuis_fc{1}="@pre \bt_p{\1} is an \link api-tir-fc-opt option field class\endlink (with an unsigned integer selector field)."
+ALIASES                += bt_pre_is_opt_ws_fc{1}="@pre \bt_p{\1} is an \link api-tir-fc-opt option field class\endlink (instances with a linked selector field)."
+ALIASES                += bt_pre_is_opt_wbs_fc{1}="@pre \bt_p{\1} is an \link api-tir-fc-opt option field class\endlink (instances with a linked boolean selector field)."
+ALIASES                += bt_pre_is_opt_wsis_fc{1}="@pre \bt_p{\1} is an \link api-tir-fc-opt option field class\endlink (instances with a linked signed integer selector field)."
+ALIASES                += bt_pre_is_opt_wuis_fc{1}="@pre \bt_p{\1} is an \link api-tir-fc-opt option field class\endlink (instances with a linked unsigned integer selector field)."
 ALIASES                += bt_pre_is_var_fc{1}="@pre \bt_p{\1} is a \link api-tir-fc-var variant field class\endlink."
-ALIASES                += bt_pre_is_var_wos_fc{1}="@pre \bt_p{\1} is a \link api-tir-fc-var variant field class\endlink (without a selector field)."
-ALIASES                += bt_pre_is_var_ws_fc{1}="@pre \bt_p{\1} is a \link api-tir-fc-var variant field class\endlink (with a selector field)."
-ALIASES                += bt_pre_is_var_wuis_fc{1}="@pre \bt_p{\1} is a \link api-tir-fc-var variant field class\endlink (with an unsigned integer selector field)."
-ALIASES                += bt_pre_is_var_wsis_fc{1}="@pre \bt_p{\1} is a \link api-tir-fc-var variant field class\endlink (with a signed integer selector field)."
+ALIASES                += bt_pre_is_var_wos_fc{1}="@pre \bt_p{\1} is a \link api-tir-fc-var variant field class\endlink (instances without a linked selector field)."
+ALIASES                += bt_pre_is_var_ws_fc{1}="@pre \bt_p{\1} is a \link api-tir-fc-var variant field class\endlink (instances with a linked selector field)."
+ALIASES                += bt_pre_is_var_wuis_fc{1}="@pre \bt_p{\1} is a \link api-tir-fc-var variant field class\endlink (instances with a linked unsigned integer selector field)."
+ALIASES                += bt_pre_is_var_wsis_fc{1}="@pre \bt_p{\1} is a \link api-tir-fc-var variant field class\endlink (instances with a linked signed integer selector field)."
 
 # Aliases: preconditions: field object type
 ALIASES                += bt_pre_is_ba_field{1}="@pre \bt_p{\1} is a \link api-tir-field-ba bit array field\endlink."
@@ -96,8 +96,8 @@ ALIASES                += bt_pre_is_sarray_field{1}="@pre \bt_p{\1} is a static
 ALIASES                += bt_pre_is_darray_field{1}="@pre \bt_p{\1} is a dynamic \link api-tir-field-array array field\endlink."
 ALIASES                += bt_pre_is_opt_field{1}="@pre \bt_p{\1} is an \link api-tir-field-opt option field\endlink."
 ALIASES                += bt_pre_is_var_field{1}="@pre \bt_p{\1} is a \link api-tir-field-var variant field\endlink."
-ALIASES                += bt_pre_is_var_wuis_field{1}="@pre \bt_p{\1} is a \link api-tir-field-var variant field\endlink (with an unsigned integer selector field)."
-ALIASES                += bt_pre_is_var_wsis_field{1}="@pre \bt_p{\1} is a \link api-tir-field-var variant field\endlink (with a signed integer selector field)."
+ALIASES                += bt_pre_is_var_wuis_field{1}="@pre \bt_p{\1} is a \link api-tir-field-var variant field\endlink (instances with a linked unsigned integer selector field)."
+ALIASES                += bt_pre_is_var_wsis_field{1}="@pre \bt_p{\1} is a \link api-tir-field-var variant field\endlink (instances with a linked signed integer selector field)."
 
 # Aliases: preconditions: value object type
 ALIASES                += bt_pre_is_null_val{1}="@pre \bt_p{\1} is a null \link api-val value\endlink (\bt_p{\1} is equal to #bt_value_null)."
index 869f8e2ec2846ce891ad1b57be1f40fcb49d3e0c..5d49edc5ca9ae3406f0d574361b6719bbe72cd46 100644 (file)
@@ -110,7 +110,7 @@ functions for each type of \em concrete (non-abstract) field class:
   <tr>
     <th>Name
     <th>Type enumerator
-    <th>Creation function
+    <th>Creation function(s)
   <tr>
     <td><em>\ref api-tir-fc-bool "Boolean"</em>
     <td>#BT_FIELD_CLASS_TYPE_BOOL
@@ -152,45 +152,81 @@ functions for each type of \em concrete (non-abstract) field class:
     <td>#BT_FIELD_CLASS_TYPE_STATIC_ARRAY
     <td>bt_field_class_array_static_create()
   <tr>
-    <td><em>Dynamic \ref api-tir-fc-array "array" (no length field)</em>
+    <td>
+      <em>Dynamic \ref api-tir-fc-array "array"
+      (instances without a linked length field)</em>
     <td>#BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD
-    <td>bt_field_class_array_dynamic_create()
+    <td>
+      - bt_field_class_array_dynamic_create()
+      - bt_field_class_array_dynamic_without_length_field_location_create()
   <tr>
-    <td><em>Dynamic \ref api-tir-fc-array "array" (with length field)</em>
+    <td>
+      <em>Dynamic \ref api-tir-fc-array "array"
+      (instances with a linked length field)</em>
     <td>#BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD
-    <td>bt_field_class_array_dynamic_create()
+    <td>
+      - bt_field_class_array_dynamic_create()
+      - bt_field_class_array_dynamic_with_length_field_location_create()
   <tr>
     <td><em>\ref api-tir-fc-struct "Structure"</em>
     <td>#BT_FIELD_CLASS_TYPE_STRUCTURE
     <td>bt_field_class_structure_create()
   <tr>
-    <td><em>\ref api-tir-fc-opt "Option" (no selector field)</em>
+    <td>
+      <em>\ref api-tir-fc-opt "Option"
+      (instances without a linked selector field)</em>
     <td>#BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD
-    <td>bt_field_class_option_without_selector_create()
+    <td>
+      - bt_field_class_option_without_selector_create()
+      - bt_field_class_option_without_selector_field_location_create()
   <tr>
-    <td><em>\ref api-tir-fc-opt "Option" (boolean selector field)</em>
+    <td>
+      <em>\ref api-tir-fc-opt "Option"
+      (instances with a linked boolean selector field)</em>
     <td>#BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD
-    <td>bt_field_class_option_with_selector_field_bool_create()
+    <td>
+      - bt_field_class_option_with_selector_field_bool_create()
+      - bt_field_class_option_with_selector_field_location_bool_create()
   <tr>
-    <td><em>\ref api-tir-fc-opt "Option" (unsigned integer selector field)</em>
+    <td>
+      <em>\ref api-tir-fc-opt "Option"
+      (instances with a linked unsigned integer selector field)</em>
     <td>#BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD
-    <td>bt_field_class_option_with_selector_field_integer_unsigned_create()
+    <td>
+      - bt_field_class_option_with_selector_field_integer_unsigned_create()
+      - bt_field_class_option_with_selector_field_location_integer_unsigned_create()
   <tr>
-    <td><em>\ref api-tir-fc-opt "Option" (signed integer selector field)</em>
+    <td>
+      <em>\ref api-tir-fc-opt "Option"
+      (instances with a linked signed integer selector field)</em>
     <td>#BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD
-    <td>bt_field_class_option_with_selector_field_integer_signed_create()
+    <td>
+      - bt_field_class_option_with_selector_field_integer_signed_create()
+      - bt_field_class_option_with_selector_field_location_integer_signed_create()
   <tr>
-    <td><em>\ref api-tir-fc-var "Variant" (no selector field)</em>
+    <td>
+      <em>\ref api-tir-fc-var "Variant"
+      (instances without a linked selector field)</em>
     <td>#BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD
-    <td>bt_field_class_variant_create()
+    <td>
+      - bt_field_class_variant_create()
+      - bt_field_class_variant_without_selector_field_location_create()
   <tr>
-    <td><em>\ref api-tir-fc-var "Variant" (unsigned integer selector field)</em>
+    <td>
+      <em>\ref api-tir-fc-var "Variant"
+      (instances with a linked unsigned integer selector field)</em>
     <td>#BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD
-    <td>bt_field_class_variant_create()
+    <td>
+      - bt_field_class_variant_create()
+      - bt_field_class_variant_with_selector_field_location_integer_unsigned_create()
   <tr>
-    <td><em>\ref api-tir-fc-var "Variant" (signed integer selector field)</em>
+    <td>
+      <em>\ref api-tir-fc-var "Variant"
+      (instances with a linked signed integer selector field)</em>
     <td>#BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD
-    <td>bt_field_class_variant_create()
+    <td>
+      - bt_field_class_variant_create()
+      - bt_field_class_variant_with_selector_field_location_integer_signed_create()
 </table>
 
 You need a \bt_trace_cls to create a field class: create one from a
@@ -219,9 +255,10 @@ When you call one of the four functions above:
   with the passed field class or with any of its contained field
   classes.
 
-- If any of the field classes recursively contained in the passed
-  field class has a \ref api-tir-fc-link "link to another field class",
-  it must honor the field class link rules.
+- If an instance of any of the field classes recursively contained in
+  the passed field class has a
+  \ref api-tir-fc-link "link to an anterior field", it must
+  honor the field link rules.
 
 Once you have called one of the four functions above, the passed field
 class becomes \ref api-fund-freezing "frozen".
@@ -555,32 +592,59 @@ one. The concrete array field classes are:
 
   <dt>Dynamic array field class</dt>
   <dd>
-    Its instances (dynamic array fields) contain a variable number array
+    Its instances (dynamic array fields) contain a variable number
     of fields.
 
-    There are two types of dynamic array field classes: without or
-    with a length field. See
-    \ref api-tir-fc-link "Field classes with links to other field classes"
+    There are two types of dynamic array field classes: instances
+    without or with a linked length field. See
+    \ref api-tir-fc-link "Fields with links to other fields"
     to learn more.
 
-    @image html darray-link.png "Dynamic array field class with a length field."
+    @image html darray-link.png "A dynamic array field linked to an unsigned integer length field."
+
+    Create with, depending on the effective \bt_mip (MIP) version of the
+    trace processing \bt_graph:
+
+    <dl>
+      <dt>MIP&nbsp;0</dt>
+      <dd>bt_field_class_array_dynamic_create().</dt>
 
-    Create with bt_field_class_array_dynamic_create().
+      <dt>MIP&nbsp;1</dt>
+      <dd>
+        bt_field_class_array_dynamic_without_length_field_location_create()
+        or
+        bt_field_class_array_dynamic_with_length_field_location_create().
+      </dd>
+    </dl>
 
-    A dynamic array field class with a length field has the
-    specific property:
+    The class of a dynamic array field with a linked length field has
+    one of the following specific properties, depending on the
+    effective MIP version of the trace processing graph:
 
     <dl>
       <dt>
         \anchor api-tir-fc-darray-prop-len-fp
-        Length field path
+        MIP&nbsp;0: Length field path
       </dt>
       <dd>
-        Field path of the linked length field class.
+        \bt_c_field_path to locate the linked length field of
+        an instance.
 
-        Get a dynamic array field class's length field path with
+        Borrow a dynamic array field class's length field path with
         bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const().
       </dd>
+
+      <dt>
+        \anchor api-tir-fc-darray-prop-len-fl
+        MIP&nbsp;1: Length field location
+      </dt>
+      <dd>
+        \bt_c_field_loc to locate the linked length field of an
+        instance.
+
+        Borrow a dynamic array field class's length field location with
+        bt_field_class_array_dynamic_with_length_field_borrow_length_field_location_const().
+      </dd>
     </dl>
   </dd>
 </dl>
@@ -600,7 +664,7 @@ Array field classes have the following common property:
     is created.
 
     Borrow an array field class's element field class with
-    Use bt_field_class_array_borrow_element_field_class() and
+    bt_field_class_array_borrow_element_field_class() and
     bt_field_class_array_borrow_element_field_class_const().
   </dd>
 </dl>
@@ -679,38 +743,51 @@ A structure field class has the following specific property:
 <strong><em>Option field classes</em></strong> are classes
 of \bt_p_opt_field.
 
-An option field either does or doesn't contain a field, called its
+An option field either does or doesn't \em contain a field, called its
 optional field.
 
 An option field class is an \em abstract field class: you cannot create
-one. An option field class either has a selector field (it's linked to a
-selector field class; see
-\ref api-tir-fc-link "Field classes with links to other field classes")
+one. An instance of an option field class either has a linked selector
+field (see \ref api-tir-fc-link "Fields with links to other fields")
 or none. Therefore, the concrete option field classes are:
 
 <dl>
-  <dt>Option field class without a selector field</dt>
+  <dt>Option field class (instances without a linked selector field)</dt>
   <dd>
-    Create with bt_field_class_option_without_selector_create().
+    Create with, depending on the effective \bt_mip (MIP) version
+    of the trace processing \bt_graph:
+
+    <dl>
+      <dt>MIP&nbsp;0</dt>
+      <dd>bt_field_class_option_without_selector_create()</dt>
 
-    An option field class without a selector field has no specific
-    properties.
+      <dt>MIP&nbsp;1</dt>
+      <dd>bt_field_class_option_without_selector_field_location_create()</dd>
+    </dl>
+
+    The class of an option field without a linked selector field has no
+    specific properties.
   </dd>
 
-  <dt>Option field class with a boolean selector field</dt>
+  <dt>Option field class (instances with a linked boolean selector field)</dt>
   <dd>
     The linked selector field of an option field class's instance
     (an option field) is a \bt_bool_field.
 
-    Consequently, the option field class's selector field class is
-    a \bt_bool_fc.
-
     @image html opt-link.png "Option field class with a boolean selector field."
 
-    Create with bt_field_class_option_with_selector_field_bool_create().
+    Create with, depending on the effective \bt_mip (MIP) version:
+
+    <dl>
+      <dt>MIP&nbsp;0</dt>
+      <dd>bt_field_class_option_with_selector_field_bool_create()</dt>
+
+      <dt>MIP&nbsp;1</dt>
+      <dd>bt_field_class_option_with_selector_field_location_bool_create()</dd>
+    </dl>
 
-    An option field class with a boolean selector field has the
-    following specific property:
+    The class of an option field with a linked boolean selector field
+    has the following specific property:
 
     <dl>
       <dt>
@@ -718,9 +795,9 @@ or none. Therefore, the concrete option field classes are:
         Selector is reversed?
       </dt>
       <dd>
-        Whether or not the linked boolean selector field makes the
-        option field class's instance (an option field) contain a field
-        when it's #BT_TRUE or when it's #BT_FALSE.
+        Whether or not the linked boolean selector field make the
+        option field class's instance (an option field) \em contain a
+        field when it's #BT_TRUE or when it's #BT_FALSE.
 
         If this property is #BT_TRUE, then if the linked selector field
         has the value #BT_FALSE, the option field contains a field.
@@ -733,22 +810,27 @@ or none. Therefore, the concrete option field classes are:
     </dl>
   </dd>
 
-  <dt>Option field class with an unsigned selector field</dt>
+  <dt>Option field class (instances with a linked unsigned integer selector field)</dt>
   <dd>
     The linked selector field of an option field class's instance
     (an option field) is an \bt_uint_field.
 
-    Consequently, the option field class's selector field class is
-    an \bt_uint_fc.
+    Create with, depending on the effective \bt_mip (MIP) version
+    of the trace processing \bt_graph:
+
+    <dl>
+      <dt>MIP&nbsp;0</dt>
+      <dd>bt_field_class_option_with_selector_field_integer_unsigned_create()</dt>
 
-    Create with
-    bt_field_class_option_with_selector_field_integer_unsigned_create().
+      <dt>MIP&nbsp;1</dt>
+      <dd>bt_field_class_option_with_selector_field_location_integer_unsigned_create()</dd>
+    </dl>
 
     Pass an \bt_uint_rs on creation to set which values of the selector
     field can make the option field contain a field.
 
-    An option field class with an unsigned integer selector field has
-    the following specific property:
+    The class of an option field with a linked unsigned integer selector
+    field has the following specific property:
 
     <dl>
       <dt>
@@ -759,34 +841,39 @@ or none. Therefore, the concrete option field classes are:
         If the linked unsigned integer selector field of an option
         field class's instance (an option field) has a value which
         intersects with the selector's unsigned integer ranges, then
-        the option field contains a field.
+        the option field \em contains a field.
 
         You cannot change the selector's unsigned integer ranges once
         the option field class is created.
 
-        Borrow the selector's unsigned integer ranges from an
-        option field class with an unsigned integer selector field with
+        Borrow the selector's unsigned integer ranges from such an
+        option field class with
         bt_field_class_option_with_selector_field_integer_unsigned_borrow_selector_ranges_const().
       </dd>
     </dl>
   </dd>
 
-  <dt>Option field class with a signed selector field</dt>
+  <dt>Option field class (instances with a linked signed integer selector field)</dt>
   <dd>
     The linked selector field of an option field class's instance
     (an option field) is a \bt_sint_field.
 
-    Consequently, the option field class's selector field class is
-    a \bt_sint_fc.
+    Create with, depending on the effective \bt_mip (MIP) version of
+    the trace processing \bt_graph:
+
+    <dl>
+      <dt>MIP&nbsp;0</dt>
+      <dd>bt_field_class_option_with_selector_field_integer_signed_create()</dt>
 
-    Create with
-    bt_field_class_option_with_selector_field_integer_signed_create().
+      <dt>MIP&nbsp;1</dt>
+      <dd>bt_field_class_option_with_selector_field_location_integer_signed_create()</dd>
+    </dl>
 
     Pass a \bt_sint_rs on creation to set which values of the selector
     field can make the option field contain a field.
 
-    An option field class with a signed integer selector field has
-    the following specific property:
+    The class of an option field class with a linked signed integer
+    selector field has the following specific property:
 
     <dl>
       <dt>
@@ -797,33 +884,45 @@ or none. Therefore, the concrete option field classes are:
         If the linked signed integer selector field of an option
         field class's instance (an option field) has a value which
         intersects with the selector's signed integer ranges, then
-        the option field contains a field.
+        the option field \em contains a field.
 
         You cannot change the selector's signed integer ranges once
         the option field class is created.
 
-        Borrow the selector's signed integer ranges from an
-        option field class with a signed integer selector field with
+        Borrow the selector's signed integer ranges from such an
+        option field class with
         bt_field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_const().
       </dd>
     </dl>
   </dd>
 </dl>
 
-Option field classes with a selector have the following common
-property:
+The classes of option fields with a linked selector field have one of
+the following common properties, depending on the effective
+\bt_mip (MIP) version of the trace processing \bt_graph:
 
 <dl>
   <dt>
     \anchor api-tir-fc-opt-prop-sel-fp
-    Selector field path
+    MIP&nbsp;0: Selector field path
   </dt>
   <dd>
-    Field path of the linked selector field class.
+    \bt_c_field_path to locate the linked selector field of an instance.
 
     Borrow such an option field class's selector field path with
     bt_field_class_option_with_selector_field_borrow_selector_field_path_const().
   </dd>
+
+  <dt>
+    \anchor api-tir-fc-opt-prop-sel-fl
+    MIP&nbsp;1: Selector field location
+  </dt>
+  <dd>
+    \bt_c_field_loc to locate the linked selector field of an instance.
+
+    Borrow such an option field class's selector field location with
+    bt_field_class_option_with_selector_field_borrow_selector_field_location_const().
+  </dd>
 </dl>
 
 Option field classes have the following common property:
@@ -841,7 +940,7 @@ Option field classes have the following common property:
     class is created.
 
     Borrow an option field class's optional field class with
-    Use bt_field_class_option_borrow_field_class() and
+    bt_field_class_option_borrow_field_class() and
     bt_field_class_option_borrow_field_class_const().
   </dd>
 </dl>
@@ -860,36 +959,54 @@ class option has a name, a field class, user attributes, and integer
 ranges, depending on the exact type.
 
 A variant field class is an \em abstract field class: you cannot create
-one. A variant field class either has a selector field (it's linked to a
-selector field class; see
-\ref api-tir-fc-link "Field classes with links to other field classes")
+one. An instance of a variant field class either has a linked selector
+field (see \ref api-tir-fc-link "Fields with links to other fields")
 or none. Therefore, the concrete variant field classes are:
 
 <dl>
-  <dt>Variant field class without a selector field</dt>
+  <dt>Variant field class (instances without a linked selector field)</dt>
   <dd>
-    Create with bt_field_class_variant_create(), passing \c NULL as
-    the selector field class.
+    Create with, depending on the effective \bt_mip (MIP) version
+    of the trace processing \bt_graph:
+
+    <dl>
+      <dt>MIP&nbsp;0</dt>
+      <dd>
+        bt_field_class_variant_create(), passing \c NULL as
+        the selector field class.
+      </dt>
+
+      <dt>MIP&nbsp;1</dt>
+      <dd>bt_field_class_variant_without_selector_field_location_create().</dd>
+    </dl>
 
     Append an option to such a variant field class with
     bt_field_class_variant_without_selector_append_option().
 
-    A variant field class without a selector field has no specific
-    properties.
+    The class of a variant field without a linked selector field has no
+    specific properties.
   </dd>
 
-  <dt>Variant field class with an unsigned selector field</dt>
+  <dt>Variant field class (instances with a linked unsigned selector field)</dt>
   <dd>
     The linked selector field of a variant field class's instance
     (a variant field) is an \bt_uint_field.
 
-    Consequently, the variant field class's selector field class is
-    an \bt_uint_fc.
+    @image html var-link.png "A variant field linked to an unsigned integer selector field."
+
+    Create with, depending on the effective \bt_mip (MIP) version of the
+    trace processing \bt_graph:
 
-    @image html var-link.png "Variant field class with an unsigned integer selector field."
+    <dl>
+      <dt>MIP&nbsp;0</dt>
+      <dd>
+        bt_field_class_variant_create(), passing an unsigned integer
+        field class as the selector field class.
+      </dt>
 
-    Create with bt_field_class_variant_create(), passing an
-    unsigned integer field class as the selector field class.
+      <dt>MIP&nbsp;1</dt>
+      <dd>bt_field_class_variant_with_selector_field_location_integer_unsigned_create().</dd>
+    </dl>
 
     Append an option to such a variant field class with
     bt_field_class_variant_with_selector_field_integer_unsigned_append_option().
@@ -904,16 +1021,24 @@ or none. Therefore, the concrete variant field classes are:
     bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_name_const().
   </dd>
 
-  <dt>Variant field class with a signed selector field</dt>
+  <dt>Variant field class (instances with a linked signed selector field)</dt>
   <dd>
     The linked selector field of a variant field class's instance
     (a variant field) is a \bt_sint_field.
 
-    Consequently, the variant field class's selector field class is
-    a \bt_sint_fc.
+    Create with, depending on the effective \bt_mip (MIP) version of the
+    trace processing \bt_graph:
+
+    <dl>
+      <dt>MIP&nbsp;0</dt>
+      <dd>
+        bt_field_class_variant_create(), passing an signed integer
+        field class as the selector field class.
+      </dt>
 
-    Create with bt_field_class_variant_create(), passing a
-    signed integer field class as the selector field class.
+      <dt>MIP&nbsp;1</dt>
+      <dd>bt_field_class_variant_with_selector_field_location_integer_signed_create().</dd>
+    </dl>
 
     Append an option to such a variant field class with
     bt_field_class_variant_with_selector_field_integer_signed_append_option().
@@ -929,20 +1054,32 @@ or none. Therefore, the concrete variant field classes are:
   </dd>
 </dl>
 
-Variant field classes with a selector have the following common
-property:
+The classes of variant fields with a linked selector field have one of
+the following common properties, depending on the effective
+\bt_mip (MIP) version of the trace processing \bt_graph:
 
 <dl>
   <dt>
     \anchor api-tir-fc-var-prop-sel-fp
-    Selector field path
+    MIP&nbsp;0: Selector field path
   </dt>
   <dd>
-    Field path of the linked selector field class.
+    \bt_c_field_path to locate the linked selector field of an instance.
 
     Borrow such a variant field class's selector field path with
     bt_field_class_variant_with_selector_field_borrow_selector_field_path_const().
   </dd>
+
+  <dt>
+    \anchor api-tir-fc-var-prop-sel-fl
+    MIP&nbsp;1: Selector field location
+  </dt>
+  <dd>
+    \bt_c_field_loc to locate the linked selector field of an instance.
+
+    Borrow such a variant field class's selector field location with
+    bt_field_class_variant_with_selector_field_borrow_selector_field_location_const().
+  </dd>
 </dl>
 
 Variant field classes have the following common property:
@@ -962,15 +1099,16 @@ Variant field classes have the following common property:
     - A field class.
     - User attributes.
 
-    If the variant field class is linked to a selector field class, then
-    each option also has an \bt_int_rs. In that case, the ranges of a
-    given option cannot overlap any range of any other option.
+    If an instance of the variant field class is linked to a selector
+    field, then each option also has an \bt_int_rs. In that case, the
+    ranges of a given option cannot overlap any range of any other
+    option.
 
     A variant field class must contain at least one option.
 
-    Depending on whether or not the variant field class has a selector
-    field class, append an option to a variant field class
-    with bt_field_class_variant_without_selector_append_option(),
+    Depending on whether or not an instance of the variant field class
+    has a linked selector field, append an option to a variant field
+    class with bt_field_class_variant_without_selector_append_option(),
     bt_field_class_variant_with_selector_field_integer_unsigned_append_option(),
     or
     bt_field_class_variant_with_selector_field_integer_signed_append_option().
@@ -995,8 +1133,8 @@ Variant field classes have the following common property:
     bt_field_class_variant_option_borrow_field_class() and
     bt_field_class_variant_option_borrow_field_class_const().
 
-    Borrow the option of a variant field classes with a selector field
-    class with
+    Borrow the option of the class of a variant field with a linked
+    selector field with
     bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const(),
     bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_name_const(),
     bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const(), or
@@ -1012,8 +1150,8 @@ Variant field classes have the following common property:
     or
     bt_field_class_variant_with_selector_field_integer_signed_option_as_option_const().
 
-    Borrow the option's ranges from a variant field class with a
-    selector field class with
+    Borrow the option's ranges from the class of a variant field with a
+    linked selector field with
     bt_field_class_variant_with_selector_field_integer_unsigned_option_borrow_ranges_const()
     or
     bt_field_class_variant_with_selector_field_integer_signed_option_borrow_ranges_const().
@@ -1027,16 +1165,14 @@ Variant field classes have the following common property:
   </dd>
 </dl>
 
-<h1>\anchor api-tir-fc-link Field classes with links to other field classes</h1>
-
-\bt_cp_darray_fc, \bt_p_opt_fc, and \bt_p_var_fc \em can have links to
-other, preceding field classes.
+<h1>\anchor api-tir-fc-link Fields with links to other fields</h1>
 
-When a field class&nbsp;A has a link to another field class&nbsp;B, then
-an instance (\bt_field) of A has a link to an instance of B.
+An instance of a \bt_darray_fc, a \bt_opt_fc, or a \bt_var_fc \em may
+have a link to another, anterior field within the same \bt_pkt or
+\bt_ev.
 
 This feature exists so that the linked field can contain the value of a
-dynamic property of the field. Those properties are:
+dynamic property of the "dependent" field. Those properties are:
 
 <dl>
   <dt>\bt_c_darray_field</dt>
@@ -1058,122 +1194,176 @@ dynamic property of the field. Those properties are:
   </dd>
 </dl>
 
-Having a linked field class is <em>optional</em>: you always set the
-field properties with a dedicated function anyway. For example, even if
-a dynamic array field is linked to a preceding length field, you must
-still set its length with bt_field_array_dynamic_set_length(). In that
-case, the value of the length field must match what you pass to
-bt_field_array_dynamic_set_length().
+Having a linked field is <em>optional</em>: you always set the field
+properties with a dedicated function anyway. For example, even if a
+dynamic array field is linked to an anterior length field, you must
+still set its integral length with bt_field_array_dynamic_set_length().
+In that case, the value of the linked length field \em must match what
+you pass to bt_field_array_dynamic_set_length().
 
 The purpose of this feature is to eventually save space when a
-\bt_sink_comp writes trace files: if the trace format can convey that
-a preceding, existing field represents the length of a dynamic array
-field, then the sink component doesn't need to write the dynamic array
-field's length twice. This is the case of the
-<a href="https://diamon.org/ctf/">Common Trace Format</a>, for
-example.
-
-@image html darray-link.png "A dynamic array field class linked to an unsigned integer field class."
-
-To link a field class&nbsp;A to a preceding field class&nbsp;B, pass
-field class&nbsp;B when you create field class&nbsp;A. For example, pass
-the \bt_uint_fc to bt_field_class_array_dynamic_create() to create a
-\bt_darray_fc with a length field.
-
-When you call bt_stream_class_set_packet_context_field_class(),
-bt_stream_class_set_event_common_context_field_class(),
-bt_event_class_set_specific_context_field_class(), or
-bt_event_class_set_payload_field_class() with a field class containing
-a field class&nbsp;A with a linked field class&nbsp;B, the path to
-B becomes available in A. The functions to borrow this field path are:
-
-- bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const()
-- bt_field_class_option_with_selector_field_borrow_selector_field_path_const()
-- bt_field_class_variant_with_selector_field_borrow_selector_field_path_const()
-
-A field path indicates how to reach a linked field from a given
-root <em>scope</em>. The available scopes are:
+\bt_sink_comp writes trace files: if, for example, the trace format can
+convey that an anterior, existing field represents the length of a
+dynamic array field, then the sink component doesn't need to write the
+dynamic array field's length twice. This is the case of the
+<a href="https://diamon.org/ctf/">Common Trace Format</a>, for example.
+
+@image html darray-link.png "A dynamic array field linked to an unsigned integer length field."
+
+How exactly you link a dependent field to another field at the field
+class level depends on the effective \bt_mip (MIP) version of the trace
+processing \bt_graph:
+
+<dl>
+  <dt>MIP&nbsp;0: \bt_c_field_path API
+  <dd>
+    Pass the class of the linked field when you create the class of the
+    dependent field.
+
+    For example, pass the unsigned integer length field class to
+    bt_field_class_array_dynamic_create() to create a class of
+    \bt_darray_field with a linked length field.
+
+    Then, when you call
+    bt_stream_class_set_packet_context_field_class(),
+    bt_stream_class_set_event_common_context_field_class(),
+    bt_event_class_set_specific_context_field_class(), or
+    bt_event_class_set_payload_field_class() with a field class
+    containing a dependent field class with the class a linked field,
+    the path to the linked field becomes available in the dependent
+    field class. The functions to borrow said field path are:
+
+    - bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const()
+    - bt_field_class_option_with_selector_field_borrow_selector_field_path_const()
+    - bt_field_class_variant_with_selector_field_borrow_selector_field_path_const()
+  </dd>
+
+  <dt>MIP&nbsp;1: \bt_c_field_loc API
+  <dd>
+    Pass the field location when you create the class of the
+    dependent field.
+
+    For example, pass the length field location to
+    bt_field_class_array_dynamic_with_length_field_location_create() to
+    create a class of \bt_darray_field with a linked length field.
+
+    The functions to borrow the field location of a field class are:
+
+    - bt_field_class_array_dynamic_with_length_field_borrow_length_field_location_const()
+    - bt_field_class_option_with_selector_field_borrow_selector_field_location_const()
+    - bt_field_class_variant_with_selector_field_borrow_selector_field_location_const()
+  </dd>
+</dl>
+
+Both \bt_p_field_path (MIP&nbsp;0 API) and \bt_p_field_loc (MIP&nbsp;1
+API) indicate how to reach the linked field of a dependent field from
+some specific root <em>scope</em> (the starting point). The available
+scopes are:
 
 <dl>
   <dt>#BT_FIELD_PATH_SCOPE_PACKET_CONTEXT</dt>
+  <dt>#BT_FIELD_LOCATION_SCOPE_PACKET_CONTEXT</dt>
   <dd>
-    Packet context field.
+    Context field of the current \bt_pkt.
 
     See bt_packet_borrow_context_field_const().
   </dd>
 
   <dt>#BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT</dt>
+  <dt>#BT_FIELD_LOCATION_SCOPE_EVENT_COMMON_CONTEXT</dt>
   <dd>
-    Event common context field.
+    Common context field of the current \bt_ev.
 
     See bt_event_borrow_common_context_field_const().
   </dd>
 
   <dt>#BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT</dt>
+  <dt>#BT_FIELD_LOCATION_SCOPE_EVENT_SPECIFIC_CONTEXT</dt>
   <dd>
-    Event specific context field.
+    Specific context field of the current event.
 
     See bt_event_borrow_specific_context_field_const().
   </dd>
 
   <dt>#BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD</dt>
+  <dt>#BT_FIELD_LOCATION_SCOPE_EVENT_PAYLOAD</dt>
   <dd>
-    Event payload field.
+    Payload field of the current event.
 
     See bt_event_borrow_payload_field_const().
   </dd>
 </dl>
 
-The rules regarding field class&nbsp;A vs. field class&nbsp;B (linked
-field class) are:
+The difference between a field path and a field location is that a field
+path works with \bt_struct_field member \em indexes while a field
+location works with structure field member <em>names</em>. The latter is
+more versatile because many fields may be candidates for the
+length/selector field of a dependent field (when they're all part of the
+same \bt_var_field).
 
-- If A is within a packet context field class, B must also be in the
-  same packet context field class.
+The rules regarding the dependent field&nbsp;\bt_var{A} vs. the linked
+field&nbsp;\bt_var{B} are:
+
+- If \bt_var{A} is within some packet context field, then \bt_var{B}
+  must also be in the same packet context field.
 
   See bt_stream_class_set_packet_context_field_class().
 
-- If A is within a event common context field class, B must be in one
-  of:
+- If \bt_var{A} is within some common event context field, then
+  \bt_var{B} must be in one of:
 
-  - The same event common context field class.
-  - The packet context field class of the same \bt_stream_cls.
+  - The same common event context field.
+  - The context field of the same packet.
 
   See bt_stream_class_set_event_common_context_field_class().
 
-- If A is within an event specific context field class, B must be in
-  one of:
+- If \bt_var{A} is within some specific event context field, then
+  \bt_var{B} must be in one of:
 
-  - The same event specific context field class.
-  - The event common context field class of the same stream class.
-  - The packet context field class of the same stream class.
+  - The same specific event context field.
+  - The common context field of the same event.
+  - The context field of the same packet.
 
   See bt_event_class_set_specific_context_field_class().
 
-- If A is within an event payload field class, B must be in one of:
+- If \bt_var{A} is within some event payload field, then \bt_var{B} must
+  be in one of:
 
-  - The same event payload field class.
-  - The event specific context field class of the same \bt_ev_cls.
-  - The event common context field class of the same stream class.
-  - The packet context field class of the same stream class.
+  - The same event payload field.
+  - The specific context field of the same event.
+  - The common context field of the same event.
+  - The context field of the same packet.
 
   See bt_event_class_set_payload_field_class().
 
-- If both A and B are in the same scope, then:
+- If both \bt_var{A} and \bt_var{B} are in the same scope, then:
+
+  - The lowest common ancestor field of \bt_var{A} and \bt_var{B} must
+    be a structure field.
+
+  - \bt_var{B} must precede \bt_var{A}.
+
+    Considering that the members of a structure field are ordered,
+    then \bt_var{B} must be part of a member that's before the member
+    which contains \bt_var{A} in their lowest common ancestor
+    structure field.
 
-  - The lowest common ancestor field class of A and B must be a
-    \bt_struct_fc.
+  - <strong>Under MIP&nbsp;0</strong>, the path from the lowest common
+    ancestor structure field of \bt_var{A} and \bt_var{B} to \bt_var{A}
+    and to \bt_var{B} must only contain structure fields.
 
-  - B must precede A.
+  - <strong>Under MIP&nbsp;1</strong>, the path from the lowest common
+    ancestor structure field of \bt_var{A} and \bt_var{B} to \bt_var{A}
+    and to \bt_var{B} must only contain structure and variant fields.
 
-    Considering that the members of a structure field class are ordered,
-    then B must be part of a member that's before the member which
-    contains A in their lowest common ancestor structure field class.
+- If \bt_var{A} is in a different scope than \bt_var{B}, then:
 
-  - The path from the lowest common ancestor structure field class of A
-    and B to A and to B must only contain structure field classes.
+  - <strong>Under MIP&nbsp;0</strong>, the path from the root scope of
+    \bt_var{B} to \bt_var{B} must only contain structure fields.
 
-- If A is in a different scope than B, the path from the root scope of B
-  to B must only contain structure field classes.
+  - <strong>Under MIP&nbsp;1</strong>, the path from the root scope of
+    \bt_var{B} to \bt_var{B} must only contain structure and variant
+    fields.
 */
 
 /*! @{ */
@@ -1333,7 +1523,7 @@ typedef enum bt_field_class_type {
 
        /*!
        @brief
-           \bt_c_darray_fc (without a length field).
+           \bt_c_darray_fc (instances without a linked length field).
 
        This type conceptually inherits
        #BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY.
@@ -1342,7 +1532,7 @@ typedef enum bt_field_class_type {
 
        /*!
        @brief
-           \bt_c_darray_fc (with a length field).
+           \bt_c_darray_fc (instances with a linked length field).
 
        This type conceptually inherits
        #BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY.
@@ -1360,13 +1550,13 @@ typedef enum bt_field_class_type {
 
        /*!
        @brief
-           \bt_c_opt_fc (without a selector field).
+           \bt_c_opt_fc (instances without a linked selector field).
        */
        BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD                       = (1ULL << 17) | BT_FIELD_CLASS_TYPE_OPTION,
 
        /*!
        @brief
-           \bt_c_opt_fc (with a selector field).
+           \bt_c_opt_fc (instances with a linked selector field).
 
        This type conceptually inherits #BT_FIELD_CLASS_TYPE_OPTION.
 
@@ -1377,7 +1567,7 @@ typedef enum bt_field_class_type {
 
        /*!
        @brief
-           \bt_c_opt_fc (with a boolean selector field).
+           \bt_c_opt_fc (instances with a linked boolean selector field).
 
        This type conceptually inherits
        #BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD.
@@ -1386,7 +1576,7 @@ typedef enum bt_field_class_type {
 
        /*!
        @brief
-           \bt_c_opt_fc (with an integer selector field).
+           \bt_c_opt_fc (instances with a linked integer selector field).
 
        This type conceptually inherits
        #BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD.
@@ -1398,7 +1588,7 @@ typedef enum bt_field_class_type {
 
        /*!
        @brief
-           \bt_c_opt_fc (with an unsigned integer selector field).
+           \bt_c_opt_fc (instances with a linked unsigned integer selector field).
 
        This type conceptually inherits
        #BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD.
@@ -1407,7 +1597,7 @@ typedef enum bt_field_class_type {
 
        /*!
        @brief
-           \bt_c_opt_fc (with a signed integer selector field).
+           \bt_c_opt_fc (instances with a linked signed integer selector field).
 
        This type conceptually inherits
        #BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD.
@@ -1425,13 +1615,13 @@ typedef enum bt_field_class_type {
 
        /*!
        @brief
-           \bt_c_var_fc (without a selector field).
+           \bt_c_var_fc (instances without a linked selector field).
        */
        BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD                      = (1ULL << 24) | BT_FIELD_CLASS_TYPE_VARIANT,
 
        /*!
        @brief
-           \bt_c_var_fc (with a selector field).
+           \bt_c_var_fc (instances with a linked selector field).
 
        This type conceptually inherits
        #BT_FIELD_CLASS_TYPE_VARIANT.
@@ -1443,7 +1633,7 @@ typedef enum bt_field_class_type {
 
        /*!
        @brief
-           \bt_c_var_fc (with an integer selector field).
+           \bt_c_var_fc (instances with a linked integer selector field).
 
        This type conceptually inherits
        #BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD.
@@ -1455,7 +1645,7 @@ typedef enum bt_field_class_type {
 
        /*!
        @brief
-           \bt_c_opt_fc (with an unsigned integer selector field).
+           \bt_c_opt_fc (instances with a linked unsigned integer selector field).
 
        This type conceptually inherits
        #BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD.
@@ -1464,7 +1654,7 @@ typedef enum bt_field_class_type {
 
        /*!
        @brief
-           \bt_c_opt_fc (with a signed integer selector field).
+           \bt_c_opt_fc (instances with a linked signed integer selector field).
 
        This type conceptually inherits
        #BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD.
@@ -2786,7 +2976,7 @@ property values:
 
 @bt_pre_not_null{trace_class}
 @bt_pre_not_null{element_field_class}
-bt_pre_fc_not_in_tc{element_field_class}
+@bt_pre_fc_not_in_tc{element_field_class}
 
 @bt_post_success_frozen{element_field_class}
 */
@@ -2825,10 +3015,22 @@ extern uint64_t bt_field_class_array_static_get_length(
     Creates a \bt_darray_fc having the element field class
     \bt_p{element_field_class} from the trace class \bt_p{trace_class}.
 
-If \bt_p{length_field_class} is not \c NULL, then the created dynamic
-array field class has a linked length field class.
-See
-\ref api-tir-fc-link "Field classes with links to other field classes"
+@note
+    @parblock
+    This function is only available when \bt_p{trace_class} was created
+    from a \bt_self_comp which belongs to a trace processing \bt_graph
+    with the effective \bt_mip version&nbsp;0.
+
+    To create a dynamic array field class from a trace class which was
+    created from a self component which belongs to a trace processing
+    graph with the effective MIP version&nbsp;1, use
+    bt_field_class_array_dynamic_without_length_field_location_create()
+    or bt_field_class_array_dynamic_with_length_field_location_create().
+    @endparblock
+
+If \bt_p{length_field_class} is not \c NULL, then an instance of
+the created dynamic array field class has a linked length field.
+See \ref api-tir-fc-link "Fields with links to other fields"
 to learn more.
 
 On success, the returned dynamic array field class has the following
@@ -2859,8 +3061,8 @@ property values:
     field class to create.
 @param[in] length_field_class
     @parblock
-    Linked length field class of the dynamic array field class to
-    create.
+    Class of a linked length field of an instance of the dynamic array
+    field class to create.
 
     Can be \c NULL.
     @endparblock
@@ -2878,35 +3080,155 @@ property values:
 
 @bt_post_success_frozen{element_field_class}
 @bt_post_success_frozen{length_field_class}
+
+@sa bt_field_class_array_dynamic_without_length_field_location_create() &mdash;
+    Creates a class of dynamic array field without a linked length field
+    (\bt_mip version&nbsp;1).
+@sa bt_field_class_array_dynamic_with_length_field_location_create() &mdash;
+    Creates a class of dynamic array field with a linked length field
+    (\bt_mip version&nbsp;1).
 */
 extern bt_field_class *bt_field_class_array_dynamic_create(
                bt_trace_class *trace_class,
                bt_field_class *element_field_class,
                bt_field_class *length_field_class) __BT_NOEXCEPT;
 
+/*!
+@brief
+    Creates a \bt_darray_fc (instances without a linked length field)
+    having the element field class \bt_p{element_field_class} from the
+    trace class \bt_p{trace_class}.
+
+On success, the returned dynamic array field class has the following
+property values:
+
+<table>
+  <tr>
+    <th>Property
+    <th>Value
+  <tr>
+    <td>\ref api-tir-fc-array-prop-elem-fc "Element field class"
+    <td>\bt_p{element_field_class}
+  <tr>
+    <td>\ref api-tir-fc-darray-prop-len-fl "Length field location"
+    <td>
+      \em None
+  <tr>
+    <td>\ref api-tir-fc-prop-user-attrs "User attributes"
+    <td>Empty \bt_map_val
+</table>
+
+@param[in] trace_class
+    Trace class from which to create a dynamic array field class.
+@param[in] element_field_class
+    Class of the element fields of the instances of the dynamic array
+    field class to create.
+
+@returns
+    New dynamic array field class reference (without a length field),
+    or \c NULL on memory error.
+
+@bt_pre_not_null{trace_class}
+@bt_pre_tc_with_mip{trace_class, 1}
+@bt_pre_not_null{element_field_class}
+@bt_pre_fc_not_in_tc{element_field_class}
+
+@bt_post_success_frozen{element_field_class}
+
+@sa bt_field_class_array_dynamic_with_length_field_location_create() &mdash;
+    Creates a class of dynamic array field with a linked length field.
+*/
+extern bt_field_class *bt_field_class_array_dynamic_without_length_field_location_create(
+               bt_trace_class *trace_class,
+               bt_field_class *element_field_class);
+
 /*! @} */
 
 /*!
-@name Dynamic array field class with length field
+@name Dynamic array field class: instances with linked length field
 @{
 */
 
 /*!
 @brief
-    Borrows the length field path from the \bt_darray_fc (with a length
-    field) \bt_p{field_class}.
+    Creates a \bt_darray_fc (instances with a linked length field)
+    having the element field class \bt_p{element_field_class} and the
+    length \bt_field_loc \bt_p{length_field_location} from the
+    trace class \bt_p{trace_class}.
+
+On success, the returned dynamic array field class has the following
+property values:
+
+<table>
+  <tr>
+    <th>Property
+    <th>Value
+  <tr>
+    <td>\ref api-tir-fc-array-prop-elem-fc "Element field class"
+    <td>\bt_p{element_field_class}
+  <tr>
+    <td>\ref api-tir-fc-darray-prop-len-fl "Length field location"
+    <td>
+      \bt_p{length_field_location}.
+
+      See \ref api-tir-fc-link "Fields with links to other fields"
+      to learn more.
+  <tr>
+    <td>\ref api-tir-fc-prop-user-attrs "User attributes"
+    <td>Empty \bt_map_val
+</table>
+
+@param[in] trace_class
+    Trace class from which to create a dynamic array field class.
+@param[in] element_field_class
+    Class of the element fields of the instances of the dynamic array
+    field class to create.
+@param[in] length_field_location
+    Length field location of the dynamic array field class to create.
+
+@returns
+    New dynamic array field class reference (instances with a linked
+    length field), or \c NULL on memory error.
+
+@bt_pre_not_null{trace_class}
+@bt_pre_tc_with_mip{trace_class, 1}
+@bt_pre_not_null{element_field_class}
+@bt_pre_fc_not_in_tc{element_field_class}
+@bt_pre_not_null{length_field_location}
+
+@bt_post_success_frozen{element_field_class}
+
+@sa bt_field_class_array_dynamic_without_length_field_location_create() &mdash;
+    Creates a class of dynamic array field without a linked
+    length field.
+*/
+extern bt_field_class *bt_field_class_array_dynamic_with_length_field_location_create(
+               bt_trace_class *trace_class,
+               bt_field_class *element_field_class,
+               const bt_field_location *length_field_location);
+
+/*!
+@brief
+    Borrows the length field path from the \bt_darray_fc (instances with
+    a linked length field) \bt_p{field_class}.
 
 See the \ref api-tir-fc-darray-prop-len-fp "length field path" property.
 
-This property is only available when a \bt_struct_fc containing
-(recursively) \bt_p{field_class} is passed to one of:
+This property is only available when all the following are true:
+
+- \bt_p{field_class} was created with
+  bt_field_class_array_dynamic_create() with \bt_p{length_field_class}
+  set to an \bt_uint_fc (not \c NULL).
 
-- bt_stream_class_set_packet_context_field_class()
-- bt_stream_class_set_event_common_context_field_class()
-- bt_event_class_set_specific_context_field_class()
-- bt_event_class_set_payload_field_class()
+- A \bt_struct_fc containing (recursively) \bt_p{field_class} is passed
+  to one of:
 
-In the meantime, this function returns \c NULL.
+  - bt_stream_class_set_packet_context_field_class()
+  - bt_stream_class_set_event_common_context_field_class()
+  - bt_event_class_set_specific_context_field_class()
+  - bt_event_class_set_payload_field_class()
+
+  In the meantime, this function returns \c NULL.
 
 @param[in] field_class
     Dynamic array field class from which to borrow the length
@@ -2923,6 +3245,32 @@ extern const bt_field_path *
 bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
                const bt_field_class *field_class) __BT_NOEXCEPT;
 
+/*!
+@brief
+    Borrows the length field location from the \bt_darray_fc (instances
+    with a linked length field) \bt_p{field_class}.
+
+See the \ref api-tir-fc-darray-prop-len-fl "length field location"
+property.
+
+This property is only available when \bt_p{field_class} was created
+with bt_field_class_array_dynamic_with_length_field_location_create().
+
+@param[in] field_class
+    Dynamic array field class from which to borrow the length
+    field location.
+
+@returns
+    Length field location of \bt_p{field_class}.
+
+@bt_pre_not_null{field_class}
+@bt_pre_is_darray_wl_fc{field_class}
+@bt_pre_fc_with_mip{field_class, 1}
+*/
+extern const bt_field_location *
+bt_field_class_array_dynamic_with_length_field_borrow_length_field_location_const(
+               const bt_field_class *field_class);
+
 /*! @} */
 
 /*!
@@ -3319,15 +3667,27 @@ bt_field_class_option_borrow_field_class_const(
 /*! @} */
 
 /*!
-@name Option field class without a selector field
+@name Option field class: instances without a linked selector field
 @{
 */
 
 /*!
 @brief
-    Creates an \bt_opt_fc (without a selector field) having the optional
-    field class \bt_p{optional_field_class} from the trace class
-    \bt_p{trace_class}.
+    Creates an \bt_opt_fc (instances without a linked selector field)
+    having the optional field class \bt_p{optional_field_class} from the
+    trace class \bt_p{trace_class}.
+
+@note
+    @parblock
+    This function is only available when \bt_p{trace_class} was created
+    from a \bt_self_comp which belongs to a trace processing \bt_graph
+    with the effective \bt_mip version&nbsp;0.
+
+    To create a similar option field class from a trace class which was
+    created from a self component which belongs to a trace processing
+    graph with the effective MIP version&nbsp;1, use
+    bt_field_class_option_without_selector_field_location_create().
+    @endparblock
 
 On success, the returned option field class has the following property
 values:
@@ -3354,65 +3714,25 @@ values:
     New option field class reference, or \c NULL on memory error.
 
 @bt_pre_not_null{trace_class}
+@bt_pre_tc_with_mip{trace_class, 0}
 @bt_pre_not_null{optional_field_class}
 @bt_pre_fc_not_in_tc{optional_field_class}
 
 @bt_post_success_frozen{optional_field_class}
+
+@sa bt_field_class_option_without_selector_field_location_create() &mdash;
+    Creates a class of option field without a linked selector field
+    (\bt_mip version&nbsp;1).
 */
 extern bt_field_class *bt_field_class_option_without_selector_create(
                bt_trace_class *trace_class,
                bt_field_class *optional_field_class) __BT_NOEXCEPT;
 
-/*! @} */
-
-/*!
-@name Option field class with a selector field
-@{
-*/
-
-/*!
-@brief
-    Borrows the selector field path from the \bt_opt_fc (with a selector
-    field) \bt_p{field_class}.
-
-See the \ref api-tir-fc-opt-prop-sel-fp "selector field path" property.
-
-This property is only available when a \bt_struct_fc containing
-(recursively) \bt_p{field_class} is passed to one of:
-
-- bt_stream_class_set_packet_context_field_class()
-- bt_stream_class_set_event_common_context_field_class()
-- bt_event_class_set_specific_context_field_class()
-- bt_event_class_set_payload_field_class()
-
-In the meantime, this function returns \c NULL.
-
-@param[in] field_class
-    Option field class from which to borrow the selector field path.
-
-@returns
-    Selector field path of \bt_p{field_class}.
-
-@bt_pre_not_null{field_class}
-@bt_pre_is_opt_ws_fc{field_class}
-@bt_pre_fc_with_mip{field_class, 0}
-*/
-extern const bt_field_path *
-bt_field_class_option_with_selector_field_borrow_selector_field_path_const(
-               const bt_field_class *field_class) __BT_NOEXCEPT;
-
-/*! @} */
-
-/*!
-@name Option field class with a boolean selector field
-@{
-*/
-
 /*!
 @brief
-    Creates an \bt_opt_fc (with a boolean selector field) having the
-    optional field class \bt_p{optional_field_class} from the trace
-    class \bt_p{trace_class}.
+    Creates an \bt_opt_fc (instances without a linked selector
+    field) having the optional field class \bt_p{optional_field_class}
+    from the trace class \bt_p{trace_class}.
 
 On success, the returned option field class has the following property
 values:
@@ -3424,14 +3744,6 @@ values:
   <tr>
     <td>\ref api-tir-fc-opt-prop-fc "Optional field class"
     <td>\bt_p{optional_field_class}
-  <tr>
-    <td>\ref api-tir-fc-opt-prop-sel-fp "Selector field path"
-    <td>
-      \em None (this property becomes available when the returned field
-      class becomes part of an \bt_ev_cls or of a \bt_stream_cls)
-  <tr>
-    <td>\ref api-tir-fc-opt-prop-sel-rev "Selector is reversed?"
-    <td>#BT_FALSE
   <tr>
     <td>\ref api-tir-fc-prop-user-attrs "User attributes"
     <td>Empty \bt_map_val
@@ -3442,28 +3754,247 @@ values:
 @param[in] optional_field_class
     Class of the optional fields of the instances of the option field
     class to create.
-@param[in] selector_field_class
-    Linked selector field class of the option field class to create.
 
 @returns
     New option field class reference, or \c NULL on memory error.
 
 @bt_pre_not_null{trace_class}
-@bt_pre_tc_with_mip{trace_class, 0}
+@bt_pre_tc_with_mip{trace_class, 1}
 @bt_pre_not_null{optional_field_class}
 @bt_pre_fc_not_in_tc{optional_field_class}
-@bt_pre_not_null{selector_field_class}
-@pre
-    \bt_p{selector_field_class} is a \bt_bool_fc.
 
 @bt_post_success_frozen{optional_field_class}
-@bt_post_success_frozen{selector_field_class}
+
+@sa bt_field_class_option_with_selector_field_location_bool_create() &mdash;
+    Creates a class of option field with a linked boolean selector field.
+@sa bt_field_class_option_with_selector_field_location_integer_unsigned_create() &mdash;
+    Creates a class of option field with a linked unsigned integer
+    selector field.
+@sa bt_field_class_option_with_selector_field_location_integer_signed_create() &mdash;
+    Creates a class of option field with a linked signed integer
+    selector field.
+*/
+extern bt_field_class *bt_field_class_option_without_selector_field_location_create(
+               bt_trace_class *trace_class,
+               bt_field_class *optional_field_class) __BT_NOEXCEPT;
+
+/*! @} */
+
+/*!
+@name Option field class: instances with a linked selector field
+@{
+*/
+
+/*!
+@brief
+    Borrows the selector field path from the \bt_opt_fc (instances
+    with a linked selector field) \bt_p{field_class}.
+
+See the \ref api-tir-fc-opt-prop-sel-fp "selector field path" property.
+
+This property is only available when all the following are true:
+
+- \bt_p{field_class} was created with
+  bt_field_class_option_with_selector_field_bool_create(),
+  bt_field_class_option_with_selector_field_integer_unsigned_create(),
+  or bt_field_class_option_with_selector_field_integer_signed_create().
+
+- A \bt_struct_fc containing (recursively) \bt_p{field_class} is passed
+  to one of:
+
+  - bt_stream_class_set_packet_context_field_class()
+  - bt_stream_class_set_event_common_context_field_class()
+  - bt_event_class_set_specific_context_field_class()
+  - bt_event_class_set_payload_field_class()
+
+  In the meantime, this function returns \c NULL.
+
+@param[in] field_class
+    Option field class from which to borrow the selector field path.
+
+@returns
+    Selector field path of \bt_p{field_class}.
+
+@bt_pre_not_null{field_class}
+@bt_pre_is_opt_ws_fc{field_class}
+@bt_pre_fc_with_mip{field_class, 0}
+*/
+extern const bt_field_path *
+bt_field_class_option_with_selector_field_borrow_selector_field_path_const(
+               const bt_field_class *field_class) __BT_NOEXCEPT;
+
+/*!
+@brief
+    Borrows the selector field location from the \bt_opt_fc (instances
+    with a linked selector field) \bt_p{field_class}.
+
+See the \ref api-tir-fc-opt-prop-sel-fl "selector field location"
+property.
+
+This property is only available when \bt_p{field_class} was created
+with bt_field_class_option_with_selector_field_location_bool_create(),
+
+
+@param[in] field_class
+    Option field class from which to borrow the selector field location.
+
+@returns
+    Selector field location of \bt_p{field_class}.
+
+@bt_pre_not_null{field_class}
+@bt_pre_is_opt_ws_fc{field_class}
+@bt_pre_fc_with_mip{field_class, 1}
+*/
+extern const bt_field_location *
+bt_field_class_option_with_selector_field_borrow_selector_field_location_const(
+               const bt_field_class *field_class) __BT_NOEXCEPT;
+
+/*! @} */
+
+/*!
+@name Option field class: instances with a linked boolean selector field
+@{
+*/
+
+/*!
+@brief
+    Creates an \bt_opt_fc (instances with a linked boolean selector
+    field) having the optional field class \bt_p{optional_field_class}
+    from the trace class \bt_p{trace_class}.
+
+@note
+    @parblock
+    This function is only available when \bt_p{trace_class} was created
+    from a \bt_self_comp which belongs to a trace processing \bt_graph
+    with the effective \bt_mip version&nbsp;0.
+
+    To create a similar option field class from a trace class which was
+    created from a self component which belongs to a trace processing
+    graph with the effective MIP version&nbsp;1, use
+    bt_field_class_option_with_selector_field_location_bool_create().
+    @endparblock
+
+On success, the returned option field class has the following property
+values:
+
+<table>
+  <tr>
+    <th>Property
+    <th>Value
+  <tr>
+    <td>\ref api-tir-fc-opt-prop-fc "Optional field class"
+    <td>\bt_p{optional_field_class}
+  <tr>
+    <td>\ref api-tir-fc-opt-prop-sel-fp "Selector field path"
+    <td>
+      \em None (this property becomes available when the returned field
+      class becomes part of an \bt_ev_cls or of a \bt_stream_cls)
+  <tr>
+    <td>\ref api-tir-fc-opt-prop-sel-rev "Selector is reversed?"
+    <td>#BT_FALSE
+  <tr>
+    <td>\ref api-tir-fc-prop-user-attrs "User attributes"
+    <td>Empty \bt_map_val
+</table>
+
+@param[in] trace_class
+    Trace class from which to create an option field class.
+@param[in] optional_field_class
+    Class of the optional fields of the instances of the option field
+    class to create.
+@param[in] selector_field_class
+    Class of a linked boolean selector field of an instance of the
+    option field class to create.
+
+@returns
+    New option field class reference, or \c NULL on memory error.
+
+@bt_pre_not_null{trace_class}
+@bt_pre_tc_with_mip{trace_class, 0}
+@bt_pre_not_null{optional_field_class}
+@bt_pre_fc_not_in_tc{optional_field_class}
+@bt_pre_not_null{selector_field_class}
+@pre
+    \bt_p{selector_field_class} is a \bt_bool_fc.
+
+@bt_post_success_frozen{optional_field_class}
+@bt_post_success_frozen{selector_field_class}
+
+@sa bt_field_class_option_with_selector_field_location_bool_create() &mdash;
+    Creates a class of option field with a linked boolean selector field
+    (\bt_mip version&nbsp;1).
 */
 extern bt_field_class *bt_field_class_option_with_selector_field_bool_create(
                bt_trace_class *trace_class,
                bt_field_class *optional_field_class,
                bt_field_class *selector_field_class) __BT_NOEXCEPT;
 
+/*!
+@brief
+    Creates an \bt_opt_fc (instances with a linked boolean selector
+    field) having the optional field class \bt_p{optional_field_class}
+    and the selector \bt_field_loc \bt_p{selector_field_location} from
+    the trace class \bt_p{trace_class}.
+
+On success, the returned option field class has the following property
+values:
+
+<table>
+  <tr>
+    <th>Property
+    <th>Value
+  <tr>
+    <td>\ref api-tir-fc-opt-prop-fc "Optional field class"
+    <td>\bt_p{optional_field_class}
+  <tr>
+    <td>\ref api-tir-fc-opt-prop-sel-fl "Selector field location"
+    <td>
+      \bt_p{selector_field_location}.
+
+      See \ref api-tir-fc-link "Fields with links to other fields"
+      to learn more.
+  <tr>
+    <td>\ref api-tir-fc-opt-prop-sel-rev "Selector is reversed?"
+    <td>#BT_FALSE
+  <tr>
+    <td>\ref api-tir-fc-prop-user-attrs "User attributes"
+    <td>Empty \bt_map_val
+</table>
+
+@param[in] trace_class
+    Trace class from which to create an option field class.
+@param[in] optional_field_class
+    Class of the optional fields of the instances of the option field
+    class to create.
+@param[in] selector_field_location
+    Selector field location of the option field class to create.
+
+@returns
+    New option field class reference, or \c NULL on memory error.
+
+@bt_pre_not_null{trace_class}
+@bt_pre_tc_with_mip{trace_class, 1}
+@bt_pre_not_null{optional_field_class}
+@bt_pre_fc_not_in_tc{optional_field_class}
+@bt_pre_not_null{selector_field_location}
+
+@bt_post_success_frozen{optional_field_class}
+@bt_post_success_frozen{selector_field_class}
+
+@sa bt_field_class_option_without_selector_field_location_create() &mdash;
+    Creates a class of option field without a linked selector field.
+@sa bt_field_class_option_with_selector_field_location_integer_unsigned_create() &mdash;
+    Creates a class of option field with a linked unsigned integer
+    selector field.
+@sa bt_field_class_option_with_selector_field_location_integer_signed_create() &mdash;
+    Creates a class of option field with a linked signed integer
+    selector field.
+*/
+extern bt_field_class *bt_field_class_option_with_selector_field_location_bool_create(
+               bt_trace_class *trace_class,
+               bt_field_class *optional_field_class,
+               const bt_field_location *selector_field_location) __BT_NOEXCEPT;
+
 /*!
 @brief
     Sets whether or not the selector of the \bt_opt_fc (with a boolean
@@ -3520,15 +4051,27 @@ bt_field_class_option_with_selector_field_bool_selector_is_reversed(
 /*! @} */
 
 /*!
-@name Option field class with an unsigned integer selector field
+@name Option field class: instances with a linked unsigned integer selector field
 @{
 */
 
 /*!
 @brief
-    Creates an \bt_opt_fc (with an unsigned integer selector field)
-    having the optional field class \bt_p{optional_field_class} from the
-    trace class \bt_p{trace_class}.
+    Creates an \bt_opt_fc (instances with a linked unsigned integer
+    selector field) having the optional field class
+    \bt_p{optional_field_class} from the trace class \bt_p{trace_class}.
+
+@note
+    @parblock
+    This function is only available when \bt_p{trace_class} was created
+    from a \bt_self_comp which belongs to a trace processing \bt_graph
+    with the effective \bt_mip version&nbsp;0.
+
+    To create a similar option field class from a trace class which was
+    created from a self component which belongs to a trace processing
+    graph with the effective MIP version&nbsp;1, use
+    bt_field_class_option_with_selector_field_location_integer_unsigned_create().
+    @endparblock
 
 On success, the returned option field class has the following property
 values:
@@ -3573,7 +4116,7 @@ values:
 @bt_pre_fc_not_in_tc{optional_field_class}
 @bt_pre_not_null{selector_field_class}
 @pre
-    \bt_p{selector_field_class} is a \bt_uint_fc.
+    \bt_p{selector_field_class} is an \bt_uint_fc.
 @bt_pre_not_null{ranges}
 @pre
     \bt_p{ranges} contains one or more \bt_p_uint_rg.
@@ -3581,6 +4124,10 @@ values:
 @bt_post_success_frozen{optional_field_class}
 @bt_post_success_frozen{selector_field_class}
 @bt_post_success_frozen{ranges}
+
+@sa bt_field_class_option_with_selector_field_location_integer_unsigned_create() &mdash;
+    Creates a class of option field with a linked unsigned integer
+    selector field (\bt_mip version&nbsp;1).
 */
 extern bt_field_class *
 bt_field_class_option_with_selector_field_integer_unsigned_create(
@@ -3590,6 +4137,80 @@ bt_field_class_option_with_selector_field_integer_unsigned_create(
                const bt_integer_range_set_unsigned *ranges)
                __BT_NOEXCEPT;
 
+/*!
+@brief
+    Creates an \bt_opt_fc (instances with a linked unsigned integer
+    selector field) having the optional field class
+    \bt_p{optional_field_class} and the selector \bt_field_loc
+    \bt_p{selector_field_location} from the trace class
+    \bt_p{trace_class}.
+
+On success, the returned option field class has the following property
+values:
+
+<table>
+  <tr>
+    <th>Property
+    <th>Value
+  <tr>
+    <td>\ref api-tir-fc-opt-prop-fc "Optional field class"
+    <td>\bt_p{optional_field_class}
+  <tr>
+    <td>\ref api-tir-fc-opt-prop-sel-fl "Selector field location"
+    <td>
+      \bt_p{selector_field_location}.
+
+      See \ref api-tir-fc-link "Fields with links to other fields"
+      to learn more.
+  <tr>
+    <td>\ref api-tir-fc-opt-prop-uint-rs "Selector's unsigned integer ranges"
+    <td>\bt_p{ranges}
+  <tr>
+    <td>\ref api-tir-fc-prop-user-attrs "User attributes"
+    <td>Empty \bt_map_val
+</table>
+
+@param[in] trace_class
+    Trace class from which to create an option field class.
+@param[in] optional_field_class
+    Class of the optional fields of the instances of the option field
+    class to create.
+@param[in] selector_field_location
+    Selector field location of the option field class to create.
+@param[in] ranges
+    Selector's unsigned integer ranges of the option field class to
+    create.
+
+@returns
+    New option field class reference, or \c NULL on memory error.
+
+@bt_pre_not_null{trace_class}
+@bt_pre_tc_with_mip{trace_class, 1}
+@bt_pre_not_null{optional_field_class}
+@bt_pre_fc_not_in_tc{optional_field_class}
+@bt_pre_not_null{selector_field_location}
+@bt_pre_not_null{ranges}
+@pre
+    \bt_p{ranges} contains one or more \bt_p_uint_rg.
+
+@bt_post_success_frozen{optional_field_class}
+@bt_post_success_frozen{ranges}
+
+@sa bt_field_class_option_without_selector_field_location_create() &mdash;
+    Creates a class of option field without a linked selector field.
+@sa bt_field_class_option_with_selector_field_location_bool_create() &mdash;
+    Creates a class of option field with a linked boolean selector field.
+@sa bt_field_class_option_with_selector_field_location_integer_signed_create() &mdash;
+    Creates a class of option field with a linked signed integer
+    selector field.
+*/
+extern bt_field_class *
+bt_field_class_option_with_selector_field_location_integer_unsigned_create(
+               bt_trace_class *trace_class,
+               bt_field_class *optional_field_class,
+               const bt_field_location *selector_field_location,
+               const bt_integer_range_set_unsigned *ranges) __BT_NOEXCEPT;
+
 /*!
 @brief
     Borrows the \bt_p_uint_rg from the \bt_opt_fc (with an unsigned
@@ -3615,15 +4236,27 @@ bt_field_class_option_with_selector_field_integer_unsigned_borrow_selector_range
 /*! @} */
 
 /*!
-@name Option field class with a signed integer selector field
+@name Option field class: instances with a linked signed integer selector field
 @{
 */
 
 /*!
 @brief
-    Creates an \bt_opt_fc (with a signed integer selector field)
-    having the optional field class \bt_p{optional_field_class} from the
-    trace class \bt_p{trace_class}.
+    Creates an \bt_opt_fc (instances with a linked signed integer
+    selector field) having the optional field class
+    \bt_p{optional_field_class} from the trace class \bt_p{trace_class}.
+
+@note
+    @parblock
+    This function is only available when \bt_p{trace_class} was created
+    from a \bt_self_comp which belongs to a trace processing \bt_graph
+    with the effective \bt_mip version&nbsp;0.
+
+    To create a similar option field class from a trace class which was
+    created from a self component which belongs to a trace processing
+    graph with the effective MIP version&nbsp;1, use
+    bt_field_class_option_with_selector_field_location_integer_signed_create().
+    @endparblock
 
 On success, the returned option field class has the following property
 values:
@@ -3668,7 +4301,7 @@ values:
 @bt_pre_fc_not_in_tc{optional_field_class}
 @bt_pre_not_null{selector_field_class}
 @pre
-    \bt_p{selector_field_class} is a \bt_uint_fc.
+    \bt_p{selector_field_class} is an \bt_uint_fc.
 @bt_pre_not_null{ranges}
 @pre
     \bt_p{ranges} contains one or more \bt_p_uint_rg.
@@ -3676,6 +4309,10 @@ values:
 @bt_post_success_frozen{optional_field_class}
 @bt_post_success_frozen{selector_field_class}
 @bt_post_success_frozen{ranges}
+
+@sa bt_field_class_option_with_selector_field_location_integer_signed_create() &mdash;
+    Creates an option field class with a linked signed integer
+    selector field (\bt_mip version&nbsp;1).
 */
 extern bt_field_class *
 bt_field_class_option_with_selector_field_integer_signed_create(
@@ -3684,6 +4321,80 @@ bt_field_class_option_with_selector_field_integer_signed_create(
                bt_field_class *selector_field_class,
                const bt_integer_range_set_signed *ranges) __BT_NOEXCEPT;
 
+/*!
+@brief
+    Creates an \bt_opt_fc (instances with a linked signed integer
+    selector field) having the optional field class
+    \bt_p{optional_field_class} and the selector \bt_field_loc
+    \bt_p{selector_field_location} from the trace class
+    \bt_p{trace_class}.
+
+On success, the returned option field class has the following property
+values:
+
+<table>
+  <tr>
+    <th>Property
+    <th>Value
+  <tr>
+    <td>\ref api-tir-fc-opt-prop-fc "Optional field class"
+    <td>\bt_p{optional_field_class}
+  <tr>
+    <td>\ref api-tir-fc-opt-prop-sel-fl "Selector field location"
+    <td>
+      \bt_p{selector_field_location}.
+
+      See \ref api-tir-fc-link "Fields with links to other fields"
+      to learn more.
+  <tr>
+    <td>\ref api-tir-fc-opt-prop-uint-rs "Selector's signed integer ranges"
+    <td>\bt_p{ranges}
+  <tr>
+    <td>\ref api-tir-fc-prop-user-attrs "User attributes"
+    <td>Empty \bt_map_val
+</table>
+
+@param[in] trace_class
+    Trace class from which to create an option field class.
+@param[in] optional_field_class
+    Class of the optional fields of the instances of the option field
+    class to create.
+@param[in] selector_field_location
+    Selector field location of the option field class to create.
+@param[in] ranges
+    Selector's signed integer ranges of the option field class to
+    create.
+
+@returns
+    New option field class reference, or \c NULL on memory error.
+
+@bt_pre_not_null{trace_class}
+@bt_pre_tc_with_mip{trace_class, 1}
+@bt_pre_not_null{optional_field_class}
+@bt_pre_fc_not_in_tc{optional_field_class}
+@bt_pre_not_null{selector_field_location}
+@bt_pre_not_null{ranges}
+@pre
+    \bt_p{ranges} contains one or more \bt_p_uint_rg.
+
+@bt_post_success_frozen{optional_field_class}
+@bt_post_success_frozen{ranges}
+
+@sa bt_field_class_variant_without_selector_field_location_create() &mdash;
+    Creates a class of option field without a linked selector field.
+@sa bt_field_class_option_with_selector_field_location_bool_create() &mdash;
+    Creates a class of option field with a linked boolean selector field.
+@sa bt_field_class_option_with_selector_field_location_integer_unsigned_create() &mdash;
+    Creates a class of option field with a linked unsigned integer
+    selector field.
+*/
+extern bt_field_class *
+bt_field_class_option_with_selector_field_location_integer_signed_create(
+               bt_trace_class *trace_class,
+               bt_field_class *optional_field_class,
+               const bt_field_location *selector_field_class,
+               const bt_integer_range_set_signed *ranges) __BT_NOEXCEPT;
+
 /*!
 @brief
     Borrows the \bt_p_sint_rg from the \bt_opt_fc (with a signed
@@ -3715,12 +4426,25 @@ bt_field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_
 
 /*!
 @brief
-    Creates a \bt_var_fc from the trace class \bt_p{trace_class}.
+    Creates an empty \bt_var_fc from the trace class \bt_p{trace_class}.
+
+@note
+    @parblock
+    This function is only available when \bt_p{trace_class} was created
+    from a \bt_self_comp which belongs to a trace processing \bt_graph
+    with the effective \bt_mip version&nbsp;0.
+
+    To create a variant field class from a trace class which was
+    created from a self component which belongs to a trace processing
+    graph with the effective MIP version&nbsp;1, use
+    bt_field_class_variant_without_selector_field_location_create(),
+    bt_field_class_variant_with_selector_field_location_integer_unsigned_create(),
+    or bt_field_class_variant_with_selector_field_location_integer_signed_create().
+    @endparblock
 
-If \bt_p{selector_field_class} is not \c NULL, then the created variant
-field class has a linked selector field class.
-See
-\ref api-tir-fc-link "Field classes with links to other field classes"
+If \bt_p{selector_field_class} is not \c NULL, then an instance of
+the created variant field class has a linked selector field.
+See \ref api-tir-fc-link "Fields with links to other fields"
 to learn more.
 
 On success, the returned variant field class has the following
@@ -3748,7 +4472,8 @@ property values:
     Trace class from which to create a variant field class.
 @param[in] selector_field_class
     @parblock
-    Linked selector field class of the variant field class to create.
+    Class of a linked selector field of an instance of the variant field
+    class to create.
 
     Can be \c NULL.
     @endparblock
@@ -3764,6 +4489,16 @@ property values:
 
 @bt_post_success_frozen{element_field_class}
 @bt_post_success_frozen{selector_field_class}
+
+@sa bt_field_class_variant_without_selector_field_location_create() &mdash;
+    Creates a class of variant field without a linked selector field
+    (\bt_mip version&nbsp;1).
+@sa bt_field_class_variant_with_selector_field_location_integer_unsigned_create() &mdash;
+    Creates a class of variant field with a linked unsigned integer
+    selector field (\bt_mip version&nbsp;1).
+@sa bt_field_class_variant_with_selector_field_location_integer_signed_create() &mdash;
+    Creates a class of variant field with a linked signed integer
+    selector field (\bt_mip version&nbsp;1).
 */
 extern bt_field_class *bt_field_class_variant_create(
                bt_trace_class *trace_class,
@@ -4035,10 +4770,53 @@ extern const bt_value *bt_field_class_variant_option_borrow_user_attributes_cons
 /*! @} */
 
 /*!
-@name Variant field class without a selector field
+@name Variant field class: instances without a linked selector field
 @{
 */
 
+/*!
+@brief
+    Creates an empty \bt_var_fc (instances without a linked
+    selector field) from the trace class \bt_p{trace_class}.
+
+On success, the returned variant field class has the following
+property values:
+
+<table>
+  <tr>
+    <th>Property
+    <th>Value
+  <tr>
+    <td>\ref api-tir-fc-var-prop-sel-fp "Selector field location"
+    <td>
+      \em None
+  <tr>
+    <td>\ref api-tir-fc-var-prop-opts "Options"
+    <td>\em None
+  <tr>
+    <td>\ref api-tir-fc-prop-user-attrs "User attributes"
+    <td>Empty \bt_map_val
+</table>
+
+@param[in] trace_class
+    Trace class from which to create a variant field class.
+
+@returns
+    New option field class reference, or \c NULL on memory error.
+
+@bt_pre_not_null{trace_class}
+@bt_pre_tc_with_mip{trace_class, 1}
+
+@sa bt_field_class_variant_with_selector_field_location_integer_unsigned_create() &mdash;
+    Creates a class of variant field with a linked unsigned integer
+    selector field.
+@sa bt_field_class_variant_with_selector_field_location_integer_signed_create() &mdash;
+    Creates a class of variant field with a linked signed integer
+    selector field.
+*/
+extern bt_field_class *bt_field_class_variant_without_selector_field_location_create(
+               bt_trace_class *trace_class) __BT_NOEXCEPT;
+
 /*!
 @brief
     Status codes for
@@ -4060,9 +4838,9 @@ typedef enum bt_field_class_variant_without_selector_append_option_status {
 
 /*!
 @brief
-    Appends an option to the \bt_var_fc (without a selector field)
-    \bt_p{field_class} having the name \bt_p{name} and the
-    field class \bt_p{option_field_class}.
+    Appends an option to the \bt_var_fc (instances without a linked
+    selector field) \bt_p{field_class} having the name \bt_p{name} and
+    the field class \bt_p{option_field_class}.
 
 See the \ref api-tir-fc-var-prop-opts "options" property.
 
@@ -4098,7 +4876,7 @@ bt_field_class_variant_without_selector_append_option(
 /*! @} */
 
 /*!
-@name Variant field class with a selector field
+@name Variant field class: instances with a linked selector field
 @{
 */
 
@@ -4125,20 +4903,26 @@ typedef enum bt_field_class_variant_with_selector_field_integer_append_option_st
 
 /*!
 @brief
-    Borrows the selector field path from the \bt_var_fc (with a selector
-    field) \bt_p{field_class}.
+    Borrows the selector field path from the \bt_var_fc (instances with
+    a linked selector field) \bt_p{field_class}.
 
 See the \ref api-tir-fc-var-prop-sel-fp "selector field path" property.
 
-This property is only available when a \bt_struct_fc containing
-(recursively) \bt_p{field_class} is passed to one of:
+This property is only available when all the following are true:
+
+- \bt_p{field_class} was created with
+  bt_field_class_variant_create() with \bt_p{selector_field_class}
+  set to an \bt_int_fc (not \c NULL).
+
+- A \bt_struct_fc containing (recursively) \bt_p{field_class} is passed
+  to one of:
 
-- bt_stream_class_set_packet_context_field_class()
-- bt_stream_class_set_event_common_context_field_class()
-- bt_event_class_set_specific_context_field_class()
-- bt_event_class_set_payload_field_class()
+  - bt_stream_class_set_packet_context_field_class()
+  - bt_stream_class_set_event_common_context_field_class()
+  - bt_event_class_set_specific_context_field_class()
+  - bt_event_class_set_payload_field_class()
 
-In the meantime, this function returns \c NULL.
+  In the meantime, this function returns \c NULL.
 
 @param[in] field_class
     Variant field class from which to borrow the selector field path.
@@ -4154,18 +4938,96 @@ extern const bt_field_path *
 bt_field_class_variant_with_selector_field_borrow_selector_field_path_const(
                const bt_field_class *field_class) __BT_NOEXCEPT;
 
+/*!
+@brief
+    Borrows the selector field location from the \bt_var_fc (instances
+    with a linked selector field) \bt_p{field_class}.
+
+See the \ref api-tir-fc-var-prop-sel-fl "selector field location"
+property.
+
+This property is only available when \bt_p{field_class} was created with
+bt_field_class_variant_with_selector_field_location_integer_unsigned_create()
+or
+bt_field_class_variant_with_selector_field_location_integer_signed_create().
+
+@param[in] field_class
+    Option field class from which to borrow the selector field location.
+
+@returns
+    Selector field location of \bt_p{field_class}.
+
+@bt_pre_not_null{field_class}
+@bt_pre_is_var_ws_fc{field_class}
+@bt_pre_fc_with_mip{field_class, 1}
+*/
+extern const bt_field_location *
+bt_field_class_variant_with_selector_field_borrow_selector_field_location_const(
+               const bt_field_class *field_class);
+
 /*! @} */
 
 /*!
-@name Variant field class with an unsigned integer selector field
+@name Variant field class: instances with a linked unsigned integer selector field
 @{
 */
 
 /*!
 @brief
-    Appends an option to the \bt_var_fc (with an unsigned integer
-    selector field) \bt_p{field_class} having the name \bt_p{name},
-    the field class \bt_p{option_field_class}, and the
+    Creates an empty \bt_var_fc (instances with a linked
+    unsigned integer selector field) having the
+    selector \bt_field_loc \bt_p{selector_field_location}
+    from the trace class \bt_p{trace_class}.
+
+On success, the returned variant field class has the following
+property values:
+
+<table>
+  <tr>
+    <th>Property
+    <th>Value
+  <tr>
+    <td>\ref api-tir-fc-var-prop-sel-fp "Selector field location"
+    <td>
+      \bt_p{selector_field_location}.
+
+      See \ref api-tir-fc-link "Fields with links to other fields"
+      to learn more.
+  <tr>
+    <td>\ref api-tir-fc-var-prop-opts "Options"
+    <td>\em None
+  <tr>
+    <td>\ref api-tir-fc-prop-user-attrs "User attributes"
+    <td>Empty \bt_map_val
+</table>
+
+@param[in] trace_class
+    Trace class from which to create a variant field class.
+@param[in] selector_field_location
+    Selector field location of the variant field class to create.
+
+@returns
+    New variant field class reference, or \c NULL on memory error.
+
+@bt_pre_not_null{trace_class}
+@bt_pre_tc_with_mip{trace_class, 1}
+@bt_pre_not_null{selector_field_location}
+
+@sa bt_field_class_variant_without_selector_field_location_create() &mdash;
+    Creates a class of variant field without a linked selector field.
+@sa bt_field_class_option_with_selector_field_location_integer_signed_create() &mdash;
+    Creates a class of variant field with a linked signed integer
+    selector field.
+*/
+extern bt_field_class *bt_field_class_variant_with_selector_field_location_integer_unsigned_create(
+               bt_trace_class *trace_class,
+               const bt_field_location *selector_field_location) __BT_NOEXCEPT;
+
+/*!
+@brief
+    Appends an option to the \bt_var_fc (instances with a linked
+    unsigned integer selector field) \bt_p{field_class} having the name
+    \bt_p{name}, the field class \bt_p{option_field_class}, and the
     \bt_p_uint_rg \bt_p{ranges}.
 
 See the \ref api-tir-fc-var-prop-opts "options" property.
@@ -4214,7 +5076,7 @@ bt_field_class_variant_with_selector_field_integer_unsigned_append_option(
 /*!
 @brief
     Borrows the option at index \bt_p{index} from the
-    \bt_var_fc (with an unsigned integer selector field)
+    \bt_var_fc (instances with a linked unsigned integer selector field)
     \bt_p{field_class}.
 
 See the \ref api-tir-fc-var-prop-opts "options" property.
@@ -4252,7 +5114,7 @@ bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_ind
 /*!
 @brief
     Borrows the option having the name \bt_p{name} from the
-    \bt_var_fc (with an unsigned integer selector field)
+    \bt_var_fc (instances with a linked unsigned integer selector field)
     \bt_p{field_class}.
 
 See the \ref api-tir-fc-var-prop-opts "options" property.
@@ -4291,7 +5153,7 @@ bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_nam
 /*! @} */
 
 /*!
-@name Variant field class (with an unsigned integer selector field) option
+@name Variant field class option: instances with a linked unsigned integer selector field
 @{
 */
 
@@ -4299,13 +5161,14 @@ bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_nam
 @typedef struct bt_field_class_variant_with_selector_field_integer_unsigned_option bt_field_class_variant_with_selector_field_integer_unsigned_option;
 
 @brief
-    Variant field class (with an unsigned integer selector field) option.
+    Variant field class option (instances with a linked unsigned integer selector field).
 */
 
 /*!
 @brief
-    Borrows the \bt_p_uint_rg from the \bt_var_fc (with an unsigned
-    integer selector field) option \bt_p{option}.
+    Borrows the \bt_p_uint_rg from the \bt_var_fc option
+    (instances with a linked unsigned integer selector field)
+    \bt_p{option}.
 
 See the \ref api-tir-fc-var-prop-opts "options" property.
 
@@ -4325,8 +5188,8 @@ bt_field_class_variant_with_selector_field_integer_unsigned_option_borrow_ranges
 
 /*!
 @brief
-    \ref api-fund-c-typing "Upcasts" the \bt_var_fc (with an
-    unsigned integer selector field) option \bt_p{option} to the
+    \ref api-fund-c-typing "Upcasts" the \bt_var_fc option (instances
+    with a linked unsigned integer selector field) \bt_p{option} to the
     common #bt_field_class_variant_option type.
 
 See the \ref api-tir-fc-var-prop-opts "options" property.
@@ -4353,15 +5216,66 @@ bt_field_class_variant_with_selector_field_integer_unsigned_option_as_option_con
 /*! @} */
 
 /*!
-@name Variant field class with a signed integer selector field
+@name Variant field class: instances with a linked signed integer selector field
 @{
 */
 
 /*!
 @brief
-    Appends an option to the \bt_var_fc (with a signed integer
-    selector field) \bt_p{field_class} having the name \bt_p{name},
-    the field class \bt_p{option_field_class}, and the
+    Creates an empty \bt_var_fc (instances with a linked
+    signed integer selector field) having the
+    selector \bt_field_loc \bt_p{selector_field_location}
+    from the trace class \bt_p{trace_class}.
+
+On success, the returned variant field class has the following
+property values:
+
+<table>
+  <tr>
+    <th>Property
+    <th>Value
+  <tr>
+    <td>\ref api-tir-fc-var-prop-sel-fp "Selector field location"
+    <td>
+      \bt_p{selector_field_location}.
+
+      See \ref api-tir-fc-link "Fields with links to other fields"
+      to learn more.
+  <tr>
+    <td>\ref api-tir-fc-var-prop-opts "Options"
+    <td>\em None
+  <tr>
+    <td>\ref api-tir-fc-prop-user-attrs "User attributes"
+    <td>Empty \bt_map_val
+</table>
+
+@param[in] trace_class
+    Trace class from which to create a variant field class.
+@param[in] selector_field_location
+    Selector field location of the variant field class to create.
+
+@returns
+    New variant field class reference, or \c NULL on memory error.
+
+@bt_pre_not_null{trace_class}
+@bt_pre_tc_with_mip{trace_class, 1}
+@bt_pre_not_null{selector_field_location}
+
+@sa bt_field_class_variant_without_selector_field_location_create() &mdash;
+    Creates a class of variant field without a linked selector field.
+@sa bt_field_class_option_with_selector_field_location_integer_unsigned_create() &mdash;
+    Creates a class of variant field with a linked unsigned integer
+    selector field.
+*/
+extern bt_field_class *bt_field_class_variant_with_selector_field_location_integer_signed_create(
+               bt_trace_class *trace_class,
+               const bt_field_location *selector_field_location) __BT_NOEXCEPT;
+
+/*!
+@brief
+    Appends an option to the \bt_var_fc (instances with a linked signed
+    integer selector field) \bt_p{field_class} having the name
+    \bt_p{name}, the field class \bt_p{option_field_class}, and the
     \bt_p_sint_rg \bt_p{ranges}.
 
 See the \ref api-tir-fc-var-prop-opts "options" property.
@@ -4411,7 +5325,7 @@ bt_field_class_variant_with_selector_field_integer_signed_append_option(
 /*!
 @brief
     Borrows the option at index \bt_p{index} from the
-    \bt_var_fc (with a signed integer selector field)
+    \bt_var_fc (instances with a linked signed integer selector field)
     \bt_p{field_class}.
 
 See the \ref api-tir-fc-var-prop-opts "options" property.
@@ -4449,7 +5363,7 @@ bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index
 /*!
 @brief
     Borrows the option having the name \bt_p{name} from the
-    \bt_var_fc (with a signed integer selector field)
+    \bt_var_fc (instances with a linked signed integer selector field)
     \bt_p{field_class}.
 
 See the \ref api-tir-fc-var-prop-opts "options" property.
@@ -4488,7 +5402,7 @@ bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_
 /*! @} */
 
 /*!
-@name Variant field class (with a signed integer selector field) option
+@name Variant field class option: instances with a linked signed integer selector field
 @{
 */
 
@@ -4496,13 +5410,14 @@ bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_
 @typedef struct bt_field_class_variant_with_selector_field_integer_signed_option bt_field_class_variant_with_selector_field_integer_signed_option;
 
 @brief
-    Variant field class (with a signed integer selector field) option.
+    Variant field class option (instances with a linked signed integer selector field).
 */
 
 /*!
 @brief
-    Borrows the \bt_p_sint_rg from the \bt_var_fc (with a signed
-    integer selector field) option \bt_p{option}.
+    Borrows the \bt_p_sint_rg from the \bt_var_fc option
+    (instances with a linked signed integer selector field)
+    \bt_p{option}.
 
 See the \ref api-tir-fc-var-prop-opts "options" property.
 
@@ -4522,9 +5437,9 @@ bt_field_class_variant_with_selector_field_integer_signed_option_borrow_ranges_c
 
 /*!
 @brief
-    \ref api-fund-c-typing "Upcasts" the \bt_var_fc (with a signed
-    integer selector field) option \bt_p{option} to the
-    common #bt_field_class_variant_option type.
+    \ref api-fund-c-typing "Upcasts" the \bt_var_fc option
+    (instances with a linked signed integer selector field)
+    \bt_p{option} to the common #bt_field_class_variant_option type.
 
 See the \ref api-tir-fc-var-prop-opts "options" property.
 
index 44b1cd1eab538ac7bec45cf87c3c75dc96f27d4a..2e5c54f2614d9a873ec9e6c07fba159dbdff588e 100644 (file)
@@ -43,9 +43,22 @@ given \bt_field from a given <em>root scope</em>.
 
 A field location indicates how to reach:
 
-- The length field(s) of a \bt_darray_field (with a length field).
-- The selector field of a \bt_opt_field (with a selector field).
-- The selector field of a \bt_var_field (with a selector field).
+- The length field of a \bt_darray_field
+  (instances with a linked length field).
+
+- The selector field of a \bt_opt_field
+  (instances with a linked selector field).
+
+- The selector field of a \bt_var_field
+  (instances with a linked selector field).
+
+You can borrow the field location from the \ref api-tir-fc "classes" of
+such fields with
+bt_field_class_array_dynamic_with_length_field_borrow_length_field_location_const(),
+bt_field_class_option_with_selector_field_borrow_selector_field_location_const(),
+and
+bt_field_class_variant_with_selector_field_borrow_selector_field_location_const().
+See \ref api-tir-fc-link "Field classes with links to other field classes".
 
 A field location is a \ref api-tir "trace IR" metadata object.
 
index fa19c61ac046831c0a30bda34f9c7278e418f3be..d9c65942b6392a33c4984c4421744246201f6abd 100644 (file)
        BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FC_ID, (_fc),             \
                _BT_ASSERT_PRE_FC_NAME)
 
+#define _BT_ASSERT_PRE_SELECTOR_FC_NAME        "Selector field class"
+#define _BT_ASSERT_PRE_SELECTOR_FC_ID  "selector-field-class"
+
+#define BT_ASSERT_PRE_SELECTOR_FC_NON_NULL(_fc)                                        \
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_SELECTOR_FC_ID, (_fc),            \
+               _BT_ASSERT_PRE_SELECTOR_FC_NAME)
+
 #define BT_ASSERT_PRE_DEV_FC_NON_NULL(_fc)                             \
        BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FC_ID, (_fc),         \
                _BT_ASSERT_PRE_FC_NAME)
 #define _BT_ASSERT_PRE_FL_ID   "field-location"
 
 /* Asserts that `_fl` is non-NULL */
-#define BT_ASSERT_PRE_FL_NON_NULL(_fl)                                 \
-       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FL_ID, (_fl),             \
+#define BT_ASSERT_PRE_FL_NON_NULL(_fl)                         \
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FL_ID, (_fl),     \
                _BT_ASSERT_PRE_FL_NAME)
 
+#define _BT_ASSERT_PRE_SELECTOR_FL_NAME        "Selector field location"
+#define _BT_ASSERT_PRE_SELECTOR_FL_ID  "selector-field-location"
+
+/* Asserts that `_fl` is non-NULL */
+#define BT_ASSERT_PRE_SELECTOR_FL_NON_NULL(_fl)                                \
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_SELECTOR_FL_ID, (_fl),    \
+               _BT_ASSERT_PRE_SELECTOR_FL_NAME)
+
+#define _BT_ASSERT_PRE_LENGTH_FL_NAME  "Length field location"
+#define _BT_ASSERT_PRE_LENGTH_FL_ID    "length-field-location"
+
+/* Asserts that `_fl` is non-NULL */
+#define BT_ASSERT_PRE_LENGTH_FL_NON_NULL(_fl)                          \
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_LENGTH_FL_ID, (_fl),      \
+               _BT_ASSERT_PRE_LENGTH_FL_NAME)
+
 #define _BT_ASSERT_PRE_FP_NAME "Field path"
 #define _BT_ASSERT_PRE_FP_ID   "field-path"
 
                _mip_version == _val,                           \
                "MIP version is not equal to %" PRIu64, _val)
 
+/* Asserts that the MIP version `_mip_version` is equal to `_val`. */
+#define BT_ASSERT_PRE_DEV_MIP_VERSION_EQ(_mip_version, _val)   \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_MIP_VERSION_VALID_ID,  \
+               _mip_version == _val,                           \
+               "MIP version is not equal to %" PRIu64, _val)
+
 /*
  * Asserts that the given MIP version `_mip_version` is greater than or equal
  * to `_val`.
                _mip_version >= _val,                                           \
                "MIP version is less than %" PRIu64, _val)
 
+/*
+ * Asserts that the given MIP version `_mip_version` is greater than or equal
+ * to `_val`.
+ */
+#define BT_ASSERT_PRE_DEV_MIP_VERSION_GE(_mip_version, _val)                   \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_MIP_VERSION_VALID_ID,                  \
+               _mip_version >= _val,                                           \
+               "MIP version is less than %" PRIu64, _val)
+
 /*
  * Asserts that the effective MIP version for `_trace_class` is equal to `_val`.
  */
 #define BT_ASSERT_PRE_FC_MIP_VERSION_EQ(_field_class, _val)            \
        BT_ASSERT_PRE_MIP_VERSION_EQ((_field_class)->mip_version, _val)
 
+/* Asserts that the effective MIP version for `_field_class` is equal to `_val`. */
+#define BT_ASSERT_PRE_DEV_FC_MIP_VERSION_EQ(_field_class, _val)                \
+       BT_ASSERT_PRE_DEV_MIP_VERSION_EQ((_field_class)->mip_version, _val)
+
+/*
+ * Asserts that the effective MIP version for `_field_class` is greator than or
+ * equal to `_val`.
+ */
+#define BT_ASSERT_PRE_FC_MIP_VERSION_GE(_field_class, _val)            \
+       BT_ASSERT_PRE_MIP_VERSION_GE((_field_class)->mip_version, _val)
+
+/*
+ * Asserts that the effective MIP version for `_field_class` is greator than or
+ * equal to `_val`.
+ */
+#define BT_ASSERT_PRE_DEV_FC_MIP_VERSION_GE(_field_class, _val)                \
+       BT_ASSERT_PRE_DEV_MIP_VERSION_GE((_field_class)->mip_version, _val)
+
 #define _BT_ASSERT_PRE_INTR_NAME       "Interrupter"
 #define _BT_ASSERT_PRE_INTR_ID         "interrupter"
 
index 9de0780026f9bc2de87764072c165e05f85b63f4..541067ea16f27cf8a2532b6e1ae6f398d0d5aa74 100644 (file)
@@ -226,16 +226,27 @@ static inline void format_field_class(char **buf_ch, bool extended,
 
                format_array_field_class(buf_ch, prefix, field_class);
 
-               if (array_fc->length_fc) {
-                       SET_TMP_PREFIX("length-fc-");
-                       format_field_class(buf_ch, extended, tmp_prefix,
-                               array_fc->length_fc);
-               }
+               if (field_class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) {
+                       switch (array_fc->length_field.xref_kind) {
+                       case FIELD_XREF_KIND_PATH:
+                               BT_ASSERT(array_fc->length_field.path.class);
+                               SET_TMP_PREFIX("length-fc-");
+                               format_field_class(buf_ch, extended, tmp_prefix,
+                                       array_fc->length_field.path.class);
 
-               if (array_fc->length_field_path) {
-                       SET_TMP_PREFIX("length-field-path-");
-                       format_field_path(buf_ch, extended, tmp_prefix,
-                               array_fc->length_field_path);
+                               if (array_fc->length_field.path.path) {
+                                       SET_TMP_PREFIX("length-field-path-");
+                                       format_field_path(buf_ch, extended, tmp_prefix,
+                                               array_fc->length_field.path.path);
+                               }
+                               break;
+                       case FIELD_XREF_KIND_LOCATION:
+                               BT_ASSERT(array_fc->length_field.location);
+                               SET_TMP_PREFIX("length-fl-");
+                               format_field_location(buf_ch, extended, tmp_prefix,
+                                       array_fc->length_field.location);
+                               break;
+                       }
                }
 
                break;
@@ -257,16 +268,25 @@ static inline void format_field_class(char **buf_ch, bool extended,
                        const struct bt_field_class_option_with_selector_field *opt_with_sel_fc =
                                (const void *) field_class;
 
-                       if (opt_with_sel_fc->selector_fc) {
+                       switch (opt_with_sel_fc->selector_field_xref_kind) {
+                       case FIELD_XREF_KIND_PATH:
+                               BT_ASSERT(opt_with_sel_fc->selector_field.path.class);
                                SET_TMP_PREFIX("selector-fc-");
                                format_field_class(buf_ch, extended, tmp_prefix,
-                                       opt_with_sel_fc->selector_fc);
-                       }
+                                       opt_with_sel_fc->selector_field.path.class);
 
-                       if (opt_with_sel_fc->selector_field_path) {
-                               SET_TMP_PREFIX("selector-field-path-");
-                               format_field_path(buf_ch, extended, tmp_prefix,
-                                       opt_with_sel_fc->selector_field_path);
+                               if (opt_with_sel_fc->selector_field.path.path) {
+                                       SET_TMP_PREFIX("selector-field-path-");
+                                       format_field_path(buf_ch, extended, tmp_prefix,
+                                               opt_with_sel_fc->selector_field.path.path);
+                               }
+                               break;
+                       case FIELD_XREF_KIND_LOCATION:
+                               BT_ASSERT_DBG(opt_with_sel_fc->selector_field.location);
+                               SET_TMP_PREFIX("selector-fl-");
+                               format_field_location(buf_ch, extended, tmp_prefix,
+                                       opt_with_sel_fc->selector_field.location);
+                               break;
                        }
                }
 
@@ -289,16 +309,26 @@ static inline void format_field_class(char **buf_ch, bool extended,
                        const struct bt_field_class_variant_with_selector_field *var_with_sel_fc =
                                (const void *) var_fc;
 
-                       if (var_with_sel_fc->selector_fc) {
+                       switch (var_with_sel_fc->selector_field_xref_kind) {
+                       case FIELD_XREF_KIND_PATH:
+                               BT_ASSERT(var_with_sel_fc->selector_field.path.class);
                                SET_TMP_PREFIX("selector-fc-");
                                format_field_class(buf_ch, extended, tmp_prefix,
-                                       var_with_sel_fc->selector_fc);
-                       }
+                                       var_with_sel_fc->selector_field.path.class);
 
-                       if (var_with_sel_fc->selector_field_path) {
-                               SET_TMP_PREFIX("selector-field-path-");
-                               format_field_path(buf_ch, extended, tmp_prefix,
-                                       var_with_sel_fc->selector_field_path);
+
+                               if (var_with_sel_fc->selector_field.path.path) {
+                                       SET_TMP_PREFIX("selector-field-path-");
+                                       format_field_path(buf_ch, extended, tmp_prefix,
+                                               var_with_sel_fc->selector_field.path.path);
+                               }
+                               break;
+                       case FIELD_XREF_KIND_LOCATION:
+                               BT_ASSERT(var_with_sel_fc->selector_field.location);
+                               SET_TMP_PREFIX("selector-fl-");
+                               format_field_location(buf_ch, extended, tmp_prefix,
+                                       var_with_sel_fc->selector_field.location);
+                               break;
                        }
                }
 
index 576241a7b1af7f83a5a06308a8e168e879e7b8f6..07e35d9ac52d9e4e84089c78e5bf11392fe07bac 100644 (file)
@@ -1216,10 +1216,18 @@ void destroy_option_field_class(struct bt_object *obj)
                struct bt_field_class_option_with_selector_field *with_sel_fc =
                        (void *) obj;
 
-               BT_LOGD_STR("Putting selector field path.");
-               BT_OBJECT_PUT_REF_AND_RESET(with_sel_fc->selector_field_path);
-               BT_LOGD_STR("Putting selector field class.");
-               BT_OBJECT_PUT_REF_AND_RESET(with_sel_fc->selector_fc);
+               switch (with_sel_fc->selector_field_xref_kind) {
+               case FIELD_XREF_KIND_PATH:
+                       BT_LOGD_STR("Putting selector field path.");
+                       BT_OBJECT_PUT_REF_AND_RESET(with_sel_fc->selector_field.path.path);
+                       BT_LOGD_STR("Putting selector field class.");
+                       BT_OBJECT_PUT_REF_AND_RESET(with_sel_fc->selector_field.path.class);
+                       break;
+               case FIELD_XREF_KIND_LOCATION:
+                       BT_LOGD_STR("Putting selector field location.");
+                       BT_OBJECT_PUT_REF_AND_RESET(with_sel_fc->selector_field.location);
+                       break;
+               };
 
                if (fc->common.type != BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD) {
                        struct bt_field_class_option_with_selector_field_integer *with_int_sel_fc =
@@ -1239,14 +1247,16 @@ struct bt_field_class *create_option_field_class(
                enum bt_field_class_type fc_type,
                struct bt_field_class *content_fc,
                struct bt_field_class *selector_fc,
+               const struct bt_field_location *selector_fl,
                const char *api_func)
 {
        struct bt_field_class_option *opt_fc = NULL;
 
-       BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(api_func);
-       BT_ASSERT_PRE_TC_NON_NULL_FROM_FUNC(api_func, trace_class);
        BT_ASSERT_PRE_NON_NULL_FROM_FUNC(api_func, "content-field-class",
                content_fc, "Content field class");
+
+       BT_ASSERT(!(selector_fc && selector_fl));
+
        BT_LIB_LOGD("Creating option field class: "
                "type=%s, %![content-fc-]+F, %![sel-fc-]+F",
                bt_common_field_class_type_string(fc_type),
@@ -1255,21 +1265,12 @@ struct bt_field_class *create_option_field_class(
        if (fc_type != BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD) {
                struct bt_field_class_option_with_selector_field *opt_with_sel_fc = NULL;
 
-               BT_ASSERT_PRE_NON_NULL_FROM_FUNC(api_func,
-                       "selector-field-class", selector_fc,
-                       "Selector field class");
+               BT_ASSERT(selector_fc || selector_fl);
 
                if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD) {
-                       BT_ASSERT_PRE_FC_HAS_TYPE_FROM_FUNC(api_func,
-                               "selector-field-class", selector_fc,
-                               "boolean-field-class", BT_FIELD_CLASS_TYPE_BOOL,
-                               "Selector field class");
                        opt_with_sel_fc = (void *) g_new0(
                                struct bt_field_class_option_with_selector_field_bool, 1);
                } else {
-                       BT_ASSERT_PRE_FC_IS_INT_FROM_FUNC(api_func,
-                               "selector-field-class",
-                               selector_fc, "Selector field class");
                        opt_with_sel_fc = (void *) g_new0(
                                struct bt_field_class_option_with_selector_field_integer, 1);
                }
@@ -1280,10 +1281,21 @@ struct bt_field_class *create_option_field_class(
                        goto error;
                }
 
-               opt_with_sel_fc->selector_fc = selector_fc;
-               bt_object_get_ref_no_null_check(opt_with_sel_fc->selector_fc);
+               if (selector_fc) {
+                       opt_with_sel_fc->selector_field_xref_kind = FIELD_XREF_KIND_PATH;
+                       opt_with_sel_fc->selector_field.path.class = selector_fc;
+                       bt_object_get_ref_no_null_check(opt_with_sel_fc->selector_field.path.class);
+               } else {
+                       opt_with_sel_fc->selector_field_xref_kind = FIELD_XREF_KIND_LOCATION;
+                       opt_with_sel_fc->selector_field.location = selector_fl;
+                       bt_object_get_ref_no_null_check(opt_with_sel_fc->selector_field.location);
+               }
+
                opt_fc = (void *) opt_with_sel_fc;
        } else {
+               BT_ASSERT(!selector_fc);
+               BT_ASSERT(!selector_fl);
+
                opt_fc = g_new0(struct bt_field_class_option, 1);
                if (!opt_fc) {
                        BT_LIB_LOGE_APPEND_CAUSE(
@@ -1307,8 +1319,6 @@ struct bt_field_class *create_option_field_class(
                bt_field_class_freeze(selector_fc);
        }
 
-       BT_LIB_LOGD("Created option field class object: "
-               "%![opt-fc-]+F, %![sel-fc-]+F", opt_fc, selector_fc);
        goto end;
 
 error:
@@ -1323,9 +1333,41 @@ struct bt_field_class *bt_field_class_option_without_selector_create(
                struct bt_trace_class *trace_class,
                struct bt_field_class *content_fc)
 {
-       return create_option_field_class(trace_class,
+       struct bt_field_class *fc;
+
+       BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
+       BT_ASSERT_PRE_TC_MIP_VERSION_EQ(trace_class, 0);
+
+       fc = create_option_field_class(trace_class,
                BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD,
-               content_fc, NULL, __func__);
+               content_fc, NULL, NULL, __func__);
+
+       BT_LIB_LOGD("Created option field class without selector field class: "
+               "%![opt-fc-]+F", fc);
+
+       return fc;
+}
+
+BT_EXPORT
+struct bt_field_class *bt_field_class_option_without_selector_field_location_create(
+               struct bt_trace_class *trace_class,
+               struct bt_field_class *content_fc)
+{
+       struct bt_field_class *fc;
+
+       BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
+       BT_ASSERT_PRE_TC_MIP_VERSION_GE(trace_class, 1);
+
+       fc = create_option_field_class(trace_class,
+               BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD,
+               content_fc, NULL, NULL, __func__);
+
+       BT_LIB_LOGD("Created option field class without selector field location: "
+               "%![opt-fc-]+F", fc);
+
+       return fc;
 }
 
 BT_EXPORT
@@ -1334,12 +1376,47 @@ struct bt_field_class *bt_field_class_option_with_selector_field_bool_create(
                struct bt_field_class *content_fc,
                struct bt_field_class *selector_fc)
 {
+       struct bt_field_class *fc;
+
        BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
        BT_ASSERT_PRE_TC_MIP_VERSION_EQ(trace_class, 0);
+       BT_ASSERT_PRE_SELECTOR_FC_NON_NULL(selector_fc);
+       BT_ASSERT_PRE_FC_HAS_TYPE("selector-field-class", selector_fc,
+                       "boolean-field-class", BT_FIELD_CLASS_TYPE_BOOL,
+                       "Selector field class");
 
-       return create_option_field_class(trace_class,
+       fc = create_option_field_class(trace_class,
                BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD,
-               content_fc, selector_fc, __func__);
+               content_fc, selector_fc, NULL, __func__);
+
+       BT_LIB_LOGD("Created option field class with boolean selector field class: "
+               "%![opt-fc-]+F, %![sel-fc-]+F", fc, selector_fc);
+
+       return fc;
+}
+
+BT_EXPORT
+struct bt_field_class *bt_field_class_option_with_selector_field_location_bool_create(
+               struct bt_trace_class *trace_class,
+               struct bt_field_class *content_fc,
+               const struct bt_field_location *selector_fl)
+{
+       struct bt_field_class *fc;
+
+       BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
+       BT_ASSERT_PRE_TC_MIP_VERSION_GE(trace_class, 1);
+       BT_ASSERT_PRE_SELECTOR_FL_NON_NULL(selector_fl);
+
+       fc = create_option_field_class(trace_class,
+               BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD,
+               content_fc, NULL, selector_fl, __func__);
+
+       BT_LIB_LOGD("Created option field class with boolean selector field location: "
+               "%![opt-fc-]+F, %![sel-fl-]+L", fc, selector_fl);
+
+       return fc;
 }
 
 BT_EXPORT
@@ -1355,13 +1432,54 @@ bt_field_class_option_with_selector_field_integer_unsigned_create(
                (const void *) u_range_set;
 
        BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
        BT_ASSERT_PRE_TC_MIP_VERSION_EQ(trace_class, 0);
+       BT_ASSERT_PRE_SELECTOR_FC_NON_NULL(selector_fc);
+       BT_ASSERT_PRE_FC_IS_UNSIGNED_INT("selector-field-class",
+               selector_fc, "Selector field class");
        BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL(range_set);
        BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY(range_set);
+
        fc = (void *) create_option_field_class(trace_class,
                BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
-               content_fc, selector_fc, __func__);
+               content_fc, selector_fc, NULL, __func__);
+       if (!fc) {
+               goto end;
+       }
+
+       fc->range_set = range_set;
+       bt_object_get_ref_no_null_check(fc->range_set);
+       bt_integer_range_set_freeze(range_set);
+
+       BT_LIB_LOGD("Created option field class with unsigned integer selector field class: "
+               "%![opt-fc-]+F, %![sel-fc-]+F", fc, selector_fc);
+
+end:
+       return (void *) fc;
+}
+
+BT_EXPORT
+struct bt_field_class *
+bt_field_class_option_with_selector_field_location_integer_unsigned_create(
+               struct bt_trace_class *trace_class,
+               struct bt_field_class *content_fc,
+               const struct bt_field_location *selector_fl,
+               const struct bt_integer_range_set_unsigned *u_range_set)
+{
+       struct bt_field_class_option_with_selector_field_integer *fc;
+       const struct bt_integer_range_set *range_set =
+               (const void *) u_range_set;
+
+       BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
+       BT_ASSERT_PRE_TC_MIP_VERSION_GE(trace_class, 1);
+       BT_ASSERT_PRE_SELECTOR_FL_NON_NULL(selector_fl);
+       BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL(range_set);
+       BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY(range_set);
 
+       fc = (void *) create_option_field_class(trace_class,
+               BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
+               content_fc, NULL, selector_fl, __func__);
        if (!fc) {
                goto end;
        }
@@ -1370,6 +1488,9 @@ bt_field_class_option_with_selector_field_integer_unsigned_create(
        bt_object_get_ref_no_null_check(fc->range_set);
        bt_integer_range_set_freeze(range_set);
 
+       BT_LIB_LOGD("Created option field class with unsigned integer selector field location: "
+               "%![opt-fc-]+F, %![sel-fl-]+L", fc, selector_fl);
+
 end:
        return (void *) fc;
 }
@@ -1387,13 +1508,54 @@ bt_field_class_option_with_selector_field_integer_signed_create(
                (const void *) i_range_set;
 
        BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
        BT_ASSERT_PRE_TC_MIP_VERSION_EQ(trace_class, 0);
+       BT_ASSERT_PRE_SELECTOR_FC_NON_NULL(selector_fc);
+       BT_ASSERT_PRE_FC_IS_SIGNED_INT("selector-field-class",
+               selector_fc, "Selector field class");
        BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL(range_set);
        BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY(range_set);
+
        fc = (void *) create_option_field_class(trace_class,
                BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
-               content_fc, selector_fc, __func__);
+               content_fc, selector_fc, NULL, __func__);
+       if (!fc) {
+               goto end;
+       }
 
+       fc->range_set = range_set;
+       bt_object_get_ref_no_null_check(fc->range_set);
+       bt_integer_range_set_freeze(range_set);
+
+       BT_LIB_LOGD("Created option field class with signed integer selector field class: "
+               "%![opt-fc-]+F, %![sel-fc-]+F", fc, selector_fc);
+
+end:
+       return (void *) fc;
+}
+
+BT_EXPORT
+struct bt_field_class *
+bt_field_class_option_with_selector_field_location_integer_signed_create(
+               struct bt_trace_class *trace_class,
+               struct bt_field_class *content_fc,
+               const struct bt_field_location *selector_fl,
+               const struct bt_integer_range_set_signed *i_range_set)
+{
+       struct bt_field_class_option_with_selector_field_integer *fc;
+       const struct bt_integer_range_set *range_set =
+               (const void *) i_range_set;
+
+       BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
+       BT_ASSERT_PRE_TC_MIP_VERSION_GE(trace_class, 1);
+       BT_ASSERT_PRE_SELECTOR_FL_NON_NULL(selector_fl);
+       BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL(range_set);
+       BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY(range_set);
+
+       fc = (void *) create_option_field_class(trace_class,
+               BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
+               content_fc, NULL, selector_fl, __func__);
        if (!fc) {
                goto end;
        }
@@ -1402,6 +1564,9 @@ bt_field_class_option_with_selector_field_integer_signed_create(
        bt_object_get_ref_no_null_check(fc->range_set);
        bt_integer_range_set_freeze(range_set);
 
+       BT_LIB_LOGD("Created option field class with signed integer selector field location: "
+               "%![opt-fc-]+F, %![sel-fl-]+L", fc, selector_fl);
+
 end:
        return (void *) fc;
 }
@@ -1439,7 +1604,23 @@ bt_field_class_option_with_selector_field_borrow_selector_field_path_const(
        BT_ASSERT_PRE_FC_NON_NULL(fc);
        BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL("field-class", fc, "Field class");
        BT_ASSERT_PRE_FC_MIP_VERSION_EQ(fc, 0);
-       return opt_fc->selector_field_path;
+       BT_ASSERT_DBG(opt_fc->selector_field_xref_kind == FIELD_XREF_KIND_PATH);
+       return opt_fc->selector_field.path.path;
+}
+
+BT_EXPORT
+const struct bt_field_location *
+bt_field_class_option_with_selector_field_borrow_selector_field_location_const(
+               const struct bt_field_class *fc)
+{
+       const struct bt_field_class_option_with_selector_field *opt_fc =
+               (const void *) fc;
+
+       BT_ASSERT_PRE_FC_NON_NULL(fc);
+       BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL("field-class", fc, "Field class");
+       BT_ASSERT_PRE_FC_MIP_VERSION_GE(fc, 1);
+       BT_ASSERT_DBG(opt_fc->selector_field_xref_kind == FIELD_XREF_KIND_LOCATION);
+       return opt_fc->selector_field.location;
 }
 
 BT_EXPORT
@@ -1525,35 +1706,45 @@ void destroy_variant_with_selector_field_field_class(struct bt_object *obj)
 
        BT_ASSERT(fc);
        finalize_variant_field_class(&fc->common);
-       BT_LOGD_STR("Putting selector field path.");
-       BT_OBJECT_PUT_REF_AND_RESET(fc->selector_field_path);
-       BT_LOGD_STR("Putting selector field class.");
-       BT_OBJECT_PUT_REF_AND_RESET(fc->selector_fc);
+
+       if (fc->selector_field_xref_kind == FIELD_XREF_KIND_PATH) {
+               BT_LOGD_STR("Putting selector field path.");
+               BT_OBJECT_PUT_REF_AND_RESET(fc->selector_field.path.path);
+               BT_LOGD_STR("Putting selector field class.");
+               BT_OBJECT_PUT_REF_AND_RESET(fc->selector_field.path.class);
+       } else {
+               BT_ASSERT(fc->selector_field_xref_kind == FIELD_XREF_KIND_LOCATION);
+               BT_LOGD_STR("Putting selector field location.");
+               BT_OBJECT_PUT_REF_AND_RESET(fc->selector_field.location);
+       }
+
        g_free(fc);
 }
 
-BT_EXPORT
-struct bt_field_class *bt_field_class_variant_create(
-               bt_trace_class *trace_class, bt_field_class *selector_fc)
+static
+struct bt_field_class *create_variant_field_class(
+               struct bt_trace_class *trace_class,
+               enum bt_field_class_type fc_type,
+               struct bt_field_class *selector_fc,
+               const struct bt_field_location *selector_fl)
 {
        int ret;
        struct bt_field_class_variant *var_fc = NULL;
        struct bt_field_class_variant_with_selector_field *var_with_sel_fc = NULL;
-       enum bt_field_class_type fc_type;
 
-       BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
-       BT_ASSERT_PRE_TC_MIP_VERSION_EQ(trace_class, 0);
+       if (fc_type != BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD) {
+               BT_ASSERT((selector_fc && !selector_fl) ||
+                       (!selector_fc && selector_fl));
 
-       if (selector_fc) {
-               BT_ASSERT_PRE_FC_IS_INT("selector-field-class", selector_fc,
-                       "Selector field class");
-       }
 
-       BT_LIB_LOGD("Creating default variant field class: %![sel-fc-]+F",
-               selector_fc);
+               if (selector_fc) {
+                       BT_LIB_LOGD("Creating default variant field class with selector field class: %![sel-fc-]+F",
+                               selector_fc);
+               } else {
+                       BT_LIB_LOGD("Creating default variant field class with selector field location: %![sel-fl-]+L",
+                               selector_fl);
+               }
 
-       if (selector_fc) {
                var_with_sel_fc = g_new0(
                        struct bt_field_class_variant_with_selector_field, 1);
                if (!var_with_sel_fc) {
@@ -1562,13 +1753,6 @@ struct bt_field_class *bt_field_class_variant_create(
                        goto error;
                }
 
-               if (bt_field_class_type_is(selector_fc->type,
-                               BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER)) {
-                       fc_type = BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD;
-               } else {
-                       fc_type = BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD;
-               }
-
                ret = init_named_field_classes_container(
                        (void *) var_with_sel_fc, fc_type,
                        destroy_variant_with_selector_field_field_class,
@@ -1579,13 +1763,27 @@ struct bt_field_class *bt_field_class_variant_create(
                        goto error;
                }
 
-               var_with_sel_fc->selector_fc = selector_fc;
-               bt_object_get_ref_no_null_check(var_with_sel_fc->selector_fc);
-               bt_field_class_freeze(selector_fc);
+               if (selector_fc) {
+                       var_with_sel_fc->selector_field_xref_kind = FIELD_XREF_KIND_PATH;
+                       var_with_sel_fc->selector_field.path.class = selector_fc;
+                       bt_object_get_ref_no_null_check(selector_fc);
+                       bt_field_class_freeze(selector_fc);
+
+                       BT_LIB_LOGD("Created default variant field class with selector field class: "
+                               "%![var-fc-]+F, %![sel-fc-]+F", var_with_sel_fc, selector_fc);
+               } else {
+                       var_with_sel_fc->selector_field_xref_kind = FIELD_XREF_KIND_LOCATION;
+                       var_with_sel_fc->selector_field.location = selector_fl;
+                       bt_object_get_ref_no_null_check(var_with_sel_fc->selector_field.location);
+
+                       BT_LIB_LOGD("Created default variant field class with selector field location: "
+                               "%![var-fc-]+F, %![sel-fl-]+L", var_fc, selector_fl);
+               }
+
                var_fc = (void *) var_with_sel_fc;
-               BT_LIB_LOGD("Created default variant field class with selector object: "
-                       "%![var-fc-]+F, %![sel-fc-]+F", var_fc, selector_fc);
        } else {
+               BT_LIB_LOGD("Creating default variant field class without selector.");
+
                var_fc = g_new0(struct bt_field_class_variant, 1);
                if (!var_fc) {
                        BT_LIB_LOGE_APPEND_CAUSE(
@@ -1593,8 +1791,7 @@ struct bt_field_class *bt_field_class_variant_create(
                        goto error;
                }
 
-               ret = init_named_field_classes_container((void *) var_fc,
-                       BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD,
+               ret = init_named_field_classes_container((void *) var_fc, fc_type,
                        destroy_variant_field_class, destroy_named_field_class,
                        trace_class);
                if (ret) {
@@ -1616,6 +1813,80 @@ end:
        return (void *) var_fc;
 }
 
+BT_EXPORT
+struct bt_field_class *bt_field_class_variant_create(
+               struct bt_trace_class *trace_class,
+               struct bt_field_class *selector_fc)
+{
+       enum bt_field_class_type fc_type;
+
+       BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
+       BT_ASSERT_PRE_TC_MIP_VERSION_EQ(trace_class, 0);
+
+       if (selector_fc) {
+               bt_field_class_type selector_fc_type;
+
+               BT_ASSERT_PRE_FC_IS_INT("selector-field-class", selector_fc,
+                       "Selector field class");
+
+               selector_fc_type = bt_field_class_get_type(selector_fc);
+
+               if (bt_field_class_type_is(selector_fc_type,
+                               BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER)) {
+                       fc_type = BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD;
+               } else {
+                       fc_type = BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD;
+               }
+       } else {
+               fc_type = BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD;
+       }
+
+       return create_variant_field_class(trace_class, fc_type, selector_fc, NULL);
+}
+
+BT_EXPORT
+struct bt_field_class *bt_field_class_variant_without_selector_field_location_create(
+               struct bt_trace_class *trace_class)
+{
+       BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
+       BT_ASSERT_PRE_TC_MIP_VERSION_GE(trace_class, 1);
+
+       return create_variant_field_class(trace_class,
+               BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD, NULL, NULL);
+}
+
+BT_EXPORT
+struct bt_field_class *bt_field_class_variant_with_selector_field_location_integer_unsigned_create(
+               struct bt_trace_class *trace_class,
+               const struct bt_field_location *selector_fl)
+{
+       BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
+       BT_ASSERT_PRE_TC_MIP_VERSION_GE(trace_class, 1);
+       BT_ASSERT_PRE_SELECTOR_FL_NON_NULL(selector_fl);
+
+       return create_variant_field_class(trace_class,
+               BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
+               NULL, selector_fl);
+}
+
+BT_EXPORT
+struct bt_field_class *bt_field_class_variant_with_selector_field_location_integer_signed_create(
+               struct bt_trace_class *trace_class,
+               const struct bt_field_location *selector_fl)
+{
+       BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
+       BT_ASSERT_PRE_TC_MIP_VERSION_GE(trace_class, 1);
+       BT_ASSERT_PRE_SELECTOR_FL_NON_NULL(selector_fl);
+
+       return create_variant_field_class(trace_class,
+               BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
+               NULL, selector_fl);
+}
+
 #define VAR_FC_OPT_NAME_IS_UNIQUE_ID                                   \
        "variant-field-class-option-name-is-unique"
 
@@ -2020,7 +2291,24 @@ bt_field_class_variant_with_selector_field_borrow_selector_field_path_const(
        BT_ASSERT_PRE_DEV_FC_IS_VARIANT_WITH_SEL("field-class", fc,
                "Field class");
        BT_ASSERT_PRE_FC_MIP_VERSION_EQ(fc, 0);
-       return var_fc->selector_field_path;
+       BT_ASSERT_DBG(var_fc->selector_field_xref_kind == FIELD_XREF_KIND_PATH);
+       return var_fc->selector_field.path.path;
+}
+
+BT_EXPORT
+const struct bt_field_location *
+bt_field_class_variant_with_selector_field_borrow_selector_field_location_const(
+               const struct bt_field_class *fc)
+{
+       const struct bt_field_class_variant_with_selector_field *var_fc =
+               (const void *) fc;
+
+       BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
+       BT_ASSERT_PRE_DEV_FC_IS_VARIANT_WITH_SEL("field-class", fc,
+               "Field class");
+       BT_ASSERT_PRE_DEV_FC_MIP_VERSION_GE(fc, 1);
+       BT_ASSERT_DBG(var_fc->selector_field_xref_kind == FIELD_XREF_KIND_LOCATION);
+       return var_fc->selector_field.location;
 }
 
 static
@@ -2144,25 +2432,39 @@ void destroy_dynamic_array_field_class(struct bt_object *obj)
        BT_ASSERT(fc);
        BT_LIB_LOGD("Destroying dynamic array field class object: %!+F", fc);
        finalize_array_field_class((void *) fc);
-       BT_LOGD_STR("Putting length field path.");
-       BT_OBJECT_PUT_REF_AND_RESET(fc->length_field_path);
-       BT_LOGD_STR("Putting length field class.");
-       BT_OBJECT_PUT_REF_AND_RESET(fc->length_fc);
+
+       if (fc->common.common.type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) {
+               switch (fc->length_field.xref_kind) {
+               case FIELD_XREF_KIND_PATH:
+                       BT_LOGD_STR("Putting length field class.");
+                       BT_OBJECT_PUT_REF_AND_RESET(fc->length_field.path.class);
+                       fc->length_field.path.class = NULL;
+
+                       BT_LOGD_STR("Putting length field path.");
+                       BT_OBJECT_PUT_REF_AND_RESET(fc->length_field.path.path);
+                       fc->length_field.path.path = NULL;
+                       break;
+               case FIELD_XREF_KIND_LOCATION:
+                       BT_LOGD_STR("Putting length field location.");
+                       BT_OBJECT_PUT_REF_AND_RESET(fc->length_field.location);
+                       fc->length_field.location = NULL;
+                       break;
+               };
+       }
+
        g_free(fc);
 }
 
-BT_EXPORT
-struct bt_field_class *bt_field_class_array_dynamic_create(
+static
+struct bt_field_class_array_dynamic *create_dynamic_array_field_class(
                struct bt_trace_class *trace_class,
                struct bt_field_class *element_fc,
-               struct bt_field_class *length_fc)
+               enum bt_field_class_type fc_type,
+               const char *api_func)
 {
        struct bt_field_class_array_dynamic *array_fc = NULL;
 
-       BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
-       BT_ASSERT_PRE_TC_MIP_VERSION_EQ(trace_class, 0);
-       BT_ASSERT_PRE_NON_NULL("element-field-class", element_fc,
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(api_func, "element-field-class", element_fc,
                "Element field class");
        BT_LOGD_STR("Creating default dynamic array field class object.");
        array_fc = g_new0(struct bt_field_class_array_dynamic, 1);
@@ -2172,24 +2474,121 @@ struct bt_field_class *bt_field_class_array_dynamic_create(
                goto error;
        }
 
-       if (init_array_field_class((void *) array_fc,
-                       length_fc ?
-                               BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD :
-                               BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD,
+       if (init_array_field_class((void *) array_fc, fc_type,
                        destroy_dynamic_array_field_class, element_fc,
                        trace_class)) {
                goto error;
        }
 
+       goto end;
+
+error:
+       BT_OBJECT_PUT_REF_AND_RESET(array_fc);
+
+end:
+       return array_fc;
+}
+
+BT_EXPORT
+struct bt_field_class *bt_field_class_array_dynamic_create(
+               struct bt_trace_class *trace_class,
+               struct bt_field_class *element_fc,
+               struct bt_field_class *length_fc)
+{
+       struct bt_field_class_array_dynamic *array_fc = NULL;
+
+
+       BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
+       BT_ASSERT_PRE_TC_MIP_VERSION_EQ(trace_class, 0);
+
+       array_fc = create_dynamic_array_field_class(trace_class, element_fc,
+               length_fc ?
+                       BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD :
+                       BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD,
+                __func__);
+       if (!array_fc) {
+               goto error;
+       }
+
        if (length_fc) {
+               array_fc->length_field.xref_kind = FIELD_XREF_KIND_PATH;
+
                BT_ASSERT_PRE_FC_IS_UNSIGNED_INT("length-field-class",
                        length_fc, "Length field class");
-               array_fc->length_fc = length_fc;
-               bt_object_get_ref_no_null_check(array_fc->length_fc);
+               array_fc->length_field.path.class = length_fc;
+               bt_object_get_ref_no_null_check(length_fc);
                bt_field_class_freeze(length_fc);
        }
 
        BT_LIB_LOGD("Created dynamic array field class object: %!+F", array_fc);
+
+       goto end;
+
+error:
+       BT_OBJECT_PUT_REF_AND_RESET(array_fc);
+
+end:
+       return (void *) array_fc;
+}
+
+BT_EXPORT
+struct bt_field_class *bt_field_class_array_dynamic_without_length_field_location_create(
+               struct bt_trace_class *trace_class,
+               struct bt_field_class *element_field_class)
+{
+       struct bt_field_class_array_dynamic *array_fc = NULL;
+
+       BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
+       BT_ASSERT_PRE_TC_MIP_VERSION_GE(trace_class, 1);
+
+       array_fc = create_dynamic_array_field_class(trace_class,
+               element_field_class, BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD,
+               __func__);
+       if (!array_fc) {
+               goto error;
+       }
+
+       BT_LIB_LOGD("Created dynamic array field class without field location object: %!+F",
+               array_fc);
+
+       goto end;
+
+error:
+       BT_OBJECT_PUT_REF_AND_RESET(array_fc);
+
+end:
+       return (void *) array_fc;
+}
+
+BT_EXPORT
+struct bt_field_class *bt_field_class_array_dynamic_with_length_field_location_create(
+               struct bt_trace_class *trace_class,
+               struct bt_field_class *element_field_class,
+               const struct bt_field_location *length_field_location)
+{
+       struct bt_field_class_array_dynamic *array_fc = NULL;
+
+       BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
+       BT_ASSERT_PRE_FL_NON_NULL(length_field_location);
+       BT_ASSERT_PRE_TC_MIP_VERSION_GE(trace_class, 1);
+
+       array_fc = create_dynamic_array_field_class(trace_class,
+               element_field_class, BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD,
+               __func__);
+       if (!array_fc) {
+               goto error;
+       }
+
+       array_fc->length_field.xref_kind = FIELD_XREF_KIND_LOCATION;
+       array_fc->length_field.location = length_field_location;
+       bt_object_get_ref_no_null_check(length_field_location);
+
+       BT_LIB_LOGD("Created dynamic array field class with field location object: %!+F",
+               array_fc);
+
        goto end;
 
 error:
@@ -2207,13 +2606,32 @@ bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
        const struct bt_field_class_array_dynamic *seq_fc = (const void *) fc;
 
        BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
+       BT_ASSERT_PRE_FC_NON_NULL(fc);
        BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
                "dynamic-array-field-class-with-length-field",
                BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD,
                "Field class");
        BT_ASSERT_PRE_FC_MIP_VERSION_EQ(fc, 0);
-       return seq_fc->length_field_path;
+       BT_ASSERT_DBG(seq_fc->length_field.xref_kind == FIELD_XREF_KIND_PATH);
+       return seq_fc->length_field.path.path;
+}
+
+BT_EXPORT
+const struct bt_field_location *
+bt_field_class_array_dynamic_with_length_field_borrow_length_field_location_const(
+               const struct bt_field_class *fc)
+{
+       const struct bt_field_class_array_dynamic *seq_fc = (const void *) fc;
+
+       BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_FC_NON_NULL(fc);
+       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+               "dynamic-array-field-class-with-length-field",
+               BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD,
+               "Field class");
+       BT_ASSERT_PRE_FC_MIP_VERSION_GE(fc, 1);
+       BT_ASSERT_DBG(seq_fc->length_field.xref_kind == FIELD_XREF_KIND_LOCATION);
+       return seq_fc->length_field.location;
 }
 
 static
index 3d4ee49e395d3d533f65d08875eedf85027ba714..a763d6c6b4d3cdc9e356086a607b012225d9dbfc 100644 (file)
        (&bt_g_array_index((_mapping)->ranges,                          \
                struct bt_field_class_enumeration_mapping_range, (_index)))
 
+enum field_xref_kind {
+       /*
+        * Start at 1 to be able to differentiate a zero-initialized field from
+        * an initialized field.
+        */
+       FIELD_XREF_KIND_PATH = 1,
+       FIELD_XREF_KIND_LOCATION,
+};
+
 struct bt_field_class {
        struct bt_object base;
        enum bt_field_class_type type;
@@ -154,11 +163,24 @@ struct bt_field_class_array_static {
 struct bt_field_class_array_dynamic {
        struct bt_field_class_array common;
 
-       /* Owned by this */
-       struct bt_field_class *length_fc;
+       /* Used with BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD */
+       struct {
+               enum field_xref_kind xref_kind;
 
-       /* Owned by this */
-       struct bt_field_path *length_field_path;
+               union {
+                       /* Used with FIELD_XREF_KIND_PATH */
+                       struct {
+                               /* Owned by this */
+                               struct bt_field_class *class;
+
+                               /* Owned by this */
+                               struct bt_field_path *path;
+                       } path;
+
+                       /* Used with FIELD_XREF_KIND_LOCATION, owned by this */
+                       const struct bt_field_location *location;
+               };
+       } length_field;
 };
 
 struct bt_field_class_option {
@@ -171,11 +193,21 @@ struct bt_field_class_option {
 struct bt_field_class_option_with_selector_field {
        struct bt_field_class_option common;
 
-       /* Owned by this */
-       struct bt_field_class *selector_fc;
+       enum field_xref_kind selector_field_xref_kind;
 
-       /* Owned by this */
-       struct bt_field_path *selector_field_path;
+       union {
+               /* Used with FIELD_XREF_KIND_PATH */
+               struct {
+                       /* Owned by this */
+                       struct bt_field_class *class;
+
+                       /* Owned by this */
+                       struct bt_field_path *path;
+               } path;
+
+               /* Used with FIELD_XREF_KIND_LOCATION, owned by this */
+               const struct bt_field_location *location;
+       } selector_field;
 };
 
 struct bt_field_class_option_with_selector_field_bool {
@@ -215,14 +247,24 @@ struct bt_field_class_variant {
 struct bt_field_class_variant_with_selector_field {
        struct bt_field_class_variant common;
 
-       /*
-        * Owned by this, but never dereferenced: only use to find it
-        * elsewhere.
-        */
-       const struct bt_field_class *selector_fc;
+       enum field_xref_kind selector_field_xref_kind;
 
-       /* Owned by this */
-       struct bt_field_path *selector_field_path;
+       union {
+               /* Used with FIELD_XREF_KIND_PATH */
+               struct {
+                       /*
+                       * Owned by this, but never dereferenced: only use to find it
+                       * elsewhere.
+                       */
+                       const struct bt_field_class *class;
+
+                       /* Owned by this */
+                       struct bt_field_path *path;
+               } path;
+
+               /* Used with FIELD_XREF_KIND_LOCATION, owned by this */
+               const struct bt_field_location *location;
+       } selector_field;
 };
 
 void _bt_field_class_freeze(const struct bt_field_class *field_class);
index 6c60a57e7c4dfeedf76f204b60c7a168f4490ad5..46f6f14fa54e39dd27b67040bda976a02fcaf913 100644 (file)
@@ -518,37 +518,42 @@ int bt_resolve_field_paths(struct bt_field_class *fc,
                        BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD)) {
                struct bt_field_class_option_with_selector_field *opt_fc = (void *) fc;
 
-               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, __func__);
-               if (!opt_fc->selector_field_path) {
-                       ret = -1;
-                       goto end;
+               if (opt_fc->selector_field_xref_kind == FIELD_XREF_KIND_PATH) {
+                       BT_ASSERT(opt_fc->selector_field.path.class);
+                       BT_ASSERT(!opt_fc->selector_field.path.path);
+                       opt_fc->selector_field.path.path = resolve_field_path(
+                               fc, opt_fc->selector_field.path.class, ctx, __func__);
+                       if (!opt_fc->selector_field.path.path) {
+                               ret = -1;
+                               goto end;
+                       }
                }
        } else if (fc->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) {
                struct bt_field_class_array_dynamic *dyn_array_fc = (void *) fc;
 
-               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, __func__);
-               if (!dyn_array_fc->length_field_path) {
-                       ret = -1;
-                       goto end;
+               if (dyn_array_fc->length_field.xref_kind == FIELD_XREF_KIND_PATH) {
+                       BT_ASSERT(dyn_array_fc->length_field.path.class);
+                       BT_ASSERT(!dyn_array_fc->length_field.path.path);
+                       dyn_array_fc->length_field.path.path = resolve_field_path(
+                               fc, dyn_array_fc->length_field.path.class, ctx, __func__);
+                       if (!dyn_array_fc->length_field.path.path) {
+                               ret = -1;
+                               goto end;
+                       }
                }
        } else if (bt_field_class_type_is(fc->type,
                        BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD)) {
                struct bt_field_class_variant_with_selector_field *var_fc =
                        (void *) fc;
 
-               if (var_fc->selector_fc) {
-                       BT_ASSERT(!var_fc->selector_field_path);
-                       var_fc->selector_field_path =
+               if (var_fc->selector_field_xref_kind == FIELD_XREF_KIND_PATH) {
+                       BT_ASSERT(var_fc->selector_field.path.class);
+                       BT_ASSERT(!var_fc->selector_field.path.path);
+                       var_fc->selector_field.path.path =
                                resolve_field_path(fc,
-                                       (void *) var_fc->selector_fc, ctx,
+                                       (void *) var_fc->selector_field.path.class, ctx,
                                        __func__);
-                       if (!var_fc->selector_field_path) {
+                       if (!var_fc->selector_field.path.path) {
                                ret = -1;
                                goto end;
                        }
This page took 0.066346 seconds and 4 git commands to generate.