lib: remove CTF concepts of packet and event headers
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 11 Dec 2018 22:43:05 +0000 (17:43 -0500)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 2 May 2019 20:50:15 +0000 (20:50 +0000)
Packet and event headers are CTF concepts. In CTF 1.8, the fields in
those scopes are reserved for format encoding/decoding purposes, and
everything they mean has its equivalent property in trace IR objects.

I know no tracers producing CTF which put something else than the known
encoding fields in packet and event headers. Everything not related to
the trace format itself goes into context fields (except for a packet's
total and content sizes which are packet context fields), which are
still available as of this patch. This is so true that Mathieu Desnoyers
confirmed that CTF 2 should explicitly disallow anything else than
format-specific fields in header scopes. However, it might be ambiguous
in CTF v1.8.2, and someone somewhere could have put user fields in
there.

Therefore, for the moment, the `ctf` plugin does not copy the values of
packet and event header fields to trace IR fields. This could be done in
the future if we find that it's a limitation: for example, prefix header
fields with `ctf-header-` and put them into appropriate context fields
(packet context for packet header and event common context for event
header).

To make sure the user knows about non-CTF header fields being removed,
the `ctf` plugin prints a warning for each such field, for example:

    12-12 10:53:25.904 21954 21954 W
    PLUGIN-CTF-METADATA-META-WARN-MEANINGLESS-HEADER-FIELDS
    warn_meaningless_field@ctf-meta-warn-meaningless-header-fields.c:32
    User field found in packet header: ignoring: name="allo"

    12-12 10:53:25.904 21954 21954 W
    PLUGIN-CTF-METADATA-META-WARN-MEANINGLESS-HEADER-FIELDS
    warn_meaningless_field@ctf-meta-warn-meaningless-header-fields.c:32
    User field found in event header: ignoring: name="msg_id"

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
43 files changed:
include/Makefile.am
include/babeltrace/babeltrace.h
include/babeltrace/common-internal.h
include/babeltrace/trace-ir/event-const.h
include/babeltrace/trace-ir/event-header-field.h [deleted file]
include/babeltrace/trace-ir/event-internal.h
include/babeltrace/trace-ir/event.h
include/babeltrace/trace-ir/field-path-const.h
include/babeltrace/trace-ir/packet-const.h
include/babeltrace/trace-ir/packet-header-field.h [deleted file]
include/babeltrace/trace-ir/packet-internal.h
include/babeltrace/trace-ir/packet.h
include/babeltrace/trace-ir/resolve-field-path-internal.h
include/babeltrace/trace-ir/stream-class-const.h
include/babeltrace/trace-ir/stream-class-internal.h
include/babeltrace/trace-ir/stream-class.h
include/babeltrace/trace-ir/trace-class-const.h
include/babeltrace/trace-ir/trace-class-internal.h
include/babeltrace/trace-ir/trace-class.h
include/babeltrace/trace-ir/trace-internal.h
lib/lib-logging.c
lib/trace-ir/Makefile.am
lib/trace-ir/event-class.c
lib/trace-ir/event-header-field.c [deleted file]
lib/trace-ir/event.c
lib/trace-ir/packet-header-field.c [deleted file]
lib/trace-ir/packet.c
lib/trace-ir/resolve-field-path.c
lib/trace-ir/stream-class.c
lib/trace-ir/trace-class.c
lib/trace-ir/trace.c
plugins/ctf/common/metadata/Makefile.am
plugins/ctf/common/metadata/ctf-meta-resolve.c
plugins/ctf/common/metadata/ctf-meta-translate.c
plugins/ctf/common/metadata/ctf-meta-update-in-ir.c
plugins/ctf/common/metadata/ctf-meta-visitors.h
plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.c [new file with mode: 0644]
plugins/ctf/common/metadata/ctf-meta.h
plugins/ctf/common/metadata/visitor-generate-ir.c
plugins/ctf/common/msg-iter/msg-iter.c
plugins/ctf/fs-src/data-stream-file.c
plugins/text/pretty/print.c
tests/lib/test_trace_ir_ref.c

