#include <babeltrace/iterator.h>
#include <babeltrace/plugin/component-factory.h>
+#include <babeltrace/ref.h>
+#include <babeltrace/values.h>
#include <popt.h>
#include <errno.h>
#include <stdlib.h>
struct bt_trace_descriptor *td_write;
struct bt_context *ctx;
struct bt_component_factory *component_factory;
+ struct bt_value *components = NULL;
int i;
call_plugins_hooks();
goto end;
}
+ components = bt_component_factory_get_components(component_factory);
+ if (!components || bt_value_array_is_empty(components)) {
+ printf_error("No plugins found, exiting.");
+ ret = -1;
+ goto end;
+ }
+
if (opt_input_paths->len == 0) {
ret = -1;
goto end;
free(opt_debug_info_dir);
free(opt_debug_info_target_prefix);
g_ptr_array_free(opt_input_paths, TRUE);
+ BT_PUT(components);
+ BT_PUT(component_factory);
if (partial_error)
exit(EXIT_FAILURE);
else
typedef void (*bt_plugin_exit_func)(void);
/* A plugin must define the __bt_plugin_init symbol */
-#define BT_PLUGIN_NAME(_x) const char *__bt_plugin_name = (_x)
-#define BT_PLUGIN_AUTHOR(_x) const char *__bt_plugin_author = (_x)
-#define BT_PLUGIN_LICENSE(_x) const char *__bt_plugin_license = (_x)
+#define BT_PLUGIN_NAME(_x) const char __bt_plugin_name[] = (_x)
+#define BT_PLUGIN_AUTHOR(_x) const char __bt_plugin_author[] = (_x)
+#define BT_PLUGIN_LICENSE(_x) const char __bt_plugin_license[] = (_x)
#define BT_PLUGIN_INIT(_x) bt_plugin_init_func __bt_plugin_init = (_x)
#define BT_PLUGIN_EXIT(_x) bt_plugin_exit_func __bt_plugin_exit = (_x)
*
* Babeltrace CTF Text Output Plugin
*
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
/* Defines BT_PLUGIN_INIT. */
BT_PLUGIN_COMPONENT_CLASSES_BEGIN
-BT_PLUGIN_SINK_COMPONENT_CLASS_ENTRY(plugin_name, ctf_text_init)
+BT_PLUGIN_SINK_COMPONENT_CLASS_ENTRY(__bt_plugin_name, ctf_text_init)
BT_PLUGIN_COMPONENT_CLASSES_END
enum loglevel {
if (plugin->module) {
if (!g_module_close(plugin->module)) {
- printf_error("Module close error: %s",
- g_module_error());
+ printf_error("Module close error: %s",
+ g_module_error());
}
}
struct bt_plugin *bt_plugin_create(GModule *module)
{
struct bt_plugin *plugin = NULL;
+ gpointer symbol = NULL;
if (!module) {
goto error;
bt_object_init(plugin, bt_plugin_destroy);
if (!g_module_symbol(module, PLUGIN_SYMBOL_NAME,
- (gpointer *) &plugin->name)) {
+ (gpointer *) &plugin->name)) {
printf_error("Unable to resolve plugin symbol %s from %s",
- PLUGIN_SYMBOL_NAME, g_module_name(module));
+ PLUGIN_SYMBOL_NAME, g_module_name(module));
goto error;
}
- printf("Loaded plugin with name %s\n", plugin->name);
if (!g_module_symbol(module, PLUGIN_SYMBOL_LICENSE,
- (gpointer *) &plugin->license)) {
+ (gpointer *) &plugin->license)) {
printf_error("Unable to resolve plugin symbol %s from %s",
- PLUGIN_SYMBOL_LICENSE, g_module_name(module));
+ PLUGIN_SYMBOL_LICENSE, g_module_name(module));
goto error;
}
- if (!g_module_symbol(module, PLUGIN_SYMBOL_INIT,
- (gpointer *) &plugin->init)) {
+ if (!g_module_symbol(module, PLUGIN_SYMBOL_INIT, &symbol)) {
printf_error("Unable to resolve plugin symbol %s from %s",
- PLUGIN_SYMBOL_INIT, g_module_name(module));
+ PLUGIN_SYMBOL_INIT, g_module_name(module));
goto error;
+ } else {
+ plugin->init = *((bt_plugin_init_func *) symbol);
+ if (!plugin->init) {
+ printf_error("NULL %s symbol target",
+ PLUGIN_SYMBOL_INIT);
+ goto error;
+ }
}
- /* Optional symbols */
- g_module_symbol(module, PLUGIN_SYMBOL_EXIT, (gpointer *) &plugin->exit);
+ /* Optional */
+ if (g_module_symbol(module, PLUGIN_SYMBOL_EXIT,
+ (gpointer *) &symbol)) {
+ plugin->exit = *((bt_plugin_exit_func *) symbol);
+ }
g_module_symbol(module, PLUGIN_SYMBOL_AUTHOR,
- (gpointer *) &plugin->author);
+ (gpointer *) &plugin->author);
return plugin;
error: