/* Parse the plugin name */
gs_plugin = bt_common_string_until(at, ".:\\", ".", &end_pos);
if (!gs_plugin || gs_plugin->len == 0 || at[end_pos] == '\0') {
- printf_err("Missing plugin name\n");
+ printf_err("Missing plugin or component class name\n");
goto error;
}
static
void print_query_usage(FILE *fp)
{
- fprintf(fp, "Usage: babeltrace [GEN OPTS] query [OPTS] OBJECT --component=TYPE.PLUGIN.CLS\n");
+ fprintf(fp, "Usage: babeltrace [GEN OPTS] query [OPTS] TYPE.PLUGIN.CLS OBJECT\n");
fprintf(fp, "\n");
fprintf(fp, "Options:\n");
fprintf(fp, "\n");
- fprintf(fp, " -c, --component=TYPE.PLUGIN.CLS Query the component class CLS of type TYPE\n");
- fprintf(fp, " (`source`, `filter`, or `sink`) found in\n");
- fprintf(fp, " 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");
static
struct poptOption query_long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "component", 'c', POPT_ARG_STRING, NULL, OPT_COMPONENT, 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 },
case OPT_OMIT_HOME_PLUGIN_PATH:
cfg->omit_home_plugin_path = true;
break;
- case OPT_COMPONENT:
- if (cfg->cmd_data.query.cfg_component) {
- printf_err("Cannot specify more than one plugin and component class:\n %s\n",
- arg);
- goto error;
- }
-
- cfg->cmd_data.query.cfg_component =
- bt_config_component_from_arg(arg);
- if (!cfg->cmd_data.query.cfg_component) {
- printf_err("Invalid format for --component option's argument:\n %s\n",
- arg);
- goto error;
- }
-
- /* Default parameters: null */
- bt_put(cfg->cmd_data.query.cfg_component->params);
- cfg->cmd_data.query.cfg_component->params =
- bt_value_null;
- break;
case OPT_PARAMS:
{
+ bt_put(params);
params = bt_value_from_arg(arg);
if (!params) {
printf_err("Invalid format for --params option's argument:\n %s\n",
arg = NULL;
}
- if (!cfg->cmd_data.query.cfg_component) {
- printf_err("No target component class specified with --component option\n");
- goto error;
- }
-
- assert(params);
- BT_MOVE(cfg->cmd_data.query.cfg_component->params, params);
-
/* Check for option parsing error */
if (opt < -1) {
printf_err("While parsing command-line options, at option %s: %s\n",
}
/*
- * We need exactly one leftover argument which is the
- * mandatory object.
+ * We need exactly two leftover arguments which are the
+ * mandatory component class specification and query object.
*/
+ leftover = poptGetArg(pc);
+ if (leftover) {
+ cfg->cmd_data.query.cfg_component =
+ bt_config_component_from_arg(leftover);
+ if (!cfg->cmd_data.query.cfg_component) {
+ printf_err("Invalid format for component class specification:\n %s\n",
+ leftover);
+ goto error;
+ }
+
+ assert(params);
+ BT_MOVE(cfg->cmd_data.query.cfg_component->params, params);
+ } else {
+ print_query_usage(stdout);
+ *retcode = -1;
+ BT_PUT(cfg);
+ goto end;
+ }
+
leftover = poptGetArg(pc);
if (leftover) {
if (strlen(leftover) == 0) {
poptFreeContext(pc);
}
- BT_PUT(params);
+ bt_put(params);
free(arg);
return cfg;
}
{
struct bt_config *cfg = NULL;
const char **argv;
- size_t i;
+ int64_t i, len;
const size_t argc = bt_value_array_size(run_args) + 1;
argv = calloc(argc, sizeof(*argv));
argv[0] = "run";
- for (i = 0; i < bt_value_array_size(run_args); i++) {
+ len = bt_value_array_size(run_args);
+ if (len < 0) {
+ printf_err("Invalid executable arguments\n");
+ goto end;
+ }
+ for (i = 0; i < len; i++) {
int ret;
struct bt_value *arg_value = bt_value_array_get(run_args, i);
const char *arg;
BT_PUT(impl_args->extra_params);
impl_args->extra_params =
bt_value_copy(base_implicit_ctf_input_args->extra_params);
- if (!impl_args) {
+ if (!impl_args->extra_params) {
print_err_oom();
destroy_implicit_component_args(impl_args);
goto error;
bool got_output_format_opt = false;
bool trimmer_has_begin = false;
bool trimmer_has_end = false;
+ bool stream_intersection_mode = false;
GString *cur_name = NULL;
GString *cur_name_prefix = NULL;
const char *leftover = NULL;
case OPT_CLOCK_OFFSET:
base_implicit_ctf_input_args.exists = true;
append_implicit_component_param(
- &implicit_muxer_args,
+ &base_implicit_ctf_input_args,
"clock-class-offset-s", arg);
- if (ret) {
- goto error;
- }
break;
case OPT_CLOCK_OFFSET_NS:
base_implicit_ctf_input_args.exists = true;
- ret = append_implicit_component_extra_param(
- &base_implicit_ctf_input_args,
- "clock-class-offset-ns", arg);
- if (ret) {
- goto error;
- }
+ append_implicit_component_param(
+ &base_implicit_ctf_input_args,
+ "clock-class-offset-ns", arg);
break;
case OPT_CLOCK_SECONDS:
append_implicit_component_param(
print_run_args_0 = true;
break;
case OPT_STREAM_INTERSECTION:
- append_implicit_component_param(
- &base_implicit_ctf_input_args,
- "stream-intersection", "yes");
- base_implicit_ctf_input_args.exists = true;
+ /*
+ * Applies to all traces implementing the trace-info
+ * query.
+ */
+ stream_intersection_mode = true;
break;
case OPT_VERBOSE:
if (*log_level != 'V' && *log_level != 'D') {
* here.
*/
if (print_run_args || print_run_args_0) {
+ if (stream_intersection_mode) {
+ printf_err("Cannot specify --stream-intersection with --run-args or --run-args-0\n");
+ goto error;
+ }
+
for (i = 0; i < bt_value_array_size(run_args); i++) {
struct bt_value *arg_value =
bt_value_array_get(run_args, i);
goto error;
}
+ cfg->cmd_data.run.stream_intersection_mode = stream_intersection_mode;
goto end;
error: