#include <stdint.h>
#include <string.h>
-enum ctf_field_type_id {
- CTF_FIELD_TYPE_ID_INT,
- CTF_FIELD_TYPE_ID_ENUM,
- CTF_FIELD_TYPE_ID_FLOAT,
- CTF_FIELD_TYPE_ID_STRING,
- CTF_FIELD_TYPE_ID_STRUCT,
- CTF_FIELD_TYPE_ID_ARRAY,
- CTF_FIELD_TYPE_ID_SEQUENCE,
- CTF_FIELD_TYPE_ID_VARIANT,
+enum ctf_field_class_type {
+ CTF_FIELD_CLASS_TYPE_INT,
+ CTF_FIELD_CLASS_TYPE_ENUM,
+ CTF_FIELD_CLASS_TYPE_FLOAT,
+ CTF_FIELD_CLASS_TYPE_STRING,
+ CTF_FIELD_CLASS_TYPE_STRUCT,
+ CTF_FIELD_CLASS_TYPE_ARRAY,
+ CTF_FIELD_CLASS_TYPE_SEQUENCE,
+ CTF_FIELD_CLASS_TYPE_VARIANT,
};
-enum ctf_field_type_meaning {
- CTF_FIELD_TYPE_MEANING_NONE,
- CTF_FIELD_TYPE_MEANING_PACKET_BEGINNING_TIME,
- CTF_FIELD_TYPE_MEANING_PACKET_END_TIME,
- CTF_FIELD_TYPE_MEANING_EVENT_CLASS_ID,
- CTF_FIELD_TYPE_MEANING_STREAM_CLASS_ID,
- CTF_FIELD_TYPE_MEANING_DATA_STREAM_ID,
- CTF_FIELD_TYPE_MEANING_MAGIC,
- CTF_FIELD_TYPE_MEANING_PACKET_COUNTER_SNAPSHOT,
- CTF_FIELD_TYPE_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT,
- CTF_FIELD_TYPE_MEANING_EXP_PACKET_TOTAL_SIZE,
- CTF_FIELD_TYPE_MEANING_EXP_PACKET_CONTENT_SIZE,
- CTF_FIELD_TYPE_MEANING_UUID,
+enum ctf_field_class_meaning {
+ CTF_FIELD_CLASS_MEANING_NONE,
+ CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME,
+ CTF_FIELD_CLASS_MEANING_PACKET_END_TIME,
+ CTF_FIELD_CLASS_MEANING_EVENT_CLASS_ID,
+ CTF_FIELD_CLASS_MEANING_STREAM_CLASS_ID,
+ CTF_FIELD_CLASS_MEANING_DATA_STREAM_ID,
+ CTF_FIELD_CLASS_MEANING_MAGIC,
+ CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT,
+ CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT,
+ CTF_FIELD_CLASS_MEANING_EXP_PACKET_TOTAL_SIZE,
+ CTF_FIELD_CLASS_MEANING_EXP_PACKET_CONTENT_SIZE,
+ CTF_FIELD_CLASS_MEANING_UUID,
};
enum ctf_byte_order {
CTF_ENCODING_UTF8,
};
-struct ctf_field_type {
- enum ctf_field_type_id id;
+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;
+ uint64_t frequency;
+ uint64_t precision;
+ int64_t offset_seconds;
+ uint64_t offset_cycles;
+ uint8_t uuid[16];
+ bool has_uuid;
+ bool is_absolute;
+
+ /* Weak, set during translation */
+ bt_clock_class *ir_cc;
+};
+
+struct ctf_field_class {
+ enum ctf_field_class_type type;
unsigned int alignment;
bool is_compound;
bool in_ir;
/* Weak, set during translation. NULL if `in_ir` is false below. */
- struct bt_field_type *ir_ft;
+ bt_field_class *ir_fc;
};
-struct ctf_field_type_bit_array {
- struct ctf_field_type base;
+struct ctf_field_class_bit_array {
+ struct ctf_field_class base;
enum ctf_byte_order byte_order;
unsigned int size;
};
-struct ctf_field_type_int {
- struct ctf_field_type_bit_array base;
- enum ctf_field_type_meaning meaning;
+struct ctf_field_class_int {
+ struct ctf_field_class_bit_array base;
+ enum ctf_field_class_meaning meaning;
bool is_signed;
- enum bt_field_type_integer_preferred_display_base disp_base;
+ bt_field_class_integer_preferred_display_base disp_base;
enum ctf_encoding encoding;
int64_t storing_index;
- /* Owned by this */
- struct bt_clock_class *mapped_clock_class;
+ /* Weak */
+ struct ctf_clock_class *mapped_clock_class;
};
struct ctf_range {
} upper;
};
-struct ctf_field_type_enum_mapping {
+struct ctf_field_class_enum_mapping {
GString *label;
struct ctf_range range;
};
-struct ctf_field_type_enum {
- struct ctf_field_type_int base;
+struct ctf_field_class_enum {
+ struct ctf_field_class_int base;
- /* Array of `struct ctf_field_type_enum_mapping` */
+ /* Array of `struct ctf_field_class_enum_mapping` */
GArray *mappings;
};
-struct ctf_field_type_float {
- struct ctf_field_type_bit_array base;
+struct ctf_field_class_float {
+ struct ctf_field_class_bit_array base;
};
-struct ctf_field_type_string {
- struct ctf_field_type base;
+struct ctf_field_class_string {
+ struct ctf_field_class base;
enum ctf_encoding encoding;
};
-struct ctf_named_field_type {
+struct ctf_named_field_class {
GString *name;
/* Owned by this */
- struct ctf_field_type *ft;
+ struct ctf_field_class *fc;
};
-struct ctf_field_type_struct {
- struct ctf_field_type base;
+struct ctf_field_class_struct {
+ struct ctf_field_class base;
- /* Array of `struct ctf_named_field_type` */
+ /* Array of `struct ctf_named_field_class` */
GArray *members;
};
struct ctf_field_path {
- enum bt_scope root;
+ enum ctf_scope root;
/* Array of `int64_t` */
GArray *path;
};
-struct ctf_field_type_variant_range {
+struct ctf_field_class_variant_range {
struct ctf_range range;
uint64_t option_index;
};
-struct ctf_field_type_variant {
- struct ctf_field_type base;
+struct ctf_field_class_variant {
+ struct ctf_field_class base;
GString *tag_ref;
struct ctf_field_path tag_path;
uint64_t stored_tag_index;
- /* Array of `struct ctf_named_field_type` */
+ /* Array of `struct ctf_named_field_class` */
GArray *options;
- /* Array of `struct ctf_field_type_variant_range` */
+ /* Array of `struct ctf_field_class_variant_range` */
GArray *ranges;
/* Weak */
- struct ctf_field_type_enum *tag_ft;
+ struct ctf_field_class_enum *tag_fc;
};
-struct ctf_field_type_array_base {
- struct ctf_field_type base;
- struct ctf_field_type *elem_ft;
+struct ctf_field_class_array_base {
+ struct ctf_field_class base;
+ struct ctf_field_class *elem_fc;
bool is_text;
};
-struct ctf_field_type_array {
- struct ctf_field_type_array_base base;
- enum ctf_field_type_meaning meaning;
+struct ctf_field_class_array {
+ struct ctf_field_class_array_base base;
+ enum ctf_field_class_meaning meaning;
uint64_t length;
};
-struct ctf_field_type_sequence {
- struct ctf_field_type_array_base base;
+struct ctf_field_class_sequence {
+ struct ctf_field_class_array_base base;
GString *length_ref;
struct ctf_field_path length_path;
uint64_t stored_length_index;
/* Weak */
- struct ctf_field_type_int *length_ft;
+ struct ctf_field_class_int *length_fc;
};
struct ctf_event_class {
GString *name;
uint64_t id;
GString *emf_uri;
- enum bt_event_class_log_level log_level;
+ bt_event_class_log_level log_level;
bool is_translated;
/* Owned by this */
- struct ctf_field_type *spec_context_ft;
+ struct ctf_field_class *spec_context_fc;
/* Owned by this */
- struct ctf_field_type *payload_ft;
+ struct ctf_field_class *payload_fc;
/* Weak, set during translation */
- struct bt_event_class *ir_ec;
+ bt_event_class *ir_ec;
};
struct ctf_stream_class {
bool is_translated;
/* Owned by this */
- struct ctf_field_type *packet_context_ft;
+ struct ctf_field_class *packet_context_fc;
/* Owned by this */
- struct ctf_field_type *event_header_ft;
+ struct ctf_field_class *event_header_fc;
/* Owned by this */
- struct ctf_field_type *event_common_context_ft;
+ struct ctf_field_class *event_common_context_fc;
/* Array of `struct ctf_event_class *`, owned by this */
GPtrArray *event_classes;
*/
GHashTable *event_classes_by_id;
- /* Owned by this */
- struct bt_clock_class *default_clock_class;
+ /* Weak */
+ struct ctf_clock_class *default_clock_class;
/* Weak, set during translation */
- struct bt_stream_class *ir_sc;
+ bt_stream_class *ir_sc;
};
enum ctf_trace_class_env_entry_type {
};
struct ctf_trace_class {
- GString *name;
unsigned int major;
unsigned int minor;
uint8_t uuid[16];
enum ctf_byte_order default_byte_order;
/* Owned by this */
- struct ctf_field_type *packet_header_ft;
+ struct ctf_field_class *packet_header_fc;
uint64_t stored_value_count;
- /* Array of `struct bt_clock_class *` (owned by this) */
+ /* Array of `struct ctf_clock_class *` (owned by this) */
GPtrArray *clock_classes;
/* Array of `struct ctf_stream_class *` */
bool is_translated;
/* Weak, set during translation */
- struct bt_trace *ir_tc;
+ bt_trace_class *ir_tc;
};
static inline
-void ctf_field_type_destroy(struct ctf_field_type *ft);
+void ctf_field_class_destroy(struct ctf_field_class *fc);
static inline
-void _ctf_field_type_init(struct ctf_field_type *ft, enum ctf_field_type_id id,
- unsigned int alignment)
+void _ctf_field_class_init(struct ctf_field_class *fc,
+ enum ctf_field_class_type type, unsigned int alignment)
{
- BT_ASSERT(ft);
- ft->id = id;
- ft->alignment = alignment;
- ft->in_ir = false;
+ BT_ASSERT(fc);
+ fc->type = type;
+ fc->alignment = alignment;
+ fc->in_ir = false;
}
static inline
-void _ctf_field_type_bit_array_init(struct ctf_field_type_bit_array *ft,
- enum ctf_field_type_id id)
+void _ctf_field_class_bit_array_init(struct ctf_field_class_bit_array *fc,
+ enum ctf_field_class_type type)
{
- _ctf_field_type_init((void *) ft, id, 1);
+ _ctf_field_class_init((void *) fc, type, 1);
}
static inline
-void _ctf_field_type_int_init(struct ctf_field_type_int *ft,
- enum ctf_field_type_id id)
+void _ctf_field_class_int_init(struct ctf_field_class_int *fc,
+ enum ctf_field_class_type type)
{
- _ctf_field_type_bit_array_init((void *) ft, id);
- ft->meaning = CTF_FIELD_TYPE_MEANING_NONE;
- ft->storing_index = -1;
+ _ctf_field_class_bit_array_init((void *) fc, type);
+ fc->meaning = CTF_FIELD_CLASS_MEANING_NONE;
+ fc->storing_index = -1;
}
static inline
}
static inline
-void _ctf_named_field_type_init(struct ctf_named_field_type *named_ft)
+void _ctf_named_field_class_init(struct ctf_named_field_class *named_fc)
{
- BT_ASSERT(named_ft);
- named_ft->name = g_string_new(NULL);
- BT_ASSERT(named_ft->name);
+ BT_ASSERT(named_fc);
+ named_fc->name = g_string_new(NULL);
+ BT_ASSERT(named_fc->name);
}
static inline
-void _ctf_named_field_type_fini(struct ctf_named_field_type *named_ft)
+void _ctf_named_field_class_fini(struct ctf_named_field_class *named_fc)
{
- BT_ASSERT(named_ft);
+ BT_ASSERT(named_fc);
- if (named_ft->name) {
- g_string_free(named_ft->name, TRUE);
+ if (named_fc->name) {
+ g_string_free(named_fc->name, TRUE);
}
- ctf_field_type_destroy(named_ft->ft);
+ ctf_field_class_destroy(named_fc->fc);
}
static inline
-void _ctf_field_type_enum_mapping_init(
- struct ctf_field_type_enum_mapping *mapping)
+void _ctf_field_class_enum_mapping_init(
+ struct ctf_field_class_enum_mapping *mapping)
{
BT_ASSERT(mapping);
mapping->label = g_string_new(NULL);
}
static inline
-void _ctf_field_type_enum_mapping_fini(
- struct ctf_field_type_enum_mapping *mapping)
+void _ctf_field_class_enum_mapping_fini(
+ struct ctf_field_class_enum_mapping *mapping)
{
BT_ASSERT(mapping);
}
static inline
-struct ctf_field_type_int *ctf_field_type_int_create(void)
+struct ctf_field_class_int *ctf_field_class_int_create(void)
{
- struct ctf_field_type_int *ft = g_new0(struct ctf_field_type_int, 1);
+ struct ctf_field_class_int *fc = g_new0(struct ctf_field_class_int, 1);
- BT_ASSERT(ft);
- _ctf_field_type_int_init(ft, CTF_FIELD_TYPE_ID_INT);
- return ft;
+ BT_ASSERT(fc);
+ _ctf_field_class_int_init(fc, CTF_FIELD_CLASS_TYPE_INT);
+ return fc;
}
static inline
-struct ctf_field_type_float *ctf_field_type_float_create(void)
+struct ctf_field_class_float *ctf_field_class_float_create(void)
{
- struct ctf_field_type_float *ft =
- g_new0(struct ctf_field_type_float, 1);
+ struct ctf_field_class_float *fc =
+ g_new0(struct ctf_field_class_float, 1);
- BT_ASSERT(ft);
- _ctf_field_type_bit_array_init((void *) ft, CTF_FIELD_TYPE_ID_FLOAT);
- return ft;
+ BT_ASSERT(fc);
+ _ctf_field_class_bit_array_init((void *) fc, CTF_FIELD_CLASS_TYPE_FLOAT);
+ return fc;
}
static inline
-struct ctf_field_type_string *ctf_field_type_string_create(void)
+struct ctf_field_class_string *ctf_field_class_string_create(void)
{
- struct ctf_field_type_string *ft =
- g_new0(struct ctf_field_type_string, 1);
+ struct ctf_field_class_string *fc =
+ g_new0(struct ctf_field_class_string, 1);
- BT_ASSERT(ft);
- _ctf_field_type_init((void *) ft, CTF_FIELD_TYPE_ID_STRING, 8);
- return ft;
+ BT_ASSERT(fc);
+ _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_TYPE_STRING, 8);
+ return fc;
}
static inline
-struct ctf_field_type_enum *ctf_field_type_enum_create(void)
+struct ctf_field_class_enum *ctf_field_class_enum_create(void)
{
- struct ctf_field_type_enum *ft = g_new0(struct ctf_field_type_enum, 1);
+ struct ctf_field_class_enum *fc = g_new0(struct ctf_field_class_enum, 1);
- BT_ASSERT(ft);
- _ctf_field_type_int_init((void *) ft, CTF_FIELD_TYPE_ID_ENUM);
- ft->mappings = g_array_new(FALSE, TRUE,
- sizeof(struct ctf_field_type_enum_mapping));
- BT_ASSERT(ft->mappings);
- return ft;
+ BT_ASSERT(fc);
+ _ctf_field_class_int_init((void *) fc, CTF_FIELD_CLASS_TYPE_ENUM);
+ fc->mappings = g_array_new(FALSE, TRUE,
+ sizeof(struct ctf_field_class_enum_mapping));
+ BT_ASSERT(fc->mappings);
+ return fc;
}
static inline
-struct ctf_field_type_struct *ctf_field_type_struct_create(void)
+struct ctf_field_class_struct *ctf_field_class_struct_create(void)
{
- struct ctf_field_type_struct *ft =
- g_new0(struct ctf_field_type_struct, 1);
+ struct ctf_field_class_struct *fc =
+ g_new0(struct ctf_field_class_struct, 1);
- BT_ASSERT(ft);
- _ctf_field_type_init((void *) ft, CTF_FIELD_TYPE_ID_STRUCT, 1);
- ft->members = g_array_new(FALSE, TRUE,
- sizeof(struct ctf_named_field_type));
- BT_ASSERT(ft->members);
- ft->base.is_compound = true;
- return ft;
+ BT_ASSERT(fc);
+ _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_TYPE_STRUCT, 1);
+ fc->members = g_array_new(FALSE, TRUE,
+ sizeof(struct ctf_named_field_class));
+ BT_ASSERT(fc->members);
+ fc->base.is_compound = true;
+ return fc;
}
static inline
-struct ctf_field_type_variant *ctf_field_type_variant_create(void)
+struct ctf_field_class_variant *ctf_field_class_variant_create(void)
{
- struct ctf_field_type_variant *ft =
- g_new0(struct ctf_field_type_variant, 1);
+ struct ctf_field_class_variant *fc =
+ g_new0(struct ctf_field_class_variant, 1);
- BT_ASSERT(ft);
- _ctf_field_type_init((void *) ft, CTF_FIELD_TYPE_ID_VARIANT, 1);
- ft->options = g_array_new(FALSE, TRUE,
- sizeof(struct ctf_named_field_type));
- BT_ASSERT(ft->options);
- ft->ranges = g_array_new(FALSE, TRUE,
- sizeof(struct ctf_field_type_variant_range));
- BT_ASSERT(ft->ranges);
- ft->tag_ref = g_string_new(NULL);
- BT_ASSERT(ft->tag_ref);
- ctf_field_path_init(&ft->tag_path);
- ft->base.is_compound = true;
- return ft;
+ BT_ASSERT(fc);
+ _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_TYPE_VARIANT, 1);
+ fc->options = g_array_new(FALSE, TRUE,
+ sizeof(struct ctf_named_field_class));
+ BT_ASSERT(fc->options);
+ fc->ranges = g_array_new(FALSE, TRUE,
+ sizeof(struct ctf_field_class_variant_range));
+ BT_ASSERT(fc->ranges);
+ fc->tag_ref = g_string_new(NULL);
+ BT_ASSERT(fc->tag_ref);
+ ctf_field_path_init(&fc->tag_path);
+ fc->base.is_compound = true;
+ return fc;
}
static inline
-struct ctf_field_type_array *ctf_field_type_array_create(void)
+struct ctf_field_class_array *ctf_field_class_array_create(void)
{
- struct ctf_field_type_array *ft =
- g_new0(struct ctf_field_type_array, 1);
+ struct ctf_field_class_array *fc =
+ g_new0(struct ctf_field_class_array, 1);
- BT_ASSERT(ft);
- _ctf_field_type_init((void *) ft, CTF_FIELD_TYPE_ID_ARRAY, 1);
- ft->base.base.is_compound = true;
- return ft;
+ BT_ASSERT(fc);
+ _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_TYPE_ARRAY, 1);
+ fc->base.base.is_compound = true;
+ return fc;
}
static inline
-struct ctf_field_type_sequence *ctf_field_type_sequence_create(void)
+struct ctf_field_class_sequence *ctf_field_class_sequence_create(void)
{
- struct ctf_field_type_sequence *ft =
- g_new0(struct ctf_field_type_sequence, 1);
+ struct ctf_field_class_sequence *fc =
+ g_new0(struct ctf_field_class_sequence, 1);
- BT_ASSERT(ft);
- _ctf_field_type_init((void *) ft, CTF_FIELD_TYPE_ID_SEQUENCE, 1);
- ft->length_ref = g_string_new(NULL);
- BT_ASSERT(ft->length_ref);
- ctf_field_path_init(&ft->length_path);
- ft->base.base.is_compound = true;
- return ft;
+ BT_ASSERT(fc);
+ _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_TYPE_SEQUENCE, 1);
+ fc->length_ref = g_string_new(NULL);
+ BT_ASSERT(fc->length_ref);
+ ctf_field_path_init(&fc->length_path);
+ fc->base.base.is_compound = true;
+ return fc;
}
static inline
-void _ctf_field_type_int_destroy(struct ctf_field_type_int *ft)
+void _ctf_field_class_int_destroy(struct ctf_field_class_int *fc)
{
- BT_ASSERT(ft);
- bt_put(ft->mapped_clock_class);
- g_free(ft);
+ BT_ASSERT(fc);
+ g_free(fc);
}
static inline
-void _ctf_field_type_enum_destroy(struct ctf_field_type_enum *ft)
+void _ctf_field_class_enum_destroy(struct ctf_field_class_enum *fc)
{
- BT_ASSERT(ft);
- bt_put(ft->base.mapped_clock_class);
+ BT_ASSERT(fc);
- if (ft->mappings) {
+ if (fc->mappings) {
uint64_t i;
- for (i = 0; i < ft->mappings->len; i++) {
- struct ctf_field_type_enum_mapping *mapping =
- &g_array_index(ft->mappings,
- struct ctf_field_type_enum_mapping, i);
+ for (i = 0; i < fc->mappings->len; i++) {
+ struct ctf_field_class_enum_mapping *mapping =
+ &g_array_index(fc->mappings,
+ struct ctf_field_class_enum_mapping, i);
- _ctf_field_type_enum_mapping_fini(mapping);
+ _ctf_field_class_enum_mapping_fini(mapping);
}
- g_array_free(ft->mappings, TRUE);
+ g_array_free(fc->mappings, TRUE);
}
- g_free(ft);
+ g_free(fc);
}
static inline
-void _ctf_field_type_float_destroy(struct ctf_field_type_float *ft)
+void _ctf_field_class_float_destroy(struct ctf_field_class_float *fc)
{
- BT_ASSERT(ft);
- g_free(ft);
+ BT_ASSERT(fc);
+ g_free(fc);
}
static inline
-void _ctf_field_type_string_destroy(struct ctf_field_type_string *ft)
+void _ctf_field_class_string_destroy(struct ctf_field_class_string *fc)
{
- BT_ASSERT(ft);
- g_free(ft);
+ BT_ASSERT(fc);
+ g_free(fc);
}
static inline
-void _ctf_field_type_struct_destroy(struct ctf_field_type_struct *ft)
+void _ctf_field_class_struct_destroy(struct ctf_field_class_struct *fc)
{
- BT_ASSERT(ft);
+ BT_ASSERT(fc);
- if (ft->members) {
+ if (fc->members) {
uint64_t i;
- for (i = 0; i < ft->members->len; i++) {
- struct ctf_named_field_type *named_ft =
- &g_array_index(ft->members,
- struct ctf_named_field_type, i);
+ for (i = 0; i < fc->members->len; i++) {
+ struct ctf_named_field_class *named_fc =
+ &g_array_index(fc->members,
+ struct ctf_named_field_class, i);
- _ctf_named_field_type_fini(named_ft);
+ _ctf_named_field_class_fini(named_fc);
}
- g_array_free(ft->members, TRUE);
+ g_array_free(fc->members, TRUE);
}
- g_free(ft);
+ g_free(fc);
}
static inline
-void _ctf_field_type_array_base_fini(struct ctf_field_type_array_base *ft)
+void _ctf_field_class_array_base_fini(struct ctf_field_class_array_base *fc)
{
- BT_ASSERT(ft);
- ctf_field_type_destroy(ft->elem_ft);
+ BT_ASSERT(fc);
+ ctf_field_class_destroy(fc->elem_fc);
}
static inline
-void _ctf_field_type_array_destroy(struct ctf_field_type_array *ft)
+void _ctf_field_class_array_destroy(struct ctf_field_class_array *fc)
{
- BT_ASSERT(ft);
- _ctf_field_type_array_base_fini((void *) ft);
- g_free(ft);
+ BT_ASSERT(fc);
+ _ctf_field_class_array_base_fini((void *) fc);
+ g_free(fc);
}
static inline
-void _ctf_field_type_sequence_destroy(struct ctf_field_type_sequence *ft)
+void _ctf_field_class_sequence_destroy(struct ctf_field_class_sequence *fc)
{
- BT_ASSERT(ft);
- _ctf_field_type_array_base_fini((void *) ft);
+ BT_ASSERT(fc);
+ _ctf_field_class_array_base_fini((void *) fc);
- if (ft->length_ref) {
- g_string_free(ft->length_ref, TRUE);
+ if (fc->length_ref) {
+ g_string_free(fc->length_ref, TRUE);
}
- ctf_field_path_fini(&ft->length_path);
- g_free(ft);
+ ctf_field_path_fini(&fc->length_path);
+ g_free(fc);
}
static inline
-void _ctf_field_type_variant_destroy(struct ctf_field_type_variant *ft)
+void _ctf_field_class_variant_destroy(struct ctf_field_class_variant *fc)
{
- BT_ASSERT(ft);
+ BT_ASSERT(fc);
- if (ft->options) {
+ if (fc->options) {
uint64_t i;
- for (i = 0; i < ft->options->len; i++) {
- struct ctf_named_field_type *named_ft =
- &g_array_index(ft->options,
- struct ctf_named_field_type, i);
+ for (i = 0; i < fc->options->len; i++) {
+ struct ctf_named_field_class *named_fc =
+ &g_array_index(fc->options,
+ struct ctf_named_field_class, i);
- _ctf_named_field_type_fini(named_ft);
+ _ctf_named_field_class_fini(named_fc);
}
- g_array_free(ft->options, TRUE);
+ g_array_free(fc->options, TRUE);
}
- if (ft->ranges) {
- g_array_free(ft->ranges, TRUE);
+ if (fc->ranges) {
+ g_array_free(fc->ranges, TRUE);
}
- if (ft->tag_ref) {
- g_string_free(ft->tag_ref, TRUE);
+ if (fc->tag_ref) {
+ g_string_free(fc->tag_ref, TRUE);
}
- ctf_field_path_fini(&ft->tag_path);
- g_free(ft);
+ ctf_field_path_fini(&fc->tag_path);
+ g_free(fc);
}
static inline
-void ctf_field_type_destroy(struct ctf_field_type *ft)
+void ctf_field_class_destroy(struct ctf_field_class *fc)
{
- if (!ft) {
+ if (!fc) {
return;
}
- switch (ft->id) {
- case CTF_FIELD_TYPE_ID_INT:
- _ctf_field_type_int_destroy((void *) ft);
+ switch (fc->type) {
+ case CTF_FIELD_CLASS_TYPE_INT:
+ _ctf_field_class_int_destroy((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_ENUM:
- _ctf_field_type_enum_destroy((void *) ft);
+ case CTF_FIELD_CLASS_TYPE_ENUM:
+ _ctf_field_class_enum_destroy((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_FLOAT:
- _ctf_field_type_float_destroy((void *) ft);
+ case CTF_FIELD_CLASS_TYPE_FLOAT:
+ _ctf_field_class_float_destroy((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_STRING:
- _ctf_field_type_string_destroy((void *) ft);
+ case CTF_FIELD_CLASS_TYPE_STRING:
+ _ctf_field_class_string_destroy((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_STRUCT:
- _ctf_field_type_struct_destroy((void *) ft);
+ case CTF_FIELD_CLASS_TYPE_STRUCT:
+ _ctf_field_class_struct_destroy((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_ARRAY:
- _ctf_field_type_array_destroy((void *) ft);
+ case CTF_FIELD_CLASS_TYPE_ARRAY:
+ _ctf_field_class_array_destroy((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_SEQUENCE:
- _ctf_field_type_sequence_destroy((void *) ft);
+ case CTF_FIELD_CLASS_TYPE_SEQUENCE:
+ _ctf_field_class_sequence_destroy((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_VARIANT:
- _ctf_field_type_variant_destroy((void *) ft);
+ case CTF_FIELD_CLASS_TYPE_VARIANT:
+ _ctf_field_class_variant_destroy((void *) fc);
break;
default:
abort();
}
static inline
-void ctf_field_type_enum_append_mapping(struct ctf_field_type_enum *ft,
+void ctf_field_class_enum_append_mapping(struct ctf_field_class_enum *fc,
const char *label, uint64_t u_lower, uint64_t u_upper)
{
- struct ctf_field_type_enum_mapping *mapping;
+ struct ctf_field_class_enum_mapping *mapping;
- BT_ASSERT(ft);
+ BT_ASSERT(fc);
BT_ASSERT(label);
- g_array_set_size(ft->mappings, ft->mappings->len + 1);
+ g_array_set_size(fc->mappings, fc->mappings->len + 1);
- mapping = &g_array_index(ft->mappings,
- struct ctf_field_type_enum_mapping, ft->mappings->len - 1);
- _ctf_field_type_enum_mapping_init(mapping);
+ mapping = &g_array_index(fc->mappings,
+ struct ctf_field_class_enum_mapping, fc->mappings->len - 1);
+ _ctf_field_class_enum_mapping_init(mapping);
g_string_assign(mapping->label, label);
mapping->range.lower.u = u_lower;
mapping->range.upper.u = u_upper;
}
static inline
-struct ctf_field_type_enum_mapping *ctf_field_type_enum_borrow_mapping_by_index(
- struct ctf_field_type_enum *ft, uint64_t index)
+struct ctf_field_class_enum_mapping *ctf_field_class_enum_borrow_mapping_by_index(
+ struct ctf_field_class_enum *fc, uint64_t index)
{
- BT_ASSERT(ft);
- BT_ASSERT(index < ft->mappings->len);
- return &g_array_index(ft->mappings, struct ctf_field_type_enum_mapping,
+ BT_ASSERT(fc);
+ BT_ASSERT(index < fc->mappings->len);
+ return &g_array_index(fc->mappings, struct ctf_field_class_enum_mapping,
index);
}
static inline
-struct ctf_named_field_type *ctf_field_type_struct_borrow_member_by_index(
- struct ctf_field_type_struct *ft, uint64_t index)
+struct ctf_named_field_class *ctf_field_class_struct_borrow_member_by_index(
+ struct ctf_field_class_struct *fc, uint64_t index)
{
- BT_ASSERT(ft);
- BT_ASSERT(index < ft->members->len);
- return &g_array_index(ft->members, struct ctf_named_field_type,
+ BT_ASSERT(fc);
+ BT_ASSERT(index < fc->members->len);
+ return &g_array_index(fc->members, struct ctf_named_field_class,
index);
}
static inline
-struct ctf_named_field_type *ctf_field_type_struct_borrow_member_by_name(
- struct ctf_field_type_struct *ft, const char *name)
+struct ctf_named_field_class *ctf_field_class_struct_borrow_member_by_name(
+ struct ctf_field_class_struct *fc, const char *name)
{
uint64_t i;
- struct ctf_named_field_type *ret_named_ft = NULL;
+ struct ctf_named_field_class *ret_named_fc = NULL;
- BT_ASSERT(ft);
+ BT_ASSERT(fc);
BT_ASSERT(name);
- for (i = 0; i < ft->members->len; i++) {
- struct ctf_named_field_type *named_ft =
- ctf_field_type_struct_borrow_member_by_index(ft, i);
+ 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);
- if (strcmp(name, named_ft->name->str) == 0) {
- ret_named_ft = named_ft;
+ if (strcmp(name, named_fc->name->str) == 0) {
+ ret_named_fc = named_fc;
goto end;
}
}
end:
- return ret_named_ft;
+ return ret_named_fc;
}
static inline
-struct ctf_field_type *ctf_field_type_struct_borrow_member_field_type_by_name(
- struct ctf_field_type_struct *struct_ft, const char *name)
+struct ctf_field_class *ctf_field_class_struct_borrow_member_field_class_by_name(
+ struct ctf_field_class_struct *struct_fc, const char *name)
{
- struct ctf_named_field_type *named_ft = NULL;
- struct ctf_field_type *ft = NULL;
+ struct ctf_named_field_class *named_fc = NULL;
+ struct ctf_field_class *fc = NULL;
- if (!struct_ft) {
+ if (!struct_fc) {
goto end;
}
- named_ft = ctf_field_type_struct_borrow_member_by_name(struct_ft, name);
- if (!named_ft) {
+ named_fc = ctf_field_class_struct_borrow_member_by_name(struct_fc, name);
+ if (!named_fc) {
goto end;
}
- ft = named_ft->ft;
+ fc = named_fc->fc;
end:
- return ft;
+ return fc;
}
static inline
-struct ctf_field_type_int *
-ctf_field_type_struct_borrow_member_int_field_type_by_name(
- struct ctf_field_type_struct *struct_ft, const char *name)
+struct ctf_field_class_int *
+ctf_field_class_struct_borrow_member_int_field_class_by_name(
+ struct ctf_field_class_struct *struct_fc, const char *name)
{
- struct ctf_field_type_int *int_ft = NULL;
+ struct ctf_field_class_int *int_fc = NULL;
- int_ft = (void *)
- ctf_field_type_struct_borrow_member_field_type_by_name(
- struct_ft, name);
- if (!int_ft) {
+ int_fc = (void *)
+ ctf_field_class_struct_borrow_member_field_class_by_name(
+ struct_fc, name);
+ if (!int_fc) {
goto end;
}
- if (int_ft->base.base.id != CTF_FIELD_TYPE_ID_INT &&
- int_ft->base.base.id != CTF_FIELD_TYPE_ID_ENUM) {
- int_ft = NULL;
+ if (int_fc->base.base.type != CTF_FIELD_CLASS_TYPE_INT &&
+ int_fc->base.base.type != CTF_FIELD_CLASS_TYPE_ENUM) {
+ int_fc = NULL;
goto end;
}
end:
- return int_ft;
+ return int_fc;
}
static inline
-void ctf_field_type_struct_append_member(struct ctf_field_type_struct *ft,
- const char *name, struct ctf_field_type *member_ft)
+void ctf_field_class_struct_append_member(struct ctf_field_class_struct *fc,
+ const char *name, struct ctf_field_class *member_fc)
{
- struct ctf_named_field_type *named_ft;
+ struct ctf_named_field_class *named_fc;
- BT_ASSERT(ft);
+ BT_ASSERT(fc);
BT_ASSERT(name);
- g_array_set_size(ft->members, ft->members->len + 1);
+ g_array_set_size(fc->members, fc->members->len + 1);
- named_ft = &g_array_index(ft->members, struct ctf_named_field_type,
- ft->members->len - 1);
- _ctf_named_field_type_init(named_ft);
- g_string_assign(named_ft->name, name);
- named_ft->ft = member_ft;
+ named_fc = &g_array_index(fc->members, struct ctf_named_field_class,
+ fc->members->len - 1);
+ _ctf_named_field_class_init(named_fc);
+ g_string_assign(named_fc->name, name);
+ named_fc->fc = member_fc;
- if (member_ft->alignment > ft->base.alignment) {
- ft->base.alignment = member_ft->alignment;
+ if (member_fc->alignment > fc->base.alignment) {
+ fc->base.alignment = member_fc->alignment;
}
}
static inline
-struct ctf_named_field_type *ctf_field_type_variant_borrow_option_by_index(
- struct ctf_field_type_variant *ft, uint64_t index)
+struct ctf_named_field_class *ctf_field_class_variant_borrow_option_by_index(
+ struct ctf_field_class_variant *fc, uint64_t index)
{
- BT_ASSERT(ft);
- BT_ASSERT(index < ft->options->len);
- return &g_array_index(ft->options, struct ctf_named_field_type,
+ BT_ASSERT(fc);
+ BT_ASSERT(index < fc->options->len);
+ return &g_array_index(fc->options, struct ctf_named_field_class,
index);
}
static inline
-struct ctf_named_field_type *ctf_field_type_variant_borrow_option_by_name(
- struct ctf_field_type_variant *ft, const char *name)
+struct ctf_named_field_class *ctf_field_class_variant_borrow_option_by_name(
+ struct ctf_field_class_variant *fc, const char *name)
{
uint64_t i;
- struct ctf_named_field_type *ret_named_ft = NULL;
+ struct ctf_named_field_class *ret_named_fc = NULL;
- BT_ASSERT(ft);
+ BT_ASSERT(fc);
BT_ASSERT(name);
- for (i = 0; i < ft->options->len; i++) {
- struct ctf_named_field_type *named_ft =
- ctf_field_type_variant_borrow_option_by_index(ft, i);
+ for (i = 0; i < fc->options->len; i++) {
+ struct ctf_named_field_class *named_fc =
+ ctf_field_class_variant_borrow_option_by_index(fc, i);
- if (strcmp(name, named_ft->name->str) == 0) {
- ret_named_ft = named_ft;
+ if (strcmp(name, named_fc->name->str) == 0) {
+ ret_named_fc = named_fc;
goto end;
}
}
end:
- return ret_named_ft;
+ return ret_named_fc;
}
static inline
-struct ctf_field_type_variant_range *
-ctf_field_type_variant_borrow_range_by_index(
- struct ctf_field_type_variant *ft, uint64_t index)
+struct ctf_field_class_variant_range *
+ctf_field_class_variant_borrow_range_by_index(
+ struct ctf_field_class_variant *fc, uint64_t index)
{
- BT_ASSERT(ft);
- BT_ASSERT(index < ft->ranges->len);
- return &g_array_index(ft->ranges, struct ctf_field_type_variant_range,
+ BT_ASSERT(fc);
+ BT_ASSERT(index < fc->ranges->len);
+ return &g_array_index(fc->ranges, struct ctf_field_class_variant_range,
index);
}
static inline
-void ctf_field_type_variant_append_option(struct ctf_field_type_variant *ft,
- const char *name, struct ctf_field_type *option_ft)
+void ctf_field_class_variant_append_option(struct ctf_field_class_variant *fc,
+ const char *name, struct ctf_field_class *option_fc)
{
- struct ctf_named_field_type *named_ft;
+ struct ctf_named_field_class *named_fc;
- BT_ASSERT(ft);
+ BT_ASSERT(fc);
BT_ASSERT(name);
- g_array_set_size(ft->options, ft->options->len + 1);
+ g_array_set_size(fc->options, fc->options->len + 1);
- named_ft = &g_array_index(ft->options, struct ctf_named_field_type,
- ft->options->len - 1);
- _ctf_named_field_type_init(named_ft);
- g_string_assign(named_ft->name, name);
- named_ft->ft = option_ft;
+ named_fc = &g_array_index(fc->options, struct ctf_named_field_class,
+ fc->options->len - 1);
+ _ctf_named_field_class_init(named_fc);
+ g_string_assign(named_fc->name, name);
+ named_fc->fc = option_fc;
}
static inline
-void ctf_field_type_variant_set_tag_field_type(
- struct ctf_field_type_variant *ft,
- struct ctf_field_type_enum *tag_ft)
+void ctf_field_class_variant_set_tag_field_class(
+ struct ctf_field_class_variant *fc,
+ struct ctf_field_class_enum *tag_fc)
{
uint64_t option_i;
- BT_ASSERT(ft);
- BT_ASSERT(tag_ft);
- ft->tag_ft = tag_ft;
+ BT_ASSERT(fc);
+ BT_ASSERT(tag_fc);
+ fc->tag_fc = tag_fc;
- for (option_i = 0; option_i < ft->options->len; option_i++) {
+ for (option_i = 0; option_i < fc->options->len; option_i++) {
uint64_t mapping_i;
- struct ctf_named_field_type *named_ft =
- ctf_field_type_variant_borrow_option_by_index(
- ft, option_i);
+ struct ctf_named_field_class *named_fc =
+ ctf_field_class_variant_borrow_option_by_index(
+ fc, option_i);
- for (mapping_i = 0; mapping_i < tag_ft->mappings->len;
+ for (mapping_i = 0; mapping_i < tag_fc->mappings->len;
mapping_i++) {
- struct ctf_field_type_enum_mapping *mapping =
- ctf_field_type_enum_borrow_mapping_by_index(
- tag_ft, mapping_i);
+ struct ctf_field_class_enum_mapping *mapping =
+ ctf_field_class_enum_borrow_mapping_by_index(
+ tag_fc, mapping_i);
- if (strcmp(named_ft->name->str,
+ if (strcmp(named_fc->name->str,
mapping->label->str) == 0) {
- struct ctf_field_type_variant_range range;
+ struct ctf_field_class_variant_range range;
range.range = mapping->range;
range.option_index = option_i;
- g_array_append_val(ft->ranges, range);
+ g_array_append_val(fc->ranges, range);
}
}
}
}
static inline
-struct ctf_field_type *ctf_field_type_compound_borrow_field_type_by_index(
- struct ctf_field_type *comp_ft, uint64_t index)
+struct ctf_field_class *ctf_field_class_compound_borrow_field_class_by_index(
+ struct ctf_field_class *comp_fc, uint64_t index)
{
- struct ctf_field_type *ft = NULL;
+ struct ctf_field_class *fc = NULL;
- switch (comp_ft->id) {
- case CTF_FIELD_TYPE_ID_STRUCT:
+ switch (comp_fc->type) {
+ case CTF_FIELD_CLASS_TYPE_STRUCT:
{
- struct ctf_named_field_type *named_ft =
- ctf_field_type_struct_borrow_member_by_index(
- (void *) comp_ft, index);
+ struct ctf_named_field_class *named_fc =
+ ctf_field_class_struct_borrow_member_by_index(
+ (void *) comp_fc, index);
- BT_ASSERT(named_ft);
- ft = named_ft->ft;
+ BT_ASSERT(named_fc);
+ fc = named_fc->fc;
break;
}
- case CTF_FIELD_TYPE_ID_VARIANT:
+ case CTF_FIELD_CLASS_TYPE_VARIANT:
{
- struct ctf_named_field_type *named_ft =
- ctf_field_type_variant_borrow_option_by_index(
- (void *) comp_ft, index);
+ struct ctf_named_field_class *named_fc =
+ ctf_field_class_variant_borrow_option_by_index(
+ (void *) comp_fc, index);
- BT_ASSERT(named_ft);
- ft = named_ft->ft;
+ BT_ASSERT(named_fc);
+ fc = named_fc->fc;
break;
}
- case CTF_FIELD_TYPE_ID_ARRAY:
- case CTF_FIELD_TYPE_ID_SEQUENCE:
+ case CTF_FIELD_CLASS_TYPE_ARRAY:
+ case CTF_FIELD_CLASS_TYPE_SEQUENCE:
{
- struct ctf_field_type_array_base *array_ft = (void *) comp_ft;
+ struct ctf_field_class_array_base *array_fc = (void *) comp_fc;
- ft = array_ft->elem_ft;
+ fc = array_fc->elem_fc;
break;
}
default:
break;
}
- return ft;
+ return fc;
}
static inline
-uint64_t ctf_field_type_compound_get_field_type_count(struct ctf_field_type *ft)
+uint64_t ctf_field_class_compound_get_field_class_count(struct ctf_field_class *fc)
{
uint64_t field_count;
- switch (ft->id) {
- case CTF_FIELD_TYPE_ID_STRUCT:
+ switch (fc->type) {
+ case CTF_FIELD_CLASS_TYPE_STRUCT:
{
- struct ctf_field_type_struct *struct_ft = (void *) ft;
+ struct ctf_field_class_struct *struct_fc = (void *) fc;
- field_count = struct_ft->members->len;
+ field_count = struct_fc->members->len;
break;
}
- case CTF_FIELD_TYPE_ID_VARIANT:
+ case CTF_FIELD_CLASS_TYPE_VARIANT:
{
- struct ctf_field_type_variant *var_ft = (void *) ft;
+ struct ctf_field_class_variant *var_fc = (void *) fc;
- field_count = var_ft->options->len;
+ field_count = var_fc->options->len;
break;
}
- case CTF_FIELD_TYPE_ID_ARRAY:
- case CTF_FIELD_TYPE_ID_SEQUENCE:
+ case CTF_FIELD_CLASS_TYPE_ARRAY:
+ case CTF_FIELD_CLASS_TYPE_SEQUENCE:
/*
* Array and sequence types always contain a single
* member (the element type).
}
static inline
-int64_t ctf_field_type_compound_get_field_type_index_from_name(
- struct ctf_field_type *ft, const char *name)
+int64_t ctf_field_class_compound_get_field_class_index_from_name(
+ struct ctf_field_class *fc, const char *name)
{
int64_t ret_index = -1;
uint64_t i;
- switch (ft->id) {
- case CTF_FIELD_TYPE_ID_STRUCT:
+ switch (fc->type) {
+ case CTF_FIELD_CLASS_TYPE_STRUCT:
{
- struct ctf_field_type_struct *struct_ft = (void *) ft;
+ struct ctf_field_class_struct *struct_fc = (void *) fc;
- for (i = 0; i < struct_ft->members->len; i++) {
- struct ctf_named_field_type *named_ft =
- ctf_field_type_struct_borrow_member_by_index(
- struct_ft, i);
+ 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);
- if (strcmp(name, named_ft->name->str) == 0) {
+ if (strcmp(name, named_fc->name->str) == 0) {
ret_index = (int64_t) i;
goto end;
}
break;
}
- case CTF_FIELD_TYPE_ID_VARIANT:
+ case CTF_FIELD_CLASS_TYPE_VARIANT:
{
- struct ctf_field_type_variant *var_ft = (void *) ft;
+ struct ctf_field_class_variant *var_fc = (void *) fc;
- for (i = 0; i < var_ft->options->len; i++) {
- struct ctf_named_field_type *named_ft =
- ctf_field_type_variant_borrow_option_by_index(
- var_ft, i);
+ 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);
- if (strcmp(name, named_ft->name->str) == 0) {
+ if (strcmp(name, named_fc->name->str) == 0) {
ret_index = (int64_t) i;
goto end;
}
g_array_set_size(fp->path, 0);
}
+static inline
+const char *ctf_scope_string(enum ctf_scope scope)
+{
+ switch (scope) {
+ case CTF_SCOPE_PACKET_HEADER:
+ return "CTF_SCOPE_PACKET_HEADER";
+ case CTF_SCOPE_PACKET_CONTEXT:
+ return "CTF_SCOPE_PACKET_CONTEXT";
+ case CTF_SCOPE_EVENT_HEADER:
+ return "CTF_SCOPE_EVENT_HEADER";
+ case CTF_SCOPE_EVENT_COMMON_CONTEXT:
+ return "CTF_SCOPE_EVENT_COMMON_CONTEXT";
+ case CTF_SCOPE_EVENT_SPECIFIC_CONTEXT:
+ return "CTF_SCOPE_EVENT_SPECIFIC_CONTEXT";
+ case CTF_SCOPE_EVENT_PAYLOAD:
+ return "CTF_SCOPE_EVENT_PAYLOAD";
+ default:
+ abort();
+ }
+}
+
static inline
GString *ctf_field_path_string(struct ctf_field_path *path)
{
goto end;
}
- g_string_append_printf(str, "[%s", bt_common_scope_string(
- path->root));
+ g_string_append_printf(str, "[%s", ctf_scope_string(path->root));
for (i = 0; i < path->path->len; i++) {
g_string_append_printf(str, ", %" PRId64,
}
static inline
-struct ctf_field_type *ctf_field_path_borrow_field_type(
+struct ctf_field_class *ctf_field_path_borrow_field_class(
struct ctf_field_path *field_path,
struct ctf_trace_class *tc,
struct ctf_stream_class *sc,
struct ctf_event_class *ec)
{
uint64_t i;
- struct ctf_field_type *ft;
+ struct ctf_field_class *fc;
switch (field_path->root) {
- case BT_SCOPE_PACKET_HEADER:
- ft = tc->packet_header_ft;
+ case CTF_SCOPE_PACKET_HEADER:
+ fc = tc->packet_header_fc;
break;
- case BT_SCOPE_PACKET_CONTEXT:
- ft = sc->packet_context_ft;
+ case CTF_SCOPE_PACKET_CONTEXT:
+ fc = sc->packet_context_fc;
break;
- case BT_SCOPE_EVENT_HEADER:
- ft = sc->event_header_ft;
+ case CTF_SCOPE_EVENT_HEADER:
+ fc = sc->event_header_fc;
break;
- case BT_SCOPE_EVENT_COMMON_CONTEXT:
- ft = sc->event_common_context_ft;
+ case CTF_SCOPE_EVENT_COMMON_CONTEXT:
+ fc = sc->event_common_context_fc;
break;
- case BT_SCOPE_EVENT_SPECIFIC_CONTEXT:
- ft = ec->spec_context_ft;
+ case CTF_SCOPE_EVENT_SPECIFIC_CONTEXT:
+ fc = ec->spec_context_fc;
break;
- case BT_SCOPE_EVENT_PAYLOAD:
- ft = ec->payload_ft;
+ case CTF_SCOPE_EVENT_PAYLOAD:
+ fc = ec->payload_fc;
break;
default:
abort();
}
- BT_ASSERT(ft);
+ BT_ASSERT(fc);
for (i = 0; i < field_path->path->len; i++) {
int64_t child_index =
ctf_field_path_borrow_index_by_index(field_path, i);
- struct ctf_field_type *child_ft =
- ctf_field_type_compound_borrow_field_type_by_index(
- ft, child_index);
- BT_ASSERT(child_ft);
- ft = child_ft;
+ struct ctf_field_class *child_fc =
+ ctf_field_class_compound_borrow_field_class_by_index(
+ fc, child_index);
+ BT_ASSERT(child_fc);
+ fc = child_fc;
}
- BT_ASSERT(ft);
- return ft;
+ BT_ASSERT(fc);
+ return fc;
}
static inline
-struct ctf_field_type *ctf_field_type_copy(struct ctf_field_type *ft);
+struct ctf_field_class *ctf_field_class_copy(struct ctf_field_class *fc);
static inline
-void ctf_field_type_bit_array_copy_content(
- struct ctf_field_type_bit_array *dst_ft,
- struct ctf_field_type_bit_array *src_ft)
+void ctf_field_class_bit_array_copy_content(
+ struct ctf_field_class_bit_array *dst_fc,
+ struct ctf_field_class_bit_array *src_fc)
{
- BT_ASSERT(dst_ft);
- BT_ASSERT(src_ft);
- dst_ft->byte_order = src_ft->byte_order;
- dst_ft->size = src_ft->size;
+ BT_ASSERT(dst_fc);
+ BT_ASSERT(src_fc);
+ dst_fc->byte_order = src_fc->byte_order;
+ dst_fc->size = src_fc->size;
}
static inline
-void ctf_field_type_int_copy_content(
- struct ctf_field_type_int *dst_ft,
- struct ctf_field_type_int *src_ft)
+void ctf_field_class_int_copy_content(
+ struct ctf_field_class_int *dst_fc,
+ struct ctf_field_class_int *src_fc)
{
- ctf_field_type_bit_array_copy_content((void *) dst_ft, (void *) src_ft);
- dst_ft->meaning = src_ft->meaning;
- dst_ft->is_signed = src_ft->is_signed;
- dst_ft->disp_base = src_ft->disp_base;
- dst_ft->encoding = src_ft->encoding;
- dst_ft->mapped_clock_class = bt_get(src_ft->mapped_clock_class);
- dst_ft->storing_index = src_ft->storing_index;
+ ctf_field_class_bit_array_copy_content((void *) dst_fc, (void *) src_fc);
+ dst_fc->meaning = src_fc->meaning;
+ dst_fc->is_signed = src_fc->is_signed;
+ dst_fc->disp_base = src_fc->disp_base;
+ dst_fc->encoding = src_fc->encoding;
+ dst_fc->mapped_clock_class = src_fc->mapped_clock_class;
+ dst_fc->storing_index = src_fc->storing_index;
}
static inline
-struct ctf_field_type_int *_ctf_field_type_int_copy(
- struct ctf_field_type_int *ft)
+struct ctf_field_class_int *_ctf_field_class_int_copy(
+ struct ctf_field_class_int *fc)
{
- struct ctf_field_type_int *copy_ft = ctf_field_type_int_create();
+ struct ctf_field_class_int *copy_fc = ctf_field_class_int_create();
- BT_ASSERT(copy_ft);
- ctf_field_type_int_copy_content(copy_ft, ft);
- return copy_ft;
+ BT_ASSERT(copy_fc);
+ ctf_field_class_int_copy_content(copy_fc, fc);
+ return copy_fc;
}
static inline
-struct ctf_field_type_enum *_ctf_field_type_enum_copy(
- struct ctf_field_type_enum *ft)
+struct ctf_field_class_enum *_ctf_field_class_enum_copy(
+ struct ctf_field_class_enum *fc)
{
- struct ctf_field_type_enum *copy_ft = ctf_field_type_enum_create();
+ struct ctf_field_class_enum *copy_fc = ctf_field_class_enum_create();
uint64_t i;
- BT_ASSERT(copy_ft);
- ctf_field_type_int_copy_content((void *) copy_ft, (void *) ft);
+ BT_ASSERT(copy_fc);
+ ctf_field_class_int_copy_content((void *) copy_fc, (void *) fc);
- for (i = 0; i < ft->mappings->len; i++) {
- struct ctf_field_type_enum_mapping *mapping =
- &g_array_index(ft->mappings,
- struct ctf_field_type_enum_mapping, i);
+ for (i = 0; i < fc->mappings->len; i++) {
+ struct ctf_field_class_enum_mapping *mapping =
+ &g_array_index(fc->mappings,
+ struct ctf_field_class_enum_mapping, i);
- ctf_field_type_enum_append_mapping(copy_ft, mapping->label->str,
+ ctf_field_class_enum_append_mapping(copy_fc, mapping->label->str,
mapping->range.lower.u, mapping->range.upper.u);
}
- return copy_ft;
+ return copy_fc;
}
static inline
-struct ctf_field_type_float *_ctf_field_type_float_copy(
- struct ctf_field_type_float *ft)
+struct ctf_field_class_float *_ctf_field_class_float_copy(
+ struct ctf_field_class_float *fc)
{
- struct ctf_field_type_float *copy_ft = ctf_field_type_float_create();
+ struct ctf_field_class_float *copy_fc = ctf_field_class_float_create();
- BT_ASSERT(copy_ft);
- ctf_field_type_bit_array_copy_content((void *) copy_ft, (void *) ft);
- return copy_ft;
+ BT_ASSERT(copy_fc);
+ ctf_field_class_bit_array_copy_content((void *) copy_fc, (void *) fc);
+ return copy_fc;
}
static inline
-struct ctf_field_type_string *_ctf_field_type_string_copy(
- struct ctf_field_type_string *ft)
+struct ctf_field_class_string *_ctf_field_class_string_copy(
+ struct ctf_field_class_string *fc)
{
- struct ctf_field_type_string *copy_ft = ctf_field_type_string_create();
+ struct ctf_field_class_string *copy_fc = ctf_field_class_string_create();
- BT_ASSERT(copy_ft);
- return copy_ft;
+ BT_ASSERT(copy_fc);
+ return copy_fc;
}
static inline
-struct ctf_field_type_struct *_ctf_field_type_struct_copy(
- struct ctf_field_type_struct *ft)
+struct ctf_field_class_struct *_ctf_field_class_struct_copy(
+ struct ctf_field_class_struct *fc)
{
- struct ctf_field_type_struct *copy_ft = ctf_field_type_struct_create();
+ struct ctf_field_class_struct *copy_fc = ctf_field_class_struct_create();
uint64_t i;
- BT_ASSERT(copy_ft);
+ BT_ASSERT(copy_fc);
- for (i = 0; i < ft->members->len; i++) {
- struct ctf_named_field_type *named_ft =
- &g_array_index(ft->members,
- struct ctf_named_field_type, i);
+ for (i = 0; i < fc->members->len; i++) {
+ struct ctf_named_field_class *named_fc =
+ &g_array_index(fc->members,
+ struct ctf_named_field_class, i);
- ctf_field_type_struct_append_member(copy_ft,
- named_ft->name->str,
- ctf_field_type_copy(named_ft->ft));
+ ctf_field_class_struct_append_member(copy_fc,
+ named_fc->name->str,
+ ctf_field_class_copy(named_fc->fc));
}
- return copy_ft;
+ return copy_fc;
}
static inline
}
static inline
-struct ctf_field_type_variant *_ctf_field_type_variant_copy(
- struct ctf_field_type_variant *ft)
+struct ctf_field_class_variant *_ctf_field_class_variant_copy(
+ struct ctf_field_class_variant *fc)
{
- struct ctf_field_type_variant *copy_ft =
- ctf_field_type_variant_create();
+ struct ctf_field_class_variant *copy_fc =
+ ctf_field_class_variant_create();
uint64_t i;
- BT_ASSERT(copy_ft);
+ BT_ASSERT(copy_fc);
- for (i = 0; i < ft->options->len; i++) {
- struct ctf_named_field_type *named_ft =
- &g_array_index(ft->options,
- struct ctf_named_field_type, i);
+ for (i = 0; i < fc->options->len; i++) {
+ struct ctf_named_field_class *named_fc =
+ &g_array_index(fc->options,
+ struct ctf_named_field_class, i);
- ctf_field_type_variant_append_option(copy_ft,
- named_ft->name->str,
- ctf_field_type_copy(named_ft->ft));
+ ctf_field_class_variant_append_option(copy_fc,
+ named_fc->name->str,
+ ctf_field_class_copy(named_fc->fc));
}
- for (i = 0; i < ft->ranges->len; i++) {
- struct ctf_field_type_variant_range *range =
- &g_array_index(ft->ranges,
- struct ctf_field_type_variant_range, i);
+ for (i = 0; i < fc->ranges->len; i++) {
+ struct ctf_field_class_variant_range *range =
+ &g_array_index(fc->ranges,
+ struct ctf_field_class_variant_range, i);
- g_array_append_val(copy_ft->ranges, *range);
+ g_array_append_val(copy_fc->ranges, *range);
}
- ctf_field_path_copy_content(©_ft->tag_path, &ft->tag_path);
- g_string_assign(copy_ft->tag_ref, ft->tag_ref->str);
- copy_ft->stored_tag_index = ft->stored_tag_index;
- return copy_ft;
+ ctf_field_path_copy_content(©_fc->tag_path, &fc->tag_path);
+ g_string_assign(copy_fc->tag_ref, fc->tag_ref->str);
+ copy_fc->stored_tag_index = fc->stored_tag_index;
+ return copy_fc;
}
static inline
-void ctf_field_type_array_base_copy_content(
- struct ctf_field_type_array_base *dst_ft,
- struct ctf_field_type_array_base *src_ft)
+void ctf_field_class_array_base_copy_content(
+ struct ctf_field_class_array_base *dst_fc,
+ struct ctf_field_class_array_base *src_fc)
{
- BT_ASSERT(dst_ft);
- BT_ASSERT(src_ft);
- dst_ft->elem_ft = ctf_field_type_copy(src_ft->elem_ft);
- dst_ft->is_text = src_ft->is_text;
+ BT_ASSERT(dst_fc);
+ BT_ASSERT(src_fc);
+ dst_fc->elem_fc = ctf_field_class_copy(src_fc->elem_fc);
+ dst_fc->is_text = src_fc->is_text;
}
static inline
-struct ctf_field_type_array *_ctf_field_type_array_copy(
- struct ctf_field_type_array *ft)
+struct ctf_field_class_array *_ctf_field_class_array_copy(
+ struct ctf_field_class_array *fc)
{
- struct ctf_field_type_array *copy_ft = ctf_field_type_array_create();
+ struct ctf_field_class_array *copy_fc = ctf_field_class_array_create();
- BT_ASSERT(copy_ft);
- ctf_field_type_array_base_copy_content((void *) copy_ft, (void *) ft);
- copy_ft->length = ft->length;
- return copy_ft;
+ BT_ASSERT(copy_fc);
+ ctf_field_class_array_base_copy_content((void *) copy_fc, (void *) fc);
+ copy_fc->length = fc->length;
+ return copy_fc;
}
static inline
-struct ctf_field_type_sequence *_ctf_field_type_sequence_copy(
- struct ctf_field_type_sequence *ft)
+struct ctf_field_class_sequence *_ctf_field_class_sequence_copy(
+ struct ctf_field_class_sequence *fc)
{
- struct ctf_field_type_sequence *copy_ft =
- ctf_field_type_sequence_create();
+ struct ctf_field_class_sequence *copy_fc =
+ ctf_field_class_sequence_create();
- BT_ASSERT(copy_ft);
- ctf_field_type_array_base_copy_content((void *) copy_ft, (void *) ft);
- ctf_field_path_copy_content(©_ft->length_path, &ft->length_path);
- g_string_assign(copy_ft->length_ref, ft->length_ref->str);
- copy_ft->stored_length_index = ft->stored_length_index;
- return copy_ft;
+ BT_ASSERT(copy_fc);
+ ctf_field_class_array_base_copy_content((void *) copy_fc, (void *) fc);
+ ctf_field_path_copy_content(©_fc->length_path, &fc->length_path);
+ g_string_assign(copy_fc->length_ref, fc->length_ref->str);
+ copy_fc->stored_length_index = fc->stored_length_index;
+ return copy_fc;
}
static inline
-struct ctf_field_type *ctf_field_type_copy(struct ctf_field_type *ft)
+struct ctf_field_class *ctf_field_class_copy(struct ctf_field_class *fc)
{
- struct ctf_field_type *copy_ft = NULL;
+ struct ctf_field_class *copy_fc = NULL;
- if (!ft) {
+ if (!fc) {
goto end;
}
/*
* Translation should not have happened yet.
*/
- BT_ASSERT(!ft->ir_ft);
+ BT_ASSERT(!fc->ir_fc);
- switch (ft->id) {
- case CTF_FIELD_TYPE_ID_INT:
- copy_ft = (void *) _ctf_field_type_int_copy((void *) ft);
+ switch (fc->type) {
+ case CTF_FIELD_CLASS_TYPE_INT:
+ copy_fc = (void *) _ctf_field_class_int_copy((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_ENUM:
- copy_ft = (void *) _ctf_field_type_enum_copy((void *) ft);
+ case CTF_FIELD_CLASS_TYPE_ENUM:
+ copy_fc = (void *) _ctf_field_class_enum_copy((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_FLOAT:
- copy_ft = (void *) _ctf_field_type_float_copy((void *) ft);
+ case CTF_FIELD_CLASS_TYPE_FLOAT:
+ copy_fc = (void *) _ctf_field_class_float_copy((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_STRING:
- copy_ft = (void *) _ctf_field_type_string_copy((void *) ft);
+ case CTF_FIELD_CLASS_TYPE_STRING:
+ copy_fc = (void *) _ctf_field_class_string_copy((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_STRUCT:
- copy_ft = (void *) _ctf_field_type_struct_copy((void *) ft);
+ case CTF_FIELD_CLASS_TYPE_STRUCT:
+ copy_fc = (void *) _ctf_field_class_struct_copy((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_ARRAY:
- copy_ft = (void *) _ctf_field_type_array_copy((void *) ft);
+ case CTF_FIELD_CLASS_TYPE_ARRAY:
+ copy_fc = (void *) _ctf_field_class_array_copy((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_SEQUENCE:
- copy_ft = (void *) _ctf_field_type_sequence_copy((void *) ft);
+ case CTF_FIELD_CLASS_TYPE_SEQUENCE:
+ copy_fc = (void *) _ctf_field_class_sequence_copy((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_VARIANT:
- copy_ft = (void *) _ctf_field_type_variant_copy((void *) ft);
+ case CTF_FIELD_CLASS_TYPE_VARIANT:
+ copy_fc = (void *) _ctf_field_class_variant_copy((void *) fc);
break;
default:
abort();
}
- copy_ft->id = ft->id;
- copy_ft->alignment = ft->alignment;
- copy_ft->in_ir = ft->in_ir;
+ copy_fc->type = fc->type;
+ copy_fc->alignment = fc->alignment;
+ copy_fc->in_ir = fc->in_ir;
end:
- return copy_ft;
+ return copy_fc;
}
static inline
g_string_free(ec->emf_uri, TRUE);
}
- ctf_field_type_destroy(ec->spec_context_ft);
- ctf_field_type_destroy(ec->payload_ft);
+ ctf_field_class_destroy(ec->spec_context_fc);
+ ctf_field_class_destroy(ec->payload_fc);
g_free(ec);
}
g_hash_table_destroy(sc->event_classes_by_id);
}
- ctf_field_type_destroy(sc->packet_context_ft);
- ctf_field_type_destroy(sc->event_header_ft);
- ctf_field_type_destroy(sc->event_common_context_ft);
- bt_put(sc->default_clock_class);
+ ctf_field_class_destroy(sc->packet_context_fc);
+ ctf_field_class_destroy(sc->event_header_fc);
+ ctf_field_class_destroy(sc->event_common_context_fc);
g_free(sc);
}
static inline
struct ctf_event_class *ctf_stream_class_borrow_event_class_by_id(
- struct ctf_stream_class *sc, uint64_t id)
+ struct ctf_stream_class *sc, uint64_t type)
{
BT_ASSERT(sc);
return g_hash_table_lookup(sc->event_classes_by_id,
- GUINT_TO_POINTER((guint) id));
+ GUINT_TO_POINTER((guint) type));
}
static inline
}
}
+static inline
+struct ctf_clock_class *ctf_clock_class_create(void)
+{
+ struct ctf_clock_class *cc = g_new0(struct ctf_clock_class, 1);
+
+ BT_ASSERT(cc);
+ cc->name = g_string_new(NULL);
+ BT_ASSERT(cc->name);
+ cc->description = g_string_new(NULL);
+ BT_ASSERT(cc->description);
+ return cc;
+}
+
+static inline
+void ctf_clock_class_destroy(struct ctf_clock_class *cc)
+{
+ if (!cc) {
+ return;
+ }
+
+ if (cc->name) {
+ g_string_free(cc->name, TRUE);
+ }
+
+ if (cc->description) {
+ g_string_free(cc->description, TRUE);
+ }
+
+ bt_clock_class_put_ref(cc->ir_cc);
+ g_free(cc);
+}
+
static inline
struct ctf_trace_class *ctf_trace_class_create(void)
{
struct ctf_trace_class *tc = g_new0(struct ctf_trace_class, 1);
BT_ASSERT(tc);
- tc->name = g_string_new(NULL);
tc->default_byte_order = -1;
- BT_ASSERT(tc->name);
tc->clock_classes = g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) ctf_clock_class_destroy);
BT_ASSERT(tc->clock_classes);
tc->stream_classes = g_ptr_array_new_with_free_func(
(GDestroyNotify) ctf_stream_class_destroy);
return;
}
- if (tc->name) {
- g_string_free(tc->name, TRUE);
- }
-
- ctf_field_type_destroy(tc->packet_header_ft);
+ ctf_field_class_destroy(tc->packet_header_fc);
if (tc->clock_classes) {
g_ptr_array_free(tc->clock_classes, TRUE);
}
static inline
-struct bt_clock_class *ctf_trace_class_borrow_clock_class_by_name(
+struct ctf_clock_class *ctf_trace_class_borrow_clock_class_by_name(
struct ctf_trace_class *tc, const char *name)
{
uint64_t i;
- struct bt_clock_class *ret_cc = NULL;
+ struct ctf_clock_class *ret_cc = NULL;
BT_ASSERT(tc);
BT_ASSERT(name);
for (i = 0; i < tc->clock_classes->len; i++) {
- struct bt_clock_class *cc = tc->clock_classes->pdata[i];
- const char *cc_name = bt_clock_class_get_name(cc);
+ struct ctf_clock_class *cc = tc->clock_classes->pdata[i];
- BT_ASSERT(cc_name);
- if (strcmp(cc_name, name) == 0) {
+ BT_ASSERT(cc->name);
+ if (strcmp(cc->name->str, name) == 0) {
ret_cc = cc;
goto end;
}