+ print_plugin_info(plugin);
+ printf(" %sComponent classes%s: %d\n",
+ bt_common_color_bold(),
+ bt_common_color_reset(),
+ bt_plugin_get_component_class_count(plugin));
+
+
+ if (cfg->cmd_data.help.cfg_component->type !=
+ BT_COMPONENT_CLASS_TYPE_UNKNOWN) {
+ struct bt_component_class *needed_comp_cls =
+ find_component_class(
+ cfg->cmd_data.help.cfg_component->plugin_name->str,
+ cfg->cmd_data.help.cfg_component->component_name->str,
+ cfg->cmd_data.help.cfg_component->type);
+
+ if (!needed_comp_cls) {
+ fprintf(stderr, "\n%s%sCannot find component class %s",
+ bt_common_color_bold(),
+ bt_common_color_fg_red(),
+ bt_common_color_reset());
+ print_plugin_comp_cls_opt(stderr,
+ cfg->cmd_data.help.cfg_component->plugin_name->str,
+ cfg->cmd_data.help.cfg_component->component_name->str,
+ cfg->cmd_data.help.cfg_component->type);
+ fprintf(stderr, "\n");
+ ret = -1;
+ goto end;
+ }
+
+ bt_put(needed_comp_cls);
+ }
+
+ for (i = 0; i < bt_plugin_get_component_class_count(plugin); i++) {
+ struct bt_component_class *comp_cls =
+ bt_plugin_get_component_class(plugin, i);
+ const char *comp_class_name =
+ bt_component_class_get_name(comp_cls);
+ const char *comp_class_description =
+ bt_component_class_get_description(comp_cls);
+ const char *comp_class_help =
+ bt_component_class_get_help(comp_cls);
+ enum bt_component_class_type type =
+ bt_component_class_get_type(comp_cls);
+
+ assert(comp_cls);
+
+ if (cfg->cmd_data.help.cfg_component->type !=
+ BT_COMPONENT_CLASS_TYPE_UNKNOWN) {
+ if (strcmp(cfg->cmd_data.help.cfg_component->component_name->str,
+ comp_class_name) != 0 &&
+ type ==
+ cfg->cmd_data.help.cfg_component->type) {
+ bt_put(comp_cls);
+ continue;
+ }
+ }
+
+ printf("\n");
+ print_plugin_comp_cls_opt(stdout,
+ cfg->cmd_data.help.cfg_component->plugin_name->str,
+ comp_class_name,
+ type);
+ printf("\n");
+ printf(" %sDescription%s: %s\n", bt_common_color_bold(),
+ bt_common_color_reset(),
+ comp_class_description ? comp_class_description : "(None)");
+
+ if (comp_class_help) {
+ printf("\n%s\n", comp_class_help);
+ }
+
+ bt_put(comp_cls);
+ }
+
+end:
+ bt_put(plugin);
+ return ret;
+}
+
+static int cmd_list_plugins(struct bt_config *cfg)
+{
+ int ret;
+ int plugins_count, component_classes_count = 0, i;
+
+ ret = load_all_plugins(cfg->cmd_data.list_plugins.plugin_paths);
+ if (ret) {
+ goto end;
+ }
+
+ printf("From the following plugin paths:\n\n");
+ print_value(cfg->cmd_data.list_plugins.plugin_paths, 2);
+ printf("\n");
+ plugins_count = loaded_plugins->len;
+ if (plugins_count == 0) {
+ fprintf(stderr, "%s%sNo plugins found.%s\n",
+ bt_common_color_bold(), bt_common_color_fg_red(),
+ bt_common_color_reset());
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Please make sure your plugin search path is set correctly. You can use\n");
+ fprintf(stderr, "the --plugin-path command-line option or the BABELTRACE_PLUGIN_PATH\n");
+ fprintf(stderr, "environment variable.\n");