#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/common-internal.h>
#include <babeltrace/plugin/plugin-internal.h>
#include <babeltrace/plugin/plugin-so-internal.h>
#include <babeltrace/graph/component-class.h>
#include <babeltrace/graph/component-class-internal.h>
#include <babeltrace/types.h>
+#include <babeltrace/assert-internal.h>
#include <glib.h>
#include <unistd.h>
#include <stdlib.h>
static
struct bt_plugin_set *(*bt_plugin_python_create_all_from_file_sym)(const char *path) =
bt_plugin_python_create_all_from_file;
+
+static
+void init_python_plugin_provider(void) {}
#else /* BT_BUILT_IN_PYTHON_PLUGIN_SUPPORT */
static GModule *python_plugin_provider_module;
static
struct bt_plugin_set *(*bt_plugin_python_create_all_from_file_sym)(const char *path);
-__attribute__((constructor)) static
+static
void init_python_plugin_provider(void) {
+ if (bt_plugin_python_create_all_from_file_sym != NULL) {
+ return;
+ }
+
BT_LOGD_STR("Loading Python plugin provider module.");
python_plugin_provider_module =
g_module_open(PYTHON_PLUGIN_PROVIDER_FILENAME, 0);
if (!python_plugin_provider_module) {
- BT_LOGI("Cannot find `%s`: continuing without Python plugin support.",
- PYTHON_PLUGIN_PROVIDER_FILENAME);
+ BT_LOGI("Cannot open `%s`: %s: continuing without Python plugin support.",
+ PYTHON_PLUGIN_PROVIDER_FILENAME, g_module_error());
return;
}
goto end;
}
- plugin = bt_get(g_ptr_array_index(plugin_set->plugins, index));
+ plugin = bt_object_get_ref(g_ptr_array_index(plugin_set->plugins, index));
end:
return plugin;
}
/* Try Python plugins if support is available */
+ init_python_plugin_provider();
if (bt_plugin_python_create_all_from_file_sym) {
plugin_set = bt_plugin_python_create_all_from_file_sym(path);
if (plugin_set) {
for (i = 0; i < dirs->len; i++) {
GString *dir = g_ptr_array_index(dirs, i);
- BT_PUT(plugin_set);
+ BT_OBJECT_PUT_REF_AND_RESET(plugin_set);
/*
* Skip this if the directory does not exist because
plugin_name) == 0) {
BT_LOGD("Plugin found in directory: name=\"%s\", path=\"%s\"",
plugin_name, dir->str);
- plugin = bt_get(candidate_plugin);
+ plugin = bt_object_get_ref(candidate_plugin);
goto end;
}
}
plugin_name, dir->str);
}
- bt_put(plugin_set);
+ bt_object_put_ref(plugin_set);
plugin_set = bt_plugin_create_all_from_static();
if (plugin_set) {
for (j = 0; j < plugin_set->plugins->len; j++) {
plugin_name) == 0) {
BT_LOGD("Plugin found in built-in plugins: "
"name=\"%s\"", plugin_name);
- plugin = bt_get(candidate_plugin);
+ plugin = bt_object_get_ref(candidate_plugin);
goto end;
}
}
end:
free(home_plugin_dir);
- bt_put(plugin_set);
+ bt_object_put_ref(plugin_set);
if (dirs) {
g_ptr_array_free(dirs, TRUE);
}
end:
- bt_put(plugin);
+ bt_object_put_ref(plugin);
return comp_cls;
}
bt_plugin_set_add_plugin(append_all_from_dir_info.plugin_set, plugin);
}
- bt_put(plugins_from_file);
+ bt_object_put_ref(plugins_from_file);
}
break;
}
goto end;
error:
- BT_PUT(plugin_set);
+ BT_OBJECT_PUT_REF_AND_RESET(plugin_set);
end:
return plugin_set;
}
comp_class = g_ptr_array_index(plugin->comp_classes, index);
- bt_get(comp_class);
+ bt_object_get_ref(comp_class);
goto end;
error:
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
end:
return comp_class;
enum bt_component_class_type comp_class_cand_type =
bt_component_class_get_type(comp_class_candidate);
- assert(comp_class_cand_name);
- assert(comp_class_cand_type >= 0);
+ BT_ASSERT(comp_class_cand_name);
+ BT_ASSERT(comp_class_cand_type >= 0);
if (strcmp(name, comp_class_cand_name) == 0 &&
comp_class_cand_type == type) {
- comp_class = bt_get(comp_class_candidate);
+ comp_class = bt_object_get_ref(comp_class_candidate);
break;
}
}
goto end;
error:
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
end:
return comp_class;
/* Add new component class */
comp_class_index = plugin->comp_classes->len;
- g_ptr_array_add(plugin->comp_classes, bt_get(comp_class));
+ g_ptr_array_add(plugin->comp_classes, bt_object_get_ref(comp_class));
/* Special case for a shared object plugin */
if (plugin->type == BT_PLUGIN_TYPE_SO) {
status = BT_PLUGIN_STATUS_ERROR;
end:
- bt_put(comp_class_dup);
+ bt_object_put_ref(comp_class_dup);
return status;
}