/*
+ * SPDX-License-Identifier: MIT
+ *
* Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
*/
#define BT_LOG_TAG "LIB/EVENT"
-#include "lib/lib-logging.h"
+#include "lib/logging.h"
-#include "lib/assert-pre.h"
-#include <babeltrace2/trace-ir/event-const.h>
+#include "lib/assert-cond.h"
+#include <babeltrace2/trace-ir/event.h>
#include <babeltrace2/trace-ir/event-class.h>
#include <babeltrace2/trace-ir/stream-class.h>
-#include <babeltrace2/trace-ir/stream-class-const.h>
#include <babeltrace2/trace-ir/packet.h>
#include <babeltrace2/trace-ir/trace.h>
#include "common/assert.h"
#include "compat/compiler.h"
-#include <inttypes.h>
+#include <stdbool.h>
#include "field.h"
#include "field-class.h"
#include "stream-class.h"
#include "stream.h"
#include "packet.h"
-#include "trace.h"
#include "packet.h"
-#include "attributes.h"
#include "event-class.h"
-BT_HIDDEN
void _bt_event_set_is_frozen(const struct bt_event *event, bool is_frozen)
{
- BT_ASSERT(event);
+ BT_ASSERT_DBG(event);
BT_LIB_LOGD("Setting event's frozen state: %!+e, is-frozen=%d",
event, is_frozen);
}
((struct bt_event *) event)->frozen = is_frozen;
- BT_LOGD_STR("Setting event's packet's frozen state.");
- bt_packet_set_is_frozen(event->packet, is_frozen);
+
+ if (event->packet) {
+ BT_LOGD_STR("Setting event's packet's frozen state.");
+ bt_packet_set_is_frozen(event->packet, is_frozen);
+ }
}
-BT_HIDDEN
struct bt_event *bt_event_new(struct bt_event_class *event_class)
{
struct bt_event *event = NULL;
BT_ASSERT(event_class);
event = g_new0(struct bt_event, 1);
if (!event) {
- BT_LOGE_STR("Failed to allocate one event.");
+ BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one event.");
goto error;
}
return event;
}
+BT_EXPORT
struct bt_event_class *bt_event_borrow_class(struct bt_event *event)
{
- BT_ASSERT_PRE_NON_NULL(event, "Event");
+ BT_ASSERT_PRE_DEV_EVENT_NON_NULL(event);
return event->class;
}
+BT_EXPORT
const struct bt_event_class *bt_event_borrow_class_const(
const struct bt_event *event)
{
return bt_event_borrow_class((void *) event);
}
+BT_EXPORT
struct bt_stream *bt_event_borrow_stream(struct bt_event *event)
{
- BT_ASSERT_PRE_NON_NULL(event, "Event");
- return event->packet ? event->packet->stream : NULL;
+ BT_ASSERT_PRE_DEV_EVENT_NON_NULL(event);
+ return event->stream;
}
+BT_EXPORT
const struct bt_stream *bt_event_borrow_stream_const(
const struct bt_event *event)
{
return bt_event_borrow_stream((void *) event);
}
+BT_EXPORT
struct bt_field *bt_event_borrow_common_context_field(struct bt_event *event)
{
- BT_ASSERT_PRE_NON_NULL(event, "Event");
+ BT_ASSERT_PRE_DEV_EVENT_NON_NULL(event);
return event->common_context_field;
}
+BT_EXPORT
const struct bt_field *bt_event_borrow_common_context_field_const(
const struct bt_event *event)
{
- BT_ASSERT_PRE_NON_NULL(event, "Event");
+ BT_ASSERT_PRE_DEV_EVENT_NON_NULL(event);
return event->common_context_field;
}
+BT_EXPORT
struct bt_field *bt_event_borrow_specific_context_field(struct bt_event *event)
{
- BT_ASSERT_PRE_NON_NULL(event, "Event");
+ BT_ASSERT_PRE_DEV_EVENT_NON_NULL(event);
return event->specific_context_field;
}
+BT_EXPORT
const struct bt_field *bt_event_borrow_specific_context_field_const(
const struct bt_event *event)
{
- BT_ASSERT_PRE_NON_NULL(event, "Event");
+ BT_ASSERT_PRE_DEV_EVENT_NON_NULL(event);
return event->specific_context_field;
}
+BT_EXPORT
struct bt_field *bt_event_borrow_payload_field(struct bt_event *event)
{
- BT_ASSERT_PRE_NON_NULL(event, "Event");
+ BT_ASSERT_PRE_DEV_EVENT_NON_NULL(event);
return event->payload_field;
}
+BT_EXPORT
const struct bt_field *bt_event_borrow_payload_field_const(
const struct bt_event *event)
{
- BT_ASSERT_PRE_NON_NULL(event, "Event");
+ BT_ASSERT_PRE_DEV_EVENT_NON_NULL(event);
return event->payload_field;
}
-BT_HIDDEN
void bt_event_destroy(struct bt_event *event)
{
BT_ASSERT(event);
bt_object_put_ref(event->class);
BT_LOGD_STR("Putting event's packet.");
BT_OBJECT_PUT_REF_AND_RESET(event->packet);
+ BT_LOGD_STR("Putting event's stream.");
+ BT_OBJECT_PUT_REF_AND_RESET(event->stream);
g_free(event);
}
+BT_EXPORT
struct bt_packet *bt_event_borrow_packet(struct bt_event *event)
{
- BT_ASSERT_PRE_NON_NULL(event, "Event");
+ BT_ASSERT_PRE_DEV_EVENT_NON_NULL(event);
return event->packet;
}
+BT_EXPORT
const struct bt_packet *bt_event_borrow_packet_const(
const struct bt_event *event)
{