g_string_free(bt_config_component->component_name, TRUE);
}
+ if (bt_config_component->instance_name) {
+ g_string_free(bt_config_component->instance_name, TRUE);
+ }
+
BT_PUT(bt_config_component->params);
g_free(bt_config_component);
goto error;
}
+ cfg_component->instance_name = g_string_new(NULL);
+ if (!cfg_component->instance_name) {
+ print_err_oom();
+ goto error;
+ }
+
/* Start with empty parameters */
cfg_component->params = bt_value_map_create();
if (!cfg_component->params) {
OPT_HELP,
OPT_INPUT_FORMAT,
OPT_LIST,
+ OPT_NAME,
OPT_NAMES,
OPT_NO_DELTA,
OPT_OMIT_HOME_PLUGIN_PATH,
fprintf(fp, " --end=END Set the `end` parameter of the latest\n");
fprintf(fp, " source component instance to END\n");
fprintf(fp, " (see the suggested format of BEGIN below)\n");
+ fprintf(fp, " --name=NAME Set the name of the latest component\n");
+ fprintf(fp, " instance to NAME (must be unique amongst\n");
+ fprintf(fp, " all the names of the component instances)\n");
fprintf(fp, " --omit-home-plugin-path Omit home plugins from plugin search path\n");
fprintf(fp, " (~/.local/lib/babeltrace/plugins)\n");
fprintf(fp, " --omit-system-plugin-path Omit system plugins from plugin search path\n");
{ "fields", 'f', POPT_ARG_STRING, NULL, OPT_FIELDS, NULL, NULL },
{ "help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL },
{ "input-format", 'i', POPT_ARG_STRING, NULL, OPT_INPUT_FORMAT, NULL, NULL },
+ { "name", '\0', POPT_ARG_STRING, NULL, OPT_NAME, NULL, NULL },
{ "names", 'n', POPT_ARG_STRING, NULL, OPT_NAMES, NULL, NULL },
{ "no-delta", '\0', POPT_ARG_NONE, NULL, OPT_NO_DELTA, NULL, NULL },
{ "omit-home-plugin-path", '\0', POPT_ARG_NONE, NULL, OPT_OMIT_HOME_PLUGIN_PATH, NULL, NULL },
struct bt_value *cur_base_params = NULL;
int opt, ret = 0;
struct bt_config *cfg = NULL;
+ struct bt_value *instance_names = NULL;
*retcode = 0;
memset(&ctf_legacy_opts, 0, sizeof(ctf_legacy_opts));
goto error;
}
+ instance_names = bt_value_map_create();
+ if (!instance_names) {
+ print_err_oom();
+ goto error;
+ }
+
ret = append_env_var_plugin_paths(cfg->cmd_data.convert.plugin_paths);
if (ret) {
printf_err("Cannot append plugin paths from BABELTRACE_PLUGIN_PATH\n");
goto error;
}
break;
+ case OPT_NAME:
+ if (!cur_cfg_comp) {
+ printf_err("Cannot set the name of unavailable default source component `%s`:\n %s\n",
+ DEFAULT_SOURCE_COMPONENT_NAME, arg);
+ goto error;
+ }
+
+ if (bt_value_map_has_key(instance_names, arg)) {
+ printf_err("Duplicate component instance name:\n %s\n",
+ arg);
+ goto error;
+ }
+
+ g_string_assign(cur_cfg_comp->instance_name, arg);
+
+ if (bt_value_map_insert(instance_names,
+ arg, bt_value_null)) {
+ print_err_oom();
+ goto error;
+ }
+ break;
case OPT_BASE_PARAMS:
{
struct bt_value *params = bt_value_from_arg(arg);
BT_PUT(text_legacy_opts.names);
BT_PUT(text_legacy_opts.fields);
BT_PUT(legacy_input_paths);
+ BT_PUT(instance_names);
return cfg;
}