Commit | Line | Data |
---|---|---|
ca9f27f3 | 1 | /* |
0235b0db | 2 | * SPDX-License-Identifier: MIT |
ca9f27f3 FD |
3 | * |
4 | * Copyright (c) 2015-2019 EfficiOS Inc. and Linux Foundation | |
5 | * Copyright (c) 2019 Francis Deslauriers <francis.deslauriers@efficios.com> | |
6 | * | |
0235b0db | 7 | * Babeltrace - Trace IR data object copy |
ca9f27f3 FD |
8 | */ |
9 | ||
91bc8451 | 10 | #define BT_COMP_LOG_SELF_COMP self_comp |
3a3d15f3 | 11 | #define BT_LOG_OUTPUT_LEVEL log_level |
350ad6c1 | 12 | #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-DATA-COPY" |
d9c39b0a | 13 | #include "logging/comp-logging.h" |
ca9f27f3 FD |
14 | |
15 | #include <inttypes.h> | |
16 | #include <stdint.h> | |
17 | ||
578e048b | 18 | #include "common/assert.h" |
498e7994 | 19 | #include "common/common.h" |
ca9f27f3 FD |
20 | |
21 | #include "trace-ir-data-copy.h" | |
22 | ||
23 | BT_HIDDEN | |
3b34b490 FD |
24 | enum debug_info_trace_ir_mapping_status copy_trace_content( |
25 | const bt_trace *in_trace, bt_trace *out_trace, | |
91bc8451 | 26 | bt_logging_level log_level, bt_self_component *self_comp) |
ca9f27f3 | 27 | { |
3b34b490 | 28 | enum debug_info_trace_ir_mapping_status status; |
ca9f27f3 | 29 | const char *trace_name; |
335a2da5 | 30 | uint64_t i, env_field_count; |
ca9f27f3 | 31 | |
91bc8451 | 32 | BT_COMP_LOGD("Copying content of trace: in-t-addr=%p, out-t-addr=%p", |
ca9f27f3 | 33 | in_trace, out_trace); |
3b34b490 | 34 | |
ca9f27f3 | 35 | trace_name = bt_trace_get_name(in_trace); |
3b34b490 | 36 | |
ca9f27f3 FD |
37 | /* Copy the trace name. */ |
38 | if (trace_name) { | |
3b34b490 FD |
39 | bt_trace_set_name_status set_name_status = |
40 | bt_trace_set_name(out_trace, trace_name); | |
41 | if (set_name_status != BT_TRACE_SET_NAME_STATUS_OK) { | |
42 | BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Cannot set trace's name: " | |
43 | "out-t-addr=%p, name=\"%s\"", out_trace, | |
44 | trace_name); | |
45 | status = (int) set_name_status; | |
ca9f27f3 FD |
46 | goto end; |
47 | } | |
48 | } | |
49 | ||
ce45f74a PP |
50 | /* |
51 | * Safe to use the same value object because it's frozen at this | |
52 | * point. | |
53 | */ | |
54 | bt_trace_set_user_attributes(out_trace, | |
55 | bt_trace_borrow_user_attributes_const(in_trace)); | |
56 | ||
335a2da5 | 57 | /* |
3b34b490 | 58 | * Do not copy the trace UUID as the trace may be modified and should |
335a2da5 PP |
59 | * no longer have the same UUID. |
60 | */ | |
61 | ||
62 | /* | |
63 | * Go over all the entries in the environment section of the | |
64 | * trace and copy the content to the new trace. | |
65 | */ | |
66 | env_field_count = bt_trace_get_environment_entry_count(in_trace); | |
67 | for (i = 0; i < env_field_count; i++) { | |
68 | const char *value_name; | |
69 | const bt_value *value = NULL; | |
70 | bt_trace_set_environment_entry_status set_env_status; | |
71 | ||
72 | bt_trace_borrow_environment_entry_by_index_const( | |
73 | in_trace, i, &value_name, &value); | |
74 | ||
75 | BT_COMP_LOGD("Copying trace environnement entry: " | |
3b34b490 | 76 | "index=%" PRId64 ", value-addr=%p, value-name=\"%s\"", |
335a2da5 PP |
77 | i, value, value_name); |
78 | ||
79 | BT_ASSERT(value_name); | |
80 | BT_ASSERT(value); | |
81 | ||
82 | if (bt_value_is_signed_integer(value)) { | |
bc463d34 FD |
83 | set_env_status = bt_trace_set_environment_entry_integer( |
84 | out_trace, value_name, | |
85 | bt_value_integer_signed_get( value)); | |
335a2da5 | 86 | } else if (bt_value_is_string(value)) { |
bc463d34 FD |
87 | set_env_status = bt_trace_set_environment_entry_string( |
88 | out_trace, value_name, | |
89 | bt_value_string_get(value)); | |
335a2da5 | 90 | } else { |
498e7994 | 91 | bt_common_abort(); |
335a2da5 PP |
92 | } |
93 | ||
bc463d34 | 94 | if (set_env_status != BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_OK) { |
3b34b490 FD |
95 | BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Cannot copy trace's environment: " |
96 | "out-t-addr=%p, name=\"%s\"", | |
335a2da5 | 97 | out_trace, trace_name); |
3b34b490 | 98 | status = (int) set_env_status; |
335a2da5 PP |
99 | goto end; |
100 | } | |
101 | } | |
102 | ||
91bc8451 | 103 | BT_COMP_LOGD("Copied content of trace: in-t-addr=%p, out-t-addr=%p", |
3b34b490 FD |
104 | in_trace, out_trace); |
105 | ||
106 | status = DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK; | |
ca9f27f3 | 107 | end: |
3b34b490 | 108 | return status; |
ca9f27f3 FD |
109 | } |
110 | ||
111 | BT_HIDDEN | |
3b34b490 FD |
112 | enum debug_info_trace_ir_mapping_status copy_stream_content( |
113 | const bt_stream *in_stream, bt_stream *out_stream, | |
91bc8451 | 114 | bt_logging_level log_level, bt_self_component *self_comp) |
ca9f27f3 | 115 | { |
3b34b490 | 116 | enum debug_info_trace_ir_mapping_status status; |
ca9f27f3 | 117 | const char *stream_name; |
ca9f27f3 | 118 | |
91bc8451 | 119 | BT_COMP_LOGD("Copying content of stream: in-s-addr=%p, out-s-addr=%p", |
ca9f27f3 FD |
120 | in_stream, out_stream); |
121 | ||
ca9f27f3 | 122 | stream_name = bt_stream_get_name(in_stream); |
3b34b490 | 123 | |
ca9f27f3 | 124 | if (stream_name) { |
3b34b490 FD |
125 | bt_stream_set_name_status set_name_status = |
126 | bt_stream_set_name(out_stream, stream_name); | |
127 | if (set_name_status != BT_STREAM_SET_NAME_STATUS_OK) { | |
128 | BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Cannot set stream's name: " | |
129 | "stream-addr=%p, name=\"%s\"", out_stream, | |
130 | stream_name); | |
131 | status = (int) set_name_status; | |
ca9f27f3 FD |
132 | goto end; |
133 | } | |
134 | } | |
135 | ||
ce45f74a PP |
136 | /* |
137 | * Safe to use the same value object because it's frozen at this | |
138 | * point. | |
139 | */ | |
140 | bt_stream_set_user_attributes(out_stream, | |
141 | bt_stream_borrow_user_attributes_const(in_stream)); | |
3b34b490 | 142 | |
91bc8451 | 143 | BT_COMP_LOGD("Copied content of stream: in-s-addr=%p, out-s-addr=%p", |
3b34b490 FD |
144 | in_stream, out_stream); |
145 | status = DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK; | |
ca9f27f3 | 146 | end: |
3b34b490 | 147 | return status; |
ca9f27f3 FD |
148 | } |
149 | ||
150 | BT_HIDDEN | |
3b34b490 FD |
151 | enum debug_info_trace_ir_mapping_status copy_packet_content( |
152 | const bt_packet *in_packet, bt_packet *out_packet, | |
91bc8451 | 153 | bt_logging_level log_level, bt_self_component *self_comp) |
ca9f27f3 | 154 | { |
3b34b490 | 155 | enum debug_info_trace_ir_mapping_status status; |
ca9f27f3 FD |
156 | const bt_field *in_context_field; |
157 | bt_field *out_context_field; | |
158 | ||
91bc8451 | 159 | BT_COMP_LOGD("Copying content of packet: in-p-addr=%p, out-p-addr=%p", |
ca9f27f3 FD |
160 | in_packet, out_packet); |
161 | ||
162 | /* Copy context field. */ | |
163 | in_context_field = bt_packet_borrow_context_field_const(in_packet); | |
164 | if (in_context_field) { | |
165 | out_context_field = bt_packet_borrow_context_field(out_packet); | |
166 | BT_ASSERT(out_context_field); | |
3b34b490 | 167 | status = copy_field_content(in_context_field, out_context_field, |
91bc8451 | 168 | log_level, self_comp); |
3b34b490 FD |
169 | if (status != DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK) { |
170 | BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Cannot copy context field: " | |
171 | "in-ctx-f-addr=%p, out-ctx-f-addr=%p", | |
172 | in_context_field, out_context_field); | |
173 | goto end; | |
174 | } | |
ca9f27f3 FD |
175 | } |
176 | ||
91bc8451 | 177 | BT_COMP_LOGD("Copied content of packet: in-p-addr=%p, out-p-addr=%p", |
ca9f27f3 | 178 | in_packet, out_packet); |
3b34b490 FD |
179 | status = DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK; |
180 | end: | |
181 | return status; | |
ca9f27f3 FD |
182 | } |
183 | ||
184 | BT_HIDDEN | |
3b34b490 FD |
185 | enum debug_info_trace_ir_mapping_status copy_event_content( |
186 | const bt_event *in_event, bt_event *out_event, | |
91bc8451 | 187 | bt_logging_level log_level, bt_self_component *self_comp) |
ca9f27f3 | 188 | { |
3b34b490 | 189 | enum debug_info_trace_ir_mapping_status status; |
ca9f27f3 FD |
190 | const bt_field *in_common_ctx_field, *in_specific_ctx_field, |
191 | *in_payload_field; | |
192 | bt_field *out_common_ctx_field, *out_specific_ctx_field, | |
193 | *out_payload_field; | |
194 | ||
91bc8451 | 195 | BT_COMP_LOGD("Copying content of event: in-e-addr=%p, out-e-addr=%p", |
ca9f27f3 FD |
196 | in_event, out_event); |
197 | in_common_ctx_field = | |
198 | bt_event_borrow_common_context_field_const(in_event); | |
199 | if (in_common_ctx_field) { | |
200 | out_common_ctx_field = | |
201 | bt_event_borrow_common_context_field(out_event); | |
98b15851 | 202 | BT_ASSERT_DBG(out_common_ctx_field); |
3b34b490 FD |
203 | |
204 | status = copy_field_content(in_common_ctx_field, | |
91bc8451 | 205 | out_common_ctx_field, log_level, self_comp); |
3b34b490 FD |
206 | if (status != DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK) { |
207 | BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Cannot copy common context field: " | |
208 | "in-comm-ctx-f-addr=%p, out-comm-ctx-f-addr=%p", | |
209 | in_common_ctx_field, out_common_ctx_field); | |
210 | goto end; | |
211 | } | |
ca9f27f3 FD |
212 | } |
213 | ||
214 | in_specific_ctx_field = | |
215 | bt_event_borrow_specific_context_field_const(in_event); | |
216 | if (in_specific_ctx_field) { | |
217 | out_specific_ctx_field = | |
218 | bt_event_borrow_specific_context_field(out_event); | |
98b15851 | 219 | BT_ASSERT_DBG(out_specific_ctx_field); |
3b34b490 FD |
220 | |
221 | status = copy_field_content(in_specific_ctx_field, | |
91bc8451 | 222 | out_specific_ctx_field, log_level, self_comp); |
3b34b490 FD |
223 | if (status != DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK) { |
224 | BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Cannot copy specific context field: " | |
225 | "in-spec-ctx-f-addr=%p, out-spec-ctx-f-addr=%p", | |
226 | in_specific_ctx_field, out_specific_ctx_field); | |
227 | goto end; | |
228 | } | |
ca9f27f3 FD |
229 | } |
230 | ||
231 | in_payload_field = bt_event_borrow_payload_field_const(in_event); | |
232 | if (in_payload_field) { | |
233 | out_payload_field = bt_event_borrow_payload_field(out_event); | |
98b15851 | 234 | BT_ASSERT_DBG(out_payload_field); |
3b34b490 FD |
235 | |
236 | status = copy_field_content(in_payload_field, | |
91bc8451 | 237 | out_payload_field, log_level, self_comp); |
3b34b490 FD |
238 | if (status != DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK) { |
239 | BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Cannot copy payloat field: " | |
240 | "in-payload-f-addr=%p, out-payload-f-addr=%p", | |
241 | in_payload_field, out_payload_field); | |
242 | goto end; | |
243 | } | |
ca9f27f3 FD |
244 | } |
245 | ||
91bc8451 | 246 | BT_COMP_LOGD("Copied content of event: in-e-addr=%p, out-e-addr=%p", |
ca9f27f3 | 247 | in_event, out_event); |
3b34b490 FD |
248 | status = DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK; |
249 | end: | |
250 | return status; | |
ca9f27f3 FD |
251 | } |
252 | ||
253 | BT_HIDDEN | |
3b34b490 FD |
254 | enum debug_info_trace_ir_mapping_status copy_field_content( |
255 | const bt_field *in_field, bt_field *out_field, | |
91bc8451 | 256 | bt_logging_level log_level, bt_self_component *self_comp) |
ca9f27f3 | 257 | { |
3b34b490 | 258 | enum debug_info_trace_ir_mapping_status status; |
ca9f27f3 FD |
259 | bt_field_class_type in_fc_type, out_fc_type; |
260 | ||
261 | in_fc_type = bt_field_get_class_type(in_field); | |
262 | out_fc_type = bt_field_get_class_type(out_field); | |
98b15851 | 263 | BT_ASSERT_DBG(in_fc_type == out_fc_type); |
ca9f27f3 | 264 | |
ef267d12 | 265 | BT_COMP_LOGT("Copying content of field: in-f-addr=%p, out-f-addr=%p", |
ca9f27f3 | 266 | in_field, out_field); |
ebdb6693 PP |
267 | |
268 | if (in_fc_type == BT_FIELD_CLASS_TYPE_BOOL) { | |
f7cfbcc3 PP |
269 | bt_field_bool_set_value(out_field, |
270 | bt_field_bool_get_value(in_field)); | |
ebdb6693 | 271 | } else if (in_fc_type == BT_FIELD_CLASS_TYPE_BIT_ARRAY) { |
dc7ac074 PP |
272 | bt_field_bit_array_set_value_as_integer(out_field, |
273 | bt_field_bit_array_get_value_as_integer(in_field)); | |
ebdb6693 PP |
274 | } else if (bt_field_class_type_is(in_fc_type, |
275 | BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER)) { | |
9c08c816 | 276 | bt_field_integer_unsigned_set_value(out_field, |
3b34b490 | 277 | bt_field_integer_unsigned_get_value(in_field)); |
ebdb6693 PP |
278 | } else if (bt_field_class_type_is(in_fc_type, |
279 | BT_FIELD_CLASS_TYPE_SIGNED_INTEGER)) { | |
9c08c816 | 280 | bt_field_integer_signed_set_value(out_field, |
3b34b490 | 281 | bt_field_integer_signed_get_value(in_field)); |
ebdb6693 | 282 | } else if (in_fc_type == BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL) { |
fe4df857 | 283 | bt_field_real_single_precision_set_value(out_field, |
3b34b490 | 284 | bt_field_real_single_precision_get_value(in_field)); |
ebdb6693 | 285 | } else if (in_fc_type == BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL) { |
fe4df857 | 286 | bt_field_real_double_precision_set_value(out_field, |
3b34b490 | 287 | bt_field_real_double_precision_get_value(in_field)); |
ebdb6693 | 288 | } else if (in_fc_type == BT_FIELD_CLASS_TYPE_STRING) { |
ca9f27f3 | 289 | const char *str = bt_field_string_get_value(in_field); |
3b34b490 | 290 | bt_field_string_set_value_status set_value_status = |
d24d5663 | 291 | bt_field_string_set_value(out_field, str); |
3b34b490 FD |
292 | if (set_value_status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) { |
293 | BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Cannot set string field's value: " | |
294 | "out-str-f-addr=%p, str=\"%s\"" PRId64, | |
ca9f27f3 | 295 | out_field, str); |
3b34b490 FD |
296 | status = (int) set_value_status; |
297 | goto end; | |
ca9f27f3 | 298 | } |
ebdb6693 | 299 | } else if (in_fc_type == BT_FIELD_CLASS_TYPE_STRUCTURE) { |
ca9f27f3 FD |
300 | uint64_t i, nb_member_struct; |
301 | const bt_field *in_member_field; | |
302 | bt_field *out_member_field; | |
1e6fd1d7 | 303 | const bt_field_class *in_field_class; |
ca9f27f3 FD |
304 | const char *in_member_name; |
305 | ||
306 | in_field_class = bt_field_borrow_class_const(in_field); | |
307 | nb_member_struct = bt_field_class_structure_get_member_count( | |
3b34b490 | 308 | in_field_class); |
ca9f27f3 FD |
309 | |
310 | /* | |
311 | * Iterate over the fields by names in the input field to avoid | |
312 | * problem if the struct fields are not in the same order after | |
313 | * the debug-info was added. | |
314 | */ | |
315 | for (i = 0; i < nb_member_struct; i++) { | |
1e6fd1d7 PP |
316 | const bt_field_class_structure_member *member = |
317 | bt_field_class_structure_borrow_member_by_index_const( | |
318 | in_field_class, i); | |
ca9f27f3 | 319 | |
1e6fd1d7 PP |
320 | in_member_name = |
321 | bt_field_class_structure_member_get_name( | |
322 | member); | |
ca9f27f3 FD |
323 | in_member_field = |
324 | bt_field_structure_borrow_member_field_by_name_const( | |
bc463d34 | 325 | in_field, in_member_name); |
ca9f27f3 FD |
326 | out_member_field = |
327 | bt_field_structure_borrow_member_field_by_name( | |
bc463d34 | 328 | out_field, in_member_name); |
ca9f27f3 | 329 | |
3b34b490 | 330 | status = copy_field_content(in_member_field, |
91bc8451 | 331 | out_member_field, log_level, self_comp); |
3b34b490 FD |
332 | if (status != DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK) { |
333 | BT_COMP_LOGE_APPEND_CAUSE(self_comp, | |
334 | "Cannot copy struct member field: " | |
335 | "out-struct-f-addr=%p, " | |
336 | "out-struct-member-f-addr=%p, " | |
337 | "member-name=\"%s\"", | |
338 | out_field, out_member_field, | |
339 | in_member_name); | |
340 | goto end; | |
341 | } | |
ca9f27f3 | 342 | } |
ebdb6693 PP |
343 | } else if (bt_field_class_type_is(in_fc_type, |
344 | BT_FIELD_CLASS_TYPE_ARRAY)) { | |
ca9f27f3 FD |
345 | const bt_field *in_element_field; |
346 | bt_field *out_element_field; | |
347 | uint64_t i, array_len; | |
9c08c816 | 348 | bt_field_array_dynamic_set_length_status set_len_status; |
ca9f27f3 FD |
349 | |
350 | array_len = bt_field_array_get_length(in_field); | |
351 | ||
ebdb6693 PP |
352 | if (bt_field_class_type_is(in_fc_type, |
353 | BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY)) { | |
9c08c816 | 354 | set_len_status = bt_field_array_dynamic_set_length( |
d24d5663 PP |
355 | out_field, array_len); |
356 | if (set_len_status != | |
357 | BT_FIELD_DYNAMIC_ARRAY_SET_LENGTH_STATUS_OK) { | |
3b34b490 FD |
358 | BT_COMP_LOGE_APPEND_CAUSE(self_comp, |
359 | "Cannot set dynamic array field's length field: " | |
360 | "out-arr-f-addr=%p, arr-length=%" PRIu64, | |
361 | out_field, array_len); | |
362 | status = (int) set_len_status; | |
363 | goto end; | |
ca9f27f3 FD |
364 | } |
365 | } | |
366 | ||
367 | for (i = 0; i < array_len; i++) { | |
368 | in_element_field = | |
369 | bt_field_array_borrow_element_field_by_index_const( | |
d24d5663 | 370 | in_field, i); |
ca9f27f3 FD |
371 | out_element_field = |
372 | bt_field_array_borrow_element_field_by_index( | |
d24d5663 | 373 | out_field, i); |
3b34b490 FD |
374 | status = copy_field_content(in_element_field, |
375 | out_element_field, log_level, self_comp); | |
376 | if (status != DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK) { | |
377 | BT_COMP_LOGE_APPEND_CAUSE(self_comp, | |
378 | "Cannot copy element field: " | |
379 | "out-arr-f-addr=%p, out-arr-elem-f-addr=%p", | |
380 | out_field, out_element_field); | |
381 | goto end; | |
382 | } | |
ca9f27f3 | 383 | } |
ebdb6693 PP |
384 | } else if (bt_field_class_type_is(in_fc_type, |
385 | BT_FIELD_CLASS_TYPE_OPTION)) { | |
f29ef814 PP |
386 | const bt_field *in_option_field; |
387 | bt_field *out_option_field; | |
388 | ||
389 | in_option_field = bt_field_option_borrow_field_const(in_field); | |
390 | ||
391 | if (in_option_field) { | |
392 | bt_field_option_set_has_field(out_field, BT_TRUE); | |
393 | out_option_field = bt_field_option_borrow_field( | |
394 | out_field); | |
98b15851 | 395 | BT_ASSERT_DBG(out_option_field); |
3b34b490 | 396 | status = copy_field_content(in_option_field, out_option_field, |
f29ef814 | 397 | log_level, self_comp); |
3b34b490 FD |
398 | if (status != DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK) { |
399 | BT_COMP_LOGE_APPEND_CAUSE(self_comp, | |
400 | "Cannot copy option field: " | |
401 | "out-opt-f-addr=%p, out-opt-field-f-addr=%p", | |
402 | out_field, out_option_field); | |
403 | goto end; | |
404 | } | |
f29ef814 PP |
405 | } else { |
406 | bt_field_option_set_has_field(out_field, BT_FALSE); | |
407 | } | |
ebdb6693 PP |
408 | } else if (bt_field_class_type_is(in_fc_type, |
409 | BT_FIELD_CLASS_TYPE_VARIANT)) { | |
7b4311c1 | 410 | bt_field_variant_select_option_by_index_status sel_opt_status; |
ca9f27f3 FD |
411 | uint64_t in_selected_option_idx; |
412 | const bt_field *in_option_field; | |
413 | bt_field *out_option_field; | |
414 | ||
415 | in_selected_option_idx = | |
7b4311c1 | 416 | bt_field_variant_get_selected_option_index( |
bc463d34 | 417 | in_field); |
7b4311c1 | 418 | sel_opt_status = bt_field_variant_select_option_by_index(out_field, |
bc463d34 | 419 | in_selected_option_idx); |
d24d5663 | 420 | if (sel_opt_status != |
7b4311c1 | 421 | BT_FIELD_VARIANT_SELECT_OPTION_STATUS_OK) { |
3b34b490 FD |
422 | BT_COMP_LOGE_APPEND_CAUSE(self_comp, |
423 | "Cannot select variant field's option field: " | |
424 | "out-var-f-addr=%p, opt-index=%" PRId64, | |
ca9f27f3 | 425 | out_field, in_selected_option_idx); |
3b34b490 FD |
426 | status = (int) sel_opt_status; |
427 | goto end; | |
ca9f27f3 FD |
428 | } |
429 | ||
430 | in_option_field = bt_field_variant_borrow_selected_option_field_const(in_field); | |
431 | out_option_field = bt_field_variant_borrow_selected_option_field(out_field); | |
432 | ||
3b34b490 | 433 | status = copy_field_content(in_option_field, out_option_field, |
91bc8451 | 434 | log_level, self_comp); |
3b34b490 FD |
435 | if (status != DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK) { |
436 | BT_COMP_LOGE_APPEND_CAUSE(self_comp, | |
437 | "Cannot copy element field: " | |
438 | "out-var-f-addr=%p, out-opt-f-addr=%p", | |
439 | out_field, out_option_field); | |
440 | goto end; | |
441 | } | |
ebdb6693 | 442 | } else { |
498e7994 | 443 | bt_common_abort(); |
ca9f27f3 | 444 | } |
ebdb6693 | 445 | |
ef267d12 | 446 | BT_COMP_LOGT("Copied content of field: in-f-addr=%p, out-f-addr=%p", |
ca9f27f3 | 447 | in_field, out_field); |
3b34b490 FD |
448 | |
449 | status = DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK; | |
450 | end: | |
451 | return status; | |
ca9f27f3 | 452 | } |