From 6e1bc0df89a0af874e3c1f2617e576cbf5e73cf7 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 31 Oct 2016 11:57:45 -0400 Subject: [PATCH] Text output plugin argument parsing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Implement plugin argument handling, and legacy behavior. The sink plugin uses "name-default=show", "name-default=hide", "field-default=show", and "field-default-hide" to specify the default behavior for names and fields. It is used to implement the compability layer with Babeltrace 1.x (all/none), but is a more flexible approach, because it then allows both use-cases: - default=show: can then set individual items to "false" (blacklist), - default=hide: can then set individual items to "true" (whitelist). In comparison, the old legacy options only allowed to specify a whitelist. Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- converter/babeltrace-cfg.c | 140 ++++++---- include/babeltrace/compiler.h | 2 + plugins/text/print.c | 47 ++-- plugins/text/text.c | 475 +++++++++++++++++++++++++++++++++- plugins/text/text.h | 48 +++- 5 files changed, 623 insertions(+), 89 deletions(-) diff --git a/converter/babeltrace-cfg.c b/converter/babeltrace-cfg.c index ee951bc8..63558694 100644 --- a/converter/babeltrace-cfg.c +++ b/converter/babeltrace-cfg.c @@ -1066,6 +1066,24 @@ GScanner *create_csv_identifiers_scanner(void) return g_scanner_new(&scanner_config); } +/* + * Inserts a string (if exists and not empty) or null to a map value + * object. + */ +static +enum bt_value_status map_insert_string_or_null(struct bt_value *map, + const char *key, GString *string) +{ + enum bt_value_status ret; + + if (string && string->len > 0) { + ret = bt_value_map_insert_string(map, key, string->str); + } else { + ret = bt_value_map_insert(map, key, bt_value_null); + } + return ret; +} + /* * Converts a comma-delimited list of known names (--names option) to * an array value object containing those names as string value objects. @@ -1077,6 +1095,7 @@ struct bt_value *names_from_arg(const char *arg) { GScanner *scanner = NULL; struct bt_value *names = NULL; + bool found_all = false, found_none = false, found_item = false; names = bt_value_array_create(); if (!names) { @@ -1103,40 +1122,37 @@ struct bt_value *names_from_arg(const char *arg) if (!strcmp(identifier, "payload") || !strcmp(identifier, "args") || !strcmp(identifier, "arg")) { + found_item = true; if (bt_value_array_append_string(names, "payload")) { goto error; } } else if (!strcmp(identifier, "context") || !strcmp(identifier, "ctx")) { + found_item = true; if (bt_value_array_append_string(names, "context")) { goto error; } } else if (!strcmp(identifier, "scope") || !strcmp(identifier, "header")) { + found_item = true; if (bt_value_array_append_string(names, identifier)) { goto error; } - } else if (!strcmp(identifier, "all") || - !strcmp(identifier, "none")) { - /* - * "all" and "none" override all the - * specific names. - */ - BT_PUT(names); - names = bt_value_array_create(); - if (!names) { - print_err_oom(); + } else if (!strcmp(identifier, "all")) { + found_all = true; + if (bt_value_array_append_string(names, + identifier)) { goto error; } - + } else if (!strcmp(identifier, "none")) { + found_none = true; if (bt_value_array_append_string(names, identifier)) { goto error; } - goto end; } else { printf_err("Unknown field name: \"%s\"\n", identifier); @@ -1153,12 +1169,27 @@ struct bt_value *names_from_arg(const char *arg) } } - goto end; +end: + if (found_none && found_all) { + printf_err("Only either \"all\" or \"none\" can be specified in the list given to the \"--names\" option, but not both.\n"); + goto error; + } + /* + * Legacy behavior is to clear the defaults (show none) when at + * least one item is specified. + */ + if (found_item && !found_none && !found_all) { + if (bt_value_array_append_string(names, "none")) { + goto error; + } + } + if (scanner) { + g_scanner_destroy(scanner); + } + return names; error: BT_PUT(names); - -end: if (scanner) { g_scanner_destroy(scanner); } @@ -1208,25 +1239,12 @@ struct bt_value *fields_from_arg(const char *arg) !strcmp(identifier, "trace:vpid") || !strcmp(identifier, "loglevel") || !strcmp(identifier, "emf") || - !strcmp(identifier, "callsite")) { - if (bt_value_array_append_string(fields, - identifier)) { - goto error; - } - } else if (!strcmp(identifier, "all")) { - /* "all" override all the specific fields */ - BT_PUT(fields); - fields = bt_value_array_create(); - if (!fields) { - print_err_oom(); - goto error; - } - + !strcmp(identifier, "callsite") || + !strcmp(identifier, "all")) { if (bt_value_array_append_string(fields, identifier)) { goto error; } - goto end; } else { printf_err("Unknown field name: \"%s\"\n", identifier); @@ -1265,7 +1283,7 @@ int insert_flat_names_fields_from_array(struct bt_value *map_obj, { int ret = 0; int i; - GString *tmpstr = NULL; + GString *tmpstr = NULL, *default_value = NULL; /* * array_obj may be NULL if no CLI options were specified to @@ -1282,9 +1300,17 @@ int insert_flat_names_fields_from_array(struct bt_value *map_obj, goto end; } + default_value = g_string_new(NULL); + if (!default_value) { + print_err_oom(); + ret = -1; + goto end; + } + for (i = 0; i < bt_value_array_size(array_obj); i++) { struct bt_value *str_obj = bt_value_array_get(array_obj, i); const char *suffix; + bool is_default = false; if (!str_obj) { printf_err("Unexpected error\n"); @@ -1301,15 +1327,39 @@ int insert_flat_names_fields_from_array(struct bt_value *map_obj, g_string_assign(tmpstr, prefix); g_string_append(tmpstr, "-"); - g_string_append(tmpstr, suffix); - ret = bt_value_map_insert_bool(map_obj, tmpstr->str, true); - if (ret) { - print_err_oom(); - goto end; + + /* Special-case for "all" and "none". */ + if (!strcmp(suffix, "all")) { + is_default = true; + g_string_assign(default_value, "show"); + } else if (!strcmp(suffix, "none")) { + is_default = true; + g_string_assign(default_value, "hide"); + } + if (is_default) { + g_string_append(tmpstr, "default"); + ret = map_insert_string_or_null(map_obj, + tmpstr->str, + default_value); + if (ret) { + print_err_oom(); + goto end; + } + } else { + g_string_append(tmpstr, suffix); + ret = bt_value_map_insert_bool(map_obj, tmpstr->str, + true); + if (ret) { + print_err_oom(); + goto end; + } } } end: + if (default_value) { + g_string_free(default_value, TRUE); + } if (tmpstr) { g_string_free(tmpstr, TRUE); } @@ -1317,24 +1367,6 @@ end: return ret; } -/* - * Inserts a string (if exists and not empty) or null to a map value - * object. - */ -static -enum bt_value_status map_insert_string_or_null(struct bt_value *map, - const char *key, GString *string) -{ - enum bt_value_status ret; - - if (string && string->len > 0) { - ret = bt_value_map_insert_string(map, key, string->str); - } else { - ret = bt_value_map_insert(map, key, bt_value_null); - } - return ret; -} - /* * Returns the parameters (map value object) corresponding to the * legacy text format options. diff --git a/include/babeltrace/compiler.h b/include/babeltrace/compiler.h index 09189bce..4eaa0e6e 100644 --- a/include/babeltrace/compiler.h +++ b/include/babeltrace/compiler.h @@ -37,4 +37,6 @@ }) #endif +#define BT_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) + #endif /* _BABELTRACE_COMPILER_H */ diff --git a/plugins/text/print.c b/plugins/text/print.c index 2b1be1fc..41e2dd2a 100644 --- a/plugins/text/print.c +++ b/plugins/text/print.c @@ -137,6 +137,10 @@ enum bt_component_status print_event_header(struct text_component *text, ret = BT_COMPONENT_STATUS_ERROR; goto end; } + if (!text->start_line) { + fputs(", ", text->out); + } + text->start_line = false; ret = print_event_timestamp(text, event); if (ret != BT_COMPONENT_STATUS_OK) { goto end; @@ -693,8 +697,12 @@ enum bt_component_status print_stream_packet_context(struct text_component *text ret = BT_COMPONENT_STATUS_ERROR; goto end; } + if (!text->start_line) { + fputs(", ", text->out); + } + text->start_line = false; if (text->options.print_scope_field_names) { - fputs(" stream.packet.context = ", text->out); + fputs("stream.packet.context = ", text->out); } ret = print_field(text, main_field, text->options.print_context_field_names); @@ -716,11 +724,15 @@ enum bt_component_status print_event_header_raw(struct text_component *text, ret = BT_COMPONENT_STATUS_ERROR; goto end; } + if (!text->start_line) { + fputs(", ", text->out); + } + text->start_line = false; if (text->options.print_scope_field_names) { - fputs(" stream.event.header = ", text->out); + fputs("stream.event.header = ", text->out); } ret = print_field(text, main_field, - text->options.print_context_field_names); + text->options.print_header_field_names); end: bt_put(main_field); return ret; @@ -738,8 +750,12 @@ enum bt_component_status print_stream_event_context(struct text_component *text, ret = BT_COMPONENT_STATUS_ERROR; goto end; } + if (!text->start_line) { + fputs(", ", text->out); + } + text->start_line = false; if (text->options.print_scope_field_names) { - fputs(" stream.event.context = ", text->out); + fputs("stream.event.context = ", text->out); } ret = print_field(text, main_field, text->options.print_context_field_names); @@ -760,8 +776,12 @@ enum bt_component_status print_event_context(struct text_component *text, ret = BT_COMPONENT_STATUS_ERROR; goto end; } + if (!text->start_line) { + fputs(", ", text->out); + } + text->start_line = false; if (text->options.print_scope_field_names) { - fputs(" event.context = ", text->out); + fputs("event.context = ", text->out); } ret = print_field(text, main_field, text->options.print_context_field_names); @@ -782,8 +802,12 @@ enum bt_component_status print_event_payload(struct text_component *text, ret = BT_COMPONENT_STATUS_ERROR; goto end; } + if (!text->start_line) { + fputs(", ", text->out); + } + text->start_line = false; if (text->options.print_scope_field_names) { - fputs(" event.fields = ", text->out); + fputs("event.fields = ", text->out); } ret = print_field(text, main_field, text->options.print_payload_field_names); @@ -798,40 +822,31 @@ enum bt_component_status text_print_event(struct text_component *text, { enum bt_component_status ret; - //TEST XXX - text->options.print_scope_field_names = true; - text->options.print_payload_field_names = true; - text->options.print_context_field_names = true; - + text->start_line = true; ret = print_event_header(text, event); if (ret != BT_COMPONENT_STATUS_OK) { goto end; } - fputs(",", text->out); ret = print_stream_packet_context(text, event); if (ret != BT_COMPONENT_STATUS_OK) { goto end; } - fputs(",", text->out); ret = print_event_header_raw(text, event); if (ret != BT_COMPONENT_STATUS_OK) { goto end; } - fputs(",", text->out); ret = print_stream_event_context(text, event); if (ret != BT_COMPONENT_STATUS_OK) { goto end; } - fputs(",", text->out); ret = print_event_context(text, event); if (ret != BT_COMPONENT_STATUS_OK) { goto end; } - fputs(",", text->out); ret = print_event_payload(text, event); if (ret != BT_COMPONENT_STATUS_OK) { diff --git a/plugins/text/text.c b/plugins/text/text.c index eca7ed73..da659eeb 100644 --- a/plugins/text/text.c +++ b/plugins/text/text.c @@ -32,11 +32,42 @@ #include #include #include +#include +#include #include #include #include #include "text.h" +#define PLUGIN_NAME "text" + +static +const char *plugin_options[] = { + "output-path", + "debug-info-dir", + "debug-info-target-prefix", + "debug-info-full-path", + "no-delta", + "clock-cycles", + "clock-seconds", + "clock-date", + "clock-gmt", + "name-default", /* show/hide */ + "name-payload", + "name-context", + "name-scope", + "name-header", + "field-default", /* show/hide */ + "field-trace", + "field-trace:hostname", + "field-trace:domain", + "field-trace:procname", + "field-trace:vpid", + "field-loglevel", + "field-emf", + "field-callsite", +}; + static const char *loglevel_str [] = { [LOGLEVEL_EMERG] = "TRACE_EMERG", @@ -60,6 +91,9 @@ static void destroy_text_data(struct text_component *text) { (void) g_string_free(text->string, TRUE); + g_free(text->options.output_path); + g_free(text->options.debug_info_dir); + g_free(text->options.debug_info_target_prefix); g_free(text); } @@ -94,7 +128,7 @@ void destroy_text(struct bt_component *component) static enum bt_component_status handle_notification(struct text_component *text, - struct bt_notification *notification) + struct bt_notification *notification) { enum bt_component_status ret = BT_COMPONENT_STATUS_OK; @@ -171,9 +205,433 @@ end: return ret; } +static +enum bt_component_status add_params_to_map(struct bt_value *plugin_opt_map) +{ + enum bt_component_status ret = BT_COMPONENT_STATUS_OK; + unsigned int i; + + for (i = 0; i < BT_ARRAY_SIZE(plugin_options); i++) { + const char *key = plugin_options[i]; + enum bt_value_status status; + + status = bt_value_map_insert(plugin_opt_map, key, bt_value_null); + switch (status) { + case BT_VALUE_STATUS_OK: + break; + default: + ret = BT_COMPONENT_STATUS_ERROR; + goto end; + } + } +end: + return ret; +} + +static +bool check_param_exists(const char *key, struct bt_value *object, void *data) +{ + struct text_component *text = data; + struct bt_value *plugin_opt_map = text->plugin_opt_map; + + if (!bt_value_map_get(plugin_opt_map, key)) { + fprintf(text->err, + "[warning] Parameter \"%s\" unknown to \"%s\" plugin\n", + key, PLUGIN_NAME); + } + return true; +} + +static +enum bt_component_status apply_one_string(const char *key, + struct bt_value *params, + char **option) +{ + enum bt_component_status ret = BT_COMPONENT_STATUS_OK; + struct bt_value *value = NULL; + enum bt_value_status status; + const char *str; + + value = bt_value_map_get(params, key); + if (!value) { + goto end; + } + if (bt_value_is_null(value)) { + goto end; + } + status = bt_value_string_get(value, &str); + switch (status) { + case BT_VALUE_STATUS_OK: + break; + default: + ret = BT_COMPONENT_STATUS_ERROR; + goto end; + } + *option = g_strdup(str); +end: + bt_put(value); + return ret; +} + +static +enum bt_component_status apply_one_bool(const char *key, + struct bt_value *params, + bool *option, + bool *found) +{ + enum bt_component_status ret = BT_COMPONENT_STATUS_OK; + struct bt_value *value = NULL; + enum bt_value_status status; + + value = bt_value_map_get(params, key); + if (!value) { + goto end; + } + status = bt_value_bool_get(value, option); + switch (status) { + case BT_VALUE_STATUS_OK: + break; + default: + ret = BT_COMPONENT_STATUS_ERROR; + goto end; + } + if (found) { + *found = true; + } +end: + bt_put(value); + return ret; +} + +static +enum bt_component_status apply_params(struct text_component *text, + struct bt_value *params) +{ + enum bt_component_status ret = BT_COMPONENT_STATUS_OK; + enum bt_value_status status; + bool value, found; + char *str = NULL; + + text->plugin_opt_map = bt_value_map_create(); + if (!text->plugin_opt_map) { + ret = BT_COMPONENT_STATUS_ERROR; + goto end; + } + ret = add_params_to_map(text->plugin_opt_map); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + /* Report unknown parameters. */ + status = bt_value_map_foreach(params, check_param_exists, text); + switch (status) { + case BT_VALUE_STATUS_OK: + break; + default: + ret = BT_COMPONENT_STATUS_ERROR; + goto end; + } + /* Known parameters. */ + ret = apply_one_string("output-path", + params, + &text->options.output_path); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + + ret = apply_one_string("debug-info-dir", + params, + &text->options.debug_info_dir); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + + ret = apply_one_string("debug-info-target-prefix", + params, + &text->options.debug_info_target_prefix); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + + value = false; /* Default. */ + ret = apply_one_bool("debug-info-full-path", params, &value, NULL); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + text->options.debug_info_full_path = value; + + value = false; /* Default. */ + ret = apply_one_bool("no-delta", params, &value, NULL); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + text->options.print_delta_field = !value; /* Reverse logic. */ + + value = false; /* Default. */ + ret = apply_one_bool("clock-cycles", params, &value, NULL); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + text->options.print_timestamp_cycles = value; + + value = false; /* Default. */ + ret = apply_one_bool("clock-seconds", params, &value, NULL); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + text->options.clock_seconds = value; + + value = false; /* Default. */ + ret = apply_one_bool("clock-date", params, &value, NULL); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + text->options.clock_date = value; + + value = false; /* Default. */ + ret = apply_one_bool("clock-gmt", params, &value, NULL); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + text->options.clock_gmt = value; + + /* Names. */ + ret = apply_one_string("name-default", params, &str); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + if (!str) { + text->options.name_default = TEXT_DEFAULT_UNSET; + } else if (!strcmp(str, "show")) { + text->options.name_default = TEXT_DEFAULT_SHOW; + } else if (!strcmp(str, "hide")) { + text->options.name_default = TEXT_DEFAULT_HIDE; + } else { + ret = BT_COMPONENT_STATUS_ERROR; + goto end; + } + g_free(str); + str = NULL; + + switch (text->options.name_default) { + case TEXT_DEFAULT_UNSET: + text->options.print_payload_field_names = true; + text->options.print_context_field_names = true; + text->options.print_header_field_names = false; + text->options.print_scope_field_names = false; + break; + case TEXT_DEFAULT_SHOW: + text->options.print_payload_field_names = true; + text->options.print_context_field_names = true; + text->options.print_header_field_names = true; + text->options.print_scope_field_names = true; + break; + case TEXT_DEFAULT_HIDE: + text->options.print_payload_field_names = false; + text->options.print_context_field_names = false; + text->options.print_header_field_names = false; + text->options.print_scope_field_names = false; + break; + default: + ret = BT_COMPONENT_STATUS_ERROR; + goto end; + } + + value = false; + found = false; + ret = apply_one_bool("name-payload", params, &value, &found); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + if (found) { + text->options.print_payload_field_names = value; + } + + value = false; + found = false; + ret = apply_one_bool("name-context", params, &value, &found); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + if (found) { + text->options.print_context_field_names = value; + } + + value = false; + found = false; + ret = apply_one_bool("name-header", params, &value, &found); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + if (found) { + text->options.print_header_field_names = value; + } + + value = false; + found = false; + ret = apply_one_bool("name-scope", params, &value, &found); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + if (found) { + text->options.print_scope_field_names = value; + } + + /* Fields. */ + ret = apply_one_string("field-default", params, &str); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + if (!str) { + text->options.field_default = TEXT_DEFAULT_UNSET; + } else if (!strcmp(str, "show")) { + text->options.field_default = TEXT_DEFAULT_SHOW; + } else if (!strcmp(str, "hide")) { + text->options.field_default = TEXT_DEFAULT_HIDE; + } else { + ret = BT_COMPONENT_STATUS_ERROR; + goto end; + } + g_free(str); + str = NULL; + + switch (text->options.field_default) { + case TEXT_DEFAULT_UNSET: + text->options.print_trace_field = false; + text->options.print_trace_hostname_field = true; + text->options.print_trace_domain_field = false; + text->options.print_trace_procname_field = true; + 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; + text->options.print_trace_hostname_field = true; + text->options.print_trace_domain_field = true; + text->options.print_trace_procname_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; + text->options.print_trace_hostname_field = false; + text->options.print_trace_domain_field = false; + text->options.print_trace_procname_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; + goto end; + } + + value = false; + found = false; + ret = apply_one_bool("field-trace", params, &value, &found); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + if (found) { + text->options.print_trace_field = value; + } + + value = false; + found = false; + ret = apply_one_bool("field-trace:hostname", params, &value, &found); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + if (found) { + text->options.print_trace_hostname_field = value; + } + + value = false; + found = false; + ret = apply_one_bool("field-trace:domain", params, &value, &found); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + if (found) { + text->options.print_trace_domain_field = value; + } + + value = false; + found = false; + ret = apply_one_bool("field-trace:procname", params, &value, &found); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + if (found) { + text->options.print_trace_procname_field = value; + } + + value = false; + found = false; + ret = apply_one_bool("field-trace:vpid", params, &value, &found); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + if (found) { + text->options.print_trace_vpid_field = value; + } + + value = false; + found = false; + ret = apply_one_bool("field-loglevel", params, &value, &found); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + if (found) { + text->options.print_loglevel_field = value; + } + + value = false; + found = false; + ret = apply_one_bool("field-emf", params, &value, &found); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + if (found) { + text->options.print_emf_field = value; + } + + value = false; + found = false; + ret = apply_one_bool("field-emf", params, &value, &found); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + if (found) { + 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; + g_free(str); + return ret; +} + static enum bt_component_status text_component_init( - struct bt_component *component, struct bt_value *params) + struct bt_component *component, struct bt_value *params) { enum bt_component_status ret; struct text_component *text = create_text(); @@ -183,6 +641,14 @@ enum bt_component_status text_component_init( goto end; } + text->out = stdout; + text->err = stderr; + + ret = apply_params(text, params); + if (ret != BT_COMPONENT_STATUS_OK) { + goto error; + } + ret = bt_component_set_destroy_cb(component, destroy_text); if (ret != BT_COMPONENT_STATUS_OK) { @@ -199,9 +665,6 @@ enum bt_component_status text_component_init( if (ret != BT_COMPONENT_STATUS_OK) { goto error; } - - text->out = stdout; - text->err = stderr; end: return ret; error: @@ -216,7 +679,7 @@ BT_PLUGIN_AUTHOR("Jérémie Galarneau"); BT_PLUGIN_LICENSE("MIT"); BT_PLUGIN_COMPONENT_CLASSES_BEGIN -BT_PLUGIN_SINK_COMPONENT_CLASS_ENTRY("text", +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 diff --git a/plugins/text/text.h b/plugins/text/text.h index 5804b59b..f1ff92df 100644 --- a/plugins/text/text.h +++ b/plugins/text/text.h @@ -49,20 +49,40 @@ enum loglevel { LOGLEVEL_DEBUG = 14, }; +enum text_default { + TEXT_DEFAULT_UNSET, + TEXT_DEFAULT_SHOW, + TEXT_DEFAULT_HIDE, +}; + struct text_options { - bool print_scope_field_names : 1; - bool print_header_field_names : 1; - bool print_context_field_names : 1; - bool print_payload_field_names : 1; - bool print_delta_field : 1; - bool print_loglevel_field : 1; - bool print_trace_field : 1; - bool print_trace_domain_field : 1; - bool print_trace_procname_field : 1; - bool print_trace_vpid_field : 1; - bool print_trace_hostname_field : 1; - bool print_timestamp_cycles : 1; - bool no_size_limit : 1; + char *output_path; + char *debug_info_dir; + char *debug_info_target_prefix; + + enum text_default name_default; + enum text_default field_default; + + bool print_scope_field_names; + bool print_header_field_names; + bool print_context_field_names; + bool print_payload_field_names; + + 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_vpid_field; + bool print_trace_hostname_field; + + bool print_timestamp_cycles; + bool clock_seconds; + bool clock_date; + bool clock_gmt; + bool debug_info_full_path; }; struct text_component { @@ -71,7 +91,9 @@ struct text_component { bool processed_first_event; uint64_t last_real_timestamp; int depth; /* nesting, used for tabulation alignment. */ + bool start_line; GString *string; + struct bt_value *plugin_opt_map; /* Temporary parameter map. */ }; BT_HIDDEN -- 2.34.1