* SOFTWARE.
*/
+#define BT_LOG_TAG "NOTIF-PACKET"
+#include <babeltrace/lib-logging-internal.h>
+
#include <babeltrace/compiler-internal.h>
+#include <babeltrace/ctf-ir/packet.h>
+#include <babeltrace/ctf-ir/packet-internal.h>
+#include <babeltrace/ctf-ir/stream-class.h>
+#include <babeltrace/ctf-ir/stream.h>
+#include <babeltrace/ctf-ir/stream-internal.h>
#include <babeltrace/graph/notification-packet-internal.h>
+#include <babeltrace/assert-internal.h>
+#include <babeltrace/assert-pre-internal.h>
+#include <inttypes.h>
static
void bt_notification_packet_begin_destroy(struct bt_object *obj)
struct bt_notification_packet_begin *notification =
(struct bt_notification_packet_begin *) obj;
+ BT_LOGD("Destroying packet beginning notification: addr=%p",
+ notification);
+ BT_LOGD_STR("Putting packet.");
BT_PUT(notification->packet);
g_free(notification);
}
struct bt_notification_packet_end *notification =
(struct bt_notification_packet_end *) obj;
+ BT_LOGD("Destroying packet end notification: addr=%p",
+ notification);
+ BT_LOGD_STR("Putting packet.");
BT_PUT(notification->packet);
g_free(notification);
}
struct bt_notification *bt_notification_packet_begin_create(
- struct bt_ctf_packet *packet)
+ struct bt_packet *packet)
{
struct bt_notification_packet_begin *notification;
-
- if (!packet) {
+ struct bt_stream *stream;
+ struct bt_stream_class *stream_class;
+
+ BT_ASSERT_PRE_NON_NULL(packet, "Packet");
+ stream = bt_packet_borrow_stream(packet);
+ BT_ASSERT(stream);
+ stream_class = bt_stream_borrow_class(stream);
+ BT_ASSERT(stream_class);
+ BT_LOGD("Creating packet beginning notification object: "
+ "packet-addr=%p, stream-addr=%p, stream-name=\"%s\", "
+ "stream-class-addr=%p, stream-class-name=\"%s\", "
+ "stream-class-id=%" PRId64,
+ packet, stream, bt_stream_get_name(stream),
+ stream_class,
+ bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class));
+ notification = g_new0(struct bt_notification_packet_begin, 1);
+ if (!notification) {
+ BT_LOGE_STR("Failed to allocate one packet beginning notification.");
goto error;
}
- notification = g_new0(struct bt_notification_packet_begin, 1);
bt_notification_init(¬ification->parent,
BT_NOTIFICATION_TYPE_PACKET_BEGIN,
bt_notification_packet_begin_destroy);
notification->packet = bt_get(packet);
+ BT_LOGD("Created packet beginning notification object: "
+ "packet-addr=%p, stream-addr=%p, stream-name=\"%s\", "
+ "stream-class-addr=%p, stream-class-name=\"%s\", "
+ "stream-class-id=%" PRId64 ", addr=%p",
+ packet, stream, bt_stream_get_name(stream),
+ stream_class,
+ bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class), notification);
return ¬ification->parent;
error:
return NULL;
}
-struct bt_ctf_packet *bt_notification_packet_begin_get_packet(
+struct bt_packet *bt_notification_packet_begin_borrow_packet(
struct bt_notification *notification)
{
- struct bt_ctf_packet *ret = NULL;
struct bt_notification_packet_begin *packet_begin;
- if (notification->type != BT_NOTIFICATION_TYPE_PACKET_BEGIN) {
- goto end;
- }
-
+ BT_ASSERT_PRE_NON_NULL(notification, "Notification");
+ BT_ASSERT_PRE_NOTIF_IS_TYPE(notification,
+ BT_NOTIFICATION_TYPE_PACKET_BEGIN);
packet_begin = container_of(notification,
struct bt_notification_packet_begin, parent);
- ret = bt_get(packet_begin->packet);
-end:
- return ret;
+ return packet_begin->packet;
}
struct bt_notification *bt_notification_packet_end_create(
- struct bt_ctf_packet *packet)
+ struct bt_packet *packet)
{
struct bt_notification_packet_end *notification;
-
- if (!packet) {
+ struct bt_stream *stream;
+ struct bt_stream_class *stream_class;
+
+ BT_ASSERT_PRE_NON_NULL(packet, "Packet");
+ stream = bt_packet_borrow_stream(packet);
+ BT_ASSERT(stream);
+ stream_class = bt_stream_borrow_class(stream);
+ BT_ASSERT(stream_class);
+ BT_LOGD("Creating packet end notification object: "
+ "packet-addr=%p, stream-addr=%p, stream-name=\"%s\", "
+ "stream-class-addr=%p, stream-class-name=\"%s\", "
+ "stream-class-id=%" PRId64,
+ packet, stream, bt_stream_get_name(stream),
+ stream_class,
+ bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class));
+ notification = g_new0(struct bt_notification_packet_end, 1);
+ if (!notification) {
+ BT_LOGE_STR("Failed to allocate one packet end notification.");
goto error;
}
- notification = g_new0(struct bt_notification_packet_end, 1);
bt_notification_init(¬ification->parent,
BT_NOTIFICATION_TYPE_PACKET_END,
bt_notification_packet_end_destroy);
notification->packet = bt_get(packet);
+ BT_LOGD("Created packet end notification object: "
+ "packet-addr=%p, stream-addr=%p, stream-name=\"%s\", "
+ "stream-class-addr=%p, stream-class-name=\"%s\", "
+ "stream-class-id=%" PRId64 ", addr=%p",
+ packet, stream, bt_stream_get_name(stream),
+ stream_class,
+ bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class), notification);
return ¬ification->parent;
error:
return NULL;
}
-struct bt_ctf_packet *bt_notification_packet_end_get_packet(
+struct bt_packet *bt_notification_packet_end_borrow_packet(
struct bt_notification *notification)
{
- struct bt_ctf_packet *ret = NULL;
struct bt_notification_packet_end *packet_end;
- if (notification->type != BT_NOTIFICATION_TYPE_PACKET_END) {
- goto end;
- }
-
+ BT_ASSERT_PRE_NON_NULL(notification, "Notification");
+ BT_ASSERT_PRE_NOTIF_IS_TYPE(notification,
+ BT_NOTIFICATION_TYPE_PACKET_END);
packet_end = container_of(notification,
struct bt_notification_packet_end, parent);
- ret = bt_get(packet_end->packet);
-end:
- return ret;
+ return packet_end->packet;
}