* SOFTWARE.
*/
+#define BT_LOG_TAG "PORT"
+#include <babeltrace/lib-logging-internal.h>
+
#include <babeltrace/graph/port.h>
#include <babeltrace/graph/component-internal.h>
#include <babeltrace/graph/port-internal.h>
{
struct bt_port *port = container_of(obj, struct bt_port, base);
+ BT_LOGD("Destroying port: addr=%p, name=\"%s\", comp-addr=%p",
+ port, bt_port_get_name(port), obj->parent);
+
if (port->name) {
g_string_free(port->name, TRUE);
}
+
g_free(port);
}
assert(type == BT_PORT_TYPE_INPUT || type == BT_PORT_TYPE_OUTPUT);
if (strlen(name) == 0) {
+ BT_LOGW_STR("Invalid parameter: name is an empty string.");
goto end;
}
port = g_new0(struct bt_port, 1);
if (!port) {
+ BT_LOGE_STR("Failed to allocate one port.");
goto end;
}
+ BT_LOGD("Creating port for component: "
+ "comp-addr=%p, comp-name=\"%s\", port-type=%s, "
+ "port-name=\"%s\"",
+ parent_component, bt_component_get_name(parent_component),
+ bt_port_type_string(type), name);
+
bt_object_init(port, bt_port_destroy);
port->name = g_string_new(name);
if (!port->name) {
+ BT_LOGE_STR("Failed to allocate one GString.");
BT_PUT(port);
goto end;
}
port->type = type;
port->user_data = user_data;
-
bt_object_set_parent(port, &parent_component->base);
+ BT_LOGD("Created port for component: "
+ "comp-addr=%p, comp-name=\"%s\", port-type=%s, "
+ "port-name=\"%s\", port-addr=%p",
+ parent_component, bt_component_get_name(parent_component),
+ bt_port_type_string(type), name, port);
+
end:
return port;
}
{
struct bt_connection *connection = NULL;
- if (!port || !port->connection) {
+ if (!port) {
+ BT_LOGW_STR("Invalid parameter: port is NULL.");
+ goto end;
+ }
+
+ if (!port->connection) {
+ /* Not an error: means disconnected */
goto end;
}
connection = bt_get(port->connection);
+
end:
return connection;
}
* connection exists.
*/
port->connection = connection;
+ BT_LOGV("Set port's connection: "
+ "port-addr=%p, port-name=\"%s\", conn-addr=%p",
+ port, bt_port_get_name(port), connection);
}
int bt_private_port_remove_from_component(
struct bt_component *comp = NULL;
if (!port) {
+ BT_LOGW_STR("Invalid parameter: private port is NULL.");
ret = -1;
goto end;
}
comp = (void *) bt_object_get_parent(port);
+
+ /* bt_component_remove_port() logs details */
ret = bt_component_remove_port(comp, port);
end:
int ret = 0;
if (!port) {
+ BT_LOGW_STR("Invalid parameter: port is NULL.");
ret = -1;
goto end;
}
if (port->connection) {
bt_connection_disconnect_ports(port->connection);
+ BT_LOGV("Disconnected port: "
+ "port-addr=%p, port-name=\"%s\"",
+ port, bt_port_get_name(port));
}
end:
int ret;
if (!port) {
+ BT_LOGW_STR("Invalid parameter: port is NULL.");
ret = -1;
goto end;
}