flt.lttng-utils.debug-info: honor component's initial log level
[babeltrace.git] / src / plugins / lttng-utils / debug-info / trace-ir-mapping.c
CommitLineData
ca9f27f3
FD
1/*
2 * Babeltrace - Mapping of IR metadata and data object between input and output
3 * trace
4 *
5 * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
6 * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
7 * Copyright (c) 2019 Francis Deslauriers <francis.deslauriers@efficios.com>
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 */
27
3a3d15f3 28#define BT_LOG_OUTPUT_LEVEL (ir_maps->log_level)
350ad6c1 29#define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-MAPPING"
3a3d15f3 30#include "logging/log.h"
ca9f27f3
FD
31
32#include <stdbool.h>
33
578e048b 34#include "common/assert.h"
3fadfbc0 35#include <babeltrace2/babeltrace.h>
ca9f27f3 36/* For bt_property_availability */
3fadfbc0 37#include <babeltrace2/property.h>
ca9f27f3
FD
38
39#include "debug-info.h"
40#include "trace-ir-data-copy.h"
41#include "trace-ir-mapping.h"
42#include "trace-ir-metadata-copy.h"
43
44static
45bt_trace_class *create_new_mapped_trace_class(struct trace_ir_maps *ir_maps,
46 const bt_trace_class *in_trace_class)
47{
48 int ret;
49 bt_trace_class *out_trace_class;
50
51 BT_LOGD("Creating new mapped trace class: in-tc-addr=%p", in_trace_class);
52
53 BT_ASSERT(ir_maps);
54 BT_ASSERT(in_trace_class);
55
56 /* Create the ouput trace class. */
57 out_trace_class = bt_trace_class_create(ir_maps->self_comp);
58 if (!out_trace_class) {
59 BT_LOGE_STR("Error create output trace class");
60 goto end;
61 }
62
63 /* If not, create a new one and add it to the mapping. */
3a3d15f3
PP
64 ret = copy_trace_class_content(in_trace_class, out_trace_class,
65 ir_maps->log_level);
ca9f27f3
FD
66 if (ret) {
67 BT_LOGE_STR("Error copy content to output trace class");
68 out_trace_class = NULL;
69 goto end;
70 }
71
72 BT_LOGD("Created new mapped trace class: in-tc-addr=%p, out-tc-addr=%p",
73 in_trace_class, out_trace_class);
74
75end:
76 return out_trace_class;
77}
78
79static
80bt_trace *create_new_mapped_trace(struct trace_ir_maps *ir_maps,
81 const bt_trace *in_trace)
82{
83 bt_trace *out_trace;
84 const bt_trace_class *in_trace_class;
85 struct trace_ir_metadata_maps *metadata_maps;
86
87 BT_LOGD("Creating new mapped trace: in-t-addr=%p", in_trace);
88 BT_ASSERT(ir_maps);
89 BT_ASSERT(in_trace);
90
91 in_trace_class = bt_trace_borrow_class_const(in_trace);
92 metadata_maps = borrow_metadata_maps_from_input_trace_class(ir_maps,
93 in_trace_class);
94
95 if (!metadata_maps->output_trace_class) {
96 metadata_maps->output_trace_class =
97 create_new_mapped_trace_class(ir_maps, in_trace_class);
98 if (!metadata_maps->output_trace_class) {
99 out_trace = NULL;
100 goto end;
101 }
102 }
103
104 out_trace = bt_trace_create(metadata_maps->output_trace_class);
105 if (!out_trace) {
106 BT_LOGE_STR("Error create output trace");
107 goto end;
108 }
109
110 /* If not, create a new one and add it to the mapping. */
3a3d15f3 111 copy_trace_content(in_trace, out_trace, ir_maps->log_level);
ca9f27f3
FD
112
113 BT_LOGD("Created new mapped trace: in-t-addr=%p, out-t-addr=%p",
114 in_trace, out_trace);
115end:
116 return out_trace;
117}
118
119static
120bt_stream_class *borrow_mapped_stream_class(struct trace_ir_metadata_maps *md_maps,
121 const bt_stream_class *in_stream_class)
122{
123 BT_ASSERT(md_maps);
124 BT_ASSERT(in_stream_class);
125
126 return g_hash_table_lookup(md_maps->stream_class_map,
127 (gpointer) in_stream_class);
128}
129
130static
131bt_stream_class *create_new_mapped_stream_class(struct trace_ir_maps *ir_maps,
132 const bt_stream_class *in_stream_class)
133{
134 int ret;
135 bt_stream_class *out_stream_class;
136 struct trace_ir_metadata_maps *md_maps;
137
138 BT_LOGD("Creating new mapped stream class: in-sc-addr=%p",
139 in_stream_class);
140
141 md_maps = borrow_metadata_maps_from_input_stream_class(ir_maps,
142 in_stream_class);
143
144 BT_ASSERT(md_maps);
145 BT_ASSERT(in_stream_class);
146 BT_ASSERT(!borrow_mapped_stream_class(md_maps, in_stream_class));
147
148 /* Create an out_stream_class. */
149 out_stream_class = bt_stream_class_create_with_id(
150 md_maps->output_trace_class,
151 bt_stream_class_get_id(in_stream_class));
152 if (!out_stream_class) {
153 BT_LOGE_STR("Error create output stream class");
154 goto end;
155 }
156
157 /* If not, create a new one and add it to the mapping. */
158 ret = copy_stream_class_content(ir_maps, in_stream_class,
159 out_stream_class);
160 if (ret) {
161 BT_LOGE_STR("Error copy content to output stream class");
162 out_stream_class = NULL;
163 goto end;
164 }
165
166 g_hash_table_insert(md_maps->stream_class_map,
167 (gpointer) in_stream_class, out_stream_class);
168
169 BT_LOGD("Created new mapped stream class: in-sc-addr=%p, out-sc-addr=%p",
170 in_stream_class, out_stream_class);
171
172end:
173 return out_stream_class;
174}
175
176static
177bt_stream *borrow_mapped_stream(struct trace_ir_data_maps *d_maps,
178 const bt_stream *in_stream)
179{
180 BT_ASSERT(d_maps);
181 BT_ASSERT(in_stream);
182
183 return g_hash_table_lookup(d_maps->stream_map, (gpointer) in_stream);
184}
185
186BT_HIDDEN
187bt_stream *trace_ir_mapping_create_new_mapped_stream(
188 struct trace_ir_maps *ir_maps,
189 const bt_stream *in_stream)
190{
191 struct trace_ir_data_maps *d_maps;
192 struct trace_ir_metadata_maps *md_maps;
193 const bt_stream_class *in_stream_class;
194 const bt_trace *in_trace;
195 bt_stream_class *out_stream_class;
196 bt_stream *out_stream = NULL;
197
ca9f27f3
FD
198 BT_ASSERT(ir_maps);
199 BT_ASSERT(in_stream);
3a3d15f3 200 BT_LOGD("Creating new mapped stream: in-s-addr=%p", in_stream);
ca9f27f3
FD
201
202 in_trace = bt_stream_borrow_trace_const(in_stream);
203
204 d_maps = borrow_data_maps_from_input_trace(ir_maps, in_trace);
205 if (!d_maps->output_trace) {
206 d_maps->output_trace = create_new_mapped_trace(ir_maps, in_trace);
207 if (!d_maps->output_trace) {
208 goto end;
209 }
210 }
211
212 BT_ASSERT(d_maps->output_trace);
213 BT_ASSERT(!borrow_mapped_stream(d_maps, in_stream));
214
215 in_stream_class = bt_stream_borrow_class_const(in_stream);
ca9f27f3
FD
216 md_maps = borrow_metadata_maps_from_input_stream_class(ir_maps, in_stream_class);
217 out_stream_class = borrow_mapped_stream_class(md_maps, in_stream_class);
218 if (!out_stream_class) {
219 out_stream_class = create_new_mapped_stream_class(ir_maps,
220 in_stream_class);
221 if (!out_stream_class) {
222 goto end;
223 }
224 }
225 BT_ASSERT(out_stream_class);
226
227 out_stream = bt_stream_create_with_id(out_stream_class,
228 d_maps->output_trace, bt_stream_get_id(in_stream));
229 if (!out_stream) {
230 BT_LOGE_STR("Error creating output stream");
231 goto end;
232 }
233 /*
234 * Release our ref since the trace object will be managing the life
235 * time of the stream objects.
236 */
237
3a3d15f3 238 copy_stream_content(in_stream, out_stream, ir_maps->log_level);
ca9f27f3
FD
239
240 g_hash_table_insert(d_maps->stream_map, (gpointer) in_stream,
241 out_stream);
242
243 BT_LOGD("Created new mapped stream: in-s-addr=%p, out-s-addr=%p",
244 in_stream, out_stream);
245
246end:
247 return out_stream;
248}
249
250BT_HIDDEN
251bt_stream *trace_ir_mapping_borrow_mapped_stream(struct trace_ir_maps *ir_maps,
252 const bt_stream *in_stream)
253{
254 BT_ASSERT(ir_maps);
255 BT_ASSERT(in_stream);
256 struct trace_ir_data_maps *d_maps;
257
258 d_maps = borrow_data_maps_from_input_stream(ir_maps, in_stream);
259 /* Return the mapped stream. */
260 return borrow_mapped_stream(d_maps, in_stream);
261}
262
263static inline
264bt_event_class *borrow_mapped_event_class(struct trace_ir_metadata_maps *md_maps,
265 const bt_event_class *in_event_class)
266{
267 return g_hash_table_lookup(md_maps->event_class_map,
268 (gpointer) in_event_class);
269}
270
271BT_HIDDEN
272bt_event_class *trace_ir_mapping_create_new_mapped_event_class(
273 struct trace_ir_maps *ir_maps,
274 const bt_event_class *in_event_class)
275{
276 bt_event_class *out_event_class;
277 const bt_trace_class *in_trace_class;
278 const bt_stream_class *in_stream_class;
279 bt_stream_class *out_stream_class;
280 struct trace_ir_metadata_maps *md_maps;
281 int ret;
282
ca9f27f3
FD
283 BT_ASSERT(ir_maps);
284 BT_ASSERT(in_event_class);
3a3d15f3
PP
285 BT_LOGD("Creating new mapped event class: in-ec-addr=%p",
286 in_event_class);
ca9f27f3
FD
287
288 in_trace_class = bt_stream_class_borrow_trace_class_const(
289 bt_event_class_borrow_stream_class_const(
290 in_event_class));
291
292 md_maps = borrow_metadata_maps_from_input_trace_class(ir_maps, in_trace_class);
293
294 BT_ASSERT(!borrow_mapped_event_class(md_maps, in_event_class));
295
296 in_stream_class =
297 bt_event_class_borrow_stream_class_const(in_event_class);
298 BT_ASSERT(in_stream_class);
299
300 /* Get the right output stream class to add the new event class to. */
301 out_stream_class = borrow_mapped_stream_class(md_maps, in_stream_class);
302 BT_ASSERT(out_stream_class);
303
304 /* Create an output event class. */
305 out_event_class = bt_event_class_create_with_id(out_stream_class,
306 bt_event_class_get_id(in_event_class));
307 if (!out_event_class) {
308 BT_LOGE_STR("Error creating output event class");
309 goto end;
310 }
311
312 /* If not, create a new one and add it to the mapping. */
313 ret = copy_event_class_content(ir_maps, in_event_class,
314 out_event_class);
315 if (ret) {
316 BT_LOGE_STR("Error copy content to output event class");
317 out_event_class = NULL;
318 goto end;
319 }
320
321 g_hash_table_insert(md_maps->event_class_map,
322 (gpointer) in_event_class, out_event_class);
323
324 BT_LOGD("Created new mapped event class: in-ec-addr=%p, out-ec-addr=%p",
325 in_event_class, out_event_class);
326
327end:
328 return out_event_class;
329}
330
331BT_HIDDEN
332bt_event_class *trace_ir_mapping_borrow_mapped_event_class(
333 struct trace_ir_maps *ir_maps,
334 const bt_event_class *in_event_class)
335{
336 struct trace_ir_metadata_maps *md_maps;
337
338 BT_ASSERT(ir_maps);
339 BT_ASSERT(in_event_class);
340
341 md_maps = borrow_metadata_maps_from_input_event_class(ir_maps, in_event_class);
342
343 /* Return the mapped event_class. */
344 return borrow_mapped_event_class(md_maps, in_event_class);
345}
346
347static inline
348bt_packet *borrow_mapped_packet(struct trace_ir_data_maps *d_maps,
349 const bt_packet *in_packet)
350{
351 BT_ASSERT(d_maps);
352 BT_ASSERT(in_packet);
353
354 return g_hash_table_lookup(d_maps->packet_map,
355 (gpointer) in_packet);
356}
357
358BT_HIDDEN
359bt_packet *trace_ir_mapping_create_new_mapped_packet(
360 struct trace_ir_maps *ir_maps,
361 const bt_packet *in_packet)
362{
363 struct trace_ir_data_maps *d_maps;
364 const bt_trace *in_trace;
365 const bt_stream *in_stream;
366 bt_packet *out_packet;
367 bt_stream *out_stream;
368
369 BT_LOGD("Creating new mapped packet: in-p-addr=%p", in_packet);
370
371 in_stream = bt_packet_borrow_stream_const(in_packet);
372 in_trace = bt_stream_borrow_trace_const(in_stream);
373 d_maps = borrow_data_maps_from_input_trace(ir_maps, in_trace);
374
375 /* There should never be a mapped packet. */
376 BT_ASSERT(!borrow_mapped_packet(d_maps, in_packet));
377
378 BT_ASSERT(in_stream);
379
380 /* Get output stream corresponding to this input stream. */
381 out_stream = borrow_mapped_stream(d_maps, in_stream);
382 BT_ASSERT(out_stream);
383
384 /* Create the output packet. */
385 out_packet = bt_packet_create(out_stream);
386 if (!out_packet) {
387 BT_LOGE_STR("Error create output packet");
388 goto end;
389 }
390
391 /*
392 * Release our ref since the stream object will be managing the life
393 * time of the packet objects.
394 */
3a3d15f3 395 copy_packet_content(in_packet, out_packet, ir_maps->log_level);
ca9f27f3
FD
396
397 g_hash_table_insert(d_maps->packet_map,
398 (gpointer) in_packet, out_packet);
399
400 BT_LOGD("Created new mapped packet: in-p-addr=%p, out-p-addr=%p",
401 in_packet, out_packet);
402
403end:
404 return out_packet;
405}
406
407BT_HIDDEN
408bt_packet *trace_ir_mapping_borrow_mapped_packet(struct trace_ir_maps *ir_maps,
409 const bt_packet *in_packet)
410{
411 struct trace_ir_data_maps *d_maps;
412 BT_ASSERT(ir_maps);
413 BT_ASSERT(in_packet);
414
415 d_maps = borrow_data_maps_from_input_packet(ir_maps, in_packet);
416
417 return borrow_mapped_packet(d_maps, in_packet);
418}
419
420BT_HIDDEN
421void trace_ir_mapping_remove_mapped_packet(struct trace_ir_maps *ir_maps,
422 const bt_packet *in_packet)
423{
424 gboolean ret;
425
426 struct trace_ir_data_maps *d_maps;
427 BT_ASSERT(ir_maps);
428 BT_ASSERT(in_packet);
429
430 d_maps = borrow_data_maps_from_input_packet(ir_maps, in_packet);
431
432 ret = g_hash_table_remove(d_maps->packet_map, in_packet);
433
434 BT_ASSERT(ret);
435}
436
437BT_HIDDEN
438void trace_ir_mapping_remove_mapped_stream(struct trace_ir_maps *ir_maps,
439 const bt_stream *in_stream)
440{
441 gboolean ret;
442 struct trace_ir_data_maps *d_maps;
443
444 BT_ASSERT(ir_maps);
445 BT_ASSERT(in_stream);
446
447 d_maps = borrow_data_maps_from_input_stream(ir_maps, in_stream);
448
449 ret = g_hash_table_remove(d_maps->stream_map, in_stream);
450
451 BT_ASSERT(ret);
452}
453
454static
455void trace_ir_metadata_maps_remove_func(const bt_trace_class *in_trace_class,
456 void *data)
457{
458 struct trace_ir_maps *maps = (struct trace_ir_maps *) data;
459 if (maps->metadata_maps) {
460 gboolean ret;
461 ret = g_hash_table_remove(maps->metadata_maps,
462 (gpointer) in_trace_class);
463 BT_ASSERT(ret);
464 }
465}
466
467static
468void trace_ir_data_maps_remove_func(const bt_trace *in_trace, void *data)
469{
470 struct trace_ir_maps *maps = (struct trace_ir_maps *) data;
471 if (maps->data_maps) {
472 gboolean ret;
473 ret = g_hash_table_remove(maps->data_maps, (gpointer) in_trace);
474 BT_ASSERT(ret);
475 }
476}
477
478struct trace_ir_data_maps *trace_ir_data_maps_create(struct trace_ir_maps *ir_maps,
479 const bt_trace *in_trace)
480{
481 struct trace_ir_data_maps *d_maps =
482 g_new0(struct trace_ir_data_maps, 1);
483 if (!d_maps) {
484 BT_LOGE_STR("Error allocating trace_ir_maps");
485 goto error;
486 }
487
3a3d15f3 488 d_maps->log_level = ir_maps->log_level;
ca9f27f3
FD
489 d_maps->input_trace = in_trace;
490
491 /* Create the hashtables used to map data objects. */
492 d_maps->stream_map = g_hash_table_new_full(g_direct_hash,
493 g_direct_equal, NULL,(GDestroyNotify) bt_stream_put_ref);
494 d_maps->packet_map = g_hash_table_new_full(g_direct_hash,
495 g_direct_equal, NULL,(GDestroyNotify) bt_packet_put_ref);
496
497 bt_trace_add_destruction_listener(in_trace, trace_ir_data_maps_remove_func,
498 ir_maps, &d_maps->destruction_listener_id);
499error:
500 return d_maps;
501}
502
503struct trace_ir_metadata_maps *trace_ir_metadata_maps_create(
504 struct trace_ir_maps *ir_maps,
505 const bt_trace_class *in_trace_class)
506{
507 struct trace_ir_metadata_maps *md_maps =
508 g_new0(struct trace_ir_metadata_maps, 1);
509 if (!md_maps) {
510 BT_LOGE_STR("Error allocating trace_ir_maps");
511 goto error;
512 }
513
3a3d15f3 514 md_maps->log_level = ir_maps->log_level;
ca9f27f3
FD
515 md_maps->input_trace_class = in_trace_class;
516 /*
517 * Create the field class resolving context. This is needed to keep
518 * track of the field class already copied in order to do the field
519 * path resolution correctly.
520 */
521 md_maps->fc_resolving_ctx =
522 g_new0(struct field_class_resolving_context, 1);
523 if (!md_maps->fc_resolving_ctx) {
524 BT_LOGE_STR("Error allocating field_class_resolving_context");
525 goto error;
526 }
527
528 /* Create the hashtables used to map metadata objects. */
529 md_maps->stream_class_map = g_hash_table_new_full(g_direct_hash,
530 g_direct_equal, NULL, (GDestroyNotify) bt_stream_class_put_ref);
531 md_maps->event_class_map = g_hash_table_new_full(g_direct_hash,
532 g_direct_equal, NULL, (GDestroyNotify) bt_event_class_put_ref);
533 md_maps->field_class_map = g_hash_table_new_full(g_direct_hash,
534 g_direct_equal, NULL, (GDestroyNotify) bt_field_class_put_ref);
535 md_maps->clock_class_map = g_hash_table_new_full(g_direct_hash,
536 g_direct_equal, NULL, (GDestroyNotify) bt_clock_class_put_ref);
537
538 bt_trace_class_add_destruction_listener(in_trace_class,
539 trace_ir_metadata_maps_remove_func,
540 ir_maps, &md_maps->destruction_listener_id);
541error:
542 return md_maps;
543}
544
545BT_HIDDEN
546void trace_ir_data_maps_destroy(struct trace_ir_data_maps *maps)
547{
548 bt_trace_status status;
549 if (!maps) {
550 return;
551 }
552
553 if (maps->packet_map) {
554 g_hash_table_destroy(maps->packet_map);
555 }
556
557 if (maps->stream_map) {
558 g_hash_table_destroy(maps->stream_map);
559 }
560
561 if (maps->output_trace) {
562 bt_trace_put_ref(maps->output_trace);
563 }
564
565 status = bt_trace_remove_destruction_listener(maps->input_trace,
566 maps->destruction_listener_id);
3b40fbf9 567 if (status != BT_TRACE_STATUS_OK) {
3a3d15f3
PP
568 BT_LOG_WRITE_CUR_LVL(BT_LOG_DEBUG, maps->log_level,
569 BT_LOG_TAG,
570 "Trace destruction listener removal failed.");
3b40fbf9 571 }
ca9f27f3
FD
572
573 g_free(maps);
574}
575
576BT_HIDDEN
577void trace_ir_metadata_maps_destroy(struct trace_ir_metadata_maps *maps)
578{
579 bt_trace_class_status status;
580 if (!maps) {
581 return;
582 }
583
584 if (maps->stream_class_map) {
585 g_hash_table_destroy(maps->stream_class_map);
586 }
587
588 if (maps->event_class_map) {
589 g_hash_table_destroy(maps->event_class_map);
590 }
591
592 if (maps->field_class_map) {
593 g_hash_table_destroy(maps->field_class_map);
594 }
595
596 if (maps->clock_class_map) {
597 g_hash_table_destroy(maps->clock_class_map);
598 }
599
600 if (maps->fc_resolving_ctx) {
601 g_free(maps->fc_resolving_ctx);
602 }
603
604 if (maps->output_trace_class) {
605 bt_trace_class_put_ref(maps->output_trace_class);
606 }
607
608 status = bt_trace_class_remove_destruction_listener(maps->input_trace_class,
609 maps->destruction_listener_id);
3b40fbf9 610 if (status != BT_TRACE_CLASS_STATUS_OK) {
3a3d15f3
PP
611 BT_LOG_WRITE_CUR_LVL(BT_LOG_DEBUG, maps->log_level, BT_LOG_TAG,
612 "Trace destruction listener removal failed.");
3b40fbf9 613 }
ca9f27f3
FD
614
615 g_free(maps);
616}
617
618void trace_ir_maps_clear(struct trace_ir_maps *maps)
619{
620 if (maps->data_maps) {
621 g_hash_table_remove_all(maps->data_maps);
622 }
623
624 if (maps->metadata_maps) {
625 g_hash_table_remove_all(maps->metadata_maps);
626 }
627}
628
629BT_HIDDEN
630void trace_ir_maps_destroy(struct trace_ir_maps *maps)
631{
632 if (!maps) {
633 return;
634 }
635
636 if (maps->debug_info_field_class_name) {
637 g_free(maps->debug_info_field_class_name);
638 }
639
640 if (maps->data_maps) {
641 g_hash_table_destroy(maps->data_maps);
642 maps->data_maps = NULL;
643 }
644
645 if (maps->metadata_maps) {
646 g_hash_table_destroy(maps->metadata_maps);
647 maps->metadata_maps = NULL;
648 }
649
650 g_free(maps);
651}
652
653BT_HIDDEN
654struct trace_ir_maps *trace_ir_maps_create(bt_self_component *self_comp,
3a3d15f3 655 const char *debug_info_field_name, bt_logging_level log_level)
ca9f27f3 656{
3a3d15f3 657 struct trace_ir_maps *ir_maps =
ca9f27f3 658 g_new0(struct trace_ir_maps, 1);
3a3d15f3
PP
659 if (!ir_maps) {
660 BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
661 "Error allocating trace_ir_maps");
ca9f27f3
FD
662 goto error;
663 }
664
3a3d15f3
PP
665 ir_maps->log_level = log_level;
666
ca9f27f3 667 /* Copy debug info field name received from the user. */
3a3d15f3 668 ir_maps->debug_info_field_class_name =
ca9f27f3 669 g_strdup(debug_info_field_name);
3a3d15f3 670 if (!ir_maps->debug_info_field_class_name) {
ca9f27f3
FD
671 BT_LOGE_STR("Cannot copy debug info field name");
672 goto error;
673 }
674
3a3d15f3 675 ir_maps->self_comp = self_comp;
ca9f27f3 676
3a3d15f3 677 ir_maps->data_maps = g_hash_table_new_full(g_direct_hash,
ca9f27f3
FD
678 g_direct_equal, (GDestroyNotify) NULL,
679 (GDestroyNotify) trace_ir_data_maps_destroy);
680
3a3d15f3 681 ir_maps->metadata_maps = g_hash_table_new_full(g_direct_hash,
ca9f27f3
FD
682 g_direct_equal, (GDestroyNotify) NULL,
683 (GDestroyNotify) trace_ir_metadata_maps_destroy);
684
685 goto end;
686error:
3a3d15f3
PP
687 trace_ir_maps_destroy(ir_maps);
688 ir_maps = NULL;
ca9f27f3 689end:
3a3d15f3 690 return ir_maps;
ca9f27f3 691}
This page took 0.054171 seconds and 4 git commands to generate.