babeltrace/trace-ir/event-class-const.h \
babeltrace/trace-ir/event-class.h \
babeltrace/trace-ir/event-const.h \
- babeltrace/trace-ir/event-header-field.h \
babeltrace/trace-ir/event.h \
babeltrace/trace-ir/field-class-const.h \
babeltrace/trace-ir/field-class.h \
babeltrace/trace-ir/field.h \
babeltrace/trace-ir/packet-const.h \
babeltrace/trace-ir/packet-context-field.h \
- babeltrace/trace-ir/packet-header-field.h \
babeltrace/trace-ir/packet.h \
babeltrace/trace-ir/stream-class-const.h \
babeltrace/trace-ir/stream-class.h \
#include <babeltrace/trace-ir/event-class-const.h>
#include <babeltrace/trace-ir/event-class.h>
#include <babeltrace/trace-ir/event-const.h>
-#include <babeltrace/trace-ir/event-header-field.h>
#include <babeltrace/trace-ir/event.h>
#include <babeltrace/trace-ir/field-class-const.h>
#include <babeltrace/trace-ir/field-class.h>
#include <babeltrace/trace-ir/field.h>
#include <babeltrace/trace-ir/packet-const.h>
#include <babeltrace/trace-ir/packet-context-field.h>
-#include <babeltrace/trace-ir/packet-header-field.h>
#include <babeltrace/trace-ir/packet.h>
#include <babeltrace/trace-ir/stream-class-const.h>
#include <babeltrace/trace-ir/stream-class.h>
const char *bt_common_scope_string(enum bt_scope scope)
{
switch (scope) {
- case BT_SCOPE_PACKET_HEADER:
- return "BT_SCOPE_PACKET_HEADER";
case BT_SCOPE_PACKET_CONTEXT:
return "BT_SCOPE_PACKET_CONTEXT";
- case BT_SCOPE_EVENT_HEADER:
- return "BT_SCOPE_EVENT_HEADER";
case BT_SCOPE_EVENT_COMMON_CONTEXT:
return "BT_SCOPE_EVENT_COMMON_CONTEXT";
case BT_SCOPE_EVENT_SPECIFIC_CONTEXT:
extern const bt_stream *bt_event_borrow_stream_const(
const bt_event *event);
-extern const bt_field *bt_event_borrow_header_field_const(
- const bt_event *event);
-
extern const bt_field *bt_event_borrow_common_context_field_const(
const bt_event *event);
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_EVENT_HEADER_FIELD_H
-#define BABELTRACE_TRACE_IR_EVENT_HEADER_FIELD_H
-
-/*
- * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/* For bt_stream_class, bt_event_header_field, bt_field */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern
-bt_event_header_field *bt_event_header_field_create(
- bt_stream_class *stream_class);
-
-extern
-bt_field *bt_event_header_field_borrow_field(
- bt_event_header_field *field);
-
-extern
-void bt_event_header_field_release(bt_event_header_field *field);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_EVENT_HEADER_FIELD_H */
/* 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;
struct bt_field *payload_field;
{
BT_ASSERT(event);
- if (event->header_field) {
- bt_field_set_is_frozen(
- event->header_field->field, false);
- bt_field_reset(
- event->header_field->field);
- }
-
if (event->common_context_field) {
bt_field_set_is_frozen(
event->common_context_field, false);
* http://www.efficios.com/ctf
*/
-/* For bt_event, bt_event_header_field, bt_event_class, bt_field, bt_packet */
+/* For bt_event, bt_event_class, bt_field, bt_packet */
#include <babeltrace/types.h>
/* For bt_event_status */
extern bt_stream *bt_event_borrow_stream(bt_event *event);
-extern bt_field *bt_event_borrow_header_field(bt_event *event);
-
-extern bt_event_status bt_event_move_header_field(bt_event *event,
- bt_event_header_field *header);
-
extern bt_field *
bt_event_borrow_common_context_field(bt_event *event);
#endif
typedef enum bt_scope {
- BT_SCOPE_PACKET_HEADER,
BT_SCOPE_PACKET_CONTEXT,
- BT_SCOPE_EVENT_HEADER,
BT_SCOPE_EVENT_COMMON_CONTEXT,
BT_SCOPE_EVENT_SPECIFIC_CONTEXT,
BT_SCOPE_EVENT_PAYLOAD,
#include <babeltrace/trace-ir/clock-snapshot-const.h>
/*
- * For bt_packet, bt_packet_header_field, bt_packet_context_field,
- * bt_stream, bt_clock_snapshot
+ * For bt_packet, bt_packet_context_field, bt_stream, bt_clock_snapshot
*/
#include <babeltrace/types.h>
extern const bt_stream *bt_packet_borrow_stream_const(
const bt_packet *packet);
-extern
-const bt_field *bt_packet_borrow_header_field_const(
- const bt_packet *packet);
-
extern
const bt_field *bt_packet_borrow_context_field_const(
const bt_packet *packet);
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_PACKET_HEADER_FIELD_H
-#define BABELTRACE_TRACE_IR_PACKET_HEADER_FIELD_H
-
-/*
- * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/* For bt_trace_class, bt_packet_header_field, bt_field */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern
-bt_packet_header_field *bt_packet_header_field_create(
- bt_trace_class *trace_class);
-
-extern
-bt_field *bt_packet_header_field_borrow_field(
- bt_packet_header_field *field);
-
-extern
-void bt_packet_header_field_release(
- bt_packet_header_field *field);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_PACKET_HEADER_FIELD_H */
struct bt_packet {
struct bt_object base;
- struct bt_field_wrapper *header_field;
struct bt_field_wrapper *context_field;
struct bt_stream *stream;
struct bt_clock_snapshot *default_beginning_cs;
* http://www.efficios.com/ctf
*/
-/* For bt_packet, bt_packet_header_field, bt_packet_context_field, bt_stream */
+/* For bt_packet, bt_packet_context_field, bt_stream */
#include <babeltrace/types.h>
/* For bt_packet_status */
extern bt_stream *bt_packet_borrow_stream(bt_packet *packet);
-extern
-bt_field *bt_packet_borrow_header_field(bt_packet *packet);
-
-extern
-bt_packet_status bt_packet_move_header_field(bt_packet *packet,
- bt_packet_header_field *header);
-
extern
bt_field *bt_packet_borrow_context_field(bt_packet *packet);
#include <glib.h>
struct bt_resolve_field_path_context {
- struct bt_field_class *packet_header;
struct bt_field_class *packet_context;
- struct bt_field_class *event_header;
struct bt_field_class *event_common_context;
struct bt_field_class *event_specific_context;
struct bt_field_class *event_payload;
/*
* For bt_bool, bt_trace_class, bt_stream_class, bt_event_class,
- * bt_stream_class, bt_event_header_field, bt_packet_context_field
+ * bt_stream_class
*/
#include <babeltrace/types.h>
bt_stream_class_borrow_packet_context_field_class_const(
const bt_stream_class *stream_class);
-extern const bt_field_class *
-bt_stream_class_borrow_event_header_field_class_const(
- const bt_stream_class *stream_class);
-
extern const bt_field_class *
bt_stream_class_borrow_event_common_context_field_class_const(
const bt_stream_class *stream_class);
bool packets_have_default_beginning_cs;
bool packets_have_default_end_cs;
struct bt_field_class *packet_context_fc;
- struct bt_field_class *event_header_fc;
struct bt_field_class *event_common_context_fc;
struct bt_clock_class *default_clock_class;
/* Array of `struct bt_event_class *` */
GPtrArray *event_classes;
- /* Pool of `struct bt_field_wrapper *` */
- struct bt_object_pool event_header_field_pool;
-
/* Pool of `struct bt_field_wrapper *` */
struct bt_object_pool packet_context_field_pool;
bt_stream_class *stream_class,
bt_field_class *field_class);
-extern bt_stream_class_status
-bt_stream_class_set_event_header_field_class(
- bt_stream_class *stream_class,
- bt_field_class *field_class);
-
extern bt_stream_class_status
bt_stream_class_set_event_common_context_field_class(
bt_stream_class *stream_class,
bt_trace_class_borrow_environment_entry_value_by_name_const(
const bt_trace_class *trace_class, const char *name);
-extern const bt_field_class *
-bt_trace_class_borrow_packet_header_field_class_const(
- const bt_trace_class *trace_class);
-
extern uint64_t bt_trace_class_get_stream_class_count(
const bt_trace_class *trace_class);
/* 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_trace_class *trace_class,
const char *name, const char *value);
-extern bt_trace_class_status bt_trace_class_set_packet_header_field_class(
- bt_trace_class *trace_class,
- bt_field_class *packet_header_field_class);
-
extern bt_stream_class *bt_trace_class_borrow_stream_class_by_index(
bt_trace_class *trace_class, uint64_t index);
*/
GHashTable *stream_classes_stream_count;
- struct bt_field_class *packet_header_fc;
GArray *is_static_listeners;
bool is_static;
bool in_remove_listener;
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_class->name.value) {
BUF_APPEND(", %sname=\"%s\"",
PRFIELD(trace_class->name.value));
PRFIELD(trace_class->stream_classes->len));
}
- BUF_APPEND(", %spacket-header-fc-addr=%p, "
- "%sassigns-auto-sc-id=%d",
- PRFIELD(trace_class->packet_header_fc),
+ BUF_APPEND(", %sassigns-auto-sc-id=%d",
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,
}
BUF_APPEND(", %spacket-context-fc-addr=%p, "
- "%sevent-header-fc-addr=%p, %sevent-common-context-fc-addr=%p",
+ "%sevent-common-context-fc-addr=%p",
PRFIELD(stream_class->packet_context_fc),
- PRFIELD(stream_class->event_header_fc),
PRFIELD(stream_class->event_common_context_fc));
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);
- SET_TMP_PREFIX("ehf-pool-");
- format_object_pool(buf_ch, extended, prefix,
- &stream_class->event_header_field_pool);
SET_TMP_PREFIX("pcf-pool-");
format_object_pool(buf_ch, extended, prefix,
&stream_class->packet_context_field_pool);
return;
}
- BUF_APPEND(", %sis-frozen=%d, %sheader-field-addr=%p, "
- "%scontext-field-addr=%p",
+ BUF_APPEND(", %sis-frozen=%d, %scontext-field-addr=%p",
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_const(packet);
if (!stream) {
return;
}
- BUF_APPEND(", %sis-frozen=%d, %sheader-field-addr=%p, "
+ BUF_APPEND(", %sis-frozen=%d, "
"%scommon-context-field-addr=%p, "
"%sspecific-context-field-addr=%p, "
"%spayload-field-addr=%p, ",
PRFIELD(event->frozen),
- PRFIELD(event->header_field ?
- event->header_field->field : NULL),
PRFIELD(event->common_context_field),
PRFIELD(event->specific_context_field),
PRFIELD(event->payload_field));
clock-snapshot.c \
event.c \
event-class.c \
- event-header-field.c \
field-wrapper.c \
field.c \
field-class.c \
field-path.c \
packet.c \
packet-context-field.c \
- packet-header-field.c \
resolve-field-path.c \
stream.c \
stream-class.c \
{
int ret;
struct bt_stream_class *stream_class;
- struct bt_trace_class *trace_class;
struct bt_resolve_field_path_context resolve_ctx = {
- .packet_header = NULL,
.packet_context = NULL,
- .event_header = NULL,
.event_common_context = NULL,
.event_specific_context = field_class,
.event_payload = NULL,
"%!+F", field_class);
stream_class = bt_event_class_borrow_stream_class_inline(
event_class);
- 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 =
stream_class->event_common_context_fc;
{
int ret;
struct bt_stream_class *stream_class;
- struct bt_trace_class *trace_class;
struct bt_resolve_field_path_context resolve_ctx = {
- .packet_header = NULL,
.packet_context = NULL,
- .event_header = NULL,
.event_common_context = NULL,
.event_specific_context = NULL,
.event_payload = field_class,
field_class);
stream_class = bt_event_class_borrow_stream_class_inline(
event_class);
- 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 =
stream_class->event_common_context_fc;
resolve_ctx.event_specific_context = event_class->specific_context_fc;
+++ /dev/null
-/*
- * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define BT_LOG_TAG "EVENT-HEADER-FIELD"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/event-header-field.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/trace-ir/field-internal.h>
-#include <babeltrace/trace-ir/field-wrapper-internal.h>
-#include <glib.h>
-
-struct bt_field *bt_event_header_field_borrow_field(
- struct bt_event_header_field *header_field)
-{
- struct bt_field_wrapper *field_wrapper = (void *) header_field;
-
- BT_ASSERT_PRE_NON_NULL(field_wrapper, "Event header field");
- return (void *) field_wrapper->field;
-}
-
-void bt_event_header_field_release(
- struct bt_event_header_field *header_field)
-{
- struct bt_field_wrapper *field_wrapper = (void *) header_field;
-
- BT_ASSERT_PRE_NON_NULL(field_wrapper, "Event header field");
-
- /*
- * Do not recycle because the pool could be destroyed at this
- * point. This function is only called when there's an error
- * anyway because the goal of an event header field wrapper is
- * to eventually move it to an event with bt_event_move_header()
- * after creating it.
- */
- bt_field_wrapper_destroy(field_wrapper);
-}
-
-struct bt_event_header_field *bt_event_header_field_create(
- struct bt_stream_class *stream_class)
-{
- struct bt_field_wrapper *field_wrapper;
-
- BT_ASSERT_PRE_NON_NULL(stream_class, "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 class: %!+S",
- stream_class);
- field_wrapper = bt_field_wrapper_create(
- &stream_class->event_header_field_pool,
- (void *) stream_class->event_header_fc);
- if (!field_wrapper) {
- BT_LIB_LOGE("Cannot allocate one event header field from stream class: "
- "%![sc-]+S", stream_class);
- goto error;
- }
-
- BT_ASSERT(field_wrapper->field);
- bt_stream_class_freeze(stream_class);
- goto end;
-
-error:
- if (field_wrapper) {
- bt_field_wrapper_destroy(field_wrapper);
- field_wrapper = NULL;
- }
-
-end:
- return (void *) field_wrapper;
-}
BT_LIB_LOGD("Setting event's frozen state: %!+e, is-frozen=%d",
event, is_frozen);
- if (event->header_field) {
- BT_LOGD_STR("Setting event's header field's frozen state.");
- bt_field_set_is_frozen(
- event->header_field->field, is_frozen);
- }
-
if (event->common_context_field) {
BT_LOGD_STR("Setting event's common context field's frozen state.");
bt_field_set_is_frozen(
bt_packet_set_is_frozen(event->packet, is_frozen);
}
-static
-void recycle_event_header_field(struct bt_field_wrapper *field_wrapper,
- struct bt_stream_class *stream_class)
-{
- BT_ASSERT(field_wrapper);
- BT_LIB_LOGD("Recycling event header field: "
- "addr=%p, %![sc-]+S, %![field-]+f", field_wrapper,
- stream_class, field_wrapper->field);
- bt_object_pool_recycle_object(
- &stream_class->event_header_field_pool,
- field_wrapper);
-}
-
-static inline
-struct bt_field_wrapper *create_event_header_field(
- struct bt_stream_class *stream_class)
-{
- struct bt_field_wrapper *field_wrapper = NULL;
-
- field_wrapper = bt_field_wrapper_create(
- &stream_class->event_header_field_pool,
- stream_class->event_header_fc);
- if (!field_wrapper) {
- goto error;
- }
-
- goto end;
-
-error:
- if (field_wrapper) {
- recycle_event_header_field(field_wrapper, stream_class);
- field_wrapper = NULL;
- }
-
-end:
- return field_wrapper;
-}
-
BT_HIDDEN
struct bt_event *bt_event_new(struct bt_event_class *event_class)
{
bt_object_init_unique(&event->base);
stream_class = bt_event_class_borrow_stream_class(event_class);
BT_ASSERT(stream_class);
-
- if (stream_class->event_header_fc) {
- event->header_field = create_event_header_field(stream_class);
- if (!event->header_field) {
- BT_LOGE_STR("Cannot create event header field.");
- goto error;
- }
- }
-
fc = stream_class->event_common_context_fc;
if (fc) {
event->common_context_field = bt_field_create(fc);
return bt_event_borrow_stream((void *) event);
}
-struct bt_field *bt_event_borrow_header_field(struct bt_event *event)
-{
- BT_ASSERT_PRE_NON_NULL(event, "Event");
- return event->header_field ? event->header_field->field : NULL;
-}
-
-const struct bt_field *bt_event_borrow_header_field_const(
- const struct bt_event *event)
-{
- BT_ASSERT_PRE_NON_NULL(event, "Event");
- return event->header_field ? event->header_field->field : NULL;
-}
-
struct bt_field *bt_event_borrow_common_context_field(struct bt_event *event)
{
BT_ASSERT_PRE_NON_NULL(event, "Event");
return event->payload_field;
}
-static
-void release_event_header_field(struct bt_field_wrapper *field_wrapper,
- struct bt_event *event)
-{
- if (!event->class) {
- bt_field_wrapper_destroy(field_wrapper);
- } else {
- struct bt_stream_class *stream_class =
- bt_event_class_borrow_stream_class(event->class);
-
- BT_ASSERT(stream_class);
- recycle_event_header_field(field_wrapper, stream_class);
- }
-}
-
BT_HIDDEN
void bt_event_destroy(struct bt_event *event)
{
BT_ASSERT(event);
BT_LIB_LOGD("Destroying event: %!+e", event);
- if (event->header_field) {
- BT_LOGD_STR("Releasing event's header field.");
- release_event_header_field(event->header_field, event);
- event->header_field = NULL;
- }
-
if (event->common_context_field) {
BT_LOGD_STR("Destroying event's stream event context field.");
bt_field_destroy(event->common_context_field);
{
return bt_event_borrow_packet((void *) event);
}
-
-enum bt_event_status bt_event_move_header_field(struct bt_event *event,
- struct bt_event_header_field *header_field)
-{
- struct bt_stream_class *stream_class;
- struct bt_field_wrapper *field_wrapper = (void *) header_field;
-
- BT_ASSERT_PRE_NON_NULL(event, "Event");
- BT_ASSERT_PRE_NON_NULL(field_wrapper, "Header field");
- BT_ASSERT_PRE_EVENT_HOT(event);
- stream_class = bt_event_class_borrow_stream_class_inline(event->class);
- BT_ASSERT_PRE(stream_class->event_header_fc,
- "Stream class has no event header field class: %!+S",
- stream_class);
-
- /* Recycle current header field: always exists */
- BT_ASSERT(event->header_field);
- recycle_event_header_field(event->header_field, stream_class);
-
- /* Move new field */
- event->header_field = field_wrapper;
- return BT_EVENT_STATUS_OK;
-}
+++ /dev/null
-/*
- * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define BT_LOG_TAG "PACKET-HEADER-FIELD"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/packet-header-field.h>
-#include <babeltrace/trace-ir/trace-internal.h>
-#include <babeltrace/trace-ir/field-wrapper-internal.h>
-#include <babeltrace/trace-ir/field-internal.h>
-#include <glib.h>
-
-struct bt_field *bt_packet_header_field_borrow_field(
- struct bt_packet_header_field *header_field)
-{
- struct bt_field_wrapper *field_wrapper = (void *) header_field;
-
- BT_ASSERT_PRE_NON_NULL(field_wrapper, "Packet header field");
- return (void *) field_wrapper->field;
-}
-
-void bt_packet_header_field_release(
- struct bt_packet_header_field *header_field)
-{
- struct bt_field_wrapper *field_wrapper = (void *) header_field;
-
- BT_ASSERT_PRE_NON_NULL(field_wrapper, "Packet header field");
-
- /*
- * Do not recycle because the pool could be destroyed at this
- * point. This function is only called when there's an error
- * anyway because the goal of a packet header field wrapper is
- * to eventually move it to a packet with
- * bt_packet_move_header() after creating it.
- */
- bt_field_wrapper_destroy(field_wrapper);
-}
-
-struct bt_packet_header_field *bt_packet_header_field_create(
- struct bt_trace_class *tc)
-{
- struct bt_field_wrapper *field_wrapper;
-
- 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(
- &tc->packet_header_field_pool,
- (void *) tc->packet_header_fc);
- if (!field_wrapper) {
- BT_LIB_LOGE("Cannot allocate one packet header field from trace class: "
- "%![tc-]+T", tc);
- goto error;
- }
-
- BT_ASSERT(field_wrapper->field);
- bt_trace_class_freeze(tc);
- goto end;
-
-error:
- if (field_wrapper) {
- bt_field_wrapper_destroy(field_wrapper);
- field_wrapper = NULL;
- }
-
-end:
- return (void *) field_wrapper;
-}
return bt_packet_borrow_stream((void *) packet);
}
-struct bt_field *bt_packet_borrow_header_field(struct bt_packet *packet)
-{
- BT_ASSERT_PRE_NON_NULL(packet, "Packet");
- return packet->header_field ? packet->header_field->field : NULL;
-}
-
-const struct bt_field *bt_packet_borrow_header_field_const(
- const struct bt_packet *packet)
-{
- return bt_packet_borrow_header_field((void *) packet);
-}
-
struct bt_field *bt_packet_borrow_context_field(struct bt_packet *packet)
{
BT_ASSERT_PRE_NON_NULL(packet, "Packet");
BT_LIB_LOGD("Setting packet's frozen state: %![packet-]+a, "
"is-frozen=%d", packet, is_frozen);
- if (packet->header_field) {
- BT_LOGD_STR("Setting packet's header field's frozen state.");
- bt_field_set_is_frozen(packet->header_field->field,
- is_frozen);
- }
-
if (packet->context_field) {
BT_LOGD_STR("Setting packet's context field's frozen state.");
bt_field_set_is_frozen(packet->context_field->field,
BT_LIB_LOGD("Resetting packet: %!+a", packet);
bt_packet_set_is_frozen(packet, false);
- if (packet->header_field) {
- bt_field_set_is_frozen(packet->header_field->field, false);
- bt_field_reset(packet->header_field->field);
- }
-
if (packet->context_field) {
bt_field_set_is_frozen(packet->context_field->field, false);
bt_field_reset(packet->context_field->field);
reset_counter_snapshots(packet);
}
-static
-void recycle_header_field(struct bt_field_wrapper *header_field,
- struct bt_trace_class *tc)
-{
- BT_ASSERT(header_field);
- BT_LIB_LOGD("Recycling packet header field: "
- "addr=%p, %![tc-]+T, %![field-]+f", header_field,
- tc, header_field->field);
- bt_object_pool_recycle_object(&tc->packet_header_field_pool,
- header_field);
-}
-
static
void recycle_context_field(struct bt_field_wrapper *context_field,
struct bt_stream_class *stream_class)
{
BT_LIB_LOGD("Destroying packet: %!+a", packet);
- if (packet->header_field) {
- if (packet->stream) {
- BT_LOGD_STR("Recycling packet's header field.");
- recycle_header_field(packet->header_field,
- bt_stream_class_borrow_trace_class_inline(
- packet->stream->class));
- } else {
- bt_field_wrapper_destroy(packet->header_field);
- }
-
- packet->header_field = NULL;
- }
-
if (packet->context_field) {
if (packet->stream) {
BT_LOGD_STR("Recycling packet's context field.");
trace_class = bt_stream_class_borrow_trace_class_inline(stream->class);
BT_ASSERT(trace_class);
- if (trace_class->packet_header_fc) {
- BT_LOGD_STR("Creating initial packet header field.");
- packet->header_field = bt_field_wrapper_create(
- &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;
- }
- }
-
if (stream->class->packet_context_fc) {
BT_LOGD_STR("Creating initial packet context field.");
packet->context_field = bt_field_wrapper_create(
return (void *) packet;
}
-enum bt_packet_status bt_packet_move_header_field(struct bt_packet *packet,
- struct bt_packet_header_field *header_field)
-{
- 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);
- 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 class: %!+T", tc);
- BT_ASSERT_PRE(field_wrapper->field->class ==
- tc->packet_header_fc,
- "Unexpected packet header field's class: "
- "%![fc-]+F, %![expected-fc-]+F", field_wrapper->field->class,
- tc->packet_header_fc);
-
- /* Recycle current header field: always exists */
- BT_ASSERT(packet->header_field);
- recycle_header_field(packet->header_field, tc);
-
- /* Move new field */
- packet->header_field = field_wrapper;
- return BT_PACKET_STATUS_OK;
-}
-
enum bt_packet_status bt_packet_move_context_field(struct bt_packet *packet,
struct bt_packet_context_field *context_field)
{
stream_class);
BT_ASSERT_PRE(field_wrapper->field->class ==
stream_class->packet_context_fc,
- "Unexpected packet header field's class: "
+ "Unexpected packet context field's class: "
"%![fc-]+F, %![expected-fc-]+F", field_wrapper->field->class,
stream_class->packet_context_fc);
struct bt_field_path *field_path = NULL;
int ret;
- ret = find_field_class(ctx->packet_header, BT_SCOPE_PACKET_HEADER,
- fc, &field_path);
- if (ret || field_path) {
- goto end;
- }
-
ret = find_field_class(ctx->packet_context, BT_SCOPE_PACKET_CONTEXT,
fc, &field_path);
if (ret || field_path) {
goto end;
}
- ret = find_field_class(ctx->event_header, BT_SCOPE_EVENT_HEADER,
- fc, &field_path);
- if (ret || field_path) {
- goto end;
- }
-
ret = find_field_class(ctx->event_common_context,
BT_SCOPE_EVENT_COMMON_CONTEXT, fc, &field_path);
if (ret || field_path) {
struct bt_resolve_field_path_context *ctx, enum bt_scope scope)
{
switch (scope) {
- case BT_SCOPE_PACKET_HEADER:
- return ctx->packet_header;
case BT_SCOPE_PACKET_CONTEXT:
return ctx->packet_context;
- case BT_SCOPE_EVENT_HEADER:
- return ctx->event_header;
case BT_SCOPE_EVENT_COMMON_CONTEXT:
return ctx->event_common_context;
case BT_SCOPE_EVENT_SPECIFIC_CONTEXT:
stream_class->name.value = NULL;
}
- BT_LOGD_STR("Putting event header field class.");
- BT_OBJECT_PUT_REF_AND_RESET(stream_class->event_header_fc);
BT_LOGD_STR("Putting packet context field class.");
BT_OBJECT_PUT_REF_AND_RESET(stream_class->packet_context_fc);
BT_LOGD_STR("Putting event common context field class.");
BT_OBJECT_PUT_REF_AND_RESET(stream_class->event_common_context_fc);
- bt_object_pool_finalize(&stream_class->event_header_field_pool);
bt_object_pool_finalize(&stream_class->packet_context_field_pool);
g_free(stream_class);
}
goto error;
}
- ret = bt_object_pool_initialize(&stream_class->event_header_field_pool,
- (bt_object_pool_new_object_func) bt_field_wrapper_new,
- (bt_object_pool_destroy_object_func) free_field_wrapper,
- stream_class);
- if (ret) {
- BT_LOGE("Failed to initialize event header field pool: ret=%d",
- ret);
- goto error;
- }
-
ret = bt_object_pool_initialize(&stream_class->packet_context_field_pool,
(bt_object_pool_new_object_func) bt_field_wrapper_new,
(bt_object_pool_destroy_object_func) free_field_wrapper,
{
int ret;
struct bt_resolve_field_path_context resolve_ctx = {
- .packet_header = NULL,
.packet_context = field_class,
- .event_header = NULL,
.event_common_context = NULL,
.event_specific_context = NULL,
.event_payload = NULL,
BT_FIELD_CLASS_TYPE_STRUCTURE,
"Packet context field class is not a structure field class: %!+F",
field_class);
- resolve_ctx.packet_header =
- bt_stream_class_borrow_trace_class_inline(stream_class)->packet_header_fc;
ret = bt_resolve_field_paths(field_class, &resolve_ctx);
if (ret) {
/*
return ret;
}
-const struct bt_field_class *bt_stream_class_borrow_event_header_field_class_const(
- const struct bt_stream_class *stream_class)
-{
- BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- return stream_class->event_header_fc;
-}
-
-enum bt_stream_class_status bt_stream_class_set_event_header_field_class(
- struct bt_stream_class *stream_class,
- struct bt_field_class *field_class)
-{
- int ret;
- struct bt_resolve_field_path_context resolve_ctx = {
- .packet_header = NULL,
- .packet_context = NULL,
- .event_header = field_class,
- .event_common_context = NULL,
- .event_specific_context = NULL,
- .event_payload = NULL,
- };
-
- BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
- BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
- BT_ASSERT_PRE(bt_field_class_get_type(field_class) ==
- BT_FIELD_CLASS_TYPE_STRUCTURE,
- "Event header field class is not a structure field class: %!+F",
- field_class);
- resolve_ctx.packet_header =
- 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) {
- /*
- * This is the only reason for which
- * bt_resolve_field_paths() can fail: anything else
- * would be because a precondition is not satisfied.
- */
- ret = BT_STREAM_CLASS_STATUS_NOMEM;
- goto end;
- }
-
- 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);
- bt_field_class_freeze(field_class);
- BT_LIB_LOGV("Set stream class's event header field class: %!+S",
- stream_class);
-
-end:
- return ret;
-}
-
const struct bt_field_class *
bt_stream_class_borrow_event_common_context_field_class_const(
const struct bt_stream_class *stream_class)
{
int ret;
struct bt_resolve_field_path_context resolve_ctx = {
- .packet_header = NULL,
.packet_context = NULL,
- .event_header = NULL,
.event_common_context = field_class,
.event_specific_context = NULL,
.event_payload = NULL,
BT_FIELD_CLASS_TYPE_STRUCTURE,
"Event common context field class is not a structure field class: %!+F",
field_class);
- resolve_ctx.packet_header =
- 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);
if (ret) {
/*
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.");
tc->stream_classes = NULL;
}
- BT_LOGD_STR("Putting packet header field class.");
- 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(bt_self_component *self_comp)
{
struct bt_trace_class *tc = NULL;
- int ret;
BT_ASSERT_PRE_NON_NULL(self_comp, "Self component");
BT_LOGD_STR("Creating default trace class object.");
}
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;
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;
-}
-
-enum bt_trace_class_status 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 class is not a structure field class: %!+F",
- field_class);
- ret = bt_resolve_field_paths(field_class, &resolve_ctx);
- if (ret) {
- /*
- * This is the only reason for which
- * bt_resolve_field_paths() can fail: anything else
- * would be because a precondition is not satisfied.
- */
- ret = BT_TRACE_CLASS_STATUS_NOMEM;
- 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 class: %!+T", tc);
-
-end:
- return ret;
-}
-
BT_HIDDEN
void _bt_trace_class_freeze(const struct bt_trace_class *tc)
{
- /* The packet header field class is already frozen */
BT_ASSERT(tc);
BT_LIB_LOGD("Freezing trace class: %!+T", tc);
((struct bt_trace_class *) tc)->frozen = true;
BT_HIDDEN
void _bt_trace_freeze(const struct bt_trace *trace)
{
- /* The packet header field class is already frozen */
BT_ASSERT(trace);
BT_LIB_LOGD("Freezing trace's class: %!+T", trace->class);
bt_trace_class_freeze(trace->class);
ctf-meta-update-default-clock-classes.c \
ctf-meta-update-text-array-sequence.c \
ctf-meta-update-value-storing-indexes.c \
+ ctf-meta-warn-meaningless-header-fields.c \
ctf-meta-translate.c \
ctf-meta-resolve.c
} scopes;
/* Root scope being visited */
- bt_scope root_scope;
+ enum ctf_scope root_scope;
field_class_stack *field_class_stack;
struct ctf_field_class *cur_fc;
};
/* TSDL dynamic scope prefixes as defined in CTF Section 7.3.2 */
static const char * const absolute_path_prefixes[] = {
- [BT_SCOPE_PACKET_HEADER] = "trace.packet.header.",
- [BT_SCOPE_PACKET_CONTEXT] = "stream.packet.context.",
- [BT_SCOPE_EVENT_HEADER] = "stream.event.header.",
- [BT_SCOPE_EVENT_COMMON_CONTEXT] = "stream.event.context.",
- [BT_SCOPE_EVENT_SPECIFIC_CONTEXT] = "event.context.",
- [BT_SCOPE_EVENT_PAYLOAD] = "event.fields.",
+ [CTF_SCOPE_PACKET_HEADER] = "trace.packet.header.",
+ [CTF_SCOPE_PACKET_CONTEXT] = "stream.packet.context.",
+ [CTF_SCOPE_EVENT_HEADER] = "stream.event.header.",
+ [CTF_SCOPE_EVENT_COMMON_CONTEXT] = "stream.event.context.",
+ [CTF_SCOPE_EVENT_SPECIFIC_CONTEXT] = "event.context.",
+ [CTF_SCOPE_EVENT_PAYLOAD] = "event.fields.",
};
/* Number of path tokens used for the absolute prefixes */
static const uint64_t absolute_path_prefix_ptoken_counts[] = {
- [BT_SCOPE_PACKET_HEADER] = 3,
- [BT_SCOPE_PACKET_CONTEXT] = 3,
- [BT_SCOPE_EVENT_HEADER] = 3,
- [BT_SCOPE_EVENT_COMMON_CONTEXT] = 3,
- [BT_SCOPE_EVENT_SPECIFIC_CONTEXT] = 2,
- [BT_SCOPE_EVENT_PAYLOAD] = 2,
+ [CTF_SCOPE_PACKET_HEADER] = 3,
+ [CTF_SCOPE_PACKET_CONTEXT] = 3,
+ [CTF_SCOPE_EVENT_HEADER] = 3,
+ [CTF_SCOPE_EVENT_COMMON_CONTEXT] = 3,
+ [CTF_SCOPE_EVENT_SPECIFIC_CONTEXT] = 2,
+ [CTF_SCOPE_EVENT_PAYLOAD] = 2,
};
static
*/
static
struct ctf_field_class *borrow_class_from_ctx(struct resolve_context *ctx,
- bt_scope scope)
+ enum ctf_scope scope)
{
switch (scope) {
- case BT_SCOPE_PACKET_HEADER:
+ case CTF_SCOPE_PACKET_HEADER:
return ctx->scopes.packet_header;
- case BT_SCOPE_PACKET_CONTEXT:
+ case CTF_SCOPE_PACKET_CONTEXT:
return ctx->scopes.packet_context;
- case BT_SCOPE_EVENT_HEADER:
+ case CTF_SCOPE_EVENT_HEADER:
return ctx->scopes.event_header;
- case BT_SCOPE_EVENT_COMMON_CONTEXT:
+ case CTF_SCOPE_EVENT_COMMON_CONTEXT:
return ctx->scopes.event_common_context;
- case BT_SCOPE_EVENT_SPECIFIC_CONTEXT:
+ case CTF_SCOPE_EVENT_SPECIFIC_CONTEXT:
return ctx->scopes.event_spec_context;
- case BT_SCOPE_EVENT_PAYLOAD:
+ case CTF_SCOPE_EVENT_PAYLOAD:
return ctx->scopes.event_payload;
default:
abort();
* is found to be relative.
*/
static
-bt_scope get_root_scope_from_absolute_pathstr(const char *pathstr)
+enum ctf_scope get_root_scope_from_absolute_pathstr(const char *pathstr)
{
- bt_scope scope;
- bt_scope ret = -1;
+ enum ctf_scope scope;
+ enum ctf_scope ret = -1;
const size_t prefixes_count = sizeof(absolute_path_prefixes) /
sizeof(*absolute_path_prefixes);
- for (scope = BT_SCOPE_PACKET_HEADER; scope < BT_SCOPE_PACKET_HEADER +
+ for (scope = CTF_SCOPE_PACKET_HEADER; scope < CTF_SCOPE_PACKET_HEADER +
prefixes_count; scope++) {
/*
* Chech if path string starts with a known absolute
* object.
*/
switch (field_path->root) {
- case BT_SCOPE_PACKET_HEADER:
+ case CTF_SCOPE_PACKET_HEADER:
if (ctx->tc->is_translated) {
BT_LOGE("Trace class is already translated: "
"root-scope=%s",
}
break;
- case BT_SCOPE_PACKET_CONTEXT:
- case BT_SCOPE_EVENT_HEADER:
- case BT_SCOPE_EVENT_COMMON_CONTEXT:
+ case CTF_SCOPE_PACKET_CONTEXT:
+ case CTF_SCOPE_EVENT_HEADER:
+ case CTF_SCOPE_EVENT_COMMON_CONTEXT:
if (!ctx->sc) {
BT_LOGE("No current stream class: "
"root-scope=%s",
}
break;
- case BT_SCOPE_EVENT_SPECIFIC_CONTEXT:
- case BT_SCOPE_EVENT_PAYLOAD:
+ case CTF_SCOPE_EVENT_SPECIFIC_CONTEXT:
+ case CTF_SCOPE_EVENT_PAYLOAD:
if (!ctx->ec) {
BT_LOGE("No current event class: "
"root-scope=%s",
struct ctf_field_path *field_path, struct resolve_context *ctx)
{
int ret = 0;
- bt_scope root_scope;
+ enum ctf_scope root_scope;
GList *ptokens = NULL;
/* Convert path string to path tokens */
* Resolves the root field class corresponding to the scope `root_scope`.
*/
static
-int resolve_root_class(bt_scope root_scope, struct resolve_context *ctx)
+int resolve_root_class(enum ctf_scope root_scope, struct resolve_context *ctx)
{
int ret;
ctx->ec = ec;
ctx->scopes.event_spec_context = ec->spec_context_fc;
- ret = resolve_root_class(BT_SCOPE_EVENT_COMMON_CONTEXT, ctx);
+ ret = resolve_root_class(CTF_SCOPE_EVENT_COMMON_CONTEXT, ctx);
if (ret) {
BT_LOGE("Cannot resolve event specific context field class: "
"ret=%d", ret);
}
ctx->scopes.event_payload = ec->payload_fc;
- ret = resolve_root_class(BT_SCOPE_EVENT_PAYLOAD, ctx);
+ ret = resolve_root_class(CTF_SCOPE_EVENT_PAYLOAD, ctx);
if (ret) {
BT_LOGE("Cannot resolve event payload field class: "
"ret=%d", ret);
if (!sc->is_translated) {
ctx->scopes.packet_context = sc->packet_context_fc;
- ret = resolve_root_class(BT_SCOPE_PACKET_CONTEXT, ctx);
+ ret = resolve_root_class(CTF_SCOPE_PACKET_CONTEXT, ctx);
if (ret) {
BT_LOGE("Cannot resolve packet context field class: "
"ret=%d", ret);
}
ctx->scopes.event_header = sc->event_header_fc;
- ret = resolve_root_class(BT_SCOPE_EVENT_HEADER, ctx);
+ ret = resolve_root_class(CTF_SCOPE_EVENT_HEADER, ctx);
if (ret) {
BT_LOGE("Cannot resolve event header field class: "
"ret=%d", ret);
}
ctx->scopes.event_common_context = sc->event_common_context_fc;
- ret = resolve_root_class(BT_SCOPE_EVENT_SPECIFIC_CONTEXT, ctx);
+ ret = resolve_root_class(CTF_SCOPE_EVENT_SPECIFIC_CONTEXT, ctx);
if (ret) {
BT_LOGE("Cannot resolve event common context field class: "
"ret=%d", ret);
.event_spec_context = NULL,
.event_payload = NULL,
},
- .root_scope = BT_SCOPE_PACKET_HEADER,
+ .root_scope = CTF_SCOPE_PACKET_HEADER,
.cur_fc = NULL,
};
if (!tc->is_translated) {
ctx.scopes.packet_header = tc->packet_header_fc;
- ret = resolve_root_class(BT_SCOPE_PACKET_HEADER, &ctx);
+ ret = resolve_root_class(CTF_SCOPE_PACKET_HEADER, &ctx);
if (ret) {
BT_LOGE("Cannot resolve packet header field class: "
"ret=%d", ret);
#include "ctf-meta-visitors.h"
+struct ctx {
+ bt_trace_class *ir_tc;
+ bt_stream_class *ir_sc;
+ struct ctf_trace_class *tc;
+ struct ctf_stream_class *sc;
+ struct ctf_event_class *ec;
+ enum ctf_scope scope;
+};
+
static inline
-bt_field_class *ctf_field_class_to_ir(bt_trace_class *ir_tc,
- struct ctf_field_class *fc,
- struct ctf_trace_class *tc,
- struct ctf_stream_class *sc,
- struct ctf_event_class *ec);
+bt_field_class *ctf_field_class_to_ir(struct ctx *ctx,
+ struct ctf_field_class *fc);
static inline
void ctf_field_class_int_set_props(struct ctf_field_class_int *fc,
}
static inline
-bt_field_class *ctf_field_class_int_to_ir(bt_trace_class *ir_tc,
+bt_field_class *ctf_field_class_int_to_ir(struct ctx *ctx,
struct ctf_field_class_int *fc)
{
bt_field_class *ir_fc;
if (fc->is_signed) {
- ir_fc = bt_field_class_signed_integer_create(ir_tc);
+ ir_fc = bt_field_class_signed_integer_create(ctx->ir_tc);
} else {
- ir_fc = bt_field_class_unsigned_integer_create(ir_tc);
+ ir_fc = bt_field_class_unsigned_integer_create(ctx->ir_tc);
}
BT_ASSERT(ir_fc);
}
static inline
-bt_field_class *ctf_field_class_enum_to_ir(bt_trace_class *ir_tc,
+bt_field_class *ctf_field_class_enum_to_ir(struct ctx *ctx,
struct ctf_field_class_enum *fc)
{
int ret;
uint64_t i;
if (fc->base.is_signed) {
- ir_fc = bt_field_class_signed_enumeration_create(ir_tc);
+ ir_fc = bt_field_class_signed_enumeration_create(ctx->ir_tc);
} else {
- ir_fc = bt_field_class_unsigned_enumeration_create(ir_tc);
+ ir_fc = bt_field_class_unsigned_enumeration_create(ctx->ir_tc);
}
BT_ASSERT(ir_fc);
}
static inline
-bt_field_class *ctf_field_class_float_to_ir(bt_trace_class *ir_tc,
+bt_field_class *ctf_field_class_float_to_ir(struct ctx *ctx,
struct ctf_field_class_float *fc)
{
bt_field_class *ir_fc;
- ir_fc = bt_field_class_real_create(ir_tc);
+ ir_fc = bt_field_class_real_create(ctx->ir_tc);
BT_ASSERT(ir_fc);
if (fc->base.size == 32) {
}
static inline
-bt_field_class *ctf_field_class_string_to_ir(bt_trace_class *ir_tc,
+bt_field_class *ctf_field_class_string_to_ir(struct ctx *ctx,
struct ctf_field_class_string *fc)
{
- bt_field_class *ir_fc = bt_field_class_string_create(ir_tc);
+ bt_field_class *ir_fc = bt_field_class_string_create(ctx->ir_tc);
BT_ASSERT(ir_fc);
return ir_fc;
}
static inline
-bt_field_class *ctf_field_class_struct_to_ir(bt_trace_class *ir_tc,
- struct ctf_field_class_struct *fc,
- struct ctf_trace_class *tc,
- struct ctf_stream_class *sc,
- struct ctf_event_class *ec)
+void translate_struct_field_class_members(struct ctx *ctx,
+ struct ctf_field_class_struct *fc, bt_field_class *ir_fc,
+ bool with_header_prefix,
+ struct ctf_field_class_struct *context_fc)
{
- int ret;
- bt_field_class *ir_fc = bt_field_class_structure_create(ir_tc);
uint64_t i;
-
- BT_ASSERT(ir_fc);
+ int ret;
for (i = 0; i < fc->members->len; i++) {
struct ctf_named_field_class *named_fc =
ctf_field_class_struct_borrow_member_by_index(fc, i);
bt_field_class *member_ir_fc;
+ const char *name = named_fc->name->str;
if (!named_fc->fc->in_ir) {
continue;
}
- member_ir_fc = ctf_field_class_to_ir(ir_tc, named_fc->fc,
- tc, sc, ec);
+ member_ir_fc = ctf_field_class_to_ir(ctx, named_fc->fc);
BT_ASSERT(member_ir_fc);
- ret = bt_field_class_structure_append_member(
- ir_fc, named_fc->name->str, member_ir_fc);
+ ret = bt_field_class_structure_append_member(ir_fc, name,
+ member_ir_fc);
BT_ASSERT(ret == 0);
bt_field_class_put_ref(member_ir_fc);
}
+}
+static inline
+bt_field_class *ctf_field_class_struct_to_ir(struct ctx *ctx,
+ struct ctf_field_class_struct *fc)
+{
+ bt_field_class *ir_fc = bt_field_class_structure_create(ctx->ir_tc);
+
+ BT_ASSERT(ir_fc);
+ translate_struct_field_class_members(ctx, fc, ir_fc, false, NULL);
return ir_fc;
}
static inline
-bt_field_class *borrow_ir_ft_from_field_path(struct ctf_field_path *field_path,
- struct ctf_trace_class *tc,
- struct ctf_stream_class *sc,
- struct ctf_event_class *ec)
+bt_field_class *borrow_ir_fc_from_field_path(struct ctx *ctx,
+ struct ctf_field_path *field_path)
{
bt_field_class *ir_fc = NULL;
struct ctf_field_class *fc = ctf_field_path_borrow_field_class(
- field_path, tc, sc, ec);
+ field_path, ctx->tc, ctx->sc, ctx->ec);
BT_ASSERT(fc);
}
static inline
-bt_field_class *ctf_field_class_variant_to_ir(bt_trace_class *ir_tc,
- struct ctf_field_class_variant *fc,
- struct ctf_trace_class *tc,
- struct ctf_stream_class *sc,
- struct ctf_event_class *ec)
+bt_field_class *ctf_field_class_variant_to_ir(struct ctx *ctx,
+ struct ctf_field_class_variant *fc)
{
int ret;
- bt_field_class *ir_fc = bt_field_class_variant_create(ir_tc);
+ bt_field_class *ir_fc = bt_field_class_variant_create(ctx->ir_tc);
uint64_t i;
BT_ASSERT(ir_fc);
- ret = bt_field_class_variant_set_selector_field_class(
- ir_fc, borrow_ir_ft_from_field_path(&fc->tag_path, tc, sc, ec));
- BT_ASSERT(ret == 0);
+
+ if (fc->tag_path.root != CTF_SCOPE_PACKET_HEADER &&
+ fc->tag_path.root != CTF_SCOPE_EVENT_HEADER) {
+ ret = bt_field_class_variant_set_selector_field_class(
+ ir_fc, borrow_ir_fc_from_field_path(ctx,
+ &fc->tag_path));
+ BT_ASSERT(ret == 0);
+ }
for (i = 0; i < fc->options->len; i++) {
struct ctf_named_field_class *named_fc =
bt_field_class *option_ir_fc;
BT_ASSERT(named_fc->fc->in_ir);
- option_ir_fc = ctf_field_class_to_ir(ir_tc, named_fc->fc,
- tc, sc, ec);
+ option_ir_fc = ctf_field_class_to_ir(ctx, named_fc->fc);
BT_ASSERT(option_ir_fc);
ret = bt_field_class_variant_append_option(
ir_fc, named_fc->name->str, option_ir_fc);
}
static inline
-bt_field_class *ctf_field_class_array_to_ir(bt_trace_class *ir_tc,
- struct ctf_field_class_array *fc,
- struct ctf_trace_class *tc,
- struct ctf_stream_class *sc,
- struct ctf_event_class *ec)
+bt_field_class *ctf_field_class_array_to_ir(struct ctx *ctx,
+ struct ctf_field_class_array *fc)
{
bt_field_class *ir_fc;
bt_field_class *elem_ir_fc;
if (fc->base.is_text) {
- ir_fc = bt_field_class_string_create(ir_tc);
+ ir_fc = bt_field_class_string_create(ctx->ir_tc);
BT_ASSERT(ir_fc);
goto end;
}
- elem_ir_fc = ctf_field_class_to_ir(ir_tc, fc->base.elem_fc, tc, sc, ec);
+ elem_ir_fc = ctf_field_class_to_ir(ctx, fc->base.elem_fc);
BT_ASSERT(elem_ir_fc);
- ir_fc = bt_field_class_static_array_create(ir_tc, elem_ir_fc,
+ ir_fc = bt_field_class_static_array_create(ctx->ir_tc, elem_ir_fc,
fc->length);
BT_ASSERT(ir_fc);
bt_field_class_put_ref(elem_ir_fc);
}
static inline
-bt_field_class *ctf_field_class_sequence_to_ir(bt_trace_class *ir_tc,
- struct ctf_field_class_sequence *fc,
- struct ctf_trace_class *tc,
- struct ctf_stream_class *sc,
- struct ctf_event_class *ec)
+bt_field_class *ctf_field_class_sequence_to_ir(struct ctx *ctx,
+ struct ctf_field_class_sequence *fc)
{
int ret;
bt_field_class *ir_fc;
bt_field_class *elem_ir_fc;
if (fc->base.is_text) {
- ir_fc = bt_field_class_string_create(ir_tc);
+ ir_fc = bt_field_class_string_create(ctx->ir_tc);
BT_ASSERT(ir_fc);
goto end;
}
- elem_ir_fc = ctf_field_class_to_ir(ir_tc, fc->base.elem_fc, tc, sc, ec);
+ elem_ir_fc = ctf_field_class_to_ir(ctx, fc->base.elem_fc);
BT_ASSERT(elem_ir_fc);
- ir_fc = bt_field_class_dynamic_array_create(ir_tc, elem_ir_fc);
+ ir_fc = bt_field_class_dynamic_array_create(ctx->ir_tc, elem_ir_fc);
BT_ASSERT(ir_fc);
bt_field_class_put_ref(elem_ir_fc);
BT_ASSERT(ir_fc);
- ret = bt_field_class_dynamic_array_set_length_field_class(
- ir_fc,
- borrow_ir_ft_from_field_path(&fc->length_path, tc, sc, ec));
- BT_ASSERT(ret == 0);
+
+ if (fc->length_path.root != CTF_SCOPE_PACKET_HEADER &&
+ fc->length_path.root != CTF_SCOPE_EVENT_HEADER) {
+ ret = bt_field_class_dynamic_array_set_length_field_class(
+ ir_fc, borrow_ir_fc_from_field_path(ctx, &fc->length_path));
+ BT_ASSERT(ret == 0);
+ }
end:
return ir_fc;
}
static inline
-bt_field_class *ctf_field_class_to_ir(bt_trace_class *ir_tc,
- struct ctf_field_class *fc,
- struct ctf_trace_class *tc,
- struct ctf_stream_class *sc,
- struct ctf_event_class *ec)
+bt_field_class *ctf_field_class_to_ir(struct ctx *ctx,
+ struct ctf_field_class *fc)
{
bt_field_class *ir_fc = NULL;
switch (fc->type) {
case CTF_FIELD_CLASS_TYPE_INT:
- ir_fc = ctf_field_class_int_to_ir(ir_tc, (void *) fc);
+ ir_fc = ctf_field_class_int_to_ir(ctx, (void *) fc);
break;
case CTF_FIELD_CLASS_TYPE_ENUM:
- ir_fc = ctf_field_class_enum_to_ir(ir_tc, (void *) fc);
+ ir_fc = ctf_field_class_enum_to_ir(ctx, (void *) fc);
break;
case CTF_FIELD_CLASS_TYPE_FLOAT:
- ir_fc = ctf_field_class_float_to_ir(ir_tc, (void *) fc);
+ ir_fc = ctf_field_class_float_to_ir(ctx, (void *) fc);
break;
case CTF_FIELD_CLASS_TYPE_STRING:
- ir_fc = ctf_field_class_string_to_ir(ir_tc, (void *) fc);
+ ir_fc = ctf_field_class_string_to_ir(ctx, (void *) fc);
break;
case CTF_FIELD_CLASS_TYPE_STRUCT:
- ir_fc = ctf_field_class_struct_to_ir(ir_tc, (void *) fc,
- tc, sc, ec);
+ ir_fc = ctf_field_class_struct_to_ir(ctx, (void *) fc);
break;
case CTF_FIELD_CLASS_TYPE_ARRAY:
- ir_fc = ctf_field_class_array_to_ir(ir_tc, (void *) fc,
- tc, sc, ec);
+ ir_fc = ctf_field_class_array_to_ir(ctx, (void *) fc);
break;
case CTF_FIELD_CLASS_TYPE_SEQUENCE:
- ir_fc = ctf_field_class_sequence_to_ir(ir_tc, (void *) fc,
- tc, sc, ec);
+ ir_fc = ctf_field_class_sequence_to_ir(ctx, (void *) fc);
break;
case CTF_FIELD_CLASS_TYPE_VARIANT:
- ir_fc = ctf_field_class_variant_to_ir(ir_tc, (void *) fc,
- tc, sc, ec);
+ ir_fc = ctf_field_class_variant_to_ir(ctx, (void *) fc);
break;
default:
abort();
}
static inline
-bt_field_class *scope_ctf_field_class_to_ir(bt_trace_class *ir_tc,
- struct ctf_field_class *fc,
- struct ctf_trace_class *tc,
- struct ctf_stream_class *sc,
- struct ctf_event_class *ec)
+bt_field_class *scope_ctf_field_class_to_ir(struct ctx *ctx)
{
bt_field_class *ir_fc = NULL;
+ struct ctf_field_class *fc = NULL;
- if (!fc) {
- goto end;
+ switch (ctx->scope) {
+ case CTF_SCOPE_PACKET_CONTEXT:
+ fc = ctx->sc->packet_context_fc;
+ break;
+ case CTF_SCOPE_EVENT_COMMON_CONTEXT:
+ fc = ctx->sc->event_common_context_fc;
+ break;
+ case CTF_SCOPE_EVENT_SPECIFIC_CONTEXT:
+ fc = ctx->ec->spec_context_fc;
+ break;
+ case CTF_SCOPE_EVENT_PAYLOAD:
+ fc = ctx->ec->payload_fc;
+ break;
+ default:
+ abort();
}
- BT_ASSERT(fc->type == CTF_FIELD_CLASS_TYPE_STRUCT);
-
- if (!ctf_field_class_struct_has_immediate_member_in_ir((void *) fc)) {
- /*
- * Nothing for IR in this scope: typical for packet
- * header, packet context, and event header.
- */
- goto end;
+ if (fc && ctf_field_class_struct_has_immediate_member_in_ir(
+ (void *) fc)) {
+ ir_fc = ctf_field_class_to_ir(ctx, fc);
}
- ir_fc = ctf_field_class_to_ir(ir_tc, fc, tc, sc, ec);
-
-end:
return ir_fc;
}
}
static inline
-bt_event_class *ctf_event_class_to_ir(struct ctf_event_class *ec,
- bt_stream_class *ir_sc, struct ctf_trace_class *tc,
- struct ctf_stream_class *sc)
+void ctf_event_class_to_ir(struct ctx *ctx)
{
int ret;
bt_event_class *ir_ec = NULL;
- bt_trace_class *ir_tc = bt_stream_class_borrow_trace_class(ir_sc);
+ bt_field_class *ir_fc;
- if (ec->is_translated) {
+ BT_ASSERT(ctx->ec);
+
+ if (ctx->ec->is_translated) {
ir_ec = bt_stream_class_borrow_event_class_by_id(
- ir_sc, ec->id);
+ ctx->ir_sc, ctx->ec->id);
BT_ASSERT(ir_ec);
goto end;
}
- ir_ec = bt_event_class_create_with_id(ir_sc, ec->id);
+ ir_ec = bt_event_class_create_with_id(ctx->ir_sc, ctx->ec->id);
BT_ASSERT(ir_ec);
bt_event_class_put_ref(ir_ec);
-
- if (ec->spec_context_fc) {
- bt_field_class *ir_fc = scope_ctf_field_class_to_ir(ir_tc,
- ec->spec_context_fc, tc, sc, ec);
-
- if (ir_fc) {
- ret = bt_event_class_set_specific_context_field_class(
- ir_ec, ir_fc);
- BT_ASSERT(ret == 0);
- bt_field_class_put_ref(ir_fc);
- }
+ ctx->scope = CTF_SCOPE_EVENT_SPECIFIC_CONTEXT;
+ ir_fc = scope_ctf_field_class_to_ir(ctx);
+ if (ir_fc) {
+ ret = bt_event_class_set_specific_context_field_class(
+ ir_ec, ir_fc);
+ BT_ASSERT(ret == 0);
+ bt_field_class_put_ref(ir_fc);
}
- if (ec->payload_fc) {
- bt_field_class *ir_fc = scope_ctf_field_class_to_ir(ir_tc,
- ec->payload_fc, tc, sc, ec);
-
- if (ir_fc) {
- ret = bt_event_class_set_payload_field_class(ir_ec,
- ir_fc);
- BT_ASSERT(ret == 0);
- bt_field_class_put_ref(ir_fc);
- }
+ ctx->scope = CTF_SCOPE_EVENT_PAYLOAD;
+ ir_fc = scope_ctf_field_class_to_ir(ctx);
+ if (ir_fc) {
+ ret = bt_event_class_set_payload_field_class(ir_ec,
+ ir_fc);
+ BT_ASSERT(ret == 0);
+ bt_field_class_put_ref(ir_fc);
}
- if (ec->name->len > 0) {
- ret = bt_event_class_set_name(ir_ec, ec->name->str);
+ if (ctx->ec->name->len > 0) {
+ ret = bt_event_class_set_name(ir_ec, ctx->ec->name->str);
BT_ASSERT(ret == 0);
}
- if (ec->emf_uri->len > 0) {
- ret = bt_event_class_set_emf_uri(ir_ec, ec->emf_uri->str);
+ if (ctx->ec->emf_uri->len > 0) {
+ ret = bt_event_class_set_emf_uri(ir_ec, ctx->ec->emf_uri->str);
BT_ASSERT(ret == 0);
}
- if (ec->log_level != -1) {
- bt_event_class_set_log_level(ir_ec, ec->log_level);
+ if (ctx->ec->log_level != -1) {
+ bt_event_class_set_log_level(ir_ec, ctx->ec->log_level);
}
- ec->is_translated = true;
- ec->ir_ec = ir_ec;
+ ctx->ec->is_translated = true;
+ ctx->ec->ir_ec = ir_ec;
end:
- return ir_ec;
+ return;
}
static inline
-bt_stream_class *ctf_stream_class_to_ir(struct ctf_stream_class *sc,
- bt_trace_class *ir_tc, struct ctf_trace_class *tc)
+void ctf_stream_class_to_ir(struct ctx *ctx)
{
int ret;
- bt_stream_class *ir_sc = NULL;
struct ctf_field_class_int *int_fc;
+ bt_field_class *ir_fc;
- if (sc->is_translated) {
- 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_tc, sc->id);
- BT_ASSERT(ir_sc);
- bt_stream_class_put_ref(ir_sc);
-
- if (sc->packet_context_fc) {
- bt_field_class *ir_fc = scope_ctf_field_class_to_ir(ir_tc,
- sc->packet_context_fc, tc, sc, NULL);
+ BT_ASSERT(ctx->sc);
- if (ir_fc) {
- ret = bt_stream_class_set_packet_context_field_class(
- ir_sc, ir_fc);
- BT_ASSERT(ret == 0);
- bt_field_class_put_ref(ir_fc);
- }
+ if (ctx->sc->is_translated) {
+ ctx->ir_sc = bt_trace_class_borrow_stream_class_by_id(
+ ctx->ir_tc, ctx->sc->id);
+ BT_ASSERT(ctx->ir_sc);
+ goto end;
}
- if (sc->event_header_fc) {
- bt_field_class *ir_fc = scope_ctf_field_class_to_ir(ir_tc,
- sc->event_header_fc, tc, sc, NULL);
-
- if (ir_fc) {
- ret = bt_stream_class_set_event_header_field_class(
- ir_sc, ir_fc);
- BT_ASSERT(ret == 0);
- bt_field_class_put_ref(ir_fc);
- }
+ ctx->ir_sc = bt_stream_class_create_with_id(ctx->ir_tc, ctx->sc->id);
+ BT_ASSERT(ctx->ir_sc);
+ bt_stream_class_put_ref(ctx->ir_sc);
+ ctx->scope = CTF_SCOPE_PACKET_CONTEXT;
+ ir_fc = scope_ctf_field_class_to_ir(ctx);
+ if (ir_fc) {
+ ret = bt_stream_class_set_packet_context_field_class(
+ ctx->ir_sc, ir_fc);
+ BT_ASSERT(ret == 0);
+ bt_field_class_put_ref(ir_fc);
}
- if (sc->event_common_context_fc) {
- bt_field_class *ir_fc = scope_ctf_field_class_to_ir(ir_tc,
- sc->event_common_context_fc, tc, sc, NULL);
-
- if (ir_fc) {
- ret = bt_stream_class_set_event_common_context_field_class(
- ir_sc, ir_fc);
- BT_ASSERT(ret == 0);
- bt_field_class_put_ref(ir_fc);
- }
+ ctx->scope = CTF_SCOPE_EVENT_COMMON_CONTEXT;
+ ir_fc = scope_ctf_field_class_to_ir(ctx);
+ if (ir_fc) {
+ ret = bt_stream_class_set_event_common_context_field_class(
+ ctx->ir_sc, ir_fc);
+ BT_ASSERT(ret == 0);
+ bt_field_class_put_ref(ir_fc);
}
- bt_stream_class_set_assigns_automatic_event_class_id(ir_sc,
+ bt_stream_class_set_assigns_automatic_event_class_id(ctx->ir_sc,
BT_FALSE);
- bt_stream_class_set_assigns_automatic_stream_id(ir_sc, BT_FALSE);
+ bt_stream_class_set_assigns_automatic_stream_id(ctx->ir_sc, BT_FALSE);
- if (sc->default_clock_class) {
- BT_ASSERT(sc->default_clock_class->ir_cc);
- ret = bt_stream_class_set_default_clock_class(ir_sc,
- sc->default_clock_class->ir_cc);
+ if (ctx->sc->default_clock_class) {
+ BT_ASSERT(ctx->sc->default_clock_class->ir_cc);
+ ret = bt_stream_class_set_default_clock_class(ctx->ir_sc,
+ ctx->sc->default_clock_class->ir_cc);
BT_ASSERT(ret == 0);
}
- int_fc = borrow_named_int_field_class((void *) sc->packet_context_fc,
+ int_fc = borrow_named_int_field_class((void *) ctx->sc->packet_context_fc,
"events_discarded");
if (int_fc) {
if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT) {
bt_stream_class_set_packets_have_discarded_event_counter_snapshot(
- ir_sc, BT_TRUE);
+ ctx->ir_sc, BT_TRUE);
}
}
- int_fc = borrow_named_int_field_class((void *) sc->packet_context_fc,
+ int_fc = borrow_named_int_field_class((void *) ctx->sc->packet_context_fc,
"packet_seq_num");
if (int_fc) {
if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT) {
bt_stream_class_set_packets_have_packet_counter_snapshot(
- ir_sc, BT_TRUE);
+ ctx->ir_sc, BT_TRUE);
}
}
- int_fc = borrow_named_int_field_class((void *) sc->packet_context_fc,
+ int_fc = borrow_named_int_field_class((void *) ctx->sc->packet_context_fc,
"timestamp_begin");
if (int_fc) {
if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME) {
bt_stream_class_set_packets_have_default_beginning_clock_snapshot(
- ir_sc, BT_TRUE);
+ ctx->ir_sc, BT_TRUE);
}
}
- int_fc = borrow_named_int_field_class((void *) sc->packet_context_fc,
+ int_fc = borrow_named_int_field_class((void *) ctx->sc->packet_context_fc,
"timestamp_end");
if (int_fc) {
if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_END_TIME) {
bt_stream_class_set_packets_have_default_end_clock_snapshot(
- ir_sc, BT_TRUE);
+ ctx->ir_sc, BT_TRUE);
}
}
- sc->is_translated = true;
- sc->ir_sc = ir_sc;
+ ctx->sc->is_translated = true;
+ ctx->sc->ir_sc = ctx->ir_sc;
end:
- return ir_sc;
+ return;
}
static inline
}
static inline
-int ctf_trace_class_to_ir(bt_trace_class *ir_tc, struct ctf_trace_class *tc)
+int ctf_trace_class_to_ir(struct ctx *ctx)
{
int ret = 0;
uint64_t i;
- if (tc->is_translated) {
- goto end;
- }
-
- if (tc->packet_header_fc) {
- bt_field_class *ir_fc = scope_ctf_field_class_to_ir(ir_tc,
- tc->packet_header_fc, tc, NULL, NULL);
+ BT_ASSERT(ctx->tc);
+ BT_ASSERT(ctx->ir_tc);
- if (ir_fc) {
- ret = bt_trace_class_set_packet_header_field_class(
- ir_tc, ir_fc);
- BT_ASSERT(ret == 0);
- bt_field_class_put_ref(ir_fc);
- }
+ if (ctx->tc->is_translated) {
+ goto end;
}
- if (tc->is_uuid_set) {
- bt_trace_class_set_uuid(ir_tc, tc->uuid);
+ if (ctx->tc->is_uuid_set) {
+ bt_trace_class_set_uuid(ctx->ir_tc, ctx->tc->uuid);
}
- for (i = 0; i < tc->env_entries->len; i++) {
+ for (i = 0; i < ctx->tc->env_entries->len; i++) {
struct ctf_trace_class_env_entry *env_entry =
- ctf_trace_class_borrow_env_entry_by_index(tc, i);
+ ctf_trace_class_borrow_env_entry_by_index(ctx->tc, i);
switch (env_entry->type) {
case CTF_TRACE_CLASS_ENV_ENTRY_TYPE_INT:
ret = bt_trace_class_set_environment_entry_integer(
- ir_tc, env_entry->name->str,
+ ctx->ir_tc, env_entry->name->str,
env_entry->value.i);
break;
case CTF_TRACE_CLASS_ENV_ENTRY_TYPE_STR:
ret = bt_trace_class_set_environment_entry_string(
- ir_tc, env_entry->name->str,
+ ctx->ir_tc, env_entry->name->str,
env_entry->value.str->str);
break;
default:
}
}
- for (i = 0; i < tc->clock_classes->len; i++) {
- struct ctf_clock_class *cc = tc->clock_classes->pdata[i];
+ for (i = 0; i < ctx->tc->clock_classes->len; i++) {
+ struct ctf_clock_class *cc = ctx->tc->clock_classes->pdata[i];
- cc->ir_cc = bt_clock_class_create(ir_tc);
+ cc->ir_cc = bt_clock_class_create(ctx->ir_tc);
ctf_clock_class_to_ir(cc->ir_cc, cc);
}
- bt_trace_class_set_assigns_automatic_stream_class_id(ir_tc,
+ bt_trace_class_set_assigns_automatic_stream_class_id(ctx->ir_tc,
BT_FALSE);
- tc->is_translated = true;
- tc->ir_tc = ir_tc;
+ ctx->tc->is_translated = true;
+ ctx->tc->ir_tc = ctx->ir_tc;
end:
return ret;
{
int ret = 0;
uint64_t i;
+ struct ctx ctx = { 0 };
- ret = ctf_trace_class_to_ir(ir_tc, tc);
+ ctx.tc = tc;
+ ctx.ir_tc = ir_tc;
+ ret = ctf_trace_class_to_ir(&ctx);
if (ret) {
goto end;
}
for (i = 0; i < tc->stream_classes->len; i++) {
uint64_t j;
- struct ctf_stream_class *sc = tc->stream_classes->pdata[i];
- bt_stream_class *ir_sc;
+ ctx.sc = tc->stream_classes->pdata[i];
- ir_sc = ctf_stream_class_to_ir(sc, ir_tc, tc);
- if (!ir_sc) {
- ret = -1;
- goto end;
- }
+ ctf_stream_class_to_ir(&ctx);
- for (j = 0; j < sc->event_classes->len; j++) {
- struct ctf_event_class *ec = sc->event_classes->pdata[j];
- bt_event_class *ir_ec;
+ for (j = 0; j < ctx.sc->event_classes->len; j++) {
+ ctx.ec = ctx.sc->event_classes->pdata[j];
- ir_ec = ctf_event_class_to_ir(ec, ir_sc, tc, sc);
- if (!ir_ec) {
- ret = -1;
- goto end;
- }
+ ctf_event_class_to_ir(&ctx);
+ ctx.ec = NULL;
}
+
+ ctx.sc = NULL;
}
end:
#include "ctf-meta-visitors.h"
+static
+void force_update_field_class_in_ir(struct ctf_field_class *fc, bool in_ir)
+{
+ uint64_t i;
+
+ if (!fc) {
+ goto end;
+ }
+
+ fc->in_ir = in_ir;
+
+ switch (fc->type) {
+ case CTF_FIELD_CLASS_TYPE_STRUCT:
+ {
+ struct ctf_field_class_struct *struct_fc = (void *) fc;
+
+ for (i = 0; i < struct_fc->members->len; i++) {
+ struct ctf_named_field_class *named_fc =
+ ctf_field_class_struct_borrow_member_by_index(
+ struct_fc, i);
+
+ force_update_field_class_in_ir(named_fc->fc, in_ir);
+ }
+
+ break;
+ }
+ case CTF_FIELD_CLASS_TYPE_VARIANT:
+ {
+ struct ctf_named_field_class *named_fc;
+ struct ctf_field_class_variant *var_fc = (void *) fc;
+
+ for (i = 0; i < var_fc->options->len; i++) {
+ named_fc =
+ ctf_field_class_variant_borrow_option_by_index(
+ var_fc, i);
+
+ force_update_field_class_in_ir(named_fc->fc, in_ir);
+ }
+
+ break;
+ }
+ case CTF_FIELD_CLASS_TYPE_ARRAY:
+ case CTF_FIELD_CLASS_TYPE_SEQUENCE:
+ {
+ struct ctf_field_class_array_base *array_fc = (void *) fc;
+
+ force_update_field_class_in_ir(array_fc->elem_fc, in_ir);
+ break;
+ }
+ default:
+ break;
+ }
+
+end:
+ return;
+}
+
static
void update_field_class_in_ir(struct ctf_field_class *fc,
GHashTable *ft_dependents)
if (!sc->is_translated) {
update_field_class_in_ir(sc->event_common_context_fc,
ft_dependents);
- update_field_class_in_ir(sc->event_header_fc,
- ft_dependents);
+ force_update_field_class_in_ir(sc->event_header_fc,
+ false);
update_field_class_in_ir(sc->packet_context_fc,
ft_dependents);
}
}
if (!ctf_tc->is_translated) {
- update_field_class_in_ir(ctf_tc->packet_header_fc,
- ft_dependents);
+ force_update_field_class_in_ir(ctf_tc->packet_header_fc,
+ false);
}
g_hash_table_destroy(ft_dependents);
BT_HIDDEN
int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc);
+BT_HIDDEN
+void ctf_trace_class_warn_meaningless_header_fields(
+ struct ctf_trace_class *ctf_tc);
+
#endif /* _CTF_META_VISITORS_H */
--- /dev/null
+/*
+ * Copyright 2018 - Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-WARN-MEANINGLESS-HEADER-FIELDS"
+#include "logging.h"
+
+#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/assert-internal.h>
+#include <glib.h>
+#include <stdint.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "ctf-meta-visitors.h"
+
+static inline
+void warn_meaningless_field(const char *name, const char *scope_name)
+{
+ BT_LOGW("User field found in %s: ignoring: name=\"%s\"",
+ scope_name, name);
+}
+
+static inline
+void warn_meaningless_fields(struct ctf_field_class *fc, const char *name,
+ const char *scope_name)
+{
+ uint64_t i;
+
+ if (!fc) {
+ goto end;
+ }
+
+ switch (fc->type) {
+ case CTF_FIELD_CLASS_TYPE_FLOAT:
+ case CTF_FIELD_CLASS_TYPE_STRING:
+ warn_meaningless_field(name, scope_name);
+ break;
+ case CTF_FIELD_CLASS_TYPE_INT:
+ case CTF_FIELD_CLASS_TYPE_ENUM:
+ {
+ struct ctf_field_class_int *int_fc = (void *) fc;
+
+ if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE &&
+ !int_fc->mapped_clock_class) {
+ warn_meaningless_field(name, scope_name);
+ }
+
+ break;
+ }
+ case CTF_FIELD_CLASS_TYPE_STRUCT:
+ {
+ struct ctf_field_class_struct *struct_fc = (void *) fc;
+
+ for (i = 0; i < struct_fc->members->len; i++) {
+ struct ctf_named_field_class *named_fc =
+ ctf_field_class_struct_borrow_member_by_index(
+ struct_fc, i);
+
+ warn_meaningless_fields(named_fc->fc,
+ named_fc->name->str, scope_name);
+ }
+
+ break;
+ }
+ case CTF_FIELD_CLASS_TYPE_VARIANT:
+ {
+ struct ctf_field_class_variant *var_fc = (void *) fc;
+
+ for (i = 0; i < var_fc->options->len; i++) {
+ struct ctf_named_field_class *named_fc =
+ ctf_field_class_variant_borrow_option_by_index(
+ var_fc, i);
+
+ warn_meaningless_fields(named_fc->fc,
+ named_fc->name->str, scope_name);
+ }
+
+ break;
+ }
+ case CTF_FIELD_CLASS_TYPE_ARRAY:
+ {
+ struct ctf_field_class_array *array_fc = (void *) fc;
+
+ if (array_fc->meaning != CTF_FIELD_CLASS_MEANING_NONE) {
+ goto end;
+ }
+
+ /* Fallthrough */
+ }
+ case CTF_FIELD_CLASS_TYPE_SEQUENCE:
+ {
+ struct ctf_field_class_array_base *array_fc = (void *) fc;
+
+ warn_meaningless_fields(array_fc->elem_fc, name, scope_name);
+ break;
+ }
+ default:
+ abort();
+ }
+
+end:
+ return;
+}
+
+BT_HIDDEN
+void ctf_trace_class_warn_meaningless_header_fields(
+ struct ctf_trace_class *ctf_tc)
+{
+ uint64_t i;
+
+ if (!ctf_tc->is_translated) {
+ warn_meaningless_fields(
+ ctf_tc->packet_header_fc, NULL, "packet header");
+ }
+
+ for (i = 0; i < ctf_tc->stream_classes->len; i++) {
+ struct ctf_stream_class *sc = ctf_tc->stream_classes->pdata[i];
+
+ if (!sc->is_translated) {
+ warn_meaningless_fields(sc->event_header_fc, NULL,
+ "event header");
+ }
+ }
+}
CTF_ENCODING_UTF8,
};
+enum ctf_scope {
+ CTF_SCOPE_PACKET_HEADER,
+ CTF_SCOPE_PACKET_CONTEXT,
+ CTF_SCOPE_EVENT_HEADER,
+ CTF_SCOPE_EVENT_COMMON_CONTEXT,
+ CTF_SCOPE_EVENT_SPECIFIC_CONTEXT,
+ CTF_SCOPE_EVENT_PAYLOAD,
+};
+
struct ctf_clock_class {
GString *name;
GString *description;
};
struct ctf_field_path {
- bt_scope root;
+ enum ctf_scope root;
/* Array of `int64_t` */
GArray *path;
g_array_set_size(fp->path, 0);
}
+static inline
+const char *ctf_scope_string(enum ctf_scope scope)
+{
+ switch (scope) {
+ case CTF_SCOPE_PACKET_HEADER:
+ return "CTF_SCOPE_PACKET_HEADER";
+ case CTF_SCOPE_PACKET_CONTEXT:
+ return "CTF_SCOPE_PACKET_CONTEXT";
+ case CTF_SCOPE_EVENT_HEADER:
+ return "CTF_SCOPE_EVENT_HEADER";
+ case CTF_SCOPE_EVENT_COMMON_CONTEXT:
+ return "CTF_SCOPE_EVENT_COMMON_CONTEXT";
+ case CTF_SCOPE_EVENT_SPECIFIC_CONTEXT:
+ return "CTF_SCOPE_EVENT_SPECIFIC_CONTEXT";
+ case CTF_SCOPE_EVENT_PAYLOAD:
+ return "CTF_SCOPE_EVENT_PAYLOAD";
+ default:
+ abort();
+ }
+}
+
static inline
GString *ctf_field_path_string(struct ctf_field_path *path)
{
goto end;
}
- g_string_append_printf(str, "[%s", bt_common_scope_string(
- path->root));
+ g_string_append_printf(str, "[%s", ctf_scope_string(path->root));
for (i = 0; i < path->path->len; i++) {
g_string_append_printf(str, ", %" PRId64,
struct ctf_field_class *fc;
switch (field_path->root) {
- case BT_SCOPE_PACKET_HEADER:
+ case CTF_SCOPE_PACKET_HEADER:
fc = tc->packet_header_fc;
break;
- case BT_SCOPE_PACKET_CONTEXT:
+ case CTF_SCOPE_PACKET_CONTEXT:
fc = sc->packet_context_fc;
break;
- case BT_SCOPE_EVENT_HEADER:
+ case CTF_SCOPE_EVENT_HEADER:
fc = sc->event_header_fc;
break;
- case BT_SCOPE_EVENT_COMMON_CONTEXT:
+ case CTF_SCOPE_EVENT_COMMON_CONTEXT:
fc = sc->event_common_context_fc;
break;
- case BT_SCOPE_EVENT_SPECIFIC_CONTEXT:
+ case CTF_SCOPE_EVENT_SPECIFIC_CONTEXT:
fc = ec->spec_context_fc;
break;
- case BT_SCOPE_EVENT_PAYLOAD:
+ case CTF_SCOPE_EVENT_PAYLOAD:
fc = ec->payload_fc;
break;
default:
goto end;
}
+ /*
+ * If there are fields which are not related to the CTF format
+ * itself in the packet header and in event header field
+ * classes, warn about it because they are never translated.
+ */
+ ctf_trace_class_warn_meaningless_header_fields(ctx->ctf_tc);
+
if (ctx->trace_class) {
/* Copy new CTF metadata -> new IR metadata */
ret = ctf_trace_class_translate(ctx->trace_class, ctx->ctf_tc);
struct ctf_event_class *ec;
} meta;
- /* Current packet header field wrapper (NULL if not created yet) */
- bt_packet_header_field *packet_header_field;
-
- /* Current packet header field wrapper (NULL if not created yet) */
+ /* Current packet context field wrapper (NULL if not created yet) */
bt_packet_context_field *packet_context_field;
- /* Current event header field (NULL if not created yet) */
- bt_event_header_field *event_header_field;
-
/* Current packet (NULL if not created yet) */
bt_packet *packet;
/* Database of current dynamic scopes */
struct {
- bt_field *trace_packet_header;
bt_field *stream_packet_context;
- bt_field *event_header;
bt_field *event_common_context;
bt_field *event_spec_context;
bt_field *event_payload;
static
void release_event_dscopes(struct bt_msg_iter *notit)
{
- notit->dscopes.event_header = NULL;
-
- if (notit->event_header_field) {
- bt_event_header_field_release(notit->event_header_field);
- notit->event_header_field = NULL;
- }
-
notit->dscopes.event_common_context = NULL;
notit->dscopes.event_spec_context = NULL;
notit->dscopes.event_payload = NULL;
static
void release_all_dscopes(struct bt_msg_iter *notit)
{
- notit->dscopes.trace_packet_header = NULL;
-
- if (notit->packet_header_field) {
- bt_packet_header_field_release(notit->packet_header_field);
- notit->packet_header_field = NULL;
- }
-
notit->dscopes.stream_packet_context = NULL;
if (notit->packet_context_field) {
goto end;
}
- BT_ASSERT(!notit->packet_header_field);
-
- if (packet_header_fc->in_ir) {
- /*
- * 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.
- * 2. A stream is created from a stream class.
- * 3. We need the packet header field's content to know
- * the ID of the stream class to select.
- */
- notit->packet_header_field =
- 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 class.");
- ret = BT_MSG_ITER_STATUS_ERROR;
- goto end;
- }
-
- notit->dscopes.trace_packet_header =
- bt_packet_header_field_borrow_field(
- notit->packet_header_field);
- BT_ASSERT(notit->dscopes.trace_packet_header);
- }
-
notit->cur_stream_class_id = -1;
notit->cur_event_class_id = -1;
notit->cur_data_stream_id = -1;
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);
+ STATE_DSCOPE_TRACE_PACKET_HEADER_CONTINUE, NULL);
if (ret < 0) {
BT_LOGW("Cannot decode packet header field: "
"notit-addr=%p, trace-class-addr=%p, "
* This field is going to be moved to the packet once we
* create it. We cannot create the packet now because a
* packet is created from a stream, and this API must be
- * able to return the packet header and context fields
- * without creating a stream
- * (read_packet_header_context_fields()).
+ * able to return the packet context properties without
+ * creating a stream
+ * (bt_msg_iter_get_packet_properties()).
*/
notit->packet_context_field =
bt_packet_context_field_create(
goto end;
}
- if (event_header_fc->in_ir) {
- BT_ASSERT(!notit->event_header_field);
- notit->event_header_field =
- 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 class.");
- status = BT_MSG_ITER_STATUS_ERROR;
- goto end;
- }
-
- notit->dscopes.event_header =
- bt_event_header_field_borrow_field(
- notit->event_header_field);
- BT_ASSERT(notit->dscopes.event_header);
- }
-
BT_LOGV("Decoding event header field: "
"notit-addr=%p, stream-class-addr=%p, "
"stream-class-id=%" PRId64 ", "
event_header_fc);
status = read_dscope_begin_state(notit, event_header_fc,
STATE_AFTER_EVENT_HEADER,
- STATE_DSCOPE_EVENT_HEADER_CONTINUE,
- notit->dscopes.event_header);
+ STATE_DSCOPE_EVENT_HEADER_CONTINUE, NULL);
if (status < 0) {
BT_LOGW("Cannot decode event header field: "
"notit-addr=%p, stream-class-addr=%p, "
notit->event = bt_message_event_borrow_event(
notit->event_msg);
BT_ASSERT(notit->event);
-
- if (notit->event_header_field) {
- int ret;
-
- BT_ASSERT(notit->event);
- ret = bt_event_move_header_field(notit->event,
- notit->event_header_field);
- if (ret) {
- status = BT_MSG_ITER_STATUS_ERROR;
- goto end;
- }
-
- notit->event_header_field = NULL;
-
- /*
- * At this point notit->dscopes.event_header has
- * the same value as the event header field within
- * notit->event.
- */
- BT_ASSERT(bt_event_borrow_header_field(
- notit->event) == notit->dscopes.event_header);
- }
-
notit->state = STATE_DSCOPE_EVENT_COMMON_CONTEXT_BEGIN;
end:
release_all_dscopes(notit);
notit->cur_dscope_field = NULL;
- if (notit->packet_header_field) {
- bt_packet_header_field_release(notit->packet_header_field);
- notit->packet_header_field = NULL;
- }
-
if (notit->packet_context_field) {
bt_packet_context_field_release(notit->packet_context_field);
notit->packet_context_field = NULL;
}
- if (notit->event_header_field) {
- bt_event_header_field_release(notit->event_header_field);
- notit->event_header_field = NULL;
- }
-
notit->buf.addr = NULL;
notit->buf.sz = 0;
notit->buf.at = 0;
notit->packet, notit->snapshots.end_clock);
}
- if (notit->packet_header_field) {
- ret = bt_packet_move_header_field(
- notit->packet, notit->packet_header_field);
- if (ret) {
- goto end;
- }
-
- notit->packet_header_field = NULL;
-
- /*
- * At this point notit->dscopes.trace_packet_header has
- * the same value as the packet header field within
- * notit->packet.
- */
- BT_ASSERT(bt_packet_borrow_header_field(
- notit->packet) ==
- notit->dscopes.trace_packet_header);
- }
-
if (notit->packet_context_field) {
ret = bt_packet_move_context_field(
notit->packet, notit->packet_context_field);
notit->packet_context_field = NULL;
/*
- * At this point notit->dscopes.trace_packet_header has
- * the same value as the packet header field within
+ * At this point notit->dscopes.stream_packet_context
+ * has the same value as the packet context field within
* notit->packet.
*/
BT_ASSERT(bt_packet_borrow_context_field(
BT_ASSERT(packet_size >= 0);
entry->packet_size = packet_size;
- /* Convert the packet's bound to nanoseconds since Epoch. */
- ret = convert_cycles_to_ns(sc->default_clock_class,
- props->snapshots.beginning_clock,
- &entry->timestamp_begin_ns);
- if (ret) {
- BT_LOGD_STR("Failed to convert raw timestamp to nanoseconds since Epoch.");
- goto end;
+ if (props->snapshots.beginning_clock != UINT64_C(-1)) {
+ /* Convert the packet's bound to nanoseconds since Epoch. */
+ ret = convert_cycles_to_ns(sc->default_clock_class,
+ props->snapshots.beginning_clock,
+ &entry->timestamp_begin_ns);
+ if (ret) {
+ BT_LOGD_STR("Failed to convert raw timestamp to nanoseconds since Epoch.");
+ goto end;
+ }
+ } else {
+ entry->timestamp_begin_ns = UINT64_C(-1);
}
- ret = convert_cycles_to_ns(sc->default_clock_class,
- props->snapshots.end_clock,
- &entry->timestamp_end_ns);
- if (ret) {
- BT_LOGD_STR("Failed to convert raw timestamp to nanoseconds since Epoch.");
- goto end;
+ if (props->snapshots.end_clock != UINT64_C(-1)) {
+ ret = convert_cycles_to_ns(sc->default_clock_class,
+ props->snapshots.end_clock,
+ &entry->timestamp_end_ns);
+ if (ret) {
+ BT_LOGD_STR("Failed to convert raw timestamp to nanoseconds since Epoch.");
+ goto end;
+ }
+ } else {
+ entry->timestamp_end_ns = UINT64_C(-1);
}
end:
return ret;
}
-static
-int print_event_header_raw(struct pretty_component *pretty,
- const bt_event *event)
-{
- int ret = 0;
- const bt_field *main_field = NULL;
-
- main_field = bt_event_borrow_header_field_const(event);
- if (!main_field) {
- goto end;
- }
- if (!pretty->start_line) {
- g_string_append(pretty->string, ", ");
- }
- pretty->start_line = false;
- if (pretty->options.print_scope_field_names) {
- print_name_equal(pretty, "stream.event.header");
- }
- ret = print_field(pretty, main_field,
- pretty->options.print_header_field_names, NULL, 0);
-
-end:
- return ret;
-}
-
static
int print_stream_event_context(struct pretty_component *pretty,
const bt_event *event)
goto end;
}
- if (pretty->options.verbose) {
- ret = print_event_header_raw(pretty, event);
- if (ret != 0) {
- goto end;
- }
- }
-
ret = print_stream_event_context(pretty, event);
if (ret != 0) {
goto end;
bt_trace_class *trace_class =
bt_stream_class_borrow_trace_class(stream_class);
bt_field_class *packet_context_type;
- bt_field_class *event_header_type;
bt_field_class *fc;
int ret;
"content_size", fc);
BT_ASSERT(ret == 0);
bt_field_class_put_ref(fc);
- event_header_type = bt_field_class_structure_create(trace_class);
- BT_ASSERT(event_header_type);
- fc = bt_field_class_unsigned_integer_create(trace_class);
- BT_ASSERT(fc);
- bt_field_class_integer_set_field_value_range(fc, 32);
- ret = bt_field_class_structure_append_member(event_header_type,
- "id", fc);
- BT_ASSERT(ret == 0);
- bt_field_class_put_ref(fc);
ret = bt_stream_class_set_packet_context_field_class(
stream_class, packet_context_type);
BT_ASSERT(ret == 0);
- ret = bt_stream_class_set_event_header_field_class(
- stream_class, event_header_type);
- BT_ASSERT(ret == 0);
bt_field_class_put_ref(packet_context_type);
- bt_field_class_put_ref(event_header_type);
}
static void create_sc1(bt_trace_class *trace_class)
BT_STREAM_CLASS_PUT_REF_AND_RESET(sc2);
}
-static void set_trace_packet_header(bt_trace_class *trace_class)
-{
- bt_field_class *packet_header_type;
- bt_field_class *fc;
- int ret;
-
- packet_header_type = bt_field_class_structure_create(trace_class);
- BT_ASSERT(packet_header_type);
- fc = bt_field_class_unsigned_integer_create(trace_class);
- BT_ASSERT(fc);
- bt_field_class_integer_set_field_value_range(fc, 32);
- ret = bt_field_class_structure_append_member(packet_header_type,
- "stream_id", fc);
- BT_ASSERT(ret == 0);
- bt_field_class_put_ref(fc);
- ret = bt_trace_class_set_packet_header_field_class(trace_class,
- packet_header_type);
- BT_ASSERT(ret == 0);
-
- bt_field_class_put_ref(packet_header_type);
-}
-
static bt_trace_class *create_tc1(bt_self_component_source *self_comp)
{
bt_trace_class *tc1 = NULL;
tc1 = bt_trace_class_create(
bt_self_component_source_as_self_component(self_comp));
BT_ASSERT(tc1);
- set_trace_packet_header(tc1);
create_sc1(tc1);
create_sc2(tc1);
return tc1;