index 4474d914ed966e0a2c255a125edbfa03e40cc736..e00822b63259358f520eaea79ebd04695de63752 100644 (file)
@@ -124,7 +124,6 @@ babeltracetraceirinclude_HEADERS = \
        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 \
@@ -133,7 +132,6 @@ babeltracetraceirinclude_HEADERS = \
        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 \
index 2930140ac886df9961312b176f8de187d16aa196..d34858931cae05d98ac2ded1748666bbca47af26 100644 (file)
@@ -70,7 +70,6 @@
 #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>
@@ -79,7 +78,6 @@
 #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>
index eebe592616b959c9c41948bf2118722199476e12..e24762a03cb9141d50ab46557704cc2f1cd75652 100644 (file)
@@ -354,12 +354,8 @@ static inline
 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:
index 3fafc484f824a0f8a68ce26140105ecc5c21be00..1199c40a71aa4ef2bb745261f6e7516d1ae90984 100644 (file)
@@ -51,9 +51,6 @@ extern const bt_packet *bt_event_borrow_packet_const(
 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);
 
diff --git a/include/babeltrace/trace-ir/event-header-field.h b/include/babeltrace/trace-ir/event-header-field.h
deleted file mode 100644 (file)
index 8445845..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#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 */
index 8e84596ad558235f20778c727b5f44fe25fb0c5c..cfc30ee1b48fa46c3110f361e2587cff06425378 100644 (file)
@@ -59,7 +59,6 @@ struct bt_event {
        /* 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;
@@ -88,13 +87,6 @@ void _bt_event_reset_dev_mode(struct bt_event *event)
 {
        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);
index cf18584a08ce7f7d66a1f0922f36c9ddcc03ca20..e394583babce5f2e66395c032d208e1c1ef107cd 100644 (file)
@@ -27,7 +27,7 @@
  * 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 */
@@ -43,11 +43,6 @@ extern bt_packet *bt_event_borrow_packet(bt_event *event);
 
 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);
 
index fe5bef6f5c9ebc57d82ba8caad1004da5e0b31b5..be75b758c2c77f0bc9c8329899d8024d7c06e3f7 100644 (file)
@@ -36,9 +36,7 @@ extern "C" {
 #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,
index f2369177aca6808c0d9594fd48a2fcc7429a714a..e9545fc8df1784a2da2a63f6303e4dd4d9d36bd2 100644 (file)
@@ -35,8 +35,7 @@
 #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>
 
@@ -52,10 +51,6 @@ typedef enum bt_packet_status {
 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);
diff --git a/include/babeltrace/trace-ir/packet-header-field.h b/include/babeltrace/trace-ir/packet-header-field.h
deleted file mode 100644 (file)
index 37cd89e..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#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 */
index c94318165b7bbf02d8d209f348144ba20794875f..62e921d6c1bae33006cc9a185f3e05dcd8ff31fa 100644 (file)
@@ -36,7 +36,6 @@
 
 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;
index eebe600a4c9db3c59e7eaa631df30247df6572c0..54c35a05b98846de4d41579ecd11364e684eb5c9 100644 (file)
@@ -26,7 +26,7 @@
  * 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 */
@@ -42,13 +42,6 @@ extern bt_packet *bt_packet_create(bt_stream *stream);
 
 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);
 
index f10f1ae5c807e774b7098ddfcf375910c720d050..9a98b3166c1f29ce1cceaf44db3c2414e7994e72 100644 (file)
@@ -32,9 +32,7 @@
 #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;
