lib: strictly type function return status enumerations
[babeltrace.git] / src / plugins / lttng-utils / debug-info / trace-ir-metadata-copy.c
CommitLineData
ca9f27f3
FD
1/*
2 * Babeltrace - Trace IR metadata object copy
3 *
4 * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
5 * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
6 * Copyright (c) 2019 Francis Deslauriers <francis.deslauriers@efficios.com>
7 *
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:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
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
24 * SOFTWARE.
25 */
26
91bc8451 27#define BT_COMP_LOG_SELF_COMP self_comp
3a3d15f3 28#define BT_LOG_OUTPUT_LEVEL log_level
350ad6c1 29#define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-META-COPY"
91bc8451 30#include "plugins/comp-logging.h"
ca9f27f3
FD
31
32#include <inttypes.h>
33#include <stdint.h>
34
578e048b 35#include "common/assert.h"
ca9f27f3
FD
36
37#include "trace-ir-metadata-copy.h"
38#include "trace-ir-metadata-field-class-copy.h"
39#include "utils.h"
40
41BT_HIDDEN
42int copy_trace_class_content(const bt_trace_class *in_trace_class,
91bc8451
PP
43 bt_trace_class *out_trace_class, bt_logging_level log_level,
44 bt_self_component *self_comp)
ca9f27f3
FD
45{
46 int ret = 0;
47 uint64_t i, env_field_count;
48 const char *in_trace_class_name;
ca9f27f3 49
91bc8451 50 BT_COMP_LOGD("Copying content of trace class: in-tc-addr=%p, out-tc-addr=%p",
ca9f27f3
FD
51 in_trace_class, out_trace_class);
52
53 /* Use the same stream class ids as in the origin trace class. */
54 bt_trace_class_set_assigns_automatic_stream_class_id(out_trace_class,
55 BT_FALSE);
56
57 in_trace_class_name = bt_trace_class_get_name(in_trace_class);
58 if (in_trace_class_name) {
59 bt_trace_class_set_name(out_trace_class, in_trace_class_name);
60 }
61
2d836ebb
FD
62 /*
63 * Do not copy the trace class UUID as it may be modified and should no
64 * longer have the same UUID.
65 */
ca9f27f3
FD
66
67 /*
68 * Go over all the entries in the environment section of the trace class
69 * and copy the content to the new trace class.
70 */
71 env_field_count = bt_trace_class_get_environment_entry_count(in_trace_class);
72 for (i = 0; i < env_field_count; i++) {
73 const char *value_name;
74 const bt_value *value = NULL;
d24d5663 75 bt_trace_class_set_environment_entry_status set_env_status;
ca9f27f3
FD
76
77 bt_trace_class_borrow_environment_entry_by_index_const(
78 in_trace_class, i, &value_name, &value);
79
91bc8451 80 BT_COMP_LOGD("Copying trace class environnement entry: "
ca9f27f3
FD
81 "index=%" PRId64 ", value-addr=%p, value-name=%s",
82 i, value, value_name);
83
84 BT_ASSERT(value_name);
85 BT_ASSERT(value);
86
fdd3a2da 87 if (bt_value_is_signed_integer(value)) {
d24d5663 88 set_env_status =
ca9f27f3
FD
89 bt_trace_class_set_environment_entry_integer(
90 out_trace_class, value_name,
fdd3a2da
PP
91 bt_value_signed_integer_get(
92 value));
ca9f27f3 93 } else if (bt_value_is_string(value)) {
d24d5663 94 set_env_status =
ca9f27f3
FD
95 bt_trace_class_set_environment_entry_string(
96 out_trace_class, value_name,
97 bt_value_string_get(value));
98 } else {
99 abort();
100 }
101
d24d5663
PP
102 if (set_env_status !=
103 BT_TRACE_CLASS_SET_ENVIRONMENT_ENTRY_STATUS_OK) {
ca9f27f3
FD
104 ret = -1;
105 goto error;
106 }
107 }
108
91bc8451 109 BT_COMP_LOGD("Copied content of trace class: in-tc-addr=%p, out-tc-addr=%p",
ca9f27f3
FD
110 in_trace_class, out_trace_class);
111error:
112 return ret;
113}
114
115static
116int copy_clock_class_content(const bt_clock_class *in_clock_class,
91bc8451
PP
117 bt_clock_class *out_clock_class, bt_logging_level log_level,
118 bt_self_component *self_comp)
ca9f27f3 119{
ca9f27f3
FD
120 const char *clock_class_name, *clock_class_description;
121 int64_t seconds;
122 uint64_t cycles;
123 bt_uuid in_uuid;
124 int ret = 0;
125
91bc8451 126 BT_COMP_LOGD("Copying content of clock class: in-cc-addr=%p, out-cc-addr=%p",
ca9f27f3
FD
127 in_clock_class, out_clock_class);
128
129 clock_class_name = bt_clock_class_get_name(in_clock_class);
130
131 if (clock_class_name) {
d24d5663
PP
132 if (bt_clock_class_set_name(out_clock_class, clock_class_name)
133 != BT_CLOCK_CLASS_SET_NAME_STATUS_OK) {
91bc8451 134 BT_COMP_LOGE("Error setting clock class' name cc-addr=%p, name=%p",
ca9f27f3
FD
135 out_clock_class, clock_class_name);
136 out_clock_class = NULL;
137 ret = -1;
138 goto error;
139 }
140 }
141
142 clock_class_description = bt_clock_class_get_description(in_clock_class);
143
144 if (clock_class_description) {
d24d5663
PP
145 if (bt_clock_class_set_description(out_clock_class,
146 clock_class_description) !=
147 BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_OK) {
91bc8451 148 BT_COMP_LOGE("Error setting clock class' description cc-addr=%p, "
ca9f27f3
FD
149 "name=%p", out_clock_class, clock_class_description);
150 out_clock_class = NULL;
151 ret = -1;
152 goto error;
153 }
154 }
155
156 in_uuid = bt_clock_class_get_uuid(in_clock_class);
157 if (in_uuid) {
158 bt_clock_class_set_uuid(out_clock_class, in_uuid);
159 }
160
161 bt_clock_class_set_frequency(out_clock_class,
162 bt_clock_class_get_frequency(in_clock_class));
163 bt_clock_class_set_precision(out_clock_class,
164 bt_clock_class_get_precision(in_clock_class));
165 bt_clock_class_get_offset(in_clock_class, &seconds, &cycles);
166 bt_clock_class_set_offset(out_clock_class, seconds, cycles);
167 bt_clock_class_set_origin_is_unix_epoch(out_clock_class,
168 bt_clock_class_origin_is_unix_epoch(in_clock_class));
169
91bc8451 170 BT_COMP_LOGD("Copied content of clock class: in-cc-addr=%p, out-cc-addr=%p",
ca9f27f3
FD
171 in_clock_class, out_clock_class);
172
173error:
174 return ret;
175}
176
177static
178bt_clock_class *borrow_mapped_clock_class(
179 struct trace_ir_metadata_maps *md_maps,
180 const bt_clock_class *in_clock_class)
181{
182 BT_ASSERT(md_maps);
183 BT_ASSERT(in_clock_class);
184
185 return g_hash_table_lookup(md_maps->clock_class_map,
186 (gpointer) in_clock_class);
187}
188
189static
190bt_clock_class *create_new_mapped_clock_class(
191 bt_self_component *self_comp,
192 struct trace_ir_metadata_maps *md_maps,
193 const bt_clock_class *in_clock_class)
194{
195 bt_clock_class *out_clock_class;
196 int ret;
3a3d15f3 197 bt_logging_level log_level = md_maps->log_level;
ca9f27f3 198
91bc8451 199 BT_COMP_LOGD("Creating new mapped clock class: in-cc-addr=%p",
ca9f27f3
FD
200 in_clock_class);
201
202 BT_ASSERT(md_maps);
203 BT_ASSERT(in_clock_class);
204
205 BT_ASSERT(!borrow_mapped_clock_class(md_maps, in_clock_class));
206
207 out_clock_class = bt_clock_class_create(self_comp);
208 if (!out_clock_class) {
91bc8451 209 BT_COMP_LOGE_STR("Cannot create clock class");
ca9f27f3
FD
210 goto end;
211 }
212 /* If not, create a new one and add it to the mapping. */
3a3d15f3 213 ret = copy_clock_class_content(in_clock_class, out_clock_class,
91bc8451 214 log_level, self_comp);
ca9f27f3 215 if (ret) {
91bc8451 216 BT_COMP_LOGE_STR("Cannot copy clock class");
ca9f27f3
FD
217 goto end;
218 }
219
220 g_hash_table_insert(md_maps->clock_class_map,
221 (gpointer) in_clock_class, out_clock_class);
222
91bc8451 223 BT_COMP_LOGD("Created new mapped clock class: in-cc-addr=%p, out-cc-addr=%p",
ca9f27f3
FD
224 in_clock_class, out_clock_class);
225end:
226 return out_clock_class;
227}
228
229BT_HIDDEN
230int copy_stream_class_content(struct trace_ir_maps *ir_maps,
231 const bt_stream_class *in_stream_class,
232 bt_stream_class *out_stream_class)
233{
234 struct trace_ir_metadata_maps *md_maps;
235 const bt_clock_class *in_clock_class;
236 bt_clock_class *out_clock_class;
237 const bt_field_class *in_packet_context_fc, *in_common_context_fc;
238 bt_field_class *out_packet_context_fc, *out_common_context_fc;
ca9f27f3
FD
239 const char *in_name;
240 int ret = 0;
3a3d15f3 241 bt_logging_level log_level = ir_maps->log_level;
91bc8451 242 bt_self_component *self_comp = ir_maps->self_comp;
ca9f27f3 243
91bc8451 244 BT_COMP_LOGD("Copying content of stream class: in-sc-addr=%p, out-sc-addr=%p",
ca9f27f3
FD
245 in_stream_class, out_stream_class);
246
247 md_maps = borrow_metadata_maps_from_input_stream_class(ir_maps, in_stream_class);
248 in_clock_class = bt_stream_class_borrow_default_clock_class_const(
249 in_stream_class);
250
251 if (in_clock_class) {
252 /* Copy the clock class. */
253 out_clock_class =
254 borrow_mapped_clock_class(md_maps, in_clock_class);
255 if (!out_clock_class) {
256 out_clock_class = create_new_mapped_clock_class(
257 ir_maps->self_comp, md_maps,
258 in_clock_class);
259 }
260 bt_stream_class_set_default_clock_class(out_stream_class,
261 out_clock_class);
262
263 }
264
9b24b6aa 265 bt_stream_class_set_packets_have_beginning_default_clock_snapshot(
649934d2 266 out_stream_class,
9b24b6aa 267 bt_stream_class_packets_have_beginning_default_clock_snapshot(
649934d2 268 in_stream_class));
9b24b6aa 269 bt_stream_class_set_packets_have_end_default_clock_snapshot(
649934d2 270 out_stream_class,
9b24b6aa 271 bt_stream_class_packets_have_end_default_clock_snapshot(
649934d2 272 in_stream_class));
2e90378a
PP
273 bt_stream_class_set_supports_discarded_events(
274 out_stream_class,
275 bt_stream_class_supports_discarded_events(in_stream_class),
276 bt_stream_class_discarded_events_have_default_clock_snapshots(
277 in_stream_class));
278 bt_stream_class_set_supports_discarded_packets(
279 out_stream_class,
280 bt_stream_class_supports_discarded_packets(in_stream_class),
281 bt_stream_class_discarded_packets_have_default_clock_snapshots(
282 in_stream_class));
649934d2 283
ca9f27f3
FD
284 in_name = bt_stream_class_get_name(in_stream_class);
285 if (in_name) {
d24d5663
PP
286 if (bt_stream_class_set_name(out_stream_class, in_name) !=
287 BT_STREAM_CLASS_SET_NAME_STATUS_OK) {
91bc8451 288 BT_COMP_LOGE("Error set stream class name: out-sc-addr=%p, "
ca9f27f3
FD
289 "name=%s", out_stream_class, in_name);
290 ret = -1;
291 goto error;
292 }
293 }
294
295 bt_stream_class_set_assigns_automatic_stream_id(out_stream_class,
296 BT_FALSE);
297 bt_stream_class_set_assigns_automatic_event_class_id(out_stream_class,
298 BT_FALSE);
299
300 /*
301 * Add the input packet context field class to the context to
302 * resolution in the further steps.
303 */
304 in_packet_context_fc =
305 bt_stream_class_borrow_packet_context_field_class_const(
306 in_stream_class);
307 md_maps->fc_resolving_ctx->packet_context =
308 in_packet_context_fc;
309
310 if (in_packet_context_fc) {
311 /* Copy packet context. */
312 out_packet_context_fc = create_field_class_copy(
313 md_maps, in_packet_context_fc);
314
315 ret = copy_field_class_content(md_maps,
316 in_packet_context_fc, out_packet_context_fc);
317 if (ret) {
318 ret = -1;
319 goto error;
320 }
321
d24d5663
PP
322 if (bt_stream_class_set_packet_context_field_class(
323 out_stream_class, out_packet_context_fc) !=
324 BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_OK) {
91bc8451 325 BT_COMP_LOGE("Error setting stream class' packet context "
ca9f27f3
FD
326 "field class: sc-addr=%p, packet-fc-addr=%p",
327 out_stream_class, out_packet_context_fc);
328 ret = -1;
329 goto error;
330 }
331 }
332
333 /*
334 * Add the input common context field class to the context to
335 * resolution in the further steps.
336 */
337 in_common_context_fc =
338 bt_stream_class_borrow_event_common_context_field_class_const(
339 in_stream_class);
340 md_maps->fc_resolving_ctx->event_common_context =
341 in_common_context_fc;
342
343 if (in_common_context_fc) {
344 /* Copy common context. */
345 /* TODO: I find it a bit awkward to have this special function
346 * here to add the debug-info field class. I would like to
347 * abstract that.*/
348 out_common_context_fc = create_field_class_copy(
349 md_maps, in_common_context_fc);
350
351 ret = copy_event_common_context_field_class_content(
352 md_maps, ir_maps->debug_info_field_class_name,
353 in_common_context_fc, out_common_context_fc);
354 if (ret) {
355 goto error;
356 }
357
d24d5663
PP
358 if (bt_stream_class_set_event_common_context_field_class(
359 out_stream_class, out_common_context_fc) !=
360 BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_OK) {
91bc8451 361 BT_COMP_LOGE("Error setting stream class' packet context "
ca9f27f3
FD
362 "field class: sc-addr=%p, packet-fc-addr=%p",
363 out_stream_class, out_common_context_fc);
364 ret = -1;
365 goto error;
366 }
367 }
368
369 /* Set packet snapshot boolean fields. */
91bc8451 370 BT_COMP_LOGD("Copied content of stream class: in-sc-addr=%p, out-sc-addr=%p",
ca9f27f3
FD
371 in_stream_class, out_stream_class);
372error:
373 return ret;
374}
375
376BT_HIDDEN
377int copy_event_class_content(struct trace_ir_maps *ir_maps,
378 const bt_event_class *in_event_class,
379 bt_event_class *out_event_class)
380{
381 struct trace_ir_metadata_maps *md_maps;
382 const char *in_event_class_name, *in_emf_uri;
383 bt_property_availability prop_avail;
3a3d15f3 384 bt_event_class_log_level ec_log_level;
ca9f27f3
FD
385 bt_field_class *out_specific_context_fc, *out_payload_fc;
386 const bt_field_class *in_event_specific_context, *in_event_payload;
387 int ret = 0;
3a3d15f3 388 bt_logging_level log_level = ir_maps->log_level;
91bc8451 389 bt_self_component *self_comp = ir_maps->self_comp;
ca9f27f3 390
91bc8451 391 BT_COMP_LOGD("Copying content of event class: in-ec-addr=%p, out-ec-addr=%p",
ca9f27f3
FD
392 in_event_class, out_event_class);
393
394 /* Copy event class name. */
395 in_event_class_name = bt_event_class_get_name(in_event_class);
396 if (in_event_class_name) {
d24d5663
PP
397 if (bt_event_class_set_name(out_event_class,
398 in_event_class_name) !=
399 BT_EVENT_CLASS_SET_NAME_STATUS_OK) {
91bc8451 400 BT_COMP_LOGE("Error setting event class' name: ec-addr=%p, "
ca9f27f3
FD
401 "name=%s", out_event_class, in_event_class_name);
402 ret = -1;
403 goto error;
404 }
405 }
406
407 /* Copy event class loglevel. */
3a3d15f3
PP
408 prop_avail = bt_event_class_get_log_level(in_event_class,
409 &ec_log_level);
ca9f27f3
FD
410 if (prop_avail == BT_PROPERTY_AVAILABILITY_AVAILABLE) {
411 bt_event_class_set_log_level(out_event_class,
3a3d15f3 412 ec_log_level);
ca9f27f3
FD
413 }
414
415 /* Copy event class emf uri. */
416 in_emf_uri = bt_event_class_get_emf_uri(in_event_class);
417 if (in_emf_uri) {
d24d5663
PP
418 if (bt_event_class_set_emf_uri(out_event_class, in_emf_uri) !=
419 BT_EVENT_CLASS_SET_EMF_URI_STATUS_OK) {
91bc8451 420 BT_COMP_LOGE("Error setting event class' emf uri: ec-addr=%p, "
ca9f27f3
FD
421 "emf uri=%s", out_event_class, in_emf_uri);
422 ret = -1;
423 goto error;
424 }
425 }
426
427 md_maps = borrow_metadata_maps_from_input_event_class(ir_maps, in_event_class);
428 /*
429 * Add the input event class' specific ctx to te
430 * context.
431 */
432 in_event_specific_context =
433 bt_event_class_borrow_specific_context_field_class_const(
434 in_event_class);
435
436 md_maps->fc_resolving_ctx->event_specific_context =
437 in_event_specific_context;
438
439 if (in_event_specific_context) {
440 /* Copy the specific context of this event class. */
441 out_specific_context_fc = create_field_class_copy(md_maps,
442 in_event_specific_context);
443
5e1abef6 444 ret = copy_field_class_content(md_maps,
ca9f27f3
FD
445 in_event_specific_context, out_specific_context_fc);
446 if (ret) {
447 goto error;
448 }
449 /*
450 * Add the output specific context to the output event
451 * class.
452 */
d24d5663
PP
453 if (bt_event_class_set_specific_context_field_class(
454 out_event_class, out_specific_context_fc) !=
455 BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_OK) {
91bc8451 456 BT_COMP_LOGE("Error setting event class' specific context "
ca9f27f3
FD
457 "field class: ec-addr=%p, ctx-fc-addr=%p",
458 out_event_class, out_specific_context_fc);
459 ret = -1;
460 goto error;
461 }
462 }
463
464 /*
465 * Add the input event class' payload field class to
466 * the context.
467 */
468 in_event_payload = bt_event_class_borrow_payload_field_class_const(
469 in_event_class);
470
471 md_maps->fc_resolving_ctx->event_payload = in_event_payload;
472
473 if (in_event_payload) {
474 /* Copy the payload of this event class. */
475 out_payload_fc = create_field_class_copy(md_maps,
476 in_event_payload);
5e1abef6 477 ret = copy_field_class_content(md_maps,
ca9f27f3
FD
478 in_event_payload, out_payload_fc);
479 if (ret) {
480 goto error;
481 }
482
483 /* Add the output payload to the output event class. */
d24d5663
PP
484 if (bt_event_class_set_payload_field_class(
485 out_event_class, out_payload_fc) !=
486 BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_OK) {
91bc8451 487 BT_COMP_LOGE("Error setting event class' payload "
ca9f27f3
FD
488 "field class: ec-addr=%p, payload-fc-addr=%p",
489 out_event_class, out_payload_fc);
490 ret = -1;
491 goto error;
492 }
493 }
494
91bc8451 495 BT_COMP_LOGD("Copied content of event class: in-ec-addr=%p, out-ec-addr=%p",
ca9f27f3
FD
496 in_event_class, out_event_class);
497error:
498 return ret;
499}
500
501BT_HIDDEN
502int copy_event_common_context_field_class_content(
503 struct trace_ir_metadata_maps *md_maps,
504 const char *debug_info_fc_name,
505 const bt_field_class *in_field_class,
506 bt_field_class *out_field_class)
507{
ca9f27f3
FD
508 bt_field_class *debug_field_class = NULL, *bin_field_class = NULL,
509 *func_field_class = NULL, *src_field_class = NULL;
510 int ret = 0;
3a3d15f3 511 bt_logging_level log_level = md_maps->log_level;
91bc8451 512 bt_self_component *self_comp = md_maps->self_comp;
ca9f27f3 513
91bc8451 514 BT_COMP_LOGD("Copying content of event common context field class: "
ca9f27f3
FD
515 "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
516
517 /* Copy the content of the input common context. */
518 ret = copy_field_class_content(md_maps, in_field_class, out_field_class);
519 if (ret) {
520 goto error;
521 }
522
523 /*
524 * If this event common context has the necessary fields to compute the
525 * debug information append the debug-info field class to the event
526 * common context.
527 */
528 if (is_event_common_ctx_dbg_info_compatible(in_field_class, debug_info_fc_name)) {
529 /*
530 * The struct field and 3 sub-fields are not stored in the
531 * field class map because they don't have input equivalent.
532 * We need to put our reference each of these field classes
533 * once they are added to their respective containing field
534 * classes.
535 */
536 debug_field_class = bt_field_class_structure_create(
537 md_maps->output_trace_class);
538 if (!debug_field_class) {
91bc8451 539 BT_COMP_LOGE_STR("Failed to create debug_info structure.");
ca9f27f3
FD
540 ret = -1;
541 goto error;
542 }
543
544 bin_field_class = bt_field_class_string_create(
545 md_maps->output_trace_class);
546 if (!bin_field_class) {
91bc8451 547 BT_COMP_LOGE_STR("Failed to create string for field=bin.");
ca9f27f3
FD
548 ret = -1;
549 goto error;
550 }
551
552 func_field_class = bt_field_class_string_create(
553 md_maps->output_trace_class);
554 if (!func_field_class) {
91bc8451 555 BT_COMP_LOGE_STR("Failed to create string for field=func.");
ca9f27f3
FD
556 ret = -1;
557 goto error;
558 }
559
560 src_field_class = bt_field_class_string_create(
561 md_maps->output_trace_class);
562 if (!src_field_class) {
91bc8451 563 BT_COMP_LOGE_STR("Failed to create string for field=src.");
ca9f27f3
FD
564 ret = -1;
565 goto error;
566 }
567
d24d5663
PP
568 if (bt_field_class_structure_append_member(
569 debug_field_class, "bin", bin_field_class) !=
570 BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK) {
91bc8451 571 BT_COMP_LOGE_STR("Failed to add a field to debug_info "
ca9f27f3
FD
572 "struct: field=bin.");
573 ret = -1;
574 goto error;
575 }
576 BT_FIELD_CLASS_PUT_REF_AND_RESET(bin_field_class);
577
d24d5663
PP
578 if (bt_field_class_structure_append_member(
579 debug_field_class, "func", func_field_class) !=
580 BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK) {
91bc8451 581 BT_COMP_LOGE_STR("Failed to add a field to debug_info "
ca9f27f3
FD
582 "struct: field=func.");
583 ret = -1;
584 goto error;
585 }
586 BT_FIELD_CLASS_PUT_REF_AND_RESET(func_field_class);
587
d24d5663
PP
588 if (bt_field_class_structure_append_member(
589 debug_field_class, "src", src_field_class) !=
590 BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK) {
91bc8451 591 BT_COMP_LOGE_STR("Failed to add a field to debug_info "
ca9f27f3
FD
592 "struct: field=src.");
593 ret = -1;
594 goto error;
595 }
596 BT_FIELD_CLASS_PUT_REF_AND_RESET(src_field_class);
597
598 /*Add the filled debug-info field class to the common context. */
d24d5663
PP
599 if (bt_field_class_structure_append_member(out_field_class,
600 debug_info_fc_name, debug_field_class) !=
601 BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK) {
91bc8451 602 BT_COMP_LOGE_STR("Failed to add debug_info field to "
ca9f27f3
FD
603 "event common context.");
604 ret = -1;
605 goto error;
606 }
607 BT_FIELD_CLASS_PUT_REF_AND_RESET(debug_field_class);
608 }
91bc8451 609 BT_COMP_LOGD("Copied content of event common context field class: "
ca9f27f3
FD
610 "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
611 goto end;
612
613error:
614 if (debug_field_class) {
615 bt_field_class_put_ref(debug_field_class);
616 }
617 if (bin_field_class) {
618 bt_field_class_put_ref(bin_field_class);
619 }
620 if (func_field_class) {
621 bt_field_class_put_ref(func_field_class);
622 }
623 if (src_field_class) {
624 bt_field_class_put_ref(src_field_class);
625 }
626end:
627 return ret;
628}
629
630BT_HIDDEN
631bt_field_class *create_field_class_copy(struct trace_ir_metadata_maps *md_maps,
632 const bt_field_class *in_field_class)
633{
634 return create_field_class_copy_internal(md_maps, in_field_class);
635}
636
637BT_HIDDEN
638int copy_field_class_content(struct trace_ir_metadata_maps *md_maps,
639 const bt_field_class *in_field_class,
640 bt_field_class *out_field_class)
641{
642 return copy_field_class_content_internal(md_maps, in_field_class,
643 out_field_class);
644}
This page took 0.056316 seconds and 4 git commands to generate.