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 "plugins/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
;
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_SCOPE_PACKET_CONTEXT
:
124 fc
= walk_field_path(md_maps
, fp
,
125 fc_resolving_ctx
->packet_context
);
127 case BT_SCOPE_EVENT_COMMON_CONTEXT
:
128 fc
= walk_field_path(md_maps
, fp
,
129 fc_resolving_ctx
->event_common_context
);
131 case BT_SCOPE_EVENT_SPECIFIC_CONTEXT
:
132 fc
= walk_field_path(md_maps
, fp
,
133 fc_resolving_ctx
->event_specific_context
);
135 case BT_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_unsigned_integer_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 unsigned integer field class: "
163 "in-fc-addr=%p, out-fc-addr=%p",
164 in_field_class
, out_field_class
);
166 field_class_integer_set_props(in_field_class
, out_field_class
);
168 BT_COMP_LOGD("Copied content of unsigned integer field class: "
169 "in-fc-addr=%p, out-fc-addr=%p",
170 in_field_class
, out_field_class
);
175 int field_class_signed_integer_copy(
176 struct trace_ir_metadata_maps
*md_maps
,
177 const bt_field_class
*in_field_class
,
178 bt_field_class
*out_field_class
)
180 BT_COMP_LOGD("Copying content of signed integer field class: "
181 "in-fc-addr=%p, out-fc-addr=%p",
182 in_field_class
, out_field_class
);
184 field_class_integer_set_props(in_field_class
, out_field_class
);
186 BT_COMP_LOGD("Copied content of signed integer field class: "
187 "in-fc-addr=%p, out-fc-addr=%p",
188 in_field_class
, out_field_class
);
193 int field_class_unsigned_enumeration_copy(
194 struct trace_ir_metadata_maps
*md_maps
,
195 const bt_field_class
*in_field_class
,
196 bt_field_class
*out_field_class
)
198 uint64_t i
, enum_mapping_count
;
201 BT_COMP_LOGD("Copying content of unsigned enumeration field class: "
202 "in-fc-addr=%p, out-fc-addr=%p",
203 in_field_class
, out_field_class
);
205 /* Copy properties of the inner integer. */
206 field_class_integer_set_props(in_field_class
, out_field_class
);
208 /* Copy all enumeration entries. */
209 enum_mapping_count
= bt_field_class_enumeration_get_mapping_count(in_field_class
);
210 for (i
= 0; i
< enum_mapping_count
; i
++) {
212 const bt_integer_range_set_unsigned
*range_set
;
213 const bt_field_class_unsigned_enumeration_mapping
*u_mapping
;
214 const bt_field_class_enumeration_mapping
*mapping
;
216 u_mapping
= bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const(
218 mapping
= bt_field_class_unsigned_enumeration_mapping_as_mapping_const(
220 label
= bt_field_class_enumeration_mapping_get_label(mapping
);
221 range_set
= bt_field_class_unsigned_enumeration_mapping_borrow_ranges_const(
223 ret
= bt_field_class_unsigned_enumeration_add_mapping(
224 out_field_class
, label
, range_set
);
230 BT_COMP_LOGD("Copied content of unsigned enumeration field class: "
231 "in-fc-addr=%p, out-fc-addr=%p",
232 in_field_class
, out_field_class
);
239 int field_class_signed_enumeration_copy(
240 struct trace_ir_metadata_maps
*md_maps
,
241 const bt_field_class
*in_field_class
,
242 bt_field_class
*out_field_class
)
244 uint64_t i
, enum_mapping_count
;
247 BT_COMP_LOGD("Copying content of signed enumeration field class: "
248 "in-fc-addr=%p, out-fc-addr=%p",
249 in_field_class
, out_field_class
);
251 /* Copy properties of the inner integer. */
252 field_class_integer_set_props(in_field_class
, out_field_class
);
254 /* Copy all enumeration entries. */
256 bt_field_class_enumeration_get_mapping_count(in_field_class
);
257 for (i
= 0; i
< enum_mapping_count
; i
++) {
259 const bt_integer_range_set_signed
*range_set
;
260 const bt_field_class_signed_enumeration_mapping
*s_mapping
;
261 const bt_field_class_enumeration_mapping
*mapping
;
263 s_mapping
= bt_field_class_signed_enumeration_borrow_mapping_by_index_const(
265 mapping
= bt_field_class_signed_enumeration_mapping_as_mapping_const(
267 label
= bt_field_class_enumeration_mapping_get_label(mapping
);
268 range_set
= bt_field_class_signed_enumeration_mapping_borrow_ranges_const(
270 ret
= bt_field_class_signed_enumeration_add_mapping(
271 out_field_class
, label
, range_set
);
277 BT_COMP_LOGD("Copied content of signed enumeration field class: "
278 "in-fc-addr=%p, out-fc-addr=%p",
279 in_field_class
, out_field_class
);
286 int field_class_real_copy(
287 struct trace_ir_metadata_maps
*md_maps
,
288 const bt_field_class
*in_field_class
,
289 bt_field_class
*out_field_class
)
291 BT_COMP_LOGD("Copying content of real field class: "
292 "in-fc-addr=%p, out-fc-addr=%p",
293 in_field_class
, out_field_class
);
295 bt_field_class_real_set_is_single_precision(out_field_class
,
296 bt_field_class_real_is_single_precision(in_field_class
));
298 BT_COMP_LOGD("Copied content real field class: in-fc-addr=%p, "
299 "out-fc-addr=%p", in_field_class
, out_field_class
);
305 int field_class_structure_copy(
306 struct trace_ir_metadata_maps
*md_maps
,
307 const bt_field_class
*in_field_class
,
308 bt_field_class
*out_field_class
)
310 uint64_t i
, struct_member_count
;
313 BT_COMP_LOGD("Copying content of structure field class: "
314 "in-fc-addr=%p, out-fc-addr=%p",
315 in_field_class
, out_field_class
);
316 /* Get the number of member in that struct. */
317 struct_member_count
=
318 bt_field_class_structure_get_member_count(in_field_class
);
320 /* Iterate over all the members of the struct. */
321 for (i
= 0; i
< struct_member_count
; i
++) {
322 const bt_field_class_structure_member
*member
;
323 const char *member_name
;
324 const bt_field_class
*member_fc
;
325 bt_field_class
*out_member_field_class
;
327 member
= bt_field_class_structure_borrow_member_by_index_const(
329 member_fc
= bt_field_class_structure_member_borrow_field_class_const(
331 member_name
= bt_field_class_structure_member_get_name(member
);
332 BT_COMP_LOGD("Copying structure field class's field: "
333 "index=%" PRId64
", "
334 "member-fc-addr=%p, field-name=\"%s\"",
335 i
, member_fc
, member_name
);
337 out_member_field_class
= create_field_class_copy(md_maps
,
339 if (!out_member_field_class
) {
340 BT_COMP_LOGE("Cannot copy structure field class's field: "
341 "index=%" PRId64
", "
342 "field-fc-addr=%p, field-name=\"%s\"",
343 i
, member_fc
, member_name
);
347 ret
= copy_field_class_content(md_maps
, member_fc
,
348 out_member_field_class
);
353 if (bt_field_class_structure_append_member(out_field_class
,
354 member_name
, out_member_field_class
) !=
355 BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK
) {
356 BT_COMP_LOGE("Cannot append structure field class's field: "
357 "index=%" PRId64
", "
358 "field-fc-addr=%p, field-name=\"%s\"",
359 i
, member_fc
, member_name
);
360 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_member_field_class
);
366 BT_COMP_LOGD("Copied structure field class: original-fc-addr=%p, copy-fc-addr=%p",
367 in_field_class
, out_field_class
);
374 int field_class_variant_copy(
375 struct trace_ir_metadata_maps
*md_maps
,
376 const bt_field_class
*in_field_class
,
377 bt_field_class
*out_field_class
)
379 bt_field_class
*out_tag_field_class
= NULL
;
380 uint64_t i
, variant_option_count
;
381 bt_field_class_type fc_type
= bt_field_class_get_type(in_field_class
);
384 BT_COMP_LOGD("Copying content of variant field class: "
385 "in-fc-addr=%p, out-fc-addr=%p",
386 in_field_class
, out_field_class
);
387 variant_option_count
=
388 bt_field_class_variant_get_option_count(in_field_class
);
389 for (i
= 0; i
< variant_option_count
; i
++) {
390 const bt_field_class
*option_fc
;
391 const char *option_name
;
392 bt_field_class
*out_option_field_class
;
393 const bt_field_class_variant_option
*option
;
395 option
= bt_field_class_variant_borrow_option_by_index_const(
397 option_fc
= bt_field_class_variant_option_borrow_field_class_const(
399 option_name
= bt_field_class_variant_option_get_name(option
);
400 out_option_field_class
= create_field_class_copy_internal(
402 if (!out_option_field_class
) {
403 BT_COMP_LOGE_STR("Cannot copy field class.");
407 ret
= copy_field_class_content_internal(md_maps
, option_fc
,
408 out_option_field_class
);
410 BT_COMP_LOGE_STR("Error copying content of option variant "
415 if (fc_type
== BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR
) {
416 const bt_field_class_variant_with_unsigned_selector_option
*spec_opt
=
417 bt_field_class_variant_with_unsigned_selector_borrow_option_by_index_const(
419 const bt_integer_range_set_unsigned
*ranges
=
420 bt_field_class_variant_with_unsigned_selector_option_borrow_ranges_const(
423 if (bt_field_class_variant_with_unsigned_selector_append_option(
424 out_field_class
, option_name
,
425 out_option_field_class
, ranges
) !=
426 BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_APPEND_OPTION_STATUS_OK
) {
427 BT_COMP_LOGE_STR("Cannot append option to variant field class with unsigned selector'");
428 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class
);
432 } else if (fc_type
== BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR
) {
433 const bt_field_class_variant_with_signed_selector_option
*spec_opt
=
434 bt_field_class_variant_with_signed_selector_borrow_option_by_index_const(
436 const bt_integer_range_set_signed
*ranges
=
437 bt_field_class_variant_with_signed_selector_option_borrow_ranges_const(
440 if (bt_field_class_variant_with_signed_selector_append_option(
441 out_field_class
, option_name
,
442 out_option_field_class
, ranges
) !=
443 BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_APPEND_OPTION_STATUS_OK
) {
444 BT_COMP_LOGE_STR("Cannot append option to variant field class with signed selector'");
445 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class
);
450 BT_ASSERT(fc_type
== BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR
);
452 if (bt_field_class_variant_without_selector_append_option(
453 out_field_class
, option_name
,
454 out_option_field_class
) !=
455 BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_APPEND_OPTION_STATUS_OK
) {
456 BT_COMP_LOGE_STR("Cannot append option to variant field class'");
457 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class
);
464 BT_COMP_LOGD("Copied content of variant field class: in-fc-addr=%p, "
465 "out-fc-addr=%p", in_field_class
, out_field_class
);
472 int field_class_static_array_copy(
473 struct trace_ir_metadata_maps
*md_maps
,
474 const bt_field_class
*in_field_class
,
475 bt_field_class
*out_field_class
)
477 BT_COMP_LOGD("Copying content of static array field class: in-fc-addr=%p, "
478 "out-fc-addr=%p", in_field_class
, out_field_class
);
480 * There is no content to copy. Keep this function call anyway for
483 BT_COMP_LOGD("Copied content of static array field class: in-fc-addr=%p, "
484 "out-fc-addr=%p", in_field_class
, out_field_class
);
490 int field_class_dynamic_array_copy(
491 struct trace_ir_metadata_maps
*md_maps
,
492 const bt_field_class
*in_field_class
,
493 bt_field_class
*out_field_class
)
495 const bt_field_class
*len_fc
;
496 const bt_field_path
*len_fp
;
497 bt_field_class
*out_len_field_class
;
500 BT_COMP_LOGD("Copying content of dynamic array field class: "
501 "in-fc-addr=%p, out-fc-addr=%p",
502 in_field_class
, out_field_class
);
504 len_fp
= bt_field_class_dynamic_array_borrow_length_field_path_const(
508 BT_COMP_LOGD("Copying dynamic array length field class using "
509 "field path: in-len-fp=%p", len_fp
);
510 len_fc
= resolve_field_path_to_field_class(
512 out_len_field_class
= g_hash_table_lookup(
513 md_maps
->field_class_map
, len_fc
);
514 if (!out_len_field_class
) {
515 BT_COMP_LOGE_STR("Cannot find the output matching length"
521 if (bt_field_class_dynamic_array_set_length_field_class(
522 out_field_class
, out_len_field_class
) !=
523 BT_FIELD_CLASS_DYNAMIC_ARRAY_SET_LENGTH_FIELD_CLASS_STATUS_OK
) {
524 BT_COMP_LOGE_STR("Cannot set dynamic array field class' "
525 "length field class.");
526 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_len_field_class
);
532 BT_COMP_LOGD("Copied dynamic array field class: in-fc-addr=%p, "
533 "out-fc-addr=%p", in_field_class
, out_field_class
);
540 int field_class_string_copy(struct trace_ir_metadata_maps
*md_maps
,
541 const bt_field_class
*in_field_class
,
542 bt_field_class
*out_field_class
)
544 BT_COMP_LOGD("Copying content of string field class: in-fc-addr=%p, "
545 "out-fc-addr=%p", in_field_class
, out_field_class
);
547 * There is no content to copy. Keep this function call anyway for
550 BT_COMP_LOGD("Copied content of string field class: in-fc-addr=%p, "
551 "out-fc-addr=%p", in_field_class
, out_field_class
);
557 bt_field_class
*copy_field_class_array_element(struct trace_ir_metadata_maps
*md_maps
,
558 const bt_field_class
*in_elem_fc
)
561 bt_field_class
*out_elem_fc
=
562 create_field_class_copy_internal(md_maps
, in_elem_fc
);
564 BT_COMP_LOGE("Error creating output elem field class "
565 "from input elem field class for static array: "
566 "in-fc-addr=%p", in_elem_fc
);
570 ret
= copy_field_class_content_internal(md_maps
, in_elem_fc
, out_elem_fc
);
572 BT_COMP_LOGE("Error creating output elem field class "
573 "from input elem field class for static array: "
574 "in-fc-addr=%p", in_elem_fc
);
575 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_elem_fc
);
584 bt_field_class
*create_field_class_copy_internal(struct trace_ir_metadata_maps
*md_maps
,
585 const bt_field_class
*in_field_class
)
587 bt_field_class
*out_field_class
= NULL
;
588 bt_field_class_type fc_type
= bt_field_class_get_type(in_field_class
);
590 BT_COMP_LOGD("Creating bare field class based on field class: in-fc-addr=%p",
594 case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER
:
595 out_field_class
= bt_field_class_unsigned_integer_create(
596 md_maps
->output_trace_class
);
598 case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER
:
599 out_field_class
= bt_field_class_signed_integer_create(
600 md_maps
->output_trace_class
);
602 case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION
:
603 out_field_class
= bt_field_class_unsigned_enumeration_create(
604 md_maps
->output_trace_class
);
606 case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
:
607 out_field_class
= bt_field_class_signed_enumeration_create(
608 md_maps
->output_trace_class
);
610 case BT_FIELD_CLASS_TYPE_REAL
:
611 out_field_class
= bt_field_class_real_create(
612 md_maps
->output_trace_class
);
614 case BT_FIELD_CLASS_TYPE_STRING
:
615 out_field_class
= bt_field_class_string_create(
616 md_maps
->output_trace_class
);
618 case BT_FIELD_CLASS_TYPE_STRUCTURE
:
619 out_field_class
= bt_field_class_structure_create(
620 md_maps
->output_trace_class
);
622 case BT_FIELD_CLASS_TYPE_STATIC_ARRAY
:
624 const bt_field_class
*in_elem_fc
=
625 bt_field_class_array_borrow_element_field_class_const(
628 bt_field_class_static_array_get_length(in_field_class
);
630 bt_field_class
*out_elem_fc
= copy_field_class_array_element(
631 md_maps
, in_elem_fc
);
633 out_field_class
= NULL
;
637 out_field_class
= bt_field_class_static_array_create(
638 md_maps
->output_trace_class
,
639 out_elem_fc
, array_len
);
642 case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY
:
644 const bt_field_class
*in_elem_fc
=
645 bt_field_class_array_borrow_element_field_class_const(
648 bt_field_class
*out_elem_fc
= copy_field_class_array_element(
649 md_maps
, in_elem_fc
);
651 out_field_class
= NULL
;
655 out_field_class
= bt_field_class_dynamic_array_create(
656 md_maps
->output_trace_class
,
660 case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR
:
661 case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR
:
662 case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR
:
664 bt_field_class
*out_sel_fc
= NULL
;
666 if (fc_type
== BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR
||
667 fc_type
== BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR
) {
668 const bt_field_class
*in_sel_fc
;
669 const bt_field_path
*sel_fp
=
670 bt_field_class_variant_with_selector_borrow_selector_field_path_const(
674 in_sel_fc
= resolve_field_path_to_field_class(sel_fp
,
676 BT_ASSERT(in_sel_fc
);
677 out_sel_fc
= g_hash_table_lookup(
678 md_maps
->field_class_map
, in_sel_fc
);
679 BT_ASSERT(out_sel_fc
);
682 out_field_class
= bt_field_class_variant_create(
683 md_maps
->output_trace_class
, out_sel_fc
);
691 * Add mapping from in_field_class to out_field_class. This simplifies
692 * the resolution of field paths in variant and dynamic array field
695 g_hash_table_insert(md_maps
->field_class_map
,
696 (gpointer
) in_field_class
, out_field_class
);
700 BT_COMP_LOGD("Created bare field class based on field class: in-fc-addr=%p, "
701 "out-fc-addr=%p", in_field_class
, out_field_class
);
703 BT_COMP_LOGE("Error creating output field class from input field "
704 "class: in-fc-addr=%p", in_field_class
);
707 return out_field_class
;
711 int copy_field_class_content_internal(
712 struct trace_ir_metadata_maps
*md_maps
,
713 const bt_field_class
*in_field_class
,
714 bt_field_class
*out_field_class
)
717 switch(bt_field_class_get_type(in_field_class
)) {
718 case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER
:
719 ret
= field_class_unsigned_integer_copy(md_maps
,
720 in_field_class
, out_field_class
);
722 case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER
:
723 ret
= field_class_signed_integer_copy(md_maps
,
724 in_field_class
, out_field_class
);
726 case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION
:
727 ret
= field_class_unsigned_enumeration_copy(md_maps
,
728 in_field_class
, out_field_class
);
730 case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
:
731 ret
= field_class_signed_enumeration_copy(md_maps
,
732 in_field_class
, out_field_class
);
734 case BT_FIELD_CLASS_TYPE_REAL
:
735 ret
= field_class_real_copy(md_maps
,
736 in_field_class
, out_field_class
);
738 case BT_FIELD_CLASS_TYPE_STRING
:
739 ret
= field_class_string_copy(md_maps
,
740 in_field_class
, out_field_class
);
742 case BT_FIELD_CLASS_TYPE_STRUCTURE
:
743 ret
= field_class_structure_copy(md_maps
,
744 in_field_class
, out_field_class
);
746 case BT_FIELD_CLASS_TYPE_STATIC_ARRAY
:
747 ret
= field_class_static_array_copy(md_maps
,
748 in_field_class
, out_field_class
);
750 case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY
:
751 ret
= field_class_dynamic_array_copy(md_maps
,
752 in_field_class
, out_field_class
);
754 case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR
:
755 case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR
:
756 case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR
:
757 ret
= field_class_variant_copy(md_maps
,
758 in_field_class
, out_field_class
);