index c4307cf3c0f43feb94f14faa0c74f61de47fa70a..d7dd912cbc6ae4f2db1def4c6cf482482cf3137f 100644 (file)
@@ -31,7 +31,7 @@
 
 /*
  * 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>
 
@@ -63,10 +63,6 @@ extern const bt_field_class *
 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);
index dcb50b62bedf5bb6fb07cd90d2f64bc301f2b459..5ef02131a00292718ace051e119d5f00e4e0fe08 100644 (file)
@@ -53,16 +53,12 @@ struct bt_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;
 
index 7895568b811b099d542ae30f166679102f8b9297..7be54efec01377ebddea3bf39929d93eb00f92c8 100644 (file)
@@ -65,11 +65,6 @@ bt_stream_class_set_packet_context_field_class(
                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,
index c438799847f9434f493a9c7c1f7001bccb33d132..0f80f304f1143cf78e8f931bed209ae08046ed00 100644 (file)
@@ -64,10 +64,6 @@ extern const bt_value *
 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);
 
index 98ddc5d05aa7635e617cd0c7ed32ade6aec94c0b..2ffa3a3c4cd217364ef85702d6507a07614eac65 100644 (file)
@@ -62,12 +62,7 @@ struct bt_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;
 };
 
index b253eb2ede8f89bd376a1d43d640f286b3c1d69e..51968f4e81e5463fbc94e09a3af81688be88cef0 100644 (file)
@@ -61,10 +61,6 @@ extern bt_trace_class_status bt_trace_class_set_environment_entry_string(
                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);
 
index 32ff433ff96365451b7109caefbee6acc6d236f3..aa4cee514c3ab7f363436ba060d0ce8131bc46e7 100644 (file)
@@ -64,7 +64,6 @@ struct bt_trace {
         */
        GHashTable *stream_classes_stream_count;
 
-       struct bt_field_class *packet_header_fc;
        GArray *is_static_listeners;
        bool is_static;
        bool in_remove_listener;
index 403c2a173a98107dc582fd9fc76aa722a55d5502..017f2540bc1c9cdae7b96d7d5b0ac7596afe0710 100644 (file)
@@ -433,8 +433,6 @@ static inline void format_field_path(char **buf_ch, bool extended,
 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));
