- A name, unique amongst all the option names of the same
variant field class.
+
+ The name is optional when the effective \bt_mip version of the
+ trace processing \bt_graph is 1.
+
- A field class.
+
- User attributes.
If an instance of the variant field class is linked to a selector
See the \ref api-tir-fc-var-prop-opts "options" property.
+This function may return \c NULL when the following are true:
+
+- The variant field class containing \bt_p{option} was created from a
+ \bt_trace_cls which was created from a \bt_comp which belongs
+ to a trace processing \bt_graph with the effective
+ \bt_mip version 1.
+
+- \bt_p{option} has no name.
+
@param[in] option
Variant field class option of which to get the name.
@returns
@parblock
- Name of \bt_p{option}.
+ Name of \bt_p{option}, or \c NULL if none
+ (possible under MIP 1).
The returned pointer remains valid as long as \bt_p{option} exists.
@endparblock
Variant field class to which to append an option having
the name \bt_p{name} and the field class \bt_p{option_field_class}.
@param[in] name
+ @parblock
Name of the option to append to \bt_p{field_class} (copied).
+
+ Can be \c NULL when the effective \bt_mip version of the trace
+ processing \bt_graph is 1.
+ @endparblock
@param[in] option_field_class
Field class of the option to append to \bt_p{field_class}.
@bt_pre_hot{field_class}
@bt_pre_is_var_wos_fc{field_class}
@pre
+ <strong>If \bt_p{name} is not \c NULL</strong>, then
\bt_p{field_class} has no option with the name \bt_p{name}.
-@bt_pre_not_null{name}
+@pre
+ <strong>If \bt_p{field_class} was created from a
+ \bt_trace_cls which was created from a \bt_comp which belongs
+ to a trace processing \bt_graph with the effective \bt_mip
+ version 0</strong>, then \bt_p{name} is \em not \c NULL.
@bt_pre_not_null{option_field_class}
@bt_pre_fc_not_in_tc{option_field_class}
the name \bt_p{name}, the field class \bt_p{option_field_class},
and the unsigned integer ranges \bt_p{ranges}.
@param[in] name
+ @parblock
Name of the option to append to \bt_p{field_class} (copied).
+
+ Can be \c NULL when the effective \bt_mip version of the trace
+ processing \bt_graph is 1.
+ @endparblock
@param[in] option_field_class
Field class of the option to append to \bt_p{field_class}.
@param[in] ranges
@bt_pre_hot{field_class}
@bt_pre_is_var_wuis_fc{field_class}
@pre
+ <strong>If \bt_p{name} is not \c NULL</strong>, then
\bt_p{field_class} has no option with the name \bt_p{name}.
-@bt_pre_not_null{name}
+@pre
+ <strong>If \bt_p{field_class} was created from a
+ \bt_trace_cls which was created from a \bt_comp which belongs
+ to a trace processing \bt_graph with the effective \bt_mip
+ version 0</strong>, then \bt_p{name} is \em not \c NULL.
@bt_pre_not_null{option_field_class}
@bt_pre_fc_not_in_tc{option_field_class}
@bt_pre_not_null{ŗanges}
the name \bt_p{name} and the field class \bt_p{option_field_class},
and the signed integer ranges \bt_p{ranges}.
@param[in] name
+ @parblock
Name of the option to append to \bt_p{field_class} (copied).
+
+ Can be \c NULL when the effective \bt_mip version of the trace
+ processing \bt_graph is 1.
+ @endparblock
@param[in] option_field_class
Field class of the option to append to \bt_p{field_class}.
@param[in] ranges
@bt_pre_hot{field_class}
@bt_pre_is_var_wsis_fc{field_class}
@pre
+ <strong>If \bt_p{name} is not \c NULL</strong>, then
\bt_p{field_class} has no option with the name \bt_p{name}.
-@bt_pre_not_null{name}
+@pre
+ <strong>If \bt_p{field_class} was created from a
+ \bt_trace_cls which was created from a \bt_comp which belongs
+ to a trace processing \bt_graph with the effective \bt_mip
+ version 0</strong>, then \bt_p{name} is \em not \c NULL.
@bt_pre_not_null{option_field_class}
@bt_pre_fc_not_in_tc{option_field_class}
@bt_pre_not_null{ŗanges}
int status = BT_FUNC_STATUS_OK;
BT_ASSERT(named_fc);
- BT_ASSERT(name);
BT_ASSERT(fc);
- named_fc->name = g_string_new(name);
- if (!named_fc->name) {
- BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
- status = BT_FUNC_STATUS_MEMORY_ERROR;
- goto end;
+
+ if (name) {
+ named_fc->name = g_string_new(name);
+ if (!named_fc->name) {
+ BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
+ status = BT_FUNC_STATUS_MEMORY_ERROR;
+ goto end;
+ }
}
named_fc->user_attributes = bt_value_map_create();
BT_ASSERT(named_fc);
BT_ASSERT_PRE_DEV_FC_HOT_FROM_FUNC(api_func, container_fc);
BT_ASSERT_PRE_FROM_FUNC(api_func, unique_entry_precond_id,
- !bt_g_hash_table_contains(container_fc->name_to_index,
- named_fc->name->str),
+ !named_fc->name ||
+ !bt_g_hash_table_contains(container_fc->name_to_index,
+ named_fc->name->str),
"Duplicate member/option name in structure/variant field class: "
"%![container-fc-]+F, name=\"%s\"", container_fc,
named_fc->name->str);
*/
bt_field_class_freeze(named_fc->fc);
g_ptr_array_add(container_fc->named_fcs, named_fc);
- g_hash_table_insert(container_fc->name_to_index, named_fc->name->str,
- GUINT_TO_POINTER(container_fc->named_fcs->len - 1));
+
+ if (named_fc->name) {
+ /*
+ * MIP > 0: a variant field class option may have no
+ * name.
+ */
+ g_hash_table_insert(container_fc->name_to_index,
+ named_fc->name->str,
+ GUINT_TO_POINTER(container_fc->named_fcs->len - 1));
+ }
+
return BT_FUNC_STATUS_OK;
}
BT_ASSERT_PRE_NO_ERROR();
BT_ASSERT_PRE_FC_NON_NULL(fc);
+ BT_ASSERT_PRE_NAME_NON_NULL(name);
BT_ASSERT_PRE_FC_IS_STRUCT("field-class", fc, "Field class");
named_fc = create_named_field_class(name, member_fc);
if (!named_fc) {
const struct bt_named_field_class *named_fc = (const void *) member;
BT_ASSERT_PRE_DEV_STRUCT_FC_MEMBER_NON_NULL(member);
+ BT_ASSERT_DBG(named_fc->name);
return named_fc->name->str;
}
BT_ASSERT_PRE_NO_ERROR();
BT_ASSERT_PRE_FC_NON_NULL(fc);
- BT_ASSERT_PRE_NAME_NON_NULL(name);
+
+ /* Name is mandatory in MIP 0, optional later. */
+ if (fc->mip_version == 0) {
+ BT_ASSERT_PRE_NAME_NON_NULL(name);
+ }
+
BT_ASSERT_PRE_NON_NULL("option-field-class", option_fc,
"Option field class");
BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
bool has_overlap;
BT_ASSERT(fc);
- BT_ASSERT_PRE_NAME_NON_NULL_FROM_FUNC(api_func, name);
+
+ /* Name is mandatory in MIP 0, optional later. */
+ if (fc->mip_version == 0) {
+ BT_ASSERT_PRE_NAME_NON_NULL_FROM_FUNC(api_func, name);
+ }
+
BT_ASSERT_PRE_NON_NULL_FROM_FUNC(api_func, "option-field-class",
option_fc, "Option field class");
BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL_FROM_FUNC(api_func, range_set);
const struct bt_named_field_class *named_fc = (const void *) option;
BT_ASSERT_PRE_DEV_VAR_FC_OPT_NON_NULL(option);
- return named_fc->name->str;
+
+ /* MIP > 0: a variant field class option may have no name */
+ return named_fc->name ? named_fc->name->str : NULL;
}
BT_EXPORT
/* A named field class is a (name, field class) pair */
struct bt_named_field_class {
+ /* MIP > 0: `NULL` if not set */
GString *name;
/* Owned by this */
/*
* Key: `const char *`, not owned by this (owned by named field
* class objects contained in `named_fcs` below).
+ *
+ * MIP > 0: the size of this hash table may be less than the
+ * size of `named_fcs` below because, for a variant field class,
+ * its option names are optional.
*/
GHashTable *name_to_index;