4 * Babeltrace Trace Converter
6 * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
8 * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 #include <babeltrace/babeltrace.h>
30 #include <babeltrace/plugin/plugin.h>
31 #include <babeltrace/common-internal.h>
32 #include <babeltrace/component/component.h>
33 #include <babeltrace/component/component-source.h>
34 #include <babeltrace/component/component-sink.h>
35 #include <babeltrace/component/component-filter.h>
36 #include <babeltrace/component/component-class.h>
37 #include <babeltrace/component/notification/iterator.h>
38 #include <babeltrace/ref.h>
39 #include <babeltrace/values.h>
41 #include <babeltrace/ctf-ir/metadata.h> /* for clocks */
46 #include "babeltrace-cfg.h"
47 #include "babeltrace-cfg-connect.h"
48 #include "default-cfg.h"
50 GPtrArray
*loaded_plugins
;
53 void init_loaded_plugins_array(void)
55 loaded_plugins
= g_ptr_array_new_full(8, bt_put
);
59 void fini_loaded_plugins_array(void)
61 g_ptr_array_free(loaded_plugins
, TRUE
);
65 struct bt_plugin
*find_plugin(const char *name
)
68 struct bt_plugin
*plugin
= NULL
;
70 for (i
= 0; i
< loaded_plugins
->len
; i
++) {
71 plugin
= g_ptr_array_index(loaded_plugins
, i
);
73 if (strcmp(name
, bt_plugin_get_name(plugin
)) == 0) {
80 return bt_get(plugin
);
84 struct bt_component_class
*find_component_class(const char *plugin_name
,
85 const char *comp_class_name
,
86 enum bt_component_class_type comp_class_type
)
88 struct bt_component_class
*comp_class
= NULL
;
89 struct bt_plugin
*plugin
= find_plugin(plugin_name
);
95 comp_class
= bt_plugin_get_component_class_by_name_and_type(plugin
,
96 comp_class_name
, comp_class_type
);
103 void print_indent(size_t indent
)
107 for (i
= 0; i
< indent
; i
++) {
113 void print_value(struct bt_value
*, size_t);
116 bool print_map_value(const char *key
, struct bt_value
*object
, void *data
)
118 size_t *indent
= data
;
120 print_indent(*indent
);
123 if (bt_value_is_array(object
) &&
124 bt_value_array_is_empty(object
)) {
129 if (bt_value_is_map(object
) &&
130 bt_value_map_is_empty(object
)) {
135 if (bt_value_is_array(object
) ||
136 bt_value_is_map(object
)) {
140 print_value(object
, *indent
+ 2);
145 void print_value(struct bt_value
*value
, size_t indent
)
158 switch (bt_value_get_type(value
)) {
159 case BT_VALUE_TYPE_NULL
:
162 case BT_VALUE_TYPE_BOOL
:
163 bt_value_bool_get(value
, &bool_val
);
164 printf("%s\n", bool_val
? "yes" : "no");
166 case BT_VALUE_TYPE_INTEGER
:
167 bt_value_integer_get(value
, &int_val
);
168 printf("%" PRId64
"\n", int_val
);
170 case BT_VALUE_TYPE_FLOAT
:
171 bt_value_float_get(value
, &dbl_val
);
172 printf("%lf\n", dbl_val
);
174 case BT_VALUE_TYPE_STRING
:
175 bt_value_string_get(value
, &str_val
);
176 printf("%s\n", str_val
);
178 case BT_VALUE_TYPE_ARRAY
:
179 size
= bt_value_array_size(value
);
183 print_indent(indent
);
188 for (i
= 0; i
< size
; i
++) {
189 struct bt_value
*element
=
190 bt_value_array_get(value
, i
);
193 print_indent(indent
);
196 if (bt_value_is_array(element
) &&
197 bt_value_array_is_empty(element
)) {
202 if (bt_value_is_map(element
) &&
203 bt_value_map_is_empty(element
)) {
208 if (bt_value_is_array(element
) ||
209 bt_value_is_map(element
)) {
213 print_value(element
, indent
+ 2);
217 case BT_VALUE_TYPE_MAP
:
218 if (bt_value_map_is_empty(value
)) {
219 print_indent(indent
);
224 bt_value_map_foreach(value
, print_map_value
, &indent
);
232 void print_bt_config_component(struct bt_config_component
*bt_config_component
)
234 printf(" %s.%s:\n", bt_config_component
->plugin_name
->str
,
235 bt_config_component
->component_name
->str
);
237 if (bt_config_component
->instance_name
->len
> 0) {
238 printf(" Name: %s\n",
239 bt_config_component
->instance_name
->str
);
242 printf(" Parameters:\n");
243 print_value(bt_config_component
->params
, 8);
247 void print_bt_config_components(GPtrArray
*array
)
251 for (i
= 0; i
< array
->len
; i
++) {
252 struct bt_config_component
*cfg_component
=
253 bt_config_get_component(array
, i
);
254 print_bt_config_component(cfg_component
);
255 BT_PUT(cfg_component
);
260 void print_plugin_paths(struct bt_value
*plugin_paths
)
262 printf(" Plugin paths:\n");
263 print_value(plugin_paths
, 4);
267 void print_cfg_convert(struct bt_config
*cfg
)
271 printf(" Force correlate: %s\n",
272 cfg
->cmd_data
.convert
.force_correlate
? "yes" : "no");
273 print_plugin_paths(cfg
->cmd_data
.convert
.plugin_paths
);
274 printf(" Source component instances:\n");
275 print_bt_config_components(cfg
->cmd_data
.convert
.sources
);
277 if (cfg
->cmd_data
.convert
.filters
->len
> 0) {
278 printf(" Filter component instances:\n");
279 print_bt_config_components(cfg
->cmd_data
.convert
.filters
);
282 printf(" Sink component instances:\n");
283 print_bt_config_components(cfg
->cmd_data
.convert
.sinks
);
284 printf(" Connections:\n");
286 for (i
= 0; i
< cfg
->cmd_data
.convert
.connections
->len
; i
++) {
287 struct bt_config_connection
*cfg_connection
=
288 g_ptr_array_index(cfg
->cmd_data
.convert
.connections
,
291 printf(" %s%s%s -> %s%s%s\n",
292 cfg_connection
->src_instance_name
->str
,
293 cfg_connection
->src_port_name
->len
> 0 ? "." : "",
294 cfg_connection
->src_port_name
->str
,
295 cfg_connection
->dst_instance_name
->str
,
296 cfg_connection
->dst_port_name
->len
> 0 ? "." : "",
297 cfg_connection
->dst_port_name
->str
);
302 void print_cfg_list_plugins(struct bt_config
*cfg
)
304 print_plugin_paths(cfg
->cmd_data
.list_plugins
.plugin_paths
);
308 void print_cfg(struct bt_config
*cfg
)
310 if (!babeltrace_verbose
) {
314 printf("Configuration:\n");
315 printf(" Debug mode: %s\n", cfg
->debug
? "yes" : "no");
316 printf(" Verbose mode: %s\n", cfg
->verbose
? "yes" : "no");
318 switch (cfg
->command
) {
319 case BT_CONFIG_COMMAND_CONVERT
:
320 print_cfg_convert(cfg
);
322 case BT_CONFIG_COMMAND_LIST_PLUGINS
:
323 print_cfg_list_plugins(cfg
);
331 struct bt_component
*create_trimmer(struct bt_config_component
*source_cfg
)
333 struct bt_component
*trimmer
= NULL
;
334 struct bt_component_class
*trimmer_class
= NULL
;
335 struct bt_value
*trimmer_params
= NULL
;
336 struct bt_value
*value
;
338 trimmer_params
= bt_value_map_create();
339 if (!trimmer_params
) {
343 value
= bt_value_map_get(source_cfg
->params
, "begin");
345 enum bt_value_status ret
;
347 ret
= bt_value_map_insert(trimmer_params
, "begin",
354 value
= bt_value_map_get(source_cfg
->params
, "end");
356 enum bt_value_status ret
;
358 ret
= bt_value_map_insert(trimmer_params
, "end",
365 value
= bt_value_map_get(source_cfg
->params
, "clock-gmt");
367 enum bt_value_status ret
;
369 ret
= bt_value_map_insert(trimmer_params
, "clock-gmt",
377 trimmer_class
= find_component_class("utils", "trimmer",
378 BT_COMPONENT_CLASS_TYPE_FILTER
);
379 if (!trimmer_class
) {
380 fprintf(stderr
, "Could not find trimmer component class. Aborting...\n");
383 trimmer
= bt_component_create(trimmer_class
, "source_trimmer",
389 bt_put(trimmer_params
);
390 bt_put(trimmer_class
);
395 int connect_source_sink(struct bt_component
*source
,
396 struct bt_config_component
*source_cfg
,
397 struct bt_component
*sink
)
400 enum bt_component_status sink_status
;
401 struct bt_component
*trimmer
= NULL
;
402 struct bt_notification_iterator
*source_it
= NULL
;
403 struct bt_notification_iterator
*to_sink_it
= NULL
;
405 source_it
= bt_component_source_create_notification_iterator(source
);
407 fprintf(stderr
, "Failed to instantiate source iterator. Aborting...\n");
412 if (bt_value_map_has_key(source_cfg
->params
, "begin")
413 || bt_value_map_has_key(source_cfg
->params
, "end")) {
414 /* A trimmer must be inserted in the graph. */
415 enum bt_component_status trimmer_status
;
417 trimmer
= create_trimmer(source_cfg
);
419 fprintf(stderr
, "Failed to create trimmer component. Aborting...\n");
424 trimmer_status
= bt_component_filter_add_iterator(trimmer
,
427 if (trimmer_status
!= BT_COMPONENT_STATUS_OK
) {
428 fprintf(stderr
, "Failed to connect source to trimmer. Aborting...\n");
433 to_sink_it
= bt_component_filter_create_notification_iterator(trimmer
);
435 fprintf(stderr
, "Failed to instantiate trimmer iterator. Aborting...\n");
440 BT_MOVE(to_sink_it
, source_it
);
443 sink_status
= bt_component_sink_add_iterator(sink
, to_sink_it
);
444 if (sink_status
!= BT_COMPONENT_STATUS_OK
) {
445 fprintf(stderr
, "Failed to connect to sink component. Aborting...\n");
457 void add_to_loaded_plugins(struct bt_plugin
**plugins
)
460 struct bt_plugin
*plugin
= *plugins
;
461 /* Check if it's already loaded (from another path). */
462 struct bt_plugin
*loaded_plugin
=
463 find_plugin(bt_plugin_get_name(plugin
));
466 printf_verbose("Not loading plugin `%s`: already loaded from `%s`\n",
467 bt_plugin_get_path(plugin
),
468 bt_plugin_get_path(loaded_plugin
));
469 BT_PUT(loaded_plugin
);
472 /* Transfer ownership to global array. */
473 g_ptr_array_add(loaded_plugins
, plugin
);
480 int load_dynamic_plugins(struct bt_value
*plugin_paths
)
482 int nr_paths
, i
, ret
= 0;
484 nr_paths
= bt_value_array_size(plugin_paths
);
490 for (i
= 0; i
< nr_paths
; i
++) {
491 struct bt_value
*plugin_path_value
= NULL
;
492 const char *plugin_path
;
493 struct bt_plugin
**plugins
;
495 plugin_path_value
= bt_value_array_get(plugin_paths
, i
);
496 if (bt_value_string_get(plugin_path_value
,
498 BT_PUT(plugin_path_value
);
502 plugins
= bt_plugin_create_all_from_dir(plugin_path
, false);
504 printf_debug("Unable to dynamically load plugins from path %s.\n",
506 BT_PUT(plugin_path_value
);
510 add_to_loaded_plugins(plugins
);
513 BT_PUT(plugin_path_value
);
520 int load_static_plugins(void)
523 struct bt_plugin
**plugins
;
525 plugins
= bt_plugin_create_all_from_static();
527 printf_debug("Unable to load static plugins.\n");
532 add_to_loaded_plugins(plugins
);
539 const char *component_type_str(enum bt_component_class_type type
)
542 case BT_COMPONENT_CLASS_TYPE_SOURCE
:
544 case BT_COMPONENT_CLASS_TYPE_SINK
:
546 case BT_COMPONENT_CLASS_TYPE_FILTER
:
548 case BT_COMPONENT_CLASS_TYPE_UNKNOWN
:
554 static int load_all_plugins(struct bt_value
*plugin_paths
)
558 if (load_dynamic_plugins(plugin_paths
)) {
559 fprintf(stderr
, "Failed to load dynamic plugins.\n");
564 if (load_static_plugins()) {
565 fprintf(stderr
, "Failed to load static plugins.\n");
574 static void print_plugin_info(struct bt_plugin
*plugin
)
576 unsigned int major
, minor
, patch
;
578 enum bt_plugin_status version_status
;
579 const char *plugin_name
;
583 const char *plugin_description
;
585 plugin_name
= bt_plugin_get_name(plugin
);
586 path
= bt_plugin_get_path(plugin
);
587 author
= bt_plugin_get_author(plugin
);
588 license
= bt_plugin_get_license(plugin
);
589 plugin_description
= bt_plugin_get_description(plugin
);
590 version_status
= bt_plugin_get_version(plugin
, &major
, &minor
,
592 printf("%s%s%s%s:\n", bt_common_color_bold(),
593 bt_common_color_fg_blue(), plugin_name
,
594 bt_common_color_reset());
595 printf(" %sPath%s: %s\n", bt_common_color_bold(),
596 bt_common_color_reset(), path
? path
: "(None)");
598 if (version_status
== BT_PLUGIN_STATUS_OK
) {
599 printf(" %sVersion%s: %u.%u.%u",
600 bt_common_color_bold(), bt_common_color_reset(),
601 major
, minor
, patch
);
610 printf(" %sDescription%s: %s\n", bt_common_color_bold(),
611 bt_common_color_reset(),
612 plugin_description
? plugin_description
: "(None)");
613 printf(" %sAuthor%s: %s\n", bt_common_color_bold(),
614 bt_common_color_reset(), author
? author
: "(Unknown)");
615 printf(" %sLicense%s: %s\n", bt_common_color_bold(),
616 bt_common_color_reset(),
617 license
? license
: "(Unknown)");
620 static void print_plugin_comp_cls_opt(FILE *fh
, const char *plugin_name
,
621 const char *comp_cls_name
, enum bt_component_class_type type
)
623 fprintf(fh
, "%s%s--%s%s %s%s%s.%s%s%s",
624 bt_common_color_bold(),
625 bt_common_color_fg_cyan(),
626 component_type_str(type
),
627 bt_common_color_fg_default(),
628 bt_common_color_fg_blue(),
630 bt_common_color_fg_default(),
631 bt_common_color_fg_yellow(),
633 bt_common_color_reset());
636 static int cmd_help(struct bt_config
*cfg
)
639 struct bt_plugin
*plugin
= NULL
;
642 ret
= load_all_plugins(cfg
->cmd_data
.list_plugins
.plugin_paths
);
647 plugin
= find_plugin(cfg
->cmd_data
.help
.cfg_component
->plugin_name
->str
);
649 fprintf(stderr
, "%s%sCannot find plugin %s%s%s\n",
650 bt_common_color_bold(), bt_common_color_fg_red(),
651 bt_common_color_fg_blue(),
652 cfg
->cmd_data
.help
.cfg_component
->plugin_name
->str
,
653 bt_common_color_reset());
658 print_plugin_info(plugin
);
659 printf(" %sComponent classes%s: %d\n",
660 bt_common_color_bold(),
661 bt_common_color_reset(),
662 bt_plugin_get_component_class_count(plugin
));
665 if (cfg
->cmd_data
.help
.cfg_component
->type
!=
666 BT_COMPONENT_CLASS_TYPE_UNKNOWN
) {
667 struct bt_component_class
*needed_comp_cls
=
668 find_component_class(
669 cfg
->cmd_data
.help
.cfg_component
->plugin_name
->str
,
670 cfg
->cmd_data
.help
.cfg_component
->component_name
->str
,
671 cfg
->cmd_data
.help
.cfg_component
->type
);
673 if (!needed_comp_cls
) {
674 fprintf(stderr
, "\n%s%sCannot find component class %s",
675 bt_common_color_bold(),
676 bt_common_color_fg_red(),
677 bt_common_color_reset());
678 print_plugin_comp_cls_opt(stderr
,
679 cfg
->cmd_data
.help
.cfg_component
->plugin_name
->str
,
680 cfg
->cmd_data
.help
.cfg_component
->component_name
->str
,
681 cfg
->cmd_data
.help
.cfg_component
->type
);
682 fprintf(stderr
, "\n");
687 bt_put(needed_comp_cls
);
690 for (i
= 0; i
< bt_plugin_get_component_class_count(plugin
); i
++) {
691 struct bt_component_class
*comp_cls
=
692 bt_plugin_get_component_class(plugin
, i
);
693 const char *comp_class_name
=
694 bt_component_class_get_name(comp_cls
);
695 const char *comp_class_description
=
696 bt_component_class_get_description(comp_cls
);
697 const char *comp_class_help
=
698 bt_component_class_get_help(comp_cls
);
699 enum bt_component_class_type type
=
700 bt_component_class_get_type(comp_cls
);
704 if (cfg
->cmd_data
.help
.cfg_component
->type
!=
705 BT_COMPONENT_CLASS_TYPE_UNKNOWN
) {
706 if (strcmp(cfg
->cmd_data
.help
.cfg_component
->component_name
->str
,
707 comp_class_name
) != 0 &&
709 cfg
->cmd_data
.help
.cfg_component
->type
) {
716 print_plugin_comp_cls_opt(stdout
,
717 cfg
->cmd_data
.help
.cfg_component
->plugin_name
->str
,
721 printf(" %sDescription%s: %s\n", bt_common_color_bold(),
722 bt_common_color_reset(),
723 comp_class_description
? comp_class_description
: "(None)");
725 if (comp_class_help
) {
726 printf("\n%s\n", comp_class_help
);
737 static int cmd_list_plugins(struct bt_config
*cfg
)
740 int plugins_count
, component_classes_count
= 0, i
;
742 ret
= load_all_plugins(cfg
->cmd_data
.list_plugins
.plugin_paths
);
747 printf("From the following plugin paths:\n\n");
748 print_value(cfg
->cmd_data
.list_plugins
.plugin_paths
, 2);
750 plugins_count
= loaded_plugins
->len
;
751 if (plugins_count
== 0) {
752 fprintf(stderr
, "%s%sNo plugins found.%s\n",
753 bt_common_color_bold(), bt_common_color_fg_red(),
754 bt_common_color_reset());
755 fprintf(stderr
, "\n");
756 fprintf(stderr
, "Please make sure your plugin search path is set correctly. You can use\n");
757 fprintf(stderr
, "the --plugin-path command-line option or the BABELTRACE_PLUGIN_PATH\n");
758 fprintf(stderr
, "environment variable.\n");
763 for (i
= 0; i
< plugins_count
; i
++) {
764 struct bt_plugin
*plugin
= g_ptr_array_index(loaded_plugins
, i
);
766 component_classes_count
+= bt_plugin_get_component_class_count(plugin
);
769 printf("Found %s%d%s component classes in %s%d%s plugins.\n",
770 bt_common_color_bold(),
771 component_classes_count
,
772 bt_common_color_reset(),
773 bt_common_color_bold(),
775 bt_common_color_reset());
777 for (i
= 0; i
< plugins_count
; i
++) {
779 struct bt_plugin
*plugin
= g_ptr_array_index(loaded_plugins
, i
);
781 component_classes_count
=
782 bt_plugin_get_component_class_count(plugin
);
784 print_plugin_info(plugin
);
786 if (component_classes_count
== 0) {
787 printf(" %sComponent classes%s: (None)\n",
788 bt_common_color_bold(),
789 bt_common_color_reset());
791 printf(" %sComponent classes%s:\n",
792 bt_common_color_bold(),
793 bt_common_color_reset());
796 for (j
= 0; j
< component_classes_count
; j
++) {
797 struct bt_component_class
*comp_class
=
798 bt_plugin_get_component_class(plugin
, j
);
799 const char *comp_class_name
=
800 bt_component_class_get_name(comp_class
);
801 const char *comp_class_description
=
802 bt_component_class_get_description(comp_class
);
803 enum bt_component_class_type type
=
804 bt_component_class_get_type(comp_class
);
807 print_plugin_comp_cls_opt(stdout
,
808 bt_plugin_get_name(plugin
), comp_class_name
,
811 if (comp_class_description
) {
812 printf(": %s", comp_class_description
);
824 static int cmd_convert(struct bt_config
*cfg
)
827 struct bt_component_class
*source_class
= NULL
;
828 struct bt_component_class
*sink_class
= NULL
;
829 struct bt_component
*source
= NULL
, *sink
= NULL
;
830 struct bt_value
*source_params
= NULL
, *sink_params
= NULL
;
831 enum bt_component_status sink_status
;
832 struct bt_config_component
*source_cfg
= NULL
, *sink_cfg
= NULL
;
834 /* TODO handle more than 1 source and 1 sink. */
835 if (cfg
->cmd_data
.convert
.sources
->len
!= 1 ||
836 cfg
->cmd_data
.convert
.sinks
->len
!= 1) {
837 fprintf(stderr
, "Only one source and one sink component class are supported. Aborting...\n");
842 ret
= load_all_plugins(cfg
->cmd_data
.convert
.plugin_paths
);
844 fprintf(stderr
, "Could not load plugins from configured plugin paths. Aborting...\n");
848 source_cfg
= bt_config_get_component(cfg
->cmd_data
.convert
.sources
, 0);
849 source_params
= bt_get(source_cfg
->params
);
850 source_class
= find_component_class(source_cfg
->plugin_name
->str
,
851 source_cfg
->component_name
->str
,
852 BT_COMPONENT_CLASS_TYPE_SOURCE
);
854 fprintf(stderr
, "Could not find %s.%s source component class. Aborting...\n",
855 source_cfg
->plugin_name
->str
,
856 source_cfg
->component_name
->str
);
861 sink_cfg
= bt_config_get_component(cfg
->cmd_data
.convert
.sinks
, 0);
862 sink_params
= bt_get(sink_cfg
->params
);
863 sink_class
= find_component_class(sink_cfg
->plugin_name
->str
,
864 sink_cfg
->component_name
->str
,
865 BT_COMPONENT_CLASS_TYPE_SINK
);
867 fprintf(stderr
, "Could not find %s.%s output component class. Aborting...\n",
868 sink_cfg
->plugin_name
->str
,
869 sink_cfg
->component_name
->str
);
874 source
= bt_component_create(source_class
, "source", source_params
);
876 fprintf(stderr
, "Failed to instantiate selected source component. Aborting...\n");
881 sink
= bt_component_create(sink_class
, "sink", sink_params
);
883 fprintf(stderr
, "Failed to instantiate selected output component. Aborting...\n");
888 ret
= connect_source_sink(source
, source_cfg
, sink
);
895 sink_status
= bt_component_sink_consume(sink
);
896 switch (sink_status
) {
897 case BT_COMPONENT_STATUS_AGAIN
:
898 /* Wait for an arbitraty 500 ms. */
901 case BT_COMPONENT_STATUS_OK
:
903 case BT_COMPONENT_STATUS_END
:
906 fprintf(stderr
, "Sink component returned an error, aborting...\n");
914 BT_PUT(source_class
);
917 BT_PUT(source_params
);
924 static void warn_command_name_and_directory_clash(struct bt_config
*cfg
)
926 if (!cfg
->command_name
) {
930 if (g_file_test(cfg
->command_name
,
931 G_FILE_TEST_EXISTS
| G_FILE_TEST_IS_DIR
)) {
932 fprintf(stderr
, "\nNOTE: The `%s` command was executed. If you meant to convert a\n",
934 fprintf(stderr
, "trace located in the local `%s` directory, please use:\n",
936 fprintf(stderr
, "\n");
937 fprintf(stderr
, " babeltrace convert %s [OPTIONS]\n",
942 int main(int argc
, const char **argv
)
946 struct bt_config
*cfg
;
948 init_loaded_plugins_array();
949 cfg
= bt_config_from_args_with_defaults(argc
, argv
, &retcode
);
952 /* Quit without errors; typically usage/version */
962 fprintf(stderr
, "Failed to create Babeltrace configuration\n");
966 babeltrace_debug
= cfg
->debug
;
967 babeltrace_verbose
= cfg
->verbose
;
970 switch (cfg
->command
) {
971 case BT_CONFIG_COMMAND_CONVERT
:
972 ret
= cmd_convert(cfg
);
974 case BT_CONFIG_COMMAND_LIST_PLUGINS
:
975 ret
= cmd_list_plugins(cfg
);
977 case BT_CONFIG_COMMAND_HELP
:
984 warn_command_name_and_directory_clash(cfg
);
985 retcode
= ret
? 1 : 0;
989 fini_loaded_plugins_array();