2 * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 #define BT_COMP_LOG_SELF_COMP (ctx->self_comp)
24 #define BT_LOG_OUTPUT_LEVEL (ctx->log_level)
25 #define BT_LOG_TAG "PLUGIN/SINK.CTF.FS/TRANSLATE-TRACE-IR-TO-CTF-IR"
26 #include "logging/comp-logging.h"
28 #include <babeltrace2/babeltrace.h>
29 #include "common/macros.h"
30 #include "common/common.h"
31 #include "common/assert.h"
38 #include "fs-sink-ctf-meta.h"
40 struct field_path_elem
{
41 uint64_t index_in_parent
;
45 const bt_field_class
*ir_fc
;
48 struct fs_sink_ctf_field_class
*parent_fc
;
52 bt_logging_level log_level
;
53 bt_self_component
*self_comp
;
56 struct fs_sink_ctf_stream_class
*cur_sc
;
59 struct fs_sink_ctf_event_class
*cur_ec
;
61 bt_field_path_scope cur_scope
;
64 * Array of `struct field_path_elem` */
69 struct field_path_elem
*cur_path_stack_at(struct ctx
*ctx
, uint64_t i
)
71 BT_ASSERT(i
< ctx
->cur_path
->len
);
72 return &g_array_index(ctx
->cur_path
, struct field_path_elem
, i
);
76 struct field_path_elem
*cur_path_stack_top(struct ctx
*ctx
)
78 BT_ASSERT(ctx
->cur_path
->len
> 0);
79 return cur_path_stack_at(ctx
, ctx
->cur_path
->len
- 1);
83 bool is_reserved_member_name(const char *name
, const char *reserved_name
)
85 bool is_reserved
= false;
87 if (strcmp(name
, reserved_name
) == 0) {
92 if (name
[0] == '_' && strcmp(&name
[1], reserved_name
) == 0) {
101 static const char *reserved_tsdl_keywords
[] = {
133 bool ist_valid_identifier(const char *name
)
137 bool ist_valid
= true;
139 /* Make sure the name is not a reserved keyword */
140 for (i
= 0; i
< sizeof(reserved_tsdl_keywords
) / sizeof(*reserved_tsdl_keywords
);
142 if (strcmp(name
, reserved_tsdl_keywords
[i
]) == 0) {
148 /* Make sure the name is not an empty string */
149 if (strlen(name
) == 0) {
154 /* Make sure the name starts with a letter or `_` */
155 if (!isalpha(name
[0]) && name
[0] != '_') {
160 /* Make sure the name only contains letters, digits, and `_` */
161 for (at
= name
; *at
!= '\0'; at
++) {
162 if (!isalnum(*at
) && *at
!= '_') {
173 bool must_protect_identifier(const char *name
)
176 bool must_protect
= false;
178 /* Protect a reserved keyword */
179 for (i
= 0; i
< sizeof(reserved_tsdl_keywords
) / sizeof(*reserved_tsdl_keywords
);
181 if (strcmp(name
, reserved_tsdl_keywords
[i
]) == 0) {
187 /* Protect an identifier which already starts with `_` */
188 if (name
[0] == '_') {
198 int cur_path_stack_push(struct ctx
*ctx
,
199 uint64_t index_in_parent
, const char *name
,
200 bool force_protect_name
, const bt_field_class
*ir_fc
,
201 struct fs_sink_ctf_field_class
*parent_fc
)
204 struct field_path_elem
*field_path_elem
;
206 g_array_set_size(ctx
->cur_path
, ctx
->cur_path
->len
+ 1);
207 field_path_elem
= cur_path_stack_top(ctx
);
208 field_path_elem
->index_in_parent
= index_in_parent
;
209 field_path_elem
->name
= g_string_new(NULL
);
212 if (force_protect_name
) {
213 g_string_assign(field_path_elem
->name
, "_");
216 g_string_append(field_path_elem
->name
, name
);
218 if (ctx
->cur_scope
== BT_FIELD_PATH_SCOPE_PACKET_CONTEXT
) {
219 if (is_reserved_member_name(name
, "packet_size") ||
220 is_reserved_member_name(name
, "content_size") ||
221 is_reserved_member_name(name
, "timestamp_begin") ||
222 is_reserved_member_name(name
, "timestamp_end") ||
223 is_reserved_member_name(name
, "events_discarded") ||
224 is_reserved_member_name(name
, "packet_seq_num")) {
225 BT_COMP_LOGE("Unsupported reserved TSDL structure field class member "
226 "or variant field class option name: name=\"%s\"",
233 if (!ist_valid_identifier(field_path_elem
->name
->str
)) {
235 BT_COMP_LOGE("Unsupported non-TSDL structure field class member "
236 "or variant field class option name: name=\"%s\"",
237 field_path_elem
->name
->str
);
242 field_path_elem
->ir_fc
= ir_fc
;
243 field_path_elem
->parent_fc
= parent_fc
;
250 void cur_path_stack_pop(struct ctx
*ctx
)
252 struct field_path_elem
*field_path_elem
;
254 BT_ASSERT(ctx
->cur_path
->len
> 0);
255 field_path_elem
= cur_path_stack_top(ctx
);
257 if (field_path_elem
->name
) {
258 g_string_free(field_path_elem
->name
, TRUE
);
259 field_path_elem
->name
= NULL
;
262 g_array_set_size(ctx
->cur_path
, ctx
->cur_path
->len
- 1);
266 * Creates a relative field ref (a single name) from IR field path
267 * `tgt_ir_field_path`.
269 * This function tries to locate the target field class recursively from
270 * the top to the bottom of the context's current path using only the
271 * target field class's own name. This is because many CTF reading tools
272 * do not support a relative field ref with more than one element, for
273 * example `prev_struct.len`.
275 * Returns a negative value if this resolving operation failed.
278 int create_relative_field_ref(struct ctx
*ctx
,
279 const bt_field_path
*tgt_ir_field_path
, GString
*tgt_field_ref
,
280 struct fs_sink_ctf_field_class
**user_tgt_fc
)
283 struct fs_sink_ctf_field_class
*tgt_fc
= NULL
;
286 const char *tgt_fc_name
= NULL
;
287 struct field_path_elem
*field_path_elem
;
289 /* Get target field class's name */
290 switch (bt_field_path_get_root_scope(tgt_ir_field_path
)) {
291 case BT_FIELD_PATH_SCOPE_PACKET_CONTEXT
:
292 BT_ASSERT(ctx
->cur_sc
);
293 tgt_fc
= ctx
->cur_sc
->packet_context_fc
;
295 case BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT
:
296 BT_ASSERT(ctx
->cur_sc
);
297 tgt_fc
= ctx
->cur_sc
->event_common_context_fc
;
299 case BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT
:
300 BT_ASSERT(ctx
->cur_ec
);
301 tgt_fc
= ctx
->cur_ec
->spec_context_fc
;
303 case BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD
:
304 BT_ASSERT(ctx
->cur_ec
);
305 tgt_fc
= ctx
->cur_ec
->payload_fc
;
313 while (i
< bt_field_path_get_item_count(tgt_ir_field_path
)) {
314 const bt_field_path_item
*fp_item
=
315 bt_field_path_borrow_item_by_index_const(
316 tgt_ir_field_path
, i
);
317 struct fs_sink_ctf_named_field_class
*named_fc
= NULL
;
322 switch (tgt_fc
->type
) {
323 case FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT
:
324 BT_ASSERT(bt_field_path_item_get_type(fp_item
) ==
325 BT_FIELD_PATH_ITEM_TYPE_INDEX
);
326 named_fc
= fs_sink_ctf_field_class_struct_borrow_member_by_index(
328 bt_field_path_item_index_get_index(fp_item
));
330 case FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT
:
331 BT_ASSERT(bt_field_path_item_get_type(fp_item
) ==
332 BT_FIELD_PATH_ITEM_TYPE_INDEX
);
333 named_fc
= fs_sink_ctf_field_class_variant_borrow_option_by_index(
335 bt_field_path_item_index_get_index(fp_item
));
337 case FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY
:
338 case FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE
:
340 struct fs_sink_ctf_field_class_array_base
*array_base_fc
=
343 BT_ASSERT(bt_field_path_item_get_type(fp_item
) ==
344 BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT
);
345 tgt_fc
= array_base_fc
->elem_fc
;
353 tgt_fc
= named_fc
->fc
;
354 tgt_fc_name
= named_fc
->name
->str
;
360 BT_ASSERT(tgt_fc
->type
== FS_SINK_CTF_FIELD_CLASS_TYPE_INT
);
361 BT_ASSERT(tgt_fc_name
);
363 /* Find target field class having this name in current context */
364 for (si
= ctx
->cur_path
->len
- 1; si
>= 0; si
--) {
365 struct fs_sink_ctf_field_class
*fc
;
366 struct fs_sink_ctf_field_class_struct
*struct_fc
;
367 struct fs_sink_ctf_field_class_variant
*var_fc
;
368 struct fs_sink_ctf_named_field_class
*named_fc
;
371 field_path_elem
= cur_path_stack_at(ctx
, (uint64_t) si
);
372 fc
= field_path_elem
->parent_fc
;
374 /* Reached stack's bottom */
380 case FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT
:
381 case FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT
:
383 case FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY
:
384 case FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE
:
387 /* Not supported by TSDL 1.8 */
392 if (fc
->type
== FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT
) {
393 struct_fc
= (void *) fc
;
394 len
= struct_fc
->members
->len
;
396 var_fc
= (void *) fc
;
397 len
= var_fc
->options
->len
;
400 for (i
= 0; i
< len
; i
++) {
401 if (fc
->type
== FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT
) {
402 named_fc
= fs_sink_ctf_field_class_struct_borrow_member_by_index(
405 named_fc
= fs_sink_ctf_field_class_variant_borrow_option_by_index(
409 if (strcmp(named_fc
->name
->str
, tgt_fc_name
) == 0) {
410 if (named_fc
->fc
== tgt_fc
) {
411 g_string_assign(tgt_field_ref
,
415 *user_tgt_fc
= tgt_fc
;
419 * Using only the target field
420 * class's name, we're not
421 * reaching the target field
422 * class. This is not supported
438 * Creates an absolute field ref from IR field path `tgt_ir_field_path`.
440 * Returns a negative value if this resolving operation failed.
443 int create_absolute_field_ref(struct ctx
*ctx
,
444 const bt_field_path
*tgt_ir_field_path
, GString
*tgt_field_ref
,
445 struct fs_sink_ctf_field_class
**user_tgt_fc
)
448 struct fs_sink_ctf_field_class
*fc
= NULL
;
451 switch (bt_field_path_get_root_scope(tgt_ir_field_path
)) {
452 case BT_FIELD_PATH_SCOPE_PACKET_CONTEXT
:
453 BT_ASSERT(ctx
->cur_sc
);
454 fc
= ctx
->cur_sc
->packet_context_fc
;
455 g_string_assign(tgt_field_ref
, "stream.packet.context");
457 case BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT
:
458 BT_ASSERT(ctx
->cur_sc
);
459 fc
= ctx
->cur_sc
->event_common_context_fc
;
460 g_string_assign(tgt_field_ref
, "stream.event.context");
462 case BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT
:
463 BT_ASSERT(ctx
->cur_ec
);
464 fc
= ctx
->cur_ec
->spec_context_fc
;
465 g_string_assign(tgt_field_ref
, "event.context");
467 case BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD
:
468 BT_ASSERT(ctx
->cur_ec
);
469 fc
= ctx
->cur_ec
->payload_fc
;
470 g_string_assign(tgt_field_ref
, "event.fields");
478 for (i
= 0; i
< bt_field_path_get_item_count(tgt_ir_field_path
); i
++) {
479 const bt_field_path_item
*fp_item
=
480 bt_field_path_borrow_item_by_index_const(
481 tgt_ir_field_path
, i
);
482 struct fs_sink_ctf_named_field_class
*named_fc
= NULL
;
484 if (bt_field_path_item_get_type(fp_item
) !=
485 BT_FIELD_PATH_ITEM_TYPE_INDEX
) {
486 /* Not supported by TSDL 1.8 */
492 case FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT
:
493 BT_ASSERT(bt_field_path_item_get_type(fp_item
) ==
494 BT_FIELD_PATH_ITEM_TYPE_INDEX
);
495 named_fc
= fs_sink_ctf_field_class_struct_borrow_member_by_index(
497 bt_field_path_item_index_get_index(fp_item
));
499 case FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT
:
500 BT_ASSERT(bt_field_path_item_get_type(fp_item
) ==
501 BT_FIELD_PATH_ITEM_TYPE_INDEX
);
502 named_fc
= fs_sink_ctf_field_class_variant_borrow_option_by_index(
504 bt_field_path_item_index_get_index(fp_item
));
511 g_string_append_c(tgt_field_ref
, '.');
512 g_string_append(tgt_field_ref
, named_fc
->name
->str
);
525 * Resolves a target field class located at `tgt_ir_field_path`, writing
526 * the resolved field ref to `tgt_field_ref` and setting
527 * `*create_before` according to whether or not the target field must be
528 * created immediately before (in which case `tgt_field_ref` is
532 void resolve_field_class(struct ctx
*ctx
,
533 const bt_field_path
*tgt_ir_field_path
,
534 GString
*tgt_field_ref
, bool *create_before
,
535 struct fs_sink_ctf_field_class
**user_tgt_fc
)
538 bt_field_path_scope tgt_scope
;
540 *create_before
= false;
542 if (!tgt_ir_field_path
) {
543 *create_before
= true;
547 tgt_scope
= bt_field_path_get_root_scope(tgt_ir_field_path
);
549 if (tgt_scope
== ctx
->cur_scope
) {
551 * Try, in this order:
553 * 1. Use a relative path, using only the target field
554 * class's name. This is what is the most commonly
555 * supported by popular CTF reading tools.
557 * 2. Use an absolute path. This could fail if there's
558 * an array field class from the current root's field
559 * class to the target field class.
561 * 3. Create the target field class before the
562 * requesting field class (fallback).
564 ret
= create_relative_field_ref(ctx
, tgt_ir_field_path
,
565 tgt_field_ref
, user_tgt_fc
);
567 ret
= create_absolute_field_ref(ctx
, tgt_ir_field_path
,
568 tgt_field_ref
, user_tgt_fc
);
570 *create_before
= true;
576 ret
= create_absolute_field_ref(ctx
, tgt_ir_field_path
,
577 tgt_field_ref
, user_tgt_fc
);
579 /* It must always work in previous scopes */
588 int translate_field_class(struct ctx
*ctx
);
591 void append_to_parent_field_class(struct ctx
*ctx
,
592 struct fs_sink_ctf_field_class
*fc
)
594 struct fs_sink_ctf_field_class
*parent_fc
=
595 cur_path_stack_top(ctx
)->parent_fc
;
597 switch (parent_fc
->type
) {
598 case FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT
:
599 fs_sink_ctf_field_class_struct_append_member((void *) parent_fc
,
600 cur_path_stack_top(ctx
)->name
->str
, fc
);
602 case FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT
:
603 fs_sink_ctf_field_class_variant_append_option((void *) parent_fc
,
604 cur_path_stack_top(ctx
)->name
->str
, fc
);
606 case FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY
:
607 case FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE
:
609 struct fs_sink_ctf_field_class_array_base
*array_base_fc
=
612 BT_ASSERT(!array_base_fc
->elem_fc
);
613 array_base_fc
->elem_fc
= fc
;
614 array_base_fc
->base
.alignment
= fc
->alignment
;
623 void update_parent_field_class_alignment(struct ctx
*ctx
,
624 unsigned int alignment
)
626 struct fs_sink_ctf_field_class
*parent_fc
=
627 cur_path_stack_top(ctx
)->parent_fc
;
629 switch (parent_fc
->type
) {
630 case FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT
:
631 fs_sink_ctf_field_class_struct_align_at_least(
632 (void *) parent_fc
, alignment
);
634 case FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY
:
635 case FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE
:
637 struct fs_sink_ctf_field_class_array_base
*array_base_fc
=
640 array_base_fc
->base
.alignment
= alignment
;
649 int translate_structure_field_class_members(struct ctx
*ctx
,
650 struct fs_sink_ctf_field_class_struct
*struct_fc
,
651 const bt_field_class
*ir_fc
)
656 for (i
= 0; i
< bt_field_class_structure_get_member_count(ir_fc
); i
++) {
657 const bt_field_class_structure_member
*member
;
659 const bt_field_class
*memb_ir_fc
;
662 bt_field_class_structure_borrow_member_by_index_const(
664 name
= bt_field_class_structure_member_get_name(member
);
665 memb_ir_fc
= bt_field_class_structure_member_borrow_field_class_const(
667 ret
= cur_path_stack_push(ctx
, i
, name
, true, memb_ir_fc
,
670 BT_COMP_LOGE("Cannot translate structure field class member: "
671 "name=\"%s\"", name
);
675 ret
= translate_field_class(ctx
);
677 BT_COMP_LOGE("Cannot translate structure field class member: "
678 "name=\"%s\"", name
);
682 cur_path_stack_pop(ctx
);
690 int translate_structure_field_class(struct ctx
*ctx
)
693 struct fs_sink_ctf_field_class_struct
*fc
=
694 fs_sink_ctf_field_class_struct_create_empty(
695 cur_path_stack_top(ctx
)->ir_fc
,
696 cur_path_stack_top(ctx
)->index_in_parent
);
699 append_to_parent_field_class(ctx
, (void *) fc
);
700 ret
= translate_structure_field_class_members(ctx
, fc
, fc
->base
.ir_fc
);
705 update_parent_field_class_alignment(ctx
, fc
->base
.alignment
);
712 * This function indicates whether or not a given variant FC option name
713 * must be protected (with the `_` prefix).
715 * One of the goals of `sink.ctf.fs` is to write a CTF trace which is as
716 * close as possible to an original CTF trace as decoded by
719 * This scenario is valid in CTF 1.8:
731 * Once in trace IR, the enumeration FC mapping names and variant FC
732 * option names are kept as is. For this reason, we don't want to
733 * protect the variant FC option names here (by prepending `_`): this
734 * would make the variant FC option name and the enumeration FC mapping
737 * This scenario is also valid in CTF 1.8:
749 * Once in trace IR, the enumeration FC mapping names are kept as is,
750 * but the `_HELLO` variant FC option name becomes `HELLO` (unprotected
751 * for presentation, as recommended by CTF 1.8). When going back to
752 * TSDL, we need to protect `HELLO` so that it becomes `_HELLO` to match
753 * the corresponding enumeration FC mapping name.
755 * This scenario is also valid in CTF 1.8:
767 * Once in trace IR, the enumeration FC mapping names are kept as is,
768 * but the `__HELLO` variant FC option name becomes `_HELLO`
769 * (unprotected). When going back to TSDL, we need to protect `_HELLO`
770 * so that it becomes `__HELLO` to match the corresponding enumeration
773 * `src.ctf.fs` always uses the _same_ integer range sets for a selector
774 * FC mapping and a corresponding variant FC option. We can use that
775 * fact to find the original variant FC option names by matching variant
776 * FC options and enumeration FC mappings by range set.
779 int must_protect_variant_option_name(const bt_field_class
*ir_var_fc
,
780 const bt_field_class
*ir_tag_fc
, uint64_t opt_i
,
781 GString
*name_buf
, bool *must_protect
)
785 bt_field_class_type ir_var_fc_type
;
786 const void *opt_ranges
= NULL
;
787 const char *mapping_label
= NULL
;
788 const char *ir_opt_name
;
789 const bt_field_class_variant_option
*base_var_opt
;
790 bool force_protect
= false;
792 *must_protect
= false;
793 ir_var_fc_type
= bt_field_class_get_type(ir_var_fc
);
794 base_var_opt
= bt_field_class_variant_borrow_option_by_index_const(
796 BT_ASSERT(base_var_opt
);
797 ir_opt_name
= bt_field_class_variant_option_get_name(base_var_opt
);
798 BT_ASSERT(ir_opt_name
);
801 * Check if the variant FC option name is required to be
802 * protected (reserved TSDL keyword or starts with `_`). In that
803 * case, the name of the selector FC mapping we find must match
804 * exactly the protected name.
806 force_protect
= must_protect_identifier(ir_opt_name
);
808 *must_protect
= true;
809 g_string_assign(name_buf
, "_");
810 g_string_append(name_buf
, ir_opt_name
);
812 g_string_assign(name_buf
, ir_opt_name
);
815 /* Borrow option's ranges */
816 if (ir_var_fc_type
== BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR
) {
817 /* No ranges: we're done */
819 } if (ir_var_fc_type
== BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR
) {
820 const bt_field_class_variant_with_selector_unsigned_option
*var_opt
=
821 bt_field_class_variant_with_selector_unsigned_borrow_option_by_index_const(
824 bt_field_class_variant_with_selector_unsigned_option_borrow_ranges_const(
827 const bt_field_class_variant_with_selector_signed_option
*var_opt
=
828 bt_field_class_variant_with_selector_signed_borrow_option_by_index_const(
831 bt_field_class_variant_with_selector_signed_option_borrow_ranges_const(
835 /* Find corresponding mapping by range set in selector FC */
836 for (i
= 0; i
< bt_field_class_enumeration_get_mapping_count(ir_tag_fc
);
838 if (ir_var_fc_type
== BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR
) {
839 const bt_field_class_enumeration_mapping
*mapping_base
;
840 const bt_field_class_enumeration_unsigned_mapping
*mapping
;
841 const bt_integer_range_set_unsigned
*mapping_ranges
;
843 mapping
= bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const(
845 mapping_ranges
= bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const(
848 if (bt_integer_range_set_unsigned_compare(opt_ranges
,
850 /* We have a winner */
852 bt_field_class_enumeration_unsigned_mapping_as_mapping_const(
855 bt_field_class_enumeration_mapping_get_label(
860 const bt_field_class_enumeration_mapping
*mapping_base
;
861 const bt_field_class_enumeration_signed_mapping
*mapping
;
862 const bt_integer_range_set_signed
*mapping_ranges
;
864 mapping
= bt_field_class_enumeration_signed_borrow_mapping_by_index_const(
866 mapping_ranges
= bt_field_class_enumeration_signed_mapping_borrow_ranges_const(
869 if (bt_integer_range_set_signed_compare(opt_ranges
,
871 /* We have a winner */
873 bt_field_class_enumeration_signed_mapping_as_mapping_const(
876 bt_field_class_enumeration_mapping_get_label(
883 if (!mapping_label
) {
884 /* Range set not found: invalid selector for CTF 1.8 */
890 * If the enumeration FC mapping name is not the same as the
891 * variant FC option name and we didn't protect already, try
892 * protecting the option name and check again.
894 if (strcmp(mapping_label
, name_buf
->str
) != 0) {
900 if (mapping_label
[0] == '\0') {
905 g_string_assign(name_buf
, "_");
906 g_string_append(name_buf
, ir_opt_name
);
908 if (strcmp(mapping_label
, name_buf
->str
) != 0) {
914 * If this comes from a `src.ctf.fs` source, it looks
915 * like the variant FC option name was initially
916 * protected: protect it again when going back to TSDL.
918 *must_protect
= true;
926 int translate_variant_field_class(struct ctx
*ctx
)
930 struct fs_sink_ctf_field_class_variant
*fc
=
931 fs_sink_ctf_field_class_variant_create_empty(
932 cur_path_stack_top(ctx
)->ir_fc
,
933 cur_path_stack_top(ctx
)->index_in_parent
);
934 bt_field_class_type ir_fc_type
;
935 const bt_field_path
*ir_selector_field_path
= NULL
;
936 struct fs_sink_ctf_field_class
*tgt_fc
= NULL
;
937 GString
*name_buf
= g_string_new(NULL
);
938 bt_value
*prot_opt_names
= bt_value_array_create();
943 BT_ASSERT(prot_opt_names
);
944 ir_fc_type
= bt_field_class_get_type(fc
->base
.ir_fc
);
945 opt_count
= bt_field_class_variant_get_option_count(fc
->base
.ir_fc
);
947 if (ir_fc_type
== BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR
||
948 ir_fc_type
== BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR
) {
949 ir_selector_field_path
= bt_field_class_variant_with_selector_borrow_selector_field_path_const(
951 BT_ASSERT(ir_selector_field_path
);
954 /* Resolve tag field class before appending to parent */
955 resolve_field_class(ctx
, ir_selector_field_path
, fc
->tag_ref
,
956 &fc
->tag_is_before
, &tgt_fc
);
958 if (ir_selector_field_path
&& tgt_fc
) {
959 uint64_t mapping_count
;
960 uint64_t option_count
;
962 /* CTF 1.8: selector FC must be an enumeration FC */
963 bt_field_class_type type
= bt_field_class_get_type(
966 if (type
!= BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION
&&
967 type
!= BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
) {
968 fc
->tag_is_before
= true;
973 * Call must_protect_variant_option_name() for each
974 * option below. In that case we also want selector FC
975 * to contain as many mappings as the variant FC has
978 mapping_count
= bt_field_class_enumeration_get_mapping_count(
980 option_count
= bt_field_class_variant_get_option_count(
983 if (mapping_count
!= option_count
) {
984 fc
->tag_is_before
= true;
989 * No compatible selector field class for CTF 1.8:
990 * create the appropriate selector field class.
992 fc
->tag_is_before
= true;
997 * First pass: detect any option name clash with option name
998 * protection. In that case, we don't fail: just create the
999 * selector field class before the variant field class.
1001 * After this, `prot_opt_names` contains the final option names,
1002 * potentially protected if needed. They can still be invalid
1003 * TSDL identifiers however; this will be checked by
1004 * cur_path_stack_push().
1006 for (i
= 0; i
< opt_count
; i
++) {
1007 bool must_protect
= false;
1009 ret
= must_protect_variant_option_name(fc
->base
.ir_fc
,
1010 tgt_fc
->ir_fc
, i
, name_buf
, &must_protect
);
1012 fc
->tag_is_before
= true;
1015 ret
= bt_value_array_append_string_element(prot_opt_names
,
1022 for (i
= 0; i
< opt_count
; i
++) {
1024 const bt_value
*opt_name_a
=
1025 bt_value_array_borrow_element_by_index_const(
1028 for (j
= 0; j
< opt_count
; j
++) {
1029 const bt_value
*opt_name_b
;
1036 bt_value_array_borrow_element_by_index_const(
1038 if (bt_value_compare(opt_name_a
, opt_name_b
)) {
1040 * Variant FC option names are not
1041 * unique when protected.
1043 fc
->tag_is_before
= true;
1044 goto append_to_parent
;
1050 append_to_parent_field_class(ctx
, (void *) fc
);
1052 for (i
= 0; i
< opt_count
; i
++) {
1053 const bt_field_class_variant_option
*opt
;
1054 const bt_field_class
*opt_ir_fc
;
1055 const bt_value
*prot_opt_name_val
=
1056 bt_value_array_borrow_element_by_index_const(
1058 const char *prot_opt_name
= bt_value_string_get(
1061 BT_ASSERT(prot_opt_name
);
1062 opt
= bt_field_class_variant_borrow_option_by_index_const(
1064 opt_ir_fc
= bt_field_class_variant_option_borrow_field_class_const(
1068 * We don't ask cur_path_stack_push() to protect the
1069 * option name because it's already protected at this
1072 ret
= cur_path_stack_push(ctx
, i
, prot_opt_name
, false,
1073 opt_ir_fc
, (void *) fc
);
1075 BT_COMP_LOGE("Cannot translate variant field class option: "
1076 "name=\"%s\"", prot_opt_name
);
1080 ret
= translate_field_class(ctx
);
1082 BT_COMP_LOGE("Cannot translate variant field class option: "
1083 "name=\"%s\"", prot_opt_name
);
1087 cur_path_stack_pop(ctx
);
1092 g_string_free(name_buf
, TRUE
);
1095 bt_value_put_ref(prot_opt_names
);
1100 int translate_static_array_field_class(struct ctx
*ctx
)
1102 struct fs_sink_ctf_field_class_array
*fc
=
1103 fs_sink_ctf_field_class_array_create_empty(
1104 cur_path_stack_top(ctx
)->ir_fc
,
1105 cur_path_stack_top(ctx
)->index_in_parent
);
1106 const bt_field_class
*elem_ir_fc
=
1107 bt_field_class_array_borrow_element_field_class_const(
1108 fc
->base
.base
.ir_fc
);
1112 append_to_parent_field_class(ctx
, (void *) fc
);
1113 ret
= cur_path_stack_push(ctx
, UINT64_C(-1), NULL
, false, elem_ir_fc
,
1116 BT_COMP_LOGE_STR("Cannot translate static array field class element.");
1120 ret
= translate_field_class(ctx
);
1122 BT_COMP_LOGE_STR("Cannot translate static array field class element.");
1126 cur_path_stack_pop(ctx
);
1127 update_parent_field_class_alignment(ctx
, fc
->base
.base
.alignment
);
1134 int translate_dynamic_array_field_class(struct ctx
*ctx
)
1136 struct fs_sink_ctf_field_class_sequence
*fc
=
1137 fs_sink_ctf_field_class_sequence_create_empty(
1138 cur_path_stack_top(ctx
)->ir_fc
,
1139 cur_path_stack_top(ctx
)->index_in_parent
);
1140 const bt_field_class
*elem_ir_fc
=
1141 bt_field_class_array_borrow_element_field_class_const(
1142 fc
->base
.base
.ir_fc
);
1147 /* Resolve length field class before appending to parent */
1148 resolve_field_class(ctx
,
1149 bt_field_class_array_dynamic_borrow_length_field_path_const(
1150 fc
->base
.base
.ir_fc
),
1151 fc
->length_ref
, &fc
->length_is_before
, NULL
);
1153 append_to_parent_field_class(ctx
, (void *) fc
);
1154 ret
= cur_path_stack_push(ctx
, UINT64_C(-1), NULL
, false, elem_ir_fc
,
1157 BT_COMP_LOGE_STR("Cannot translate dynamic array field class element.");
1161 ret
= translate_field_class(ctx
);
1163 BT_COMP_LOGE_STR("Cannot translate dynamic array field class element.");
1167 cur_path_stack_pop(ctx
);
1168 update_parent_field_class_alignment(ctx
, fc
->base
.base
.alignment
);
1175 int translate_integer_field_class(struct ctx
*ctx
)
1177 struct fs_sink_ctf_field_class_int
*fc
=
1178 fs_sink_ctf_field_class_int_create(
1179 cur_path_stack_top(ctx
)->ir_fc
,
1180 cur_path_stack_top(ctx
)->index_in_parent
);
1183 append_to_parent_field_class(ctx
, (void *) fc
);
1188 int translate_real_field_class(struct ctx
*ctx
)
1190 struct fs_sink_ctf_field_class_float
*fc
=
1191 fs_sink_ctf_field_class_float_create(
1192 cur_path_stack_top(ctx
)->ir_fc
,
1193 cur_path_stack_top(ctx
)->index_in_parent
);
1196 append_to_parent_field_class(ctx
, (void *) fc
);
1201 int translate_string_field_class(struct ctx
*ctx
)
1203 struct fs_sink_ctf_field_class_string
*fc
=
1204 fs_sink_ctf_field_class_string_create(
1205 cur_path_stack_top(ctx
)->ir_fc
,
1206 cur_path_stack_top(ctx
)->index_in_parent
);
1209 append_to_parent_field_class(ctx
, (void *) fc
);
1214 * Translates a field class, recursively.
1216 * The field class's IR field class, parent field class, and index
1217 * within its parent are in the context's current path's top element
1218 * (cur_path_stack_top()).
1221 int translate_field_class(struct ctx
*ctx
)
1225 switch (bt_field_class_get_type(cur_path_stack_top(ctx
)->ir_fc
)) {
1226 case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER
:
1227 case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER
:
1228 case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION
:
1229 case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
:
1230 ret
= translate_integer_field_class(ctx
);
1232 case BT_FIELD_CLASS_TYPE_REAL
:
1233 ret
= translate_real_field_class(ctx
);
1235 case BT_FIELD_CLASS_TYPE_STRING
:
1236 ret
= translate_string_field_class(ctx
);
1238 case BT_FIELD_CLASS_TYPE_STRUCTURE
:
1239 ret
= translate_structure_field_class(ctx
);
1241 case BT_FIELD_CLASS_TYPE_STATIC_ARRAY
:
1242 ret
= translate_static_array_field_class(ctx
);
1244 case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY
:
1245 ret
= translate_dynamic_array_field_class(ctx
);
1247 case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR
:
1248 case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR
:
1249 case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR
:
1250 ret
= translate_variant_field_class(ctx
);
1260 int set_field_ref(struct fs_sink_ctf_field_class
*fc
, const char *fc_name
,
1261 struct fs_sink_ctf_field_class
*parent_fc
)
1264 GString
*field_ref
= NULL
;
1266 const char *tgt_type
;
1267 struct fs_sink_ctf_field_class_struct
*parent_struct_fc
=
1270 unsigned int suffix
= 0;
1272 if (!fc_name
|| !parent_fc
||
1273 parent_fc
->type
!= FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT
) {
1280 case FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE
:
1282 struct fs_sink_ctf_field_class_sequence
*seq_fc
= (void *) fc
;
1284 field_ref
= seq_fc
->length_ref
;
1285 is_before
= seq_fc
->length_is_before
;
1289 case FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT
:
1291 struct fs_sink_ctf_field_class_variant
*var_fc
= (void *) fc
;
1293 field_ref
= var_fc
->tag_ref
;
1294 is_before
= var_fc
->tag_is_before
;
1302 BT_ASSERT(field_ref
);
1308 /* Initial field ref */
1309 g_string_printf(field_ref
, "__%s_%s", fc_name
, tgt_type
);
1312 * Make sure field ref does not clash with an existing field
1313 * class name within the same parent structure field class.
1316 bool name_ok
= true;
1318 for (i
= 0; i
< parent_struct_fc
->members
->len
; i
++) {
1319 struct fs_sink_ctf_named_field_class
*named_fc
=
1320 fs_sink_ctf_field_class_struct_borrow_member_by_index(
1321 parent_struct_fc
, i
);
1323 if (strcmp(field_ref
->str
, named_fc
->name
->str
) == 0) {
1331 /* No clash: we're done */
1335 /* Append suffix and try again */
1336 g_string_printf(field_ref
, "__%s_%s_%u", fc_name
, tgt_type
,
1346 * This function recursively sets field refs of sequence and variant
1347 * field classes when they are immediately before, avoiding name clashes
1348 * with existing field class names.
1350 * It can fail at this point if, for example, a sequence field class of
1351 * which to set the length's field ref has something else than a
1352 * structure field class as its parent: in this case, there's no
1353 * location to place the length field class immediately before the
1354 * sequence field class.
1357 int set_field_refs(struct fs_sink_ctf_field_class
* const fc
,
1358 const char *fc_name
, struct fs_sink_ctf_field_class
*parent_fc
)
1361 enum fs_sink_ctf_field_class_type fc_type
;
1367 case FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT
:
1368 case FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT
:
1372 struct fs_sink_ctf_field_class_struct
*struct_fc
;
1373 struct fs_sink_ctf_field_class_variant
*var_fc
= NULL
;
1374 struct fs_sink_ctf_named_field_class
*named_fc
;
1376 if (fc_type
== FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT
) {
1377 struct_fc
= (void *) fc
;
1378 len
= struct_fc
->members
->len
;
1380 var_fc
= (void *) fc
;
1381 len
= var_fc
->options
->len
;
1382 ret
= set_field_ref(fc
, fc_name
, parent_fc
);
1388 for (i
= 0; i
< len
; i
++) {
1389 if (fc_type
== FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT
) {
1390 named_fc
= fs_sink_ctf_field_class_struct_borrow_member_by_index(
1393 named_fc
= fs_sink_ctf_field_class_variant_borrow_option_by_index(
1397 ret
= set_field_refs(named_fc
->fc
, named_fc
->name
->str
,
1406 case FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY
:
1407 case FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE
:
1409 struct fs_sink_ctf_field_class_array_base
*array_base_fc
=
1412 if (fc_type
== FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE
) {
1413 ret
= set_field_ref(fc
, fc_name
, parent_fc
);
1419 ret
= set_field_refs(array_base_fc
->elem_fc
, NULL
, fc
);
1435 * This function translates a root scope trace IR field class to
1436 * a CTF IR field class.
1438 * The resulting CTF IR field class is written to `*fc` so that it
1439 * exists as the parent object's (stream class or event class) true root
1440 * field class during the recursive translation for resolving purposes.
1441 * This is also why this function creates the empty structure field
1442 * class and then calls translate_structure_field_class_members() to
1446 int translate_scope_field_class(struct ctx
*ctx
, bt_field_path_scope scope
,
1447 struct fs_sink_ctf_field_class
**fc
,
1448 const bt_field_class
*ir_fc
)
1456 BT_ASSERT(bt_field_class_get_type(ir_fc
) ==
1457 BT_FIELD_CLASS_TYPE_STRUCTURE
);
1459 *fc
= (void *) fs_sink_ctf_field_class_struct_create_empty(
1460 ir_fc
, UINT64_C(-1));
1462 ctx
->cur_scope
= scope
;
1463 BT_ASSERT(ctx
->cur_path
->len
== 0);
1464 ret
= cur_path_stack_push(ctx
, UINT64_C(-1), NULL
, false, ir_fc
, NULL
);
1466 BT_COMP_LOGE("Cannot translate scope structure field class: "
1471 ret
= translate_structure_field_class_members(ctx
, (void *) *fc
, ir_fc
);
1473 BT_COMP_LOGE("Cannot translate scope structure field class: "
1478 cur_path_stack_pop(ctx
);
1480 /* Set field refs for preceding targets */
1481 ret
= set_field_refs(*fc
, NULL
, NULL
);
1488 void ctx_init(struct ctx
*ctx
, struct fs_sink_comp
*fs_sink
)
1490 memset(ctx
, 0, sizeof(struct ctx
));
1491 ctx
->cur_path
= g_array_new(FALSE
, TRUE
,
1492 sizeof(struct field_path_elem
));
1493 BT_ASSERT(ctx
->cur_path
);
1494 ctx
->log_level
= fs_sink
->log_level
;
1495 ctx
->self_comp
= fs_sink
->self_comp
;
1499 void ctx_fini(struct ctx
*ctx
)
1501 if (ctx
->cur_path
) {
1502 g_array_free(ctx
->cur_path
, TRUE
);
1503 ctx
->cur_path
= NULL
;
1508 int translate_event_class(struct fs_sink_comp
*fs_sink
,
1509 struct fs_sink_ctf_stream_class
*sc
,
1510 const bt_event_class
*ir_ec
,
1511 struct fs_sink_ctf_event_class
**out_ec
)
1515 struct fs_sink_ctf_event_class
*ec
;
1520 ctx_init(&ctx
, fs_sink
);
1521 ec
= fs_sink_ctf_event_class_create(sc
, ir_ec
);
1525 ret
= translate_scope_field_class(&ctx
, BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT
,
1526 &ec
->spec_context_fc
,
1527 bt_event_class_borrow_specific_context_field_class_const(
1533 ret
= translate_scope_field_class(&ctx
, BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD
,
1535 bt_event_class_borrow_payload_field_class_const(ir_ec
));
1547 int try_translate_event_class_trace_ir_to_ctf_ir(
1548 struct fs_sink_comp
*fs_sink
,
1549 struct fs_sink_ctf_stream_class
*sc
,
1550 const bt_event_class
*ir_ec
,
1551 struct fs_sink_ctf_event_class
**out_ec
)
1558 /* Check in hash table first */
1559 *out_ec
= g_hash_table_lookup(sc
->event_classes_from_ir
, ir_ec
);
1560 if (G_LIKELY(*out_ec
)) {
1564 ret
= translate_event_class(fs_sink
, sc
, ir_ec
, out_ec
);
1570 bool default_clock_class_name_exists(struct fs_sink_ctf_trace
*trace
,
1573 bool exists
= false;
1576 for (i
= 0; i
< trace
->stream_classes
->len
; i
++) {
1577 struct fs_sink_ctf_stream_class
*sc
=
1578 trace
->stream_classes
->pdata
[i
];
1580 if (sc
->default_clock_class_name
->len
== 0) {
1581 /* No default clock class */
1585 if (strcmp(sc
->default_clock_class_name
->str
, name
) == 0) {
1596 void make_unique_default_clock_class_name(struct fs_sink_ctf_stream_class
*sc
)
1598 unsigned int suffix
= 0;
1601 g_string_assign(sc
->default_clock_class_name
, "");
1602 sprintf(buf
, "default");
1604 while (default_clock_class_name_exists(sc
->trace
, buf
)) {
1605 sprintf(buf
, "default%u", suffix
);
1609 g_string_assign(sc
->default_clock_class_name
, buf
);
1613 int translate_stream_class(struct fs_sink_comp
*fs_sink
,
1614 struct fs_sink_ctf_trace
*trace
,
1615 const bt_stream_class
*ir_sc
,
1616 struct fs_sink_ctf_stream_class
**out_sc
)
1623 ctx_init(&ctx
, fs_sink
);
1624 *out_sc
= fs_sink_ctf_stream_class_create(trace
, ir_sc
);
1627 /* Set default clock class's protected name, if any */
1628 if ((*out_sc
)->default_clock_class
) {
1629 const char *name
= bt_clock_class_get_name(
1630 (*out_sc
)->default_clock_class
);
1633 /* Try original name, protected */
1634 g_string_assign((*out_sc
)->default_clock_class_name
,
1637 if (must_protect_identifier(name
)) {
1639 (*out_sc
)->default_clock_class_name
,
1643 g_string_assign((*out_sc
)->default_clock_class_name
,
1645 if (!ist_valid_identifier(
1646 (*out_sc
)->default_clock_class_name
->str
)) {
1647 /* Invalid: create a new name */
1648 make_unique_default_clock_class_name(*out_sc
);
1652 /* No name: create a name */
1653 make_unique_default_clock_class_name(*out_sc
);
1657 ctx
.cur_sc
= *out_sc
;
1658 ret
= translate_scope_field_class(&ctx
, BT_FIELD_PATH_SCOPE_PACKET_CONTEXT
,
1659 &(*out_sc
)->packet_context_fc
,
1660 bt_stream_class_borrow_packet_context_field_class_const(ir_sc
));
1665 if ((*out_sc
)->packet_context_fc
) {
1667 * Make sure the structure field class's alignment is
1668 * enough: 8 is what we use for our own special members
1669 * in the packet context.
1671 fs_sink_ctf_field_class_struct_align_at_least(
1672 (void *) (*out_sc
)->packet_context_fc
, 8);
1675 ret
= translate_scope_field_class(&ctx
, BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT
,
1676 &(*out_sc
)->event_common_context_fc
,
1677 bt_stream_class_borrow_event_common_context_field_class_const(
1686 fs_sink_ctf_stream_class_destroy(*out_sc
);
1695 int try_translate_stream_class_trace_ir_to_ctf_ir(
1696 struct fs_sink_comp
*fs_sink
,
1697 struct fs_sink_ctf_trace
*trace
,
1698 const bt_stream_class
*ir_sc
,
1699 struct fs_sink_ctf_stream_class
**out_sc
)
1707 for (i
= 0; i
< trace
->stream_classes
->len
; i
++) {
1708 *out_sc
= trace
->stream_classes
->pdata
[i
];
1710 if ((*out_sc
)->ir_sc
== ir_sc
) {
1715 ret
= translate_stream_class(fs_sink
, trace
, ir_sc
, out_sc
);
1722 struct fs_sink_ctf_trace
*translate_trace_trace_ir_to_ctf_ir(
1723 struct fs_sink_comp
*fs_sink
, const bt_trace
*ir_trace
)
1727 struct fs_sink_ctf_trace
*trace
= NULL
;
1729 /* Check that trace's environment is TSDL-compatible */
1730 count
= bt_trace_get_environment_entry_count(ir_trace
);
1731 for (i
= 0; i
< count
; i
++) {
1733 const bt_value
*val
;
1735 bt_trace_borrow_environment_entry_by_index_const(
1736 ir_trace
, i
, &name
, &val
);
1738 if (!ist_valid_identifier(name
)) {
1739 BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR
, fs_sink
->log_level
,
1741 "Unsupported trace class's environment entry name: "
1742 "name=\"%s\"", name
);
1746 switch (bt_value_get_type(val
)) {
1747 case BT_VALUE_TYPE_SIGNED_INTEGER
:
1748 case BT_VALUE_TYPE_STRING
:
1751 BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR
, fs_sink
->log_level
,
1753 "Unsupported trace class's environment entry value type: "
1755 bt_common_value_type_string(
1756 bt_value_get_type(val
)));
1761 trace
= fs_sink_ctf_trace_create(ir_trace
);