@@ -455,13 +453,8 @@ static inline void format_trace_class(char **buf_ch, bool extended,
                        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,
@@ -521,9 +514,8 @@ static inline void format_stream_class(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) {
@@ -544,9 +536,6 @@ static inline void format_stream_class(char **buf_ch, bool extended,
        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);
@@ -661,10 +650,8 @@ static inline void format_packet(char **buf_ch, bool extended,
                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) {
@@ -719,13 +706,11 @@ static inline void format_event(char **buf_ch, bool extended,
                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));
index 5c35796eeabebd101ac5884e5cd257ebe173c60f..0b2107e031adb23aa27b93c140a640c4e18a4a90 100644 (file)
@@ -6,14 +6,12 @@ libtrace_ir_la_SOURCES = \
        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 \
index b15ee7ad2163ab39b55fefc39e2eb7d79144c229..6ed174bb3dccad109b587a02a5eab18c06a8977f 100644 (file)
@@ -279,11 +279,8 @@ enum bt_event_class_status bt_event_class_set_specific_context_field_class(
 {
        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,
@@ -298,10 +295,7 @@ enum bt_event_class_status bt_event_class_set_specific_context_field_class(
                "%!+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;
 
@@ -341,11 +335,8 @@ enum bt_event_class_status bt_event_class_set_payload_field_class(
 {
        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,
@@ -360,10 +351,7 @@ enum bt_event_class_status bt_event_class_set_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;
diff --git a/lib/trace-ir/event-header-field.c b/lib/trace-ir/event-header-field.c
deleted file mode 100644 (file)
index da7e8c9..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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;
-}
index f63bd309965ed1e45f03de914fd70e7ea753632b..e245d79391969ace16acd7367abf70788527b35f 100644 (file)
@@ -56,12 +56,6 @@ void _bt_event_set_is_frozen(const struct bt_event *event, bool is_frozen)
        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(
@@ -85,44 +79,6 @@ void _bt_event_set_is_frozen(const struct bt_event *event, bool 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)
 {
@@ -140,15 +96,6 @@ 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);
@@ -221,19 +168,6 @@ const struct bt_stream *bt_event_borrow_stream_const(
        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");
@@ -273,33 +207,12 @@ const struct bt_field *bt_event_borrow_payload_field_const(
        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);
@@ -370,26 +283,3 @@ const struct bt_packet *bt_event_borrow_packet_const(
 {
        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;
-}
diff --git a/lib/trace-ir/packet-header-field.c b/lib/trace-ir/packet-header-field.c
deleted file mode 100644 (file)
index 8f72a42..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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;
-}
index 4909e9523460fa47b476e3b60f97d37cb6163bd5..5a8f815675652d39ea157b4b8c9ba332d7f81d96 100644 (file)
@@ -55,18 +55,6 @@ const struct bt_stream *bt_packet_borrow_stream_const(
        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");
@@ -89,12 +77,6 @@ void _bt_packet_set_is_frozen(const struct bt_packet *packet, bool is_frozen)
        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,
@@ -120,11 +102,6 @@ void reset_packet(struct bt_packet *packet)
        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);
@@ -141,18 +118,6 @@ void reset_packet(struct bt_packet *packet)
        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)
@@ -208,19 +173,6 @@ void bt_packet_destroy(struct bt_packet *packet)
 {
        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.");
@@ -271,17 +223,6 @@ struct bt_packet *bt_packet_new(struct bt_stream *stream)
        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(
@@ -346,33 +287,6 @@ end:
        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)
 {
@@ -388,7 +302,7 @@ enum bt_packet_status bt_packet_move_context_field(struct bt_packet *packet,
                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);
 
index 00ec6447b49fd9f00e75ac814a21bb44a6271180..597eb74325fed5a9e39a795b6e9e66c71d9f26b3 100644 (file)
@@ -124,24 +124,12 @@ struct bt_field_path *find_field_class_in_ctx(struct bt_field_class *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) {
@@ -209,12 +197,8 @@ struct bt_field_class *borrow_root_field_class(
                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:
index 5fe060c278b80554297a3a97098be47236f46d20..ead41195c31f5b5c791d4cd8578f4a0850e65792 100644 (file)
@@ -68,13 +68,10 @@ void destroy_stream_class(struct bt_object *obj)
                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);
 }
@@ -145,16 +142,6 @@ struct bt_stream_class *create_stream_class_with_id(
                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,
@@ -303,9 +290,7 @@ enum bt_stream_class_status bt_stream_class_set_packet_context_field_class(
 {
        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,
@@ -318,8 +303,6 @@ enum bt_stream_class_status bt_stream_class_set_packet_context_field_class(
                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) {
                /*
@@ -343,60 +326,6 @@ end:
        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)
@@ -412,9 +341,7 @@ bt_stream_class_set_event_common_context_field_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,
@@ -427,10 +354,7 @@ bt_stream_class_set_event_common_context_field_class(
                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) {
                /*
index 78a7161bb56c2c632521115364bcf8cfcf80ad00..7fa6a2f515b62ed2fda8f977e1b1a6cc474afdd0 100644 (file)
@@ -63,7 +63,6 @@ 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.");
@@ -83,23 +82,12 @@ void destroy_trace_class(struct bt_object *obj)
                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.");
@@ -131,16 +119,6 @@ struct bt_trace_class *bt_trace_class_create(bt_self_component *self_comp)
        }
 
        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;
 
@@ -353,60 +331,9 @@ bt_trace_class_borrow_stream_class_by_id_const(
        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;
index a46d8684f04cbfe4990806163b118ffa4468ccf3..2ef2b6f1301caffe4fd2508f6d9362a8405ce818 100644 (file)
@@ -359,7 +359,6 @@ enum bt_trace_status bt_trace_remove_is_static_listener(
 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);
index c1f89c351e31a42edc01a88297410eafad071c6a..4dfc22b05514898a3f88495563434dbc4156ccf0 100644 (file)
@@ -33,6 +33,7 @@ libctf_ast_la_SOURCES = \
        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
 
index ab2b44aa464bc7a3e9c825cd065d21f78adb183c..a8e4746ed6e08c0e5889298201c4d246e87f2df2 100644 (file)
@@ -64,29 +64,29 @@ struct resolve_context {
        } 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
@@ -227,20 +227,20 @@ void field_class_stack_pop(field_class_stack *stack)
  */
 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();
@@ -254,14 +254,14 @@ struct ctf_field_class *borrow_class_from_ctx(struct resolve_context *ctx,
  * 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
@@ -470,7 +470,7 @@ int absolute_ptokens_to_field_path(GList *ptokens,
         * 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",
@@ -480,9 +480,9 @@ int absolute_ptokens_to_field_path(GList *ptokens,
                }
 
                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",
@@ -500,8 +500,8 @@ int absolute_ptokens_to_field_path(GList *ptokens,
                }
 
                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",
@@ -637,7 +637,7 @@ int pathstr_to_field_path(const char *pathstr,
                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 */
@@ -1148,7 +1148,7 @@ end:
  * 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;
 
@@ -1174,7 +1174,7 @@ int resolve_event_class_field_classes(struct resolve_context *ctx,
 
        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);
@@ -1182,7 +1182,7 @@ int resolve_event_class_field_classes(struct resolve_context *ctx,
        }
 
        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);
@@ -1210,7 +1210,7 @@ int resolve_stream_class_field_classes(struct resolve_context *ctx,
 
        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);
@@ -1218,7 +1218,7 @@ int resolve_stream_class_field_classes(struct resolve_context *ctx,
                }
 
                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);
@@ -1226,7 +1226,7 @@ int resolve_stream_class_field_classes(struct resolve_context *ctx,
                }
 
                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);
@@ -1275,7 +1275,7 @@ int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc)
                        .event_spec_context = NULL,
                        .event_payload = NULL,
                },
-               .root_scope = BT_SCOPE_PACKET_HEADER,
+               .root_scope = CTF_SCOPE_PACKET_HEADER,
                .cur_fc = NULL,
        };
 
@@ -1289,7 +1289,7 @@ int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc)
 
        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);
index e3da926f16f6a0c97a16f12a608d6ee3404b6601..1d318ccf0ddf85b62ef757c2e5dee7d742da6e6c 100644 (file)
 
 #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,
@@ -43,15 +49,15 @@ 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);
@@ -60,7 +66,7 @@ bt_field_class *ctf_field_class_int_to_ir(bt_trace_class *ir_tc,
 }
 
 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;
@@ -68,9 +74,9 @@ bt_field_class *ctf_field_class_enum_to_ir(bt_trace_class *ir_tc,
        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);
@@ -97,12 +103,12 @@ bt_field_class *ctf_field_class_enum_to_ir(bt_trace_class *ir_tc,
 }
 
 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) {
@@ -114,58 +120,61 @@ bt_field_class *ctf_field_class_float_to_ir(bt_trace_class *ir_tc,
 }
 
 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);
 
@@ -177,20 +186,22 @@ bt_field_class *borrow_ir_ft_from_field_path(struct ctf_field_path *field_path,
 }
 
 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 =
@@ -198,8 +209,7 @@ bt_field_class *ctf_field_class_variant_to_ir(bt_trace_class *ir_tc,
                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);
@@ -211,24 +221,21 @@ bt_field_class *ctf_field_class_variant_to_ir(bt_trace_class *ir_tc,
 }
 
 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);
@@ -238,43 +245,40 @@ end:
 }
 
 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;
 
@@ -283,32 +287,28 @@ bt_field_class *ctf_field_class_to_ir(bt_trace_class *ir_tc,
 
        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();
@@ -340,31 +340,33 @@ end:
 }
 
 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;
 }
 
@@ -396,177 +398,153 @@ end:
 }
 
 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
@@ -596,44 +574,35 @@ void ctf_clock_class_to_ir(bt_clock_class *ir_cc, struct ctf_clock_class *cc)
 }
 
 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:
@@ -645,17 +614,17 @@ int ctf_trace_class_to_ir(bt_trace_class *ir_tc, struct ctf_trace_class *tc)
                }
        }
 
