Text output identical with babeltrace 1
authorJulien Desfossez <jdesfossez@efficios.com>
Mon, 20 Mar 2017 20:13:44 +0000 (16:13 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:39 +0000 (12:57 -0400)
Various fixes to make sure the text output stays the same as babeltrace
1. Tested all -f and -n options combinations with no differences.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
cli/babeltrace-cfg.c
plugins/text/print.c
plugins/text/text.c
plugins/text/text.h

index bf36be9b19b3c600532dfd88ff12fc7d0f477bc1..e847b9705be1a5fd8248e4d895a9abdeba8700d9 100644 (file)
@@ -1207,6 +1207,7 @@ int insert_flat_params_from_array(GString *params_arg,
        int ret = 0;
        int i;
        GString *tmpstr = NULL, *default_value = NULL;
        int ret = 0;
        int i;
        GString *tmpstr = NULL, *default_value = NULL;
+       bool default_set = false, non_default_set = false;
 
        /*
         * names_array may be NULL if no CLI options were specified to
 
        /*
         * names_array may be NULL if no CLI options were specified to
@@ -1260,15 +1261,31 @@ int insert_flat_params_from_array(GString *params_arg,
                        g_string_assign(default_value, "hide");
                }
                if (is_default) {
                        g_string_assign(default_value, "hide");
                }
                if (is_default) {
+                       default_set = true;
                        g_string_append(tmpstr, "default");
                        append_param_arg(params_arg, tmpstr->str,
                                default_value->str);
                } else {
                        g_string_append(tmpstr, "default");
                        append_param_arg(params_arg, tmpstr->str,
                                default_value->str);
                } else {
+                       non_default_set = true;
                        g_string_append(tmpstr, suffix);
                        append_param_arg(params_arg, tmpstr->str, "yes");
                }
        }
 
                        g_string_append(tmpstr, suffix);
                        append_param_arg(params_arg, tmpstr->str, "yes");
                }
        }
 
+       /* Implicit field-default=hide if any non-default option is set. */
+       if (non_default_set && !default_set) {
+               g_string_assign(tmpstr, prefix);
+               g_string_append(tmpstr, "-default");
+               g_string_assign(default_value, "hide");
+               ret = map_insert_string_or_null(map_obj,
+                               tmpstr->str,
+                               default_value);
+               if (ret) {
+                       print_err_oom();
+                       goto end;
+               }
+       }
+
 end:
        if (default_value) {
                g_string_free(default_value, TRUE);
 end:
        if (default_value) {
                g_string_free(default_value, TRUE);
index db6bae374965178c782b4cf53955c0da294ec569..e742f2184c19236c8ffce7ab9c582e67fb8b741f 100644 (file)
@@ -334,6 +334,7 @@ enum bt_component_status print_event_header(struct text_component *text,
        struct bt_ctf_event_class *event_class = NULL;
        struct bt_ctf_stream_class *stream_class = NULL;
        struct bt_ctf_trace *trace_class = NULL;
        struct bt_ctf_event_class *event_class = NULL;
        struct bt_ctf_stream_class *stream_class = NULL;
        struct bt_ctf_trace *trace_class = NULL;
+       int dom_print = 0;
 
        event_class = bt_ctf_event_get_class(event);
        if (!event_class) {
 
        event_class = bt_ctf_event_get_class(event);
        if (!event_class) {
@@ -350,10 +351,6 @@ enum bt_component_status print_event_header(struct text_component *text,
                ret = BT_COMPONENT_STATUS_ERROR;
                goto end;
        }
                ret = BT_COMPONENT_STATUS_ERROR;
                goto end;
        }
-       if (!text->start_line) {
-               fputs(", ", text->out);
-       }
-       text->start_line = false;
        ret = print_event_timestamp(text, event, &text->start_line);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto end;
        ret = print_event_timestamp(text, event, &text->start_line);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto end;
@@ -366,11 +363,13 @@ enum bt_component_status print_event_header(struct text_component *text,
                        if (!text->start_line) {
                                fputs(", ", text->out);
                        }
                        if (!text->start_line) {
                                fputs(", ", text->out);
                        }
-                       text->start_line = false;
                        if (print_names) {
                                print_name_equal(text, "trace");
                        }
                        fprintf(text->out, "%s", name);
                        if (print_names) {
                                print_name_equal(text, "trace");
                        }
                        fprintf(text->out, "%s", name);
+                       if (!print_names) {
+                               fprintf(text->out, " ");
+                       }
                }
        }
        if (text->options.print_trace_hostname_field) {
                }
        }
        if (text->options.print_trace_hostname_field) {
@@ -384,7 +383,6 @@ enum bt_component_status print_event_header(struct text_component *text,
                        if (!text->start_line) {
                                fputs(", ", text->out);
                        }
                        if (!text->start_line) {
                                fputs(", ", text->out);
                        }
-                       text->start_line = false;
                        if (print_names) {
                                print_name_equal(text, "trace:hostname");
                        }
                        if (print_names) {
                                print_name_equal(text, "trace:hostname");
                        }
@@ -393,6 +391,7 @@ enum bt_component_status print_event_header(struct text_component *text,
                                fprintf(text->out, "%s", str);
                        }
                        bt_put(hostname_str);
                                fprintf(text->out, "%s", str);
                        }
                        bt_put(hostname_str);
+                       dom_print = 1;
                }
        }
        if (text->options.print_trace_domain_field) {
                }
        }
        if (text->options.print_trace_domain_field) {
@@ -406,15 +405,17 @@ enum bt_component_status print_event_header(struct text_component *text,
                        if (!text->start_line) {
                                fputs(", ", text->out);
                        }
                        if (!text->start_line) {
                                fputs(", ", text->out);
                        }
-                       text->start_line = false;
                        if (print_names) {
                                print_name_equal(text, "trace:domain");
                        if (print_names) {
                                print_name_equal(text, "trace:domain");
+                       } else if (dom_print) {
+                               fputs(":", text->out);
                        }
                        if (bt_value_string_get(domain_str, &str)
                                        == BT_VALUE_STATUS_OK) {
                                fprintf(text->out, "%s", str);
                        }
                        bt_put(domain_str);
                        }
                        if (bt_value_string_get(domain_str, &str)
                                        == BT_VALUE_STATUS_OK) {
                                fprintf(text->out, "%s", str);
                        }
                        bt_put(domain_str);
+                       dom_print = 1;
                }
        }
        if (text->options.print_trace_procname_field) {
                }
        }
        if (text->options.print_trace_procname_field) {
@@ -428,15 +429,17 @@ enum bt_component_status print_event_header(struct text_component *text,
                        if (!text->start_line) {
                                fputs(", ", text->out);
                        }
                        if (!text->start_line) {
                                fputs(", ", text->out);
                        }
-                       text->start_line = false;
                        if (print_names) {
                                print_name_equal(text, "trace:procname");
                        if (print_names) {
                                print_name_equal(text, "trace:procname");
+                       } else if (dom_print) {
+                               fputs(":", text->out);
                        }
                        if (bt_value_string_get(procname_str, &str)
                                        == BT_VALUE_STATUS_OK) {
                                fprintf(text->out, "%s", str);
                        }
                        bt_put(procname_str);
                        }
                        if (bt_value_string_get(procname_str, &str)
                                        == BT_VALUE_STATUS_OK) {
                                fprintf(text->out, "%s", str);
                        }
                        bt_put(procname_str);
+                       dom_print = 1;
                }
        }
        if (text->options.print_trace_vpid_field) {
                }
        }
        if (text->options.print_trace_vpid_field) {
@@ -450,15 +453,17 @@ enum bt_component_status print_event_header(struct text_component *text,
                        if (!text->start_line) {
                                fputs(", ", text->out);
                        }
                        if (!text->start_line) {
                                fputs(", ", text->out);
                        }
-                       text->start_line = false;
                        if (print_names) {
                                print_name_equal(text, "trace:vpid");
                        if (print_names) {
                                print_name_equal(text, "trace:vpid");
+                       } else if (dom_print) {
+                               fputs(":", text->out);
                        }
                        if (bt_value_integer_get(vpid_value, &value)
                                        == BT_VALUE_STATUS_OK) {
                                fprintf(text->out, "(%" PRId64 ")", value);
                        }
                        bt_put(vpid_value);
                        }
                        if (bt_value_integer_get(vpid_value, &value)
                                        == BT_VALUE_STATUS_OK) {
                                fprintf(text->out, "(%" PRId64 ")", value);
                        }
                        bt_put(vpid_value);
+                       dom_print = 1;
                }
        }
        if (text->options.print_loglevel_field) {
                }
        }
        if (text->options.print_loglevel_field) {
@@ -474,9 +479,10 @@ enum bt_component_status print_event_header(struct text_component *text,
                        if (!text->start_line) {
                                fputs(", ", text->out);
                        }
                        if (!text->start_line) {
                                fputs(", ", text->out);
                        }
-                       text->start_line = false;
                        if (print_names) {
                                print_name_equal(text, "loglevel");
                        if (print_names) {
                                print_name_equal(text, "loglevel");
+                       } else if (dom_print) {
+                               fputs(":", text->out);
                        }
                        if (loglevel_str) {
                                const char *str;
                        }
                        if (loglevel_str) {
                                const char *str;
@@ -498,6 +504,7 @@ enum bt_component_status print_event_header(struct text_component *text,
                        }
                        bt_put(loglevel_str);
                        bt_put(loglevel_value);
                        }
                        bt_put(loglevel_str);
                        bt_put(loglevel_value);
+                       dom_print = 1;
                }
        }
        if (text->options.print_emf_field) {
                }
        }
        if (text->options.print_emf_field) {
@@ -509,9 +516,10 @@ enum bt_component_status print_event_header(struct text_component *text,
                        if (!text->start_line) {
                                fputs(", ", text->out);
                        }
                        if (!text->start_line) {
                                fputs(", ", text->out);
                        }
-                       text->start_line = false;
                        if (print_names) {
                                print_name_equal(text, "model.emf.uri");
                        if (print_names) {
                                print_name_equal(text, "model.emf.uri");
+                       } else if (dom_print) {
+                               fputs(":", text->out);
                        }
                        if (uri_str) {
                                const char *str;
                        }
                        if (uri_str) {
                                const char *str;
@@ -522,12 +530,16 @@ enum bt_component_status print_event_header(struct text_component *text,
                                }
                        }
                        bt_put(uri_str);
                                }
                        }
                        bt_put(uri_str);
+                       dom_print = 1;
                }
        }
                }
        }
