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