- seq_field = stack_top(notit->stack)->base;
- iret = bt_ctf_field_sequence_set_length(seq_field, length_field);
- if (iret) {
- BT_LOGE("Cannot set sequence field's length field: "
- "notit-addr=%p, seq-field-addr=%p, "
- "length-field-addr=%p, ",
- notit, seq_field, length_field);
- goto end;
- }
-
- ret = (int64_t) length;
-
-end:
- BT_PUT(length_field);
- BT_PUT(field_path);
-
- return ret;
-}
-
-static
-struct bt_ctf_field_type *btr_get_variant_type_cb(
- struct bt_ctf_field_type *type, void *data)
-{
- struct bt_ctf_field_path *path;
- struct bt_ctf_notif_iter *notit = data;
- struct bt_ctf_field *var_field;
- struct bt_ctf_field *tag_field = NULL;
- struct bt_ctf_field *selected_field = NULL;
- struct bt_ctf_field_type *selected_field_type = NULL;
-
- path = bt_ctf_field_type_variant_get_tag_field_path(type);
- assert(path);
- tag_field = resolve_field(notit, path);
- if (!tag_field) {
- BT_LOGW("Cannot resolve variant field type's tag field path: "
- "notit-addr=%p, ft-addr=%p",
- notit, type);
- goto end;
- }
-
- /*
- * We found the enumeration tag field instance which should be
- * able to select a current field for this variant. This
- * callback function we're in is called _after_
- * compound_begin(), so the current stack top's base field is
- * the variant field in question. We get the selected field here
- * thanks to this tag field (thus creating the selected field),
- * which will also provide us with its type. Then, this field
- * will remain the current selected one until the next callback
- * function call which is used to fill the current selected
- * field.
- */
- var_field = stack_top(notit->stack)->base;
- selected_field = bt_ctf_field_variant_get_field(var_field, tag_field);
- if (!selected_field) {
- BT_LOGW("Cannot get variant field's selection using tag field: "
- "notit-addr=%p, var-field-addr=%p, tag-field-addr=%p",
- notit, var_field, tag_field);
- goto end;
- }
-
- selected_field_type = bt_ctf_field_get_type(selected_field);
-
-end:
- BT_PUT(tag_field);
- BT_PUT(selected_field);
- BT_PUT(path);
-
- return selected_field_type;
-}
-
-static
-int set_event_clocks(struct bt_ctf_event *event,
- struct bt_ctf_notif_iter *notit)
-{
- int ret;
- GHashTableIter iter;
- struct bt_ctf_clock_class *clock_class;
- uint64_t *clock_state;
-
- g_hash_table_iter_init(&iter, notit->clock_states);
-
- while (g_hash_table_iter_next(&iter, (gpointer) &clock_class,
- (gpointer) &clock_state)) {
- struct bt_ctf_clock_value *clock_value;
-
- clock_value = bt_ctf_clock_value_create(clock_class,
- *clock_state);
- if (!clock_value) {
- BT_LOGE("Cannot create clock value from clock class: "
- "notit-addr=%p, clock-class-addr=%p, "
- "clock-class-name=\"%s\"",
- notit, clock_class,
- bt_ctf_clock_class_get_name(clock_class));
- ret = -1;
- goto end;
- }
- ret = bt_ctf_event_set_clock_value(event, clock_value);
- bt_put(clock_value);
- if (ret) {
- struct bt_ctf_event_class *event_class =
- bt_ctf_event_get_class(event);
-
- assert(event_class);
- BT_LOGE("Cannot set event's clock value: "
- "notit-addr=%p, event-addr=%p, "
- "event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", "
- "clock-class-addr=%p, "
- "clock-class-name=\"%s\", "
- "clock-value-addr=%p",
- notit, event,
- bt_ctf_event_class_get_name(event_class),
- bt_ctf_event_class_get_id(event_class),
- clock_class,
- bt_ctf_clock_class_get_name(clock_class),
- clock_value);
- bt_put(event_class);
- goto end;
- }