4ac6ad6d5c20c5558483d3e5540019313e36c67b
[babeltrace.git] / plugins / text / pretty / pretty.c
1 /*
2 * pretty.c
3 *
4 * Babeltrace CTF Text Output Plugin
5 *
6 * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
7 * Copyright 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 *
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * SOFTWARE.
28 */
29
30 #include <babeltrace/plugin/plugin-dev.h>
31 #include <babeltrace/graph/component.h>
32 #include <babeltrace/graph/private-component.h>
33 #include <babeltrace/graph/private-component-sink.h>
34 #include <babeltrace/graph/component-sink.h>
35 #include <babeltrace/graph/port.h>
36 #include <babeltrace/graph/private-port.h>
37 #include <babeltrace/graph/connection.h>
38 #include <babeltrace/graph/private-connection.h>
39 #include <babeltrace/graph/notification.h>
40 #include <babeltrace/graph/notification-iterator.h>
41 #include <babeltrace/graph/notification-event.h>
42 #include <babeltrace/values.h>
43 #include <babeltrace/compiler-internal.h>
44 #include <babeltrace/common-internal.h>
45 #include <plugins-common.h>
46 #include <stdio.h>
47 #include <stdbool.h>
48 #include <glib.h>
49 #include <assert.h>
50
51 #include "pretty.h"
52
53 GQuark stream_packet_context_quarks[STREAM_PACKET_CONTEXT_QUARKS_LEN];
54
55 static
56 const char *plugin_options[] = {
57 "color",
58 "path",
59 "no-delta",
60 "clock-cycles",
61 "clock-seconds",
62 "clock-date",
63 "clock-gmt",
64 "verbose",
65 "name-default", /* show/hide */
66 "name-payload",
67 "name-context",
68 "name-scope",
69 "name-header",
70 "field-default", /* show/hide */
71 "field-trace",
72 "field-trace:hostname",
73 "field-trace:domain",
74 "field-trace:procname",
75 "field-trace:vpid",
76 "field-loglevel",
77 "field-emf",
78 "field-callsite",
79 };
80
81 static
82 void destroy_pretty_data(struct pretty_component *pretty)
83 {
84 bt_put(pretty->input_iterator);
85
86 if (pretty->string) {
87 (void) g_string_free(pretty->string, TRUE);
88 }
89
90 if (pretty->tmp_string) {
91 (void) g_string_free(pretty->tmp_string, TRUE);
92 }
93
94 if (pretty->out != stdout) {
95 int ret;
96
97 ret = fclose(pretty->out);
98 if (ret) {
99 perror("close output file");
100 }
101 }
102 g_free(pretty->options.output_path);
103 g_free(pretty);
104 }
105
106 static
107 struct pretty_component *create_pretty(void)
108 {
109 struct pretty_component *pretty;
110
111 pretty = g_new0(struct pretty_component, 1);
112 if (!pretty) {
113 goto end;
114 }
115 pretty->string = g_string_new("");
116 if (!pretty->string) {
117 goto error;
118 }
119 pretty->tmp_string = g_string_new("");
120 if (!pretty->tmp_string) {
121 goto error;
122 }
123 end:
124 return pretty;
125
126 error:
127 g_free(pretty);
128 return NULL;
129 }
130
131 BT_HIDDEN
132 void pretty_finalize(struct bt_private_component *component)
133 {
134 void *data = bt_private_component_get_user_data(component);
135
136 destroy_pretty_data(data);
137 }
138
139 static
140 enum bt_component_status handle_notification(struct pretty_component *pretty,
141 struct bt_notification *notification)
142 {
143 enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
144
145 assert(pretty);
146
147 switch (bt_notification_get_type(notification)) {
148 case BT_NOTIFICATION_TYPE_EVENT:
149 ret = pretty_print_event(pretty, notification);
150 break;
151 case BT_NOTIFICATION_TYPE_INACTIVITY:
152 fprintf(stderr, "Inactivity notification\n");
153 break;
154 case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
155 case BT_NOTIFICATION_TYPE_PACKET_END:
156 case BT_NOTIFICATION_TYPE_STREAM_BEGIN:
157 case BT_NOTIFICATION_TYPE_STREAM_END:
158 break;
159 case BT_NOTIFICATION_TYPE_DISCARDED_PACKETS:
160 case BT_NOTIFICATION_TYPE_DISCARDED_EVENTS:
161 ret = pretty_print_discarded_elements(pretty, notification);
162 break;
163 default:
164 fprintf(stderr, "Unhandled notification type\n");
165 }
166
167 return ret;
168 }
169
170 BT_HIDDEN
171 void pretty_port_connected(
172 struct bt_private_component *component,
173 struct bt_private_port *self_port,
174 struct bt_port *other_port)
175 {
176 enum bt_connection_status conn_status;
177 struct bt_private_connection *connection;
178 struct pretty_component *pretty;
179 static const enum bt_notification_type notif_types[] = {
180 BT_NOTIFICATION_TYPE_EVENT,
181 BT_NOTIFICATION_TYPE_DISCARDED_PACKETS,
182 BT_NOTIFICATION_TYPE_DISCARDED_EVENTS,
183 BT_NOTIFICATION_TYPE_SENTINEL,
184 };
185
186 pretty = bt_private_component_get_user_data(component);
187 assert(pretty);
188 assert(!pretty->input_iterator);
189 connection = bt_private_port_get_private_connection(self_port);
190 assert(connection);
191 conn_status = bt_private_connection_create_notification_iterator(
192 connection, notif_types, &pretty->input_iterator);
193 if (conn_status != BT_CONNECTION_STATUS_OK) {
194 pretty->error = true;
195 }
196
197 bt_put(connection);
198 }
199
200 BT_HIDDEN
201 enum bt_component_status pretty_consume(struct bt_private_component *component)
202 {
203 enum bt_component_status ret;
204 struct bt_notification *notification = NULL;
205 struct bt_notification_iterator *it;
206 struct pretty_component *pretty =
207 bt_private_component_get_user_data(component);
208 enum bt_notification_iterator_status it_ret;
209
210 if (unlikely(pretty->error)) {
211 ret = BT_COMPONENT_STATUS_ERROR;
212 goto end;
213 }
214
215 it = pretty->input_iterator;
216 it_ret = bt_notification_iterator_next(it);
217
218 switch (it_ret) {
219 case BT_NOTIFICATION_ITERATOR_STATUS_END:
220 ret = BT_COMPONENT_STATUS_END;
221 BT_PUT(pretty->input_iterator);
222 goto end;
223 case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
224 ret = BT_COMPONENT_STATUS_AGAIN;
225 goto end;
226 case BT_NOTIFICATION_ITERATOR_STATUS_OK:
227 break;
228 default:
229 ret = BT_COMPONENT_STATUS_ERROR;
230 goto end;
231 }
232
233 notification = bt_notification_iterator_get_notification(it);
234 assert(notification);
235 ret = handle_notification(pretty, notification);
236
237 end:
238 bt_put(notification);
239 return ret;
240 }
241
242 static
243 enum bt_component_status add_params_to_map(struct bt_value *plugin_opt_map)
244 {
245 enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
246 unsigned int i;
247
248 for (i = 0; i < BT_ARRAY_SIZE(plugin_options); i++) {
249 const char *key = plugin_options[i];
250 enum bt_value_status status;
251
252 status = bt_value_map_insert(plugin_opt_map, key, bt_value_null);
253 switch (status) {
254 case BT_VALUE_STATUS_OK:
255 break;
256 default:
257 ret = BT_COMPONENT_STATUS_ERROR;
258 goto end;
259 }
260 }
261 end:
262 return ret;
263 }
264
265 static
266 bt_bool check_param_exists(const char *key, struct bt_value *object, void *data)
267 {
268 struct pretty_component *pretty = data;
269 struct bt_value *plugin_opt_map = pretty->plugin_opt_map;
270
271 if (!bt_value_map_get(plugin_opt_map, key)) {
272 fprintf(pretty->err,
273 "[warning] Parameter \"%s\" unknown to \"text.pretty\" sink component\n", key);
274 }
275 return BT_TRUE;
276 }
277
278 static
279 enum bt_component_status apply_one_string(const char *key,
280 struct bt_value *params,
281 char **option)
282 {
283 enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
284 struct bt_value *value = NULL;
285 enum bt_value_status status;
286 const char *str;
287
288 value = bt_value_map_get(params, key);
289 if (!value) {
290 goto end;
291 }
292 if (bt_value_is_null(value)) {
293 goto end;
294 }
295 status = bt_value_string_get(value, &str);
296 switch (status) {
297 case BT_VALUE_STATUS_OK:
298 break;
299 default:
300 ret = BT_COMPONENT_STATUS_ERROR;
301 goto end;
302 }
303 *option = g_strdup(str);
304 end:
305 bt_put(value);
306 return ret;
307 }
308
309 static
310 enum bt_component_status apply_one_bool(const char *key,
311 struct bt_value *params,
312 bool *option,
313 bool *found)
314 {
315 enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
316 struct bt_value *value = NULL;
317 enum bt_value_status status;
318 bt_bool bool_val;
319
320 value = bt_value_map_get(params, key);
321 if (!value) {
322 goto end;
323 }
324 status = bt_value_bool_get(value, &bool_val);
325 switch (status) {
326 case BT_VALUE_STATUS_OK:
327 break;
328 default:
329 ret = BT_COMPONENT_STATUS_ERROR;
330 goto end;
331 }
332 *option = (bool) bool_val;
333 if (found) {
334 *found = true;
335 }
336 end:
337 bt_put(value);
338 return ret;
339 }
340
341 static
342 void warn_wrong_color_param(struct pretty_component *pretty)
343 {
344 fprintf(pretty->err,
345 "[warning] Accepted values for the \"color\" parameter are:\n \"always\", \"auto\", \"never\"\n");
346 }
347
348 static
349 enum bt_component_status open_output_file(struct pretty_component *pretty)
350 {
351 enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
352
353 if (!pretty->options.output_path) {
354 goto end;
355 }
356
357 pretty->out = fopen(pretty->options.output_path, "w");
358 if (!pretty->out) {
359 goto error;
360 }
361
362 goto end;
363
364 error:
365 ret = BT_COMPONENT_STATUS_ERROR;
366 end:
367 return ret;
368 }
369
370 static
371 enum bt_component_status apply_params(struct pretty_component *pretty,
372 struct bt_value *params)
373 {
374 enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
375 enum bt_value_status status;
376 bool value, found;
377 char *str = NULL;
378
379 pretty->plugin_opt_map = bt_value_map_create();
380 if (!pretty->plugin_opt_map) {
381 ret = BT_COMPONENT_STATUS_ERROR;
382 goto end;
383 }
384 ret = add_params_to_map(pretty->plugin_opt_map);
385 if (ret != BT_COMPONENT_STATUS_OK) {
386 goto end;
387 }
388 /* Report unknown parameters. */
389 status = bt_value_map_foreach(params, check_param_exists, pretty);
390 switch (status) {
391 case BT_VALUE_STATUS_OK:
392 break;
393 default:
394 ret = BT_COMPONENT_STATUS_ERROR;
395 goto end;
396 }
397 /* Known parameters. */
398 pretty->options.color = PRETTY_COLOR_OPT_AUTO;
399 if (bt_value_map_has_key(params, "color")) {
400 struct bt_value *color_value;
401 const char *color;
402
403 color_value = bt_value_map_get(params, "color");
404 if (!color_value) {
405 goto end;
406 }
407
408 status = bt_value_string_get(color_value, &color);
409 if (status) {
410 warn_wrong_color_param(pretty);
411 } else {
412 if (strcmp(color, "never") == 0) {
413 pretty->options.color = PRETTY_COLOR_OPT_NEVER;
414 } else if (strcmp(color, "auto") == 0) {
415 pretty->options.color = PRETTY_COLOR_OPT_AUTO;
416 } else if (strcmp(color, "always") == 0) {
417 pretty->options.color = PRETTY_COLOR_OPT_ALWAYS;
418 } else {
419 warn_wrong_color_param(pretty);
420 }
421 }
422
423 bt_put(color_value);
424 }
425
426 ret = apply_one_string("path", params, &pretty->options.output_path);
427 if (ret != BT_COMPONENT_STATUS_OK) {
428 goto end;
429 }
430 ret = open_output_file(pretty);
431 if (ret != BT_COMPONENT_STATUS_OK) {
432 goto end;
433 }
434
435 value = false; /* Default. */
436 ret = apply_one_bool("no-delta", params, &value, NULL);
437 if (ret != BT_COMPONENT_STATUS_OK) {
438 goto end;
439 }
440 pretty->options.print_delta_field = !value; /* Reverse logic. */
441
442 value = false; /* Default. */
443 ret = apply_one_bool("clock-cycles", params, &value, NULL);
444 if (ret != BT_COMPONENT_STATUS_OK) {
445 goto end;
446 }
447 pretty->options.print_timestamp_cycles = value;
448
449 value = false; /* Default. */
450 ret = apply_one_bool("clock-seconds", params, &value, NULL);
451 if (ret != BT_COMPONENT_STATUS_OK) {
452 goto end;
453 }
454 pretty->options.clock_seconds = value;
455
456 value = false; /* Default. */
457 ret = apply_one_bool("clock-date", params, &value, NULL);
458 if (ret != BT_COMPONENT_STATUS_OK) {
459 goto end;
460 }
461 pretty->options.clock_date = value;
462
463 value = false; /* Default. */
464 ret = apply_one_bool("clock-gmt", params, &value, NULL);
465 if (ret != BT_COMPONENT_STATUS_OK) {
466 goto end;
467 }
468 pretty->options.clock_gmt = value;
469
470 value = false; /* Default. */
471 ret = apply_one_bool("verbose", params, &value, NULL);
472 if (ret != BT_COMPONENT_STATUS_OK) {
473 goto end;
474 }
475 pretty->options.verbose = value;
476
477 /* Names. */
478 ret = apply_one_string("name-default", params, &str);
479 if (ret != BT_COMPONENT_STATUS_OK) {
480 goto end;
481 }
482 if (!str) {
483 pretty->options.name_default = PRETTY_DEFAULT_UNSET;
484 } else if (!strcmp(str, "show")) {
485 pretty->options.name_default = PRETTY_DEFAULT_SHOW;
486 } else if (!strcmp(str, "hide")) {
487 pretty->options.name_default = PRETTY_DEFAULT_HIDE;
488 } else {
489 ret = BT_COMPONENT_STATUS_ERROR;
490 goto end;
491 }
492 g_free(str);
493 str = NULL;
494
495 switch (pretty->options.name_default) {
496 case PRETTY_DEFAULT_UNSET:
497 pretty->options.print_payload_field_names = true;
498 pretty->options.print_context_field_names = true;
499 pretty->options.print_header_field_names = false;
500 pretty->options.print_scope_field_names = false;
501 break;
502 case PRETTY_DEFAULT_SHOW:
503 pretty->options.print_payload_field_names = true;
504 pretty->options.print_context_field_names = true;
505 pretty->options.print_header_field_names = true;
506 pretty->options.print_scope_field_names = true;
507 break;
508 case PRETTY_DEFAULT_HIDE:
509 pretty->options.print_payload_field_names = false;
510 pretty->options.print_context_field_names = false;
511 pretty->options.print_header_field_names = false;
512 pretty->options.print_scope_field_names = false;
513 break;
514 default:
515 ret = BT_COMPONENT_STATUS_ERROR;
516 goto end;
517 }
518
519 value = false;
520 found = false;
521 ret = apply_one_bool("name-payload", params, &value, &found);
522 if (ret != BT_COMPONENT_STATUS_OK) {
523 goto end;
524 }
525 if (found) {
526 pretty->options.print_payload_field_names = value;
527 }
528
529 value = false;
530 found = false;
531 ret = apply_one_bool("name-context", params, &value, &found);
532 if (ret != BT_COMPONENT_STATUS_OK) {
533 goto end;
534 }
535 if (found) {
536 pretty->options.print_context_field_names = value;
537 }
538
539 value = false;
540 found = false;
541 ret = apply_one_bool("name-header", params, &value, &found);
542 if (ret != BT_COMPONENT_STATUS_OK) {
543 goto end;
544 }
545 if (found) {
546 pretty->options.print_header_field_names = value;
547 }
548
549 value = false;
550 found = false;
551 ret = apply_one_bool("name-scope", params, &value, &found);
552 if (ret != BT_COMPONENT_STATUS_OK) {
553 goto end;
554 }
555 if (found) {
556 pretty->options.print_scope_field_names = value;
557 }
558
559 /* Fields. */
560 ret = apply_one_string("field-default", params, &str);
561 if (ret != BT_COMPONENT_STATUS_OK) {
562 goto end;
563 }
564 if (!str) {
565 pretty->options.field_default = PRETTY_DEFAULT_UNSET;
566 } else if (!strcmp(str, "show")) {
567 pretty->options.field_default = PRETTY_DEFAULT_SHOW;
568 } else if (!strcmp(str, "hide")) {
569 pretty->options.field_default = PRETTY_DEFAULT_HIDE;
570 } else {
571 ret = BT_COMPONENT_STATUS_ERROR;
572 goto end;
573 }
574 g_free(str);
575 str = NULL;
576
577 switch (pretty->options.field_default) {
578 case PRETTY_DEFAULT_UNSET:
579 pretty->options.print_trace_field = false;
580 pretty->options.print_trace_hostname_field = true;
581 pretty->options.print_trace_domain_field = false;
582 pretty->options.print_trace_procname_field = true;
583 pretty->options.print_trace_vpid_field = true;
584 pretty->options.print_loglevel_field = false;
585 pretty->options.print_emf_field = false;
586 pretty->options.print_callsite_field = false;
587 break;
588 case PRETTY_DEFAULT_SHOW:
589 pretty->options.print_trace_field = true;
590 pretty->options.print_trace_hostname_field = true;
591 pretty->options.print_trace_domain_field = true;
592 pretty->options.print_trace_procname_field = true;
593 pretty->options.print_trace_vpid_field = true;
594 pretty->options.print_loglevel_field = true;
595 pretty->options.print_emf_field = true;
596 pretty->options.print_callsite_field = true;
597 break;
598 case PRETTY_DEFAULT_HIDE:
599 pretty->options.print_trace_field = false;
600 pretty->options.print_trace_hostname_field = false;
601 pretty->options.print_trace_domain_field = false;
602 pretty->options.print_trace_procname_field = false;
603 pretty->options.print_trace_vpid_field = false;
604 pretty->options.print_loglevel_field = false;
605 pretty->options.print_emf_field = false;
606 pretty->options.print_callsite_field = false;
607 break;
608 default:
609 ret = BT_COMPONENT_STATUS_ERROR;
610 goto end;
611 }
612
613 value = false;
614 found = false;
615 ret = apply_one_bool("field-trace", params, &value, &found);
616 if (ret != BT_COMPONENT_STATUS_OK) {
617 goto end;
618 }
619 if (found) {
620 pretty->options.print_trace_field = value;
621 }
622
623 value = false;
624 found = false;
625 ret = apply_one_bool("field-trace:hostname", params, &value, &found);
626 if (ret != BT_COMPONENT_STATUS_OK) {
627 goto end;
628 }
629 if (found) {
630 pretty->options.print_trace_hostname_field = value;
631 }
632
633 value = false;
634 found = false;
635 ret = apply_one_bool("field-trace:domain", params, &value, &found);
636 if (ret != BT_COMPONENT_STATUS_OK) {
637 goto end;
638 }
639 if (found) {
640 pretty->options.print_trace_domain_field = value;
641 }
642
643 value = false;
644 found = false;
645 ret = apply_one_bool("field-trace:procname", params, &value, &found);
646 if (ret != BT_COMPONENT_STATUS_OK) {
647 goto end;
648 }
649 if (found) {
650 pretty->options.print_trace_procname_field = value;
651 }
652
653 value = false;
654 found = false;
655 ret = apply_one_bool("field-trace:vpid", params, &value, &found);
656 if (ret != BT_COMPONENT_STATUS_OK) {
657 goto end;
658 }
659 if (found) {
660 pretty->options.print_trace_vpid_field = value;
661 }
662
663 value = false;
664 found = false;
665 ret = apply_one_bool("field-loglevel", params, &value, &found);
666 if (ret != BT_COMPONENT_STATUS_OK) {
667 goto end;
668 }
669 if (found) {
670 pretty->options.print_loglevel_field = value;
671 }
672
673 value = false;
674 found = false;
675 ret = apply_one_bool("field-emf", params, &value, &found);
676 if (ret != BT_COMPONENT_STATUS_OK) {
677 goto end;
678 }
679 if (found) {
680 pretty->options.print_emf_field = value;
681 }
682
683 value = false;
684 found = false;
685 ret = apply_one_bool("field-callsite", params, &value, &found);
686 if (ret != BT_COMPONENT_STATUS_OK) {
687 goto end;
688 }
689 if (found) {
690 pretty->options.print_callsite_field = value;
691 }
692
693 end:
694 bt_put(pretty->plugin_opt_map);
695 pretty->plugin_opt_map = NULL;
696 g_free(str);
697 return ret;
698 }
699
700 static
701 void set_use_colors(struct pretty_component *pretty)
702 {
703 switch (pretty->options.color) {
704 case PRETTY_COLOR_OPT_ALWAYS:
705 pretty->use_colors = true;
706 break;
707 case PRETTY_COLOR_OPT_AUTO:
708 pretty->use_colors = pretty->out == stdout &&
709 bt_common_colors_supported();
710 break;
711 case PRETTY_COLOR_OPT_NEVER:
712 pretty->use_colors = false;
713 break;
714 }
715 }
716
717 static
718 void init_stream_packet_context_quarks(void)
719 {
720 stream_packet_context_quarks[Q_TIMESTAMP_BEGIN] =
721 g_quark_from_string("timestamp_begin");
722 stream_packet_context_quarks[Q_TIMESTAMP_BEGIN] =
723 g_quark_from_string("timestamp_begin");
724 stream_packet_context_quarks[Q_TIMESTAMP_END] =
725 g_quark_from_string("timestamp_end");
726 stream_packet_context_quarks[Q_EVENTS_DISCARDED] =
727 g_quark_from_string("events_discarded");
728 stream_packet_context_quarks[Q_CONTENT_SIZE] =
729 g_quark_from_string("content_size");
730 stream_packet_context_quarks[Q_PACKET_SIZE] =
731 g_quark_from_string("packet_size");
732 stream_packet_context_quarks[Q_PACKET_SEQ_NUM] =
733 g_quark_from_string("packet_seq_num");
734 }
735
736 BT_HIDDEN
737 enum bt_component_status pretty_init(
738 struct bt_private_component *component,
739 struct bt_value *params,
740 UNUSED_VAR void *init_method_data)
741 {
742 enum bt_component_status ret;
743 struct pretty_component *pretty = create_pretty();
744
745 if (!pretty) {
746 ret = BT_COMPONENT_STATUS_NOMEM;
747 goto end;
748 }
749
750 ret = bt_private_component_sink_add_input_private_port(component,
751 "in", NULL, NULL);
752 if (ret != BT_COMPONENT_STATUS_OK) {
753 goto end;
754 }
755
756 pretty->out = stdout;
757 pretty->err = stderr;
758
759 pretty->delta_cycles = -1ULL;
760 pretty->last_cycles_timestamp = -1ULL;
761
762 pretty->delta_real_timestamp = -1ULL;
763 pretty->last_real_timestamp = -1ULL;
764
765 ret = apply_params(pretty, params);
766 if (ret != BT_COMPONENT_STATUS_OK) {
767 goto error;
768 }
769
770 set_use_colors(pretty);
771 ret = bt_private_component_set_user_data(component, pretty);
772 if (ret != BT_COMPONENT_STATUS_OK) {
773 goto error;
774 }
775
776 init_stream_packet_context_quarks();
777
778 end:
779 return ret;
780 error:
781 destroy_pretty_data(pretty);
782 return ret;
783 }
This page took 0.050741 seconds and 3 git commands to generate.