babeltrace/trace-ir/stream-class.h \
babeltrace/trace-ir/stream-const.h \
babeltrace/trace-ir/stream.h \
+ babeltrace/trace-ir/trace-class-const.h \
+ babeltrace/trace-ir/trace-class.h \
babeltrace/trace-ir/trace-const.h \
babeltrace/trace-ir/trace.h
#include <babeltrace/trace-ir/stream-class.h>
#include <babeltrace/trace-ir/stream-const.h>
#include <babeltrace/trace-ir/stream.h>
+#include <babeltrace/trace-ir/trace-class-const.h>
+#include <babeltrace/trace-ir/trace-class.h>
#include <babeltrace/trace-ir/trace-const.h>
#include <babeltrace/trace-ir/trace.h>
* `a`:
* Packet. The parameter type is `struct bt_packet *`.
*
+ * `T`:
+ * Trace IR trace class. The parameter type is `struct bt_trace_class *`.
+ *
* `t`:
* Trace IR trace. The parameter type is `struct bt_trace *`.
*
struct bt_event {
struct bt_object base;
+
+ /* Owned by this */
struct bt_event_class *class;
+
+ /* Owned by this */
struct bt_packet *packet;
+
struct bt_field_wrapper *header_field;
struct bt_field *common_context_field;
struct bt_field *specific_context_field;
/*
* Only used in developer mode, this flag indicates whether or
- * not this field class is part of a trace.
+ * not this field class is part of a trace class.
*/
- bool part_of_trace;
+ bool part_of_trace_class;
};
struct bt_field_class_integer {
* shared objects for other purposes.
*/
BT_HIDDEN
-void _bt_field_class_make_part_of_trace(const struct bt_field_class *field_class);
+void _bt_field_class_make_part_of_trace_class(
+ const struct bt_field_class *field_class);
#ifdef BT_DEV_MODE
-# define bt_field_class_make_part_of_trace _bt_field_class_make_part_of_trace
+# define bt_field_class_make_part_of_trace_class _bt_field_class_make_part_of_trace_class
#else
-# define bt_field_class_make_part_of_trace(_fc) ((void) _fc)
+# define bt_field_class_make_part_of_trace_class(_fc) ((void) _fc)
#endif
#endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H */
extern "C" {
#endif
-struct bt_trace;
+struct bt_trace_class;
struct bt_packet_header_field;
struct bt_field;
extern
struct bt_packet_header_field *bt_packet_header_field_create(
- struct bt_trace *trace);
+ struct bt_trace_class *trace_class);
extern
struct bt_field *bt_packet_header_field_borrow_field(
extern "C" {
#endif
-struct bt_trace;
+struct bt_trace_class;
struct bt_stream_class;
struct bt_event_class;
struct bt_clock_class;
struct bt_event_header_field;
struct bt_packet_context_field;
-extern const struct bt_trace *bt_stream_class_borrow_trace_const(
+extern const struct bt_trace_class *bt_stream_class_borrow_trace_class_const(
const struct bt_stream_class *stream_class);
extern const char *bt_stream_class_get_name(
#endif
static inline
-struct bt_trace *bt_stream_class_borrow_trace_inline(
+struct bt_trace_class *bt_stream_class_borrow_trace_class_inline(
const struct bt_stream_class *stream_class)
{
BT_ASSERT(stream_class);
extern "C" {
#endif
+struct bt_trace_class;
struct bt_stream_class;
-struct bt_trace;
struct bt_event_class;
struct bt_clock_class;
-extern struct bt_stream_class *bt_stream_class_create(struct bt_trace *trace);
+extern struct bt_stream_class *bt_stream_class_create(
+ struct bt_trace_class *trace_class);
extern struct bt_stream_class *bt_stream_class_create_with_id(
- struct bt_trace *trace, uint64_t id);
+ struct bt_trace_class *trace_class, uint64_t id);
-extern struct bt_trace *bt_stream_class_borrow_trace(
+extern struct bt_trace_class *bt_stream_class_borrow_trace_class(
struct bt_stream_class *stream_class);
extern int bt_stream_class_set_name(struct bt_stream_class *stream_class,
extern "C" {
#endif
+struct bt_trace;
struct bt_stream;
struct bt_stream_class;
extern const struct bt_stream_class *bt_stream_borrow_class_const(
const struct bt_stream *stream);
+extern const struct bt_trace *bt_stream_borrow_trace_const(
+ const struct bt_stream *stream);
+
extern const char *bt_stream_get_name(const struct bt_stream *stream);
extern uint64_t bt_stream_get_id(const struct bt_stream *stream);
struct bt_stream {
struct bt_object base;
- /* Weak: parent is this class's trace */
+ /* Owned by this */
struct bt_stream_class *class;
struct {
# define bt_stream_freeze(_stream)
#endif
+static inline
+struct bt_trace *bt_stream_borrow_trace_inline(const struct bt_stream *stream)
+{
+ BT_ASSERT(stream);
+ return (void *) bt_object_borrow_parent(&stream->base);
+}
+
#endif /* BABELTRACE_TRACE_IR_STREAM_INTERNAL_H */
extern "C" {
#endif
+struct bt_trace;
struct bt_stream;
struct bt_stream_class;
-extern struct bt_stream *bt_stream_create(struct bt_stream_class *stream_class);
+extern struct bt_stream *bt_stream_create(struct bt_stream_class *stream_class,
+ struct bt_trace *trace);
extern struct bt_stream *bt_stream_create_with_id(
- struct bt_stream_class *stream_class, uint64_t id);
+ struct bt_stream_class *stream_class,
+ struct bt_trace *trace, uint64_t id);
+
+extern struct bt_trace *bt_stream_borrow_trace(struct bt_stream *stream);
extern struct bt_stream_class *bt_stream_borrow_class(struct bt_stream *stream);
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_TRACE_CLASS_CONST_H
+#define BABELTRACE_TRACE_IR_TRACE_CLASS_CONST_H
+
+/*
+ * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/* For bt_bool, bt_uuid */
+#include <babeltrace/types.h>
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_trace_class;
+struct bt_stream_class;
+struct bt_field_class;
+struct bt_value;
+
+extern bt_bool bt_trace_class_assigns_automatic_stream_class_id(
+ const struct bt_trace_class *trace_class);
+
+extern const char *bt_trace_class_get_name(
+ const struct bt_trace_class *trace_class);
+
+extern bt_uuid bt_trace_class_get_uuid(
+ const struct bt_trace_class *trace_class);
+
+extern uint64_t bt_trace_class_get_environment_entry_count(
+ const struct bt_trace_class *trace_class);
+
+extern void bt_trace_class_borrow_environment_entry_by_index_const(
+ const struct bt_trace_class *trace_class, uint64_t index,
+ const char **name, const struct bt_value **value);
+
+extern const struct bt_value *
+bt_trace_class_borrow_environment_entry_value_by_name_const(
+ const struct bt_trace_class *trace_class, const char *name);
+
+extern const struct bt_field_class *
+bt_trace_class_borrow_packet_header_field_class_const(
+ const struct bt_trace_class *trace_class);
+
+extern uint64_t bt_trace_class_get_stream_class_count(
+ const struct bt_trace_class *trace_class);
+
+extern const struct bt_stream_class *
+bt_trace_class_borrow_stream_class_by_index_const(
+ const struct bt_trace_class *trace_class, uint64_t index);
+
+extern const struct bt_stream_class *bt_trace_class_borrow_stream_class_by_id_const(
+ const struct bt_trace_class *trace_class, uint64_t id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_TRACE_CLASS_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_TRACE_CLASS_INTERNAL_H
+#define BABELTRACE_TRACE_IR_TRACE_CLASS_INTERNAL_H
+
+/*
+ * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <babeltrace/assert-pre-internal.h>
+#include <babeltrace/trace-ir/trace-class.h>
+#include <babeltrace/trace-ir/stream-class-internal.h>
+#include <babeltrace/trace-ir/field-classes.h>
+#include <babeltrace/trace-ir/fields.h>
+#include <babeltrace/trace-ir/attributes-internal.h>
+#include <babeltrace/trace-ir/clock-class-internal.h>
+#include <babeltrace/object-internal.h>
+#include <babeltrace/object-pool-internal.h>
+#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/values.h>
+#include <babeltrace/types.h>
+#include <glib.h>
+#include <sys/types.h>
+#include <babeltrace/compat/uuid-internal.h>
+
+struct bt_trace_class {
+ struct bt_object base;
+
+ struct {
+ GString *str;
+
+ /* NULL or `str->str` above */
+ const char *value;
+ } name;
+
+ struct {
+ uint8_t uuid[BABELTRACE_UUID_LEN];
+
+ /* NULL or `uuid` above */
+ bt_uuid value;
+ } uuid;
+
+ struct bt_value *environment;
+
+ /* Array of `struct bt_stream_class *` */
+ GPtrArray *stream_classes;
+
+ struct bt_field_class *packet_header_fc;
+ bool assigns_automatic_stream_class_id;
+
+ /* Pool of `struct bt_field_wrapper *` */
+ struct bt_object_pool packet_header_field_pool;
+
+ bool frozen;
+};
+
+BT_HIDDEN
+void _bt_trace_class_freeze(const struct bt_trace_class *trace_class);
+
+#ifdef BT_DEV_MODE
+# define bt_trace_class_freeze _bt_trace_class_freeze
+#else
+# define bt_trace_class_freeze(_tc)
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_TRACE_CLASS_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_TRACE_CLASS_H
+#define BABELTRACE_TRACE_IR_TRACE_CLASS_H
+
+/*
+ * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/* For bt_bool, bt_uuid */
+#include <babeltrace/types.h>
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_trace_class;
+struct bt_stream_class;
+struct bt_field_class;
+
+extern struct bt_trace_class *bt_trace_class_create(void);
+
+extern void bt_trace_class_set_assigns_automatic_stream_class_id(
+ struct bt_trace_class *trace_class, bt_bool value);
+
+extern int bt_trace_class_set_name(struct bt_trace_class *trace_class,
+ const char *name);
+
+extern void bt_trace_class_set_uuid(struct bt_trace_class *trace_class,
+ bt_uuid uuid);
+
+extern int bt_trace_class_set_environment_entry_integer(
+ struct bt_trace_class *trace_class,
+ const char *name, int64_t value);
+
+extern int bt_trace_class_set_environment_entry_string(
+ struct bt_trace_class *trace_class,
+ const char *name, const char *value);
+
+extern int bt_trace_class_set_packet_header_field_class(
+ struct bt_trace_class *trace_class,
+ struct bt_field_class *packet_header_field_class);
+
+extern struct bt_stream_class *bt_trace_class_borrow_stream_class_by_index(
+ struct bt_trace_class *trace_class, uint64_t index);
+
+extern struct bt_stream_class *bt_trace_class_borrow_stream_class_by_id(
+ struct bt_trace_class *trace_class, uint64_t id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_TRACE_CLASS_H */
typedef void (* bt_trace_listener_removed_func)(const struct bt_trace *trace,
void *data);
-extern bt_bool bt_trace_assigns_automatic_stream_class_id(
+extern const struct bt_trace_class *bt_trace_borrow_class_const(
const struct bt_trace *trace);
extern const char *bt_trace_get_name(const struct bt_trace *trace);
-extern bt_uuid bt_trace_get_uuid(const struct bt_trace *trace);
-
-extern uint64_t bt_trace_get_environment_entry_count(
- const struct bt_trace *trace);
-
-extern void bt_trace_borrow_environment_entry_by_index_const(
- const struct bt_trace *trace, uint64_t index,
- const char **name, const struct bt_value **value);
-
-extern const struct bt_value *
-bt_trace_borrow_environment_entry_value_by_name_const(
- const struct bt_trace *trace, const char *name);
-
-extern const struct bt_field_class *
-bt_trace_borrow_packet_header_field_class_const(
- const struct bt_trace *trace);
-
-extern uint64_t bt_trace_get_stream_class_count(const struct bt_trace *trace);
-
-extern const struct bt_stream_class *
-bt_trace_borrow_stream_class_by_index_const(const struct bt_trace *trace,
- uint64_t index);
-
-extern const struct bt_stream_class *bt_trace_borrow_stream_class_by_id_const(
- const struct bt_trace *trace, uint64_t id);
-
extern uint64_t bt_trace_get_stream_count(const struct bt_trace *trace);
extern const struct bt_stream *bt_trace_borrow_stream_by_index_const(
*/
#include <babeltrace/assert-pre-internal.h>
+#include <babeltrace/trace-ir/trace-class-internal.h>
#include <babeltrace/trace-ir/trace.h>
#include <babeltrace/trace-ir/stream-class-internal.h>
#include <babeltrace/trace-ir/field-classes.h>
struct bt_trace {
struct bt_object base;
+ /* Owned by this */
+ struct bt_trace_class *class;
+
struct {
GString *str;
const char *value;
} name;
- struct {
- uint8_t uuid[BABELTRACE_UUID_LEN];
-
- /* NULL or `uuid` above */
- bt_uuid value;
- } uuid;
-
- struct bt_value *environment;
-
- /* Array of `struct bt_stream_class *` */
- GPtrArray *stream_classes;
-
/* Array of `struct bt_stream *` */
GPtrArray *streams;
/*
- * Stream class (weak) to number of instantiated streams, used
- * to automatically assign stream IDs per stream class.
+ * Stream class (weak, owned by owned trace class) to number of
+ * instantiated streams, used to automatically assign stream IDs
+ * per stream class within this trace.
*/
GHashTable *stream_classes_stream_count;
struct bt_field_class *packet_header_fc;
- bool assigns_automatic_stream_class_id;
-
GArray *is_static_listeners;
bool is_static;
bool in_remove_listener;
-
- /* Pool of `struct bt_field_wrapper *` */
- struct bt_object_pool packet_header_field_pool;
-
bool frozen;
};
* http://www.efficios.com/ctf
*/
-/* For bt_bool, bt_uuid */
+/* For bt_bool */
#include <babeltrace/types.h>
#include <stdint.h>
#endif
struct bt_trace;
+struct bt_trace_class;
struct bt_stream;
-struct bt_stream_class;
-struct bt_field_class;
-struct bt_value;
-struct bt_packet_header_field;
-extern struct bt_trace *bt_trace_create(void);
+extern struct bt_trace_class *bt_trace_borrow_class(struct bt_trace *trace);
-extern void bt_trace_set_assigns_automatic_stream_class_id(
- struct bt_trace *trace, bt_bool value);
+extern struct bt_trace *bt_trace_create(struct bt_trace_class *trace_class);
extern int bt_trace_set_name(struct bt_trace *trace, const char *name);
-extern void bt_trace_set_uuid(struct bt_trace *trace, bt_uuid uuid);
-
-extern int bt_trace_set_environment_entry_integer(struct bt_trace *trace,
- const char *name, int64_t value);
-
-extern int bt_trace_set_environment_entry_string(struct bt_trace *trace,
- const char *name, const char *value);
-
-extern int bt_trace_set_packet_header_field_class(
- struct bt_trace *trace,
- struct bt_field_class *packet_header_field_class);
-
-extern struct bt_stream_class *bt_trace_borrow_stream_class_by_index(
- struct bt_trace *trace, uint64_t index);
-
-extern struct bt_stream_class *bt_trace_borrow_stream_class_by_id(
- struct bt_trace *trace, uint64_t id);
-
extern struct bt_stream *bt_trace_borrow_stream_by_index(struct bt_trace *trace,
uint64_t index);
stream_class = bt_event_class_borrow_stream_class(event_class);
BT_ASSERT(stream_class);
- return bt_stream_class_borrow_trace(stream_class) != NULL;
+ return bt_stream_class_borrow_trace_class(stream_class) != NULL;
}
BT_HIDDEN
#include <babeltrace/trace-ir/field-classes-internal.h>
#include <babeltrace/trace-ir/fields-internal.h>
#include <babeltrace/trace-ir/event-class-internal.h>
+#include <babeltrace/trace-ir/event-const.h>
#include <babeltrace/trace-ir/event-internal.h>
+#include <babeltrace/trace-ir/packet-const.h>
#include <babeltrace/trace-ir/packet-internal.h>
#include <babeltrace/trace-ir/stream-class-internal.h>
#include <babeltrace/trace-ir/stream-internal.h>
+#include <babeltrace/trace-ir/stream-const.h>
#include <babeltrace/trace-ir/trace-internal.h>
+#include <babeltrace/trace-ir/trace-class-internal.h>
#include <babeltrace/trace-ir/clock-class-internal.h>
#include <babeltrace/trace-ir/clock-value-internal.h>
#include <babeltrace/trace-ir/field-path-internal.h>
} while (0)
static inline void format_component(char **buf_ch, bool extended,
- const char *prefix, struct bt_component *component);
+ const char *prefix, const struct bt_component *component);
static inline void format_port(char **buf_ch, bool extended,
- const char *prefix, struct bt_port *port);
+ const char *prefix, const struct bt_port *port);
static inline void format_connection(char **buf_ch, bool extended,
- const char *prefix, struct bt_connection *connection);
+ const char *prefix, const struct bt_connection *connection);
static inline void format_clock_value(char **buf_ch, bool extended,
- const char *prefix, struct bt_clock_value *clock_value);
+ const char *prefix, const struct bt_clock_value *clock_value);
static inline void format_field_path(char **buf_ch, bool extended,
- const char *prefix, struct bt_field_path *field_path);
+ const char *prefix, const struct bt_field_path *field_path);
static inline void format_object(char **buf_ch, bool extended,
- const char *prefix, struct bt_object *obj)
+ const char *prefix, const struct bt_object *obj)
{
BUF_APPEND(", %sref-count=%llu", prefix, obj->ref_count);
}
}
static inline void format_object_pool(char **buf_ch, bool extended,
- const char *prefix, struct bt_object_pool *pool)
+ const char *prefix, const struct bt_object_pool *pool)
{
BUF_APPEND(", %ssize=%zu", PRFIELD(pool->size));
static inline void format_integer_field_class(char **buf_ch,
bool extended, const char *prefix,
- struct bt_field_class *field_class)
+ const struct bt_field_class *field_class)
{
- struct bt_field_class_integer *int_fc = (void *) field_class;
+ const struct bt_field_class_integer *int_fc =
+ (const void *) field_class;
BUF_APPEND(", %srange-size=%" PRIu64 ", %sbase=%s",
PRFIELD(int_fc->range),
static inline void format_array_field_class(char **buf_ch,
bool extended, const char *prefix,
- struct bt_field_class *field_class)
+ const struct bt_field_class *field_class)
{
- struct bt_field_class_array *array_fc = (void *) field_class;
+ const struct bt_field_class_array *array_fc =
+ (const void *) field_class;
BUF_APPEND(", %selement-fc-addr=%p, %selement-fc-type=%s",
PRFIELD(array_fc->element_fc),
}
static inline void format_field_class(char **buf_ch, bool extended,
- const char *prefix, struct bt_field_class *field_class)
+ const char *prefix, const struct bt_field_class *field_class)
{
char tmp_prefix[64];
if (extended) {
BUF_APPEND(", %sis-frozen=%d", PRFIELD(field_class->frozen));
- BUF_APPEND(", %sis-part-of-trace=%d",
- PRFIELD(field_class->part_of_trace));
+ BUF_APPEND(", %sis-part-of-trace-class=%d",
+ PRFIELD(field_class->part_of_trace_class));
} else {
return;
}
}
case BT_FIELD_CLASS_TYPE_REAL:
{
- struct bt_field_class_real *real_fc = (void *) field_class;
+ const struct bt_field_class_real *real_fc = (void *) field_class;
BUF_APPEND(", %sis-single-precision=%d",
PRFIELD(real_fc->is_single_precision));
case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION:
case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION:
{
- struct bt_field_class_enumeration *enum_fc =
- (void *) field_class;
+ const struct bt_field_class_enumeration *enum_fc =
+ (const void *) field_class;
format_integer_field_class(buf_ch, extended, prefix, field_class);
BUF_APPEND(", %smapping-count=%u",
}
case BT_FIELD_CLASS_TYPE_STRUCTURE:
{
- struct bt_field_class_structure *struct_fc =
- (void *) field_class;
+ const struct bt_field_class_structure *struct_fc =
+ (const void *) field_class;
if (struct_fc->common.named_fcs) {
BUF_APPEND(", %smember-count=%u",
}
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
{
- struct bt_field_class_static_array *array_fc =
- (void *) field_class;
+ const struct bt_field_class_static_array *array_fc =
+ (const void *) field_class;
format_array_field_class(buf_ch, extended, prefix, field_class);
BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_fc->length));
}
case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
{
- struct bt_field_class_dynamic_array *array_fc =
- (void *) field_class;
+ const struct bt_field_class_dynamic_array *array_fc =
+ (const void *) field_class;
format_array_field_class(buf_ch, extended, prefix, field_class);
}
case BT_FIELD_CLASS_TYPE_VARIANT:
{
- struct bt_field_class_variant *var_fc = (void *) field_class;
+ const struct bt_field_class_variant *var_fc =
+ (const void *) field_class;
if (var_fc->common.named_fcs) {
BUF_APPEND(", %soption-count=%u",
}
static inline void format_field_integer_extended(char **buf_ch,
- const char *prefix, struct bt_field *field)
+ const char *prefix, const struct bt_field *field)
{
- struct bt_field_integer *integer = (void *) field;
- struct bt_field_class_integer *field_class = (void *) field->class;
+ const struct bt_field_integer *integer = (void *) field;
+ const struct bt_field_class_integer *field_class =
+ (void *) field->class;
const char *fmt = NULL;
BT_ASSERT(field_class);
}
static inline void format_field(char **buf_ch, bool extended,
- const char *prefix, struct bt_field *field)
+ const char *prefix, const struct bt_field *field)
{
BUF_APPEND(", %sis-set=%d", PRFIELD(field->is_set));
}
case BT_FIELD_CLASS_TYPE_REAL:
{
- struct bt_field_real *real_field = (void *) field;
+ const struct bt_field_real *real_field = (const void *) field;
BUF_APPEND(", %svalue=%f", PRFIELD(real_field->value));
break;
}
case BT_FIELD_CLASS_TYPE_STRING:
{
- struct bt_field_string *str = (void *) field;
+ const struct bt_field_string *str = (const void *) field;
if (str->buf) {
BT_ASSERT(str->buf->data);
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
{
- struct bt_field_array *array_field = (void *) field;
+ const struct bt_field_array *array_field = (const void *) field;
BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_field->length));
}
case BT_FIELD_CLASS_TYPE_VARIANT:
{
- struct bt_field_variant *var_field = (void *) field;
+ const struct bt_field_variant *var_field = (const void *) field;
BUF_APPEND(", %sselected-field-index=%" PRIu64,
PRFIELD(var_field->selected_index));
}
static inline void format_field_path(char **buf_ch, bool extended,
- const char *prefix, struct bt_field_path *field_path)
+ const char *prefix, const struct bt_field_path *field_path)
{
uint64_t i;
BUF_APPEND("%s", "]");
}
-static inline void format_trace(char **buf_ch, bool extended,
- const char *prefix, struct bt_trace *trace)
+static inline void format_trace_class(char **buf_ch, bool extended,
+ const char *prefix, const struct bt_trace_class *trace_class)
{
char tmp_prefix[64];
- if (trace->name.value) {
- BUF_APPEND(", %sname=\"%s\"", PRFIELD(trace->name.value));
+ if (trace_class->name.value) {
+ BUF_APPEND(", %sname=\"%s\"",
+ PRFIELD(trace_class->name.value));
}
if (!extended) {
return;
}
- BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace->frozen));
+ BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace_class->frozen));
- if (trace->uuid.value) {
- BUF_APPEND_UUID(trace->uuid.value);
+ if (trace_class->uuid.value) {
+ BUF_APPEND_UUID(trace_class->uuid.value);
}
- if (trace->stream_classes) {
+ if (trace_class->stream_classes) {
BUF_APPEND(", %sstream-class-count=%u",
- PRFIELD(trace->stream_classes->len));
+ PRFIELD(trace_class->stream_classes->len));
}
+ BUF_APPEND(", %spacket-header-fc-addr=%p, "
+ "%sassigns-auto-sc-id=%d",
+ PRFIELD(trace_class->packet_header_fc),
+ PRFIELD(trace_class->assigns_automatic_stream_class_id));
+ SET_TMP_PREFIX("phf-pool-");
+ format_object_pool(buf_ch, extended, prefix,
+ &trace_class->packet_header_field_pool);
+}
+
+static inline void format_trace(char **buf_ch, bool extended,
+ const char *prefix, const struct bt_trace *trace)
+{
+ char tmp_prefix[64];
+
+ if (trace->name.value) {
+ BUF_APPEND(", %sname=\"%s\"", PRFIELD(trace->name.value));
+ }
+
+ if (!extended) {
+ return;
+ }
+
+ BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace->frozen));
+
if (trace->streams) {
BUF_APPEND(", %sstream-count=%u",
PRFIELD(trace->streams->len));
}
- BUF_APPEND(", %spacket-header-fc-addr=%p, %sis-static=%d, "
- "%sassigns-auto-sc-id=%d",
- PRFIELD(trace->packet_header_fc),
- PRFIELD(trace->is_static),
- PRFIELD(trace->assigns_automatic_stream_class_id));
- SET_TMP_PREFIX("phf-pool-");
- format_object_pool(buf_ch, extended, prefix,
- &trace->packet_header_field_pool);
+ BUF_APPEND(", %sis-static=%d", PRFIELD(trace->is_static));
+
+ if (!trace->class) {
+ return;
+ }
+
+ BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace->class));
+ SET_TMP_PREFIX("trace-class-");
+ format_trace_class(buf_ch, false, tmp_prefix, trace->class);
}
static inline void format_stream_class(char **buf_ch, bool extended,
- const char *prefix, struct bt_stream_class *stream_class)
+ const char *prefix,
+ const struct bt_stream_class *stream_class)
{
- struct bt_trace *trace;
+ const struct bt_trace_class *trace_class;
char tmp_prefix[64];
BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream_class->id));
PRFIELD(stream_class->packet_context_fc),
PRFIELD(stream_class->event_header_fc),
PRFIELD(stream_class->event_common_context_fc));
- trace = bt_stream_class_borrow_trace_inline(stream_class);
- if (!trace) {
+ trace_class = bt_stream_class_borrow_trace_class_inline(stream_class);
+ if (!trace_class) {
return;
}
PRFIELD(stream_class->packets_have_packet_counter_snapshot),
PRFIELD(stream_class->packets_have_default_beginning_cv),
PRFIELD(stream_class->packets_have_default_end_cv));
- BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
- SET_TMP_PREFIX("trace-");
- format_trace(buf_ch, false, tmp_prefix, trace);
+ BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class));
+ SET_TMP_PREFIX("trace-class-");
+ format_trace_class(buf_ch, false, tmp_prefix, trace_class);
SET_TMP_PREFIX("ehf-pool-");
format_object_pool(buf_ch, extended, prefix,
&stream_class->event_header_field_pool);
}
static inline void format_event_class(char **buf_ch, bool extended,
- const char *prefix, struct bt_event_class *event_class)
+ const char *prefix, const struct bt_event_class *event_class)
{
- struct bt_stream_class *stream_class;
- struct bt_trace *trace;
+ const struct bt_stream_class *stream_class;
+ const struct bt_trace_class *trace_class;
char tmp_prefix[64];
BUF_APPEND(", %sid=%" PRIu64, PRFIELD(event_class->id));
PRFIELD(event_class->specific_context_fc),
PRFIELD(event_class->payload_fc));
- stream_class = bt_event_class_borrow_stream_class(event_class);
+ stream_class = bt_event_class_borrow_stream_class_const(event_class);
if (!stream_class) {
return;
}
BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class));
SET_TMP_PREFIX("stream-class-");
format_stream_class(buf_ch, false, tmp_prefix, stream_class);
- trace = bt_stream_class_borrow_trace_inline(stream_class);
- if (!trace) {
+ trace_class = bt_stream_class_borrow_trace_class_inline(stream_class);
+ if (!trace_class) {
return;
}
- BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
- SET_TMP_PREFIX("trace-");
- format_trace(buf_ch, false, tmp_prefix, trace);
+ BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class));
+ SET_TMP_PREFIX("trace-class-");
+ format_trace_class(buf_ch, false, tmp_prefix, trace_class);
SET_TMP_PREFIX("event-pool-");
format_object_pool(buf_ch, extended, prefix, &event_class->event_pool);
}
static inline void format_stream(char **buf_ch, bool extended,
- const char *prefix, struct bt_stream *stream)
+ const char *prefix, const struct bt_stream *stream)
{
- struct bt_stream_class *stream_class;
- struct bt_trace *trace;
+ const struct bt_stream_class *stream_class;
+ const struct bt_trace_class *trace_class = NULL;
+ const struct bt_trace *trace = NULL;
char tmp_prefix[64];
BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream->id));
return;
}
- stream_class = bt_stream_borrow_class(stream);
- if (!stream_class) {
- return;
+ stream_class = bt_stream_borrow_class_const(stream);
+ if (stream_class) {
+ BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class));
+ SET_TMP_PREFIX("stream-class-");
+ format_stream_class(buf_ch, false, tmp_prefix, stream_class);
+ trace_class = bt_stream_class_borrow_trace_class_inline(stream_class);
}
- BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class));
- SET_TMP_PREFIX("stream-class-");
- format_stream_class(buf_ch, false, tmp_prefix, stream_class);
- trace = bt_stream_class_borrow_trace_inline(stream_class);
- if (!trace) {
- return;
+ if (trace_class) {
+ BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class));
+ SET_TMP_PREFIX("trace-class-");
+ format_trace_class(buf_ch, false, tmp_prefix, trace_class);
+ }
+
+ trace = bt_stream_borrow_trace_inline(stream);
+ if (trace) {
+ BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
+ SET_TMP_PREFIX("trace-");
+ format_trace(buf_ch, false, tmp_prefix, trace);
}
- BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
- SET_TMP_PREFIX("trace-");
- format_trace(buf_ch, false, tmp_prefix, trace);
SET_TMP_PREFIX("packet-pool-");
format_object_pool(buf_ch, extended, prefix, &stream->packet_pool);
}
static inline void format_packet(char **buf_ch, bool extended,
- const char *prefix, struct bt_packet *packet)
+ const char *prefix, const struct bt_packet *packet)
{
- struct bt_stream *stream;
- struct bt_trace *trace;
+ const struct bt_stream *stream;
+ const struct bt_trace_class *trace_class;
char tmp_prefix[64];
if (!extended) {
PRFIELD(packet->frozen),
PRFIELD(packet->header_field ? packet->header_field->field : NULL),
PRFIELD(packet->context_field ? packet->context_field->field : NULL));
- stream = bt_packet_borrow_stream(packet);
+ stream = bt_packet_borrow_stream_const(packet);
if (!stream) {
return;
}
BUF_APPEND(", %sstream-addr=%p", PRFIELD(stream));
SET_TMP_PREFIX("stream-");
format_stream(buf_ch, false, tmp_prefix, stream);
- trace = (struct bt_trace *) bt_object_borrow_parent(&stream->base);
- if (!trace) {
+ trace_class = (const struct bt_trace_class *) bt_object_borrow_parent(&stream->base);
+ if (!trace_class) {
return;
}
- BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
- SET_TMP_PREFIX("trace-");
- format_trace(buf_ch, false, tmp_prefix, trace);
+ BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class));
+ SET_TMP_PREFIX("trace-class-");
+ format_trace_class(buf_ch, false, tmp_prefix, trace_class);
}
static inline void format_event(char **buf_ch, bool extended,
- const char *prefix, struct bt_event *event)
+ const char *prefix, const struct bt_event *event)
{
- struct bt_packet *packet;
- struct bt_stream *stream;
- struct bt_trace *trace;
- struct bt_stream_class *stream_class;
+ const struct bt_packet *packet;
+ const struct bt_stream *stream;
+ const struct bt_trace_class *trace_class;
+ const struct bt_stream_class *stream_class;
char tmp_prefix[64];
if (!extended) {
format_stream_class(buf_ch, false, tmp_prefix,
stream_class);
- trace = bt_stream_class_borrow_trace_inline(stream_class);
- if (trace) {
- BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
- SET_TMP_PREFIX("trace-");
- format_trace(buf_ch, false, tmp_prefix, trace);
+ trace_class = bt_stream_class_borrow_trace_class_inline(
+ stream_class);
+ if (trace_class) {
+ BUF_APPEND(", %strace-class-addr=%p",
+ PRFIELD(trace_class));
+ SET_TMP_PREFIX("trace-class-");
+ format_trace_class(buf_ch, false, tmp_prefix,
+ trace_class);
}
}
event->default_cv);
}
- packet = bt_event_borrow_packet(event);
+ packet = bt_event_borrow_packet_const(event);
if (!packet) {
return;
}
BUF_APPEND(", %spacket-addr=%p", PRFIELD(packet));
SET_TMP_PREFIX("packet-");
format_packet(buf_ch, false, tmp_prefix, packet);
- stream = bt_packet_borrow_stream(packet);
+ stream = bt_packet_borrow_stream_const(packet);
if (!stream) {
return;
}
}
static inline void format_clock_class(char **buf_ch, bool extended,
- const char *prefix, struct bt_clock_class *clock_class)
+ const char *prefix, const struct bt_clock_class *clock_class)
{
char tmp_prefix[64];
}
static inline void format_clock_value(char **buf_ch, bool extended,
- const char *prefix, struct bt_clock_value *clock_value)
+ const char *prefix, const struct bt_clock_value *clock_value)
{
char tmp_prefix[64];
BUF_APPEND(", %svalue=%" PRIu64 ", %sns-from-origin=%" PRId64,
}
static inline void format_value(char **buf_ch, bool extended,
- const char *prefix, struct bt_value *value)
+ const char *prefix, const struct bt_value *value)
{
BUF_APPEND(", %stype=%s",
PRFIELD(bt_common_value_type_string(bt_value_get_type(value))));
}
static inline void format_notification(char **buf_ch, bool extended,
- const char *prefix, struct bt_notification *notif)
+ const char *prefix, const struct bt_notification *notif)
{
char tmp_prefix[64];
switch (notif->type) {
case BT_NOTIFICATION_TYPE_EVENT:
{
- struct bt_notification_event *notif_event = (void *) notif;
+ const struct bt_notification_event *notif_event =
+ (const void *) notif;
if (notif_event->event) {
SET_TMP_PREFIX("event-");
}
case BT_NOTIFICATION_TYPE_STREAM_BEGIN:
{
- struct bt_notification_stream_begin *notif_stream =
- (void *) notif;
+ const struct bt_notification_stream_begin *notif_stream =
+ (const void *) notif;
if (notif_stream->stream) {
SET_TMP_PREFIX("stream-");
}
case BT_NOTIFICATION_TYPE_STREAM_END:
{
- struct bt_notification_stream_end *notif_stream =
- (void *) notif;
+ const struct bt_notification_stream_end *notif_stream =
+ (const void *) notif;
if (notif_stream->stream) {
SET_TMP_PREFIX("stream-");
}
case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
{
- struct bt_notification_packet_begin *notif_packet =
- (void *) notif;
+ const struct bt_notification_packet_begin *notif_packet =
+ (const void *) notif;
if (notif_packet->packet) {
SET_TMP_PREFIX("packet-");
}
case BT_NOTIFICATION_TYPE_PACKET_END:
{
- struct bt_notification_packet_end *notif_packet =
- (void *) notif;
+ const struct bt_notification_packet_end *notif_packet =
+ (const void *) notif;
if (notif_packet->packet) {
SET_TMP_PREFIX("packet-");
static inline void format_plugin_so_shared_lib_handle(char **buf_ch,
const char *prefix,
- struct bt_plugin_so_shared_lib_handle *handle)
+ const struct bt_plugin_so_shared_lib_handle *handle)
{
BUF_APPEND(", %saddr=%p", PRFIELD(handle));
}
static inline void format_component_class(char **buf_ch, bool extended,
- const char *prefix, struct bt_component_class *comp_class)
+ const char *prefix,
+ const struct bt_component_class *comp_class)
{
char tmp_prefix[64];
}
static inline void format_component(char **buf_ch, bool extended,
- const char *prefix, struct bt_component *component)
+ const char *prefix, const struct bt_component *component)
{
char tmp_prefix[64];
}
static inline void format_port(char **buf_ch, bool extended,
- const char *prefix, struct bt_port *port)
+ const char *prefix, const struct bt_port *port)
{
char tmp_prefix[64];
}
static inline void format_connection(char **buf_ch, bool extended,
- const char *prefix, struct bt_connection *connection)
+ const char *prefix, const struct bt_connection *connection)
{
char tmp_prefix[64];
}
static inline void format_graph(char **buf_ch, bool extended,
- const char *prefix, struct bt_graph *graph)
+ const char *prefix, const struct bt_graph *graph)
{
char tmp_prefix[64];
static inline void format_notification_iterator(char **buf_ch,
bool extended, const char *prefix,
- struct bt_notification_iterator *iterator)
+ const struct bt_notification_iterator *iterator)
{
const char *type;
char tmp_prefix[64];
switch (iterator->type) {
case BT_NOTIFICATION_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT:
{
- struct bt_self_component_port_input_notification_iterator *
- port_in_iter = (void *) iterator;
+ const struct bt_self_component_port_input_notification_iterator *
+ port_in_iter = (const void *) iterator;
if (port_in_iter->upstream_component) {
SET_TMP_PREFIX("upstream-comp-");
}
case BT_NOTIFICATION_ITERATOR_TYPE_PORT_OUTPUT:
{
- struct bt_port_output_notification_iterator *port_out_iter =
- (void *) iterator;
+ const struct bt_port_output_notification_iterator *port_out_iter =
+ (const void *) iterator;
if (port_out_iter->graph) {
SET_TMP_PREFIX("graph-");
PRFIELD(plugin->sink_comp_classes->len));
if (plugin->spec_data) {
- struct bt_plugin_so_spec_data *spec_data =
- (void *) plugin->spec_data;
+ const struct bt_plugin_so_spec_data *spec_data =
+ (const void *) plugin->spec_data;
if (spec_data->shared_lib_handle) {
SET_TMP_PREFIX("so-handle-");
bool extended = false;
char prefix[64];
char *prefix_ch = prefix;
- void *obj;
+ const void *obj;
/* skip "%!" */
fmt_ch += 2;
case 't':
format_trace(buf_ch, extended, prefix, obj);
break;
+ case 'T':
+ format_trace_class(buf_ch, extended, prefix, obj);
+ break;
case 'K':
format_clock_class(buf_ch, extended, prefix, obj);
break;
stream.c \
stream-class.c \
trace.c \
+ trace-class.c \
utils.c
libtrace_ir_la_LIBADD = $(UUID_LIBS)
{
int ret;
struct bt_stream_class *stream_class;
- struct bt_trace *trace;
+ struct bt_trace_class *trace_class;
struct bt_resolve_field_path_context resolve_ctx = {
.packet_header = NULL,
.packet_context = NULL,
"%!+F", field_class);
stream_class = bt_event_class_borrow_stream_class_inline(
event_class);
- trace = bt_stream_class_borrow_trace_inline(stream_class);
- resolve_ctx.packet_header = trace->packet_header_fc;
+ trace_class = bt_stream_class_borrow_trace_class_inline(stream_class);
+ resolve_ctx.packet_header = trace_class->packet_header_fc;
resolve_ctx.packet_context = stream_class->packet_context_fc;
resolve_ctx.event_header = stream_class->event_header_fc;
resolve_ctx.event_common_context =
goto end;
}
- bt_field_class_make_part_of_trace(field_class);
+ bt_field_class_make_part_of_trace_class(field_class);
bt_object_put_ref(event_class->specific_context_fc);
event_class->specific_context_fc = field_class;
bt_object_get_no_null_check(event_class->specific_context_fc);
{
int ret;
struct bt_stream_class *stream_class;
- struct bt_trace *trace;
+ struct bt_trace_class *trace_class;
struct bt_resolve_field_path_context resolve_ctx = {
.packet_header = NULL,
.packet_context = NULL,
field_class);
stream_class = bt_event_class_borrow_stream_class_inline(
event_class);
- trace = bt_stream_class_borrow_trace_inline(stream_class);
- resolve_ctx.packet_header = trace->packet_header_fc;
+ trace_class = bt_stream_class_borrow_trace_class_inline(stream_class);
+ resolve_ctx.packet_header = trace_class->packet_header_fc;
resolve_ctx.packet_context = stream_class->packet_context_fc;
resolve_ctx.event_header = stream_class->event_header_fc;
resolve_ctx.event_common_context =
goto end;
}
- bt_field_class_make_part_of_trace(field_class);
+ bt_field_class_make_part_of_trace_class(field_class);
bt_object_put_ref(event_class->payload_fc);
event_class->payload_fc = field_class;
bt_object_get_no_null_check(event_class->payload_fc);
struct bt_field_wrapper *field_wrapper;
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- BT_ASSERT_PRE(bt_stream_class_borrow_trace_inline(stream_class),
+ BT_ASSERT_PRE(bt_stream_class_borrow_trace_class_inline(stream_class),
"Stream class is not part of a trace: %!+S", stream_class);
BT_ASSERT_PRE(stream_class->event_header_fc,
"Stream class has no event header field classe: %!+S",
}
BT_HIDDEN
-void _bt_field_class_make_part_of_trace(const struct bt_field_class *c_fc)
+void _bt_field_class_make_part_of_trace_class(const struct bt_field_class *c_fc)
{
struct bt_field_class *fc = (void *) c_fc;
BT_ASSERT(fc);
- BT_ASSERT_PRE(!fc->part_of_trace,
+ BT_ASSERT_PRE(!fc->part_of_trace_class,
"Field class is already part of a trace: %!+F", fc);
- fc->part_of_trace = true;
+ fc->part_of_trace_class = true;
switch (fc->type) {
case BT_FIELD_CLASS_TYPE_STRUCTURE:
BT_FIELD_CLASS_NAMED_FC_AT_INDEX(
container_fc, i);
- bt_field_class_make_part_of_trace(named_fc->fc);
+ bt_field_class_make_part_of_trace_class(named_fc->fc);
}
break;
{
struct bt_field_class_array *array_fc = (void *) fc;
- bt_field_class_make_part_of_trace(array_fc->element_fc);
+ bt_field_class_make_part_of_trace_class(array_fc->element_fc);
break;
}
default:
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
BT_ASSERT_PRE(stream_class->frozen,
- "Stream class is not part of a trace: %!+S", stream_class);
+ "Stream class is not part of a trace class: %!+S",
+ stream_class);
BT_ASSERT_PRE(stream_class->packet_context_fc,
"Stream class has no packet context field classe: %!+S",
stream_class);
}
struct bt_packet_header_field *bt_packet_header_field_create(
- struct bt_trace *trace)
+ struct bt_trace_class *tc)
{
struct bt_field_wrapper *field_wrapper;
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE(trace->packet_header_fc,
- "Trace has no packet header field classe: %!+t", trace);
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ BT_ASSERT_PRE(tc->packet_header_fc,
+ "Trace class has no packet header field class: %!+T", tc);
field_wrapper = bt_field_wrapper_create(
- &trace->packet_header_field_pool,
- (void *) trace->packet_header_fc);
+ &tc->packet_header_field_pool,
+ (void *) tc->packet_header_fc);
if (!field_wrapper) {
- BT_LIB_LOGE("Cannot allocate one packet header field from trace: "
- "%![trace-]+t", trace);
+ BT_LIB_LOGE("Cannot allocate one packet header field from trace class: "
+ "%![tc-]+T", tc);
goto error;
}
BT_ASSERT(field_wrapper->field);
- bt_trace_freeze(trace);
+ bt_trace_class_freeze(tc);
goto end;
error:
static
void recycle_header_field(struct bt_field_wrapper *header_field,
- struct bt_trace *trace)
+ struct bt_trace_class *tc)
{
BT_ASSERT(header_field);
BT_LIB_LOGD("Recycling packet header field: "
- "addr=%p, %![trace-]+t, %![field-]+f", header_field,
- trace, header_field->field);
- bt_object_pool_recycle_object(&trace->packet_header_field_pool,
+ "addr=%p, %![tc-]+T, %![field-]+f", header_field,
+ tc, header_field->field);
+ bt_object_pool_recycle_object(&tc->packet_header_field_pool,
header_field);
}
if (packet->stream) {
BT_LOGD_STR("Recycling packet's header field.");
recycle_header_field(packet->header_field,
- bt_stream_class_borrow_trace_inline(
+ bt_stream_class_borrow_trace_class_inline(
packet->stream->class));
} else {
bt_field_wrapper_destroy(packet->header_field);
struct bt_packet *bt_packet_new(struct bt_stream *stream)
{
struct bt_packet *packet = NULL;
- struct bt_trace *trace = NULL;
+ struct bt_trace_class *trace_class = NULL;
BT_ASSERT(stream);
BT_LIB_LOGD("Creating packet object: %![stream-]+s", stream);
(bt_object_release_func) bt_packet_recycle);
packet->stream = stream;
bt_object_get_no_null_check(stream);
- trace = bt_stream_class_borrow_trace_inline(stream->class);
- BT_ASSERT(trace);
+ trace_class = bt_stream_class_borrow_trace_class_inline(stream->class);
+ BT_ASSERT(trace_class);
- if (trace->packet_header_fc) {
+ if (trace_class->packet_header_fc) {
BT_LOGD_STR("Creating initial packet header field.");
packet->header_field = bt_field_wrapper_create(
- &trace->packet_header_field_pool,
- trace->packet_header_fc);
+ &trace_class->packet_header_field_pool,
+ trace_class->packet_header_fc);
if (!packet->header_field) {
BT_LOGE_STR("Cannot create packet header field wrapper.");
goto error;
int bt_packet_move_header_field(struct bt_packet *packet,
struct bt_packet_header_field *header_field)
{
- struct bt_trace *trace;
+ struct bt_trace_class *tc;
struct bt_field_wrapper *field_wrapper = (void *) header_field;
BT_ASSERT_PRE_NON_NULL(packet, "Packet");
BT_ASSERT_PRE_NON_NULL(field_wrapper, "Header field");
BT_ASSERT_PRE_PACKET_HOT(packet);
- trace = bt_stream_class_borrow_trace_inline(packet->stream->class);
- BT_ASSERT_PRE(trace->packet_header_fc,
- "Trace has no packet header field classe: %!+t",
- trace);
+ tc = bt_stream_class_borrow_trace_class_inline(packet->stream->class);
+ BT_ASSERT_PRE(tc->packet_header_fc,
+ "Trace class has no packet header field classe: %!+T", tc);
BT_ASSERT_PRE(field_wrapper->field->class ==
- trace->packet_header_fc,
+ tc->packet_header_fc,
"Unexpected packet header field's class: "
"%![fc-]+F, %![expected-fc-]+F", field_wrapper->field->class,
- trace->packet_header_fc);
+ tc->packet_header_fc);
/* Recycle current header field: always exists */
BT_ASSERT(packet->header_field);
- recycle_header_field(packet->header_field, trace);
+ recycle_header_field(packet->header_field, tc);
/* Move new field */
packet->header_field = field_wrapper;
BT_ASSERT_PRE_FUNC
static
-bool stream_class_id_is_unique(const struct bt_trace *trace, uint64_t id)
+bool stream_class_id_is_unique(const struct bt_trace_class *tc, uint64_t id)
{
uint64_t i;
bool is_unique = true;
- for (i = 0; i < trace->stream_classes->len; i++) {
+ for (i = 0; i < tc->stream_classes->len; i++) {
const struct bt_stream_class *sc =
- trace->stream_classes->pdata[i];
+ tc->stream_classes->pdata[i];
if (sc->id == id) {
is_unique = false;
}
static
-struct bt_stream_class *create_stream_class_with_id(struct bt_trace *trace,
- uint64_t id)
+struct bt_stream_class *create_stream_class_with_id(
+ struct bt_trace_class *tc, uint64_t id)
{
struct bt_stream_class *stream_class = NULL;
int ret;
- BT_ASSERT(trace);
- BT_ASSERT_PRE(stream_class_id_is_unique(trace, id),
- "Duplicate stream class ID: %![trace-]+t, id=%" PRIu64,
- trace, id);
- BT_LIB_LOGD("Creating stream class object: %![trace-]+t, id=%" PRIu64,
- trace, id);
+ BT_ASSERT(tc);
+ BT_ASSERT_PRE(stream_class_id_is_unique(tc, id),
+ "Duplicate stream class ID: %![tc-]+T, id=%" PRIu64, tc, id);
+ BT_LIB_LOGD("Creating stream class object: %![tc-]+T, id=%" PRIu64,
+ tc, id);
stream_class = g_new0(struct bt_stream_class, 1);
if (!stream_class) {
BT_LOGE_STR("Failed to allocate one stream class.");
goto error;
}
- bt_object_set_parent(&stream_class->base, &trace->base);
- g_ptr_array_add(trace->stream_classes, stream_class);
- bt_trace_freeze(trace);
+ bt_object_set_parent(&stream_class->base, &tc->base);
+ g_ptr_array_add(tc->stream_classes, stream_class);
+ bt_trace_class_freeze(tc);
BT_LIB_LOGD("Created stream class object: %!+S", stream_class);
goto end;
return stream_class;
}
-struct bt_stream_class *bt_stream_class_create(struct bt_trace *trace)
+struct bt_stream_class *bt_stream_class_create(struct bt_trace_class *tc)
{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE(trace->assigns_automatic_stream_class_id,
- "Trace does not automatically assigns stream class IDs: "
- "%![sc-]+t", trace);
- return create_stream_class_with_id(trace,
- (uint64_t) trace->stream_classes->len);
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ BT_ASSERT_PRE(tc->assigns_automatic_stream_class_id,
+ "Trace class does not automatically assigns stream class IDs: "
+ "%![sc-]+T", tc);
+ return create_stream_class_with_id(tc,
+ (uint64_t) tc->stream_classes->len);
}
struct bt_stream_class *bt_stream_class_create_with_id(
- struct bt_trace *trace, uint64_t id)
+ struct bt_trace_class *tc, uint64_t id)
{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE(!trace->assigns_automatic_stream_class_id,
- "Trace automatically assigns stream class IDs: "
- "%![sc-]+t", trace);
- return create_stream_class_with_id(trace, id);
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ BT_ASSERT_PRE(!tc->assigns_automatic_stream_class_id,
+ "Trace class automatically assigns stream class IDs: "
+ "%![sc-]+T", tc);
+ return create_stream_class_with_id(tc, id);
}
-struct bt_trace *bt_stream_class_borrow_trace(
+struct bt_trace_class *bt_stream_class_borrow_trace_class(
struct bt_stream_class *stream_class)
{
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- return bt_stream_class_borrow_trace_inline(stream_class);
+ return bt_stream_class_borrow_trace_class_inline(stream_class);
}
-const struct bt_trace *bt_stream_class_borrow_trace_const(
+const struct bt_trace_class *bt_stream_class_borrow_trace_class_const(
const struct bt_stream_class *stream_class)
{
- return bt_stream_class_borrow_trace((void *) stream_class);
+ return bt_stream_class_borrow_trace_class((void *) stream_class);
}
const char *bt_stream_class_get_name(const struct bt_stream_class *stream_class)
struct bt_event_class *event_class = NULL;
uint64_t i;
- BT_ASSERT_PRE_NON_NULL(stream_class, "Trace");
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
for (i = 0; i < stream_class->event_classes->len; i++) {
struct bt_event_class *event_class_candidate =
"Packet context field classe is not a structure field classe: %!+F",
field_class);
resolve_ctx.packet_header =
- bt_stream_class_borrow_trace_inline(stream_class)->packet_header_fc;
+ bt_stream_class_borrow_trace_class_inline(stream_class)->packet_header_fc;
ret = bt_resolve_field_paths(field_class, &resolve_ctx);
if (ret) {
goto end;
}
- bt_field_class_make_part_of_trace(field_class);
+ bt_field_class_make_part_of_trace_class(field_class);
bt_object_put_ref(stream_class->packet_context_fc);
stream_class->packet_context_fc = field_class;
bt_object_get_no_null_check(stream_class->packet_context_fc);
"Event header field classe is not a structure field classe: %!+F",
field_class);
resolve_ctx.packet_header =
- bt_stream_class_borrow_trace_inline(stream_class)->packet_header_fc;
+ bt_stream_class_borrow_trace_class_inline(stream_class)->packet_header_fc;
resolve_ctx.packet_context = stream_class->packet_context_fc;
ret = bt_resolve_field_paths(field_class, &resolve_ctx);
if (ret) {
goto end;
}
- bt_field_class_make_part_of_trace(field_class);
+ bt_field_class_make_part_of_trace_class(field_class);
bt_object_put_ref(stream_class->event_header_fc);
stream_class->event_header_fc = field_class;
bt_object_get_no_null_check(stream_class->event_header_fc);
"Event common context field classe is not a structure field classe: %!+F",
field_class);
resolve_ctx.packet_header =
- bt_stream_class_borrow_trace_inline(stream_class)->packet_header_fc;
+ bt_stream_class_borrow_trace_class_inline(stream_class)->packet_header_fc;
resolve_ctx.packet_context = stream_class->packet_context_fc;
resolve_ctx.event_header = stream_class->event_header_fc;
ret = bt_resolve_field_paths(field_class, &resolve_ctx);
goto end;
}
- bt_field_class_make_part_of_trace(field_class);
+ bt_field_class_make_part_of_trace_class(field_class);
bt_object_put_ref(stream_class->event_common_context_fc);
stream_class->event_common_context_fc = field_class;
bt_object_get_no_null_check(stream_class->event_common_context_fc);
stream->name.value = NULL;
}
+ BT_LOGD_STR("Putting stream's class.");
+ bt_object_put_ref(stream->class);
bt_object_pool_finalize(&stream->packet_pool);
g_free(stream);
}
static
struct bt_stream *create_stream_with_id(struct bt_stream_class *stream_class,
- uint64_t id)
+ struct bt_trace *trace, uint64_t id)
{
int ret;
struct bt_stream *stream;
- struct bt_trace *trace;
BT_ASSERT(stream_class);
- trace = bt_stream_class_borrow_trace_inline(stream_class);
+ BT_ASSERT(trace);
+ BT_ASSERT_PRE(trace->class ==
+ bt_stream_class_borrow_trace_class_inline(stream_class),
+ "Trace's class is different from stream class's parent trace class: "
+ "%![sc-]+S, %![trace-]+t", stream_class, trace);
BT_ASSERT_PRE(stream_id_is_unique(trace, stream_class, id),
"Duplicate stream ID: %![trace-]+t, id=%" PRIu64, trace, id);
BT_ASSERT_PRE(!trace->is_static,
}
stream->class = stream_class;
+ bt_object_get_no_null_check(stream_class);
+
+ /* bt_trace_add_stream() sets the parent trace, and freezes the trace */
bt_trace_add_stream(trace, stream);
+
bt_stream_class_freeze(stream_class);
BT_LIB_LOGD("Created stream object: %!+s", stream);
goto end;
return stream;
}
-struct bt_stream *bt_stream_create(struct bt_stream_class *stream_class)
+struct bt_stream *bt_stream_create(struct bt_stream_class *stream_class,
+ struct bt_trace *trace)
{
uint64_t id;
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
BT_ASSERT_PRE(stream_class->assigns_automatic_stream_id,
"Stream class does not automatically assigns stream IDs: "
"%![sc-]+S", stream_class);
- id = bt_trace_get_automatic_stream_id(
- bt_stream_class_borrow_trace_inline(stream_class),
- stream_class);
- return create_stream_with_id(stream_class, id);
+ id = bt_trace_get_automatic_stream_id(trace, stream_class);
+ return create_stream_with_id(stream_class, trace, id);
}
struct bt_stream *bt_stream_create_with_id(struct bt_stream_class *stream_class,
- uint64_t id)
+ struct bt_trace *trace, uint64_t id)
{
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
BT_ASSERT_PRE(!stream_class->assigns_automatic_stream_id,
"Stream class automatically assigns stream IDs: "
"%![sc-]+S", stream_class);
- return create_stream_with_id(stream_class, id);
+ return create_stream_with_id(stream_class, trace, id);
}
struct bt_stream_class *bt_stream_borrow_class(struct bt_stream *stream)
return bt_stream_borrow_class((void *) stream);
}
+struct bt_trace *bt_stream_borrow_trace(struct bt_stream *stream)
+{
+ BT_ASSERT_PRE_NON_NULL(stream, "Stream");
+ return bt_stream_borrow_trace_inline(stream);
+}
+
+const struct bt_trace *bt_stream_borrow_trace_const(
+ const struct bt_stream *stream)
+{
+ return bt_stream_borrow_trace((void *) stream);
+}
+
const char *bt_stream_get_name(const struct bt_stream *stream)
{
BT_ASSERT_PRE_NON_NULL(stream, "Stream class");
--- /dev/null
+/*
+ * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define BT_LOG_TAG "TRACE"
+#include <babeltrace/lib-logging-internal.h>
+
+#include <babeltrace/assert-pre-internal.h>
+#include <babeltrace/trace-ir/trace-class.h>
+#include <babeltrace/trace-ir/trace-class-const.h>
+#include <babeltrace/trace-ir/trace-internal.h>
+#include <babeltrace/trace-ir/clock-class-internal.h>
+#include <babeltrace/trace-ir/stream-internal.h>
+#include <babeltrace/trace-ir/stream-class-internal.h>
+#include <babeltrace/trace-ir/event-internal.h>
+#include <babeltrace/trace-ir/event-class.h>
+#include <babeltrace/trace-ir/event-class-internal.h>
+#include <babeltrace/ctf-writer/functor-internal.h>
+#include <babeltrace/ctf-writer/clock-internal.h>
+#include <babeltrace/trace-ir/field-wrapper-internal.h>
+#include <babeltrace/trace-ir/field-classes-internal.h>
+#include <babeltrace/trace-ir/attributes-internal.h>
+#include <babeltrace/trace-ir/utils-internal.h>
+#include <babeltrace/trace-ir/resolve-field-path-internal.h>
+#include <babeltrace/compiler-internal.h>
+#include <babeltrace/values.h>
+#include <babeltrace/values-const.h>
+#include <babeltrace/values-internal.h>
+#include <babeltrace/object.h>
+#include <babeltrace/types.h>
+#include <babeltrace/endian-internal.h>
+#include <babeltrace/assert-internal.h>
+#include <babeltrace/compat/glib-internal.h>
+#include <inttypes.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define BT_ASSERT_PRE_TRACE_CLASS_HOT(_tc) \
+ BT_ASSERT_PRE_HOT((_tc), "Trace class", ": %!+T", (_tc))
+
+static
+void destroy_trace_class(struct bt_object *obj)
+{
+ struct bt_trace_class *tc = (void *) obj;
+
+ BT_LIB_LOGD("Destroying trace class object: %!+T", tc);
+ bt_object_pool_finalize(&tc->packet_header_field_pool);
+
+ if (tc->environment) {
+ BT_LOGD_STR("Destroying environment attributes.");
+ bt_attributes_destroy(tc->environment);
+ tc->environment = NULL;
+ }
+
+ if (tc->name.str) {
+ g_string_free(tc->name.str, TRUE);
+ tc->name.str = NULL;
+ tc->name.value = NULL;
+ }
+
+ if (tc->stream_classes) {
+ BT_LOGD_STR("Destroying stream classes.");
+ g_ptr_array_free(tc->stream_classes, TRUE);
+ tc->stream_classes = NULL;
+ }
+
+ BT_LOGD_STR("Putting packet header field classe.");
+ bt_object_put_ref(tc->packet_header_fc);
+ tc->packet_header_fc = NULL;
+ g_free(tc);
+}
+
+static
+void free_packet_header_field(struct bt_field_wrapper *field_wrapper,
+ struct bt_trace_class *tc)
+{
+ bt_field_wrapper_destroy(field_wrapper);
+}
+
+struct bt_trace_class *bt_trace_class_create(void)
+{
+ struct bt_trace_class *tc = NULL;
+ int ret;
+
+ BT_LOGD_STR("Creating default trace class object.");
+ tc = g_new0(struct bt_trace_class, 1);
+ if (!tc) {
+ BT_LOGE_STR("Failed to allocate one trace class.");
+ goto error;
+ }
+
+ bt_object_init_shared_with_parent(&tc->base, destroy_trace_class);
+
+ tc->stream_classes = g_ptr_array_new_with_free_func(
+ (GDestroyNotify) bt_object_try_spec_release);
+ if (!tc->stream_classes) {
+ BT_LOGE_STR("Failed to allocate one GPtrArray.");
+ goto error;
+ }
+
+ tc->name.str = g_string_new(NULL);
+ if (!tc->name.str) {
+ BT_LOGE_STR("Failed to allocate one GString.");
+ goto error;
+ }
+
+ tc->environment = bt_attributes_create();
+ if (!tc->environment) {
+ BT_LOGE_STR("Cannot create empty attributes object.");
+ goto error;
+ }
+
+ tc->assigns_automatic_stream_class_id = true;
+ ret = bt_object_pool_initialize(&tc->packet_header_field_pool,
+ (bt_object_pool_new_object_func) bt_field_wrapper_new,
+ (bt_object_pool_destroy_object_func) free_packet_header_field,
+ tc);
+ if (ret) {
+ BT_LOGE("Failed to initialize packet header field pool: ret=%d",
+ ret);
+ goto error;
+ }
+
+ BT_LIB_LOGD("Created trace class object: %!+T", tc);
+ goto end;
+
+error:
+ BT_OBJECT_PUT_REF_AND_RESET(tc);
+
+end:
+ return tc;
+}
+
+const char *bt_trace_class_get_name(const struct bt_trace_class *tc)
+{
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ return tc->name.value;
+}
+
+int bt_trace_class_set_name(struct bt_trace_class *tc, const char *name)
+{
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+ BT_ASSERT_PRE_TRACE_CLASS_HOT(tc);
+ g_string_assign(tc->name.str, name);
+ tc->name.value = tc->name.str->str;
+ BT_LIB_LOGV("Set trace class's name: %!+T", tc);
+ return 0;
+}
+
+bt_uuid bt_trace_class_get_uuid(const struct bt_trace_class *tc)
+{
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ return tc->uuid.value;
+}
+
+void bt_trace_class_set_uuid(struct bt_trace_class *tc, bt_uuid uuid)
+{
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ BT_ASSERT_PRE_NON_NULL(uuid, "UUID");
+ BT_ASSERT_PRE_TRACE_CLASS_HOT(tc);
+ memcpy(tc->uuid.uuid, uuid, BABELTRACE_UUID_LEN);
+ tc->uuid.value = tc->uuid.uuid;
+ BT_LIB_LOGV("Set trace class's UUID: %!+T", tc);
+}
+
+BT_ASSERT_FUNC
+static
+bool trace_has_environment_entry(const struct bt_trace_class *tc, const char *name)
+{
+ BT_ASSERT(tc);
+
+ return bt_attributes_borrow_field_value_by_name(
+ tc->environment, name) != NULL;
+}
+
+static
+int set_environment_entry(struct bt_trace_class *tc, const char *name,
+ struct bt_value *value)
+{
+ int ret;
+
+ BT_ASSERT(tc);
+ BT_ASSERT(name);
+ BT_ASSERT(value);
+ BT_ASSERT_PRE(!tc->frozen ||
+ !trace_has_environment_entry(tc, name),
+ "Trace class is frozen: cannot replace environment entry: "
+ "%![tc-]+T, entry-name=\"%s\"", tc, name);
+ ret = bt_attributes_set_field_value(tc->environment, name,
+ value);
+ bt_value_freeze(value);
+ if (ret) {
+ BT_LIB_LOGE("Cannot set trace class's environment entry: "
+ "%![tc-]+T, entry-name=\"%s\"", tc, name);
+ } else {
+ BT_LIB_LOGV("Set trace class's environment entry: "
+ "%![tc-]+T, entry-name=\"%s\"", tc, name);
+ }
+
+ return ret;
+}
+
+int bt_trace_class_set_environment_entry_string(
+ struct bt_trace_class *tc, const char *name, const char *value)
+{
+ int ret;
+ struct bt_value *value_obj;
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+ BT_ASSERT_PRE_NON_NULL(value, "Value");
+ value_obj = bt_value_string_create_init(value);
+ if (!value_obj) {
+ BT_LOGE_STR("Cannot create a string value object.");
+ ret = -1;
+ goto end;
+ }
+
+ /* set_environment_entry() logs errors */
+ ret = set_environment_entry(tc, name, value_obj);
+
+end:
+ bt_object_put_ref(value_obj);
+ return ret;
+}
+
+int bt_trace_class_set_environment_entry_integer(struct bt_trace_class *tc,
+ const char *name, int64_t value)
+{
+ int ret;
+ struct bt_value *value_obj;
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+ value_obj = bt_value_integer_create_init(value);
+ if (!value_obj) {
+ BT_LOGE_STR("Cannot create an integer value object.");
+ ret = -1;
+ goto end;
+ }
+
+ /* set_environment_entry() logs errors */
+ ret = set_environment_entry(tc, name, value_obj);
+
+end:
+ bt_object_put_ref(value_obj);
+ return ret;
+}
+
+uint64_t bt_trace_class_get_environment_entry_count(const struct bt_trace_class *tc)
+{
+ int64_t ret;
+
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ ret = bt_attributes_get_count(tc->environment);
+ BT_ASSERT(ret >= 0);
+ return (uint64_t) ret;
+}
+
+void bt_trace_class_borrow_environment_entry_by_index_const(
+ const struct bt_trace_class *tc, uint64_t index,
+ const char **name, const struct bt_value **value)
+{
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+ BT_ASSERT_PRE_NON_NULL(value, "Value");
+ BT_ASSERT_PRE_VALID_INDEX(index,
+ bt_attributes_get_count(tc->environment));
+ *value = bt_attributes_borrow_field_value(tc->environment, index);
+ BT_ASSERT(*value);
+ *name = bt_attributes_get_field_name(tc->environment, index);
+ BT_ASSERT(*name);
+}
+
+const struct bt_value *bt_trace_class_borrow_environment_entry_value_by_name_const(
+ const struct bt_trace_class *tc, const char *name)
+{
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+ return bt_attributes_borrow_field_value_by_name(tc->environment,
+ name);
+}
+
+uint64_t bt_trace_class_get_stream_class_count(const struct bt_trace_class *tc)
+{
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ return (uint64_t) tc->stream_classes->len;
+}
+
+struct bt_stream_class *bt_trace_class_borrow_stream_class_by_index(
+ struct bt_trace_class *tc, uint64_t index)
+{
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ BT_ASSERT_PRE_VALID_INDEX(index, tc->stream_classes->len);
+ return g_ptr_array_index(tc->stream_classes, index);
+}
+
+const struct bt_stream_class *
+bt_trace_class_borrow_stream_class_by_index_const(
+ const struct bt_trace_class *tc, uint64_t index)
+{
+ return bt_trace_class_borrow_stream_class_by_index(
+ (void *) tc, index);
+}
+
+struct bt_stream_class *bt_trace_class_borrow_stream_class_by_id(
+ struct bt_trace_class *tc, uint64_t id)
+{
+ struct bt_stream_class *stream_class = NULL;
+ uint64_t i;
+
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+
+ for (i = 0; i < tc->stream_classes->len; i++) {
+ struct bt_stream_class *stream_class_candidate =
+ g_ptr_array_index(tc->stream_classes, i);
+
+ if (stream_class_candidate->id == id) {
+ stream_class = stream_class_candidate;
+ goto end;
+ }
+ }
+
+end:
+ return stream_class;
+}
+
+const struct bt_stream_class *
+bt_trace_class_borrow_stream_class_by_id_const(
+ const struct bt_trace_class *tc, uint64_t id)
+{
+ return bt_trace_class_borrow_stream_class_by_id((void *) tc, id);
+}
+
+const struct bt_field_class *bt_trace_class_borrow_packet_header_field_class_const(
+ const struct bt_trace_class *tc)
+{
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ return tc->packet_header_fc;
+}
+
+int bt_trace_class_set_packet_header_field_class(
+ struct bt_trace_class *tc,
+ struct bt_field_class *field_class)
+{
+ int ret;
+ struct bt_resolve_field_path_context resolve_ctx = {
+ .packet_header = field_class,
+ .packet_context = NULL,
+ .event_header = NULL,
+ .event_common_context = NULL,
+ .event_specific_context = NULL,
+ .event_payload = NULL,
+ };
+
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
+ BT_ASSERT_PRE_TRACE_CLASS_HOT(tc);
+ BT_ASSERT_PRE(bt_field_class_get_type(field_class) ==
+ BT_FIELD_CLASS_TYPE_STRUCTURE,
+ "Packet header field classe is not a structure field classe: %!+F",
+ field_class);
+ ret = bt_resolve_field_paths(field_class, &resolve_ctx);
+ if (ret) {
+ goto end;
+ }
+
+ bt_field_class_make_part_of_trace_class(field_class);
+ bt_object_put_ref(tc->packet_header_fc);
+ tc->packet_header_fc = field_class;
+ bt_object_get_no_null_check(tc->packet_header_fc);
+ bt_field_class_freeze(field_class);
+ BT_LIB_LOGV("Set trace class's packet header field classe: %!+T", tc);
+
+end:
+ return ret;
+}
+
+BT_HIDDEN
+void _bt_trace_class_freeze(const struct bt_trace_class *tc)
+{
+ /* The packet header field classe is already frozen */
+ BT_ASSERT(tc);
+ BT_LIB_LOGD("Freezing trace class: %!+T", tc);
+ ((struct bt_trace_class *) tc)->frozen = true;
+}
+
+bt_bool bt_trace_class_assigns_automatic_stream_class_id(const struct bt_trace_class *tc)
+{
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ return (bt_bool) tc->assigns_automatic_stream_class_id;
+}
+
+void bt_trace_class_set_assigns_automatic_stream_class_id(struct bt_trace_class *tc,
+ bt_bool value)
+{
+ BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
+ BT_ASSERT_PRE_TRACE_CLASS_HOT(tc);
+ tc->assigns_automatic_stream_class_id = (bool) value;
+ BT_LIB_LOGV("Set trace class's automatic stream class ID "
+ "assignment property: %!+T", tc);
+}
#include <babeltrace/lib-logging-internal.h>
#include <babeltrace/assert-pre-internal.h>
+#include <babeltrace/trace-ir/trace.h>
+#include <babeltrace/trace-ir/trace-class-internal.h>
#include <babeltrace/trace-ir/trace-const.h>
#include <babeltrace/trace-ir/trace-internal.h>
#include <babeltrace/trace-ir/clock-class-internal.h>
trace->is_static_listeners = NULL;
}
- bt_object_pool_finalize(&trace->packet_header_field_pool);
-
- if (trace->environment) {
- BT_LOGD_STR("Destroying environment attributes.");
- bt_attributes_destroy(trace->environment);
- trace->environment = NULL;
- }
-
if (trace->name.str) {
g_string_free(trace->name.str, TRUE);
trace->name.str = NULL;
trace->streams = NULL;
}
- if (trace->stream_classes) {
- BT_LOGD_STR("Destroying stream classes.");
- g_ptr_array_free(trace->stream_classes, TRUE);
- trace->stream_classes = NULL;
- }
-
if (trace->stream_classes_stream_count) {
g_hash_table_destroy(trace->stream_classes_stream_count);
trace->stream_classes_stream_count = NULL;
}
- BT_LOGD_STR("Putting packet header field classe.");
- bt_object_put_ref(trace->packet_header_fc);
- trace->packet_header_fc = NULL;
+ BT_LOGD_STR("Putting trace's class.");
+ bt_object_put_ref(trace->class);
+ trace->class = NULL;
g_free(trace);
}
-static
-void free_packet_header_field(struct bt_field_wrapper *field_wrapper,
- struct bt_trace *trace)
-{
- bt_field_wrapper_destroy(field_wrapper);
-}
-
-struct bt_trace *bt_trace_create(void)
+struct bt_trace *bt_trace_create(struct bt_trace_class *tc)
{
struct bt_trace *trace = NULL;
- int ret;
- BT_LOGD_STR("Creating default trace object.");
+ BT_LIB_LOGD("Creating trace object: %![tc-]+T", tc);
trace = g_new0(struct bt_trace, 1);
if (!trace) {
BT_LOGE_STR("Failed to allocate one trace.");
goto error;
}
- bt_object_init_shared_with_parent(&trace->base, destroy_trace);
+ bt_object_init_shared(&trace->base, destroy_trace);
trace->streams = g_ptr_array_new_with_free_func(
(GDestroyNotify) bt_object_try_spec_release);
if (!trace->streams) {
goto error;
}
- trace->stream_classes = g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_object_try_spec_release);
- if (!trace->stream_classes) {
- BT_LOGE_STR("Failed to allocate one GPtrArray.");
- goto error;
- }
-
trace->stream_classes_stream_count = g_hash_table_new(g_direct_hash,
g_direct_equal);
if (!trace->stream_classes_stream_count) {
goto error;
}
- trace->environment = bt_attributes_create();
- if (!trace->environment) {
- BT_LOGE_STR("Cannot create empty attributes object.");
- goto error;
- }
-
trace->is_static_listeners = g_array_new(FALSE, TRUE,
sizeof(struct bt_trace_is_static_listener_elem));
if (!trace->is_static_listeners) {
goto error;
}
- trace->assigns_automatic_stream_class_id = true;
- ret = bt_object_pool_initialize(&trace->packet_header_field_pool,
- (bt_object_pool_new_object_func) bt_field_wrapper_new,
- (bt_object_pool_destroy_object_func) free_packet_header_field,
- trace);
- if (ret) {
- BT_LOGE("Failed to initialize packet header field pool: ret=%d",
- ret);
- goto error;
- }
-
+ trace->class = tc;
+ bt_object_get_no_null_check(trace->class);
BT_LIB_LOGD("Created trace object: %!+t", trace);
goto end;
BT_OBJECT_PUT_REF_AND_RESET(trace);
end:
- return (void *) trace;
+ return trace;
}
const char *bt_trace_get_name(const struct bt_trace *trace)
return 0;
}
-bt_uuid bt_trace_get_uuid(const struct bt_trace *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return trace->uuid.value;
-}
-
-void bt_trace_set_uuid(struct bt_trace *trace, bt_uuid uuid)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE_NON_NULL(uuid, "UUID");
- BT_ASSERT_PRE_TRACE_HOT(trace);
- memcpy(trace->uuid.uuid, uuid, BABELTRACE_UUID_LEN);
- trace->uuid.value = trace->uuid.uuid;
- BT_LIB_LOGV("Set trace's UUID: %!+t", trace);
-}
-
-BT_ASSERT_FUNC
-static
-bool trace_has_environment_entry(const struct bt_trace *trace, const char *name)
-{
- BT_ASSERT(trace);
-
- return bt_attributes_borrow_field_value_by_name(
- trace->environment, name) != NULL;
-}
-
-static
-int set_environment_entry(struct bt_trace *trace, const char *name,
- struct bt_value *value)
-{
- int ret;
-
- BT_ASSERT(trace);
- BT_ASSERT(name);
- BT_ASSERT(value);
- BT_ASSERT_PRE(!trace->frozen ||
- !trace_has_environment_entry(trace, name),
- "Trace is frozen: cannot replace environment entry: "
- "%![trace-]+t, entry-name=\"%s\"", trace, name);
- ret = bt_attributes_set_field_value(trace->environment, name,
- value);
- bt_value_freeze(value);
- if (ret) {
- BT_LIB_LOGE("Cannot set trace's environment entry: "
- "%![trace-]+t, entry-name=\"%s\"", trace, name);
- } else {
- BT_LIB_LOGV("Set trace's environment entry: "
- "%![trace-]+t, entry-name=\"%s\"", trace, name);
- }
-
- return ret;
-}
-
-int bt_trace_set_environment_entry_string(
- struct bt_trace *trace,
- const char *name, const char *value)
-{
- int ret;
- struct bt_value *value_obj;
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE_NON_NULL(name, "Name");
- BT_ASSERT_PRE_NON_NULL(value, "Value");
- value_obj = bt_value_string_create_init(value);
- if (!value_obj) {
- BT_LOGE_STR("Cannot create a string value object.");
- ret = -1;
- goto end;
- }
-
- /* set_environment_entry() logs errors */
- ret = set_environment_entry(trace, name, value_obj);
-
-end:
- bt_object_put_ref(value_obj);
- return ret;
-}
-
-int bt_trace_set_environment_entry_integer(struct bt_trace *trace,
- const char *name, int64_t value)
-{
- int ret;
- struct bt_value *value_obj;
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE_NON_NULL(name, "Name");
- value_obj = bt_value_integer_create_init(value);
- if (!value_obj) {
- BT_LOGE_STR("Cannot create an integer value object.");
- ret = -1;
- goto end;
- }
-
- /* set_environment_entry() logs errors */
- ret = set_environment_entry(trace, name, value_obj);
-
-end:
- bt_object_put_ref(value_obj);
- return ret;
-}
-
-uint64_t bt_trace_get_environment_entry_count(const struct bt_trace *trace)
-{
- int64_t ret;
-
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- ret = bt_attributes_get_count(trace->environment);
- BT_ASSERT(ret >= 0);
- return (uint64_t) ret;
-}
-
-void bt_trace_borrow_environment_entry_by_index_const(
- const struct bt_trace *trace, uint64_t index,
- const char **name, const struct bt_value **value)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE_NON_NULL(name, "Name");
- BT_ASSERT_PRE_NON_NULL(value, "Value");
- BT_ASSERT_PRE_VALID_INDEX(index,
- bt_attributes_get_count(trace->environment));
- *value = bt_attributes_borrow_field_value(trace->environment, index);
- BT_ASSERT(*value);
- *name = bt_attributes_get_field_name(trace->environment, index);
- BT_ASSERT(*name);
-}
-
-const struct bt_value *bt_trace_borrow_environment_entry_value_by_name_const(
- const struct bt_trace *trace, const char *name)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE_NON_NULL(name, "Name");
- return bt_attributes_borrow_field_value_by_name(trace->environment,
- name);
-}
-
uint64_t bt_trace_get_stream_count(const struct bt_trace *trace)
{
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
return bt_trace_borrow_stream_by_id((void *) trace, id);
}
-uint64_t bt_trace_get_stream_class_count(const struct bt_trace *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return (uint64_t) trace->stream_classes->len;
-}
-
-struct bt_stream_class *bt_trace_borrow_stream_class_by_index(
- struct bt_trace *trace, uint64_t index)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE_VALID_INDEX(index, trace->stream_classes->len);
- return g_ptr_array_index(trace->stream_classes, index);
-}
-
-const struct bt_stream_class *
-bt_trace_borrow_stream_class_by_index_const(
- const struct bt_trace *trace, uint64_t index)
-{
- return bt_trace_borrow_stream_class_by_index(
- (void *) trace, index);
-}
-
-struct bt_stream_class *bt_trace_borrow_stream_class_by_id(
- struct bt_trace *trace, uint64_t id)
-{
- struct bt_stream_class *stream_class = NULL;
- uint64_t i;
-
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-
- for (i = 0; i < trace->stream_classes->len; i++) {
- struct bt_stream_class *stream_class_candidate =
- g_ptr_array_index(trace->stream_classes, i);
-
- if (stream_class_candidate->id == id) {
- stream_class = stream_class_candidate;
- goto end;
- }
- }
-
-end:
- return stream_class;
-}
-
-const struct bt_stream_class *
-bt_trace_borrow_stream_class_by_id_const(
- const struct bt_trace *trace, uint64_t id)
-{
- return bt_trace_borrow_stream_class_by_id((void *) trace, id);
-}
-
-const struct bt_field_class *bt_trace_borrow_packet_header_field_class_const(
- const struct bt_trace *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return trace->packet_header_fc;
-}
-
-int bt_trace_set_packet_header_field_class(
- struct bt_trace *trace,
- struct bt_field_class *field_class)
-{
- int ret;
- struct bt_resolve_field_path_context resolve_ctx = {
- .packet_header = field_class,
- .packet_context = NULL,
- .event_header = NULL,
- .event_common_context = NULL,
- .event_specific_context = NULL,
- .event_payload = NULL,
- };
-
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
- BT_ASSERT_PRE_TRACE_HOT(trace);
- BT_ASSERT_PRE(bt_field_class_get_type(field_class) ==
- BT_FIELD_CLASS_TYPE_STRUCTURE,
- "Packet header field classe is not a structure field classe: %!+F",
- field_class);
- ret = bt_resolve_field_paths(field_class, &resolve_ctx);
- if (ret) {
- goto end;
- }
-
- bt_field_class_make_part_of_trace(field_class);
- bt_object_put_ref(trace->packet_header_fc);
- trace->packet_header_fc = field_class;
- bt_object_get_no_null_check(trace->packet_header_fc);
- bt_field_class_freeze(field_class);
- BT_LIB_LOGV("Set trace's packet header field classe: %!+t", trace);
-
-end:
- return ret;
-}
-
bt_bool bt_trace_is_static(const struct bt_trace *trace)
{
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
{
/* The packet header field classe is already frozen */
BT_ASSERT(trace);
+ BT_LIB_LOGD("Freezing trace's class: %!+T", trace->class);
+ bt_trace_class_freeze(trace->class);
BT_LIB_LOGD("Freezing trace: %!+t", trace);
((struct bt_trace *) trace)->frozen = true;
}
-bt_bool bt_trace_assigns_automatic_stream_class_id(const struct bt_trace *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return (bt_bool) trace->assigns_automatic_stream_class_id;
-}
-
-void bt_trace_set_assigns_automatic_stream_class_id(struct bt_trace *trace,
- bt_bool value)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE_TRACE_HOT(trace);
- trace->assigns_automatic_stream_class_id = (bool) value;
- BT_LIB_LOGV("Set trace's automatic stream class ID "
- "assignment property: %!+t", trace);
-}
-
BT_HIDDEN
void bt_trace_add_stream(struct bt_trace *trace, struct bt_stream *stream)
{
return id;
}
+
+struct bt_trace_class *bt_trace_borrow_class(struct bt_trace *trace)
+{
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return trace->class;
+}
+
+const struct bt_trace_class *bt_trace_borrow_class_const(
+ const struct bt_trace *trace)
+{
+ return bt_trace_borrow_class((void *) trace);
+}
BT_HIDDEN
struct ctf_visitor_generate_ir *ctf_visitor_generate_ir_create(
- const struct ctf_metadata_decoder_config *config,
- const char *name);
+ const struct ctf_metadata_decoder_config *config);
void ctf_visitor_generate_ir_destroy(struct ctf_visitor_generate_ir *visitor);
BT_HIDDEN
-struct bt_trace *ctf_visitor_generate_ir_get_ir_trace(
+struct bt_trace_class *ctf_visitor_generate_ir_get_ir_trace_class(
struct ctf_visitor_generate_ir *visitor);
BT_HIDDEN
static inline
struct bt_stream_class *ctf_stream_class_to_ir(struct ctf_stream_class *sc,
- struct bt_trace *ir_trace, struct ctf_trace_class *tc)
+ struct bt_trace_class *ir_tc, struct ctf_trace_class *tc)
{
int ret;
struct bt_stream_class *ir_sc = NULL;
struct ctf_field_class_int *int_fc;
if (sc->is_translated) {
- ir_sc = bt_trace_borrow_stream_class_by_id(
- ir_trace, sc->id);
+ ir_sc = bt_trace_class_borrow_stream_class_by_id(ir_tc, sc->id);
BT_ASSERT(ir_sc);
goto end;
}
- ir_sc = bt_stream_class_create_with_id(ir_trace, sc->id);
+ ir_sc = bt_stream_class_create_with_id(ir_tc, sc->id);
BT_ASSERT(ir_sc);
bt_object_put_ref(ir_sc);
}
static inline
-int ctf_trace_class_to_ir(struct bt_trace *ir_trace,
+int ctf_trace_class_to_ir(struct bt_trace_class *ir_tc,
struct ctf_trace_class *tc)
{
int ret = 0;
tc->packet_header_fc, tc, NULL, NULL);
if (ir_fc) {
- ret = bt_trace_set_packet_header_field_class(
- ir_trace, ir_fc);
+ ret = bt_trace_class_set_packet_header_field_class(
+ ir_tc, ir_fc);
BT_ASSERT(ret == 0);
bt_object_put_ref(ir_fc);
}
}
- if (tc->name->len > 0) {
- ret = bt_trace_set_name(ir_trace, tc->name->str);
- if (ret) {
- goto end;
- }
- }
-
if (tc->is_uuid_set) {
- bt_trace_set_uuid(ir_trace, tc->uuid);
+ bt_trace_class_set_uuid(ir_tc, tc->uuid);
}
for (i = 0; i < tc->env_entries->len; i++) {
switch (env_entry->type) {
case CTF_TRACE_CLASS_ENV_ENTRY_TYPE_INT:
- ret = bt_trace_set_environment_entry_integer(
- ir_trace, env_entry->name->str,
+ ret = bt_trace_class_set_environment_entry_integer(
+ ir_tc, env_entry->name->str,
env_entry->value.i);
break;
case CTF_TRACE_CLASS_ENV_ENTRY_TYPE_STR:
- ret = bt_trace_set_environment_entry_string(
- ir_trace, env_entry->name->str,
+ ret = bt_trace_class_set_environment_entry_string(
+ ir_tc, env_entry->name->str,
env_entry->value.str->str);
break;
default:
}
}
- bt_trace_set_assigns_automatic_stream_class_id(ir_trace,
+ bt_trace_class_set_assigns_automatic_stream_class_id(ir_tc,
BT_FALSE);
tc->is_translated = true;
- tc->ir_tc = ir_trace;
+ tc->ir_tc = ir_tc;
end:
return ret;
}
BT_HIDDEN
-int ctf_trace_class_translate(struct bt_trace *ir_trace,
+int ctf_trace_class_translate(struct bt_trace_class *ir_tc,
struct ctf_trace_class *tc)
{
int ret = 0;
uint64_t i;
- ret = ctf_trace_class_to_ir(ir_trace, tc);
+ ret = ctf_trace_class_to_ir(ir_tc, tc);
if (ret) {
goto end;
}
struct ctf_stream_class *sc = tc->stream_classes->pdata[i];
struct bt_stream_class *ir_sc;
- ir_sc = ctf_stream_class_to_ir(sc, ir_trace, tc);
+ ir_sc = ctf_stream_class_to_ir(sc, ir_tc, tc);
if (!ir_sc) {
ret = -1;
goto end;
int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc);
BT_HIDDEN
-int ctf_trace_class_translate(struct bt_trace *ir_trace,
+int ctf_trace_class_translate(struct bt_trace_class *ir_tc,
struct ctf_trace_class *tc);
BT_HIDDEN
};
struct ctf_trace_class {
- GString *name;
unsigned int major;
unsigned int minor;
uint8_t uuid[16];
bool is_translated;
/* Weak, set during translation */
- struct bt_trace *ir_tc;
+ struct bt_trace_class *ir_tc;
};
static inline
struct ctf_trace_class *tc = g_new0(struct ctf_trace_class, 1);
BT_ASSERT(tc);
- tc->name = g_string_new(NULL);
tc->default_byte_order = -1;
- BT_ASSERT(tc->name);
tc->clock_classes = g_ptr_array_new_with_free_func(
(GDestroyNotify) bt_object_put_ref);
BT_ASSERT(tc->clock_classes);
return;
}
- if (tc->name) {
- g_string_free(tc->name, TRUE);
- }
-
ctf_field_class_destroy(tc->packet_header_fc);
if (tc->clock_classes) {
BT_HIDDEN
struct ctf_metadata_decoder *ctf_metadata_decoder_create(
- const struct ctf_metadata_decoder_config *config,
- const char *name)
+ const struct ctf_metadata_decoder_config *config)
{
struct ctf_metadata_decoder *mdec =
g_new0(struct ctf_metadata_decoder, 1);
BT_LOGD("Creating CTF metadata decoder: "
"clock-class-offset-s=%" PRId64 ", "
- "clock-class-offset-ns=%" PRId64 ", name=\"%s\"",
- config->clock_class_offset_s, config->clock_class_offset_ns,
- name);
+ "clock-class-offset-ns=%" PRId64,
+ config->clock_class_offset_s, config->clock_class_offset_ns);
if (!mdec) {
BT_LOGE_STR("Failed to allocate one CTF metadata decoder.");
}
mdec->config = *config;
- mdec->visitor = ctf_visitor_generate_ir_create(config, name);
+ mdec->visitor = ctf_visitor_generate_ir_create(config);
if (!mdec->visitor) {
BT_LOGE("Failed to create a CTF IR metadata AST visitor: "
"mdec-addr=%p", mdec);
BT_LOGD("Creating CTF metadata decoder: "
"clock-class-offset-s=%" PRId64 ", "
- "clock-class-offset-ns=%" PRId64 ", "
- "name=\"%s\", addr=%p",
+ "clock-class-offset-ns=%" PRId64 ", addr=%p",
config->clock_class_offset_s, config->clock_class_offset_ns,
- name, mdec);
+ mdec);
end:
return mdec;
}
BT_HIDDEN
-struct bt_trace *ctf_metadata_decoder_get_ir_trace(
+struct bt_trace_class *ctf_metadata_decoder_get_ir_trace_class(
struct ctf_metadata_decoder *mdec)
{
- return ctf_visitor_generate_ir_get_ir_trace(mdec->visitor);
+ return ctf_visitor_generate_ir_get_ir_trace_class(mdec->visitor);
}
BT_HIDDEN
};
/*
- * Creates a CTF metadata decoder. `name` is this decoder's trace's
- * name.
+ * Creates a CTF metadata decoder.
*
* Returns `NULL` on error.
*/
BT_HIDDEN
struct ctf_metadata_decoder *ctf_metadata_decoder_create(
- const struct ctf_metadata_decoder_config *config,
- const char *name);
+ const struct ctf_metadata_decoder_config *config);
/*
* Destroys a CTF metadata decoder that you created with
* until the end of this file stream. If it finds new information (new
* event class, new stream class, or new clock class), it appends this
* information to the decoder's trace object (as returned by
- * ctf_metadata_decoder_get_ir_trace()), or it creates this trace.
+ * ctf_metadata_decoder_get_ir_trace_class()), or it creates this trace.
*
* The metadata can be packetized or not.
*
struct ctf_metadata_decoder *metadata_decoder, FILE *fp);
BT_HIDDEN
-struct bt_trace *ctf_metadata_decoder_get_ir_trace(
+struct bt_trace_class *ctf_metadata_decoder_get_ir_trace_class(
struct ctf_metadata_decoder *mdec);
BT_HIDDEN
* Visitor context (private).
*/
struct ctx {
- /* Trace IR trace being filled (owned by this) */
- struct bt_trace *trace;
+ /* Trace IR trace class being filled (owned by this) */
+ struct bt_trace_class *trace_class;
/* CTF meta trace being filled (owned by this) */
struct ctf_trace_class *ctf_tc;
/* True if this is an LTTng trace */
bool is_lttng;
- /* Eventual name suffix of the trace to set (owned by this) */
- char *trace_class_name_suffix;
-
/* Config passed by the user */
struct ctf_metadata_decoder_config decoder_config;
};
scope = parent_scope;
}
- bt_object_put_ref(ctx->trace);
+ bt_object_put_ref(ctx->trace_class);
if (ctx->ctf_tc) {
ctf_trace_class_destroy(ctx->ctf_tc);
}
- if (ctx->trace_class_name_suffix) {
- free(ctx->trace_class_name_suffix);
- }
-
g_free(ctx);
end:
* @returns New visitor context, or NULL on error
*/
static
-struct ctx *ctx_create(const struct ctf_metadata_decoder_config *decoder_config,
- const char *trace_class_name_suffix)
+struct ctx *ctx_create(
+ const struct ctf_metadata_decoder_config *decoder_config)
{
struct ctx *ctx = NULL;
goto error;
}
- ctx->trace = bt_trace_create();
- if (!ctx->trace) {
- BT_LOGE_STR("Cannot create empty trace.");
+ ctx->trace_class = bt_trace_class_create();
+ if (!ctx->trace_class) {
+ BT_LOGE_STR("Cannot create empty trace class.");
goto error;
}
goto error;
}
- if (trace_class_name_suffix) {
- ctx->trace_class_name_suffix = strdup(trace_class_name_suffix);
- if (!ctx->trace_class_name_suffix) {
- BT_LOGE_STR("Failed to copy string.");
- goto error;
- }
- }
-
ctx->decoder_config = *decoder_config;
goto end;
return ret;
}
-static
-int try_set_trace_class_name(struct ctx *ctx)
-{
- GString *name = NULL;
- int ret = 0;
- struct ctf_trace_class_env_entry *env_entry;
-
- if (ctx->ctf_tc->name->len > 0) {
- /* Already set */
- goto end;
- }
-
- name = g_string_new(NULL);
- if (!name) {
- BT_LOGE_STR("Failed to allocate a GString.");
- ret = -1;
- goto end;
- }
-
- /*
- * Check if we have a trace environment string value named `hostname`.
- * If so, use it as the trace name's prefix.
- */
- env_entry = ctf_trace_class_borrow_env_entry_by_name(ctx->ctf_tc,
- "hostname");
- if (env_entry &&
- env_entry->type == CTF_TRACE_CLASS_ENV_ENTRY_TYPE_STR) {
- g_string_append(name, env_entry->value.str->str);
-
- if (ctx->trace_class_name_suffix) {
- g_string_append_c(name, G_DIR_SEPARATOR);
- }
- }
-
- if (ctx->trace_class_name_suffix) {
- g_string_append(name, ctx->trace_class_name_suffix);
- }
-
- g_string_assign(ctx->ctf_tc->name, name->str);
- goto end;
-
-end:
- if (name) {
- g_string_free(name, TRUE);
- }
-
- return ret;
-}
-
BT_HIDDEN
struct ctf_visitor_generate_ir *ctf_visitor_generate_ir_create(
- const struct ctf_metadata_decoder_config *decoder_config,
- const char *name)
+ const struct ctf_metadata_decoder_config *decoder_config)
{
struct ctx *ctx = NULL;
/* Create visitor's context */
- ctx = ctx_create(decoder_config, name);
+ ctx = ctx_create(decoder_config);
if (!ctx) {
BT_LOGE_STR("Cannot create visitor's context.");
goto error;
}
BT_HIDDEN
-struct bt_trace *ctf_visitor_generate_ir_get_ir_trace(
+struct bt_trace_class *ctf_visitor_generate_ir_get_ir_trace_class(
struct ctf_visitor_generate_ir *visitor)
{
struct ctx *ctx = (void *) visitor;
BT_ASSERT(ctx);
- BT_ASSERT(ctx->trace);
- bt_object_get_ref(ctx->trace);
- return ctx->trace;
+ BT_ASSERT(ctx->trace_class);
+ bt_object_get_ref(ctx->trace_class);
+ return ctx->trace_class;
}
BT_HIDDEN
goto end;
}
- /* Set trace's name, if not already done */
- ret = try_set_trace_class_name(ctx);
- if (ret) {
- ret = -EINVAL;
- goto end;
- }
-
/* Update trace class meanings */
ret = ctf_trace_class_update_meanings(ctx->ctf_tc);
if (ret) {
}
/* Copy new CTF metadata -> new IR metadata */
- ret = ctf_trace_class_translate(ctx->trace, ctx->ctf_tc);
+ ret = ctf_trace_class_translate(ctx->trace_class, ctx->ctf_tc);
if (ret) {
ret = -EINVAL;
goto end;
goto end;
}
- /* Packet header class is common to the whole trace. */
+ /* Packet header class is common to the whole trace class. */
packet_header_fc = notit->meta.tc->packet_header_fc;
if (!packet_header_fc) {
notit->state = STATE_AFTER_TRACE_PACKET_HEADER;
if (packet_header_fc->in_ir) {
/*
- * Create free packet header field from trace. This
- * field is going to be moved to the packet once we
+ * Create free packet header field from trace class.
+ * This field is going to be moved to the packet once we
* create it. We cannot create the packet now because:
*
* 1. A packet is created from a stream.
bt_packet_header_field_create(
notit->meta.tc->ir_tc);
if (!notit->packet_header_field) {
- BT_LOGE_STR("Cannot create packet header field wrapper from trace.");
+ BT_LOGE_STR("Cannot create packet header field wrapper from trace class.");
ret = BT_NOTIF_ITER_STATUS_ERROR;
goto end;
}
notit->cur_event_class_id = -1;
notit->cur_data_stream_id = -1;
BT_LOGV("Decoding packet header field:"
- "notit-addr=%p, trace-addr=%p, trace-name=\"%s\", fc-addr=%p",
- notit, notit->meta.tc,
- notit->meta.tc->name->str, packet_header_fc);
+ "notit-addr=%p, trace-class-addr=%p, fc-addr=%p",
+ notit, notit->meta.tc, packet_header_fc);
ret = read_dscope_begin_state(notit, packet_header_fc,
STATE_AFTER_TRACE_PACKET_HEADER,
STATE_DSCOPE_TRACE_PACKET_HEADER_CONTINUE,
notit->dscopes.trace_packet_header);
if (ret < 0) {
BT_LOGW("Cannot decode packet header field: "
- "notit-addr=%p, trace-addr=%p, "
- "trace-name=\"%s\", fc-addr=%p",
- notit, notit->meta.tc,
- notit->meta.tc->name->str,
- packet_header_fc);
+ "notit-addr=%p, trace-class-addr=%p, "
+ "fc-addr=%p",
+ notit, notit->meta.tc, packet_header_fc);
}
end:
if (notit->meta.tc->stream_classes->len != 1) {
BT_LOGW("Need exactly one stream class since there's "
"no stream class ID field: "
- "notit-addr=%p, trace-name=\"%s\"",
- notit, notit->meta.tc->name->str);
+ "notit-addr=%p", notit);
status = BT_NOTIF_ITER_STATUS_ERROR;
goto end;
}
new_stream_class = ctf_trace_class_borrow_stream_class_by_id(
notit->meta.tc, notit->cur_stream_class_id);
if (!new_stream_class) {
- BT_LOGW("No stream class with ID of stream class ID to use in trace: "
+ BT_LOGW("No stream class with ID of stream class ID to use in trace class: "
"notit-addr=%p, stream-class-id=%" PRIu64 ", "
- "trace-addr=%p, trace-name=\"%s\"",
- notit, notit->cur_stream_class_id, notit->meta.tc,
- notit->meta.tc->name->str);
+ "trace-class-addr=%p",
+ notit, notit->cur_stream_class_id, notit->meta.tc);
status = BT_NOTIF_ITER_STATUS_ERROR;
goto end;
}
"prev-stream-class-id=%" PRId64 ", "
"next-stream-class-addr=%p, "
"next-stream-class-id=%" PRId64 ", "
- "trace-addr=%p, trace-name=\"%s\"",
+ "trace-addr=%p",
notit, notit->meta.sc,
notit->meta.sc->id,
new_stream_class,
new_stream_class->id,
- notit->meta.tc,
- notit->meta.tc->name->str);
+ notit->meta.tc);
status = BT_NOTIF_ITER_STATUS_ERROR;
goto end;
}
bt_event_header_field_create(
notit->meta.sc->ir_sc);
if (!notit->event_header_field) {
- BT_LOGE_STR("Cannot create event header field wrapper from trace.");
+ BT_LOGE_STR("Cannot create event header field wrapper from trace class.");
status = BT_NOTIF_ITER_STATUS_ERROR;
goto end;
}
if (notit->meta.sc->event_classes->len != 1) {
BT_LOGW("Need exactly one event class since there's "
"no event class ID field: "
- "notit-addr=%p, trace-name=\"%s\"",
- notit, notit->meta.tc->name->str);
+ "notit-addr=%p", notit);
status = BT_NOTIF_ITER_STATUS_ERROR;
goto end;
}
BT_LOGW("No event class with ID of event class ID to use in stream class: "
"notit-addr=%p, stream-class-id=%" PRIu64 ", "
"event-class-id=%" PRIu64 ", "
- "trace-addr=%p, trace-name=\"%s\"",
+ "trace-class-addr=%p",
notit, notit->meta.sc->id, notit->cur_event_class_id,
- notit->meta.tc, notit->meta.tc->name->str);
+ notit->meta.tc);
status = BT_NOTIF_ITER_STATUS_ERROR;
goto end;
}
BT_ASSERT(medops.request_bytes);
BT_ASSERT(medops.borrow_stream);
BT_LOGD("Creating CTF plugin notification iterator: "
- "trace-addr=%p, trace-name=\"%s\", max-request-size=%zu, "
- "data=%p", tc, tc->name->str, max_request_sz, data);
+ "trace-addr=%p, max-request-size=%zu, "
+ "data=%p", tc, max_request_sz, data);
notit = g_new0(struct bt_notif_iter, 1);
if (!notit) {
BT_LOGE_STR("Failed to allocate one CTF plugin notification iterator.");
bt_notif_iter_reset(notit);
BT_LOGD("Created CTF plugin notification iterator: "
- "trace-addr=%p, trace-name=\"%s\", max-request-size=%zu, "
+ "trace-addr=%p, max-request-size=%zu, "
"data=%p, notit-addr=%p",
- tc, tc->name->str, max_request_sz, data,
- notit);
+ tc, max_request_sz, data, notit);
notit->cur_packet_offset = 0;
end:
g_ptr_array_free(ctf_fs_trace->ds_file_groups, TRUE);
}
+ BT_OBJECT_PUT_REF_AND_RESET(ctf_fs_trace->trace);
+
if (ctf_fs_trace->path) {
g_string_free(ctf_fs_trace->path, TRUE);
}
/* No stream ID: use 0 */
ds_file_group->stream = bt_stream_create_with_id(
ds_file_group->stream_class,
+ ctf_fs_trace->trace,
ctf_fs_trace->next_stream_id);
ctf_fs_trace->next_stream_id++;
} else {
/* Specific stream ID */
ds_file_group->stream = bt_stream_create_with_id(
ds_file_group->stream_class,
+ ctf_fs_trace->trace,
(uint64_t) ds_file_group->stream_id);
}
return ret;
}
+static
+int set_trace_name(struct bt_trace *trace, const char *name_suffix)
+{
+ int ret = 0;
+ const struct bt_trace_class *tc = bt_trace_borrow_class_const(trace);
+ const struct bt_value *val;
+ GString *name;
+
+ name = g_string_new(NULL);
+ if (!name) {
+ BT_LOGE_STR("Failed to allocate a GString.");
+ ret = -1;
+ goto end;
+ }
+
+ /*
+ * Check if we have a trace environment string value named `hostname`.
+ * If so, use it as the trace name's prefix.
+ */
+ val = bt_trace_class_borrow_environment_entry_value_by_name_const(
+ tc, "hostname");
+ if (val && bt_value_is_string(val)) {
+ g_string_append(name, bt_value_string_get(val));
+
+ if (name_suffix) {
+ g_string_append_c(name, G_DIR_SEPARATOR);
+ }
+ }
+
+ if (name_suffix) {
+ g_string_append(name, name_suffix);
+ }
+
+ ret = bt_trace_set_name(trace, name->str);
+ if (ret) {
+ goto end;
+ }
+
+ goto end;
+
+end:
+ if (name) {
+ g_string_free(name, TRUE);
+ }
+
+ 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 = ctf_fs_metadata_set_trace(ctf_fs_trace, metadata_config);
+ ret = ctf_fs_metadata_set_trace_class(ctf_fs_trace, metadata_config);
+ if (ret) {
+ goto error;
+ }
+
+ ctf_fs_trace->trace =
+ bt_trace_create(ctf_fs_trace->metadata->trace_class);
+ if (!ctf_fs_trace->trace) {
+ goto error;
+ }
+
+ ret = set_trace_name(ctf_fs_trace->trace, name);
if (ret) {
goto error;
}
* trace needs. There won't be any more. Therefore it is safe to
* make this trace static.
*/
- (void) bt_trace_make_static(ctf_fs_trace->metadata->trace);
+ (void) bt_trace_make_static(ctf_fs_trace->trace);
goto end;
struct ctf_metadata_decoder *decoder;
/* Owned by this */
- struct bt_trace *trace;
+ struct bt_trace_class *trace_class;
/* Weak (owned by `decoder` above) */
struct ctf_trace_class *tc;
/* Owned by this */
struct ctf_fs_metadata *metadata;
+ /* Owned by this */
+ struct bt_trace *trace;
+
/* Array of struct ctf_fs_ds_file_group *, owned by this */
GPtrArray *ds_file_groups;
return file;
}
-int ctf_fs_metadata_set_trace(struct ctf_fs_trace *ctf_fs_trace,
+int ctf_fs_metadata_set_trace_class(struct ctf_fs_trace *ctf_fs_trace,
struct ctf_fs_metadata_config *config)
{
int ret = 0;
}
ctf_fs_trace->metadata->decoder = ctf_metadata_decoder_create(
- config ? &decoder_config : NULL,
- ctf_fs_trace->name->str);
+ config ? &decoder_config : NULL);
if (!ctf_fs_trace->metadata->decoder) {
BT_LOGE("Cannot create metadata decoder object");
ret = -1;
goto end;
}
- ctf_fs_trace->metadata->trace = ctf_metadata_decoder_get_ir_trace(
- ctf_fs_trace->metadata->decoder);
- BT_ASSERT(ctf_fs_trace->metadata->trace);
+ ctf_fs_trace->metadata->trace_class =
+ ctf_metadata_decoder_get_ir_trace_class(
+ ctf_fs_trace->metadata->decoder);
+ BT_ASSERT(ctf_fs_trace->metadata->trace_class);
ctf_fs_trace->metadata->tc =
ctf_metadata_decoder_borrow_ctf_trace_class(
ctf_fs_trace->metadata->decoder);
free(metadata->text);
}
- if (metadata->trace) {
- BT_OBJECT_PUT_REF_AND_RESET(metadata->trace);
+ if (metadata->trace_class) {
+ BT_OBJECT_PUT_REF_AND_RESET(metadata->trace_class);
}
if (metadata->decoder) {
void ctf_fs_metadata_fini(struct ctf_fs_metadata *metadata);
BT_HIDDEN
-int ctf_fs_metadata_set_trace(struct ctf_fs_trace *ctf_fs_trace,
+int ctf_fs_metadata_set_trace_class(struct ctf_fs_trace *ctf_fs_trace,
struct ctf_fs_metadata_config *config);
BT_HIDDEN
bt_bool no_timestamp;
} params;
- struct bt_trace *trace;
+ struct bt_trace_class *trace_class;
struct bt_stream_class *stream_class;
struct bt_event_class *event_class;
+ struct bt_trace *trace;
struct bt_stream *stream;
struct bt_packet *packet;
struct bt_clock_class *clock_class;
int create_meta(struct dmesg_component *dmesg_comp, bool has_ts)
{
struct bt_field_class *fc = NULL;
- const char *trace_name = NULL;
- gchar *basename = NULL;
int ret = 0;
- dmesg_comp->trace = bt_trace_create();
- if (!dmesg_comp->trace) {
- BT_LOGE_STR("Cannot create an empty trace object.");
+ dmesg_comp->trace_class = bt_trace_class_create();
+ if (!dmesg_comp->trace_class) {
+ BT_LOGE_STR("Cannot create an empty trace class object.");
goto error;
}
- if (dmesg_comp->params.read_from_stdin) {
- trace_name = "STDIN";
- } else {
- basename = g_path_get_basename(dmesg_comp->params.path->str);
- BT_ASSERT(basename);
-
- if (strcmp(basename, G_DIR_SEPARATOR_S) != 0 &&
- strcmp(basename, ".") != 0) {
- trace_name = basename;
- }
- }
-
- if (trace_name) {
- ret = bt_trace_set_name(dmesg_comp->trace, trace_name);
- if (ret) {
- BT_LOGE("Cannot set trace's name: name=\"%s\"", trace_name);
- goto error;
- }
- }
-
dmesg_comp->stream_class = bt_stream_class_create(
- dmesg_comp->trace);
+ dmesg_comp->trace_class);
if (!dmesg_comp->stream_class) {
BT_LOGE_STR("Cannot create a stream class object.");
goto error;
end:
bt_object_put_ref(fc);
-
- if (basename) {
- g_free(basename);
- }
-
return ret;
}
}
static
-int create_packet_and_stream(struct dmesg_component *dmesg_comp)
+int create_packet_and_stream_and_trace(struct dmesg_component *dmesg_comp)
{
int ret = 0;
+ const char *trace_name;
+ gchar *basename = NULL;
+
+ dmesg_comp->trace = bt_trace_create(dmesg_comp->trace_class);
+ if (!dmesg_comp->trace) {
+ BT_LOGE_STR("Cannot create trace object.");
+ goto error;
+ }
- dmesg_comp->stream = bt_stream_create(dmesg_comp->stream_class);
+ if (dmesg_comp->params.read_from_stdin) {
+ trace_name = "STDIN";
+ } else {
+ basename = g_path_get_basename(dmesg_comp->params.path->str);
+ BT_ASSERT(basename);
+
+ if (strcmp(basename, G_DIR_SEPARATOR_S) != 0 &&
+ strcmp(basename, ".") != 0) {
+ trace_name = basename;
+ }
+ }
+
+ if (trace_name) {
+ ret = bt_trace_set_name(dmesg_comp->trace, trace_name);
+ if (ret) {
+ BT_LOGE("Cannot set trace's name: name=\"%s\"",
+ trace_name);
+ goto error;
+ }
+ }
+
+ dmesg_comp->stream = bt_stream_create(dmesg_comp->stream_class,
+ dmesg_comp->trace);
if (!dmesg_comp->stream) {
BT_LOGE_STR("Cannot create stream object.");
goto error;
ret = -1;
end:
+ if (basename) {
+ g_free(basename);
+ }
+
return ret;
}
goto error;
}
- ret = create_packet_and_stream(dmesg_comp);
+ ret = create_packet_and_stream_and_trace(dmesg_comp);
if (ret) {
BT_LOGE("Cannot create packet and stream objects: "
"dmesg-comp-addr=%p", dmesg_comp);
int ret = 0;
const struct bt_stream *stream = NULL;
const struct bt_stream_class *stream_class = NULL;
- const struct bt_trace *trace = NULL;
const struct bt_clock_value *clock_value = NULL;
enum bt_clock_value_status cv_status;
ret = -1;
goto end;
}
- trace = bt_stream_class_borrow_trace_const(stream_class);
- if (!trace) {
- ret = -1;
- goto end;
- }
cv_status = bt_event_borrow_default_clock_value_const(event,
&clock_value);
int ret = 0;
const struct bt_event_class *event_class = NULL;
const struct bt_stream_class *stream_class = NULL;
- const struct bt_trace *trace_class = NULL;
+ const struct bt_trace_class *trace_class = NULL;
+ const struct bt_packet *packet = NULL;
+ const struct bt_stream *stream = NULL;
+ const struct bt_trace *trace = NULL;
int dom_print = 0;
enum bt_property_availability prop_avail;
event_class = bt_event_borrow_class_const(event);
- if (!event_class) {
- ret = -1;
- goto end;
- }
stream_class = bt_event_class_borrow_stream_class_const(event_class);
- if (!stream_class) {
- ret = -1;
- goto end;
- }
- trace_class = bt_stream_class_borrow_trace_const(stream_class);
- if (!trace_class) {
- ret = -1;
- goto end;
- }
+ trace_class = bt_stream_class_borrow_trace_class_const(stream_class);
+ packet = bt_event_borrow_packet_const(event);
+ stream = bt_packet_borrow_stream_const(packet);
+ trace = bt_stream_borrow_trace_const(stream);
ret = print_event_timestamp(pretty, event, &pretty->start_line);
if (ret) {
goto end;
if (pretty->options.print_trace_field) {
const char *name;
- name = bt_trace_get_name(trace_class);
+ name = bt_trace_get_name(trace);
if (name) {
if (!pretty->start_line) {
g_string_append(pretty->string, ", ");
if (pretty->options.print_trace_hostname_field) {
const struct bt_value *hostname_str;
- hostname_str = bt_trace_borrow_environment_entry_value_by_name_const(
+ hostname_str = bt_trace_class_borrow_environment_entry_value_by_name_const(
trace_class, "hostname");
if (hostname_str) {
const char *str;
if (pretty->options.print_trace_domain_field) {
const struct bt_value *domain_str;
- domain_str = bt_trace_borrow_environment_entry_value_by_name_const(
+ domain_str = bt_trace_class_borrow_environment_entry_value_by_name_const(
trace_class, "domain");
if (domain_str) {
const char *str;
if (pretty->options.print_trace_procname_field) {
const struct bt_value *procname_str;
- procname_str = bt_trace_borrow_environment_entry_value_by_name_const(
+ procname_str = bt_trace_class_borrow_environment_entry_value_by_name_const(
trace_class, "procname");
if (procname_str) {
const char *str;
if (pretty->options.print_trace_vpid_field) {
const struct bt_value *vpid_value;
- vpid_value = bt_trace_borrow_environment_entry_value_by_name_const(
+ vpid_value = bt_trace_class_borrow_environment_entry_value_by_name_const(
trace_class, "vpid");
if (vpid_value) {
int64_t value;
static struct bt_packet *src_stream1_packet2;
static struct bt_packet *src_stream2_packet1;
static struct bt_packet *src_stream2_packet2;
-static const struct bt_stream *pub_src_stream1;
-static const struct bt_stream *pub_src_stream2;
-static const struct bt_packet *pub_src_stream1_packet1;
-static const struct bt_packet *pub_src_stream1_packet2;
-static const struct bt_packet *pub_src_stream2_packet1;
-static const struct bt_packet *pub_src_stream2_packet2;
enum {
SEQ_END = -1,
static
void init_static_data(void)
{
+ struct bt_trace_class *trace_class;
struct bt_trace *trace;
/* Test events */
test_events = g_array_new(FALSE, TRUE, sizeof(struct test_event));
BT_ASSERT(test_events);
- /* Metadata */
- trace = bt_trace_create();
+ /* Metadata, streams, and packets*/
+ trace_class = bt_trace_class_create();
BT_ASSERT(trace);
- src_stream_class = bt_stream_class_create(trace);
+ src_stream_class = bt_stream_class_create(trace_class);
BT_ASSERT(src_stream_class);
src_event_class = bt_event_class_create(src_stream_class);
BT_ASSERT(src_event_class);
- src_stream1 = bt_stream_create(src_stream_class);
+ trace = bt_trace_create(trace_class);
+ BT_ASSERT(trace);
+ src_stream1 = bt_stream_create(src_stream_class, trace);
BT_ASSERT(src_stream1);
- pub_src_stream1 = src_stream1;
- src_stream2 = bt_stream_create(src_stream_class);
+ src_stream2 = bt_stream_create(src_stream_class, trace);
BT_ASSERT(src_stream2);
- pub_src_stream2 = src_stream2;
src_stream1_packet1 = bt_packet_create(src_stream1);
BT_ASSERT(src_stream1_packet1);
- pub_src_stream1_packet1 = src_stream1_packet1;
src_stream1_packet2 = bt_packet_create(src_stream1);
BT_ASSERT(src_stream1_packet2);
- pub_src_stream1_packet2 = src_stream1_packet2;
src_stream2_packet1 = bt_packet_create(src_stream2);
BT_ASSERT(src_stream2_packet1);
- pub_src_stream2_packet1 = src_stream2_packet1;
src_stream2_packet2 = bt_packet_create(src_stream2);
BT_ASSERT(src_stream2_packet2);
- pub_src_stream2_packet2 = src_stream2_packet2;
if (debug) {
fprintf(stderr, ":: stream 1: %p\n", src_stream1);
}
bt_object_put_ref(trace);
+ bt_object_put_ref(trace_class);
}
static
void test_no_auto_notifs(void)
{
const struct test_event expected_test_events[] = {
- { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = pub_src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = pub_src_stream1, .packet = pub_src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = pub_src_stream1, .packet = pub_src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = pub_src_stream1, .packet = pub_src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = pub_src_stream2, .packet = NULL, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = pub_src_stream1, .packet = pub_src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = pub_src_stream2, .packet = pub_src_stream2_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = pub_src_stream2, .packet = pub_src_stream2_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = pub_src_stream1, .packet = pub_src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = pub_src_stream1, .packet = pub_src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = pub_src_stream2, .packet = pub_src_stream2_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = pub_src_stream1, .packet = pub_src_stream1_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = pub_src_stream1, .packet = pub_src_stream1_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = pub_src_stream2, .packet = NULL, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = pub_src_stream1, .packet = pub_src_stream1_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = pub_src_stream1, .packet = NULL, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream1, .packet = NULL, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet1, },
+ { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, },
+ { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream2, .packet = NULL, },
+ { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream2, .packet = src_stream2_packet2, },
+ { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream2, .packet = src_stream2_packet2, },
+ { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet1, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream2, .packet = src_stream2_packet2, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet2, },
+ { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet2, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream2, .packet = NULL, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet2, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream1, .packet = NULL, },
{ .type = TEST_EV_TYPE_END, },
{ .type = TEST_EV_TYPE_SENTINEL, },
};
void test_output_port_notification_iterator(void)
{
const struct test_event expected_test_events[] = {
- { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = pub_src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = pub_src_stream1, .packet = pub_src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = pub_src_stream1, .packet = pub_src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = pub_src_stream1, .packet = pub_src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = pub_src_stream2, .packet = NULL, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = pub_src_stream1, .packet = pub_src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = pub_src_stream2, .packet = pub_src_stream2_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = pub_src_stream2, .packet = pub_src_stream2_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = pub_src_stream1, .packet = pub_src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = pub_src_stream1, .packet = pub_src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = pub_src_stream2, .packet = pub_src_stream2_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = pub_src_stream1, .packet = pub_src_stream1_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = pub_src_stream1, .packet = pub_src_stream1_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = pub_src_stream2, .packet = NULL, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = pub_src_stream1, .packet = pub_src_stream1_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = pub_src_stream1, .packet = NULL, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream1, .packet = NULL, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet1, },
+ { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, },
+ { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream2, .packet = NULL, },
+ { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream2, .packet = src_stream2_packet2, },
+ { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream2, .packet = src_stream2_packet2, },
+ { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet1, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream2, .packet = src_stream2_packet2, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet2, },
+ { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet2, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream2, .packet = NULL, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet2, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream1, .packet = NULL, },
{ .type = TEST_EV_TYPE_END, },
{ .type = TEST_EV_TYPE_SENTINEL, },
};
#define NR_TESTS 37
struct user {
- struct bt_trace *tc;
+ struct bt_trace_class *tc;
struct bt_stream_class *sc;
struct bt_event_class *ec;
struct bt_stream *stream;
bt_object_put_ref(event_header_type);
}
-static void create_sc1(struct bt_trace *trace)
+static void create_sc1(struct bt_trace_class *trace_class)
{
int ret;
struct bt_event_class *ec1 = NULL, *ec2 = NULL;
struct bt_stream_class *sc1 = NULL, *ret_stream = NULL;
- sc1 = bt_stream_class_create(trace);
+ sc1 = bt_stream_class_create(trace_class);
BT_ASSERT(sc1);
ret = bt_stream_class_set_name(sc1, "sc1");
BT_ASSERT(ret == 0);
BT_OBJECT_PUT_REF_AND_RESET(sc1);
}
-static void create_sc2(struct bt_trace *trace)
+static void create_sc2(struct bt_trace_class *trace_class)
{
int ret;
struct bt_event_class *ec3 = NULL;
struct bt_stream_class *sc2 = NULL, *ret_stream = NULL;
- sc2 = bt_stream_class_create(trace);
+ sc2 = bt_stream_class_create(trace_class);
BT_ASSERT(sc2);
ret = bt_stream_class_set_name(sc2, "sc2");
BT_ASSERT(ret == 0);
BT_OBJECT_PUT_REF_AND_RESET(sc2);
}
-static void set_trace_packet_header(struct bt_trace *trace)
+static void set_trace_packet_header(struct bt_trace_class *trace_class)
{
struct bt_field_class *packet_header_type;
struct bt_field_class *fc;
"stream_id", fc);
BT_ASSERT(ret == 0);
bt_object_put_ref(fc);
- ret = bt_trace_set_packet_header_field_class(trace,
+ ret = bt_trace_class_set_packet_header_field_class(trace_class,
packet_header_type);
BT_ASSERT(ret == 0);
bt_object_put_ref(packet_header_type);
}
-static struct bt_trace *create_tc1(void)
+static struct bt_trace_class *create_tc1(void)
{
- struct bt_trace *tc1 = NULL;
+ struct bt_trace_class *tc1 = NULL;
- tc1 = bt_trace_create();
+ tc1 = bt_trace_class_create();
BT_ASSERT(tc1);
set_trace_packet_header(tc1);
create_sc1(tc1);
return tc1;
}
-static void init_weak_refs(struct bt_trace *tc,
- struct bt_trace **tc1,
+static void init_weak_refs(struct bt_trace_class *tc,
+ struct bt_trace_class **tc1,
struct bt_stream_class **sc1,
struct bt_stream_class **sc2,
struct bt_event_class **ec1,
struct bt_event_class **ec3)
{
*tc1 = tc;
- *sc1 = bt_trace_borrow_stream_class_by_index(tc, 0);
- *sc2 = bt_trace_borrow_stream_class_by_index(tc, 1);
+ *sc1 = bt_trace_class_borrow_stream_class_by_index(tc, 0);
+ *sc2 = bt_trace_class_borrow_stream_class_by_index(tc, 1);
*ec1 = bt_stream_class_borrow_event_class_by_index(*sc1, 0);
*ec2 = bt_stream_class_borrow_event_class_by_index(*sc1, 1);
*ec3 = bt_stream_class_borrow_event_class_by_index(*sc2, 0);
* of expected reference counts without affecting them by taking
* "real" references to the objects.
*/
- struct bt_trace *tc1 = NULL, *weak_tc1 = NULL;
+ struct bt_trace_class *tc1 = NULL, *weak_tc1 = NULL;
struct bt_stream_class *weak_sc1 = NULL, *weak_sc2 = NULL;
struct bt_event_class *weak_ec1 = NULL, *weak_ec2 = NULL,
*weak_ec3 = NULL;
"TC1 reference count is 1");
/* User A acquires a reference to SC2 from TC1. */
- user_a.sc = bt_trace_borrow_stream_class_by_index(
+ user_a.sc = bt_trace_class_borrow_stream_class_by_index(
user_a.tc, 1);
bt_object_get_ref(user_a.sc);
ok(user_a.sc, "User A acquires SC2 from TC1");