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 ouput 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
);
137 bt_stream_class
*trace_ir_mapping_borrow_mapped_stream_class(
138 struct trace_ir_maps
*ir_maps
,
139 const bt_stream_class
*in_stream_class
)
141 BT_ASSERT_DBG(ir_maps
);
142 BT_ASSERT_DBG(in_stream_class
);
144 struct trace_ir_metadata_maps
*md_maps
=
145 borrow_metadata_maps_from_input_stream_class(ir_maps
,
147 return g_hash_table_lookup(md_maps
->stream_class_map
,
148 (gpointer
) in_stream_class
);
152 bt_stream_class
*trace_ir_mapping_create_new_mapped_stream_class(
153 struct trace_ir_maps
*ir_maps
,
154 const bt_stream_class
*in_stream_class
)
156 bt_self_component
*self_comp
= ir_maps
->self_comp
;
157 enum debug_info_trace_ir_mapping_status status
;
158 struct trace_ir_metadata_maps
*md_maps
;
159 bt_stream_class
*out_stream_class
;
161 BT_COMP_LOGD("Creating new mapped stream class: in-sc-addr=%p",
165 BT_ASSERT(in_stream_class
);
166 BT_ASSERT(!trace_ir_mapping_borrow_mapped_stream_class(ir_maps
,
169 md_maps
= borrow_metadata_maps_from_input_stream_class(ir_maps
,
174 /* Create the output stream class. */
175 out_stream_class
= bt_stream_class_create_with_id(
176 md_maps
->output_trace_class
,
177 bt_stream_class_get_id(in_stream_class
));
178 if (!out_stream_class
) {
179 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
180 "Error create output stream class");
184 /* Add it to the mapping. The mapping now owns out_stream_class. */
185 g_hash_table_insert(md_maps
->stream_class_map
,
186 (gpointer
) in_stream_class
, out_stream_class
);
188 /* Copy the content over to the output stream class. */
189 status
= copy_stream_class_content(ir_maps
, in_stream_class
,
191 if (status
!= DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK
) {
192 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
193 "Error copy content to output stream class: "
194 "in-sc-addr=%p, out-sc-addr=%p", in_stream_class
,
199 BT_COMP_LOGD("Created new mapped stream class: "
200 "in-sc-addr=%p, out-sc-addr=%p",
201 in_stream_class
, out_stream_class
);
205 out_stream_class
= NULL
;
207 return out_stream_class
;
211 bt_stream
*borrow_mapped_stream(struct trace_ir_data_maps
*d_maps
,
212 const bt_stream
*in_stream
)
214 BT_ASSERT_DBG(d_maps
);
215 BT_ASSERT_DBG(in_stream
);
217 return g_hash_table_lookup(d_maps
->stream_map
, (gpointer
) in_stream
);
221 bt_stream
*trace_ir_mapping_create_new_mapped_stream(
222 struct trace_ir_maps
*ir_maps
, const bt_stream
*in_stream
)
224 bt_self_component
*self_comp
= ir_maps
->self_comp
;
225 enum debug_info_trace_ir_mapping_status status
;
226 struct trace_ir_data_maps
*d_maps
;
227 const bt_stream_class
*in_stream_class
;
228 const bt_trace
*in_trace
;
229 bt_stream_class
*out_stream_class
;
230 bt_stream
*out_stream
= NULL
;
233 BT_ASSERT(in_stream
);
234 BT_COMP_LOGD("Creating new mapped stream: in-s-addr=%p", in_stream
);
236 in_trace
= bt_stream_borrow_trace_const(in_stream
);
238 d_maps
= borrow_data_maps_from_input_trace(ir_maps
, in_trace
);
239 if (!d_maps
->output_trace
) {
240 /* Create the output trace for this input trace. */
241 d_maps
->output_trace
= create_new_mapped_trace(ir_maps
, in_trace
);
242 if (!d_maps
->output_trace
) {
243 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
244 "Error creating mapped trace");
249 BT_ASSERT(d_maps
->output_trace
);
250 BT_ASSERT(!borrow_mapped_stream(d_maps
, in_stream
));
252 in_stream_class
= bt_stream_borrow_class_const(in_stream
);
253 out_stream_class
= trace_ir_mapping_borrow_mapped_stream_class(ir_maps
,
256 if (!out_stream_class
) {
257 /* Create the output stream class for this input stream class. */
258 out_stream_class
= trace_ir_mapping_create_new_mapped_stream_class(
259 ir_maps
, in_stream_class
);
260 if (!out_stream_class
) {
261 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
262 "Error creating mapped stream class");
266 BT_ASSERT(out_stream_class
);
268 /* Create the output stream for this input stream. */
269 out_stream
= bt_stream_create_with_id(out_stream_class
,
270 d_maps
->output_trace
, bt_stream_get_id(in_stream
));
272 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
273 "Error creating output stream");
277 /* Add it to the mapping. The mapping now owns out_stream.*/
278 g_hash_table_insert(d_maps
->stream_map
, (gpointer
) in_stream
,
281 /* Copy the content over to the output stream. */
282 status
= copy_stream_content(in_stream
, out_stream
, ir_maps
->log_level
,
284 if (status
!= DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK
) {
285 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
286 "Error copy content to output stream: "
287 "in-s-addr=%p, out-s-addr=%p", in_stream
, out_stream
);
291 BT_COMP_LOGD("Created new mapped stream: in-s-addr=%p, out-s-addr=%p",
292 in_stream
, out_stream
);
302 bt_stream
*trace_ir_mapping_borrow_mapped_stream(struct trace_ir_maps
*ir_maps
,
303 const bt_stream
*in_stream
)
305 struct trace_ir_data_maps
*d_maps
;
307 BT_ASSERT_DBG(ir_maps
);
308 BT_ASSERT_DBG(in_stream
);
310 d_maps
= borrow_data_maps_from_input_stream(ir_maps
, in_stream
);
311 /* Return the mapped stream. */
312 return borrow_mapped_stream(d_maps
, in_stream
);
316 bt_event_class
*borrow_mapped_event_class(struct trace_ir_metadata_maps
*md_maps
,
317 const bt_event_class
*in_event_class
)
319 return g_hash_table_lookup(md_maps
->event_class_map
,
320 (gpointer
) in_event_class
);
324 bt_event_class
*trace_ir_mapping_create_new_mapped_event_class(
325 struct trace_ir_maps
*ir_maps
,
326 const bt_event_class
*in_event_class
)
328 bt_self_component
*self_comp
= ir_maps
->self_comp
;
329 enum debug_info_trace_ir_mapping_status status
;
330 struct trace_ir_metadata_maps
*md_maps
;
331 const bt_stream_class
*in_stream_class
;
332 bt_stream_class
*out_stream_class
;
333 bt_event_class
*out_event_class
;
335 BT_COMP_LOGD("Creating new mapped event class: in-ec-addr=%p",
339 BT_ASSERT(in_event_class
);
341 in_stream_class
= bt_event_class_borrow_stream_class_const(in_event_class
);
343 BT_ASSERT(in_stream_class
);
345 md_maps
= borrow_metadata_maps_from_input_stream_class(ir_maps
,
349 BT_ASSERT(!borrow_mapped_event_class(md_maps
, in_event_class
));
351 /* Get the right output stream class to add the new event class to it. */
352 out_stream_class
= trace_ir_mapping_borrow_mapped_stream_class(
353 ir_maps
, in_stream_class
);
354 BT_ASSERT(out_stream_class
);
356 /* Create an output event class. */
357 out_event_class
= bt_event_class_create_with_id(out_stream_class
,
358 bt_event_class_get_id(in_event_class
));
359 if (!out_event_class
) {
360 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
361 "Error creating output event class");
365 /* Add it to the mapping. The mapping now owns out_event_class. */
366 g_hash_table_insert(md_maps
->event_class_map
, (gpointer
) in_event_class
,
369 /* Copy the content over to the output event class. */
370 status
= copy_event_class_content(ir_maps
, in_event_class
,
372 if (status
!= DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK
) {
373 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
374 "Error copy content to output event class: "
375 "in-ec-addr=%p, out-ec-addr=%p", in_event_class
,
380 BT_COMP_LOGD("Created new mapped event class: in-ec-addr=%p, out-ec-addr=%p",
381 in_event_class
, out_event_class
);
385 out_event_class
= NULL
;
387 return out_event_class
;
391 bt_event_class
*trace_ir_mapping_borrow_mapped_event_class(
392 struct trace_ir_maps
*ir_maps
,
393 const bt_event_class
*in_event_class
)
395 struct trace_ir_metadata_maps
*md_maps
;
397 BT_ASSERT_DBG(ir_maps
);
398 BT_ASSERT_DBG(in_event_class
);
400 md_maps
= borrow_metadata_maps_from_input_event_class(ir_maps
,
403 /* Return the mapped event_class. */
404 return borrow_mapped_event_class(md_maps
, in_event_class
);
408 bt_packet
*borrow_mapped_packet(struct trace_ir_data_maps
*d_maps
,
409 const bt_packet
*in_packet
)
411 BT_ASSERT_DBG(d_maps
);
412 BT_ASSERT_DBG(in_packet
);
414 return g_hash_table_lookup(d_maps
->packet_map
, (gpointer
) in_packet
);
418 bt_packet
*trace_ir_mapping_create_new_mapped_packet(
419 struct trace_ir_maps
*ir_maps
,
420 const bt_packet
*in_packet
)
422 bt_self_component
*self_comp
= ir_maps
->self_comp
;
423 enum debug_info_trace_ir_mapping_status status
;
424 struct trace_ir_data_maps
*d_maps
;
425 const bt_stream
*in_stream
;
426 const bt_trace
*in_trace
;
427 bt_packet
*out_packet
;
428 bt_stream
*out_stream
;
430 BT_COMP_LOGD("Creating new mapped packet: in-p-addr=%p", in_packet
);
432 in_stream
= bt_packet_borrow_stream_const(in_packet
);
433 in_trace
= bt_stream_borrow_trace_const(in_stream
);
434 d_maps
= borrow_data_maps_from_input_trace(ir_maps
, in_trace
);
436 /* There should never be a mapped packet already. */
437 BT_ASSERT(!borrow_mapped_packet(d_maps
, in_packet
));
438 BT_ASSERT(in_stream
);
440 /* Get output stream corresponding to this input stream. */
441 out_stream
= borrow_mapped_stream(d_maps
, in_stream
);
442 BT_ASSERT(out_stream
);
444 /* Create the output packet. */
445 out_packet
= bt_packet_create(out_stream
);
447 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
448 "Error create output packet");
452 /* Add it to the mapping. The mapping now owns out_packet. */
453 g_hash_table_insert(d_maps
->packet_map
, (gpointer
) in_packet
,
456 /* Copy the content over to the output packet. */
457 status
= copy_packet_content(in_packet
, out_packet
, ir_maps
->log_level
,
459 if (status
!= DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK
) {
460 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
461 "Error copy content to output packet: "
462 "in-p-addr=%p, out-p-addr=%p", in_packet
, out_packet
);
466 BT_COMP_LOGD("Created new mapped packet: in-p-addr=%p, out-p-addr=%p",
467 in_packet
, out_packet
);
477 bt_packet
*trace_ir_mapping_borrow_mapped_packet(struct trace_ir_maps
*ir_maps
,
478 const bt_packet
*in_packet
)
480 struct trace_ir_data_maps
*d_maps
;
481 BT_ASSERT_DBG(ir_maps
);
482 BT_ASSERT_DBG(in_packet
);
484 d_maps
= borrow_data_maps_from_input_packet(ir_maps
, in_packet
);
486 return borrow_mapped_packet(d_maps
, in_packet
);
490 void trace_ir_mapping_remove_mapped_packet(struct trace_ir_maps
*ir_maps
,
491 const bt_packet
*in_packet
)
493 struct trace_ir_data_maps
*d_maps
;
497 BT_ASSERT(in_packet
);
499 d_maps
= borrow_data_maps_from_input_packet(ir_maps
, in_packet
);
501 ret
= g_hash_table_remove(d_maps
->packet_map
, in_packet
);
507 void trace_ir_mapping_remove_mapped_stream(struct trace_ir_maps
*ir_maps
,
508 const bt_stream
*in_stream
)
510 struct trace_ir_data_maps
*d_maps
;
514 BT_ASSERT(in_stream
);
516 d_maps
= borrow_data_maps_from_input_stream(ir_maps
, in_stream
);
518 ret
= g_hash_table_remove(d_maps
->stream_map
, in_stream
);
524 void trace_ir_metadata_maps_remove_func(const bt_trace_class
*in_trace_class
,
527 struct trace_ir_maps
*maps
= (struct trace_ir_maps
*) data
;
528 if (maps
->metadata_maps
) {
530 ret
= g_hash_table_remove(maps
->metadata_maps
,
531 (gpointer
) in_trace_class
);
537 void trace_ir_data_maps_remove_func(const bt_trace
*in_trace
, void *data
)
539 struct trace_ir_maps
*maps
= (struct trace_ir_maps
*) data
;
540 if (maps
->data_maps
) {
542 ret
= g_hash_table_remove(maps
->data_maps
, (gpointer
) in_trace
);
547 struct trace_ir_data_maps
*trace_ir_data_maps_create(struct trace_ir_maps
*ir_maps
,
548 const bt_trace
*in_trace
)
550 bt_self_component
*self_comp
= ir_maps
->self_comp
;
551 bt_trace_add_listener_status add_listener_status
;
552 struct trace_ir_data_maps
*d_maps
= g_new0(struct trace_ir_data_maps
, 1);
555 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
556 "Error allocating trace_ir_maps");
560 d_maps
->log_level
= ir_maps
->log_level
;
561 d_maps
->self_comp
= ir_maps
->self_comp
;
562 d_maps
->input_trace
= in_trace
;
564 /* Create the hashtables used to map data objects. */
565 d_maps
->stream_map
= g_hash_table_new_full(g_direct_hash
,
566 g_direct_equal
, NULL
,(GDestroyNotify
) bt_stream_put_ref
);
567 d_maps
->packet_map
= g_hash_table_new_full(g_direct_hash
,
568 g_direct_equal
, NULL
,(GDestroyNotify
) bt_packet_put_ref
);
570 add_listener_status
= bt_trace_add_destruction_listener(
571 in_trace
, trace_ir_data_maps_remove_func
,
572 ir_maps
, &d_maps
->destruction_listener_id
);
573 BT_ASSERT(add_listener_status
== BT_TRACE_ADD_LISTENER_STATUS_OK
);
579 struct trace_ir_metadata_maps
*trace_ir_metadata_maps_create(
580 struct trace_ir_maps
*ir_maps
,
581 const bt_trace_class
*in_trace_class
)
583 bt_self_component
*self_comp
= ir_maps
->self_comp
;
584 bt_trace_class_add_listener_status add_listener_status
;
585 struct trace_ir_metadata_maps
*md_maps
=
586 g_new0(struct trace_ir_metadata_maps
, 1);
589 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
590 "Error allocating trace_ir_maps");
594 md_maps
->log_level
= ir_maps
->log_level
;
595 md_maps
->self_comp
= ir_maps
->self_comp
;
596 md_maps
->input_trace_class
= in_trace_class
;
598 * Create the field class resolving context. This is needed to keep
599 * track of the field class already copied in order to do the field
600 * path resolution correctly.
602 md_maps
->fc_resolving_ctx
=
603 g_new0(struct field_class_resolving_context
, 1);
604 if (!md_maps
->fc_resolving_ctx
) {
605 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
606 "Error allocating field_class_resolving_context");
610 /* Create the hashtables used to map metadata objects. */
611 md_maps
->stream_class_map
= g_hash_table_new_full(g_direct_hash
,
612 g_direct_equal
, NULL
, (GDestroyNotify
) bt_stream_class_put_ref
);
613 md_maps
->event_class_map
= g_hash_table_new_full(g_direct_hash
,
614 g_direct_equal
, NULL
, (GDestroyNotify
) bt_event_class_put_ref
);
615 md_maps
->field_class_map
= g_hash_table_new_full(g_direct_hash
,
616 g_direct_equal
, NULL
, (GDestroyNotify
) bt_field_class_put_ref
);
617 md_maps
->clock_class_map
= g_hash_table_new_full(g_direct_hash
,
618 g_direct_equal
, NULL
, (GDestroyNotify
) bt_clock_class_put_ref
);
620 add_listener_status
= bt_trace_class_add_destruction_listener(
621 in_trace_class
, trace_ir_metadata_maps_remove_func
,
622 ir_maps
, &md_maps
->destruction_listener_id
);
623 BT_ASSERT(add_listener_status
== BT_TRACE_CLASS_ADD_LISTENER_STATUS_OK
);
630 void trace_ir_data_maps_destroy(struct trace_ir_data_maps
*maps
)
632 bt_trace_remove_listener_status status
;
638 if (maps
->packet_map
) {
639 g_hash_table_destroy(maps
->packet_map
);
642 if (maps
->stream_map
) {
643 g_hash_table_destroy(maps
->stream_map
);
646 if (maps
->output_trace
) {
647 bt_trace_put_ref(maps
->output_trace
);
650 status
= bt_trace_remove_destruction_listener(maps
->input_trace
,
651 maps
->destruction_listener_id
);
652 if (status
!= BT_TRACE_REMOVE_LISTENER_STATUS_OK
) {
653 BT_COMP_LOG_CUR_LVL(BT_LOG_DEBUG
, maps
->log_level
,
655 "Trace destruction listener removal failed.");
656 bt_current_thread_clear_error();
663 void trace_ir_metadata_maps_destroy(struct trace_ir_metadata_maps
*maps
)
665 bt_trace_class_remove_listener_status status
;
671 if (maps
->stream_class_map
) {
672 g_hash_table_destroy(maps
->stream_class_map
);
675 if (maps
->event_class_map
) {
676 g_hash_table_destroy(maps
->event_class_map
);
679 if (maps
->field_class_map
) {
680 g_hash_table_destroy(maps
->field_class_map
);
683 if (maps
->clock_class_map
) {
684 g_hash_table_destroy(maps
->clock_class_map
);
687 g_free(maps
->fc_resolving_ctx
);
689 if (maps
->output_trace_class
) {
690 bt_trace_class_put_ref(maps
->output_trace_class
);
693 status
= bt_trace_class_remove_destruction_listener(
694 maps
->input_trace_class
, maps
->destruction_listener_id
);
695 if (status
!= BT_TRACE_CLASS_REMOVE_LISTENER_STATUS_OK
) {
696 BT_COMP_LOG_CUR_LVL(BT_LOG_DEBUG
, maps
->log_level
,
698 "Trace destruction listener removal failed.");
699 bt_current_thread_clear_error();
705 void trace_ir_maps_clear(struct trace_ir_maps
*maps
)
707 if (maps
->data_maps
) {
708 g_hash_table_remove_all(maps
->data_maps
);
711 if (maps
->metadata_maps
) {
712 g_hash_table_remove_all(maps
->metadata_maps
);
717 void trace_ir_maps_destroy(struct trace_ir_maps
*maps
)
723 g_free(maps
->debug_info_field_class_name
);
725 if (maps
->data_maps
) {
726 g_hash_table_destroy(maps
->data_maps
);
727 maps
->data_maps
= NULL
;
730 if (maps
->metadata_maps
) {
731 g_hash_table_destroy(maps
->metadata_maps
);
732 maps
->metadata_maps
= NULL
;
739 struct trace_ir_maps
*trace_ir_maps_create(bt_self_component
*self_comp
,
740 const char *debug_info_field_name
, bt_logging_level log_level
)
742 struct trace_ir_maps
*ir_maps
= g_new0(struct trace_ir_maps
, 1);
744 BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR
, log_level
, self_comp
,
745 "Error allocating trace_ir_maps");
749 ir_maps
->log_level
= log_level
;
750 ir_maps
->self_comp
= self_comp
;
752 /* Copy debug info field name received from the user. */
753 ir_maps
->debug_info_field_class_name
= g_strdup(debug_info_field_name
);
754 if (!ir_maps
->debug_info_field_class_name
) {
755 BT_COMP_LOGE_APPEND_CAUSE(self_comp
,
756 "Cannot copy debug info field name");
760 ir_maps
->self_comp
= self_comp
;
762 ir_maps
->data_maps
= g_hash_table_new_full(g_direct_hash
,
763 g_direct_equal
, (GDestroyNotify
) NULL
,
764 (GDestroyNotify
) trace_ir_data_maps_destroy
);
766 ir_maps
->metadata_maps
= g_hash_table_new_full(g_direct_hash
,
767 g_direct_equal
, (GDestroyNotify
) NULL
,
768 (GDestroyNotify
) trace_ir_metadata_maps_destroy
);
772 trace_ir_maps_destroy(ir_maps
);