X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=converter%2Fbabeltrace-cfg.c;h=6e07a43749822a3d705360e6f3e5a3aceea5a5b8;hb=63ce0e1d658d528f48fd0f16d5a6748c1b369ef1;hp=807dcdc9c82acd5feb3130efd452ac3c1edfbfc6;hpb=ebba3338a91f2b439a50d41f97e9fb4b76cbe29f;p=babeltrace.git diff --git a/converter/babeltrace-cfg.c b/converter/babeltrace-cfg.c index 807dcdc9..6e07a437 100644 --- a/converter/babeltrace-cfg.c +++ b/converter/babeltrace-cfg.c @@ -732,8 +732,9 @@ end: * Return value is owned by the caller. */ static -struct bt_config_component *bt_config_component_create(const char *plugin_name, - const char *component_name) +struct bt_config_component *bt_config_component_create( + enum bt_component_class_type type, + const char *plugin_name, const char *component_name) { struct bt_config_component *cfg_component = NULL; @@ -744,6 +745,7 @@ struct bt_config_component *bt_config_component_create(const char *plugin_name, } bt_object_init(cfg_component, bt_config_component_destroy); + cfg_component->type = type; cfg_component->plugin_name = g_string_new(plugin_name); if (!cfg_component->plugin_name) { print_err_oom(); @@ -782,7 +784,8 @@ end: * Creates a component configuration from a command-line source/sink * option's argument. */ -struct bt_config_component *bt_config_component_from_arg(const char *arg) +struct bt_config_component *bt_config_component_from_arg( + enum bt_component_class_type type, const char *arg) { struct bt_config_component *bt_config_component = NULL; char *plugin_name; @@ -794,7 +797,7 @@ struct bt_config_component *bt_config_component_from_arg(const char *arg) goto error; } - bt_config_component = bt_config_component_create(plugin_name, + bt_config_component = bt_config_component_create(type, plugin_name, component_name); if (!bt_config_component) { goto error; @@ -850,13 +853,14 @@ void bt_config_destroy(struct bt_object *obj) break; case BT_CONFIG_COMMAND_HELP: BT_PUT(cfg->cmd_data.help.plugin_paths); + BT_PUT(cfg->cmd_data.help.cfg_component); + break; + case BT_CONFIG_COMMAND_QUERY_INFO: + BT_PUT(cfg->cmd_data.query_info.plugin_paths); + BT_PUT(cfg->cmd_data.query_info.cfg_component); - if (cfg->cmd_data.help.plugin_name) { - g_string_free(cfg->cmd_data.help.plugin_name, TRUE); - } - - if (cfg->cmd_data.help.component_name) { - g_string_free(cfg->cmd_data.help.component_name, TRUE); + if (cfg->cmd_data.query_info.action) { + g_string_free(cfg->cmd_data.query_info.action, TRUE); } break; default: @@ -1362,7 +1366,7 @@ int append_sinks_from_legacy_opts(GPtrArray *sinks, component_name = "metadata-text"; break; case LEGACY_OUTPUT_FORMAT_DUMMY: - plugin_name = "dummy"; + plugin_name = "utils"; component_name = "dummy"; break; default: @@ -1389,8 +1393,8 @@ int append_sinks_from_legacy_opts(GPtrArray *sinks, } /* Create a component configuration */ - bt_config_component = bt_config_component_create(plugin_name, - component_name); + bt_config_component = bt_config_component_create( + BT_COMPONENT_CLASS_TYPE_SINK, plugin_name, component_name); if (!bt_config_component) { goto error; } @@ -1518,8 +1522,8 @@ int append_sources_from_legacy_opts(GPtrArray *sources, } /* Create a component configuration */ - bt_config_component = bt_config_component_create("ctf", - component_name); + bt_config_component = bt_config_component_create( + BT_COMPONENT_CLASS_TYPE_SOURCE, "ctf", component_name); if (!bt_config_component) { goto error; } @@ -1683,7 +1687,7 @@ void print_output_legacy_to_sinks( enum legacy_output_format legacy_output_format, struct text_legacy_opts *text_legacy_opts) { - const char *input_format; + const char *output_format; GString *str = NULL; str = g_string_new(" "); @@ -1694,22 +1698,22 @@ void print_output_legacy_to_sinks( switch (legacy_output_format) { case LEGACY_OUTPUT_FORMAT_TEXT: - input_format = "text"; + output_format = "text"; break; case LEGACY_OUTPUT_FORMAT_CTF_METADATA: - input_format = "ctf-metadata"; + output_format = "ctf-metadata"; break; case LEGACY_OUTPUT_FORMAT_DUMMY: - input_format = "dummy"; + output_format = "dummy"; break; default: assert(false); } printf_err("Both `%s` legacy output format and non-legacy sink component\ninstances(s) specified.\n\n", - input_format); + output_format); printf_err("Specify the following non-legacy sink component instance instead of the\nlegacy `%s` output format options:\n\n", - input_format); + output_format); g_string_append(str, "-o "); switch (legacy_output_format) { @@ -1720,7 +1724,7 @@ void print_output_legacy_to_sinks( g_string_append(str, "ctf.metadata-text"); break; case LEGACY_OUTPUT_FORMAT_DUMMY: - g_string_append(str, "dummy.dummy"); + g_string_append(str, "utils.dummy"); break; default: assert(false); @@ -2320,14 +2324,49 @@ static struct bt_config *bt_config_help_create( } } - cfg->cmd_data.help.plugin_name = g_string_new(NULL); - if (!cfg->cmd_data.help.plugin_name) { + cfg->cmd_data.help.cfg_component = + bt_config_component_create(BT_COMPONENT_CLASS_TYPE_UNKNOWN, + NULL, NULL); + if (!cfg->cmd_data.help.cfg_component) { print_err_oom(); goto error; } - cfg->cmd_data.help.component_name = g_string_new(NULL); - if (!cfg->cmd_data.help.component_name) { + goto end; + +error: + BT_PUT(cfg); + +end: + return cfg; +} + +static struct bt_config *bt_config_query_info_create( + struct bt_value *initial_plugin_paths) +{ + struct bt_config *cfg; + + /* Create config */ + cfg = bt_config_base_create(BT_CONFIG_COMMAND_QUERY_INFO); + if (!cfg) { + print_err_oom(); + goto error; + } + + if (initial_plugin_paths) { + cfg->cmd_data.query_info.plugin_paths = + bt_get(initial_plugin_paths); + } else { + cfg->cmd_data.query_info.plugin_paths = + bt_value_array_create(); + if (!cfg->cmd_data.query_info.plugin_paths) { + print_err_oom(); + goto error; + } + } + + cfg->cmd_data.query_info.action = g_string_new(NULL); + if (!cfg->cmd_data.query_info.action) { print_err_oom(); goto error; } @@ -2341,6 +2380,44 @@ end: return cfg; } +/* + * Prints the expected format for a --params option. + */ +static +void print_expected_params_format(FILE *fp) +{ + fprintf(fp, "Expected format of PARAMS\n"); + fprintf(fp, "-------------------------\n"); + fprintf(fp, "\n"); + fprintf(fp, " PARAM=VALUE[,PARAM=VALUE]...\n"); + fprintf(fp, "\n"); + fprintf(fp, "The parameter string is a comma-separated list of PARAM=VALUE assignments,\n"); + fprintf(fp, "where PARAM is the parameter name (C identifier plus [:.-] characters), and\n"); + fprintf(fp, "VALUE can be one of:\n"); + fprintf(fp, "\n"); + fprintf(fp, "* `null`, `nul`, `NULL`: null value (no backticks).\n"); + fprintf(fp, "* `true`, `TRUE`, `yes`, `YES`: true boolean value (no backticks).\n"); + fprintf(fp, "* `false`, `FALSE`, `no`, `NO`: false boolean value (no backticks).\n"); + fprintf(fp, "* Binary (`0b` prefix), octal (`0` prefix), decimal, or hexadecimal\n"); + fprintf(fp, " (`0x` prefix) signed 64-bit integer.\n"); + fprintf(fp, "* Double precision floating point number (scientific notation is accepted).\n"); + fprintf(fp, "* Unquoted string with no special characters, and not matching any of\n"); + fprintf(fp, " the null and boolean value symbols above.\n"); + fprintf(fp, "* Double-quoted string (accepts escape characters).\n"); + fprintf(fp, "\n"); + fprintf(fp, "Whitespaces are allowed around individual `=` and `,` tokens.\n"); + fprintf(fp, "\n"); + fprintf(fp, "Example:\n"); + fprintf(fp, "\n"); + fprintf(fp, " many=null, fresh=yes, condition=false, squirrel=-782329,\n"); + fprintf(fp, " observe=3.14, simple=beef, needs-quotes=\"some string\",\n"); + fprintf(fp, " escape.chars-are:allowed=\"this is a \\\" double quote\"\n"); + fprintf(fp, "\n"); + fprintf(fp, "IMPORTANT: Make sure to single-quote the whole argument when you run babeltrace\n"); + fprintf(fp, "from a shell.\n"); +} + + /* * Prints the help command usage. */ @@ -2348,9 +2425,9 @@ static void print_help_usage(FILE *fp) { fprintf(fp, "Usage: babeltrace [GENERAL OPTIONS] help [OPTIONS] PLUGIN\n"); - fprintf(fp, " babeltrace [GENERAL OPTIONS] help [OPTIONS] --source PLUGIN.COMPCLS\n"); - fprintf(fp, " babeltrace [GENERAL OPTIONS] help [OPTIONS] --filter PLUGIN.COMPCLS\n"); - fprintf(fp, " babeltrace [GENERAL OPTIONS] help [OPTIONS] --sink PLUGIN.COMPCLS\n"); + fprintf(fp, " babeltrace [GENERAL OPTIONS] help [OPTIONS] --source=PLUGIN.COMPCLS\n"); + fprintf(fp, " babeltrace [GENERAL OPTIONS] help [OPTIONS] --filter=PLUGIN.COMPCLS\n"); + fprintf(fp, " babeltrace [GENERAL OPTIONS] help [OPTIONS] --sink=PLUGIN.COMPCLS\n"); fprintf(fp, "\n"); fprintf(fp, "Options:\n"); fprintf(fp, "\n"); @@ -2411,7 +2488,6 @@ struct bt_config *bt_config_help_from_args(int argc, const char *argv[], goto error; } - cfg->cmd_data.help.comp_cls_type = BT_COMPONENT_CLASS_TYPE_UNKNOWN; cfg->cmd_data.help.omit_system_plugin_path = omit_system_plugin_path; cfg->cmd_data.help.omit_home_plugin_path = omit_home_plugin_path; ret = append_env_var_plugin_paths(cfg->cmd_data.help.plugin_paths); @@ -2456,7 +2532,7 @@ struct bt_config *bt_config_help_from_args(int argc, const char *argv[], case OPT_SOURCE: case OPT_FILTER: case OPT_SINK: - if (cfg->cmd_data.help.comp_cls_type != + if (cfg->cmd_data.help.cfg_component->type != BT_COMPONENT_CLASS_TYPE_UNKNOWN) { printf_err("Cannot specify more than one plugin and component class:\n %s\n", arg); @@ -2465,15 +2541,15 @@ struct bt_config *bt_config_help_from_args(int argc, const char *argv[], switch (opt) { case OPT_SOURCE: - cfg->cmd_data.help.comp_cls_type = + cfg->cmd_data.help.cfg_component->type = BT_COMPONENT_CLASS_TYPE_SOURCE; break; case OPT_FILTER: - cfg->cmd_data.help.comp_cls_type = + cfg->cmd_data.help.cfg_component->type = BT_COMPONENT_CLASS_TYPE_FILTER; break; case OPT_SINK: - cfg->cmd_data.help.comp_cls_type = + cfg->cmd_data.help.cfg_component->type = BT_COMPONENT_CLASS_TYPE_SINK; break; default: @@ -2509,16 +2585,17 @@ struct bt_config *bt_config_help_from_args(int argc, const char *argv[], leftover = poptGetArg(pc); if (leftover) { - if (cfg->cmd_data.help.comp_cls_type != + if (cfg->cmd_data.help.cfg_component->type != BT_COMPONENT_CLASS_TYPE_UNKNOWN) { printf_err("Cannot specify plugin name and --source/--filter/--sink component class:\n %s\n", leftover); goto error; } - g_string_assign(cfg->cmd_data.help.plugin_name, leftover); + g_string_assign(cfg->cmd_data.help.cfg_component->plugin_name, + leftover); } else { - if (cfg->cmd_data.help.comp_cls_type == + if (cfg->cmd_data.help.cfg_component->type == BT_COMPONENT_CLASS_TYPE_UNKNOWN) { print_help_usage(stdout); *retcode = -1; @@ -2529,8 +2606,9 @@ struct bt_config *bt_config_help_from_args(int argc, const char *argv[], plugin_component_names_from_arg(plugin_comp_cls_names, &plugin_name, &component_name); if (plugin_name && component_name) { - g_string_assign(cfg->cmd_data.help.plugin_name, plugin_name); - g_string_assign(cfg->cmd_data.help.component_name, + g_string_assign(cfg->cmd_data.help.cfg_component->plugin_name, + plugin_name); + g_string_assign(cfg->cmd_data.help.cfg_component->component_name, component_name); } else { printf_err("Invalid --source/--filter/--sink option's argument:\n %s\n", @@ -2566,6 +2644,246 @@ end: return cfg; } +/* + * Prints the help command usage. + */ +static +void print_query_info_usage(FILE *fp) +{ + fprintf(fp, "Usage: babeltrace [GEN OPTS] query-info [OPTS] ACTION --source=PLUGIN.COMPCLS\n"); + fprintf(fp, " babeltrace [GEN OPTS] query-info [OPTS] ACTION --filter=PLUGIN.COMPCLS\n"); + fprintf(fp, " babeltrace [GEN OPTS] query-info [OPTS] ACTION --sink=PLUGIN.COMPCLS\n"); + fprintf(fp, "\n"); + fprintf(fp, "Options:\n"); + fprintf(fp, "\n"); + fprintf(fp, " --filter=PLUGIN.COMPCLS Query info from the filter component class\n"); + fprintf(fp, " COMPCLS found in the plugin PLUGIN\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"); + fprintf(fp, " -p, --params=PARAMS Set the query parameters to PARAMS\n"); + fprintf(fp, " (see the expected format of PARAMS below)\n"); + fprintf(fp, " --plugin-path=PATH[:PATH]... Add PATH to the list of paths from which\n"); + fprintf(fp, " dynamic plugins can be loaded\n"); + fprintf(fp, " --sink=PLUGIN.COMPCLS Query info from the sink component class\n"); + fprintf(fp, " COMPCLS found in the plugin PLUGIN\n"); + fprintf(fp, " --source=PLUGIN.COMPCLS Query info from the source component class\n"); + fprintf(fp, " COMPCLS found in the plugin PLUGIN\n"); + fprintf(fp, " -h --help Show this help and quit\n"); + fprintf(fp, "\n\n"); + print_expected_params_format(fp); +} + +static struct poptOption query_info_long_options[] = { + /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */ + { "filter", '\0', POPT_ARG_STRING, NULL, OPT_FILTER, NULL, NULL }, + { "help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL }, + { "omit-home-plugin-path", '\0', POPT_ARG_NONE, NULL, OPT_OMIT_HOME_PLUGIN_PATH, NULL, NULL }, + { "omit-system-plugin-path", '\0', POPT_ARG_NONE, NULL, OPT_OMIT_SYSTEM_PLUGIN_PATH, NULL, NULL }, + { "params", 'p', POPT_ARG_STRING, NULL, OPT_PARAMS, NULL, NULL }, + { "plugin-path", '\0', POPT_ARG_STRING, NULL, OPT_PLUGIN_PATH, NULL, NULL }, + { "sink", '\0', POPT_ARG_STRING, NULL, OPT_SINK, NULL, NULL }, + { "source", '\0', POPT_ARG_STRING, NULL, OPT_SOURCE, NULL, NULL }, + { NULL, 0, 0, NULL, 0, NULL, NULL }, +}; + +/* + * Creates a Babeltrace config object from the arguments of a query-info + * command. + * + * *retcode is set to the appropriate exit code to use. + */ +struct bt_config *bt_config_query_info_from_args(int argc, const char *argv[], + int *retcode, bool omit_system_plugin_path, + bool omit_home_plugin_path, + struct bt_value *initial_plugin_paths) +{ + poptContext pc = NULL; + char *arg = NULL; + int opt; + int ret; + struct bt_config *cfg = NULL; + const char *leftover; + struct bt_value *params = bt_value_null; + + *retcode = 0; + cfg = bt_config_query_info_create(initial_plugin_paths); + if (!cfg) { + print_err_oom(); + goto error; + } + + cfg->cmd_data.query_info.omit_system_plugin_path = + omit_system_plugin_path; + cfg->cmd_data.query_info.omit_home_plugin_path = omit_home_plugin_path; + ret = append_env_var_plugin_paths(cfg->cmd_data.query_info.plugin_paths); + if (ret) { + printf_err("Cannot append plugin paths from BABELTRACE_PLUGIN_PATH\n"); + goto error; + } + + /* Parse options */ + pc = poptGetContext(NULL, argc, (const char **) argv, + query_info_long_options, 0); + if (!pc) { + printf_err("Cannot get popt context\n"); + goto error; + } + + poptReadDefaultConfig(pc, 0); + + while ((opt = poptGetNextOpt(pc)) > 0) { + arg = poptGetOptArg(pc); + + switch (opt) { + case OPT_PLUGIN_PATH: + if (bt_common_is_setuid_setgid()) { + printf_debug("Skipping non-system plugin paths for setuid/setgid binary\n"); + } else { + if (bt_config_append_plugin_paths( + cfg->cmd_data.query_info.plugin_paths, + arg)) { + printf_err("Invalid --plugin-path option's argument:\n %s\n", + arg); + goto error; + } + } + break; + case OPT_OMIT_SYSTEM_PLUGIN_PATH: + cfg->cmd_data.query_info.omit_system_plugin_path = true; + break; + case OPT_OMIT_HOME_PLUGIN_PATH: + cfg->cmd_data.query_info.omit_home_plugin_path = true; + break; + case OPT_SOURCE: + case OPT_FILTER: + case OPT_SINK: + { + enum bt_component_class_type type; + + if (cfg->cmd_data.query_info.cfg_component) { + printf_err("Cannot specify more than one plugin and component class:\n %s\n", + arg); + goto error; + } + + switch (opt) { + case OPT_SOURCE: + type = BT_COMPONENT_CLASS_TYPE_SOURCE; + break; + case OPT_FILTER: + type = BT_COMPONENT_CLASS_TYPE_FILTER; + break; + case OPT_SINK: + type = BT_COMPONENT_CLASS_TYPE_SINK; + break; + default: + assert(false); + } + + cfg->cmd_data.query_info.cfg_component = + bt_config_component_from_arg(type, arg); + if (!cfg->cmd_data.query_info.cfg_component) { + printf_err("Invalid format for --source/--filter/--sink option's argument:\n %s\n", + arg); + goto error; + } + + /* Default parameters: null */ + bt_put(cfg->cmd_data.query_info.cfg_component->params); + cfg->cmd_data.query_info.cfg_component->params = + bt_value_null; + break; + } + case OPT_PARAMS: + { + params = bt_value_from_arg(arg); + if (!params) { + printf_err("Invalid format for --params option's argument:\n %s\n", + arg); + goto error; + } + break; + } + case OPT_HELP: + print_query_info_usage(stdout); + *retcode = -1; + BT_PUT(cfg); + goto end; + default: + printf_err("Unknown command-line option specified (option code %d)\n", + opt); + goto error; + } + + free(arg); + arg = NULL; + } + + if (!cfg->cmd_data.query_info.cfg_component) { + printf_err("No target component class specified with --source/--filter/--sink option\n"); + goto error; + } + + assert(params); + BT_MOVE(cfg->cmd_data.query_info.cfg_component->params, params); + + /* Check for option parsing error */ + if (opt < -1) { + printf_err("While parsing command-line options, at option %s: %s\n", + poptBadOption(pc, 0), poptStrerror(opt)); + goto error; + } + + /* + * We need exactly one leftover argument which is the + * mandatory action. + */ + leftover = poptGetArg(pc); + if (leftover) { + if (strlen(leftover) == 0) { + printf_err("Invalid empty action\n"); + goto error; + } + + g_string_assign(cfg->cmd_data.query_info.action, leftover); + } else { + print_query_info_usage(stdout); + *retcode = -1; + BT_PUT(cfg); + goto end; + } + + leftover = poptGetArg(pc); + if (leftover) { + printf_err("Invalid argument: %s\n", leftover); + goto error; + } + + if (append_home_and_system_plugin_paths( + cfg->cmd_data.query_info.plugin_paths, + cfg->cmd_data.query_info.omit_system_plugin_path, + cfg->cmd_data.query_info.omit_home_plugin_path)) { + printf_err("Cannot append home and system plugin paths\n"); + goto error; + } + + goto end; + +error: + *retcode = 1; + BT_PUT(cfg); + +end: + if (pc) { + poptFreeContext(pc); + } + + BT_PUT(params); + free(arg); + return cfg; +} + /* * Prints the list-plugins command usage. */ @@ -2853,35 +3171,7 @@ void print_convert_usage(FILE *fp) fprintf(fp, "\n"); fprintf(fp, " my-filter.top10:json-out\n"); fprintf(fp, "\n\n"); - fprintf(fp, "Expected format of PARAMS\n"); - fprintf(fp, "-------------------------\n"); - fprintf(fp, "\n"); - fprintf(fp, " PARAM=VALUE[,PARAM=VALUE]...\n"); - fprintf(fp, "\n"); - fprintf(fp, "The parameter string is a comma-separated list of PARAM=VALUE assignments,\n"); - fprintf(fp, "where PARAM is the parameter name (C identifier plus [:.-] characters), and\n"); - fprintf(fp, "VALUE can be one of:\n"); - fprintf(fp, "\n"); - fprintf(fp, "* `null`, `nul`, `NULL`: null value (no backticks).\n"); - fprintf(fp, "* `true`, `TRUE`, `yes`, `YES`: true boolean value (no backticks).\n"); - fprintf(fp, "* `false`, `FALSE`, `no`, `NO`: false boolean value (no backticks).\n"); - fprintf(fp, "* Binary (`0b` prefix), octal (`0` prefix), decimal, or hexadecimal\n"); - fprintf(fp, " (`0x` prefix) signed 64-bit integer.\n"); - fprintf(fp, "* Double precision floating point number (scientific notation is accepted).\n"); - fprintf(fp, "* Unquoted string with no special characters, and not matching any of\n"); - fprintf(fp, " the null and boolean value symbols above.\n"); - fprintf(fp, "* Double-quoted string (accepts escape characters).\n"); - fprintf(fp, "\n"); - fprintf(fp, "Whitespaces are allowed around individual `=` and `,` tokens.\n"); - fprintf(fp, "\n"); - fprintf(fp, "Example:\n"); - fprintf(fp, "\n"); - fprintf(fp, " many=null, fresh=yes, condition=false, squirrel=-782329,\n"); - fprintf(fp, " observe=3.14, simple=beef, needs-quotes=\"some string\",\n"); - fprintf(fp, " escape.chars-are:allowed=\"this is a \\\" double quote\"\n"); - fprintf(fp, "\n"); - fprintf(fp, "IMPORTANT: Make sure to single-quote the whole argument when you run babeltrace\n"); - fprintf(fp, "from a shell.\n"); + print_expected_params_format(fp); } static struct poptOption convert_long_options[] = { @@ -3022,7 +3312,8 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[], } /* Note: implicit source never gets positional base params. */ - implicit_source_comp = bt_config_component_from_arg(DEFAULT_SOURCE_COMPONENT_NAME); + implicit_source_comp = bt_config_component_from_arg( + BT_COMPONENT_CLASS_TYPE_SOURCE, DEFAULT_SOURCE_COMPONENT_NAME); if (!implicit_source_comp) { print_err_oom(); goto error; @@ -3124,7 +3415,8 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[], cur_cfg_comp_dest); } - cur_cfg_comp = bt_config_component_from_arg(arg); + cur_cfg_comp = bt_config_component_from_arg( + BT_COMPONENT_CLASS_TYPE_SOURCE, arg); if (!cur_cfg_comp) { printf_err("Invalid format for --source option's argument:\n %s\n", arg); @@ -3186,7 +3478,8 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[], cur_cfg_comp_dest); } - cur_cfg_comp = bt_config_component_from_arg(arg); + cur_cfg_comp = bt_config_component_from_arg( + BT_COMPONENT_CLASS_TYPE_SINK, arg); if (!cur_cfg_comp) { printf_err("Invalid format for --sink option's argument:\n %s\n", arg); @@ -3562,7 +3855,9 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[], if (cfg->cmd_data.convert.sinks->len == 0) { /* Use implicit sink as default. */ - cur_cfg_comp = bt_config_component_from_arg(DEFAULT_SINK_COMPONENT_NAME); + cur_cfg_comp = bt_config_component_from_arg( + BT_COMPONENT_CLASS_TYPE_SINK, + DEFAULT_SINK_COMPONENT_NAME); if (!cur_cfg_comp) { printf_error("Cannot find implicit sink plugin `%s`\n", DEFAULT_SINK_COMPONENT_NAME); @@ -3635,6 +3930,7 @@ void print_gen_usage(FILE *fp) fprintf(fp, " convert Build a trace conversion graph and run it (default)\n"); fprintf(fp, " help Get help for a plugin or a component class\n"); fprintf(fp, " list-plugins List available plugins and their content\n"); + fprintf(fp, " query-info Query information from a component class\n"); fprintf(fp, "\n"); fprintf(fp, "Use `babeltrace COMMAND --help` to show the help of COMMAND.\n"); } @@ -3693,6 +3989,8 @@ struct bt_config *bt_config_from_args(int argc, const char *argv[], command = BT_CONFIG_COMMAND_LIST_PLUGINS; } else if (strcmp(cur_arg, "help") == 0) { command = BT_CONFIG_COMMAND_HELP; + } else if (strcmp(cur_arg, "query-info") == 0) { + command = BT_CONFIG_COMMAND_QUERY_INFO; } else { /* * Unknown argument, but not a known @@ -3745,6 +4043,11 @@ struct bt_config *bt_config_from_args(int argc, const char *argv[], command_argv, retcode, omit_system_plugin_path, omit_home_plugin_path, initial_plugin_paths); break; + case BT_CONFIG_COMMAND_QUERY_INFO: + config = bt_config_query_info_from_args(command_argc, + command_argv, retcode, omit_system_plugin_path, + omit_home_plugin_path, initial_plugin_paths); + break; default: assert(false); }