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