+       if (dom_print && !print_names) {
+               fputs(" ", text->out);
+       }
        if (!text->start_line) {
                fputs(", ", text->out);
        }
        if (!text->start_line) {
                fputs(", ", text->out);
        }
-       text->start_line = false;
+       text->start_line = true;
        if (print_names) {
                print_name_equal(text, "name");
        }
        if (print_names) {
                print_name_equal(text, "name");
        }
@@ -538,6 +550,11 @@ enum bt_component_status print_event_header(struct text_component *text,
        if (text->use_colors) {
                fputs(COLOR_RST, text->out);
        }
        if (text->use_colors) {
                fputs(COLOR_RST, text->out);
        }
+       if (!print_names) {
+               fputs(": ", text->out);
+       } else {
+               fputs(", ", text->out);
+       }
 end:
        bt_put(trace_class);
        bt_put(stream_class);
 end:
        bt_put(trace_class);
        bt_put(stream_class);
@@ -899,6 +916,9 @@ enum bt_component_status print_array_field(struct text_component *text,
                } else {
                        fprintf(text->out, " ");
                }
                } else {
                        fprintf(text->out, " ");
                }
+               if (print_names) {
+                       fprintf(text->out, "[%" PRIu64 "] = ", i);
+               }
        }
        field = bt_ctf_field_array_get_field(array, i);
        if (!field) {
        }
        field = bt_ctf_field_array_get_field(array, i);
        if (!field) {
@@ -1008,6 +1028,9 @@ enum bt_component_status print_sequence_field(struct text_component *text,
                } else {
                        fprintf(text->out, " ");
                }
                } else {
                        fprintf(text->out, " ");
                }
+               if (print_names) {
+                       fprintf(text->out, "[%" PRIu64 "] = ", i);
+               }
        }
        field = bt_ctf_field_sequence_get_field(seq, i);
        if (!field) {
        }
        field = bt_ctf_field_sequence_get_field(seq, i);
        if (!field) {
@@ -1376,9 +1399,11 @@ enum bt_component_status text_print_event(struct text_component *text,
                goto end;
        }
 
                goto end;
        }
 
-       ret = print_event_header_raw(text, event);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
+       if (text->options.verbose) {
+               ret = print_event_header_raw(text, event);
+               if (ret != BT_COMPONENT_STATUS_OK) {
+                       goto end;
+               }
        }
 
        ret = print_stream_event_context(text, event);
        }
 
        ret = print_stream_event_context(text, event);
index 66b476e92f3052062b2ab5337155b0fd7d727dad..3e2727622dca85cef6309ed2cc99103dac71cc39 100644 (file)
@@ -74,6 +74,7 @@ const char *plugin_options[] = {
        "field-trace:vpid",
        "field-loglevel",
        "field-emf",
        "field-trace:vpid",
        "field-loglevel",
        "field-emf",
+       "field-callsite",
 };
 
 static
 };
 
 static
@@ -129,10 +130,8 @@ enum bt_component_status handle_notification(struct text_component *text,
 
        switch (bt_notification_get_type(notification)) {
        case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
 
        switch (bt_notification_get_type(notification)) {
        case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
-               puts("<packet>");
                break;
        case BT_NOTIFICATION_TYPE_PACKET_END:
                break;
        case BT_NOTIFICATION_TYPE_PACKET_END:
-               puts("</packet>");
                break;
        case BT_NOTIFICATION_TYPE_EVENT:
        {
                break;
        case BT_NOTIFICATION_TYPE_EVENT:
        {
@@ -151,7 +150,6 @@ enum bt_component_status handle_notification(struct text_component *text,
                break;
        }
        case BT_NOTIFICATION_TYPE_STREAM_END:
                break;
        }
        case BT_NOTIFICATION_TYPE_STREAM_END:
-               puts("</stream>");
                break;
        default:
                puts("Unhandled notification type");
                break;
        default:
                puts("Unhandled notification type");
@@ -559,7 +557,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_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;
                break;
        case TEXT_DEFAULT_SHOW:
                text->options.print_trace_field = true;
@@ -569,7 +567,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_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;
                break;
        case TEXT_DEFAULT_HIDE:
                text->options.print_trace_field = false;
@@ -579,7 +577,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_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;
                break;
        default:
                ret = BT_COMPONENT_STATUS_ERROR;
@@ -658,12 +656,12 @@ enum bt_component_status apply_params(struct text_component *text,
 
        value = false;
        found = false;
 
        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) {
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto end;
        }
        if (found) {
-               text->options.print_emf_field = value;
+               text->options.print_callsite_field = value;
        }
 
 end:
        }
 
 end:
index 956527607b1ca6819e81f7859c39084a7590ead0..222035e8f1714e72853fc28ffd020ce55d896a71 100644 (file)
@@ -59,6 +59,7 @@ struct text_options {
        bool print_delta_field;
        bool print_loglevel_field;
        bool print_emf_field;
        bool print_delta_field;
        bool print_loglevel_field;
        bool print_emf_field;
+       bool print_callsite_field;
        bool print_trace_field;
        bool print_trace_domain_field;
        bool print_trace_procname_field;
        bool print_trace_field;
        bool print_trace_domain_field;
        bool print_trace_procname_field;
This page took 0.030898 seconds and 4 git commands to generate.