#define BT_COMP_LOG_SELF_COMP (stream->trace->fs_sink->self_comp)
#define BT_LOG_OUTPUT_LEVEL (stream->log_level)
#define BT_LOG_TAG "PLUGIN/SINK.CTF.FS/STREAM"
-#include "plugins/comp-logging.h"
+#include "logging/comp-logging.h"
#include <babeltrace2/babeltrace.h>
#include <stdio.h>
int write_field(struct fs_sink_stream *stream,
struct fs_sink_ctf_field_class *fc, const bt_field *field);
+static inline
+int write_bool_field(struct fs_sink_stream *stream,
+ struct fs_sink_ctf_field_class_int *fc, const bt_field *field)
+{
+ /*
+ * CTF 1.8 has no boolean field class type, so this component
+ * translates this boolean field to an 8-bit unsigned integer
+ * field which has the value 0 (false) or 1 (true).
+ */
+ return bt_ctfser_write_unsigned_int(&stream->ctfser,
+ bt_field_bool_get_value(field) ? 1 : 0,
+ fc->base.base.alignment, fc->base.size, BYTE_ORDER);
+}
+
static inline
int write_int_field(struct fs_sink_stream *stream,
struct fs_sink_ctf_field_class_int *fc, const bt_field *field)
if (fc->is_signed) {
ret = bt_ctfser_write_signed_int(&stream->ctfser,
- bt_field_signed_integer_get_value(field),
+ bt_field_integer_signed_get_value(field),
fc->base.base.alignment, fc->base.size, BYTE_ORDER);
} else {
ret = bt_ctfser_write_unsigned_int(&stream->ctfser,
- bt_field_unsigned_integer_get_value(field),
+ bt_field_integer_unsigned_get_value(field),
fc->base.base.alignment, fc->base.size, BYTE_ORDER);
}
return ret;
}
+static inline
+int write_option_field(struct fs_sink_stream *stream,
+ struct fs_sink_ctf_field_class_option *fc,
+ const bt_field *field)
+{
+ int ret;
+ const bt_field *content_field =
+ bt_field_option_borrow_field_const(field);
+
+ ret = bt_ctfser_write_unsigned_int(&stream->ctfser,
+ content_field ? 1 : 0, 8, 8, BYTE_ORDER);
+ if (G_UNLIKELY(ret)) {
+ goto end;
+ }
+
+ /*
+ * CTF 1.8 has no option field class type, so this component
+ * translates the option field class to a variant field class
+ * where the options are:
+ *
+ * * An empty structure field class (field occupies 0 bits).
+ * * The optional field class itself.
+ *
+ * If `content_field` is `NULL`, do not write anything (empty
+ * structure).
+ */
+ if (content_field) {
+ ret = write_field(stream, fc->content_fc, content_field);
+ }
+
+end:
+ return ret;
+}
+
static inline
int write_variant_field(struct fs_sink_stream *stream,
struct fs_sink_ctf_field_class_variant *fc,
int ret;
switch (fc->type) {
+ case FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL:
+ ret = write_bool_field(stream, (void *) fc, field);
+ break;
case FS_SINK_CTF_FIELD_CLASS_TYPE_INT:
ret = write_int_field(stream, (void *) fc, field);
break;
case FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE:
ret = write_sequence_field(stream, (void *) fc, field);
break;
+ case FS_SINK_CTF_FIELD_CLASS_TYPE_OPTION:
+ ret = write_option_field(stream, (void *) fc, field);
+ break;
case FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT:
ret = write_variant_field(stream, (void *) fc, field);
break;
/* Other members */
if (stream->sc->packet_context_fc) {
- const bt_field *packet_context_field =
- bt_packet_borrow_context_field_const(
- stream->packet_state.packet);
+ const bt_field *packet_context_field;
+ BT_ASSERT(stream->packet_state.packet);
+ packet_context_field = bt_packet_borrow_context_field_const(
+ stream->packet_state.packet);
BT_ASSERT(packet_context_field);
ret = write_struct_field(stream,
(void *) stream->sc->packet_context_fc,