#define BT_LOG_TAG "PLUGIN-CTF-FS-SINK-TRANSLATE-CTF-IR-TO-TSDL"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <glib.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/endian-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/endian-internal.h>
#include "fs-sink-ctf-meta.h"
for (i = 0; i < bt_field_class_enumeration_get_mapping_count(ir_fc); i++) {
const char *label;
- const bt_field_class_unsigned_enumeration_mapping_ranges *u_ranges;
- const bt_field_class_signed_enumeration_mapping_ranges *i_ranges;
+ const bt_field_class_enumeration_mapping *mapping;
+ const bt_field_class_unsigned_enumeration_mapping *u_mapping;
+ const bt_field_class_signed_enumeration_mapping *i_mapping;
uint64_t range_count;
uint64_t range_i;
if (is_signed) {
- bt_field_class_signed_enumeration_borrow_mapping_by_index_const(
- ir_fc, i, &label, &i_ranges);
- range_count = bt_field_class_signed_enumeration_mapping_ranges_get_range_count(
- i_ranges);
+ i_mapping = bt_field_class_signed_enumeration_borrow_mapping_by_index_const(
+ ir_fc, i);
+ mapping = bt_field_class_signed_enumeration_mapping_as_mapping_const(
+ i_mapping);
} else {
- bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const(
- ir_fc, i, &label, &u_ranges);
- range_count = bt_field_class_unsigned_enumeration_mapping_ranges_get_range_count(
- u_ranges);
+ u_mapping = bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const(
+ ir_fc, i);
+ mapping = bt_field_class_unsigned_enumeration_mapping_as_mapping_const(
+ u_mapping);
}
+ label = bt_field_class_enumeration_mapping_get_label(
+ mapping);
+ range_count =
+ bt_field_class_enumeration_mapping_get_range_count(
+ mapping);
+
for (range_i = 0; range_i < range_count; range_i++) {
append_indent(ctx);
if (is_signed) {
int64_t lower, upper;
- bt_field_class_signed_enumeration_mapping_ranges_get_range_by_index(
- i_ranges, range_i,
+ bt_field_class_signed_enumeration_mapping_get_range_by_index(
+ i_mapping, range_i,
&lower, &upper);
if (lower == upper) {
} else {
uint64_t lower, upper;
- bt_field_class_unsigned_enumeration_mapping_ranges_get_range_by_index(
- u_ranges, range_i,
+ bt_field_class_unsigned_enumeration_mapping_get_range_by_index(
+ u_mapping, range_i,
&lower, &upper);
if (lower == upper) {
BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
NULL, "content_size", true);
- if (sc->default_clock_class) {
+ if (sc->packets_have_ts_begin) {
append_indent(ctx);
append_integer_field_class_from_props(ctx, 64, 8, false,
BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
sc->default_clock_class_name->str,
"timestamp_begin", true);
+ }
+
+ if (sc->packets_have_ts_end) {
append_indent(ctx);
append_integer_field_class_from_props(ctx, 64, 8, false,
BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
"timestamp_end", true);
}
- append_indent(ctx);
- append_integer_field_class_from_props(ctx, 64, 8, false,
- BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
- NULL, "events_discarded", true);
+ if (sc->has_discarded_events) {
+ append_indent(ctx);
+ append_integer_field_class_from_props(ctx, 64, 8, false,
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
+ NULL, "events_discarded", true);
+ }
+
+ /*
+ * Unconditionnally write the packet sequence number as, even if
+ * there's no possible discarded packets message, it's still
+ * useful information to have.
+ */
append_indent(ctx);
append_integer_field_class_from_props(ctx, 64, 8, false,
BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
g_string_append_printf(tsdl, "%s = ", name);
switch (bt_value_get_type(val)) {
- case BT_VALUE_TYPE_INTEGER:
+ case BT_VALUE_TYPE_SIGNED_INTEGER:
g_string_append_printf(tsdl, "%" PRId64,
- bt_value_integer_get(val));
+ bt_value_signed_integer_get(val));
break;
case BT_VALUE_TYPE_STRING:
append_quoted_string(&ctx, bt_value_string_get(val));