X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Ftext%2Ftext.c;h=370fb2d3478fdb9892e57d916314893a6a714be4;hb=6ba0b073d3cc5040234aad3ab820b7ca4022e3e9;hp=f9134b778fedea0d9d32b75aa0de68159dc6c62f;hpb=c3c30b08de95f06de6ad2f12001bede5da3f7674;p=babeltrace.git diff --git a/plugins/text/text.c b/plugins/text/text.c index f9134b77..370fb2d3 100644 --- a/plugins/text/text.c +++ b/plugins/text/text.c @@ -4,6 +4,7 @@ * Babeltrace CTF Text Output Plugin * * Copyright 2016 Jérémie Galarneau + * Copyright 2016 Mathieu Desnoyers * * Author: Jérémie Galarneau * @@ -26,12 +27,12 @@ * SOFTWARE. */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -39,8 +40,6 @@ #include #include "text.h" -#define PLUGIN_NAME "text" - static const char *plugin_options[] = { "output-path", @@ -65,7 +64,6 @@ const char *plugin_options[] = { "field-trace:vpid", "field-loglevel", "field-emf", - "field-callsite", }; static @@ -119,7 +117,7 @@ enum bt_component_status handle_notification(struct text_component *text, } switch (bt_notification_get_type(notification)) { - case BT_NOTIFICATION_TYPE_PACKET_START: + case BT_NOTIFICATION_TYPE_PACKET_BEGIN: puts(""); break; case BT_NOTIFICATION_TYPE_PACKET_END: @@ -164,15 +162,21 @@ enum bt_component_status run(struct bt_component *component) goto end; } - if (!text->processed_first_event) { - ret = bt_notification_iterator_next(it); - if (ret != BT_COMPONENT_STATUS_OK) { + if (likely(text->processed_first_event)) { + enum bt_notification_iterator_status it_ret; + + it_ret = bt_notification_iterator_next(it); + switch (it_ret) { + case BT_NOTIFICATION_ITERATOR_STATUS_ERROR: + ret = BT_COMPONENT_STATUS_ERROR; + goto end; + case BT_NOTIFICATION_ITERATOR_STATUS_END: + ret = BT_COMPONENT_STATUS_END; goto end; + default: + break; } - } else { - text->processed_first_event = true; } - notification = bt_notification_iterator_get_notification(it); if (!notification) { ret = BT_COMPONENT_STATUS_ERROR; @@ -180,6 +184,7 @@ enum bt_component_status run(struct bt_component *component) } ret = handle_notification(text, notification); + text->processed_first_event = true; end: bt_put(it); bt_put(notification); @@ -217,8 +222,7 @@ bool check_param_exists(const char *key, struct bt_value *object, void *data) if (!bt_value_map_get(plugin_opt_map, key)) { fprintf(text->err, - "[warning] Parameter \"%s\" unknown to \"%s\" plugin\n", - key, PLUGIN_NAME); + "[warning] Parameter \"%s\" unknown to \"text\" plugin\n", key); } return true; } @@ -485,7 +489,6 @@ enum bt_component_status apply_params(struct text_component *text, text->options.print_loglevel_field = false; text->options.print_emf_field = false; text->options.print_emf_field = false; - text->options.print_callsite_field = false; break; case TEXT_DEFAULT_SHOW: text->options.print_trace_field = true; @@ -496,7 +499,6 @@ enum bt_component_status apply_params(struct text_component *text, text->options.print_loglevel_field = true; text->options.print_emf_field = true; text->options.print_emf_field = true; - text->options.print_callsite_field = true; break; case TEXT_DEFAULT_HIDE: text->options.print_trace_field = false; @@ -507,7 +509,6 @@ enum bt_component_status apply_params(struct text_component *text, text->options.print_loglevel_field = false; text->options.print_emf_field = false; text->options.print_emf_field = false; - text->options.print_callsite_field = false; break; default: ret = BT_COMPONENT_STATUS_ERROR; @@ -594,15 +595,6 @@ enum bt_component_status apply_params(struct text_component *text, text->options.print_emf_field = value; } - value = false; - found = false; - ret = apply_one_bool("field-callsite", params, &value, &found); - if (ret != BT_COMPONENT_STATUS_OK) { - goto end; - } - if (found) { - text->options.print_callsite_field = value; - } end: bt_put(text->plugin_opt_map); text->plugin_opt_map = NULL; @@ -625,6 +617,12 @@ enum bt_component_status text_component_init( text->out = stdout; text->err = stderr; + text->delta_cycles = -1ULL; + text->last_cycles_timestamp = -1ULL; + + text->delta_real_timestamp = -1ULL; + text->last_real_timestamp = -1ULL; + ret = apply_params(text, params); if (ret != BT_COMPONENT_STATUS_OK) { goto error; @@ -654,13 +652,11 @@ error: } /* Initialize plug-in entry points. */ -BT_PLUGIN_NAME("text"); +BT_PLUGIN(text); BT_PLUGIN_DESCRIPTION("Babeltrace text output plug-in."); BT_PLUGIN_AUTHOR("Jérémie Galarneau"); BT_PLUGIN_LICENSE("MIT"); - -BT_PLUGIN_COMPONENT_CLASSES_BEGIN -BT_PLUGIN_SINK_COMPONENT_CLASS_ENTRY(PLUGIN_NAME, - "Formats CTF-IR to text. Formerly known as ctf-text.", - text_component_init) -BT_PLUGIN_COMPONENT_CLASSES_END +BT_PLUGIN_COMPONENT_CLASS(BT_COMPONENT_TYPE_SINK, text, + text_component_init); +BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION(BT_COMPONENT_TYPE_SINK, text, + "Formats CTF-IR to text. Formerly known as ctf-text.");