2 * SPDX-License-Identifier: MIT
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>
8 * Babeltrace - Mapping of IR metadata and data object between input and output
12 #define BT_COMP_LOG_SELF_COMP (ir_maps->self_comp)
13 #define BT_LOG_OUTPUT_LEVEL (ir_maps->log_level)
14 #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-MAPPING"
15 #include "logging/comp-logging.h"
17 #include "common/assert.h"
18 #include <babeltrace2/babeltrace.h>
20 #include "debug-info.h"
21 #include "trace-ir-data-copy.h"
22 #include "trace-ir-mapping.h"
23 #include "trace-ir-metadata-copy.h"
26 bt_trace_class
*create_new_mapped_trace_class(struct trace_ir_maps
*ir_maps
,
27 const bt_trace_class
*in_trace_class
)
29 bt_self_component
*self_comp
= ir_maps
->self_comp
;
30 enum debug_info_trace_ir_mapping_status status
;
31 struct trace_ir_metadata_maps
*metadata_maps
;
33 BT_COMP_LOGD("Creating new mapped trace class: in-tc-addr=%p", in_trace_class
);
36 BT_ASSERT(in_trace_class
);
38 metadata_maps
= borrow_metadata_maps_from_input_trace_class(ir_maps
,
41 BT_ASSERT(!metadata_maps
->output_trace_class
);
43 /* Create the output trace class. */
44 metadata_maps
->output_trace_class
=
45 bt_trace_class_create(ir_maps
->self_comp
);
46 if (!metadata_maps
->output_trace_class
) {
47 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
48 "Error create output trace class");
52 /* Copy the content over and add to the mapping. */
53 status
= copy_trace_class_content(ir_maps
, in_trace_class
,
54 metadata_maps
->output_trace_class
, ir_maps
->log_level
,
56 if (status
!= DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK
) {
57 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
58 "Error copy content to output trace class"
59 "in-tc-addr=%p, out-tc-addr=%p", in_trace_class
,
60 metadata_maps
->output_trace_class
);
64 BT_COMP_LOGD("Created new mapped trace class: "
65 "in-tc-addr=%p, out-tc-addr=%p",
66 in_trace_class
, metadata_maps
->output_trace_class
);
70 BT_TRACE_CLASS_PUT_REF_AND_RESET(metadata_maps
->output_trace_class
);
72 return metadata_maps
->output_trace_class
;
76 bt_trace
*create_new_mapped_trace(struct trace_ir_maps
*ir_maps
,
77 const bt_trace
*in_trace
)
79 bt_self_component
*self_comp
= ir_maps
->self_comp
;
80 enum debug_info_trace_ir_mapping_status status
;
81 struct trace_ir_metadata_maps
*metadata_maps
;
82 const bt_trace_class
*in_trace_class
;
85 BT_COMP_LOGD("Creating new mapped trace: in-t-addr=%p", in_trace
);
89 in_trace_class
= bt_trace_borrow_class_const(in_trace
);
90 metadata_maps
= borrow_metadata_maps_from_input_trace_class(ir_maps
,
93 if (!metadata_maps
->output_trace_class
) {
95 * If there is no output trace class yet, create a one and add
98 metadata_maps
->output_trace_class
=
99 create_new_mapped_trace_class(ir_maps
, in_trace_class
);
100 if (!metadata_maps
->output_trace_class
) {
101 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
102 "Error create output trace class");
108 /* Create the output trace from the output trace class. */
109 out_trace
= bt_trace_create(metadata_maps
->output_trace_class
);
111 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
112 "Error create output trace");
116 /* Copy the content over to the output trace. */
117 status
= copy_trace_content(in_trace
, out_trace
, ir_maps
->log_level
,
119 if (status
!= DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK
) {
120 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
121 "Error copy content to output trace"
122 "in-t-addr=%p, out-t-addr=%p", in_trace
, out_trace
);
126 BT_COMP_LOGD("Created new mapped trace: in-t-addr=%p, out-t-addr=%p",
127 in_trace
, out_trace
);
131 BT_TRACE_PUT_REF_AND_RESET(out_trace
);
136 bt_stream_class
*trace_ir_mapping_borrow_mapped_stream_class(
137 struct trace_ir_maps
*ir_maps
,
138 const bt_stream_class
*in_stream_class
)
140 BT_ASSERT_DBG(ir_maps
);
141 BT_ASSERT_DBG(in_stream_class
);
143 struct trace_ir_metadata_maps
*md_maps
=
144 borrow_metadata_maps_from_input_stream_class(ir_maps
,
146 return g_hash_table_lookup(md_maps
->stream_class_map
,
147 (gpointer
) in_stream_class
);
150 bt_stream_class
*trace_ir_mapping_create_new_mapped_stream_class(
151 struct trace_ir_maps
*ir_maps
,
152 const bt_stream_class
*in_stream_class
)
154 bt_self_component
*self_comp
= ir_maps
->self_comp
;
155 enum debug_info_trace_ir_mapping_status status
;
156 struct trace_ir_metadata_maps
*md_maps
;
157 bt_stream_class
*out_stream_class
;
159 BT_COMP_LOGD("Creating new mapped stream class: in-sc-addr=%p",
163 BT_ASSERT(in_stream_class
);
164 BT_ASSERT(!trace_ir_mapping_borrow_mapped_stream_class(ir_maps
,
167 md_maps
= borrow_metadata_maps_from_input_stream_class(ir_maps
,
172 /* Create the output stream class. */
173 out_stream_class
= bt_stream_class_create_with_id(
174 md_maps
->output_trace_class
,
175 bt_stream_class_get_id(in_stream_class
));
176 if (!out_stream_class
) {
177 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
178 "Error create output stream class");
182 /* Add it to the mapping. The mapping now owns out_stream_class. */
183 g_hash_table_insert(md_maps
->stream_class_map
,
184 (gpointer
) in_stream_class
, out_stream_class
);
186 /* Copy the content over to the output stream class. */
187 status
= copy_stream_class_content(ir_maps
, in_stream_class
,
189 if (status
!= DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK
) {
190 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
191 "Error copy content to output stream class: "
192 "in-sc-addr=%p, out-sc-addr=%p", in_stream_class
,
197 BT_COMP_LOGD("Created new mapped stream class: "
198 "in-sc-addr=%p, out-sc-addr=%p",
199 in_stream_class
, out_stream_class
);
203 out_stream_class
= NULL
;
205 return out_stream_class
;
209 bt_stream
*borrow_mapped_stream(struct trace_ir_data_maps
*d_maps
,
210 const bt_stream
*in_stream
)
212 BT_ASSERT_DBG(d_maps
);
213 BT_ASSERT_DBG(in_stream
);
215 return g_hash_table_lookup(d_maps
->stream_map
, (gpointer
) in_stream
);
218 bt_stream
*trace_ir_mapping_create_new_mapped_stream(
219 struct trace_ir_maps
*ir_maps
, const bt_stream
*in_stream
)
221 bt_self_component
*self_comp
= ir_maps
->self_comp
;
222 enum debug_info_trace_ir_mapping_status status
;
223 struct trace_ir_data_maps
*d_maps
;
224 const bt_stream_class
*in_stream_class
;
225 const bt_trace
*in_trace
;
226 bt_stream_class
*out_stream_class
;
227 bt_stream
*out_stream
= NULL
;
230 BT_ASSERT(in_stream
);
231 BT_COMP_LOGD("Creating new mapped stream: in-s-addr=%p", in_stream
);
233 in_trace
= bt_stream_borrow_trace_const(in_stream
);
235 d_maps
= borrow_data_maps_from_input_trace(ir_maps
, in_trace
);
236 if (!d_maps
->output_trace
) {
237 /* Create the output trace for this input trace. */
238 d_maps
->output_trace
= create_new_mapped_trace(ir_maps
, in_trace
);
239 if (!d_maps
->output_trace
) {
240 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
241 "Error creating mapped trace");
246 BT_ASSERT(d_maps
->output_trace
);
247 BT_ASSERT(!borrow_mapped_stream(d_maps
, in_stream
));
249 in_stream_class
= bt_stream_borrow_class_const(in_stream
);
250 out_stream_class
= trace_ir_mapping_borrow_mapped_stream_class(ir_maps
,
253 if (!out_stream_class
) {
254 /* Create the output stream class for this input stream class. */
255 out_stream_class
= trace_ir_mapping_create_new_mapped_stream_class(
256 ir_maps
, in_stream_class
);
257 if (!out_stream_class
) {
258 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
259 "Error creating mapped stream class");
263 BT_ASSERT(out_stream_class
);
265 /* Create the output stream for this input stream. */
266 out_stream
= bt_stream_create_with_id(out_stream_class
,
267 d_maps
->output_trace
, bt_stream_get_id(in_stream
));
269 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
270 "Error creating output stream");
274 /* Add it to the mapping. The mapping now owns out_stream.*/
275 g_hash_table_insert(d_maps
->stream_map
, (gpointer
) in_stream
,
278 /* Copy the content over to the output stream. */
279 status
= copy_stream_content(in_stream
, out_stream
, ir_maps
->log_level
,
281 if (status
!= DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK
) {
282 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
283 "Error copy content to output stream: "
284 "in-s-addr=%p, out-s-addr=%p", in_stream
, out_stream
);
288 BT_COMP_LOGD("Created new mapped stream: in-s-addr=%p, out-s-addr=%p",
289 in_stream
, out_stream
);
298 bt_stream
*trace_ir_mapping_borrow_mapped_stream(struct trace_ir_maps
*ir_maps
,
299 const bt_stream
*in_stream
)
301 struct trace_ir_data_maps
*d_maps
;
303 BT_ASSERT_DBG(ir_maps
);
304 BT_ASSERT_DBG(in_stream
);
306 d_maps
= borrow_data_maps_from_input_stream(ir_maps
, in_stream
);
307 /* Return the mapped stream. */
308 return borrow_mapped_stream(d_maps
, in_stream
);
312 bt_event_class
*borrow_mapped_event_class(struct trace_ir_metadata_maps
*md_maps
,
313 const bt_event_class
*in_event_class
)
315 return g_hash_table_lookup(md_maps
->event_class_map
,
316 (gpointer
) in_event_class
);
319 bt_event_class
*trace_ir_mapping_create_new_mapped_event_class(
320 struct trace_ir_maps
*ir_maps
,
321 const bt_event_class
*in_event_class
)
323 bt_self_component
*self_comp
= ir_maps
->self_comp
;
324 enum debug_info_trace_ir_mapping_status status
;
325 struct trace_ir_metadata_maps
*md_maps
;
326 const bt_stream_class
*in_stream_class
;
327 bt_stream_class
*out_stream_class
;
328 bt_event_class
*out_event_class
;
330 BT_COMP_LOGD("Creating new mapped event class: in-ec-addr=%p",
334 BT_ASSERT(in_event_class
);
336 in_stream_class
= bt_event_class_borrow_stream_class_const(in_event_class
);
338 BT_ASSERT(in_stream_class
);
340 md_maps
= borrow_metadata_maps_from_input_stream_class(ir_maps
,
344 BT_ASSERT(!borrow_mapped_event_class(md_maps
, in_event_class
));
346 /* Get the right output stream class to add the new event class to it. */
347 out_stream_class
= trace_ir_mapping_borrow_mapped_stream_class(
348 ir_maps
, in_stream_class
);
349 BT_ASSERT(out_stream_class
);
351 /* Create an output event class. */
352 out_event_class
= bt_event_class_create_with_id(out_stream_class
,
353 bt_event_class_get_id(in_event_class
));
354 if (!out_event_class
) {
355 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
356 "Error creating output event class");
360 /* Add it to the mapping. The mapping now owns out_event_class. */
361 g_hash_table_insert(md_maps
->event_class_map
, (gpointer
) in_event_class
,
364 /* Copy the content over to the output event class. */
365 status
= copy_event_class_content(ir_maps
, in_event_class
,
367 if (status
!= DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK
) {
368 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
369 "Error copy content to output event class: "
370 "in-ec-addr=%p, out-ec-addr=%p", in_event_class
,
375 BT_COMP_LOGD("Created new mapped event class: in-ec-addr=%p, out-ec-addr=%p",
376 in_event_class
, out_event_class
);
380 out_event_class
= NULL
;
382 return out_event_class
;
385 bt_event_class
*trace_ir_mapping_borrow_mapped_event_class(
386 struct trace_ir_maps
*ir_maps
,
387 const bt_event_class
*in_event_class
)
389 struct trace_ir_metadata_maps
*md_maps
;
391 BT_ASSERT_DBG(ir_maps
);
392 BT_ASSERT_DBG(in_event_class
);
394 md_maps
= borrow_metadata_maps_from_input_event_class(ir_maps
,
397 /* Return the mapped event_class. */
398 return borrow_mapped_event_class(md_maps
, in_event_class
);
402 bt_packet
*borrow_mapped_packet(struct trace_ir_data_maps
*d_maps
,
403 const bt_packet
*in_packet
)
405 BT_ASSERT_DBG(d_maps
);
406 BT_ASSERT_DBG(in_packet
);
408 return g_hash_table_lookup(d_maps
->packet_map
, (gpointer
) in_packet
);
411 bt_packet
*trace_ir_mapping_create_new_mapped_packet(
412 struct trace_ir_maps
*ir_maps
,
413 const bt_packet
*in_packet
)
415 bt_self_component
*self_comp
= ir_maps
->self_comp
;
416 enum debug_info_trace_ir_mapping_status status
;
417 struct trace_ir_data_maps
*d_maps
;
418 const bt_stream
*in_stream
;
419 const bt_trace
*in_trace
;
420 bt_packet
*out_packet
;
421 bt_stream
*out_stream
;
423 BT_COMP_LOGD("Creating new mapped packet: in-p-addr=%p", in_packet
);
425 in_stream
= bt_packet_borrow_stream_const(in_packet
);
426 in_trace
= bt_stream_borrow_trace_const(in_stream
);
427 d_maps
= borrow_data_maps_from_input_trace(ir_maps
, in_trace
);
429 /* There should never be a mapped packet already. */
430 BT_ASSERT(!borrow_mapped_packet(d_maps
, in_packet
));
431 BT_ASSERT(in_stream
);
433 /* Get output stream corresponding to this input stream. */
434 out_stream
= borrow_mapped_stream(d_maps
, in_stream
);
435 BT_ASSERT(out_stream
);
437 /* Create the output packet. */
438 out_packet
= bt_packet_create(out_stream
);
440 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
441 "Error create output packet");
445 /* Add it to the mapping. The mapping now owns out_packet. */
446 g_hash_table_insert(d_maps
->packet_map
, (gpointer
) in_packet
,
449 /* Copy the content over to the output packet. */
450 status
= copy_packet_content(in_packet
, out_packet
, ir_maps
->log_level
,
452 if (status
!= DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK
) {
453 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
454 "Error copy content to output packet: "
455 "in-p-addr=%p, out-p-addr=%p", in_packet
, out_packet
);
459 BT_COMP_LOGD("Created new mapped packet: in-p-addr=%p, out-p-addr=%p",
460 in_packet
, out_packet
);
469 bt_packet
*trace_ir_mapping_borrow_mapped_packet(struct trace_ir_maps
*ir_maps
,
470 const bt_packet
*in_packet
)
472 struct trace_ir_data_maps
*d_maps
;
473 BT_ASSERT_DBG(ir_maps
);
474 BT_ASSERT_DBG(in_packet
);
476 d_maps
= borrow_data_maps_from_input_packet(ir_maps
, in_packet
);
478 return borrow_mapped_packet(d_maps
, in_packet
);
481 void trace_ir_mapping_remove_mapped_packet(struct trace_ir_maps
*ir_maps
,
482 const bt_packet
*in_packet
)
484 struct trace_ir_data_maps
*d_maps
;
488 BT_ASSERT(in_packet
);
490 d_maps
= borrow_data_maps_from_input_packet(ir_maps
, in_packet
);
492 ret
= g_hash_table_remove(d_maps
->packet_map
, in_packet
);
497 void trace_ir_mapping_remove_mapped_stream(struct trace_ir_maps
*ir_maps
,
498 const bt_stream
*in_stream
)
500 struct trace_ir_data_maps
*d_maps
;
504 BT_ASSERT(in_stream
);
506 d_maps
= borrow_data_maps_from_input_stream(ir_maps
, in_stream
);
508 ret
= g_hash_table_remove(d_maps
->stream_map
, in_stream
);
514 void trace_ir_metadata_maps_remove_func(const bt_trace_class
*in_trace_class
,
517 struct trace_ir_maps
*maps
= (struct trace_ir_maps
*) data
;
518 if (maps
->metadata_maps
) {
520 ret
= g_hash_table_remove(maps
->metadata_maps
,
521 (gpointer
) in_trace_class
);
527 void trace_ir_data_maps_remove_func(const bt_trace
*in_trace
, void *data
)
529 struct trace_ir_maps
*maps
= (struct trace_ir_maps
*) data
;
530 if (maps
->data_maps
) {
532 ret
= g_hash_table_remove(maps
->data_maps
, (gpointer
) in_trace
);
537 struct trace_ir_data_maps
*trace_ir_data_maps_create(struct trace_ir_maps
*ir_maps
,
538 const bt_trace
*in_trace
)
540 bt_self_component
*self_comp
= ir_maps
->self_comp
;
541 bt_trace_add_listener_status add_listener_status
;
542 struct trace_ir_data_maps
*d_maps
= g_new0(struct trace_ir_data_maps
, 1);
545 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
546 "Error allocating trace_ir_maps");
550 d_maps
->log_level
= ir_maps
->log_level
;
551 d_maps
->self_comp
= ir_maps
->self_comp
;
552 d_maps
->input_trace
= in_trace
;
554 /* Create the hashtables used to map data objects. */
555 d_maps
->stream_map
= g_hash_table_new_full(g_direct_hash
,
556 g_direct_equal
, NULL
,(GDestroyNotify
) bt_stream_put_ref
);
557 d_maps
->packet_map
= g_hash_table_new_full(g_direct_hash
,
558 g_direct_equal
, NULL
,(GDestroyNotify
) bt_packet_put_ref
);
560 add_listener_status
= bt_trace_add_destruction_listener(
561 in_trace
, trace_ir_data_maps_remove_func
,
562 ir_maps
, &d_maps
->destruction_listener_id
);
563 BT_ASSERT(add_listener_status
== BT_TRACE_ADD_LISTENER_STATUS_OK
);
569 struct trace_ir_metadata_maps
*trace_ir_metadata_maps_create(
570 struct trace_ir_maps
*ir_maps
,
571 const bt_trace_class
*in_trace_class
)
573 bt_self_component
*self_comp
= ir_maps
->self_comp
;
574 bt_trace_class_add_listener_status add_listener_status
;
575 struct trace_ir_metadata_maps
*md_maps
=
576 g_new0(struct trace_ir_metadata_maps
, 1);
579 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
580 "Error allocating trace_ir_maps");
584 md_maps
->log_level
= ir_maps
->log_level
;
585 md_maps
->self_comp
= ir_maps
->self_comp
;
586 md_maps
->input_trace_class
= in_trace_class
;
588 * Create the field class resolving context. This is needed to keep
589 * track of the field class already copied in order to do the field
590 * path resolution correctly.
592 md_maps
->fc_resolving_ctx
=
593 g_new0(struct field_class_resolving_context
, 1);
594 if (!md_maps
->fc_resolving_ctx
) {
595 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
596 "Error allocating field_class_resolving_context");
600 /* Create the hashtables used to map metadata objects. */
601 md_maps
->stream_class_map
= g_hash_table_new_full(g_direct_hash
,
602 g_direct_equal
, NULL
, (GDestroyNotify
) bt_stream_class_put_ref
);
603 md_maps
->event_class_map
= g_hash_table_new_full(g_direct_hash
,
604 g_direct_equal
, NULL
, (GDestroyNotify
) bt_event_class_put_ref
);
605 md_maps
->field_class_map
= g_hash_table_new_full(g_direct_hash
,
606 g_direct_equal
, NULL
, (GDestroyNotify
) bt_field_class_put_ref
);
607 md_maps
->clock_class_map
= g_hash_table_new_full(g_direct_hash
,
608 g_direct_equal
, NULL
, (GDestroyNotify
) bt_clock_class_put_ref
);
610 add_listener_status
= bt_trace_class_add_destruction_listener(
611 in_trace_class
, trace_ir_metadata_maps_remove_func
,
612 ir_maps
, &md_maps
->destruction_listener_id
);
613 BT_ASSERT(add_listener_status
== BT_TRACE_CLASS_ADD_LISTENER_STATUS_OK
);
619 void trace_ir_data_maps_destroy(struct trace_ir_data_maps
*maps
)
621 bt_trace_remove_listener_status status
;
627 if (maps
->packet_map
) {
628 g_hash_table_destroy(maps
->packet_map
);
631 if (maps
->stream_map
) {
632 g_hash_table_destroy(maps
->stream_map
);
635 if (maps
->output_trace
) {
636 bt_trace_put_ref(maps
->output_trace
);
639 status
= bt_trace_remove_destruction_listener(maps
->input_trace
,
640 maps
->destruction_listener_id
);
641 if (status
!= BT_TRACE_REMOVE_LISTENER_STATUS_OK
) {
642 BT_COMP_LOG_CUR_LVL(BT_LOG_DEBUG
, maps
->log_level
,
644 "Trace destruction listener removal failed.");
645 bt_current_thread_clear_error();
651 void trace_ir_metadata_maps_destroy(struct trace_ir_metadata_maps
*maps
)
653 bt_trace_class_remove_listener_status status
;
659 if (maps
->stream_class_map
) {
660 g_hash_table_destroy(maps
->stream_class_map
);
663 if (maps
->event_class_map
) {
664 g_hash_table_destroy(maps
->event_class_map
);
667 if (maps
->field_class_map
) {
668 g_hash_table_destroy(maps
->field_class_map
);
671 if (maps
->clock_class_map
) {
672 g_hash_table_destroy(maps
->clock_class_map
);
675 g_free(maps
->fc_resolving_ctx
);
677 if (maps
->output_trace_class
) {
678 bt_trace_class_put_ref(maps
->output_trace_class
);
681 status
= bt_trace_class_remove_destruction_listener(
682 maps
->input_trace_class
, maps
->destruction_listener_id
);
683 if (status
!= BT_TRACE_CLASS_REMOVE_LISTENER_STATUS_OK
) {
684 BT_COMP_LOG_CUR_LVL(BT_LOG_DEBUG
, maps
->log_level
,
686 "Trace destruction listener removal failed.");
687 bt_current_thread_clear_error();
693 void trace_ir_maps_clear(struct trace_ir_maps
*maps
)
695 if (maps
->data_maps
) {
696 g_hash_table_remove_all(maps
->data_maps
);
699 if (maps
->metadata_maps
) {
700 g_hash_table_remove_all(maps
->metadata_maps
);
704 void trace_ir_maps_destroy(struct trace_ir_maps
*maps
)
710 g_free(maps
->debug_info_field_class_name
);
712 if (maps
->data_maps
) {
713 g_hash_table_destroy(maps
->data_maps
);
714 maps
->data_maps
= NULL
;
717 if (maps
->metadata_maps
) {
718 g_hash_table_destroy(maps
->metadata_maps
);
719 maps
->metadata_maps
= NULL
;
725 struct trace_ir_maps
*trace_ir_maps_create(bt_self_component
*self_comp
,
726 const char *debug_info_field_name
, bt_logging_level log_level
)
728 struct trace_ir_maps
*ir_maps
= g_new0(struct trace_ir_maps
, 1);
730 BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR
, log_level
, self_comp
,
731 "Error allocating trace_ir_maps");
735 ir_maps
->log_level
= log_level
;
736 ir_maps
->self_comp
= self_comp
;
738 /* Copy debug info field name received from the user. */
739 ir_maps
->debug_info_field_class_name
= g_strdup(debug_info_field_name
);
740 if (!ir_maps
->debug_info_field_class_name
) {
741 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
742 "Cannot copy debug info field name");
746 ir_maps
->self_comp
= self_comp
;
748 ir_maps
->data_maps
= g_hash_table_new_full(g_direct_hash
,
749 g_direct_equal
, (GDestroyNotify
) NULL
,
750 (GDestroyNotify
) trace_ir_data_maps_destroy
);
752 ir_maps
->metadata_maps
= g_hash_table_new_full(g_direct_hash
,
753 g_direct_equal
, (GDestroyNotify
) NULL
,
754 (GDestroyNotify
) trace_ir_metadata_maps_destroy
);
758 trace_ir_maps_destroy(ir_maps
);