2 * Babeltrace - Trace IR field copy
4 * Copyright (c) 2015-2019 EfficiOS Inc. and Linux Foundation
5 * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
6 * Copyright (c) 2019 Francis Deslauriers <francis.deslauriers@efficios.com>
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 #define BT_COMP_LOG_SELF_COMP (md_maps->self_comp)
28 #define BT_LOG_OUTPUT_LEVEL (md_maps->log_level)
29 #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-META-FC-COPY"
30 #include "logging/comp-logging.h"
32 #include "common/assert.h"
33 #include "common/common.h"
34 #include "compat/compiler.h"
35 #include <babeltrace2/babeltrace.h>
37 #include "trace-ir-metadata-copy.h"
38 #include "trace-ir-metadata-field-class-copy.h"
41 * This fonction walks througth the nested structures field class to resolve a
42 * field path object. A field path is made of indexes inside possibly nested
43 * structures ultimately leading to a field class.
46 const bt_field_class
*walk_field_path(struct trace_ir_metadata_maps
*md_maps
,
47 const bt_field_path
*fp
, const bt_field_class
*fc
)
49 uint64_t i
, fp_item_count
;
50 const bt_field_class
*curr_fc
;
52 BT_ASSERT(bt_field_class_get_type(fc
) == BT_FIELD_CLASS_TYPE_STRUCTURE
);
53 BT_COMP_LOGD("Walking field path on field class: fp-addr=%p, fc-addr=%p",
56 fp_item_count
= bt_field_path_get_item_count(fp
);
58 for (i
= 0; i
< fp_item_count
; i
++) {
59 bt_field_class_type fc_type
= bt_field_class_get_type(curr_fc
);
60 const bt_field_path_item
*fp_item
=
61 bt_field_path_borrow_item_by_index_const(fp
, i
);
64 case BT_FIELD_CLASS_TYPE_STRUCTURE
:
66 const bt_field_class_structure_member
*member
;
68 BT_ASSERT(bt_field_path_item_get_type(fp_item
) ==
69 BT_FIELD_PATH_ITEM_TYPE_INDEX
);
70 member
= bt_field_class_structure_borrow_member_by_index_const(
72 bt_field_path_item_index_get_index(fp_item
));
73 curr_fc
= bt_field_class_structure_member_borrow_field_class_const(
77 case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR
:
78 case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR
:
79 case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR
:
81 const bt_field_class_variant_option
*option
;
83 BT_ASSERT(bt_field_path_item_get_type(fp_item
) ==
84 BT_FIELD_PATH_ITEM_TYPE_INDEX
);
85 option
= bt_field_class_variant_borrow_option_by_index_const(
87 bt_field_path_item_index_get_index(fp_item
));
88 curr_fc
= bt_field_class_variant_option_borrow_field_class_const(
92 case BT_FIELD_CLASS_TYPE_STATIC_ARRAY
:
93 case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY
:
95 BT_ASSERT(bt_field_path_item_get_type(fp_item
) ==
96 BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT
);
97 curr_fc
= bt_field_class_array_borrow_element_field_class_const(
110 const bt_field_class
*resolve_field_path_to_field_class(const bt_field_path
*fp
,
111 struct trace_ir_metadata_maps
*md_maps
)
113 struct field_class_resolving_context
*fc_resolving_ctx
;
114 const bt_field_class
*fc
;
115 bt_field_path_scope fp_scope
;
117 BT_COMP_LOGD("Resolving field path: fp-addr=%p", fp
);
119 fc_resolving_ctx
= md_maps
->fc_resolving_ctx
;
120 fp_scope
= bt_field_path_get_root_scope(fp
);
123 case BT_FIELD_PATH_SCOPE_PACKET_CONTEXT
:
124 fc
= walk_field_path(md_maps
, fp
,
125 fc_resolving_ctx
->packet_context
);
127 case BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT
:
128 fc
= walk_field_path(md_maps
, fp
,
129 fc_resolving_ctx
->event_common_context
);
131 case BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT
:
132 fc
= walk_field_path(md_maps
, fp
,
133 fc_resolving_ctx
->event_specific_context
);
135 case BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD
:
136 fc
= walk_field_path(md_maps
, fp
,
137 fc_resolving_ctx
->event_payload
);
147 void field_class_integer_set_props(const bt_field_class
*input_fc
,
148 bt_field_class
*output_fc
)
150 bt_field_class_integer_set_preferred_display_base(output_fc
,
151 bt_field_class_integer_get_preferred_display_base(input_fc
));
152 bt_field_class_integer_set_field_value_range(output_fc
,
153 bt_field_class_integer_get_field_value_range(input_fc
));
157 int field_class_bool_copy(
158 struct trace_ir_metadata_maps
*md_maps
,
159 const bt_field_class
*in_field_class
,
160 bt_field_class
*out_field_class
)
162 BT_COMP_LOGD("Copying content of boolean field class: "
163 "in-fc-addr=%p, out-fc-addr=%p",
164 in_field_class
, out_field_class
);
165 BT_COMP_LOGD("Copied content of boolean field class: "
166 "in-fc-addr=%p, out-fc-addr=%p",
167 in_field_class
, out_field_class
);
172 int field_class_unsigned_integer_copy(
173 struct trace_ir_metadata_maps
*md_maps
,
174 const bt_field_class
*in_field_class
,
175 bt_field_class
*out_field_class
)
177 BT_COMP_LOGD("Copying content of unsigned integer field class: "
178 "in-fc-addr=%p, out-fc-addr=%p",
179 in_field_class
, out_field_class
);
181 field_class_integer_set_props(in_field_class
, out_field_class
);
183 BT_COMP_LOGD("Copied content of unsigned integer field class: "
184 "in-fc-addr=%p, out-fc-addr=%p",
185 in_field_class
, out_field_class
);
190 int field_class_signed_integer_copy(
191 struct trace_ir_metadata_maps
*md_maps
,
192 const bt_field_class
*in_field_class
,
193 bt_field_class
*out_field_class
)
195 BT_COMP_LOGD("Copying content of signed integer field class: "
196 "in-fc-addr=%p, out-fc-addr=%p",
197 in_field_class
, out_field_class
);
199 field_class_integer_set_props(in_field_class
, out_field_class
);
201 BT_COMP_LOGD("Copied content of signed integer field class: "
202 "in-fc-addr=%p, out-fc-addr=%p",
203 in_field_class
, out_field_class
);
208 int field_class_unsigned_enumeration_copy(
209 struct trace_ir_metadata_maps
*md_maps
,
210 const bt_field_class
*in_field_class
,
211 bt_field_class
*out_field_class
)
213 uint64_t i
, enum_mapping_count
;
216 BT_COMP_LOGD("Copying content of unsigned enumeration field class: "
217 "in-fc-addr=%p, out-fc-addr=%p",
218 in_field_class
, out_field_class
);
220 /* Copy properties of the inner integer. */
221 field_class_integer_set_props(in_field_class
, out_field_class
);
223 /* Copy all enumeration entries. */
224 enum_mapping_count
= bt_field_class_enumeration_get_mapping_count(in_field_class
);
225 for (i
= 0; i
< enum_mapping_count
; i
++) {
227 const bt_integer_range_set_unsigned
*range_set
;
228 const bt_field_class_enumeration_unsigned_mapping
*u_mapping
;
229 const bt_field_class_enumeration_mapping
*mapping
;
231 u_mapping
= bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const(
233 mapping
= bt_field_class_enumeration_unsigned_mapping_as_mapping_const(
235 label
= bt_field_class_enumeration_mapping_get_label(mapping
);
236 range_set
= bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const(
238 ret
= bt_field_class_enumeration_unsigned_add_mapping(
239 out_field_class
, label
, range_set
);
245 BT_COMP_LOGD("Copied content of unsigned enumeration field class: "
246 "in-fc-addr=%p, out-fc-addr=%p",
247 in_field_class
, out_field_class
);
254 int field_class_signed_enumeration_copy(
255 struct trace_ir_metadata_maps
*md_maps
,
256 const bt_field_class
*in_field_class
,
257 bt_field_class
*out_field_class
)
259 uint64_t i
, enum_mapping_count
;
262 BT_COMP_LOGD("Copying content of signed enumeration field class: "
263 "in-fc-addr=%p, out-fc-addr=%p",
264 in_field_class
, out_field_class
);
266 /* Copy properties of the inner integer. */
267 field_class_integer_set_props(in_field_class
, out_field_class
);
269 /* Copy all enumeration entries. */
271 bt_field_class_enumeration_get_mapping_count(in_field_class
);
272 for (i
= 0; i
< enum_mapping_count
; i
++) {
274 const bt_integer_range_set_signed
*range_set
;
275 const bt_field_class_enumeration_signed_mapping
*s_mapping
;
276 const bt_field_class_enumeration_mapping
*mapping
;
278 s_mapping
= bt_field_class_enumeration_signed_borrow_mapping_by_index_const(
280 mapping
= bt_field_class_enumeration_signed_mapping_as_mapping_const(
282 label
= bt_field_class_enumeration_mapping_get_label(mapping
);
283 range_set
= bt_field_class_enumeration_signed_mapping_borrow_ranges_const(
285 ret
= bt_field_class_enumeration_signed_add_mapping(
286 out_field_class
, label
, range_set
);
292 BT_COMP_LOGD("Copied content of signed enumeration field class: "
293 "in-fc-addr=%p, out-fc-addr=%p",
294 in_field_class
, out_field_class
);
301 int field_class_real_copy(
302 struct trace_ir_metadata_maps
*md_maps
,
303 const bt_field_class
*in_field_class
,
304 bt_field_class
*out_field_class
)
306 BT_COMP_LOGD("Copying content of real field class: "
307 "in-fc-addr=%p, out-fc-addr=%p",
308 in_field_class
, out_field_class
);
310 bt_field_class_real_set_is_single_precision(out_field_class
,
311 bt_field_class_real_is_single_precision(in_field_class
));
313 BT_COMP_LOGD("Copied content real field class: in-fc-addr=%p, "
314 "out-fc-addr=%p", in_field_class
, out_field_class
);
320 int field_class_structure_copy(
321 struct trace_ir_metadata_maps
*md_maps
,
322 const bt_field_class
*in_field_class
,
323 bt_field_class
*out_field_class
)
325 uint64_t i
, struct_member_count
;
328 BT_COMP_LOGD("Copying content of structure field class: "
329 "in-fc-addr=%p, out-fc-addr=%p",
330 in_field_class
, out_field_class
);
331 /* Get the number of member in that struct. */
332 struct_member_count
=
333 bt_field_class_structure_get_member_count(in_field_class
);
335 /* Iterate over all the members of the struct. */
336 for (i
= 0; i
< struct_member_count
; i
++) {
337 const bt_field_class_structure_member
*member
;
338 const char *member_name
;
339 const bt_field_class
*member_fc
;
340 bt_field_class
*out_member_field_class
;
342 member
= bt_field_class_structure_borrow_member_by_index_const(
344 member_fc
= bt_field_class_structure_member_borrow_field_class_const(
346 member_name
= bt_field_class_structure_member_get_name(member
);
347 BT_COMP_LOGD("Copying structure field class's field: "
348 "index=%" PRId64
", "
349 "member-fc-addr=%p, field-name=\"%s\"",
350 i
, member_fc
, member_name
);
352 out_member_field_class
= create_field_class_copy(md_maps
,
354 if (!out_member_field_class
) {
355 BT_COMP_LOGE("Cannot copy structure field class's field: "
356 "index=%" PRId64
", "
357 "field-fc-addr=%p, field-name=\"%s\"",
358 i
, member_fc
, member_name
);
362 ret
= copy_field_class_content(md_maps
, member_fc
,
363 out_member_field_class
);
368 if (bt_field_class_structure_append_member(out_field_class
,
369 member_name
, out_member_field_class
) !=
370 BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK
) {
371 BT_COMP_LOGE("Cannot append structure field class's field: "
372 "index=%" PRId64
", "
373 "field-fc-addr=%p, field-name=\"%s\"",
374 i
, member_fc
, member_name
);
375 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_member_field_class
);
381 BT_COMP_LOGD("Copied structure field class: original-fc-addr=%p, copy-fc-addr=%p",
382 in_field_class
, out_field_class
);
389 int field_class_variant_copy(
390 struct trace_ir_metadata_maps
*md_maps
,
391 const bt_field_class
*in_field_class
,
392 bt_field_class
*out_field_class
)
394 bt_field_class
*out_tag_field_class
= NULL
;
395 uint64_t i
, variant_option_count
;
396 bt_field_class_type fc_type
= bt_field_class_get_type(in_field_class
);
399 BT_COMP_LOGD("Copying content of variant field class: "
400 "in-fc-addr=%p, out-fc-addr=%p",
401 in_field_class
, out_field_class
);
402 variant_option_count
=
403 bt_field_class_variant_get_option_count(in_field_class
);
404 for (i
= 0; i
< variant_option_count
; i
++) {
405 const bt_field_class
*option_fc
;
406 const char *option_name
;
407 bt_field_class
*out_option_field_class
;
408 const bt_field_class_variant_option
*option
;
410 option
= bt_field_class_variant_borrow_option_by_index_const(
412 option_fc
= bt_field_class_variant_option_borrow_field_class_const(
414 option_name
= bt_field_class_variant_option_get_name(option
);
415 out_option_field_class
= create_field_class_copy_internal(
417 if (!out_option_field_class
) {
418 BT_COMP_LOGE_STR("Cannot copy field class.");
422 ret
= copy_field_class_content_internal(md_maps
, option_fc
,
423 out_option_field_class
);
425 BT_COMP_LOGE_STR("Error copying content of option variant "
430 if (fc_type
== BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR
) {
431 const bt_field_class_variant_with_selector_unsigned_option
*spec_opt
=
432 bt_field_class_variant_with_selector_unsigned_borrow_option_by_index_const(
434 const bt_integer_range_set_unsigned
*ranges
=
435 bt_field_class_variant_with_selector_unsigned_option_borrow_ranges_const(
438 if (bt_field_class_variant_with_selector_unsigned_append_option(
439 out_field_class
, option_name
,
440 out_option_field_class
, ranges
) !=
441 BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_APPEND_OPTION_STATUS_OK
) {
442 BT_COMP_LOGE_STR("Cannot append option to variant field class with unsigned selector'");
443 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class
);
447 } else if (fc_type
== BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR
) {
448 const bt_field_class_variant_with_selector_signed_option
*spec_opt
=
449 bt_field_class_variant_with_selector_signed_borrow_option_by_index_const(
451 const bt_integer_range_set_signed
*ranges
=
452 bt_field_class_variant_with_selector_signed_option_borrow_ranges_const(
455 if (bt_field_class_variant_with_selector_signed_append_option(
456 out_field_class
, option_name
,
457 out_option_field_class
, ranges
) !=
458 BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_APPEND_OPTION_STATUS_OK
) {
459 BT_COMP_LOGE_STR("Cannot append option to variant field class with signed selector'");
460 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class
);
465 BT_ASSERT(fc_type
== BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR
);
467 if (bt_field_class_variant_without_selector_append_option(
468 out_field_class
, option_name
,
469 out_option_field_class
) !=
470 BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_APPEND_OPTION_STATUS_OK
) {
471 BT_COMP_LOGE_STR("Cannot append option to variant field class'");
472 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class
);
479 BT_COMP_LOGD("Copied content of variant field class: in-fc-addr=%p, "
480 "out-fc-addr=%p", in_field_class
, out_field_class
);
487 int field_class_static_array_copy(
488 struct trace_ir_metadata_maps
*md_maps
,
489 const bt_field_class
*in_field_class
,
490 bt_field_class
*out_field_class
)
492 BT_COMP_LOGD("Copying content of static array field class: in-fc-addr=%p, "
493 "out-fc-addr=%p", in_field_class
, out_field_class
);
495 * There is no content to copy. Keep this function call anyway for
498 BT_COMP_LOGD("Copied content of static array field class: in-fc-addr=%p, "
499 "out-fc-addr=%p", in_field_class
, out_field_class
);
505 int field_class_dynamic_array_copy(
506 struct trace_ir_metadata_maps
*md_maps
,
507 const bt_field_class
*in_field_class
,
508 bt_field_class
*out_field_class
)
510 BT_COMP_LOGD("Copying content of dynamic array field class: "
511 "in-fc-addr=%p, out-fc-addr=%p",
512 in_field_class
, out_field_class
);
515 * There is no content to copy. Keep this function call anyway for
518 BT_COMP_LOGD("Copied dynamic array field class: in-fc-addr=%p, "
519 "out-fc-addr=%p", in_field_class
, out_field_class
);
525 int field_class_string_copy(struct trace_ir_metadata_maps
*md_maps
,
526 const bt_field_class
*in_field_class
,
527 bt_field_class
*out_field_class
)
529 BT_COMP_LOGD("Copying content of string field class: in-fc-addr=%p, "
530 "out-fc-addr=%p", in_field_class
, out_field_class
);
532 * There is no content to copy. Keep this function call anyway for
535 BT_COMP_LOGD("Copied content of string field class: in-fc-addr=%p, "
536 "out-fc-addr=%p", in_field_class
, out_field_class
);
542 bt_field_class
*copy_field_class_array_element(struct trace_ir_metadata_maps
*md_maps
,
543 const bt_field_class
*in_elem_fc
)
546 bt_field_class
*out_elem_fc
=
547 create_field_class_copy_internal(md_maps
, in_elem_fc
);
549 BT_COMP_LOGE("Error creating output elem field class "
550 "from input elem field class for static array: "
551 "in-fc-addr=%p", in_elem_fc
);
555 ret
= copy_field_class_content_internal(md_maps
, in_elem_fc
, out_elem_fc
);
557 BT_COMP_LOGE("Error creating output elem field class "
558 "from input elem field class for static array: "
559 "in-fc-addr=%p", in_elem_fc
);
560 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_elem_fc
);
569 bt_field_class
*create_field_class_copy_internal(struct trace_ir_metadata_maps
*md_maps
,
570 const bt_field_class
*in_field_class
)
572 bt_field_class
*out_field_class
= NULL
;
573 bt_field_class_type fc_type
= bt_field_class_get_type(in_field_class
);
575 BT_COMP_LOGD("Creating bare field class based on field class: in-fc-addr=%p",
579 case BT_FIELD_CLASS_TYPE_BOOL
:
580 out_field_class
= bt_field_class_bool_create(
581 md_maps
->output_trace_class
);
583 case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER
:
584 out_field_class
= bt_field_class_integer_unsigned_create(
585 md_maps
->output_trace_class
);
587 case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER
:
588 out_field_class
= bt_field_class_integer_signed_create(
589 md_maps
->output_trace_class
);
591 case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION
:
592 out_field_class
= bt_field_class_enumeration_unsigned_create(
593 md_maps
->output_trace_class
);
595 case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
:
596 out_field_class
= bt_field_class_enumeration_signed_create(
597 md_maps
->output_trace_class
);
599 case BT_FIELD_CLASS_TYPE_REAL
:
600 out_field_class
= bt_field_class_real_create(
601 md_maps
->output_trace_class
);
603 case BT_FIELD_CLASS_TYPE_STRING
:
604 out_field_class
= bt_field_class_string_create(
605 md_maps
->output_trace_class
);
607 case BT_FIELD_CLASS_TYPE_STRUCTURE
:
608 out_field_class
= bt_field_class_structure_create(
609 md_maps
->output_trace_class
);
611 case BT_FIELD_CLASS_TYPE_STATIC_ARRAY
:
613 const bt_field_class
*in_elem_fc
=
614 bt_field_class_array_borrow_element_field_class_const(
617 bt_field_class_array_static_get_length(in_field_class
);
619 bt_field_class
*out_elem_fc
= copy_field_class_array_element(
620 md_maps
, in_elem_fc
);
622 out_field_class
= NULL
;
626 out_field_class
= bt_field_class_array_static_create(
627 md_maps
->output_trace_class
,
628 out_elem_fc
, array_len
);
631 case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY
:
633 const bt_field_class
*in_elem_fc
=
634 bt_field_class_array_borrow_element_field_class_const(
636 const bt_field_path
*length_fp
=
637 bt_field_class_array_dynamic_borrow_length_field_path_const(
639 bt_field_class
*out_length_fc
= NULL
;
641 bt_field_class
*out_elem_fc
= copy_field_class_array_element(
642 md_maps
, in_elem_fc
);
644 out_field_class
= NULL
;
649 const bt_field_class
*in_length_fc
=
650 resolve_field_path_to_field_class(length_fp
,
653 BT_ASSERT(in_length_fc
);
654 out_length_fc
= g_hash_table_lookup(md_maps
->field_class_map
,
656 BT_ASSERT(out_length_fc
);
659 out_field_class
= bt_field_class_array_dynamic_create(
660 md_maps
->output_trace_class
,
661 out_elem_fc
, out_length_fc
);
664 case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR
:
665 case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR
:
666 case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR
:
668 bt_field_class
*out_sel_fc
= NULL
;
670 if (fc_type
== BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR
||
671 fc_type
== BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR
) {
672 const bt_field_class
*in_sel_fc
;
673 const bt_field_path
*sel_fp
=
674 bt_field_class_variant_with_selector_borrow_selector_field_path_const(
678 in_sel_fc
= resolve_field_path_to_field_class(sel_fp
,
680 BT_ASSERT(in_sel_fc
);
681 out_sel_fc
= g_hash_table_lookup(
682 md_maps
->field_class_map
, in_sel_fc
);
683 BT_ASSERT(out_sel_fc
);
686 out_field_class
= bt_field_class_variant_create(
687 md_maps
->output_trace_class
, out_sel_fc
);
695 * Add mapping from in_field_class to out_field_class. This simplifies
696 * the resolution of field paths in variant and dynamic array field
699 g_hash_table_insert(md_maps
->field_class_map
,
700 (gpointer
) in_field_class
, out_field_class
);
704 BT_COMP_LOGD("Created bare field class based on field class: in-fc-addr=%p, "
705 "out-fc-addr=%p", in_field_class
, out_field_class
);
707 BT_COMP_LOGE("Error creating output field class from input field "
708 "class: in-fc-addr=%p", in_field_class
);
711 return out_field_class
;
715 int copy_field_class_content_internal(
716 struct trace_ir_metadata_maps
*md_maps
,
717 const bt_field_class
*in_field_class
,
718 bt_field_class
*out_field_class
)
721 switch(bt_field_class_get_type(in_field_class
)) {
722 case BT_FIELD_CLASS_TYPE_BOOL
:
723 ret
= field_class_bool_copy(md_maps
,
724 in_field_class
, out_field_class
);
726 case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER
:
727 ret
= field_class_unsigned_integer_copy(md_maps
,
728 in_field_class
, out_field_class
);
730 case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER
:
731 ret
= field_class_signed_integer_copy(md_maps
,
732 in_field_class
, out_field_class
);
734 case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION
:
735 ret
= field_class_unsigned_enumeration_copy(md_maps
,
736 in_field_class
, out_field_class
);
738 case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
:
739 ret
= field_class_signed_enumeration_copy(md_maps
,
740 in_field_class
, out_field_class
);
742 case BT_FIELD_CLASS_TYPE_REAL
:
743 ret
= field_class_real_copy(md_maps
,
744 in_field_class
, out_field_class
);
746 case BT_FIELD_CLASS_TYPE_STRING
:
747 ret
= field_class_string_copy(md_maps
,
748 in_field_class
, out_field_class
);
750 case BT_FIELD_CLASS_TYPE_STRUCTURE
:
751 ret
= field_class_structure_copy(md_maps
,
752 in_field_class
, out_field_class
);
754 case BT_FIELD_CLASS_TYPE_STATIC_ARRAY
:
755 ret
= field_class_static_array_copy(md_maps
,
756 in_field_class
, out_field_class
);
758 case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY
:
759 ret
= field_class_dynamic_array_copy(md_maps
,
760 in_field_class
, out_field_class
);
762 case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR
:
763 case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR
:
764 case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR
:
765 ret
= field_class_variant_copy(md_maps
,
766 in_field_class
, out_field_class
);