# Graph, component, and notification API
babeltracegraphincludedir = "$(includedir)/babeltrace/graph"
babeltracegraphinclude_HEADERS = \
- babeltrace/graph/clock-class-priority-map.h \
babeltrace/graph/component-class-filter.h \
babeltrace/graph/component-class-sink.h \
babeltrace/graph/component-class-source.h \
babeltrace/graph/component.h \
babeltrace/graph/connection.h \
babeltrace/graph/graph.h \
- babeltrace/graph/notification-discarded-events.h \
- babeltrace/graph/notification-discarded-packets.h \
babeltrace/graph/notification-event.h \
babeltrace/graph/notification-inactivity.h \
babeltrace/graph/notification-iterator.h \
babeltrace/ctf-ir/clock-class-internal.h \
babeltrace/ctf-ir/field-types-internal.h \
babeltrace/ctf-ir/clock-value-internal.h \
+ babeltrace/ctf-ir/clock-value-set-internal.h \
babeltrace/ctf-ir/attributes-internal.h \
babeltrace/ctf-ir/stream-internal.h \
babeltrace/ctf-ir/resolve-internal.h \
babeltrace/graph/component-class-sink-colander-internal.h \
babeltrace/graph/notification-inactivity-internal.h \
babeltrace/graph/component-source-internal.h \
- babeltrace/graph/notification-discarded-elements-internal.h \
babeltrace/graph/notification-packet-internal.h \
babeltrace/graph/notification-iterator-internal.h \
babeltrace/graph/notification-internal.h \
babeltrace/graph/component-class-internal.h \
babeltrace/graph/component-sink-internal.h \
babeltrace/graph/port-internal.h \
- babeltrace/graph/clock-class-priority-map-internal.h \
babeltrace/list-internal.h \
version.h \
version.i
#include <babeltrace/plugin/plugin.h>
/* Graph, component, and notification API */
-#include <babeltrace/graph/clock-class-priority-map.h>
#include <babeltrace/graph/component-class-filter.h>
#include <babeltrace/graph/component-class-sink.h>
#include <babeltrace/graph/component-class-source.h>
#include <babeltrace/graph/component.h>
#include <babeltrace/graph/connection.h>
#include <babeltrace/graph/graph.h>
-#include <babeltrace/graph/notification-discarded-events.h>
-#include <babeltrace/graph/notification-discarded-packets.h>
#include <babeltrace/graph/notification-event.h>
#include <babeltrace/graph/notification-inactivity.h>
#include <babeltrace/graph/notification-iterator.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/object-internal.h>
+#include <babeltrace/ctf-ir/clock-class-internal.h>
#include <stdbool.h>
#include <stdint.h>
clock_value->frozen = is_frozen;
}
+static inline
+uint64_t ns_from_value(uint64_t frequency, uint64_t value)
+{
+ uint64_t ns;
+
+ if (frequency == UINT64_C(1000000000)) {
+ ns = value;
+ } else {
+ double dblres = ((1e9 * (double) value) / (double) frequency);
+
+ if (dblres >= (double) UINT64_MAX) {
+ /* Overflows uint64_t */
+ ns = -1ULL;
+ } else {
+ ns = (uint64_t) dblres;
+ }
+ }
+
+ return ns;
+}
+
+static inline
+int ns_from_epoch(struct bt_clock_class *clock_class, uint64_t value,
+ int64_t *ns_from_epoch, bool *overflows)
+{
+ int ret = 0;
+ int64_t diff;
+ int64_t s_ns;
+ uint64_t u_ns;
+ uint64_t cycles;
+
+ *overflows = false;
+
+ /* Initialize nanosecond timestamp to clock's offset in seconds */
+ if (clock_class->offset_s <= (INT64_MIN / INT64_C(1000000000)) ||
+ clock_class->offset_s >= (INT64_MAX / INT64_C(1000000000))) {
+ /*
+ * Overflow: offset in seconds converted to nanoseconds
+ * is outside the int64_t range.
+ */
+ *overflows = true;
+ goto end;
+ }
+
+ *ns_from_epoch = clock_class->offset_s * INT64_C(1000000000);
+
+ /* Add offset in cycles */
+ if (clock_class->offset < 0) {
+ cycles = (uint64_t) -clock_class->offset;
+ } else {
+ cycles = (uint64_t) clock_class->offset;
+ }
+
+ u_ns = ns_from_value(clock_class->frequency, cycles);
+
+ if (u_ns == UINT64_C(-1) || u_ns >= INT64_MAX) {
+ /*
+ * Overflow: offset in cycles converted to nanoseconds
+ * is outside the int64_t range.
+ */
+ *overflows = true;
+ goto end;
+ }
+
+ s_ns = (int64_t) u_ns;
+ BT_ASSERT(s_ns >= 0);
+
+ if (clock_class->offset < 0) {
+ if (*ns_from_epoch >= 0) {
+ /*
+ * Offset in cycles is negative so it must also
+ * be negative once converted to nanoseconds.
+ */
+ s_ns = -s_ns;
+ goto offset_ok;
+ }
+
+ diff = *ns_from_epoch - INT64_MIN;
+
+ if (s_ns >= diff) {
+ /*
+ * Overflow: current timestamp in nanoseconds
+ * plus the offset in cycles converted to
+ * nanoseconds is outside the int64_t range.
+ */
+ *overflows = true;
+ goto end;
+ }
+
+ /*
+ * Offset in cycles is negative so it must also be
+ * negative once converted to nanoseconds.
+ */
+ s_ns = -s_ns;
+ } else {
+ if (*ns_from_epoch <= 0) {
+ goto offset_ok;
+ }
+
+ diff = INT64_MAX - *ns_from_epoch;
+
+ if (s_ns >= diff) {
+ /*
+ * Overflow: current timestamp in nanoseconds
+ * plus the offset in cycles converted to
+ * nanoseconds is outside the int64_t range.
+ */
+ *overflows = true;
+ goto end;
+ }
+ }
+
+offset_ok:
+ *ns_from_epoch += s_ns;
+
+ /* Add clock value (cycles) */
+ u_ns = ns_from_value(clock_class->frequency, value);
+
+ if (u_ns == -1ULL || u_ns >= INT64_MAX) {
+ /*
+ * Overflow: value converted to nanoseconds is outside
+ * the int64_t range.
+ */
+ *overflows = true;
+ goto end;
+ }
+
+ s_ns = (int64_t) u_ns;
+ BT_ASSERT(s_ns >= 0);
+
+ /* Clock value (cycles) is always positive */
+ if (*ns_from_epoch <= 0) {
+ goto value_ok;
+ }
+
+ diff = INT64_MAX - *ns_from_epoch;
+
+ if (s_ns >= diff) {
+ /*
+ * Overflow: current timestamp in nanoseconds plus the
+ * clock value converted to nanoseconds is outside the
+ * int64_t range.
+ */
+ *overflows = true;
+ goto end;
+ }
+
+value_ok:
+ *ns_from_epoch += s_ns;
+
+end:
+ if (*overflows) {
+ *ns_from_epoch = 0;
+ ret = -1;
+ }
+
+ return ret;
+}
+
+static inline
+void set_ns_from_epoch(struct bt_clock_value *clock_value)
+{
+ (void) ns_from_epoch(clock_value->clock_class,
+ clock_value->value, &clock_value->ns_from_epoch,
+ &clock_value->ns_from_epoch_overflows);
+}
+
+static inline
+void bt_clock_value_set_raw_value(struct bt_clock_value *clock_value,
+ uint64_t cycles)
+{
+ BT_ASSERT(clock_value);
+
+ clock_value->value = cycles;
+ set_ns_from_epoch(clock_value);
+ bt_clock_value_set(clock_value);
+}
+
+static inline
+int bt_clock_value_set_value_inline(struct bt_clock_value *clock_value,
+ uint64_t raw_value)
+{
+#ifdef BT_ASSERT_PRE_NON_NULL
+ BT_ASSERT_PRE_NON_NULL(clock_value, "Clock value");
+#endif
+
+#ifdef BT_ASSERT_PRE_HOT
+ BT_ASSERT_PRE_HOT(clock_value, "Clock value", ": %!+k", clock_value);
+#endif
+
+ bt_clock_value_set_raw_value(clock_value, raw_value);
+ return 0;
+}
+
#ifdef BT_DEV_MODE
# define bt_clock_value_set_is_frozen _bt_clock_value_set_is_frozen
#else
--- /dev/null
+#ifndef BABELTRACE_GRAPH_CLOCK_VALUE_SET_H
+#define BABELTRACE_GRAPH_CLOCK_VALUE_SET_H
+
+/*
+ * Copyright 2018 Philippe Proulx <pproulx@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.
+ */
+
+#include <stdint.h>
+#include <glib.h>
+#include <babeltrace/ctf-ir/clock-value-internal.h>
+#include <babeltrace/ctf-ir/clock-class-internal.h>
+#include <babeltrace/assert-internal.h>
+
+struct bt_clock_value_set {
+ /* Unique objects owned by this */
+ GPtrArray *clock_values;
+
+ /* Weak; points to one of the clock values above */
+ struct bt_clock_value *default_cv;
+};
+
+static inline
+int bt_clock_value_set_initialize(struct bt_clock_value_set *cv_set)
+{
+ int ret = 0;
+
+ cv_set->clock_values = g_ptr_array_sized_new(1);
+ if (!cv_set->clock_values) {
+#ifdef BT_LOGE_STR
+ BT_LOGE_STR("Failed to allocate one GPtrArray.");
+#endif
+
+ ret = -1;
+ goto end;
+ }
+
+ cv_set->default_cv = NULL;
+
+end:
+ return ret;
+}
+
+static inline
+void bt_clock_value_set_reset(struct bt_clock_value_set *cv_set)
+{
+ uint64_t i;
+
+ BT_ASSERT(cv_set);
+ BT_ASSERT(cv_set->clock_values);
+
+ for (i = 0; i < cv_set->clock_values->len; i++) {
+ struct bt_clock_value *cv = cv_set->clock_values->pdata[i];
+
+ BT_ASSERT(cv);
+ bt_clock_value_reset(cv);
+ bt_clock_value_set_is_frozen(cv, false);
+ }
+
+ cv_set->default_cv = NULL;
+}
+
+static inline
+void bt_clock_value_set_finalize(struct bt_clock_value_set *cv_set)
+{
+ uint64_t i;
+
+ BT_ASSERT(cv_set);
+
+ if (cv_set->clock_values) {
+ for (i = 0; i < cv_set->clock_values->len; i++) {
+ struct bt_clock_value *cv =
+ cv_set->clock_values->pdata[i];
+
+ BT_ASSERT(cv);
+ bt_clock_value_recycle(cv);
+ }
+
+ g_ptr_array_free(cv_set->clock_values, TRUE);
+ }
+
+ cv_set->default_cv = NULL;
+}
+
+static inline
+int bt_clock_value_set_set_clock_value(
+ struct bt_clock_value_set *cv_set,
+ struct bt_clock_class *cc, uint64_t raw_value,
+ bt_bool is_default)
+{
+ int ret = 0;
+ struct bt_clock_value *clock_value = NULL;
+ uint64_t i;
+
+ BT_ASSERT(cv_set);
+ BT_ASSERT(cc);
+
+ /* Check if we already have a value for this clock class */
+ for (i = 0; i < cv_set->clock_values->len; i++) {
+ struct bt_clock_value *cv = cv_set->clock_values->pdata[i];
+
+ BT_ASSERT(cv);
+
+ if (cv->clock_class == cc) {
+ clock_value = cv;
+ break;
+ }
+ }
+
+ if (!clock_value) {
+ clock_value = bt_clock_value_create(cc);
+ if (!clock_value) {
+#ifdef BT_LIB_LOGE
+ BT_LIB_LOGE("Cannot create a clock value from a clock class: "
+ "%![cc-]+K", cc);
+#endif
+
+ ret = -1;
+ goto end;
+ }
+
+ g_ptr_array_add(cv_set->clock_values, clock_value);
+ }
+
+#ifdef BT_ASSERT_PRE_HOT
+ BT_ASSERT_PRE_HOT(clock_value, "Clock value", ": %!+k", clock_value);
+#endif
+
+ ret = bt_clock_value_set_value_inline(clock_value, raw_value);
+ if (ret) {
+ goto end;
+ }
+
+ if (is_default) {
+ cv_set->default_cv = clock_value;
+ }
+
+end:
+ return ret;
+}
+
+#endif /* BABELTRACE_GRAPH_CLOCK_VALUE_SET_H */
return bt_get(bt_clock_value_borrow_class(clock_value));
}
-extern int bt_clock_value_set_value(
- struct bt_clock_value *clock_value, uint64_t raw_value);
extern int bt_clock_value_get_value(
struct bt_clock_value *clock_value, uint64_t *raw_value);
extern int bt_clock_value_get_value_ns_from_epoch(
struct bt_event_class_common *event_class,
struct bt_clock_class **expected_clock_class);
-BT_HIDDEN
-int bt_event_class_update_event_pool_clock_values(
- struct bt_event_class *event_class);
-
static inline
const char *bt_event_class_common_get_name(
struct bt_event_class_common *event_class)
#include <babeltrace/ctf-ir/fields.h>
#include <babeltrace/ctf-ir/fields-internal.h>
#include <babeltrace/ctf-ir/event-class-internal.h>
-#include <babeltrace/ctf-ir/clock-value-internal.h>
+#include <babeltrace/ctf-ir/clock-value-set-internal.h>
#include <babeltrace/ctf-ir/field-wrapper-internal.h>
#include <babeltrace/ctf-ir/validation-internal.h>
#include <babeltrace/object-internal.h>
struct bt_event {
struct bt_event_common common;
-
- /* Maps clock classes to bt_clock_value. */
- GHashTable *clock_values;
+ struct bt_clock_value_set cv_set;
struct bt_packet *packet;
};
#endif
#define BT_ASSERT_PRE_EVENT_COMMON_HOT(_event, _name) \
- BT_ASSERT_PRE_HOT((_event), (_name), ": +%!+_e", (_event))
+ BT_ASSERT_PRE_HOT((_event), (_name), ": %!+_e", (_event))
static inline
struct bt_event_class_common *bt_event_common_borrow_class(
static inline
void _bt_event_reset_dev_mode(struct bt_event *event)
{
- GHashTableIter iter;
- gpointer key, value;
-
BT_ASSERT(event);
if (event->common.header_field) {
event->common.payload_field, false);
bt_field_common_reset_recursive(event->common.payload_field);
}
-
- g_hash_table_iter_init(&iter, event->clock_values);
- while (g_hash_table_iter_next(&iter, &key, &value)) {
- struct bt_clock_value *clock_value = value;
-
- BT_ASSERT(clock_value);
- bt_clock_value_reset(clock_value);
- bt_clock_value_set_is_frozen(clock_value, false);
- }
}
#ifdef BT_DEV_MODE
{
BT_ASSERT(event);
bt_event_set_is_frozen(event, false);
- bt_event_reset_dev_mode(event);
+ bt_clock_value_set_reset(&event->cv_set);
bt_object_put_no_null_check(&event->packet->base);
event->packet = NULL;
}
/* For bt_get() */
#include <babeltrace/ref.h>
+/* For bt_bool */
+#include <babeltrace/types.h>
+
#include <stdint.h>
#include <stddef.h>
@{
*/
-extern struct bt_clock_value *bt_event_borrow_clock_value(
- struct bt_event *event,
- struct bt_clock_class *clock_class);
+extern int bt_event_set_clock_value(struct bt_event *event,
+ struct bt_clock_class *clock_class, uint64_t raw_value,
+ bt_bool is_default);
+
+extern struct bt_clock_value *bt_event_borrow_default_clock_value(
+ struct bt_event *event);
/** @} */
"%![ft-]+_F", bt_common_field_type_id_string(_type_id), (_ft))
#define BT_ASSERT_PRE_FT_HOT(_ft, _name) \
- BT_ASSERT_PRE_HOT((_ft), (_name), ": +%!+_F", (_ft))
+ BT_ASSERT_PRE_HOT((_ft), (_name), ": %!+_F", (_ft))
#define BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(_ft, _index) \
(&g_array_index(((struct bt_field_type_common_structure *) (_ft))->fields, \
_name " is not set: %!+_f", (_field))
#define BT_ASSERT_PRE_FIELD_COMMON_HOT(_field, _name) \
- BT_ASSERT_PRE_HOT((_field), (_name), ": +%!+_f", (_field))
+ BT_ASSERT_PRE_HOT((_field), (_name), ": %!+_f", (_field))
struct bt_field;
struct bt_field_common;
#include <babeltrace/ctf-ir/field-wrapper-internal.h>
#include <babeltrace/object-internal.h>
#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/ctf-ir/clock-value-set-internal.h>
struct bt_packet {
struct bt_object base;
struct bt_field_wrapper *header;
struct bt_field_wrapper *context;
struct bt_stream *stream;
+ struct bt_clock_value_set begin_cv_set;
+ struct bt_clock_value_set end_cv_set;
int frozen;
};
* http://www.efficios.com/ctf
*/
+#include <stdint.h>
+
/* For bt_get() */
#include <babeltrace/ref.h>
-#include <stdint.h>
+/* For bt_bool */
+#include <babeltrace/types.h>
#ifdef __cplusplus
extern "C" {
struct bt_packet_header_field;
struct bt_packet_context_field;
struct bt_stream;
+struct bt_clock_value;
+struct bt_clock_class;
/**
@name Creation and parent access functions
/** @} */
+extern int bt_packet_set_beginning_clock_value(struct bt_packet *packet,
+ struct bt_clock_class *clock_class, uint64_t raw_value,
+ bt_bool is_default);
+
+extern struct bt_clock_value *bt_packet_borrow_default_beginning_clock_value(
+ struct bt_packet *packet);
+
+extern int bt_packet_set_end_clock_value(struct bt_packet *packet,
+ struct bt_clock_class *clock_class, uint64_t raw_value,
+ bt_bool is_default);
+
+extern struct bt_clock_value *bt_packet_borrow_default_end_clock_value(
+ struct bt_packet *packet);
+
/** @} */
#ifdef __cplusplus
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_CLOCK_CLASS_PRIORITY_MAP_INTERNAL_H
-#define BABELTRACE_GRAPH_CLOCK_CLASS_PRIORITY_MAP_INTERNAL_H
-
-/*
- * Copyright 2017 Philippe Proulx <pproulx@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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-#include <stddef.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/ctf-ir/clock-class.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/types.h>
-#include <glib.h>
-
-struct bt_clock_class_priority_map {
- struct bt_object base;
-
- /* Array of struct bt_clock_class *, owned by this */
- GPtrArray *entries;
-
- /* struct bt_clock_class * (weak) to priority (uint64_t *) */
- GHashTable *prios;
-
- /* Clock class (weak) with the currently highest priority */
- struct bt_clock_class *highest_prio_cc;
-
- bt_bool frozen;
-};
-
-static inline
-void _bt_clock_class_priority_map_freeze(
- struct bt_clock_class_priority_map *cc_prio_map)
-{
- BT_ASSERT(cc_prio_map);
- cc_prio_map->frozen = BT_TRUE;
-}
-
-#ifdef BT_DEV_MODE
-# define bt_clock_class_priority_map_freeze _bt_clock_class_priority_map_freeze
-#else
-# define bt_clock_class_priority_map_freeze(_cc_prio_map)
-#endif /* BT_DEV_MODE */
-
-#endif /* BABELTRACE_GRAPH_CLOCK_CLASS_PRIORITY_MAP_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_CLOCK_CLASS_PRIORITY_MAP_H
-#define BABELTRACE_GRAPH_CLOCK_CLASS_PRIORITY_MAP_H
-
-/*
- * Copyright 2017 Philippe Proulx <pproulx@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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/* For bt_get() */
-#include <babeltrace/ref.h>
-
-#include <stdint.h>
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_clock_class;
-
-/**
-@defgroup graphclockclassprioritymap Clock class priority map
-@ingroup graph
-@brief Clock class priority map.
-
-@code
-#include <babeltrace/graph/clock-class-priority-map.h>
-@endcode
-
-A <strong><em>clock class priority map</em></strong> object associates
-CTF IR clock classes to priorities. A clock class priority indicates
-which clock class you should choose to sort notifications by time.
-
-You need a clock class priority map object when you create
-an \link graphnotifevent event notification\endlink or
-an \link graphnotifinactivity inactivity notification\endlink.
-
-A priority is a 64-bit unsigned integer. A lower value has a
-\em higher priority. Multiple clock classes can have the same priority
-within a given clock class priority map.
-
-The following functions can \em freeze clock class priority map objects:
-
-- bt_notification_event_create() freezes its clock class priority
- map parameter.
-- bt_notification_inactivity_create() freezes its clock class priority
- map parameter.
-
-You cannot modify a frozen clock class priority map object: it is
-considered immutable, except for \link refs reference counting\endlink.
-
-As with any Babeltrace object, clock class priority map objects have
-<a href="https://en.wikipedia.org/wiki/Reference_counting">reference
-counts</a>. See \ref refs to learn more about the reference counting
-management of Babeltrace objects.
-
-@file
-@brief Clock class priority map type and functions.
-@sa graphclockclassprioritymap
-
-@addtogroup graphclockclassprioritymap
-@{
-*/
-
-/**
-@struct bt_clock_class_priority_map
-@brief A clock class priority map.
-@sa graphclockclassprioritymap
-*/
-struct bt_clock_class_priority_map;
-
-/**
-@brief Creates an empty clock class priority map.
-
-@returns Created clock class priority map object, or \c NULL on error.
-
-@postsuccessrefcountret1
-*/
-extern struct bt_clock_class_priority_map *bt_clock_class_priority_map_create(void);
-
-/**
-@brief Returns the number of CTF IR clock classes contained in the
- clock class priority map \p clock_class_priority_map.
-
-@param[in] clock_class_priority_map Clock class priority map of
- which to get the number of
- clock classes.
-@returns Number of clock classes contained
- in \p clock_class_priority_map,
- or a negative value on error.
-
-@prenotnull{clock_class_priority_map}
-@postrefcountsame{clock_class_priority_map}
-*/
-extern int64_t bt_clock_class_priority_map_get_clock_class_count(
- struct bt_clock_class_priority_map *clock_class_priority_map);
-
-extern struct bt_clock_class *
-bt_clock_class_priority_map_borrow_clock_class_by_index(
- struct bt_clock_class_priority_map *clock_class_priority_map,
- uint64_t index);
-
-/**
-@brief Returns the CTF IR clock class at index \p index in the clock
- class priority map \p clock_class_priority_map.
-
-@param[in] clock_class_priority_map Clock class priority map of which
- to get the clock class at index
- \p index.
-@param[in] index Index of the clock class to find
- in \p clock_class_priority_map.
-@returns Clock class at index \p index in
- \p clock_class_priority_map,
- or \c NULL on error.
-
-@prenotnull{clock_class_priority_map}
-@pre \p index is lesser than the number of clock classes contained in
- the clock class priority map \p clock_class_priority_map (see
- bt_clock_class_priority_map_get_clock_class_count()).
-@postrefcountsame{clock_class_priority_map}
-
-@sa bt_clock_class_priority_map_get_clock_class_by_name(): Finds a clock
- class by name in a given clock class priority map.
-@sa bt_clock_class_priority_map_get_highest_priority_clock_class():
- Returns the clock class with the highest priority contained
- in a given clock class priority map.
-@sa bt_clock_class_priority_map_add_clock_class(): Adds a clock class
- to a clock class priority map.
-*/
-static inline
-struct bt_clock_class *
-bt_clock_class_priority_map_get_clock_class_by_index(
- struct bt_clock_class_priority_map *clock_class_priority_map,
- uint64_t index)
-{
- return bt_get(bt_clock_class_priority_map_borrow_clock_class_by_index(
- clock_class_priority_map, index));
-}
-
-extern struct bt_clock_class *
-bt_clock_class_priority_map_borrow_clock_class_by_name(
- struct bt_clock_class_priority_map *clock_class_priority_map,
- const char *name);
-
-/**
-@brief Returns the CTF IR clock class named \c name found in the clock
- class priority map \p clock_class_priority_map.
-
-@param[in] clock_class_priority_map Clock class priority map of
- which to get the clock class
- named \p name.
-@param[in] name Name of the clock class to find
- in \p clock_class_priority_map.
-@returns Clock class named \p name in
- \p clock_class_priority_map,
- or \c NULL on error.
-
-@prenotnull{clock_class_priority_map}
-@prenotnull{name}
-@postrefcountsame{clock_class_priority_map}
-@postsuccessrefcountretinc
-
-@sa bt_clock_class_priority_map_get_clock_class_by_index(): Returns the clock
- class contained in a given clock class priority map at
- a given index.
-@sa bt_clock_class_priority_map_get_highest_priority_clock_class():
- Returns the clock class with the highest priority contained in
- a given clock class priority map.
-@sa bt_clock_class_priority_map_add_clock_class(): Adds a clock class
- to a clock class priority map.
-*/
-static inline
-struct bt_clock_class *bt_clock_class_priority_map_get_clock_class_by_name(
- struct bt_clock_class_priority_map *clock_class_priority_map,
- const char *name)
-{
- return bt_get(bt_clock_class_priority_map_borrow_clock_class_by_name(
- clock_class_priority_map, name));
-}
-
-extern struct bt_clock_class *
-bt_clock_class_priority_map_borrow_highest_priority_clock_class(
- struct bt_clock_class_priority_map *clock_class_priority_map);
-
-/**
-@brief Returns the CTF IR clock class with the currently highest
- priority within the clock class priority map
- \p clock_class_priority_map.
-
-If multiple clock classes share the same highest priority in
-\p clock_class_priority_map, you cannot deterministically know which one
-this function returns.
-
-@param[in] clock_class_priority_map Clock class priority map of which
- to get the clock class with the
- highest priority.
-@returns Clock class with the highest
- priority within
- \p clock_class_priority_map, or
- \c NULL on error or if there are
- no clock classes in
- \p clock_class_priority_map.
-
-@prenotnull{clock_class_priority_map}
-@postrefcountsame{clock_class_priority_map}
-@postsuccessrefcountretinc
-
-@sa bt_clock_class_priority_map_get_clock_class_by_index(): Returns the clock
- class contained in a given clock class priority map at
- a given index.
-@sa bt_clock_class_priority_map_get_clock_class_by_name(): Finds a
- clock class by name in a given clock class priority map.
-@sa bt_clock_class_priority_map_add_clock_class(): Adds a clock class
- to a clock class priority map.
-*/
-static inline
-struct bt_clock_class *
-bt_clock_class_priority_map_get_highest_priority_clock_class(
- struct bt_clock_class_priority_map *clock_class_priority_map)
-{
- return bt_get(
- bt_clock_class_priority_map_borrow_highest_priority_clock_class(
- clock_class_priority_map));
-}
-
-/**
-@brief Returns the priority of the CTF IR clock class \p clock_class
- contained within the clock class priority map
- \p clock_class_priority_map.
-
-@param[in] clock_class_priority_map Clock class priority map
- containing \p clock_class.
-@param[in] clock_class Clock class of which to get the
- priority.
-@param[out] priority Returned priority of
- \p clock_class within
- \p clock_class_priority_map.
-@returns 0 on success, or a negative
- value on error.
-
-@prenotnull{clock_class_priority_map}
-@prenotnull{clock_class}
-@prenotnull{priority}
-@pre \p clock_class is contained in \p clock_class_priority_map (was
- previously added to \p clock_class_priority_map with
- bt_clock_class_priority_map_add_clock_class()).
-@postrefcountsame{clock_class_priority_map}
-@postrefcountsame{clock_class}
-
-@sa bt_clock_class_priority_map_get_highest_priority_clock_class():
- Returns the clock class with the highest priority contained
- in a given clock class priority map.
-*/
-extern int bt_clock_class_priority_map_get_clock_class_priority(
- struct bt_clock_class_priority_map *clock_class_priority_map,
- struct bt_clock_class *clock_class, uint64_t *priority);
-
-/**
-@brief Adds the CTF IR clock class \p clock_class to the clock class
- priority map \p clock_class_priority_map with the
- priority \p priority.
-
-You can call this function even if \p clock_class is frozen.
-
-A lower priority value means a \em higher priority. Multiple clock
-classes can have the same priority within a given clock class priority
-map.
-
-@param[in] clock_class_priority_map Clock class priority map to
- which to add \p clock_class.
-@param[in] clock_class Clock class to add to
- \p clock_class_priority_map.
-@param[in] priority Priority of \p clock_class within
- \p clock_class_priority_map,
- where a lower value means a
- higher priority.
-@returns 0 on success, or a negative
- value on error.
-
-@prenotnull{clock_class_priority_map}
-@prenotnull{clock_class}
-@prehot{clock_class_priority_map}
-@postrefcountsame{clock_class_priority_map}
-@postsuccessrefcountinc{clock_class}
-
-@sa bt_clock_class_priority_map_get_clock_class_by_index(): Returns the clock
- class contained in a given clock class priority map
- at a given index.
-@sa bt_clock_class_priority_map_get_clock_class_by_name(): Finds a
- clock class by name in a given clock class priority map.
-*/
-extern int bt_clock_class_priority_map_add_clock_class(
- struct bt_clock_class_priority_map *clock_class_priority_map,
- struct bt_clock_class *clock_class, uint64_t priority);
-
-/**
-@brief Creates a copy of the clock class priority map
- \p clock_class_priority_map.
-
-You can copy a frozen clock class priority map: the resulting copy is
-<em>not frozen</em>.
-
-@param[in] clock_class_priority_map Clock class priority map to copy.
-@returns Copy of \p clock_class_priority_map
- on success, or a negative value
- on error.
-
-@prenotnull{clock_class_priority_map}
-@postrefcountsame{clock_class_priority_map}
-@postsuccessrefcountret1
-@post <strong>On success</strong>, the returned clock class priority map
- is not frozen.
-*/
-extern struct bt_clock_class_priority_map *bt_clock_class_priority_map_copy(
- struct bt_clock_class_priority_map *clock_class_priority_map);
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_CLOCK_CLASS_PRIORITY_MAP_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_NOTIFICATION_DISCARDED_ELEMENTS_INTERNAL_H
-#define BABELTRACE_GRAPH_NOTIFICATION_DISCARDED_ELEMENTS_INTERNAL_H
-
-/*
- * Copyright 2017 Philippe Proulx <pproulx@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.
- */
-
-#include <glib.h>
-#include <stdint.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/graph/notification.h>
-#include <babeltrace/graph/notification-internal.h>
-
-struct bt_clock_class_priority_map;
-struct bt_stream;
-
-struct bt_notification_discarded_elements {
- struct bt_notification parent;
- struct bt_stream *stream;
- struct bt_clock_value *begin_clock_value;
- struct bt_clock_value *end_clock_value;
- int64_t count;
-};
-
-BT_HIDDEN
-struct bt_notification *bt_notification_discarded_elements_create(
- struct bt_graph *graph,
- enum bt_notification_type type,
- struct bt_stream *stream,
- struct bt_clock_value *begin_clock_value,
- struct bt_clock_value *end_clock_value,
- uint64_t count);
-
-BT_HIDDEN
-struct bt_stream *bt_notification_discarded_elements_borrow_stream(
- enum bt_notification_type type,
- struct bt_notification *notification);
-
-BT_HIDDEN
-struct bt_clock_value *
-bt_notification_discarded_elements_borrow_begin_clock_value(
- enum bt_notification_type type,
- struct bt_notification *notification);
-
-BT_HIDDEN
-struct bt_clock_value *
-bt_notification_discarded_elements_borrow_end_clock_value(
- enum bt_notification_type type,
- struct bt_notification *notification);
-
-BT_HIDDEN
-int64_t bt_notification_discarded_elements_get_count(
- enum bt_notification_type type,
- struct bt_notification *notification);
-
-#endif /* BABELTRACE_GRAPH_NOTIFICATION_DISCARDED_ELEMENTS_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_NOTIFICATION_DISCARDED_EVENTS_H
-#define BABELTRACE_GRAPH_NOTIFICATION_DISCARDED_EVENTS_H
-
-/*
- * Copyright 2017 Philippe Proulx <pproulx@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.
- */
-
-/* For bt_get() */
-#include <babeltrace/ref.h>
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_notification;
-struct bt_clock_class_priority_map;
-struct bt_clock_class;
-struct bt_stream;
-
-extern struct bt_clock_value *
-bt_notification_discarded_events_borrow_begin_clock_value(
- struct bt_notification *notification);
-
-static inline
-struct bt_clock_value *
-bt_notification_discarded_events_get_begin_clock_value(
- struct bt_notification *notification)
-{
- return bt_get(bt_notification_discarded_events_borrow_begin_clock_value(
- notification));
-}
-
-extern struct bt_clock_value *
-bt_notification_discarded_events_borrow_end_clock_value(
- struct bt_notification *notification);
-
-static inline
-struct bt_clock_value *
-bt_notification_discarded_events_get_end_clock_value(
- struct bt_notification *notification)
-{
- return bt_get(bt_notification_discarded_events_borrow_end_clock_value(
- notification));
-}
-
-extern int64_t bt_notification_discarded_events_get_count(
- struct bt_notification *notification);
-
-extern struct bt_stream *bt_notification_discarded_events_borrow_stream(
- struct bt_notification *notification);
-
-static inline
-struct bt_stream *bt_notification_discarded_events_get_stream(
- struct bt_notification *notification)
-{
- return bt_get(bt_notification_discarded_events_borrow_stream(
- notification));
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_NOTIFICATION_DISCARDED_EVENTS_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_NOTIFICATION_DISCARDED_PACKETS_H
-#define BABELTRACE_GRAPH_NOTIFICATION_DISCARDED_PACKETS_H
-
-/*
- * Copyright 2017 Philippe Proulx <pproulx@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.
- */
-
-/* For bt_get() */
-#include <babeltrace/ref.h>
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_notification;
-struct bt_clock_class_priority_map;
-struct bt_clock_class;
-struct bt_stream;
-
-extern struct bt_clock_value *
-bt_notification_discarded_packets_borrow_begin_clock_value(
- struct bt_notification *notification);
-
-static inline
-struct bt_clock_value *
-bt_notification_discarded_packets_get_begin_clock_value(
- struct bt_notification *notification)
-{
- return bt_get(
- bt_notification_discarded_packets_borrow_begin_clock_value(
- notification));
-}
-
-extern struct bt_clock_value *
-bt_notification_discarded_packets_borrow_end_clock_value(
- struct bt_notification *notification);
-
-static inline
-struct bt_clock_value *
-bt_notification_discarded_packets_get_end_clock_value(
- struct bt_notification *notification)
-{
- return bt_get(bt_notification_discarded_packets_borrow_end_clock_value(
- notification));
-}
-
-extern int64_t bt_notification_discarded_packets_get_count(
- struct bt_notification *notification);
-
-extern struct bt_stream *bt_notification_discarded_packets_borrow_stream(
- struct bt_notification *notification);
-
-static inline
-struct bt_stream *bt_notification_discarded_packets_get_stream(
- struct bt_notification *notification)
-{
- return bt_get(bt_notification_discarded_packets_borrow_stream(
- notification));
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_NOTIFICATION_DISCARDED_PACKETS_H */
#include <babeltrace/ctf-ir/event-class.h>
#include <babeltrace/ctf-ir/event.h>
#include <babeltrace/graph/notification-internal.h>
-#include <babeltrace/graph/clock-class-priority-map.h>
#include <babeltrace/assert-internal.h>
#ifdef __cplusplus
struct bt_notification_event {
struct bt_notification parent;
struct bt_event *event;
- struct bt_clock_class_priority_map *cc_prio_map;
};
BT_HIDDEN
struct bt_notification;
struct bt_event;
struct bt_event_class;
-struct bt_clock_class_priority_map;
extern
struct bt_notification *bt_notification_event_create(struct bt_graph *graph,
- struct bt_event_class *event_class,
- struct bt_packet *packet,
- struct bt_clock_class_priority_map *clock_class_priority_map);
+ struct bt_event_class *event_class, struct bt_packet *packet);
extern struct bt_event *bt_notification_event_borrow_event(
struct bt_notification *notification);
-extern struct bt_clock_class_priority_map *
-bt_notification_event_borrow_clock_class_priority_map(
- struct bt_notification *notification);
-
-static inline
-struct bt_clock_class_priority_map *
-bt_notification_event_get_clock_class_priority_map(
- struct bt_notification *notification)
-{
- return bt_get(bt_notification_event_borrow_clock_class_priority_map(
- notification));
-}
-
#ifdef __cplusplus
}
#endif
*/
#include <glib.h>
-
-struct bt_clock_class_priority_map;
+#include <babeltrace/ctf-ir/clock-value-set-internal.h>
+#include <babeltrace/graph/notification.h>
struct bt_notification_inactivity {
struct bt_notification parent;
- struct bt_clock_class_priority_map *cc_prio_map;
- GHashTable *clock_values;
+ struct bt_clock_value_set cv_set;
};
#endif /* BABELTRACE_GRAPH_NOTIFICATION_INACTIVITY_INTERNAL_H */
* SOFTWARE.
*/
-/* For bt_get() */
-#include <babeltrace/ref.h>
+#include <stdint.h>
+
+/* For bt_bool */
+#include <babeltrace/types.h>
#ifdef __cplusplus
extern "C" {
#endif
struct bt_notification;
-struct bt_clock_class_priority_map;
+struct bt_clock_value;
struct bt_clock_class;
extern
struct bt_notification *bt_notification_inactivity_create(
- struct bt_graph *graph,
- struct bt_clock_class_priority_map *clock_class_priority_map);
-
-extern struct bt_clock_class_priority_map *
-bt_notification_inactivity_borrow_clock_class_priority_map(
- struct bt_notification *notification);
+ struct bt_graph *graph);
-static inline
-struct bt_clock_class_priority_map *
-bt_notification_inactivity_get_clock_class_priority_map(
- struct bt_notification *notification)
-{
- return bt_get(
- bt_notification_inactivity_borrow_clock_class_priority_map(
- notification));
-}
+extern int bt_notification_inactivity_set_clock_value(
+ struct bt_notification *notif,
+ struct bt_clock_class *clock_class, uint64_t raw_value,
+ bt_bool is_default);
-extern struct bt_clock_value *bt_notification_inactivity_borrow_clock_value(
- struct bt_notification *notification,
- struct bt_clock_class *clock_class);
+extern struct bt_clock_value *bt_notification_inactivity_borrow_default_clock_value(
+ struct bt_notification *notif);
#ifdef __cplusplus
}
return "BT_NOTIFICATION_TYPE_PACKET_BEGIN";
case BT_NOTIFICATION_TYPE_PACKET_END:
return "BT_NOTIFICATION_TYPE_PACKET_END";
- case BT_NOTIFICATION_TYPE_DISCARDED_EVENTS:
- return "BT_NOTIFICATION_TYPE_DISCARDED_EVENTS";
- case BT_NOTIFICATION_TYPE_DISCARDED_PACKETS:
- return "BT_NOTIFICATION_TYPE_DISCARDED_PACKETS";
default:
return "(unknown)";
}
#include <babeltrace/compiler-internal.h>
#include <babeltrace/ctf-ir/packet.h>
#include <babeltrace/graph/notification-internal.h>
+#include <babeltrace/ctf-ir/clock-value-set-internal.h>
#include <babeltrace/assert-internal.h>
struct bt_notification_stream_begin {
struct bt_notification parent;
struct bt_stream *stream;
+ struct bt_clock_value_set cv_set;
};
struct bt_notification_stream_end {
struct bt_notification parent;
struct bt_stream *stream;
+ struct bt_clock_value_set cv_set;
};
#endif /* BABELTRACE_GRAPH_NOTIFICATION_STREAM_INTERNAL_H */
* SOFTWARE.
*/
+#include <stdint.h>
+
/* For bt_get() */
#include <babeltrace/ref.h>
+/* For bt_bool */
+#include <babeltrace/types.h>
+
#ifdef __cplusplus
extern "C" {
#endif
struct bt_notification;
+struct bt_clock_class;
+struct bt_clock_value;
struct bt_stream;
extern
return bt_get(bt_notification_stream_begin_borrow_stream(notification));
}
+extern int bt_notification_stream_begin_set_clock_value(
+ struct bt_notification *notif,
+ struct bt_clock_class *clock_class, uint64_t raw_value,
+ bt_bool is_default);
+
+extern struct bt_clock_value *bt_notification_stream_begin_borrow_default_clock_value(
+ struct bt_notification *notif);
+
extern struct bt_stream *bt_notification_stream_end_borrow_stream(
struct bt_notification *notification);
return bt_get(bt_notification_stream_end_borrow_stream(notification));
}
+extern int bt_notification_stream_end_set_clock_value(
+ struct bt_notification *notif,
+ struct bt_clock_class *clock_class, uint64_t raw_value,
+ bt_bool is_default);
+
+extern struct bt_clock_value *bt_notification_stream_end_borrow_default_clock_value(
+ struct bt_notification *notif);
+
#ifdef __cplusplus
}
#endif
BT_NOTIFICATION_TYPE_STREAM_END = 3,
BT_NOTIFICATION_TYPE_PACKET_BEGIN = 4,
BT_NOTIFICATION_TYPE_PACKET_END = 5,
- BT_NOTIFICATION_TYPE_DISCARDED_EVENTS = 6,
- BT_NOTIFICATION_TYPE_DISCARDED_PACKETS = 7,
BT_NOTIFICATION_TYPE_NR, /* Not part of ABI. */
};
return ret;
}
-static inline
-uint64_t ns_from_value(uint64_t frequency, uint64_t value)
-{
- uint64_t ns;
-
- if (frequency == UINT64_C(1000000000)) {
- ns = value;
- } else {
- double dblres = ((1e9 * (double) value) / (double) frequency);
-
- if (dblres >= (double) UINT64_MAX) {
- /* Overflows uint64_t */
- ns = -1ULL;
- } else {
- ns = (uint64_t) dblres;
- }
- }
-
- return ns;
-}
-
BT_HIDDEN
void bt_clock_class_freeze(struct bt_clock_class *clock_class)
{
g_free(clock_value);
}
-static inline
-int ns_from_epoch(struct bt_clock_class *clock_class, uint64_t value,
- int64_t *ns_from_epoch, bool *overflows)
-{
- int ret = 0;
- int64_t diff;
- int64_t s_ns;
- uint64_t u_ns;
- uint64_t cycles;
-
- *overflows = false;
-
- /* Initialize nanosecond timestamp to clock's offset in seconds */
- if (clock_class->offset_s <= (INT64_MIN / INT64_C(1000000000)) ||
- clock_class->offset_s >= (INT64_MAX / INT64_C(1000000000))) {
- /*
- * Overflow: offset in seconds converted to nanoseconds
- * is outside the int64_t range.
- */
- *overflows = true;
- goto end;
- }
-
- *ns_from_epoch = clock_class->offset_s * INT64_C(1000000000);
-
- /* Add offset in cycles */
- if (clock_class->offset < 0) {
- cycles = (uint64_t) -clock_class->offset;
- } else {
- cycles = (uint64_t) clock_class->offset;
- }
-
- u_ns = ns_from_value(clock_class->frequency, cycles);
-
- if (u_ns == UINT64_C(-1) || u_ns >= INT64_MAX) {
- /*
- * Overflow: offset in cycles converted to nanoseconds
- * is outside the int64_t range.
- */
- *overflows = true;
- goto end;
- }
-
- s_ns = (int64_t) u_ns;
- BT_ASSERT(s_ns >= 0);
-
- if (clock_class->offset < 0) {
- if (*ns_from_epoch >= 0) {
- /*
- * Offset in cycles is negative so it must also
- * be negative once converted to nanoseconds.
- */
- s_ns = -s_ns;
- goto offset_ok;
- }
-
- diff = *ns_from_epoch - INT64_MIN;
-
- if (s_ns >= diff) {
- /*
- * Overflow: current timestamp in nanoseconds
- * plus the offset in cycles converted to
- * nanoseconds is outside the int64_t range.
- */
- *overflows = true;
- goto end;
- }
-
- /*
- * Offset in cycles is negative so it must also be
- * negative once converted to nanoseconds.
- */
- s_ns = -s_ns;
- } else {
- if (*ns_from_epoch <= 0) {
- goto offset_ok;
- }
-
- diff = INT64_MAX - *ns_from_epoch;
-
- if (s_ns >= diff) {
- /*
- * Overflow: current timestamp in nanoseconds
- * plus the offset in cycles converted to
- * nanoseconds is outside the int64_t range.
- */
- *overflows = true;
- goto end;
- }
- }
-
-offset_ok:
- *ns_from_epoch += s_ns;
-
- /* Add clock value (cycles) */
- u_ns = ns_from_value(clock_class->frequency, value);
-
- if (u_ns == -1ULL || u_ns >= INT64_MAX) {
- /*
- * Overflow: value converted to nanoseconds is outside
- * the int64_t range.
- */
- *overflows = true;
- goto end;
- }
-
- s_ns = (int64_t) u_ns;
- BT_ASSERT(s_ns >= 0);
-
- /* Clock value (cycles) is always positive */
- if (*ns_from_epoch <= 0) {
- goto value_ok;
- }
-
- diff = INT64_MAX - *ns_from_epoch;
-
- if (s_ns >= diff) {
- /*
- * Overflow: current timestamp in nanoseconds plus the
- * clock value converted to nanoseconds is outside the
- * int64_t range.
- */
- *overflows = true;
- goto end;
- }
-
-value_ok:
- *ns_from_epoch += s_ns;
-
-end:
- if (*overflows) {
- *ns_from_epoch = 0;
- ret = -1;
- }
-
- return ret;
-}
-
-static
-void set_ns_from_epoch(struct bt_clock_value *clock_value)
-{
- (void) ns_from_epoch(clock_value->clock_class,
- clock_value->value, &clock_value->ns_from_epoch,
- &clock_value->ns_from_epoch_overflows);
-}
-
static
struct bt_clock_value *bt_clock_value_new(struct bt_clock_class *clock_class)
{
bt_put(clock_class);
}
-BT_HIDDEN
-void bt_clock_value_set_raw_value(struct bt_clock_value *clock_value,
- uint64_t cycles)
-{
- BT_ASSERT(clock_value);
-
- clock_value->value = cycles;
- set_ns_from_epoch(clock_value);
- bt_clock_value_set(clock_value);
-}
-
-int bt_clock_value_set_value(struct bt_clock_value *clock_value,
- uint64_t raw_value)
-{
- BT_ASSERT_PRE_NON_NULL(clock_value, "Clock value");
- BT_ASSERT_PRE_HOT(clock_value, "Clock value", ": %!+k", clock_value);
- bt_clock_value_set_raw_value(clock_value, raw_value);
- return 0;
-}
-
int bt_clock_value_get_value(struct bt_clock_value *clock_value,
uint64_t *raw_value)
{
end:
return ret;
}
-
-BT_HIDDEN
-int bt_event_class_update_event_pool_clock_values(
- struct bt_event_class *event_class)
-{
- int ret = 0;
- uint64_t i;
- struct bt_stream_class *stream_class =
- bt_event_class_borrow_stream_class(event_class);
-
- BT_ASSERT(stream_class->common.clock_class);
-
- for (i = 0; i < event_class->event_pool.size; i++) {
- struct bt_clock_value *cv;
- struct bt_event *event =
- event_class->event_pool.objects->pdata[i];
-
- BT_ASSERT(event);
-
- cv = g_hash_table_lookup(event->clock_values,
- stream_class->common.clock_class);
- if (cv) {
- continue;
- }
-
- cv = bt_clock_value_create(stream_class->common.clock_class);
- if (!cv) {
- BT_LIB_LOGE("Cannot create clock value from clock class: "
- "%![cc-]+K", stream_class->common.clock_class);
- ret = -1;
- goto end;
- }
-
- g_hash_table_insert(event->clock_values,
- stream_class->common.clock_class, cv);
- }
-
-end:
- return ret;
-}
goto error;
}
- event->clock_values = g_hash_table_new_full(g_direct_hash,
- g_direct_equal, NULL,
- (GDestroyNotify) bt_clock_value_recycle);
- BT_ASSERT(event->clock_values);
stream_class = bt_event_class_borrow_stream_class(event_class);
BT_ASSERT(stream_class);
-
- if (stream_class->common.clock_class) {
- struct bt_clock_value *clock_value;
-
- clock_value = bt_clock_value_create(
- stream_class->common.clock_class);
- if (!clock_value) {
- BT_LIB_LOGE("Cannot create clock value from clock class: "
- "%![cc-]+K", stream_class->common.clock_class);
- goto error;
- }
-
- g_hash_table_insert(event->clock_values,
- stream_class->common.clock_class, clock_value);
+ ret = bt_clock_value_set_initialize(&event->cv_set);
+ if (ret) {
+ goto error;
}
goto end;
bt_event_common_finalize((void *) event,
(void *) bt_field_destroy_recursive,
(void *) release_event_header_field);
- g_hash_table_destroy(event->clock_values);
+ bt_clock_value_set_finalize(&event->cv_set);
BT_LOGD_STR("Putting event's packet.");
bt_put(event->packet);
g_free(event);
}
-struct bt_clock_value *bt_event_borrow_clock_value(
- struct bt_event *event, struct bt_clock_class *clock_class)
+int bt_event_set_clock_value(struct bt_event *event,
+ struct bt_clock_class *clock_class, uint64_t raw_value,
+ bt_bool is_default)
+{
+ BT_ASSERT_PRE_NON_NULL(event, "Event");
+ BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
+ BT_ASSERT_PRE_HOT(BT_TO_COMMON(event), "Event", ": %!+e", event);
+ BT_ASSERT_PRE(is_default,
+ "You can only set a default clock value as of this version.");
+ return bt_clock_value_set_set_clock_value(&event->cv_set, clock_class,
+ raw_value, is_default);
+}
+
+struct bt_clock_value *bt_event_borrow_default_clock_value(
+ struct bt_event *event)
{
struct bt_clock_value *clock_value = NULL;
BT_ASSERT_PRE_NON_NULL(event, "Event");
- BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
- clock_value = g_hash_table_lookup(event->clock_values, clock_class);
+ clock_value = event->cv_set.default_cv;
if (!clock_value) {
- BT_LOGV("No clock value associated to the given clock class: "
- "event-addr=%p, event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", clock-class-addr=%p, "
- "clock-class-name=\"%s\"", event,
- bt_event_class_common_get_name(event->common.class),
- bt_event_class_common_get_id(event->common.class),
- clock_class, bt_clock_class_get_name(clock_class));
- goto end;
+ BT_LIB_LOGV("No default clock value: %![event-]+e", event);
}
-end:
return clock_value;
}
BT_ASSERT_PRE_NON_NULL(event, "Event");
BT_ASSERT_PRE_NON_NULL(field_wrapper, "Header field");
- BT_ASSERT_PRE_HOT(BT_TO_COMMON(event), "Event", ": +%!+e", event);
+ BT_ASSERT_PRE_HOT(BT_TO_COMMON(event), "Event", ": %!+e", event);
stream_class = bt_event_class_borrow_stream_class(
bt_event_borrow_class(event));
BT_ASSERT_PRE(stream_class->common.event_header_field_type,
(void *) packet->context->field, false);
bt_field_reset_recursive((void *) packet->context->field);
}
+
+ bt_clock_value_set_reset(&packet->begin_cv_set);
+ bt_clock_value_set_reset(&packet->end_cv_set);
}
static
}
}
+ bt_clock_value_set_finalize(&packet->begin_cv_set);
+ bt_clock_value_set_finalize(&packet->end_cv_set);
BT_LOGD_STR("Putting packet's stream.");
bt_put(packet->stream);
g_free(packet);
}
}
+ if (bt_clock_value_set_initialize(&packet->begin_cv_set)) {
+ BT_PUT(packet);
+ goto end;
+ }
+
+ if (bt_clock_value_set_initialize(&packet->end_cv_set)) {
+ BT_PUT(packet);
+ goto end;
+ }
+
BT_LOGD("Created packet object: addr=%p", packet);
end:
BT_ASSERT_PRE_NON_NULL(packet, "Event");
BT_ASSERT_PRE_NON_NULL(field_wrapper, "Header field");
- BT_ASSERT_PRE_HOT(packet, "Packet", ": +%!+a", packet);
+ BT_ASSERT_PRE_HOT(packet, "Packet", ": %!+a", packet);
trace = bt_stream_class_borrow_trace(
bt_stream_borrow_class(packet->stream));
BT_ASSERT_PRE(trace->common.packet_header_field_type,
BT_ASSERT_PRE_NON_NULL(packet, "Event");
BT_ASSERT_PRE_NON_NULL(field_wrapper, "Context field");
- BT_ASSERT_PRE_HOT(packet, "Packet", ": +%!+a", packet);
+ BT_ASSERT_PRE_HOT(packet, "Packet", ": %!+a", packet);
stream_class = bt_stream_borrow_class(packet->stream);
BT_ASSERT_PRE(stream_class->common.packet_context_field_type,
"Stream class has no packet context field type: %!+S",
packet->context = field_wrapper;
return 0;
}
+
+int bt_packet_set_beginning_clock_value(struct bt_packet *packet,
+ struct bt_clock_class *clock_class, uint64_t raw_value,
+ bt_bool is_default)
+{
+ BT_ASSERT_PRE_NON_NULL(packet, "Packet");
+ BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
+ BT_ASSERT_PRE_HOT(packet, "Packet", ": %!+a", packet);
+ BT_ASSERT_PRE(is_default,
+ "You can only set a default clock value as of this version.");
+ return bt_clock_value_set_set_clock_value(&packet->begin_cv_set,
+ clock_class, raw_value, is_default);
+}
+
+struct bt_clock_value *bt_packet_borrow_default_begin_clock_value(
+ struct bt_packet *packet)
+{
+ struct bt_clock_value *clock_value = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(packet, "Packet");
+ clock_value = packet->begin_cv_set.default_cv;
+ if (!clock_value) {
+ BT_LIB_LOGV("No default clock value: %![packet-]+a", packet);
+ }
+
+ return clock_value;
+}
+
+int bt_packet_set_end_clock_value(struct bt_packet *packet,
+ struct bt_clock_class *clock_class, uint64_t raw_value,
+ bt_bool is_default)
+{
+ BT_ASSERT_PRE_NON_NULL(packet, "Packet");
+ BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
+ BT_ASSERT_PRE_HOT(packet, "Packet", ": %!+a", packet);
+ BT_ASSERT_PRE(is_default,
+ "You can only set a default clock value as of this version.");
+ return bt_clock_value_set_set_clock_value(&packet->end_cv_set,
+ clock_class, raw_value, is_default);
+}
+
+struct bt_clock_value *bt_packet_borrow_default_end_clock_value(
+ struct bt_packet *packet)
+{
+ struct bt_clock_value *clock_value = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(packet, "Packet");
+ clock_value = packet->end_cv_set.default_cv;
+ if (!clock_value) {
+ BT_LIB_LOGV("No default clock value: %![packet-]+a", packet);
+ }
+
+ return clock_value;
+}
return ret;
}
-int bt_stream_class_add_event_class(
- struct bt_stream_class *stream_class,
+int bt_stream_class_add_event_class(struct bt_stream_class *stream_class,
struct bt_event_class *event_class)
{
struct bt_trace *trace;
int ret = 0;
- uint64_t i;
- struct bt_clock_class *old_clock_class;
if (!stream_class) {
BT_LOGW("Invalid parameter: stream class is NULL: "
goto end;
}
- old_clock_class = stream_class->common.clock_class;
trace = BT_FROM_COMMON(bt_stream_class_common_borrow_trace(
BT_TO_COMMON(stream_class)));
if (trace && trace->is_static) {
(void) bt_trace_object_modification(&obj, trace);
}
- if (!old_clock_class && stream_class->common.clock_class) {
- /*
- * Adding this event class updated the stream class's
- * single clock class: make sure all the events which
- * exist in event pools have an existing clock value for
- * this clock class so that any created event object in
- * the future (from a pool or not) has this clock value
- * available.
- */
- for (i = 0; i < stream_class->common.event_classes->len; i++) {
- struct bt_event_class *event_class =
- stream_class->common.event_classes->pdata[i];
-
- BT_ASSERT(event_class);
- ret = bt_event_class_update_event_pool_clock_values(
- event_class);
- if (ret) {
- goto end;
- }
- }
- }
-
end:
return ret;
}
# Graph library
libgraph_la_SOURCES = \
- clock-class-priority-map.c \
component.c \
component-class.c \
graph.c \
+++ /dev/null
-/*
- * clock-class-priority-map.c
- *
- * Copyright 2017 Philippe Proulx <pproulx@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 "CC-PRIO-MAP"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/graph/clock-class-priority-map.h>
-#include <babeltrace/graph/clock-class-priority-map-internal.h>
-#include <babeltrace/ctf-ir/clock-class.h>
-#include <babeltrace/ctf-ir/clock-class-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ref.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <glib.h>
-
-static
-void bt_clock_class_priority_map_destroy(struct bt_object *obj)
-{
- struct bt_clock_class_priority_map *cc_prio_map = (void *) obj;
-
- BT_LOGD("Destroying component class priority map object: addr=%p",
- cc_prio_map);
-
- if (cc_prio_map->entries) {
- BT_LOGD("Putting clock classes.");
- g_ptr_array_free(cc_prio_map->entries, TRUE);
- }
-
- if (cc_prio_map->prios) {
- g_hash_table_destroy(cc_prio_map->prios);
- }
-
- g_free(cc_prio_map);
-}
-
-struct bt_clock_class_priority_map *bt_clock_class_priority_map_create()
-{
- struct bt_clock_class_priority_map *cc_prio_map = NULL;
-
- BT_LOGD_STR("Creating clock class priority map object.");
-
- cc_prio_map = g_new0(struct bt_clock_class_priority_map, 1);
- if (!cc_prio_map) {
- BT_LOGE_STR("Failed to allocate one clock class priority map.");
- goto error;
- }
-
- bt_object_init_shared(&cc_prio_map->base,
- bt_clock_class_priority_map_destroy);
- cc_prio_map->entries = g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_put);
- if (!cc_prio_map->entries) {
- BT_LOGE_STR("Failed to allocate a GPtrArray.");
- goto error;
- }
-
- cc_prio_map->prios = g_hash_table_new_full(g_direct_hash,
- g_direct_equal, NULL, (GDestroyNotify) g_free);
- if (!cc_prio_map->entries) {
- BT_LOGE_STR("Failed to allocate a GHashTable.");
- goto error;
- }
-
- BT_LOGD("Created clock class priority map object: addr=%p",
- cc_prio_map);
- goto end;
-
-error:
- BT_PUT(cc_prio_map);
-
-end:
- return cc_prio_map;
-}
-
-int64_t bt_clock_class_priority_map_get_clock_class_count(
- struct bt_clock_class_priority_map *cc_prio_map)
-{
- BT_ASSERT_PRE_NON_NULL(cc_prio_map, "Clock class priority map");
- return (int64_t) cc_prio_map->entries->len;
-}
-
-struct bt_clock_class *bt_clock_class_priority_map_borrow_clock_class_by_index(
- struct bt_clock_class_priority_map *cc_prio_map,
- uint64_t index)
-{
- BT_ASSERT_PRE_NON_NULL(cc_prio_map, "Clock class priority map");
- BT_ASSERT_PRE(index < cc_prio_map->entries->len,
- "Index is out of bounds: index=%" PRIu64 ", count=%" PRIu64,
- index, cc_prio_map->entries->len);
- return g_ptr_array_index(cc_prio_map->entries, index);
-}
-
-struct bt_clock_class *bt_clock_class_priority_map_borrow_clock_class_by_name(
- struct bt_clock_class_priority_map *cc_prio_map,
- const char *name)
-{
- size_t i;
- struct bt_clock_class *clock_class = NULL;
-
- BT_ASSERT_PRE_NON_NULL(cc_prio_map, "Clock class priority map");
- BT_ASSERT_PRE_NON_NULL(name, "Name");
-
- for (i = 0; i < cc_prio_map->entries->len; i++) {
- struct bt_clock_class *cur_cc =
- g_ptr_array_index(cc_prio_map->entries, i);
- const char *cur_cc_name =
- bt_clock_class_get_name(cur_cc);
-
- BT_ASSERT(cur_cc_name);
-
- if (strcmp(cur_cc_name, name) == 0) {
- clock_class = cur_cc;
- goto end;
- }
- }
-
-end:
- return clock_class;
-}
-
-
-struct clock_class_prio {
- uint64_t prio;
- struct bt_clock_class *clock_class;
-};
-
-static
-void current_highest_prio_gh_func(gpointer key, gpointer value,
- gpointer user_data)
-{
- struct clock_class_prio *func_data = user_data;
- uint64_t *prio = value;
-
- if (*prio <= func_data->prio) {
- func_data->prio = *prio;
- func_data->clock_class = key;
- }
-}
-
-static
-struct clock_class_prio bt_clock_class_priority_map_current_highest_prio(
- struct bt_clock_class_priority_map *cc_prio_map)
-{
- struct clock_class_prio func_data = {
- .prio = -1ULL,
- .clock_class = NULL,
- };
-
- g_hash_table_foreach(cc_prio_map->prios, current_highest_prio_gh_func,
- &func_data);
- return func_data;
-}
-
-struct bt_clock_class *
-bt_clock_class_priority_map_borrow_highest_priority_clock_class(
- struct bt_clock_class_priority_map *cc_prio_map)
-{
- BT_ASSERT_PRE_NON_NULL(cc_prio_map, "Clock class priority map");
- return cc_prio_map->highest_prio_cc;
-}
-
-int bt_clock_class_priority_map_get_clock_class_priority(
- struct bt_clock_class_priority_map *cc_prio_map,
- struct bt_clock_class *clock_class, uint64_t *priority)
-{
- int ret = 0;
- uint64_t *prio;
-
- BT_ASSERT_PRE_NON_NULL(cc_prio_map, "Clock class priority map");
- BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
- BT_ASSERT_PRE_NON_NULL(priority, "Priority");
- prio = g_hash_table_lookup(cc_prio_map->prios, clock_class);
- if (!prio) {
- BT_LOGV("Clock class does not exist in clock class priority map: "
- "cc-prio-map-addr=%p, clock-class-addr=%p, "
- "clock-class-name=\"%s\"",
- cc_prio_map, clock_class,
- bt_clock_class_get_name(clock_class));
- ret = -1;
- goto end;
- }
-
- *priority = *prio;
-
-end:
- return ret;
-}
-
-int bt_clock_class_priority_map_add_clock_class(
- struct bt_clock_class_priority_map *cc_prio_map,
- struct bt_clock_class *clock_class, uint64_t priority)
-{
- int ret = 0;
- uint64_t *prio_ptr = NULL;
- struct clock_class_prio cc_prio;
-
- // FIXME when available: check
- // bt_clock_class_is_valid(clock_class)
- BT_ASSERT_PRE_NON_NULL(cc_prio_map, "Clock class priority map");
- BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
- BT_ASSERT_PRE_HOT(cc_prio_map, "Clock class priority map", "");
-
- /* Check for existing clock class */
- prio_ptr = g_hash_table_lookup(cc_prio_map->prios, clock_class);
- if (prio_ptr) {
- *prio_ptr = priority;
- prio_ptr = NULL;
- goto set_highest_prio;
- }
-
- prio_ptr = g_new(uint64_t, 1);
- if (!prio_ptr) {
- BT_LOGE_STR("Failed to allocate a uint64_t.");
- ret = -1;
- goto end;
- }
-
- *prio_ptr = priority;
- bt_get(clock_class);
- g_ptr_array_add(cc_prio_map->entries, clock_class);
- g_hash_table_insert(cc_prio_map->prios, clock_class, prio_ptr);
- prio_ptr = NULL;
-
-set_highest_prio:
- cc_prio = bt_clock_class_priority_map_current_highest_prio(
- cc_prio_map);
- BT_ASSERT(cc_prio.clock_class);
- cc_prio_map->highest_prio_cc = cc_prio.clock_class;
- BT_LOGV("Added clock class to clock class priority map: "
- "cc-prio-map-addr=%p, added-clock-class-addr=%p, "
- "added-clock-class-name=\"%s\", "
- "highest-prio-clock-class-addr=%p, "
- "highest-prio-clock-class-name=\"%s\"",
- cc_prio_map, clock_class,
- bt_clock_class_get_name(clock_class),
- cc_prio.clock_class,
- bt_clock_class_get_name(cc_prio.clock_class));
-
-end:
- g_free(prio_ptr);
-
- return ret;
-}
-
-struct bt_clock_class_priority_map *bt_clock_class_priority_map_copy(
- struct bt_clock_class_priority_map *orig_cc_prio_map)
-{
- struct bt_clock_class_priority_map *cc_prio_map;
- size_t i;
-
- cc_prio_map = bt_clock_class_priority_map_create();
- if (!cc_prio_map) {
- BT_LOGE_STR("Cannot create empty clock class priority map.");
- goto error;
- }
-
- for (i = 0; i < orig_cc_prio_map->entries->len; i++) {
- struct bt_clock_class *clock_class =
- g_ptr_array_index(orig_cc_prio_map->entries, i);
- uint64_t *prio = g_hash_table_lookup(orig_cc_prio_map->prios,
- clock_class);
- int ret = bt_clock_class_priority_map_add_clock_class(
- cc_prio_map, clock_class, *prio);
-
- if (ret) {
- BT_LOGE("Cannot add clock class to clock class priority map copy: "
- "cc-prio-map-copy-addr=%p, clock-class-addr=%p, "
- "clock-class-name=\"%s\"",
- cc_prio_map, clock_class,
- bt_clock_class_get_name(clock_class));
- goto error;
- }
- }
-
- cc_prio_map->highest_prio_cc = orig_cc_prio_map->highest_prio_cc;
- BT_LOGD("Copied clock class priority map: "
- "original-addr=%p, copy-addr=%p",
- orig_cc_prio_map, cc_prio_map);
- goto end;
-
-error:
- BT_PUT(cc_prio_map);
-
-end:
- return cc_prio_map;
-}
#include <babeltrace/graph/notification-packet-internal.h>
#include <babeltrace/graph/notification-stream.h>
#include <babeltrace/graph/notification-stream-internal.h>
-#include <babeltrace/graph/notification-discarded-elements-internal.h>
#include <babeltrace/graph/port.h>
#include <babeltrace/graph/graph-internal.h>
#include <babeltrace/types.h>
*/
#define NOTIF_BATCH_SIZE 15
-struct discarded_elements_state {
- struct bt_clock_value *cur_begin;
- uint64_t cur_count;
-};
-
struct stream_state {
struct bt_stream *stream; /* owned by this */
struct bt_packet *cur_packet; /* owned by this */
- struct discarded_elements_state discarded_packets_state;
- struct discarded_elements_state discarded_events_state;
uint64_t expected_notif_seq_num;
bt_bool is_ended;
};
bt_put(stream_state->cur_packet);
BT_LOGV_STR("Putting stream state's stream.");
bt_put(stream_state->stream);
- bt_put(stream_state->discarded_packets_state.cur_begin);
- bt_put(stream_state->discarded_events_state.cur_begin);
g_free(stream_state);
}
goto end;
}
- /*
- * The packet index is a monotonic counter which may not start
- * at 0 at the beginning of the stream. We therefore need to
- * have an internal object initial state of -1ULL to distinguish
- * between initial state and having seen a packet with
- * the sequence number 0.
- */
- stream_state->discarded_packets_state.cur_count = -1ULL;
-
/*
* We keep a reference to the stream until we know it's ended.
*/
packet.c \
event.c \
stream.c \
- inactivity.c \
- discarded-events.c \
- discarded-packets.c \
- discarded-elements.c
+ inactivity.c
+++ /dev/null
-/*
- * Copyright 2017 Philippe Proulx <pproulx@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 "NOTIF-DISCARDED"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ctf-ir/clock-class.h>
-#include <babeltrace/graph/clock-class-priority-map.h>
-#include <babeltrace/graph/clock-class-priority-map-internal.h>
-#include <babeltrace/graph/notification-internal.h>
-#include <babeltrace/graph/notification-discarded-elements-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <stdint.h>
-#include <inttypes.h>
-
-static
-void bt_notification_discarded_elements_destroy(struct bt_object *obj)
-{
- struct bt_notification_discarded_elements *notification =
- (struct bt_notification_discarded_elements *) obj;
-
- BT_LOGD("Destroying discarded elements notification: addr=%p",
- notification);
- BT_LOGD_STR("Putting stream.");
- bt_put(notification->stream);
- BT_LOGD_STR("Putting beginning clock value.");
- bt_put(notification->begin_clock_value);
- BT_LOGD_STR("Putting end clock value.");
- bt_put(notification->end_clock_value);
- g_free(notification);
-}
-
-BT_HIDDEN
-struct bt_notification *bt_notification_discarded_elements_create(
- struct bt_graph *graph,
- enum bt_notification_type type,
- struct bt_stream *stream,
- struct bt_clock_value *begin_clock_value,
- struct bt_clock_value *end_clock_value,
- uint64_t count)
-{
- struct bt_notification_discarded_elements *notification;
- struct bt_notification *ret_notif = NULL;
-
- BT_ASSERT_PRE_NON_NULL(stream, "Stream");
- BT_LOGD("Creating discarded elements notification object: "
- "type=%s, stream-addr=%p, stream-name=\"%s\", "
- "begin-clock-value-addr=%p, end-clock-value-addr=%p, "
- "count=%" PRIu64,
- bt_notification_type_string(type), stream,
- bt_stream_get_name(stream), begin_clock_value,
- end_clock_value, count);
- notification = g_new0(struct bt_notification_discarded_elements, 1);
- if (!notification) {
- BT_LOGE_STR("Failed to allocate one discarded elements notification.");
- goto error;
- }
-
- bt_notification_init(¬ification->parent, type,
- bt_notification_discarded_elements_destroy, NULL);
- ret_notif = ¬ification->parent;
- notification->stream = bt_get(stream);
- notification->begin_clock_value = bt_get(begin_clock_value);
- notification->end_clock_value = bt_get(end_clock_value);
- notification->count = (int64_t) count;
- BT_LOGD("Created discarded elements notification object: "
- "type=%s, stream-addr=%p, stream-name=\"%s\", "
- "begin-clock-value-addr=%p, end-clock-value-addr=%p, "
- "count=%" PRIu64 ", addr=%p",
- bt_notification_type_string(type), stream,
- bt_stream_get_name(stream), begin_clock_value,
- end_clock_value, count, ret_notif);
- goto end;
-
-error:
- BT_PUT(ret_notif);
-
-end:
- return ret_notif;
-}
-
-BT_HIDDEN
-struct bt_clock_value *
-bt_notification_discarded_elements_borrow_begin_clock_value(
- enum bt_notification_type type,
- struct bt_notification *notification)
-{
- struct bt_notification_discarded_elements *discarded_elems_notif;
-
- BT_ASSERT_PRE_NON_NULL(notification, "Notification");
- BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, type);
- discarded_elems_notif = container_of(notification,
- struct bt_notification_discarded_elements, parent);
- return discarded_elems_notif->begin_clock_value;
-}
-
-BT_HIDDEN
-struct bt_clock_value *
-bt_notification_discarded_elements_borrow_end_clock_value(
- enum bt_notification_type type,
- struct bt_notification *notification)
-{
- struct bt_notification_discarded_elements *discarded_elems_notif;
-
- BT_ASSERT_PRE_NON_NULL(notification, "Notification");
- BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, type);
- discarded_elems_notif = container_of(notification,
- struct bt_notification_discarded_elements, parent);
- return discarded_elems_notif->end_clock_value;
-}
-
-BT_HIDDEN
-int64_t bt_notification_discarded_elements_get_count(
- enum bt_notification_type type,
- struct bt_notification *notification)
-{
- struct bt_notification_discarded_elements *discarded_elems_notif;
-
- BT_ASSERT_PRE_NON_NULL(notification, "Notification");
- BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, type);
- discarded_elems_notif = container_of(notification,
- struct bt_notification_discarded_elements, parent);
- return discarded_elems_notif->count;
-}
-
-BT_HIDDEN
-struct bt_stream *bt_notification_discarded_elements_borrow_stream(
- enum bt_notification_type type,
- struct bt_notification *notification)
-{
- struct bt_notification_discarded_elements *discarded_elems_notif;
-
- BT_ASSERT_PRE_NON_NULL(notification, "Notification");
- BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, type);
- discarded_elems_notif = container_of(notification,
- struct bt_notification_discarded_elements, parent);
- return discarded_elems_notif->stream;
-}
#include <babeltrace/ctf-ir/stream-class-internal.h>
#include <babeltrace/ctf-ir/trace.h>
#include <babeltrace/graph/graph-internal.h>
-#include <babeltrace/graph/clock-class-priority-map.h>
-#include <babeltrace/graph/clock-class-priority-map-internal.h>
#include <babeltrace/graph/notification-event-internal.h>
#include <babeltrace/types.h>
#include <babeltrace/assert-internal.h>
struct bt_notification *bt_notification_event_create(
struct bt_graph *graph,
struct bt_event_class *event_class,
- struct bt_packet *packet,
- struct bt_clock_class_priority_map *cc_prio_map)
+ struct bt_packet *packet)
{
struct bt_notification_event *notification = NULL;
struct bt_event *event;
BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
BT_ASSERT_PRE_NON_NULL(packet, "Packet");
- BT_ASSERT_PRE_NON_NULL(cc_prio_map, "Clock class priority map");
BT_LOGD("Creating event notification object: "
"event-class-addr=%p, "
- "event-class-name=\"%s\", event-class-id=%" PRId64 ", "
- "cc-prio-map-addr=%p",
+ "event-class-name=\"%s\", event-class-id=%" PRId64,
event_class,
bt_event_class_get_name(event_class),
- bt_event_class_get_id(event_class), cc_prio_map);
+ bt_event_class_get_id(event_class));
BT_ASSERT_PRE(event_class_has_trace(event_class),
"Event class is not part of a trace: %!+E", event_class);
event = bt_event_create(event_class, packet);
goto error;
}
- BT_ASSERT(!notification->cc_prio_map);
- notification->cc_prio_map = cc_prio_map;
- bt_object_get_no_null_check_no_parent_check(
- ¬ification->cc_prio_map->base);
BT_ASSERT(!notification->event);
notification->event = event;
- BT_LOGD_STR("Freezing event notification's clock class priority map.");
- bt_clock_class_priority_map_freeze(notification->cc_prio_map);
BT_LOGD("Created event notification object: "
"event-addr=%p, event-class-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64 ", "
- "cc-prio-map-addr=%p, notif-addr=%p",
+ "notif-addr=%p",
notification->event, event_class,
bt_event_class_get_name(event_class),
- bt_event_class_get_id(event_class), cc_prio_map,
+ bt_event_class_get_id(event_class),
notification);
goto end;
bt_event_recycle(event_notif->event);
}
- BT_LOGD_STR("Putting clock class priority map.");
- BT_PUT(event_notif->cc_prio_map);
g_free(notif);
}
BT_LOGD_STR("Recycling event.");
bt_event_recycle(event_notif->event);
event_notif->event = NULL;
- bt_object_put_no_null_check(&event_notif->cc_prio_map->base);
- event_notif->cc_prio_map = NULL;
graph = notif->graph;
notif->graph = NULL;
bt_object_pool_recycle_object(&graph->event_notif_pool, notif);
struct bt_notification_event, parent);
return event_notification->event;
}
-
-extern struct bt_clock_class_priority_map *
-bt_notification_event_borrow_clock_class_priority_map(
- struct bt_notification *notification)
-{
- struct bt_notification_event *event_notification;
-
- BT_ASSERT_PRE_NON_NULL(notification, "Notification");
- BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, BT_NOTIFICATION_TYPE_EVENT);
- event_notification = container_of(notification,
- struct bt_notification_event, parent);
- return event_notification->cc_prio_map;
-}
#include <babeltrace/compiler-internal.h>
#include <babeltrace/ctf-ir/clock-class.h>
#include <babeltrace/ctf-ir/clock-value-internal.h>
-#include <babeltrace/graph/clock-class-priority-map.h>
-#include <babeltrace/graph/clock-class-priority-map-internal.h>
#include <babeltrace/graph/notification-internal.h>
#include <babeltrace/graph/notification-inactivity-internal.h>
#include <babeltrace/assert-pre-internal.h>
(struct bt_notification_inactivity *) obj;
BT_LOGD("Destroying inactivity notification: addr=%p", notification);
- BT_LOGD_STR("Putting clock class priority map.");
- bt_put(notification->cc_prio_map);
-
- if (notification->clock_values) {
- BT_LOGD_STR("Putting clock values.");
- g_hash_table_destroy(notification->clock_values);
- }
-
+ bt_clock_value_set_finalize(¬ification->cv_set);
g_free(notification);
}
struct bt_notification *bt_notification_inactivity_create(
- struct bt_graph *graph,
- struct bt_clock_class_priority_map *cc_prio_map)
+ struct bt_graph *graph)
{
struct bt_notification_inactivity *notification;
struct bt_notification *ret_notif = NULL;
- uint64_t i;
+ int ret;
- if (cc_prio_map) {
- /* Function's reference, released at the end */
- bt_get(cc_prio_map);
- } else {
- cc_prio_map = bt_clock_class_priority_map_create();
- if (!cc_prio_map) {
- BT_LOGE_STR("Cannot create empty clock class priority map.");
- goto error;
- }
- }
-
- BT_LOGD("Creating inactivity notification object: "
- "cc-prio-map-addr=%p",
- cc_prio_map);
+ BT_LOGD_STR("Creating inactivity notification object.");
notification = g_new0(struct bt_notification_inactivity, 1);
if (!notification) {
BT_LOGE_STR("Failed to allocate one inactivity notification.");
BT_NOTIFICATION_TYPE_INACTIVITY,
bt_notification_inactivity_destroy, NULL);
ret_notif = ¬ification->parent;
- notification->clock_values = g_hash_table_new_full(g_direct_hash,
- g_direct_equal, NULL, (GDestroyNotify) bt_clock_value_recycle);
- if (!notification->clock_values) {
- BT_LOGE_STR("Failed to allocate a GHashTable.");
+ ret = bt_clock_value_set_initialize(¬ification->cv_set);
+ if (ret) {
goto error;
}
- for (i = 0; i < cc_prio_map->entries->len; i++) {
- struct bt_clock_value *clock_value;
- struct bt_clock_class *clock_class =
- cc_prio_map->entries->pdata[i];
-
- clock_value = bt_clock_value_create(clock_class);
- if (!clock_value) {
- BT_LIB_LOGE("Cannot create clock value from clock class: "
- "%![cc-]+K", clock_class);
- goto error;
- }
-
- g_hash_table_insert(notification->clock_values,
- clock_class, clock_value);
- }
-
- notification->cc_prio_map = bt_get(cc_prio_map);
- BT_LOGD_STR("Freezing inactivity notification's clock class priority map.");
- bt_clock_class_priority_map_freeze(cc_prio_map);
- BT_LOGD("Created inactivity notification object: "
- "cc-prio-map-addr=%p, notif-addr=%p",
- cc_prio_map, ret_notif);
+ BT_LOGD("Created inactivity notification object: addr=%p",
+ ret_notif);
goto end;
error:
BT_PUT(ret_notif);
end:
- bt_put(cc_prio_map);
return ret_notif;
}
-extern struct bt_clock_class_priority_map *
-bt_notification_inactivity_borrow_clock_class_priority_map(
- struct bt_notification *notification)
+int bt_notification_inactivity_set_clock_value(struct bt_notification *notif,
+ struct bt_clock_class *clock_class, uint64_t raw_value,
+ bt_bool is_default)
{
- struct bt_notification_inactivity *inactivity_notification;
+ struct bt_notification_inactivity *inactivity = (void *) notif;
- BT_ASSERT_PRE_NON_NULL(notification, "Notification");
- BT_ASSERT_PRE_NOTIF_IS_TYPE(notification,
- BT_NOTIFICATION_TYPE_INACTIVITY);
- inactivity_notification = container_of(notification,
- struct bt_notification_inactivity, parent);
- return inactivity_notification->cc_prio_map;
+ BT_ASSERT_PRE_NON_NULL(notif, "Notification");
+ BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
+ BT_ASSERT_PRE_HOT(notif, "Notification", ": %!+n", notif);
+ BT_ASSERT_PRE_NOTIF_IS_TYPE(notif, BT_NOTIFICATION_TYPE_INACTIVITY);
+ BT_ASSERT_PRE(is_default,
+ "You can only set a default clock value as of this version.");
+ return bt_clock_value_set_set_clock_value(&inactivity->cv_set,
+ clock_class, raw_value, is_default);
}
-struct bt_clock_value *bt_notification_inactivity_borrow_clock_value(
- struct bt_notification *notification,
- struct bt_clock_class *clock_class)
+struct bt_clock_value *bt_notification_inactivity_borrow_default_clock_value(
+ struct bt_notification *notif)
{
- struct bt_notification_inactivity *inactivity_notification;
+ struct bt_notification_inactivity *inactivity = (void *) notif;
+ struct bt_clock_value *clock_value = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(notif, "Notification");
+ BT_ASSERT_PRE_NOTIF_IS_TYPE(notif, BT_NOTIFICATION_TYPE_INACTIVITY);
+ clock_value = inactivity->cv_set.default_cv;
+ if (!clock_value) {
+ BT_LIB_LOGV("No default clock value: %![notif-]+n", notif);
+ }
- BT_ASSERT_PRE_NON_NULL(notification, "Notification");
- BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
- BT_ASSERT_PRE_NOTIF_IS_TYPE(notification,
- BT_NOTIFICATION_TYPE_INACTIVITY);
- inactivity_notification = container_of(notification,
- struct bt_notification_inactivity, parent);
- return g_hash_table_lookup(
- inactivity_notification->clock_values, clock_class);
+ return clock_value;
}
#define BT_LOG_TAG "NOTIF-STREAM"
#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace/assert-pre-internal.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/ctf-ir/stream-internal.h>
#include <babeltrace/ctf-ir/stream-class.h>
#include <babeltrace/graph/notification-stream-internal.h>
#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
#include <inttypes.h>
static
notification);
BT_LOGD_STR("Putting stream.");
BT_PUT(notification->stream);
+ bt_clock_value_set_finalize(¬ification->cv_set);
g_free(notification);
}
{
struct bt_notification_stream_end *notification;
struct bt_stream_class *stream_class;
+ int ret;
BT_ASSERT_PRE_NON_NULL(stream, "Stream");
stream_class = bt_stream_borrow_class(stream);
BT_NOTIFICATION_TYPE_STREAM_END,
bt_notification_stream_end_destroy, NULL);
notification->stream = bt_get(stream);
+ ret = bt_clock_value_set_initialize(¬ification->cv_set);
+ if (ret) {
+ goto error;
+ }
+
BT_LOGD("Created stream end notification object: "
"stream-addr=%p, stream-name=\"%s\", "
"stream-class-addr=%p, stream-class-name=\"%s\", "
return stream_end->stream;
}
+int bt_notification_stream_end_set_clock_value(struct bt_notification *notif,
+ struct bt_clock_class *clock_class, uint64_t raw_value,
+ bt_bool is_default)
+{
+ struct bt_notification_stream_end *stream_end = (void *) notif;
+
+ BT_ASSERT_PRE_NON_NULL(notif, "Notification");
+ BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
+ BT_ASSERT_PRE_HOT(notif, "Notification", ": %!+n", notif);
+ BT_ASSERT_PRE_NOTIF_IS_TYPE(notif, BT_NOTIFICATION_TYPE_STREAM_END);
+ BT_ASSERT_PRE(is_default,
+ "You can only set a default clock value as of this version.");
+ return bt_clock_value_set_set_clock_value(&stream_end->cv_set,
+ clock_class, raw_value, is_default);
+}
+
+struct bt_clock_value *bt_notification_stream_end_borrow_default_clock_value(
+ struct bt_notification *notif)
+{
+ struct bt_notification_stream_end *stream_end = (void *) notif;
+ struct bt_clock_value *clock_value = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(notif, "Notification");
+ BT_ASSERT_PRE_NOTIF_IS_TYPE(notif, BT_NOTIFICATION_TYPE_STREAM_END);
+ clock_value = stream_end->cv_set.default_cv;
+ if (!clock_value) {
+ BT_LIB_LOGV("No default clock value: %![notif-]+n", notif);
+ }
+
+ return clock_value;
+}
+
static
void bt_notification_stream_begin_destroy(struct bt_object *obj)
{
notification);
BT_LOGD_STR("Putting stream.");
BT_PUT(notification->stream);
+ bt_clock_value_set_finalize(¬ification->cv_set);
g_free(notification);
}
struct bt_notification *bt_notification_stream_begin_create(
struct bt_graph *graph, struct bt_stream *stream)
{
+ int ret;
struct bt_notification_stream_begin *notification;
struct bt_stream_class *stream_class;
BT_NOTIFICATION_TYPE_STREAM_BEGIN,
bt_notification_stream_begin_destroy, NULL);
notification->stream = bt_get(stream);
+ ret = bt_clock_value_set_initialize(¬ification->cv_set);
+ if (ret) {
+ goto error;
+ }
+
BT_LOGD("Created stream beginning notification object: "
"stream-addr=%p, stream-name=\"%s\", "
"stream-class-addr=%p, stream-class-name=\"%s\", "
struct bt_notification_stream_begin, parent);
return stream_begin->stream;
}
+
+int bt_notification_stream_begin_set_clock_value(struct bt_notification *notif,
+ struct bt_clock_class *clock_class, uint64_t raw_value,
+ bt_bool is_default)
+{
+ struct bt_notification_stream_begin *stream_begin = (void *) notif;
+
+ BT_ASSERT_PRE_NON_NULL(notif, "Notification");
+ BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
+ BT_ASSERT_PRE_HOT(notif, "Notification", ": %!+n", notif);
+ BT_ASSERT_PRE_NOTIF_IS_TYPE(notif, BT_NOTIFICATION_TYPE_STREAM_BEGIN);
+ BT_ASSERT_PRE(is_default,
+ "You can only set a default clock value as of this version.");
+ return bt_clock_value_set_set_clock_value(&stream_begin->cv_set,
+ clock_class, raw_value, is_default);
+}
+
+struct bt_clock_value *bt_notification_stream_begin_borrow_default_clock_value(
+ struct bt_notification *notif)
+{
+ struct bt_notification_stream_begin *stream_begin = (void *) notif;
+ struct bt_clock_value *clock_value = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(notif, "Notification");
+ BT_ASSERT_PRE_NOTIF_IS_TYPE(notif, BT_NOTIFICATION_TYPE_STREAM_BEGIN);
+ clock_value = stream_begin->cv_set.default_cv;
+ if (!clock_value) {
+ BT_LIB_LOGV("No default clock value: %![notif-]+n", notif);
+ }
+
+ return clock_value;
+}
#include <babeltrace/ctf-writer/trace-internal.h>
#include <babeltrace/ctf-writer/clock-internal.h>
#include <babeltrace/ctf-writer/writer-internal.h>
-#include <babeltrace/graph/clock-class-priority-map-internal.h>
#include <babeltrace/graph/component-class-internal.h>
#include <babeltrace/graph/component-class-sink-colander-internal.h>
#include <babeltrace/graph/component-filter-internal.h>
#include <babeltrace/graph/component-source-internal.h>
#include <babeltrace/graph/connection-internal.h>
#include <babeltrace/graph/graph-internal.h>
-#include <babeltrace/graph/notification-discarded-elements-internal.h>
#include <babeltrace/graph/notification-event-internal.h>
#include <babeltrace/graph/notification-inactivity-internal.h>
#include <babeltrace/graph/notification-internal.h>
static inline void format_connection(char **buf_ch, bool extended,
const char *prefix, struct bt_connection *connection);
+static inline void format_clock_value(char **buf_ch, bool extended,
+ const char *prefix, struct bt_clock_value *clock_value);
+
static inline void format_object(char **buf_ch, bool extended,
const char *prefix, struct bt_object *obj)
{
BUF_APPEND(", %sref-count=%llu", prefix, obj->ref_count);
}
+static inline void format_clock_value_set(char **buf_ch, bool extended,
+ const char *prefix, struct bt_clock_value_set *cv_set)
+{
+ char tmp_prefix[64];
+
+ if (!cv_set->clock_values) {
+ return;
+ }
+
+ BUF_APPEND(", %ssize=%u", PRFIELD(cv_set->clock_values->len));
+
+ if (cv_set->default_cv) {
+ SET_TMP_PREFIX("default-cv-");
+ format_clock_value(buf_ch, extended, tmp_prefix,
+ cv_set->default_cv);
+ }
+}
+
static inline void format_object_pool(char **buf_ch, bool extended,
const char *prefix, struct bt_object_pool *pool)
{
return;
}
- if (event->clock_values) {
- BUF_APPEND(", %sclock-value-count=%u",
- PRFIELD(g_hash_table_size(event->clock_values)));
- }
-
+ SET_TMP_PREFIX("cvs-");
+ format_clock_value_set(buf_ch, extended, tmp_prefix, &event->cv_set);
packet = bt_event_borrow_packet(event);
if (!packet) {
return;
const char *prefix, struct bt_clock_value *clock_value)
{
char tmp_prefix[64];
- BUF_APPEND(", %svalue=%" PRIu64 ", %sns-from-epoch=%" PRId64,
+ BUF_APPEND(", %sraw-value=%" PRIu64 ", %sns-from-epoch=%" PRId64,
PRFIELD(clock_value->value),
PRFIELD(clock_value->ns_from_epoch));
SET_TMP_PREFIX("event-");
format_event(buf_ch, true, tmp_prefix, notif_event->event);
-
- if (!notif_event->cc_prio_map) {
- return;
- }
-
- BUF_APPEND(", %scc-prio-map-addr=%p, %scc-prio-map-cc-count=%u",
- PRFIELD(notif_event->cc_prio_map),
- PRFIELD(notif_event->cc_prio_map->entries->len));
- break;
- }
- case BT_NOTIFICATION_TYPE_INACTIVITY:
- {
- struct bt_notification_inactivity *notif_inactivity =
- (void *) notif;
-
- if (!notif_inactivity->cc_prio_map) {
- return;
- }
-
- BUF_APPEND(", %scc-prio-map-addr=%p, %scc-prio-map-cc-count=%u",
- PRFIELD(notif_inactivity->cc_prio_map),
- PRFIELD(notif_inactivity->cc_prio_map->entries->len));
break;
}
case BT_NOTIFICATION_TYPE_STREAM_BEGIN:
format_packet(buf_ch, true, tmp_prefix, notif_packet->packet);
break;
}
- case BT_NOTIFICATION_TYPE_DISCARDED_EVENTS:
- case BT_NOTIFICATION_TYPE_DISCARDED_PACKETS:
- {
- struct bt_notification_discarded_elements *notif_discarded =
- (void *) notif;
-
- BUF_APPEND(", %scount=%" PRId64,
- PRFIELD(notif_discarded->count));
-
- if (notif_discarded->begin_clock_value) {
- SET_TMP_PREFIX("begin-clock-value-");
- format_clock_value(buf_ch, true, tmp_prefix,
- notif_discarded->begin_clock_value);
- }
-
- if (notif_discarded->end_clock_value) {
- SET_TMP_PREFIX("end-clock-value-");
- format_clock_value(buf_ch, true, tmp_prefix,
- notif_discarded->end_clock_value);
- }
- break;
- }
default:
break;
}
(_value))
#define BT_ASSERT_PRE_VALUE_HOT(_value, _name) \
- BT_ASSERT_PRE_HOT((_value), (_name), ": +%!+v", (_value))
+ BT_ASSERT_PRE_HOT((_value), (_name), ": %!+v", (_value))
#define BT_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(_index, _count) \
BT_ASSERT_PRE((_index) < (_count), \
int ret = 0;
struct ctf_node *node;
+ *value = 0;
+
if (bt_list_empty(head)) {
ret = -1;
goto end;
void *data;
};
+/* Clock value: clock class and raw value */
+struct clock_value {
+ struct bt_clock_class *clock_class; /* Weak */
+ uint64_t raw_value;
+};
+
/* CTF notification iterator */
struct bt_notif_iter {
/* Visit stack */
struct bt_trace *trace;
struct bt_stream_class *stream_class;
struct bt_event_class *event_class;
- struct bt_clock_class_priority_map *cc_prio_map;
} meta;
/* Current packet header field wrapper (NULL if not created yet) */
/* Current content size (bits) (-1 if unknown) */
int64_t cur_content_size;
+ /* Current packet default beginning and end clock values */
+ struct clock_value cur_packet_begin_cv;
+ struct clock_value cur_packet_end_cv;
+
/*
* Offset, in the underlying media, of the current packet's start
* (-1 if unknown).
return status;
}
+static inline
+void reset_clock_value(struct clock_value *cv)
+{
+ BT_ASSERT(cv);
+ cv->clock_class = NULL;
+ cv->raw_value = UINT64_C(-1);
+}
+
static
enum bt_notif_iter_status read_dscope_begin_state(
struct bt_notif_iter *notit,
STATE_AFTER_STREAM_PACKET_CONTEXT);
}
+static inline
+uint64_t get_field_raw_clock_value(struct bt_field *base_field,
+ const char *field_name, struct bt_clock_class **user_cc)
+{
+ struct bt_field *field;
+ struct bt_field_type *ft;
+ struct bt_clock_class *clock_class = NULL;
+ uint64_t val = UINT64_C(-1);
+ int ret;
+
+ field = bt_field_structure_borrow_field_by_name(base_field, field_name);
+ if (!field) {
+ goto end;
+ }
+
+ ft = bt_field_borrow_type(field);
+ BT_ASSERT(ft);
+
+ if (!bt_field_type_is_integer(ft)) {
+ goto end;
+ }
+
+ clock_class = bt_field_type_integer_borrow_mapped_clock_class(ft);
+ if (!clock_class) {
+ goto end;
+ }
+
+ ret = bt_field_integer_unsigned_get_value(field, &val);
+ BT_ASSERT(ret == 0);
+
+end:
+ *user_cc = clock_class;
+ return val;
+}
+
+static
+void set_current_packet_begin_end(struct bt_notif_iter *notit)
+{
+ struct bt_clock_class *clock_class;
+ uint64_t val;
+
+ if (!notit->dscopes.stream_packet_context) {
+ goto end;
+ }
+
+ val = get_field_raw_clock_value(notit->dscopes.stream_packet_context,
+ "timestamp_begin", &clock_class);
+ notit->cur_packet_begin_cv.clock_class = clock_class;
+ notit->cur_packet_begin_cv.raw_value = val;
+ val = get_field_raw_clock_value(notit->dscopes.stream_packet_context,
+ "timestamp_end", &clock_class);
+ notit->cur_packet_end_cv.clock_class = clock_class;
+ notit->cur_packet_end_cv.raw_value = val;
+
+end:
+ return;
+}
+
static
enum bt_notif_iter_status set_current_packet_content_sizes(
struct bt_notif_iter *notit)
enum bt_notif_iter_status status;
status = set_current_packet_content_sizes(notit);
- if (status == BT_NOTIF_ITER_STATUS_OK) {
- if (notit->stream_begin_emitted) {
- notit->state = STATE_EMIT_NOTIF_NEW_PACKET;
- } else {
- notit->state = STATE_EMIT_NOTIF_NEW_STREAM;
- }
+ if (status != BT_NOTIF_ITER_STATUS_OK) {
+ goto end;
+ }
+
+ set_current_packet_begin_end(notit);
+
+ if (notit->stream_begin_emitted) {
+ notit->state = STATE_EMIT_NOTIF_NEW_PACKET;
+ } else {
+ notit->state = STATE_EMIT_NOTIF_NEW_STREAM;
}
+end:
return status;
}
notit->packet);
BT_ASSERT(notit->graph);
notif = bt_notification_event_create(notit->graph,
- notit->meta.event_class, notit->packet,
- notit->meta.cc_prio_map);
+ notit->meta.event_class, notit->packet);
if (!notif) {
BT_LOGE("Cannot create event notification: "
"notit-addr=%p, ec-addr=%p, ec-name=\"%s\", "
notit->cur_content_size = -1;
notit->cur_packet_size = -1;
notit->cur_packet_offset = -1;
+ reset_clock_value(¬it->cur_packet_begin_cv);
+ reset_clock_value(¬it->cur_packet_end_cv);
notit->stream_begin_emitted = false;
notit->cur_timestamp_end = NULL;
}
notit->cur_content_size = -1;
notit->cur_packet_size = -1;
+ reset_clock_value(¬it->cur_packet_begin_cv);
+ reset_clock_value(¬it->cur_packet_end_cv);
notit->cur_sc_field_path_cache = NULL;
end:
while (g_hash_table_iter_next(&iter, (gpointer) &clock_class,
(gpointer) &clock_state)) {
- struct bt_clock_value *clock_value;
-
- clock_value = bt_event_borrow_clock_value(notit->event,
- clock_class);
- if (!clock_value) {
- BT_LOGE("Cannot borrow clock value from event with given clock class: "
+ ret = bt_event_set_clock_value(notit->event, clock_class,
+ *clock_state, BT_TRUE);
+ if (ret) {
+ BT_LOGE("Cannot set event's default clock value: "
"notit-addr=%p, clock-class-addr=%p, "
"clock-class-name=\"%s\"",
notit, clock_class,
ret = -1;
goto end;
}
-
- ret = bt_clock_value_set_value(clock_value, *clock_state);
- BT_ASSERT(ret == 0);
}
ret = 0;
+
end:
return ret;
}
notit->dscopes.stream_packet_context);
}
+ if (notit->cur_packet_begin_cv.clock_class) {
+ ret = bt_packet_set_beginning_clock_value(notit->packet,
+ notit->cur_packet_begin_cv.clock_class,
+ notit->cur_packet_begin_cv.raw_value, BT_TRUE);
+ if (ret) {
+ BT_LOGE("Cannot set packet's default beginning clock value: "
+ "notit-addr=%p, packet-addr=%p",
+ notit, notit->packet);
+ goto end;
+ }
+ }
+
+ if (notit->cur_packet_end_cv.clock_class) {
+ ret = bt_packet_set_end_clock_value(notit->packet,
+ notit->cur_packet_end_cv.clock_class,
+ notit->cur_packet_end_cv.raw_value, BT_TRUE);
+ if (ret) {
+ BT_LOGE("Cannot set packet's default end clock value: "
+ "notit-addr=%p, packet-addr=%p",
+ notit, notit->packet);
+ goto end;
+ }
+ }
+
BT_ASSERT(notit->graph);
notif = bt_notification_packet_begin_create(notit->graph,
notit->packet);
BT_LOGE("Cannot create packet beginning notification: "
"notit-addr=%p, packet-addr=%p",
notit, notit->packet);
- return;
+ goto end;
}
-end:
*notification = notif;
+
+end:
+ return;
}
static
{
BT_PUT(notit->packet);
BT_PUT(notit->stream);
- BT_PUT(notit->meta.cc_prio_map);
release_all_dscopes(notit);
BT_LOGD("Destroying CTF plugin notification iterator: addr=%p", notit);
enum bt_notif_iter_status bt_notif_iter_get_next_notification(
struct bt_notif_iter *notit,
- struct bt_clock_class_priority_map *cc_prio_map,
struct bt_graph *graph,
struct bt_notification **notification)
{
goto end;
}
- if (cc_prio_map != notit->meta.cc_prio_map) {
- bt_put(notit->meta.cc_prio_map);
- notit->meta.cc_prio_map = bt_get(cc_prio_map);
- }
-
notit->graph = graph;
- BT_LOGV("Getting next notification: notit-addr=%p, cc-prio-map-addr=%p",
- notit, cc_prio_map);
+ BT_LOGV("Getting next notification: notit-addr=%p", notit);
while (true) {
status = handle_state(notit);
* call this function again, until another status is returned.
*
* @param notif_iter CTF notification iterator
- * @param cc_prio_map Clock class priority map to use when
- * creating an event notification
* @param notification Returned notification if the function's
* return value is #BT_NOTIF_ITER_STATUS_OK
* @returns One of #bt_notif_iter_status values
BT_HIDDEN
enum bt_notif_iter_status bt_notif_iter_get_next_notification(
struct bt_notif_iter *notit,
- struct bt_clock_class_priority_map *cc_prio_map,
struct bt_graph *graph,
struct bt_notification **notification);
enum bt_notification_iterator_status status;
notif_iter_status = bt_notif_iter_get_next_notification(
- ds_file->notif_iter, ds_file->cc_prio_map, ds_file->graph,
- notif);
+ ds_file->notif_iter, ds_file->graph, notif);
switch (notif_iter_status) {
case BT_NOTIF_ITER_STATUS_EOF:
return ret;
}
-static
-int create_cc_prio_map(struct ctf_fs_trace *ctf_fs_trace)
-{
- int ret = 0;
- size_t i;
- int count;
-
- BT_ASSERT(ctf_fs_trace);
- ctf_fs_trace->cc_prio_map = bt_clock_class_priority_map_create();
- if (!ctf_fs_trace->cc_prio_map) {
- ret = -1;
- goto end;
- }
-
- count = bt_trace_get_clock_class_count(
- ctf_fs_trace->metadata->trace);
- BT_ASSERT(count >= 0);
-
- for (i = 0; i < count; i++) {
- struct bt_clock_class *clock_class =
- bt_trace_borrow_clock_class_by_index(
- ctf_fs_trace->metadata->trace, i);
-
- BT_ASSERT(clock_class);
- ret = bt_clock_class_priority_map_add_clock_class(
- ctf_fs_trace->cc_prio_map, clock_class, 0);
-
- if (ret) {
- goto end;
- }
- }
-
-end:
- return ret;
-}
-
BT_HIDDEN
struct ctf_fs_trace *ctf_fs_trace_create(const char *path, const char *name,
struct ctf_fs_metadata_config *metadata_config,
goto error;
}
- ret = create_cc_prio_map(ctf_fs_trace);
- if (ret) {
- goto error;
- }
-
/*
* create_ds_file_groups() created all the streams that this
* trace needs. There won't be any more. Therefore it is safe to
goto error;
}
- dmesg_comp->cc_prio_map = bt_clock_class_priority_map_create();
- if (!dmesg_comp->cc_prio_map) {
- BT_LOGE_STR("Cannot create empty clock class priority map.");
- goto error;
- }
-
if (has_ts) {
dmesg_comp->clock_class = create_clock_class();
if (!dmesg_comp->clock_class) {
goto error;
}
- ret = bt_clock_class_priority_map_add_clock_class(
- dmesg_comp->cc_prio_map, dmesg_comp->clock_class, 0);
- if (ret) {
- BT_LOGE_STR("Cannot add clock class to clock class priority map.");
- goto error;
- }
-
bt_put(ft);
ft = create_event_header_ft(dmesg_comp->clock_class);
if (!ft) {
}
notif = bt_notification_event_create(dmesg_comp->graph,
- dmesg_comp->event_class, dmesg_comp->packet,
- dmesg_comp->cc_prio_map);
+ dmesg_comp->event_class, dmesg_comp->packet);
if (!notif) {
BT_LOGE_STR("Cannot create event notification.");
goto error;
BT_ASSERT(event);
if (dmesg_comp->clock_class) {
- struct bt_clock_value *cv = bt_event_borrow_clock_value(event,
- dmesg_comp->clock_class);
-
- ret = bt_clock_value_set_value(cv, ts);
+ ret = bt_event_set_clock_value(event,
+ dmesg_comp->clock_class, ts, BT_TRUE);
BT_ASSERT(ret == 0);
eh_field = bt_event_borrow_header(event);
BT_ASSERT(eh_field);
case BT_NOTIFICATION_TYPE_INACTIVITY:
fprintf(stderr, "Inactivity notification\n");
break;
- case BT_NOTIFICATION_TYPE_DISCARDED_PACKETS:
- case BT_NOTIFICATION_TYPE_DISCARDED_EVENTS:
- ret = pretty_print_discarded_elements(pretty, notification);
- break;
default:
break;
}
enum bt_component_status pretty_print_event(struct pretty_component *pretty,
struct bt_notification *event_notif);
-BT_HIDDEN
-enum bt_component_status pretty_print_discarded_elements(
- struct pretty_component *pretty,
- struct bt_notification *notif);
-
#endif /* BABELTRACE_PLUGIN_TEXT_PRETTY_PRETTY_H */
static
void print_timestamp_cycles(struct pretty_component *pretty,
- struct bt_clock_class *clock_class,
struct bt_event *event)
{
int ret;
struct bt_clock_value *clock_value;
uint64_t cycles;
- clock_value = bt_event_borrow_clock_value(event, clock_class);
+ clock_value = bt_event_borrow_default_clock_value(event);
if (!clock_value) {
g_string_append(pretty->string, "????????????????????");
return;
static
enum bt_component_status print_event_timestamp(struct pretty_component *pretty,
- struct bt_event *event,
- struct bt_clock_class_priority_map *cc_prio_map,
- bool *start_line)
+ struct bt_event *event, bool *start_line)
{
bool print_names = pretty->options.print_header_field_names;
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
struct bt_stream *stream = NULL;
struct bt_stream_class *stream_class = NULL;
struct bt_trace *trace = NULL;
- struct bt_clock_class *clock_class = NULL;
+ struct bt_clock_value *clock_value = NULL;
stream = bt_event_borrow_stream(event);
if (!stream) {
goto end;
}
- if (bt_clock_class_priority_map_get_clock_class_count(cc_prio_map) == 0) {
- /* No clock class: skip the timestamp without an error */
- goto end;
- }
-
- clock_class =
- bt_clock_class_priority_map_borrow_highest_priority_clock_class(
- cc_prio_map);
- if (!clock_class) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ clock_value = bt_event_borrow_default_clock_value(event);
+ if (!clock_value) {
+ /* No default clock value: skip the timestamp without an error */
goto end;
}
g_string_append(pretty->string, COLOR_TIMESTAMP);
}
if (pretty->options.print_timestamp_cycles) {
- print_timestamp_cycles(pretty, clock_class, event);
+ print_timestamp_cycles(pretty, event);
} else {
struct bt_clock_value *clock_value =
- bt_event_borrow_clock_value(event, clock_class);
+ bt_event_borrow_default_clock_value(event);
print_timestamp_wall(pretty, clock_value);
}
static
enum bt_component_status print_event_header(struct pretty_component *pretty,
- struct bt_event *event,
- struct bt_clock_class_priority_map *cc_prio_map)
+ struct bt_event *event)
{
bool print_names = pretty->options.print_header_field_names;
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
ret = BT_COMPONENT_STATUS_ERROR;
goto end;
}
- ret = print_event_timestamp(pretty, event, cc_prio_map,
- &pretty->start_line);
+ ret = print_event_timestamp(pretty, event, &pretty->start_line);
if (ret != BT_COMPONENT_STATUS_OK) {
goto end;
}
enum bt_component_status ret;
struct bt_event *event =
bt_notification_event_borrow_event(event_notif);
- struct bt_clock_class_priority_map *cc_prio_map =
- bt_notification_event_borrow_clock_class_priority_map(
- event_notif);
BT_ASSERT(event);
- BT_ASSERT(cc_prio_map);
pretty->start_line = true;
g_string_assign(pretty->string, "");
- ret = print_event_header(pretty, event, cc_prio_map);
+ ret = print_event_header(pretty, event);
if (ret != BT_COMPONENT_STATUS_OK) {
goto end;
}
end:
return ret;
}
-
-BT_HIDDEN
-enum bt_component_status pretty_print_discarded_elements(
- struct pretty_component *pretty,
- struct bt_notification *notif)
-{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
- struct bt_stream *stream = NULL;
- struct bt_stream_class *stream_class = NULL;
- struct bt_trace *trace = NULL;
- const char *stream_name;
- const char *trace_name;
- const unsigned char *trace_uuid;
- int64_t stream_class_id;
- int64_t stream_id;
- bool is_discarded_events;
- int64_t count;
- struct bt_clock_value *clock_value = NULL;
-
- /* Stream name */
- switch (bt_notification_get_type(notif)) {
- case BT_NOTIFICATION_TYPE_DISCARDED_EVENTS:
- stream = bt_notification_discarded_events_borrow_stream(notif);
- count = bt_notification_discarded_events_get_count(notif);
- is_discarded_events = true;
- break;
- case BT_NOTIFICATION_TYPE_DISCARDED_PACKETS:
- stream = bt_notification_discarded_packets_borrow_stream(notif);
- count = bt_notification_discarded_packets_get_count(notif);
- is_discarded_events = false;
- break;
- default:
- abort();
- }
-
- BT_ASSERT(stream);
- stream_name = bt_stream_get_name(stream);
-
- /* Stream class ID */
- stream_class = bt_stream_borrow_class(stream);
- BT_ASSERT(stream_class);
- stream_class_id = bt_stream_class_get_id(stream_class);
-
- /* Stream ID */
- stream_id = bt_stream_get_id(stream);
-
- /* Trace path */
- trace = bt_stream_class_borrow_trace(stream_class);
- BT_ASSERT(trace);
- trace_name = bt_trace_get_name(trace);
- if (!trace_name) {
- trace_name = "(unknown)";
- }
-
- /* Trace UUID */
- trace_uuid = bt_trace_get_uuid(trace);
-
- /*
- * Print to standard error stream to remain backward compatible
- * with Babeltrace 1.
- */
- fprintf(stderr,
- "%s%sWARNING%s%s: Tracer discarded %" PRId64 " %s%s between [",
- bt_common_color_fg_yellow(),
- bt_common_color_bold(),
- bt_common_color_reset(),
- bt_common_color_fg_yellow(),
- count, is_discarded_events ? "event" : "packet",
- count == 1 ? "" : "s");
- g_string_assign(pretty->string, "");
- clock_value = is_discarded_events ?
- bt_notification_discarded_events_borrow_begin_clock_value(notif) :
- bt_notification_discarded_packets_borrow_begin_clock_value(notif);
- print_timestamp_wall(pretty, clock_value);
- fprintf(stderr, "%s] and [", pretty->string->str);
- g_string_assign(pretty->string, "");
- clock_value = is_discarded_events ?
- bt_notification_discarded_events_borrow_end_clock_value(notif) :
- bt_notification_discarded_packets_borrow_end_clock_value(notif);
- print_timestamp_wall(pretty, clock_value);
- fprintf(stderr, "%s] in trace \"%s\" ",
- pretty->string->str, trace_name);
-
- if (trace_uuid) {
- fprintf(stderr,
- "(UUID: %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x) ",
- trace_uuid[0],
- trace_uuid[1],
- trace_uuid[2],
- trace_uuid[3],
- trace_uuid[4],
- trace_uuid[5],
- trace_uuid[6],
- trace_uuid[7],
- trace_uuid[8],
- trace_uuid[9],
- trace_uuid[10],
- trace_uuid[11],
- trace_uuid[12],
- trace_uuid[13],
- trace_uuid[14],
- trace_uuid[15]);
- } else {
- fprintf(stderr, "(no UUID) ");
- }
-
- fprintf(stderr, "within stream \"%s\" (stream class ID: %" PRId64 ", ",
- stream_name, stream_class_id);
-
- if (stream_id >= 0) {
- fprintf(stderr, "stream ID: %" PRId64, stream_id);
- } else {
- fprintf(stderr, "no stream ID");
- }
-
- fprintf(stderr, ").%s\n", bt_common_color_reset());
- return ret;
-}
counter->count.packet_begin +
counter->count.packet_end +
counter->count.inactivity +
- counter->count.discarded_events +
- counter->count.discarded_packets +
counter->count.other;
}
PRINTF_COUNT("packet beginning", "packet beginnings", packet_begin);
PRINTF_COUNT("packet end", "packet ends", packet_end);
PRINTF_COUNT("inactivity", "inactivities", inactivity);
- PRINTF_COUNT("discarded events notification",
- "discarded events notifications", discarded_events_notifs);
- PRINTF_COUNT(" known discarded event", " known discarded events",
- discarded_events);
- PRINTF_COUNT("discarded packets notification",
- "discarded packets notifications", discarded_packets_notifs);
- PRINTF_COUNT(" known discarded packet", " known discarded packets",
- discarded_packets);
if (counter->count.other > 0) {
PRINTF_COUNT(" other (unknown) notification",
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
struct counter *counter;
enum bt_notification_iterator_status it_ret;
- int64_t count;
uint64_t notif_count;
bt_notification_array notifs;
case BT_NOTIFICATION_TYPE_PACKET_END:
counter->count.packet_end++;
break;
- case BT_NOTIFICATION_TYPE_DISCARDED_EVENTS:
- counter->count.discarded_events_notifs++;
- count = bt_notification_discarded_events_get_count(
- notif);
- if (count >= 0) {
- counter->count.discarded_events += count;
- }
- break;
- case BT_NOTIFICATION_TYPE_DISCARDED_PACKETS:
- counter->count.discarded_packets_notifs++;
- count = bt_notification_discarded_packets_get_count(
- notif);
- if (count >= 0) {
- counter->count.discarded_packets += count;
- }
- break;
default:
counter->count.other++;
}
uint64_t packet_begin;
uint64_t packet_end;
uint64_t inactivity;
- uint64_t discarded_events_notifs;
- uint64_t discarded_events;
- uint64_t discarded_packets_notifs;
- uint64_t discarded_packets;
uint64_t other;
} count;
uint64_t last_printed_total;
struct bt_notification *notif, int64_t last_returned_ts_ns,
int64_t *ts_ns)
{
- struct bt_clock_class_priority_map *cc_prio_map = NULL;
struct bt_clock_class *clock_class = NULL;
struct bt_clock_value *clock_value = NULL;
struct bt_event *event = NULL;
switch (bt_notification_get_type(notif)) {
case BT_NOTIFICATION_TYPE_EVENT:
- cc_prio_map =
- bt_notification_event_borrow_clock_class_priority_map(
- notif);
+ event = bt_notification_event_borrow_event(notif);
+ BT_ASSERT(event);
+ clock_value = bt_event_borrow_default_clock_value(event);
break;
case BT_NOTIFICATION_TYPE_INACTIVITY:
- cc_prio_map =
- bt_notification_inactivity_borrow_clock_class_priority_map(
+ clock_value =
+ bt_notification_inactivity_borrow_default_clock_value(
notif);
break;
default:
goto end;
}
- if (!cc_prio_map) {
- BT_LOGE("Cannot get notification's clock class priority map: "
- "notif-addr=%p", notif);
- goto error;
- }
-
/*
- * If the clock class priority map is empty, then we consider
- * that this notification has no time. In this case it's always
- * the youngest.
+ * If the clock value is missing, then we consider that this
+ * notification has no time. In this case it's always the
+ * youngest.
*/
- if (bt_clock_class_priority_map_get_clock_class_count(cc_prio_map) == 0) {
- BT_LOGV_STR("Notification's clock class priority map contains 0 clock classes: "
+ if (!clock_value) {
+ BT_LOGV_STR("Notification's default clock value is missing: "
"using the last returned timestamp.");
*ts_ns = last_returned_ts_ns;
goto end;
}
- clock_class =
- bt_clock_class_priority_map_borrow_highest_priority_clock_class(
- cc_prio_map);
- if (!clock_class) {
- BT_LOGE("Cannot get the clock class with the highest priority from clock class priority map: "
- "cc-prio-map-addr=%p", cc_prio_map);
- goto error;
- }
-
+ clock_class = bt_clock_value_borrow_class(clock_value);
+ BT_ASSERT(clock_class);
cc_uuid = bt_clock_class_get_uuid(clock_class);
cc_name = bt_clock_class_get_name(clock_class);
}
}
- switch (bt_notification_get_type(notif)) {
- case BT_NOTIFICATION_TYPE_EVENT:
- event = bt_notification_event_borrow_event(notif);
- BT_ASSERT(event);
- clock_value = bt_event_borrow_clock_value(event,
- clock_class);
- break;
- case BT_NOTIFICATION_TYPE_INACTIVITY:
- clock_value = bt_notification_inactivity_borrow_clock_value(
- notif, clock_class);
- break;
- default:
- BT_LOGF("Unexpected notification type at this point: "
- "type=%d", bt_notification_get_type(notif));
- abort();
- }
-
- if (!clock_value) {
- BT_LOGE("Cannot get notification's clock value for clock class: "
- "clock-class-addr=%p, clock-class-name=\"%s\"",
- clock_class, cc_name);
- goto error;
- }
-
ret = bt_clock_value_get_value_ns_from_epoch(clock_value, ts_ns);
if (ret) {
BT_LOGE("Cannot get nanoseconds from Epoch of clock value: "
test_graph_topo_LDADD = $(COMMON_TEST_LDADD)
-test_cc_prio_map_LDADD = $(COMMON_TEST_LDADD)
-
test_bt_notification_iterator_LDADD = $(COMMON_TEST_LDADD)
noinst_PROGRAMS = test_bitfield test_ctf_writer test_bt_values \
test_ctf_ir_ref test_bt_ctf_field_type_validation test_ir_visit \
- test_graph_topo test_cc_prio_map test_bt_notification_iterator
+ test_graph_topo test_bt_notification_iterator
test_bitfield_SOURCES = test_bitfield.c
test_ctf_writer_SOURCES = test_ctf_writer.c
test_bt_ctf_field_type_validation_SOURCES = test_bt_ctf_field_type_validation.c
test_ir_visit_SOURCES = test_ir_visit.c
test_graph_topo_SOURCES = test_graph_topo.c
-test_cc_prio_map_SOURCES = test_cc_prio_map.c
test_bt_notification_iterator_SOURCES = test_bt_notification_iterator.c
check_SCRIPTS = test_ctf_writer_complete
#include <babeltrace/ctf-ir/stream-class.h>
#include <babeltrace/ctf-ir/stream.h>
#include <babeltrace/ctf-ir/trace.h>
-#include <babeltrace/graph/clock-class-priority-map.h>
#include <babeltrace/graph/component-class-filter.h>
#include <babeltrace/graph/component-class-sink.h>
#include <babeltrace/graph/component-class-source.h>
static enum test current_test;
static GArray *test_events;
static struct bt_graph *graph;
-static struct bt_clock_class_priority_map *src_empty_cc_prio_map;
static struct bt_stream_class *src_stream_class;
static struct bt_event_class *src_event_class;
static struct bt_stream *src_stream1;
BT_ASSERT(trace);
ret = bt_trace_set_packet_header_field_type(trace, empty_struct_ft);
BT_ASSERT(ret == 0);
- src_empty_cc_prio_map = bt_clock_class_priority_map_create();
- BT_ASSERT(src_empty_cc_prio_map);
src_stream_class = bt_stream_class_create("my-stream-class");
BT_ASSERT(src_stream_class);
ret = bt_stream_class_set_packet_context_field_type(src_stream_class,
g_array_free(test_events, TRUE);
/* Metadata */
- bt_put(src_empty_cc_prio_map);
bt_put(src_stream_class);
bt_put(src_event_class);
bt_put(src_stream1);
switch (user_data->seq[user_data->at]) {
case SEQ_INACTIVITY:
- *notif = bt_notification_inactivity_create(graph,
- src_empty_cc_prio_map);
+ *notif = bt_notification_inactivity_create(graph);
break;
case SEQ_STREAM1_BEGIN:
*notif = bt_notification_stream_begin_create(graph,
if (event_packet) {
*notif = bt_notification_event_create(graph, src_event_class,
- event_packet, src_empty_cc_prio_map);
+ event_packet);
}
BT_ASSERT(*notif);
+++ /dev/null
-/*
- * test_cc_prio_map.c
- *
- * Copyright 2017 - Philippe Proulx <pproulx@efficios.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; under version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <babeltrace/ref.h>
-#include <babeltrace/graph/clock-class-priority-map.h>
-#include <babeltrace/ctf-ir/clock-class.h>
-#include <babeltrace/assert-internal.h>
-
-#include "tap/tap.h"
-
-#define NR_TESTS 17
-
-static void test_clock_class_priority_map(void)
-{
- struct bt_clock_class_priority_map *cc_prio_map;
- struct bt_clock_class_priority_map *cc_prio_map_copy;
- struct bt_clock_class *cc1;
- struct bt_clock_class *cc2;
- struct bt_clock_class *cc3;
- struct bt_clock_class *cc;
- uint64_t prio;
- int ret;
-
- cc_prio_map = bt_clock_class_priority_map_create();
- ok(cc_prio_map, "bt_clock_class_priority_map_create() succeeds");
- cc1 = bt_clock_class_create("cc1", 1);
- BT_ASSERT(cc1);
- cc2 = bt_clock_class_create("cc2", 2);
- BT_ASSERT(cc2);
- cc3 = bt_clock_class_create("cc3", 3);
- BT_ASSERT(cc3);
- ok(!bt_clock_class_priority_map_get_highest_priority_clock_class(cc_prio_map),
- "bt_clock_class_priority_map_get_highest_priority_clock_class() returns NULL when there's no clock classes");
- ret = bt_clock_class_priority_map_add_clock_class(cc_prio_map, cc2, 75);
- BT_ASSERT(ret == 0);
- cc = bt_clock_class_priority_map_get_highest_priority_clock_class(cc_prio_map);
- ok(cc == cc2,
- "bt_clock_class_priority_map_get_highest_priority_clock_class() returns the expected clock class (1)");
- BT_PUT(cc);
- ret = bt_clock_class_priority_map_add_clock_class(cc_prio_map, cc1, 1001);
- BT_ASSERT(ret == 0);
- cc = bt_clock_class_priority_map_get_highest_priority_clock_class(cc_prio_map);
- ok(cc == cc2,
- "bt_clock_class_priority_map_get_highest_priority_clock_class() returns the expected clock class (2)");
- BT_PUT(cc);
- ret = bt_clock_class_priority_map_add_clock_class(cc_prio_map, cc3, 11);
- BT_ASSERT(ret == 0);
- cc = bt_clock_class_priority_map_get_highest_priority_clock_class(cc_prio_map);
- ok(cc == cc3,
- "bt_clock_class_priority_map_get_highest_priority_clock_class() returns the expected clock class (3)");
- BT_PUT(cc);
- ret = bt_clock_class_priority_map_get_clock_class_priority(cc_prio_map, cc1, &prio);
- ok(ret == 0, "bt_clock_class_priority_map_get_clock_class_priority() succeeds");
- ok(prio == 1001,
- "bt_clock_class_priority_map_get_clock_class_priority() returns the expected priority (1)");
- ret = bt_clock_class_priority_map_get_clock_class_priority(cc_prio_map, cc2, &prio);
- BT_ASSERT(ret == 0);
- ok(prio == 75,
- "bt_clock_class_priority_map_get_clock_class_priority() returns the expected priority (2)");
- ret = bt_clock_class_priority_map_get_clock_class_priority(cc_prio_map, cc3, &prio);
- BT_ASSERT(ret == 0);
- ok(prio == 11,
- "bt_clock_class_priority_map_get_clock_class_priority() returns the expected priority (3)");
- cc_prio_map_copy = bt_clock_class_priority_map_copy(cc_prio_map);
- ok(cc_prio_map_copy, "bt_clock_class_priority_map_copy() succeeds");
- ret = bt_clock_class_priority_map_get_clock_class_priority(cc_prio_map_copy, cc1, &prio);
- BT_ASSERT(ret == 0);
- ok(prio == 1001,
- "bt_clock_class_priority_map_get_clock_class_priority() returns the expected priority (1, copy)");
- ret = bt_clock_class_priority_map_get_clock_class_priority(cc_prio_map_copy, cc2, &prio);
- BT_ASSERT(ret == 0);
- ok(prio == 75,
- "bt_clock_class_priority_map_get_clock_class_priority() returns the expected priority (2, copy)");
- ret = bt_clock_class_priority_map_get_clock_class_priority(cc_prio_map_copy, cc3, &prio);
- BT_ASSERT(ret == 0);
- ok(prio == 11,
- "bt_clock_class_priority_map_get_clock_class_priority() returns the expected priority (3, copy)");
- cc = bt_clock_class_priority_map_get_highest_priority_clock_class(cc_prio_map_copy);
- ok(cc == cc3,
- "bt_clock_class_priority_map_get_highest_priority_clock_class() returns the expected clock class (copy)");
- BT_PUT(cc);
- ret = bt_clock_class_priority_map_add_clock_class(cc_prio_map_copy, cc3, 253);
- ok(ret == 0, "bt_clock_class_priority_map_add_clock_class() succeeds for an existing clock class");
- ret = bt_clock_class_priority_map_get_clock_class_priority(cc_prio_map_copy, cc3, &prio);
- BT_ASSERT(ret == 0);
- ok(prio == 253,
- "bt_clock_class_priority_map_get_clock_class_priority() returns the expected priority (updated, copy)");
- cc = bt_clock_class_priority_map_get_highest_priority_clock_class(cc_prio_map_copy);
- ok(cc == cc2,
- "bt_clock_class_priority_map_get_highest_priority_clock_class() returns the expected clock class (updated, copy)");
- BT_PUT(cc);
-
- BT_PUT(cc3);
- BT_PUT(cc2);
- BT_PUT(cc1);
- BT_PUT(cc_prio_map);
- BT_PUT(cc_prio_map_copy);
-}
-
-int main(int argc, char **argv)
-{
- plan_tests(NR_TESTS);
- test_clock_class_priority_map();
- return exit_status();
-}
static enum test current_test;
static GArray *test_events;
static struct bt_graph *graph;
-static struct bt_clock_class_priority_map *src_cc_prio_map;
-static struct bt_clock_class_priority_map *src_empty_cc_prio_map;
static struct bt_clock_class *src_clock_class;
static struct bt_stream_class *src_stream_class;
static struct bt_event_class *src_event_class;
BT_ASSERT(ret == 0);
ret = bt_trace_add_clock_class(trace, src_clock_class);
BT_ASSERT(ret == 0);
- src_empty_cc_prio_map = bt_clock_class_priority_map_create();
- BT_ASSERT(src_empty_cc_prio_map);
- src_cc_prio_map = bt_clock_class_priority_map_create();
- BT_ASSERT(src_cc_prio_map);
- ret = bt_clock_class_priority_map_add_clock_class(src_cc_prio_map,
- src_clock_class, 0);
- BT_ASSERT(ret == 0);
src_stream_class = bt_stream_class_create("my-stream-class");
BT_ASSERT(src_stream_class);
ret = bt_stream_class_set_packet_context_field_type(src_stream_class,
g_array_free(test_events, TRUE);
/* Metadata */
- bt_put(src_empty_cc_prio_map);
- bt_put(src_cc_prio_map);
bt_put(src_clock_class);
bt_put(src_stream_class);
bt_put(src_event_class);
static
struct bt_notification *src_create_event_notif(struct bt_packet *packet,
- struct bt_clock_class_priority_map *cc_prio_map, int64_t ts_ns)
+ int64_t ts_ns)
{
int ret;
struct bt_event *event;
struct bt_notification *notif;
- struct bt_clock_value *clock_value;
struct bt_field *field;
- notif = bt_notification_event_create(graph, src_event_class,
- packet, cc_prio_map);
+ notif = bt_notification_event_create(graph, src_event_class, packet);
BT_ASSERT(notif);
event = bt_notification_event_borrow_event(notif);
BT_ASSERT(event);
BT_ASSERT(field);
ret = bt_field_integer_unsigned_set_value(field, (uint64_t) ts_ns);
BT_ASSERT(ret == 0);
- clock_value = bt_event_borrow_clock_value(event, src_clock_class);
- BT_ASSERT(clock_value);
- ret = bt_clock_value_set_value(clock_value, (uint64_t) ts_ns);
- BT_ASSERT(ret == 0);
+
+ if (ts_ns != UINT64_C(-1)) {
+ ret = bt_event_set_clock_value(event, src_clock_class, (uint64_t) ts_ns,
+ BT_TRUE);
+ BT_ASSERT(ret == 0);
+ }
+
return notif;
}
default:
{
notifs[0] = src_create_event_notif(user_data->packet,
- src_cc_prio_map, cur_ts_ns);
+ cur_ts_ns);
BT_ASSERT(notifs[0]);
break;
}
} else if (user_data->at < 7) {
notifs[0] =
src_create_event_notif(
- user_data->packet,
- src_empty_cc_prio_map, 0);
+ user_data->packet, UINT64_C(-1));
BT_ASSERT(notifs[0]);
} else if (user_data->at == 7) {
notifs[0] =
{
int ret;
struct test_event test_event;
+ struct bt_clock_value *cv;
switch (bt_notification_get_type(notification)) {
case BT_NOTIFICATION_TYPE_EVENT:
{
struct bt_event *event;
- struct bt_clock_class_priority_map *cc_prio_map;
test_event.type = TEST_EV_TYPE_NOTIF_EVENT;
- cc_prio_map =
- bt_notification_event_borrow_clock_class_priority_map(
- notification);
- BT_ASSERT(cc_prio_map);
event = bt_notification_event_borrow_event(notification);
BT_ASSERT(event);
+ cv = bt_event_borrow_default_clock_value(event);
- if (bt_clock_class_priority_map_get_clock_class_count(cc_prio_map) > 0) {
- struct bt_clock_value *clock_value;
- struct bt_clock_class *clock_class =
- bt_clock_class_priority_map_borrow_highest_priority_clock_class(
- cc_prio_map);
-
- BT_ASSERT(clock_class);
- clock_value = bt_event_borrow_clock_value(event,
- clock_class);
- BT_ASSERT(clock_value);
+ if (cv) {
ret = bt_clock_value_get_value_ns_from_epoch(
- clock_value, &test_event.ts_ns);
+ cv, &test_event.ts_ns);
BT_ASSERT(ret == 0);
} else {
test_event.ts_ns = -1;
}
case BT_NOTIFICATION_TYPE_INACTIVITY:
{
- struct bt_clock_class_priority_map *cc_prio_map;
-
test_event.type = TEST_EV_TYPE_NOTIF_INACTIVITY;
- cc_prio_map = bt_notification_inactivity_borrow_clock_class_priority_map(
+ cv = bt_notification_inactivity_borrow_default_clock_value(
notification);
- BT_ASSERT(cc_prio_map);
-
- if (bt_clock_class_priority_map_get_clock_class_count(cc_prio_map) > 0) {
- struct bt_clock_value *clock_value;
- struct bt_clock_class *clock_class =
- bt_clock_class_priority_map_borrow_highest_priority_clock_class(
- cc_prio_map);
-
- BT_ASSERT(clock_class);
- clock_value =
- bt_notification_inactivity_borrow_clock_value(
- notification, clock_class);
- BT_ASSERT(clock_value);
+
+ if (cv) {
ret = bt_clock_value_get_value_ns_from_epoch(
- clock_value, &test_event.ts_ns);
+ cv, &test_event.ts_ns);
BT_ASSERT(ret == 0);
} else {
test_event.ts_ns = -1;