projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Always evaluate BT_ASSERT(); add BT_ASSERT_DBG() for debug mode only
[babeltrace.git]
/
src
/
lib
/
graph
/
message
/
packet.c
diff --git
a/src/lib/graph/message/packet.c
b/src/lib/graph/message/packet.c
index 1a6169a254fc23c0bd38011066252fcc9e4cb4e0..637156d3c1f6b18cb6553c8cd99466bcb6fa3f61 100644
(file)
--- a/
src/lib/graph/message/packet.c
+++ b/
src/lib/graph/message/packet.c
@@
-21,9
+21,11
@@
* SOFTWARE.
*/
* SOFTWARE.
*/
-#define BT_LOG_TAG "MSG-PACKET"
-#include "lib/l
ib-l
ogging.h"
+#define BT_LOG_TAG "
LIB/
MSG-PACKET"
+#include "lib/logging.h"
+#include "lib/assert-pre.h"
+#include "lib/assert-post.h"
#include "compat/compiler.h"
#include <babeltrace2/trace-ir/packet.h>
#include "lib/trace-ir/packet.h"
#include "compat/compiler.h"
#include <babeltrace2/trace-ir/packet.h>
#include "lib/trace-ir/packet.h"
@@
-37,7
+39,6
@@
#include <babeltrace2/graph/message-packet-beginning.h>
#include <babeltrace2/graph/message-packet-end.h>
#include "common/assert.h"
#include <babeltrace2/graph/message-packet-beginning.h>
#include <babeltrace2/graph/message-packet-end.h>
#include "common/assert.h"
-#include "lib/assert-pre.h"
#include "lib/object.h"
#include <inttypes.h>
#include "lib/object.h"
#include <inttypes.h>
@@
-51,7
+52,8
@@
struct bt_message *new_packet_message(struct bt_graph *graph,
message = g_new0(struct bt_message_packet, 1);
if (!message) {
message = g_new0(struct bt_message_packet, 1);
if (!message) {
- BT_LOGE_STR("Failed to allocate one packet message.");
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Failed to allocate one packet message.");
goto error;
}
goto error;
}
@@
-97,6
+99,12
@@
struct bt_message *create_packet_message(
stream_class = bt_stream_borrow_class(stream);
BT_ASSERT(stream_class);
stream_class = bt_stream_borrow_class(stream);
BT_ASSERT(stream_class);
+ /*
+ * It's not possible to create a packet from a stream of which
+ * the class indicates that packets are not supported.
+ */
+ BT_ASSERT(stream_class->supports_packets);
+
if (pool == &msg_iter->graph->packet_begin_msg_pool) {
need_cs = stream_class->packets_have_beginning_default_clock_snapshot;
} else {
if (pool == &msg_iter->graph->packet_begin_msg_pool) {
need_cs = stream_class->packets_have_beginning_default_clock_snapshot;
} else {
@@
-135,7
+143,7
@@
struct bt_message *create_packet_message(
message->default_cs = bt_clock_snapshot_create(
stream_class->default_clock_class);
if (!message->default_cs) {
message->default_cs = bt_clock_snapshot_create(
stream_class->default_clock_class);
if (!message->default_cs) {
- bt_object_put_no_null_check(message);
+ bt_object_put_
ref_
no_null_check(message);
message = NULL;
goto end;
}
message = NULL;
goto end;
}
@@
-145,7
+153,7
@@
struct bt_message *create_packet_message(
BT_ASSERT(!message->packet);
message->packet = packet;
BT_ASSERT(!message->packet);
message->packet = packet;
- bt_object_get_no_null_check_no_parent_check(
+ bt_object_get_
ref_
no_null_check_no_parent_check(
&message->packet->base);
bt_packet_set_is_frozen(packet, true);
BT_LIB_LOGD("Created packet message object: "
&message->packet->base);
bt_packet_set_is_frozen(packet, true);
BT_LIB_LOGD("Created packet message object: "
@@
-229,7
+237,7
@@
void recycle_packet_message(struct bt_message *msg, struct bt_object_pool *pool)
BT_LIB_LOGD("Recycling packet message: %!+n", msg);
bt_message_reset(msg);
BT_LIB_LOGD("Recycling packet message: %!+n", msg);
bt_message_reset(msg);
- bt_object_put_no_null_check(&packet_msg->packet->base);
+ bt_object_put_
ref_
no_null_check(&packet_msg->packet->base);
if (packet_msg->default_cs) {
bt_clock_snapshot_recycle(packet_msg->default_cs);
if (packet_msg->default_cs) {
bt_clock_snapshot_recycle(packet_msg->default_cs);
@@
-272,8
+280,8
@@
struct bt_packet *bt_message_packet_beginning_borrow_packet(
{
struct bt_message_packet *packet_msg = (void *) message;
{
struct bt_message_packet *packet_msg = (void *) message;
- BT_ASSERT_PRE_NON_NULL(message, "Message");
- BT_ASSERT_PRE_MSG_IS_TYPE(message,
+ BT_ASSERT_PRE_
DEV_
NON_NULL(message, "Message");
+ BT_ASSERT_PRE_
DEV_
MSG_IS_TYPE(message,
BT_MESSAGE_TYPE_PACKET_BEGINNING);
return packet_msg->packet;
}
BT_MESSAGE_TYPE_PACKET_BEGINNING);
return packet_msg->packet;
}
@@
-290,8
+298,8
@@
struct bt_packet *bt_message_packet_end_borrow_packet(
{
struct bt_message_packet *packet_msg = (void *) message;
{
struct bt_message_packet *packet_msg = (void *) message;
- BT_ASSERT_PRE_NON_NULL(message, "Message");
- BT_ASSERT_PRE_MSG_IS_TYPE(message,
+ BT_ASSERT_PRE_
DEV_
NON_NULL(message, "Message");
+ BT_ASSERT_PRE_
DEV_
MSG_IS_TYPE(message,
BT_MESSAGE_TYPE_PACKET_END);
return packet_msg->packet;
}
BT_MESSAGE_TYPE_PACKET_END);
return packet_msg->packet;
}
@@
-310,8
+318,9
@@
borrow_packet_message_default_clock_snapshot_const(
{
struct bt_message_packet *packet_msg = (void *) message;
{
struct bt_message_packet *packet_msg = (void *) message;
- BT_ASSERT(message);
- BT_ASSERT_PRE(packet_msg->packet->stream->class->default_clock_class,
+ BT_ASSERT_DBG(message);
+ BT_ASSERT_PRE_DEV(
+ packet_msg->packet->stream->class->default_clock_class,
"Message's stream's class has no default clock class: "
"%![msg-]+n, %![sc-]+S",
message, packet_msg->packet->stream->class);
"Message's stream's class has no default clock class: "
"%![msg-]+n, %![sc-]+S",
message, packet_msg->packet->stream->class);
@@
-322,8
+331,8
@@
const struct bt_clock_snapshot *
bt_message_packet_beginning_borrow_default_clock_snapshot_const(
const struct bt_message *msg)
{
bt_message_packet_beginning_borrow_default_clock_snapshot_const(
const struct bt_message *msg)
{
- BT_ASSERT_PRE_NON_NULL(msg, "Message");
- BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_BEGINNING);
+ BT_ASSERT_PRE_
DEV_
NON_NULL(msg, "Message");
+ BT_ASSERT_PRE_
DEV_
MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_BEGINNING);
return borrow_packet_message_default_clock_snapshot_const(msg);
}
return borrow_packet_message_default_clock_snapshot_const(msg);
}
@@
-331,8
+340,8
@@
const struct bt_clock_snapshot *
bt_message_packet_end_borrow_default_clock_snapshot_const(
const struct bt_message *msg)
{
bt_message_packet_end_borrow_default_clock_snapshot_const(
const struct bt_message *msg)
{
- BT_ASSERT_PRE_NON_NULL(msg, "Message");
- BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_END);
+ BT_ASSERT_PRE_
DEV_
NON_NULL(msg, "Message");
+ BT_ASSERT_PRE_
DEV_
MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_END);
return borrow_packet_message_default_clock_snapshot_const(msg);
}
return borrow_packet_message_default_clock_snapshot_const(msg);
}
@@
-343,7
+352,7
@@
borrow_packet_message_stream_class_default_clock_class(
{
struct bt_message_packet *packet_msg = (void *) msg;
{
struct bt_message_packet *packet_msg = (void *) msg;
- BT_ASSERT(msg);
+ BT_ASSERT
_DBG
(msg);
return packet_msg->packet->stream->class->default_clock_class;
}
return packet_msg->packet->stream->class->default_clock_class;
}
@@
-351,8
+360,8
@@
const struct bt_clock_class *
bt_message_packet_beginning_borrow_stream_class_default_clock_class_const(
const struct bt_message *msg)
{
bt_message_packet_beginning_borrow_stream_class_default_clock_class_const(
const struct bt_message *msg)
{
- BT_ASSERT_PRE_NON_NULL(msg, "Message");
- BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_BEGINNING);
+ BT_ASSERT_PRE_
DEV_
NON_NULL(msg, "Message");
+ BT_ASSERT_PRE_
DEV_
MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_BEGINNING);
return borrow_packet_message_stream_class_default_clock_class(msg);
}
return borrow_packet_message_stream_class_default_clock_class(msg);
}
@@
-360,7
+369,7
@@
const struct bt_clock_class *
bt_message_packet_end_borrow_stream_class_default_clock_class_const(
const struct bt_message *msg)
{
bt_message_packet_end_borrow_stream_class_default_clock_class_const(
const struct bt_message *msg)
{
- BT_ASSERT_PRE_NON_NULL(msg, "Message");
- BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_END);
+ BT_ASSERT_PRE_
DEV_
NON_NULL(msg, "Message");
+ BT_ASSERT_PRE_
DEV_
MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_END);
return borrow_packet_message_stream_class_default_clock_class(msg);
}
return borrow_packet_message_stream_class_default_clock_class(msg);
}
This page took
0.026156 seconds
and
4
git commands to generate.