#define BT_LOG_TAG "PLUGIN-SO"
#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace/assert-internal.h>
+#include <babeltrace/assert-pre-internal.h>
#include <babeltrace/compiler-internal.h>
-#include <babeltrace/object.h>
#include <babeltrace/plugin/plugin-internal.h>
#include <babeltrace/plugin/plugin-so-internal.h>
#include <babeltrace/plugin/plugin-dev.h>
#include <babeltrace/graph/component-class-sink.h>
#include <babeltrace/types.h>
#include <babeltrace/list-internal.h>
-#include <babeltrace/assert-internal.h>
#include <string.h>
#include <stdlib.h>
#include <glib.h>
*
* It allows this use-case:
*
- * my_plugins = bt_plugin_create_all_from_file("/path/to/my-plugin.so");
+ * my_plugins = bt_plugin_find_all_from_file("/path/to/my-plugin.so");
* // instantiate components from a plugin's component classes
* // put plugins and free my_plugins here
* // user code of instantiated components still exists
BT_LOGD_STR("Released references from all component classes to shared library handles.");
}
+static inline
+const char *bt_self_plugin_status_string(enum bt_self_plugin_status status)
+{
+ switch (status) {
+ case BT_SELF_PLUGIN_STATUS_OK:
+ return "BT_SELF_PLUGIN_STATUS_OK";
+ case BT_SELF_PLUGIN_STATUS_ERROR:
+ return "BT_SELF_PLUGIN_STATUS_ERROR";
+ case BT_SELF_PLUGIN_STATUS_NOMEM:
+ return "BT_SELF_PLUGIN_STATUS_NOMEM";
+ default:
+ return "(unknown)";
+ }
+}
+
static
void bt_plugin_so_shared_lib_handle_destroy(struct bt_object *obj)
{
shared_lib_handle, path);
if (shared_lib_handle->init_called && shared_lib_handle->exit) {
- enum bt_plugin_status status;
-
BT_LOGD_STR("Calling user's plugin exit function.");
- status = shared_lib_handle->exit();
- BT_LOGD("User function returned: %s",
- bt_plugin_status_string(status));
-
- if (status < 0) {
- BT_LOGW("User's plugin exit function failed: "
- "path=\"%s\"", path);
- }
+ shared_lib_handle->exit();
+ BT_LOGD_STR("User function returned.");
}
if (shared_lib_handle->module) {
* DEBUG-level logging because we're only _trying_ to
* open this file as a Babeltrace plugin: if it's not,
* it's not an error. And because this can be tried
- * during bt_plugin_create_all_from_dir(), it's not even
+ * during bt_plugin_find_all_from_dir(), it's not even
* a warning.
*/
BT_LOGD("Cannot open GModule: %s: path=\"%s\"",
bt_component_class_source_query_method query;
bt_component_class_source_accept_output_port_connection_method accept_output_port_connection;
bt_component_class_source_output_port_connected_method output_port_connected;
- bt_component_class_source_output_port_disconnected_method output_port_disconnected;
- bt_component_class_source_notification_iterator_init_method notif_iter_init;
- bt_component_class_source_notification_iterator_finalize_method notif_iter_finalize;
+ bt_component_class_source_message_iterator_init_method msg_iter_init;
+ bt_component_class_source_message_iterator_finalize_method msg_iter_finalize;
+ bt_component_class_source_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin;
+ bt_component_class_source_message_iterator_seek_beginning_method msg_iter_seek_beginning;
+ bt_component_class_source_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
+ bt_component_class_source_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning;
} source;
struct {
bt_component_class_filter_accept_output_port_connection_method accept_output_port_connection;
bt_component_class_filter_input_port_connected_method input_port_connected;
bt_component_class_filter_output_port_connected_method output_port_connected;
- bt_component_class_filter_input_port_disconnected_method input_port_disconnected;
- bt_component_class_filter_output_port_disconnected_method output_port_disconnected;
- bt_component_class_filter_notification_iterator_init_method notif_iter_init;
- bt_component_class_filter_notification_iterator_finalize_method notif_iter_finalize;
+ bt_component_class_filter_message_iterator_init_method msg_iter_init;
+ bt_component_class_filter_message_iterator_finalize_method msg_iter_finalize;
+ bt_component_class_filter_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin;
+ bt_component_class_filter_message_iterator_seek_beginning_method msg_iter_seek_beginning;
+ bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
+ bt_component_class_filter_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning;
} filter;
struct {
bt_component_class_sink_query_method query;
bt_component_class_sink_accept_input_port_connection_method accept_input_port_connection;
bt_component_class_sink_input_port_connected_method input_port_connected;
- bt_component_class_sink_input_port_disconnected_method input_port_disconnected;
+ bt_component_class_sink_graph_is_configured_method graph_is_configured;
} sink;
} methods;
};
abort();
}
break;
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_DISCONNECTED_METHOD:
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GRAPH_IS_CONFIGURED_METHOD:
+ switch (cc_type) {
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ cc_full_descr->methods.sink.graph_is_configured =
+ cur_cc_descr_attr->value.sink_graph_is_configured_method;
+ break;
+ default:
+ abort();
+ }
+ break;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INIT_METHOD:
+ switch (cc_type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ cc_full_descr->methods.source.msg_iter_init =
+ cur_cc_descr_attr->value.source_msg_iter_init_method;
+ break;
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ cc_full_descr->methods.filter.msg_iter_init =
+ cur_cc_descr_attr->value.filter_msg_iter_init_method;
+ break;
+ default:
+ abort();
+ }
+ break;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD:
switch (cc_type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ cc_full_descr->methods.source.msg_iter_finalize =
+ cur_cc_descr_attr->value.source_msg_iter_finalize_method;
+ break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
- cc_full_descr->methods.filter.input_port_disconnected =
- cur_cc_descr_attr->value.filter_input_port_disconnected_method;
+ cc_full_descr->methods.filter.msg_iter_finalize =
+ cur_cc_descr_attr->value.filter_msg_iter_finalize_method;
break;
- case BT_COMPONENT_CLASS_TYPE_SINK:
- cc_full_descr->methods.sink.input_port_disconnected =
- cur_cc_descr_attr->value.sink_input_port_disconnected_method;
+ default:
+ abort();
+ }
+ break;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD:
+ switch (cc_type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ cc_full_descr->methods.source.msg_iter_seek_ns_from_origin =
+ cur_cc_descr_attr->value.source_msg_iter_seek_ns_from_origin_method;
+ break;
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin =
+ cur_cc_descr_attr->value.filter_msg_iter_seek_ns_from_origin_method;
break;
default:
abort();
}
break;
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_DISCONNECTED_METHOD:
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD:
switch (cc_type) {
case BT_COMPONENT_CLASS_TYPE_SOURCE:
- cc_full_descr->methods.source.output_port_disconnected =
- cur_cc_descr_attr->value.source_output_port_disconnected_method;
+ cc_full_descr->methods.source.msg_iter_seek_beginning =
+ cur_cc_descr_attr->value.source_msg_iter_seek_beginning_method;
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
- cc_full_descr->methods.filter.output_port_disconnected =
- cur_cc_descr_attr->value.filter_output_port_disconnected_method;
+ cc_full_descr->methods.filter.msg_iter_seek_beginning =
+ cur_cc_descr_attr->value.filter_msg_iter_seek_beginning_method;
break;
default:
abort();
}
break;
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD:
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD:
switch (cc_type) {
case BT_COMPONENT_CLASS_TYPE_SOURCE:
- cc_full_descr->methods.source.notif_iter_init =
- cur_cc_descr_attr->value.source_notif_iter_init_method;
+ cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin =
+ cur_cc_descr_attr->value.source_msg_iter_can_seek_ns_from_origin_method;
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
- cc_full_descr->methods.filter.notif_iter_init =
- cur_cc_descr_attr->value.filter_notif_iter_init_method;
+ cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin =
+ cur_cc_descr_attr->value.filter_msg_iter_can_seek_ns_from_origin_method;
break;
default:
abort();
}
break;
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD:
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD:
switch (cc_type) {
case BT_COMPONENT_CLASS_TYPE_SOURCE:
- cc_full_descr->methods.source.notif_iter_finalize =
- cur_cc_descr_attr->value.source_notif_iter_finalize_method;
+ cc_full_descr->methods.source.msg_iter_can_seek_beginning =
+ cur_cc_descr_attr->value.source_msg_iter_can_seek_beginning_method;
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
- cc_full_descr->methods.filter.notif_iter_finalize =
- cur_cc_descr_attr->value.filter_notif_iter_finalize_method;
+ cc_full_descr->methods.filter.msg_iter_can_seek_beginning =
+ cur_cc_descr_attr->value.filter_msg_iter_can_seek_beginning_method;
break;
default:
abort();
/* Initialize plugin */
if (spec->init) {
+ enum bt_self_plugin_status init_status;
+
BT_LOGD_STR("Calling user's plugin initialization function.");
- status = spec->init(plugin);
+ init_status = spec->init((void *) plugin);
BT_LOGD("User function returned: %s",
- bt_plugin_status_string(status));
+ bt_self_plugin_status_string(init_status));
- if (status < 0) {
+ if (init_status < 0) {
BT_LOGW_STR("User's plugin initialization function failed.");
+ status = BT_PLUGIN_STATUS_ERROR;
goto end;
}
}
case BT_COMPONENT_CLASS_TYPE_SOURCE:
src_comp_class = bt_component_class_source_create(
cc_full_descr->descriptor->name,
- cc_full_descr->descriptor->methods.source.notif_iter_next);
+ cc_full_descr->descriptor->methods.source.msg_iter_next);
comp_class = bt_component_class_source_as_component_class(
src_comp_class);
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
flt_comp_class = bt_component_class_filter_create(
cc_full_descr->descriptor->name,
- cc_full_descr->descriptor->methods.source.notif_iter_next);
+ cc_full_descr->descriptor->methods.source.msg_iter_next);
comp_class = bt_component_class_filter_as_component_class(
flt_comp_class);
break;
}
}
- if (cc_full_descr->methods.source.output_port_disconnected) {
- ret = bt_component_class_source_set_output_port_disconnected_method(
+ if (cc_full_descr->methods.source.msg_iter_init) {
+ ret = bt_component_class_source_set_message_iterator_init_method(
+ src_comp_class,
+ cc_full_descr->methods.source.msg_iter_init);
+ if (ret) {
+ BT_LOGE_STR("Cannot set source component class's message iterator initialization method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->methods.source.msg_iter_finalize) {
+ ret = bt_component_class_source_set_message_iterator_finalize_method(
+ src_comp_class,
+ cc_full_descr->methods.source.msg_iter_finalize);
+ if (ret) {
+ BT_LOGE_STR("Cannot set source component class's message iterator finalization method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->methods.source.msg_iter_seek_ns_from_origin) {
+ ret = bt_component_class_source_set_message_iterator_seek_ns_from_origin_method(
+ src_comp_class,
+ cc_full_descr->methods.source.msg_iter_seek_ns_from_origin);
+ if (ret) {
+ BT_LOGE_STR("Cannot set source component class's message iterator \"seek nanoseconds from origin\" method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->methods.source.msg_iter_seek_beginning) {
+ ret = bt_component_class_source_set_message_iterator_seek_beginning_method(
src_comp_class,
- cc_full_descr->methods.source.output_port_disconnected);
+ cc_full_descr->methods.source.msg_iter_seek_beginning);
if (ret) {
- BT_LOGE_STR("Cannot set source component class's \"output port disconnected\" method.");
+ BT_LOGE_STR("Cannot set source component class's message iterator \"seek beginning\" method.");
status = BT_PLUGIN_STATUS_ERROR;
BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
goto end;
}
}
- if (cc_full_descr->methods.source.notif_iter_init) {
- ret = bt_component_class_source_set_notification_iterator_init_method(
+ if (cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin) {
+ ret = bt_component_class_source_set_message_iterator_can_seek_ns_from_origin_method(
src_comp_class,
- cc_full_descr->methods.source.notif_iter_init);
+ cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin);
if (ret) {
- BT_LOGE_STR("Cannot set source component class's notification iterator initialization method.");
+ BT_LOGE_STR("Cannot set source component class's message iterator \"can seek nanoseconds from origin\" method.");
status = BT_PLUGIN_STATUS_ERROR;
BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
goto end;
}
}
- if (cc_full_descr->methods.source.notif_iter_finalize) {
- ret = bt_component_class_source_set_notification_iterator_finalize_method(
+ if (cc_full_descr->methods.source.msg_iter_can_seek_beginning) {
+ ret = bt_component_class_source_set_message_iterator_can_seek_beginning_method(
src_comp_class,
- cc_full_descr->methods.source.notif_iter_finalize);
+ cc_full_descr->methods.source.msg_iter_can_seek_beginning);
if (ret) {
- BT_LOGE_STR("Cannot set source component class's notification iterator finalization method.");
+ BT_LOGE_STR("Cannot set source component class's message iterator \"can seek beginning\" method.");
status = BT_PLUGIN_STATUS_ERROR;
BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
goto end;
}
}
- if (cc_full_descr->methods.filter.input_port_disconnected) {
- ret = bt_component_class_filter_set_input_port_disconnected_method(
+ if (cc_full_descr->methods.filter.msg_iter_init) {
+ ret = bt_component_class_filter_set_message_iterator_init_method(
flt_comp_class,
- cc_full_descr->methods.filter.input_port_disconnected);
+ cc_full_descr->methods.filter.msg_iter_init);
if (ret) {
- BT_LOGE_STR("Cannot set filter component class's \"input port disconnected\" method.");
+ BT_LOGE_STR("Cannot set filter component class's message iterator initialization method.");
status = BT_PLUGIN_STATUS_ERROR;
BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
goto end;
}
}
- if (cc_full_descr->methods.filter.output_port_disconnected) {
- ret = bt_component_class_filter_set_output_port_disconnected_method(
+ if (cc_full_descr->methods.filter.msg_iter_finalize) {
+ ret = bt_component_class_filter_set_message_iterator_finalize_method(
flt_comp_class,
- cc_full_descr->methods.filter.output_port_disconnected);
+ cc_full_descr->methods.filter.msg_iter_finalize);
if (ret) {
- BT_LOGE_STR("Cannot set filter component class's \"output port disconnected\" method.");
+ BT_LOGE_STR("Cannot set filter component class's message iterator finalization method.");
status = BT_PLUGIN_STATUS_ERROR;
BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
goto end;
}
}
- if (cc_full_descr->methods.filter.notif_iter_init) {
- ret = bt_component_class_filter_set_notification_iterator_init_method(
+ if (cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin) {
+ ret = bt_component_class_filter_set_message_iterator_seek_ns_from_origin_method(
flt_comp_class,
- cc_full_descr->methods.filter.notif_iter_init);
+ cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin);
if (ret) {
- BT_LOGE_STR("Cannot set filter component class's notification iterator initialization method.");
+ BT_LOGE_STR("Cannot set filter component class's message iterator \"seek nanoseconds from origin\" method.");
status = BT_PLUGIN_STATUS_ERROR;
BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
goto end;
}
}
- if (cc_full_descr->methods.filter.notif_iter_finalize) {
- ret = bt_component_class_filter_set_notification_iterator_finalize_method(
+ if (cc_full_descr->methods.filter.msg_iter_seek_beginning) {
+ ret = bt_component_class_filter_set_message_iterator_seek_beginning_method(
flt_comp_class,
- cc_full_descr->methods.filter.notif_iter_finalize);
+ cc_full_descr->methods.filter.msg_iter_seek_beginning);
if (ret) {
- BT_LOGE_STR("Cannot set filter component class's notification iterator finalization method.");
+ BT_LOGE_STR("Cannot set filter component class's message iterator \"seek beginning\" method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin) {
+ ret = bt_component_class_filter_set_message_iterator_can_seek_ns_from_origin_method(
+ flt_comp_class,
+ cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin);
+ if (ret) {
+ BT_LOGE_STR("Cannot set filter component class's message iterator \"can seek nanoseconds from origin\" method.");
+ status = BT_PLUGIN_STATUS_ERROR;
+ BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
+ goto end;
+ }
+ }
+
+ if (cc_full_descr->methods.filter.msg_iter_can_seek_beginning) {
+ ret = bt_component_class_filter_set_message_iterator_can_seek_beginning_method(
+ flt_comp_class,
+ cc_full_descr->methods.filter.msg_iter_can_seek_beginning);
+ if (ret) {
+ BT_LOGE_STR("Cannot set filter component class's message iterator \"can seek beginning\" method.");
status = BT_PLUGIN_STATUS_ERROR;
BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
goto end;
}
}
- if (cc_full_descr->methods.sink.input_port_disconnected) {
- ret = bt_component_class_sink_set_input_port_disconnected_method(
+ if (cc_full_descr->methods.sink.graph_is_configured) {
+ ret = bt_component_class_sink_set_graph_is_configured_method(
sink_comp_class,
- cc_full_descr->methods.sink.input_port_disconnected);
+ cc_full_descr->methods.sink.graph_is_configured);
if (ret) {
- BT_LOGE_STR("Cannot set sink component class's \"input port disconnected\" method.");
+ BT_LOGE_STR("Cannot set sink component class's \"graph is configured\" method.");
status = BT_PLUGIN_STATUS_ERROR;
BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
goto end;
* _trying_ to open this file as a compatible
* Babeltrace plugin: if it's not, it's not an
* error. And because this can be tried during
- * bt_plugin_create_all_from_dir(), it's not
+ * bt_plugin_find_all_from_dir(), it's not
* even a warning.
*/
BT_LOGD("Unknown ABI major version: abi-major=%d",
* _trying_ to open this file as a compatible
* Babeltrace plugin: if it's not, it's not an
* error. And because this can be tried during
- * bt_plugin_create_all_from_dir(), it's not
+ * bt_plugin_find_all_from_dir(), it's not
* even a warning.
*/
BT_LOGD_STR("Cannot initialize SO plugin object from sections.");
"comp-cls-addr=%p", comp_class);
}
-BT_HIDDEN
void bt_plugin_so_on_add_component_class(struct bt_plugin *plugin,
struct bt_component_class *comp_class)
{