-       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;
@@ -667,33 +636,29 @@ int ctf_trace_class_translate(bt_trace_class *ir_tc,
 {
        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:
index a765b7c1b0b09244918d1b90827ec39bc2576edc..ed5d23bfd25b060b0311dae7e81df95ac2ed0d0a 100644 (file)
 
 #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)
@@ -208,16 +265,16 @@ int ctf_trace_class_update_in_ir(struct ctf_trace_class *ctf_tc)
                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);
index 7870b89c2069e2ccf90232a887c390482c47191f..846aee9d5530443578236a3ebe5c19e45edd58da 100644 (file)
@@ -46,4 +46,8 @@ int ctf_trace_class_update_value_storing_indexes(struct ctf_trace_class *ctf_tc)
 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 */
diff --git a/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.c b/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.c
new file mode 100644 (file)
index 0000000..943078f
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * 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");
+               }
+       }
+}
index 0982cc404953bd3970c863490379c925069606a0..33e41090724ef761c06d0b352713621ee9245de4 100644 (file)
@@ -59,6 +59,15 @@ enum ctf_encoding {
        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;
@@ -150,7 +159,7 @@ struct ctf_field_class_struct {
 };
 
 struct ctf_field_path {
-       bt_scope root;
+       enum ctf_scope root;
 
        /* Array of `int64_t` */
        GArray *path;
@@ -1021,6 +1030,27 @@ void ctf_field_path_clear(struct ctf_field_path *fp)
        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)
 {
@@ -1033,8 +1063,7 @@ 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,
@@ -1058,22 +1087,22 @@ struct ctf_field_class *ctf_field_path_borrow_field_class(
        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:
index 27345fd287a63ff33d85987d0531f4d96ab7e656..c74e35728efa0e2569d846c50a345ccb77cc4aaf 100644 (file)
@@ -5060,6 +5060,13 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                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);
index 7bd9192b0032d1f94a66800a031df537e73669ae..91d06e9da78355f4c33778ba69790fb741149f75 100644 (file)
@@ -129,15 +129,9 @@ struct bt_msg_iter {
                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;
 
@@ -152,9 +146,7 @@ struct bt_msg_iter {
 
        /* 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;
@@ -619,13 +611,6 @@ end:
 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;
@@ -634,13 +619,6 @@ void release_event_dscopes(struct bt_msg_iter *notit)
 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) {
@@ -671,34 +649,6 @@ enum bt_msg_iter_status read_packet_header_begin_state(
                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;
@@ -707,8 +657,7 @@ enum bt_msg_iter_status read_packet_header_begin_state(
                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, "
@@ -910,9 +859,9 @@ enum bt_msg_iter_status read_packet_context_begin_state(
                 * 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(
@@ -1090,23 +1039,6 @@ enum bt_msg_iter_status read_event_header_begin_state(
                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 ", "
@@ -1116,8 +1048,7 @@ enum bt_msg_iter_status read_event_header_begin_state(
                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, "
@@ -1245,29 +1176,6 @@ enum bt_msg_iter_status after_event_header_state(
        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:
@@ -1580,21 +1488,11 @@ void bt_msg_iter_reset(struct bt_msg_iter *notit)
        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;
@@ -2376,25 +2274,6 @@ void notify_new_packet(struct bt_msg_iter *notit,
                        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);
@@ -2405,8 +2284,8 @@ void notify_new_packet(struct bt_msg_iter *notit,
                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(
index 2865f6020d9b2828a1a320f73ebd54bed164dc6b..280a5d398ceb5f7b480d9fb4bcde4cc48f7e2722 100644 (file)
@@ -503,21 +503,29 @@ int init_index_entry(struct ctf_fs_ds_index_entry *entry,
        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:
index 32719cbaec5a5e6ab4bced0763cc1ad530212701..88c84a97895381aedd9e5d1fd6da9e8b5a90eb5c 100644 (file)
@@ -1077,31 +1077,6 @@ 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)
@@ -1215,13 +1190,6 @@ int pretty_print_event(struct pretty_component *pretty,
                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;
index 166cddad57232c6af5277eaad321344196a199b8..f0f3961dcb6ec56d72d3a7844e5a85c28422f9ca 100644 (file)
@@ -193,7 +193,6 @@ static void set_stream_class_field_classes(
        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;
 
@@ -213,23 +212,10 @@ static void set_stream_class_field_classes(
                "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)
@@ -274,28 +260,6 @@ static void create_sc2(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;
@@ -303,7 +267,6 @@ static bt_trace_class *create_tc1(bt_self_component_source *self_comp)
        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;
This page took 0.110167 seconds and 4 git commands to generate.