X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Ftext%2Ftext.c;h=78cdaab666ee9c16a6109c1ffcb0012aea0f4362;hb=77986badaf402cb8f87a346402cda81041d6c4d9;hp=045673686b6361846c662f40b28fc8121e1e553b;hpb=41a2b7aeccec8153fc6845819a0ca98461f35cb1;p=babeltrace.git diff --git a/plugins/text/text.c b/plugins/text/text.c index 04567368..78cdaab6 100644 --- a/plugins/text/text.c +++ b/plugins/text/text.c @@ -28,16 +28,16 @@ */ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -74,6 +74,7 @@ const char *plugin_options[] = { "field-trace:vpid", "field-loglevel", "field-emf", + "field-callsite", }; static @@ -81,6 +82,14 @@ void destroy_text_data(struct text_component *text) { bt_put(text->input_iterator); (void) g_string_free(text->string, TRUE); + if (text->out != stdout) { + int ret; + + ret = fclose(text->out); + if (ret) { + perror("close output file"); + } + } g_free(text->options.output_path); g_free(text->options.debug_info_dir); g_free(text->options.debug_info_target_prefix); @@ -129,10 +138,8 @@ enum bt_component_status handle_notification(struct text_component *text, switch (bt_notification_get_type(notification)) { case BT_NOTIFICATION_TYPE_PACKET_BEGIN: - puts(""); break; case BT_NOTIFICATION_TYPE_PACKET_END: - puts(""); break; case BT_NOTIFICATION_TYPE_EVENT: { @@ -151,7 +158,6 @@ enum bt_component_status handle_notification(struct text_component *text, break; } case BT_NOTIFICATION_TYPE_STREAM_END: - puts(""); break; default: puts("Unhandled notification type"); @@ -324,6 +330,28 @@ void warn_wrong_color_param(struct text_component *text) "[warning] Accepted values for the \"color\" parameter are:\n \"always\", \"auto\", \"never\"\n"); } +static +enum bt_component_status open_output_file(struct text_component *text) +{ + enum bt_component_status ret = BT_COMPONENT_STATUS_OK; + + if (!text->options.output_path) { + goto end; + } + + text->out = fopen(text->options.output_path, "w"); + if (!text->out) { + goto error; + } + + goto end; + +error: + ret = BT_COMPONENT_STATUS_ERROR; +end: + return ret; +} + static enum bt_component_status apply_params(struct text_component *text, struct bt_value *params) @@ -386,6 +414,10 @@ enum bt_component_status apply_params(struct text_component *text, if (ret != BT_COMPONENT_STATUS_OK) { goto end; } + ret = open_output_file(text); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } ret = apply_one_string("debug-info-dir", params, @@ -559,7 +591,7 @@ enum bt_component_status apply_params(struct text_component *text, text->options.print_trace_vpid_field = true; 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; @@ -569,7 +601,7 @@ enum bt_component_status apply_params(struct text_component *text, text->options.print_trace_vpid_field = true; 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; @@ -579,7 +611,7 @@ enum bt_component_status apply_params(struct text_component *text, text->options.print_trace_vpid_field = false; 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; @@ -658,12 +690,12 @@ enum bt_component_status apply_params(struct text_component *text, value = false; found = false; - ret = apply_one_bool("field-emf", params, &value, &found); + ret = apply_one_bool("field-callsite", params, &value, &found); if (ret != BT_COMPONENT_STATUS_OK) { goto end; } if (found) { - text->options.print_emf_field = value; + text->options.print_callsite_field = value; } end: