cpp-common/bt2c/fmt.hpp: use `wise_enum::string_type` in `EnableIfIsWiseEnum` definition
[babeltrace.git] / src / lib / error.c
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (c) 2019 Philippe Proulx <pproulx@efficios.com>
5 */
6
7 #define BT_LOG_TAG "LIB/ERROR"
8 #include "lib/logging.h"
9
10 #include <stdlib.h>
11 #include <stdint.h>
12 #include <babeltrace2/babeltrace.h>
13
14 #include "error.h"
15 #include "graph/component.h"
16 #include "graph/component-class.h"
17 #include "graph/iterator.h"
18 #include "common/assert.h"
19 #include "common/common.h"
20 #include "lib/assert-cond.h"
21 #include "lib/func-status.h"
22
23 #define BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(_cause, _exp_type_name, _exp_type) \
24 BT_ASSERT_PRE("error-cause-has-" _exp_type_name "-actor", \
25 ((const struct bt_error_cause *) (_cause))->actor_type == _exp_type, \
26 "Unexpected error cause's actor type: type=%s, exp-type=%s", \
27 bt_error_cause_actor_type_string(((const struct bt_error_cause *) (_cause))->actor_type), \
28 bt_error_cause_actor_type_string(_exp_type))
29
30 static
31 void fini_component_class_id(
32 struct bt_error_cause_component_class_id *comp_class_id)
33 {
34 BT_ASSERT(comp_class_id);
35
36 if (comp_class_id->name) {
37 g_string_free(comp_class_id->name, TRUE);
38 comp_class_id->name = NULL;
39 }
40
41 if (comp_class_id->plugin_name) {
42 g_string_free(comp_class_id->plugin_name, TRUE);
43 comp_class_id->plugin_name = NULL;
44 }
45 }
46
47 static
48 void fini_error_cause(struct bt_error_cause *cause)
49 {
50 BT_ASSERT(cause);
51 BT_LIB_LOGD("Finalizing error cause: %!+r", cause);
52
53 if (cause->module_name) {
54 g_string_free(cause->module_name, TRUE);
55 cause->module_name = NULL;
56 }
57
58 if (cause->file_name) {
59 g_string_free(cause->file_name, TRUE);
60 cause->file_name = NULL;
61 }
62
63 if (cause->message) {
64 g_string_free(cause->message, TRUE);
65 cause->message = NULL;
66 }
67 }
68
69 static
70 void destroy_error_cause(struct bt_error_cause *cause)
71 {
72 if (!cause) {
73 goto end;
74 }
75
76 BT_LIB_LOGD("Destroying error cause: %!+r", cause);
77
78 switch (cause->actor_type) {
79 case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT:
80 {
81 struct bt_error_cause_component_actor *spec_cause =
82 (void *) cause;
83
84 if (spec_cause->comp_name) {
85 g_string_free(spec_cause->comp_name, TRUE);
86 spec_cause->comp_name = NULL;
87 }
88
89 fini_component_class_id(&spec_cause->comp_class_id);
90 break;
91 }
92 case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS:
93 {
94 struct bt_error_cause_component_class_actor *spec_cause =
95 (void *) cause;
96
97 fini_component_class_id(&spec_cause->comp_class_id);
98 break;
99 }
100 case BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR:
101 {
102 struct bt_error_cause_message_iterator_actor *spec_cause =
103 (void *) cause;
104
105 if (spec_cause->comp_name) {
106 g_string_free(spec_cause->comp_name, TRUE);
107 spec_cause->comp_name = NULL;
108 }
109
110 if (spec_cause->output_port_name) {
111 g_string_free(spec_cause->output_port_name, TRUE);
112 spec_cause->output_port_name = NULL;
113 }
114
115 fini_component_class_id(&spec_cause->comp_class_id);
116 break;
117 }
118 default:
119 break;
120 }
121
122 fini_error_cause(cause);
123 g_free(cause);
124
125 end:
126 return;
127 }
128
129 static
130 int init_error_cause(struct bt_error_cause *cause,
131 enum bt_error_cause_actor_type actor_type)
132 {
133 int ret = 0;
134
135 BT_ASSERT(cause);
136 BT_LIB_LOGD("Initializing error cause: %!+r", cause);
137 cause->actor_type = actor_type;
138 cause->module_name = g_string_new(NULL);
139 if (!cause->module_name) {
140 BT_LOGE_STR("Failed to allocate one GString.");
141 ret = -1;
142 goto end;
143 }
144
145 cause->message = g_string_new(NULL);
146 if (!cause->message) {
147 BT_LOGE_STR("Failed to allocate one GString.");
148 ret = -1;
149 goto end;
150 }
151
152 cause->file_name = g_string_new(NULL);
153 if (!cause->file_name) {
154 BT_LOGE_STR("Failed to allocate one GString.");
155 ret = -1;
156 goto end;
157 }
158
159 end:
160 return ret;
161 }
162
163 static
164 int init_component_class_id(
165 struct bt_error_cause_component_class_id *comp_class_id,
166 struct bt_component_class *comp_cls)
167 {
168 int ret = 0;
169
170 BT_ASSERT(comp_class_id);
171 comp_class_id->type = comp_cls->type;
172 comp_class_id->name = g_string_new(comp_cls->name->str);
173 if (!comp_class_id->name) {
174 BT_LOGE_STR("Failed to allocate one GString.");
175 ret = -1;
176 goto end;
177 }
178
179 comp_class_id->plugin_name = g_string_new(comp_cls->plugin_name->str);
180 if (!comp_class_id->plugin_name) {
181 BT_LOGE_STR("Failed to allocate one GString.");
182 ret = -1;
183 goto end;
184 }
185
186 end:
187 return ret;
188 }
189
190 static
191 void set_error_cause_props(struct bt_error_cause *cause,
192 const char *file_name, uint64_t line_no)
193 {
194 BT_ASSERT(cause);
195 g_string_assign(cause->file_name, file_name);
196 cause->line_no = line_no;
197 }
198
199 static
200 struct bt_error_cause *create_error_cause(const char *module_name,
201 const char *file_name, uint64_t line_no)
202 {
203 struct bt_error_cause *cause = g_new0(struct bt_error_cause, 1);
204 int ret;
205
206 BT_LOGD_STR("Creating error cause (unknown actor).");
207
208 if (!cause) {
209 BT_LOGE_STR("Failed to allocate one error cause.");
210 goto error;
211 }
212
213 ret = init_error_cause(cause, BT_ERROR_CAUSE_ACTOR_TYPE_UNKNOWN);
214 if (ret) {
215 goto error;
216 }
217
218 g_string_assign(cause->module_name, module_name);
219 set_error_cause_props(cause, file_name, line_no);
220 BT_LIB_LOGD("Created error cause: %!+r", cause);
221 goto end;
222
223 error:
224 destroy_error_cause(cause);
225 cause = NULL;
226
227 end:
228 return cause;
229 }
230
231 static
232 void append_component_class_id_str(GString *str,
233 struct bt_error_cause_component_class_id *comp_class_id)
234 {
235 const char *type_str = NULL;
236
237 switch (comp_class_id->type) {
238 case BT_COMPONENT_CLASS_TYPE_SOURCE:
239 type_str = "src";
240 break;
241 case BT_COMPONENT_CLASS_TYPE_FILTER:
242 type_str = "flt";
243 break;
244 case BT_COMPONENT_CLASS_TYPE_SINK:
245 type_str = "sink";
246 break;
247 default:
248 bt_common_abort();
249 }
250
251 if (comp_class_id->plugin_name->len > 0) {
252 g_string_append_printf(str, "%s.%s.%s",
253 type_str, comp_class_id->plugin_name->str,
254 comp_class_id->name->str);
255 } else {
256 g_string_append_printf(str, "%s.%s",
257 type_str, comp_class_id->name->str);
258 }
259 }
260
261 static
262 struct bt_error_cause_component_actor *create_error_cause_component_actor(
263 struct bt_component *comp, const char *file_name,
264 uint64_t line_no)
265 {
266 struct bt_error_cause_component_actor *cause =
267 g_new0(struct bt_error_cause_component_actor, 1);
268 int ret;
269
270 BT_LOGD_STR("Creating error cause object (component actor).");
271
272 if (!cause) {
273 goto error;
274 }
275
276 ret = init_error_cause(&cause->base,
277 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT);
278 if (ret) {
279 goto error;
280 }
281
282 set_error_cause_props(&cause->base, file_name, line_no);
283 cause->comp_name = g_string_new(comp->name->str);
284 if (!cause->comp_name) {
285 BT_LOGE_STR("Failed to allocate one GString.");
286 goto error;
287 }
288
289 ret = init_component_class_id(&cause->comp_class_id, comp->class);
290 if (ret) {
291 goto error;
292 }
293
294 g_string_append_printf(cause->base.module_name, "%s: ",
295 comp->name->str);
296 append_component_class_id_str(cause->base.module_name,
297 &cause->comp_class_id);
298 BT_LIB_LOGD("Created error cause object: %!+r", cause);
299 goto end;
300
301 error:
302 if (cause) {
303 destroy_error_cause(&cause->base);
304 cause = NULL;
305 }
306
307 end:
308 return cause;
309 }
310
311 static
312 struct bt_error_cause_component_class_actor *
313 create_error_cause_component_class_actor(struct bt_component_class *comp_cls,
314 const char *file_name, uint64_t line_no)
315 {
316 struct bt_error_cause_component_class_actor *cause =
317 g_new0(struct bt_error_cause_component_class_actor, 1);
318 int ret;
319
320 BT_LOGD_STR("Creating error cause object (component class actor).");
321
322 if (!cause) {
323 BT_LOGE_STR("Failed to allocate one error cause object.");
324 goto error;
325 }
326
327 ret = init_error_cause(&cause->base,
328 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS);
329 if (ret) {
330 goto error;
331 }
332
333 set_error_cause_props(&cause->base, file_name, line_no);
334 ret = init_component_class_id(&cause->comp_class_id, comp_cls);
335 if (ret) {
336 goto error;
337 }
338
339 append_component_class_id_str(cause->base.module_name,
340 &cause->comp_class_id);
341 BT_LIB_LOGD("Created error cause object: %!+r", cause);
342 goto end;
343
344 error:
345 if (cause) {
346 destroy_error_cause(&cause->base);
347 cause = NULL;
348 }
349
350 end:
351 return cause;
352 }
353
354 static
355 struct bt_error_cause_message_iterator_actor *
356 create_error_cause_message_iterator_actor(struct bt_message_iterator *iter,
357 const char *file_name, uint64_t line_no)
358 {
359 struct bt_error_cause_message_iterator_actor *cause;
360 struct bt_message_iterator *input_port_iter;
361 int ret;
362
363 BT_LOGD_STR("Creating error cause object (message iterator actor).");
364
365 /*
366 * This can only be created from within a graph, from a user
367 * message iterator, which is a self component port input
368 * message iterator.
369 */
370 input_port_iter = (void *) iter;
371 cause = g_new0(struct bt_error_cause_message_iterator_actor, 1);
372 if (!cause) {
373 BT_LOGE_STR("Failed to allocate one error cause object.");
374 goto error;
375 }
376
377 ret = init_error_cause(&cause->base,
378 BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR);
379 if (ret) {
380 goto error;
381 }
382
383 set_error_cause_props(&cause->base, file_name, line_no);
384 cause->comp_name = g_string_new(
385 input_port_iter->upstream_component->name->str);
386 if (!cause->comp_name) {
387 BT_LOGE_STR("Failed to allocate one GString.");
388 goto error;
389 }
390
391 cause->output_port_name = g_string_new(
392 input_port_iter->upstream_port->name->str);
393 if (!cause->output_port_name) {
394 BT_LOGE_STR("Failed to allocate one GString.");
395 goto error;
396 }
397
398 ret = init_component_class_id(&cause->comp_class_id,
399 input_port_iter->upstream_component->class);
400 if (ret) {
401 goto error;
402 }
403
404 g_string_append_printf(cause->base.module_name, "%s (%s): ",
405 input_port_iter->upstream_component->name->str,
406 input_port_iter->upstream_port->name->str);
407 append_component_class_id_str(cause->base.module_name,
408 &cause->comp_class_id);
409 BT_LIB_LOGD("Created error cause object: %!+r", cause);
410 goto end;
411
412 error:
413 if (cause) {
414 destroy_error_cause(&cause->base);
415 cause = NULL;
416 }
417
418 end:
419 return cause;
420 }
421
422 struct bt_error *bt_error_create(void)
423 {
424 struct bt_error *error;
425
426 BT_LOGD_STR("Creating error object.");
427 error = g_new0(struct bt_error, 1);
428 if (!error) {
429 BT_LOGE_STR("Failed to allocate one error object.");
430 goto error;
431 }
432
433 error->causes = g_ptr_array_new_with_free_func(
434 (GDestroyNotify) destroy_error_cause);
435 if (!error->causes) {
436 BT_LOGE_STR("Failed to allocate one GPtrArray.");
437 goto error;
438 }
439
440 BT_LOGD("Created error object: addr=%p", error);
441 goto end;
442
443 error:
444 bt_error_destroy(error);
445 error = NULL;
446
447 end:
448 return error;
449 }
450
451 void bt_error_destroy(struct bt_error *error)
452 {
453 if (!error) {
454 goto end;
455 }
456
457 if (error->causes) {
458 g_ptr_array_free(error->causes, TRUE);
459 error->causes = NULL;
460 }
461
462 g_free(error);
463
464 end:
465 return;
466 }
467
468 int bt_error_append_cause_from_unknown(struct bt_error *error,
469 const char *module_name, const char *file_name,
470 uint64_t line_no, const char *msg_fmt, va_list args)
471 {
472 struct bt_error_cause *cause = NULL;
473 int status = BT_FUNC_STATUS_OK;
474
475 BT_ASSERT(error);
476 BT_ASSERT(module_name);
477 BT_ASSERT(file_name);
478 BT_ASSERT(msg_fmt);
479 BT_LOGD("Appending error cause from unknown actor: "
480 "module-name=\"%s\", func-name=\"%s\", line-no=%" PRIu64,
481 module_name, file_name, line_no);
482 cause = create_error_cause(module_name, file_name, line_no);
483 if (!cause) {
484 /* create_error_cause() logs errors */
485 status = BT_FUNC_STATUS_MEMORY_ERROR;
486 goto end;
487 }
488
489 g_string_append_vprintf(cause->message, msg_fmt, args);
490 g_ptr_array_add(error->causes, cause);
491 BT_LIB_LOGD("Appended error cause: %!+r", cause);
492 cause = NULL;
493
494 end:
495 return status;
496 }
497
498 int bt_error_append_cause_from_component(
499 struct bt_error *error, bt_self_component *self_comp,
500 const char *file_name, uint64_t line_no,
501 const char *msg_fmt, va_list args)
502 {
503 struct bt_error_cause_component_actor *cause = NULL;
504 int status = BT_FUNC_STATUS_OK;
505
506 BT_ASSERT(error);
507 BT_ASSERT(self_comp);
508 BT_ASSERT(file_name);
509 BT_ASSERT(msg_fmt);
510 BT_LIB_LOGD("Appending error cause from component actor: %![comp-]+c",
511 self_comp);
512 cause = create_error_cause_component_actor((void *) self_comp,
513 file_name, line_no);
514 if (!cause) {
515 /* create_error_cause_component_actor() logs errors */
516 status = BT_FUNC_STATUS_MEMORY_ERROR;
517 goto end;
518 }
519
520 g_string_append_vprintf(cause->base.message, msg_fmt, args);
521 g_ptr_array_add(error->causes, cause);
522 BT_LIB_LOGD("Appended error cause: %!+r", cause);
523 cause = NULL;
524
525 end:
526 return status;
527 }
528
529 int bt_error_append_cause_from_component_class(
530 struct bt_error *error,
531 bt_self_component_class *self_comp_class,
532 const char *file_name, uint64_t line_no,
533 const char *msg_fmt, va_list args)
534 {
535 struct bt_error_cause_component_class_actor *cause = NULL;
536 int status = BT_FUNC_STATUS_OK;
537
538 BT_ASSERT(error);
539 BT_ASSERT(self_comp_class);
540 BT_ASSERT(file_name);
541 BT_ASSERT(msg_fmt);
542 BT_LIB_LOGD("Appending error cause from component class actor: "
543 "%![comp-cls-]+C", self_comp_class);
544 cause = create_error_cause_component_class_actor(
545 (void *) self_comp_class, file_name, line_no);
546 if (!cause) {
547 /* create_error_cause_component_class_actor() logs errors */
548 status = BT_FUNC_STATUS_MEMORY_ERROR;
549 goto end;
550 }
551
552 g_string_append_vprintf(cause->base.message, msg_fmt, args);
553 g_ptr_array_add(error->causes, cause);
554 BT_LIB_LOGD("Appended error cause: %!+r", cause);
555 cause = NULL;
556
557 end:
558 return status;
559 }
560
561 int bt_error_append_cause_from_message_iterator(
562 struct bt_error *error, bt_self_message_iterator *self_iter,
563 const char *file_name, uint64_t line_no,
564 const char *msg_fmt, va_list args)
565 {
566 struct bt_error_cause_message_iterator_actor *cause = NULL;
567 int status = BT_FUNC_STATUS_OK;
568
569 BT_ASSERT(error);
570 BT_ASSERT(self_iter);
571 BT_ASSERT(file_name);
572 BT_ASSERT(msg_fmt);
573 BT_LIB_LOGD("Appending error cause from message iterator actor: "
574 "%![comp-]+i", self_iter);
575 cause = create_error_cause_message_iterator_actor(
576 (void *) self_iter, file_name, line_no);
577 if (!cause) {
578 /* create_error_cause_message_iterator_actor() logs errors */
579 status = BT_FUNC_STATUS_MEMORY_ERROR;
580 goto end;
581 }
582
583 g_string_append_vprintf(cause->base.message, msg_fmt, args);
584 g_ptr_array_add(error->causes, cause);
585 BT_LIB_LOGD("Appended error cause: %!+r", cause);
586 cause = NULL;
587
588 end:
589 return status;
590 }
591
592 static
593 uint64_t error_cause_count(const bt_error *error)
594 {
595 return error->causes ? error->causes->len : 0;
596 }
597
598 BT_EXPORT
599 uint64_t bt_error_get_cause_count(const bt_error *error)
600 {
601 BT_ASSERT_PRE_ERROR_NON_NULL(error);
602 return error_cause_count(error);
603 }
604
605 BT_EXPORT
606 void bt_error_release(const struct bt_error *error)
607 {
608 BT_ASSERT_PRE_ERROR_NON_NULL(error);
609 bt_error_destroy((void *) error);
610 }
611
612 BT_EXPORT
613 const struct bt_error_cause *bt_error_borrow_cause_by_index(
614 const bt_error *error, uint64_t index)
615 {
616 BT_ASSERT_PRE_ERROR_NON_NULL(error);
617 BT_ASSERT_PRE_VALID_INDEX(index, error_cause_count(error));
618 return error->causes->pdata[index];
619 }
620
621 BT_EXPORT
622 enum bt_error_cause_actor_type bt_error_cause_get_actor_type(
623 const struct bt_error_cause *cause)
624 {
625 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
626 return cause->actor_type;
627 }
628
629 BT_EXPORT
630 const char *bt_error_cause_get_message(const struct bt_error_cause *cause)
631 {
632 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
633 return cause->message->str;
634 }
635
636 BT_EXPORT
637 const char *bt_error_cause_get_module_name(const struct bt_error_cause *cause)
638 {
639 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
640 return cause->module_name->str;
641 }
642
643 BT_EXPORT
644 const char *bt_error_cause_get_file_name(const struct bt_error_cause *cause)
645 {
646 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
647 return cause->file_name->str;
648 }
649
650 BT_EXPORT
651 uint64_t bt_error_cause_get_line_number(const bt_error_cause *cause)
652 {
653 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
654 return cause->line_no;
655 }
656
657 BT_EXPORT
658 const char *bt_error_cause_component_actor_get_component_name(
659 const struct bt_error_cause *cause)
660 {
661 const struct bt_error_cause_component_actor *spec_cause =
662 (const void *) cause;
663
664 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
665 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "component",
666 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT);
667 return spec_cause->comp_name->str;
668 }
669
670 BT_EXPORT
671 bt_component_class_type bt_error_cause_component_actor_get_component_class_type(
672 const struct bt_error_cause *cause)
673 {
674 const struct bt_error_cause_component_actor *spec_cause =
675 (const void *) cause;
676
677 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
678 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "component",
679 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT);
680 return spec_cause->comp_class_id.type;
681 }
682
683 BT_EXPORT
684 const char *bt_error_cause_component_actor_get_component_class_name(
685 const struct bt_error_cause *cause)
686 {
687 const struct bt_error_cause_component_actor *spec_cause =
688 (const void *) cause;
689
690 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
691 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "component",
692 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT);
693 return spec_cause->comp_class_id.name->str;
694 }
695
696 BT_EXPORT
697 const char *bt_error_cause_component_actor_get_plugin_name(
698 const struct bt_error_cause *cause)
699 {
700 const struct bt_error_cause_component_actor *spec_cause =
701 (const void *) cause;
702
703 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
704 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "component",
705 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT);
706 return spec_cause->comp_class_id.plugin_name->len > 0 ?
707 spec_cause->comp_class_id.plugin_name->str : NULL;
708 }
709
710 BT_EXPORT
711 bt_component_class_type
712 bt_error_cause_component_class_actor_get_component_class_type(
713 const struct bt_error_cause *cause)
714 {
715 const struct bt_error_cause_component_class_actor *spec_cause =
716 (const void *) cause;
717
718 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
719 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "component-class",
720 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS);
721 return spec_cause->comp_class_id.type;
722 }
723
724 BT_EXPORT
725 const char *bt_error_cause_component_class_actor_get_component_class_name(
726 const struct bt_error_cause *cause)
727 {
728 const struct bt_error_cause_component_class_actor *spec_cause =
729 (const void *) cause;
730
731 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
732 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "component-class",
733 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS);
734 return spec_cause->comp_class_id.name->str;
735 }
736
737 BT_EXPORT
738 const char *bt_error_cause_component_class_actor_get_plugin_name(
739 const struct bt_error_cause *cause)
740 {
741 const struct bt_error_cause_component_class_actor *spec_cause =
742 (const void *) cause;
743
744 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
745 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "component-class",
746 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS);
747 return spec_cause->comp_class_id.plugin_name->len > 0 ?
748 spec_cause->comp_class_id.plugin_name->str : NULL;
749 }
750
751 BT_EXPORT
752 const char *bt_error_cause_message_iterator_actor_get_component_name(
753 const struct bt_error_cause *cause)
754 {
755 const struct bt_error_cause_message_iterator_actor *spec_cause =
756 (const void *) cause;
757
758 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
759 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "message-iterator",
760 BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR);
761 return spec_cause->comp_name->str;
762 }
763
764 BT_EXPORT
765 const char *
766 bt_error_cause_message_iterator_actor_get_component_output_port_name(
767 const struct bt_error_cause *cause)
768 {
769 const struct bt_error_cause_message_iterator_actor *spec_cause =
770 (const void *) cause;
771
772 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
773 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "message-iterator",
774 BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR);
775 return spec_cause->output_port_name->str;
776 }
777
778 BT_EXPORT
779 bt_component_class_type
780 bt_error_cause_message_iterator_actor_get_component_class_type(
781 const struct bt_error_cause *cause)
782 {
783 const struct bt_error_cause_message_iterator_actor *spec_cause =
784 (const void *) cause;
785
786 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
787 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "message-iterator",
788 BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR);
789 return spec_cause->comp_class_id.type;
790 }
791
792 BT_EXPORT
793 const char *bt_error_cause_message_iterator_actor_get_component_class_name(
794 const struct bt_error_cause *cause)
795 {
796 const struct bt_error_cause_message_iterator_actor *spec_cause =
797 (const void *) cause;
798
799 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
800 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "message-iterator",
801 BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR);
802 return spec_cause->comp_class_id.name->str;
803 }
804
805 BT_EXPORT
806 const char *bt_error_cause_message_iterator_actor_get_plugin_name(
807 const struct bt_error_cause *cause)
808 {
809 const struct bt_error_cause_message_iterator_actor *spec_cause =
810 (const void *) cause;
811
812 BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
813 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "message-iterator",
814 BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR);
815 return spec_cause->comp_class_id.plugin_name->len > 0 ?
816 spec_cause->comp_class_id.plugin_name->str : NULL;
817 }
This page took 0.043615 seconds and 4 git commands to generate.