#! /bin/sh
-# Copyright (C) 2011-2014 Free Software Foundation, Inc.
+# Copyright (C) 2011-2018 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# last `echo $?' statement), and would thus die reporting an internal
# error.
# For more information, see the Autoconf manual and the threads:
- # <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
+ # <https://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
# <http://mail.opensolaris.org/pipermail/ksh93-integration-discuss/2009-February/004121.html>
trap : 1 3 2 13 15
if test $merge -gt 0; then
# Local Variables:
# mode: shell-script
# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
plugins/Makefile
plugins/ctf/Makefile
plugins/ctf/common/Makefile
- plugins/ctf/common/btr/Makefile
+ plugins/ctf/common/bfcr/Makefile
plugins/ctf/common/metadata/Makefile
plugins/ctf/common/notif-iter/Makefile
plugins/ctf/common/utils/Makefile
babeltracectfirincludedir = "$(includedir)/babeltrace/ctf-ir"
babeltracectfirinclude_HEADERS = \
babeltrace/ctf-ir/clock.h \
- babeltrace/ctf-ir/event-class.h \
babeltrace/ctf-ir/event-fields.h \
babeltrace/ctf-ir/event-types.h \
babeltrace/ctf-ir/event.h \
babeltrace/trace-ir/event.h \
babeltrace/trace-ir/event-header-field.h \
babeltrace/trace-ir/field-path.h \
- babeltrace/trace-ir/field-types.h \
+ babeltrace/trace-ir/field-classes.h \
babeltrace/trace-ir/fields.h \
babeltrace/trace-ir/packet.h \
babeltrace/trace-ir/packet-context-field.h \
babeltrace/trace-ir/field-wrapper-internal.h \
babeltrace/trace-ir/trace-internal.h \
babeltrace/trace-ir/clock-class-internal.h \
- babeltrace/trace-ir/field-types-internal.h \
+ babeltrace/trace-ir/field-classes-internal.h \
babeltrace/trace-ir/clock-value-internal.h \
babeltrace/trace-ir/attributes-internal.h \
babeltrace/trace-ir/stream-internal.h \
#include <babeltrace/ctf-writer/visitor.h>
#include <babeltrace/ctf-writer/writer.h>
+/* Legacy API (for CTF writer) */
+#include <babeltrace/ctf-ir/clock.h>
+#include <babeltrace/ctf-ir/event-class.h>
+#include <babeltrace/ctf-ir/event-fields.h>
+#include <babeltrace/ctf-ir/event-types.h>
+#include <babeltrace/ctf-ir/event.h>
+#include <babeltrace/ctf-ir/field-types.h>
+#include <babeltrace/ctf-ir/fields.h>
+#include <babeltrace/ctf-ir/stream-class.h>
+#include <babeltrace/ctf-ir/stream.h>
+#include <babeltrace/ctf-ir/trace.h>
+#include <babeltrace/ctf-ir/utils.h>
+
/* Trace IR API */
#include <babeltrace/trace-ir/clock-class.h>
#include <babeltrace/trace-ir/clock-value.h>
-#include <babeltrace/trace-ir/clock.h>
#include <babeltrace/trace-ir/event-class.h>
#include <babeltrace/trace-ir/event-header-field.h>
#include <babeltrace/trace-ir/event.h>
+#include <babeltrace/trace-ir/field-classes.h>
#include <babeltrace/trace-ir/field-path.h>
-#include <babeltrace/trace-ir/field-types.h>
#include <babeltrace/trace-ir/fields.h>
#include <babeltrace/trace-ir/packet-context-field.h>
#include <babeltrace/trace-ir/packet-header-field.h>
#include <stdbool.h>
#include <babeltrace/assert-internal.h>
#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/trace-ir/field-types.h>
+#include <babeltrace/trace-ir/field-classes.h>
#include <babeltrace/trace-ir/field-path.h>
#include <babeltrace/trace-ir/event-class.h>
#include <stdarg.h>
size_t bt_common_get_page_size(void);
static inline
-const char *bt_common_field_type_id_string(enum bt_field_type_id type_id)
+const char *bt_common_field_class_id_string(enum bt_field_class_id class_id)
{
- switch (type_id) {
- case BT_FIELD_TYPE_ID_UNSIGNED_INTEGER:
- return "BT_FIELD_TYPE_ID_UNSIGNED_INTEGER";
- case BT_FIELD_TYPE_ID_SIGNED_INTEGER:
- return "BT_FIELD_TYPE_ID_SIGNED_INTEGER";
- case BT_FIELD_TYPE_ID_REAL:
- return "BT_FIELD_TYPE_ID_REAL";
- case BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION:
- return "BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION";
- case BT_FIELD_TYPE_ID_SIGNED_ENUMERATION:
- return "BT_FIELD_TYPE_ID_SIGNED_ENUMERATION";
- case BT_FIELD_TYPE_ID_STRING:
- return "BT_FIELD_TYPE_ID_STRING";
- case BT_FIELD_TYPE_ID_STRUCTURE:
- return "BT_FIELD_TYPE_ID_STRUCTURE";
- case BT_FIELD_TYPE_ID_STATIC_ARRAY:
- return "BT_FIELD_TYPE_ID_STATIC_ARRAY";
- case BT_FIELD_TYPE_ID_DYNAMIC_ARRAY:
- return "BT_FIELD_TYPE_ID_DYNAMIC_ARRAY";
- case BT_FIELD_TYPE_ID_VARIANT:
- return "BT_FIELD_TYPE_ID_VARIANT";
+ switch (class_id) {
+ case BT_FIELD_CLASS_ID_UNSIGNED_INTEGER:
+ return "BT_FIELD_CLASS_ID_UNSIGNED_INTEGER";
+ case BT_FIELD_CLASS_ID_SIGNED_INTEGER:
+ return "BT_FIELD_CLASS_ID_SIGNED_INTEGER";
+ case BT_FIELD_CLASS_ID_REAL:
+ return "BT_FIELD_CLASS_ID_REAL";
+ case BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION:
+ return "BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION";
+ case BT_FIELD_CLASS_ID_SIGNED_ENUMERATION:
+ return "BT_FIELD_CLASS_ID_SIGNED_ENUMERATION";
+ case BT_FIELD_CLASS_ID_STRING:
+ return "BT_FIELD_CLASS_ID_STRING";
+ case BT_FIELD_CLASS_ID_STRUCTURE:
+ return "BT_FIELD_CLASS_ID_STRUCTURE";
+ case BT_FIELD_CLASS_ID_STATIC_ARRAY:
+ return "BT_FIELD_CLASS_ID_STATIC_ARRAY";
+ case BT_FIELD_CLASS_ID_DYNAMIC_ARRAY:
+ return "BT_FIELD_CLASS_ID_DYNAMIC_ARRAY";
+ case BT_FIELD_CLASS_ID_VARIANT:
+ return "BT_FIELD_CLASS_ID_VARIANT";
default:
return "(unknown)";
}
};
static inline
-const char *bt_common_field_type_integer_preferred_display_base_string(enum bt_field_type_integer_preferred_display_base base)
+const char *bt_common_field_class_integer_preferred_display_base_string(enum bt_field_class_integer_preferred_display_base base)
{
switch (base) {
- case BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_BINARY:
- return "BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_BINARY";
- case BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL:
- return "BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL";
- case BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL:
- return "BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL";
- case BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL:
- return "BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL";
+ case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY:
+ return "BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY";
+ case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL:
+ return "BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL";
+ case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL:
+ return "BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL";
+ case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL:
+ return "BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL";
default:
return "(unknown)";
}
+++ /dev/null
-/* Pre-2.0 CTF writer backward compatibility */
-#include <babeltrace/ctf-writer/event-class.h>
* The available format specifiers are:
*
* `F`:
- * Trace IR field type. The parameter type is `struct
- * bt_field_type *`.
+ * Trace IR field class. The parameter type is
+ * `structbt_field_class *`.
*
* `f`:
* Trace IR field. The parameter type is `struct bt_field *`.
* Field path. The parameter type is `struct bt_field_path *`.
*
* `E`:
- * Trace IR event class. The parameter type is `struct
- * bt_event_class *`.
+ * Trace IR event class. The parameter type is
+ * `struct bt_event_class *`.
*
* `e`:
* Trace IR event. The parameter type is `struct bt_event *`.
*
* `S`:
- * Trace IR stream class. The parameter type is `struct
- * bt_stream_class *`.
+ * Trace IR stream class. The parameter type is
+ * `struct bt_stream_class *`.
*
* `s`:
* Trace IR stream. The parameter type is `struct bt_stream *`.
*/
#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/field-types.h>
+#include <babeltrace/trace-ir/field-classes.h>
#include <babeltrace/trace-ir/fields.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/values.h>
struct bt_event_class {
struct bt_object base;
- struct bt_field_type *specific_context_ft;
- struct bt_field_type *payload_ft;
+ struct bt_field_class *specific_context_fc;
+ struct bt_field_class *payload_fc;
struct {
GString *str;
#endif
struct bt_event_class;
-struct bt_field_type;
+struct bt_field_class;
struct bt_stream_class;
enum bt_event_class_log_level {
extern int bt_event_class_set_emf_uri(struct bt_event_class *event_class,
const char *emf_uri);
-extern struct bt_field_type *bt_event_class_borrow_specific_context_field_type(
+extern struct bt_field_class *bt_event_class_borrow_specific_context_field_class(
struct bt_event_class *event_class);
-extern int bt_event_class_set_specific_context_field_type(
+extern int bt_event_class_set_specific_context_field_class(
struct bt_event_class *event_class,
- struct bt_field_type *field_type);
+ struct bt_field_class *field_class);
-extern struct bt_field_type *bt_event_class_borrow_payload_field_type(
+extern struct bt_field_class *bt_event_class_borrow_payload_field_class(
struct bt_event_class *event_class);
-extern int bt_event_class_set_payload_field_type(
+extern int bt_event_class_set_payload_field_class(
struct bt_event_class *event_class,
- struct bt_field_type *field_type);
+ struct bt_field_class *field_class);
#ifdef __cplusplus
}
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H
+#define BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H
+
+/*
+ * BabelTrace - Trace IR: Event field classes internal
+ *
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@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.
+ */
+
+#include <babeltrace/assert-pre-internal.h>
+#include <babeltrace/trace-ir/clock-class.h>
+#include <babeltrace/trace-ir/field-classes.h>
+#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/object-internal.h>
+#include <babeltrace/types.h>
+#include <stdint.h>
+#include <glib.h>
+
+#define BT_ASSERT_PRE_FC_IS_INT(_fc, _name) \
+ BT_ASSERT_PRE( \
+ ((struct bt_field_class *) (_fc))->id == BT_FIELD_CLASS_ID_UNSIGNED_INTEGER || \
+ ((struct bt_field_class *) (_fc))->id == BT_FIELD_CLASS_ID_SIGNED_INTEGER || \
+ ((struct bt_field_class *) (_fc))->id == BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION || \
+ ((struct bt_field_class *) (_fc))->id == BT_FIELD_CLASS_ID_SIGNED_ENUMERATION, \
+ _name " is not an integer field class: %![fc-]+F", (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(_fc, _name) \
+ BT_ASSERT_PRE( \
+ ((struct bt_field_class *) (_fc))->id == BT_FIELD_CLASS_ID_UNSIGNED_INTEGER || \
+ ((struct bt_field_class *) (_fc))->id == BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION, \
+ _name " is not an unsigned integer field class: %![fc-]+F", (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_ENUM(_fc, _name) \
+ BT_ASSERT_PRE( \
+ ((struct bt_field_class *) (_fc))->id == BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION || \
+ ((struct bt_field_class *) (_fc))->id == BT_FIELD_CLASS_ID_SIGNED_ENUMERATION, \
+ _name " is not an enumeration field class: %![fc-]+F", (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_ARRAY(_fc, _name) \
+ BT_ASSERT_PRE( \
+ ((struct bt_field_class *) (_fc))->id == BT_FIELD_CLASS_ID_STATIC_ARRAY || \
+ ((struct bt_field_class *) (_fc))->id == BT_FIELD_CLASS_ID_DYNAMIC_ARRAY, \
+ _name " is not an array field class: %![fc-]+F", (_fc))
+
+#define BT_ASSERT_PRE_FC_HAS_ID(_fc, _id, _name) \
+ BT_ASSERT_PRE(((struct bt_field_class *) (_fc))->id == (_id), \
+ _name " has the wrong ID: expected-id=%s, " \
+ "%![fc-]+F", bt_common_field_class_id_string(_id), (_fc))
+
+#define BT_ASSERT_PRE_FC_HOT(_fc, _name) \
+ BT_ASSERT_PRE_HOT((struct bt_field_class *) (_fc), \
+ (_name), ": %!+F", (_fc))
+
+#define BT_FIELD_CLASS_NAMED_FC_AT_INDEX(_fc, _index) \
+ (&g_array_index(((struct bt_field_class_named_field_class_container *) (_fc))->named_fcs, \
+ struct bt_named_field_class, (_index)))
+
+#define BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(_fc, _index) \
+ (&g_array_index(((struct bt_field_class_enumeration *) (_fc))->mappings, \
+ struct bt_field_class_enumeration_mapping, (_index)))
+
+#define BT_FIELD_CLASS_ENUM_MAPPING_RANGE_AT_INDEX(_mapping, _index) \
+ (&g_array_index((_mapping)->ranges, \
+ struct bt_field_class_enumeration_mapping_range, (_index)))
+
+struct bt_field;
+struct bt_field_class;
+
+struct bt_field_class {
+ struct bt_object base;
+ enum bt_field_class_id id;
+ bool frozen;
+
+ /*
+ * Only used in developer mode, this flag indicates whether or
+ * not this field class is part of a trace.
+ */
+ bool part_of_trace;
+};
+
+struct bt_field_class_integer {
+ struct bt_field_class common;
+
+ /*
+ * Value range of fields built from this integer field class:
+ * this is an equivalent integer size in bits. More formally,
+ * `range` is `n` in:
+ *
+ * Unsigned range: [0, 2^n - 1]
+ * Signed range: [-2^(n - 1), 2^(n - 1) - 1]
+ */
+ uint64_t range;
+
+ enum bt_field_class_integer_preferred_display_base base;
+};
+
+struct bt_field_class_enumeration_mapping_range {
+ union {
+ uint64_t u;
+ int64_t i;
+ } lower;
+
+ union {
+ uint64_t u;
+ int64_t i;
+ } upper;
+};
+
+struct bt_field_class_enumeration_mapping {
+ GString *label;
+
+ /* Array of `struct bt_field_class_enumeration_mapping_range` */
+ GArray *ranges;
+};
+
+struct bt_field_class_enumeration {
+ struct bt_field_class_integer common;
+
+ /* Array of `struct bt_field_class_enumeration_mapping *` */
+ GArray *mappings;
+
+ /*
+ * This is an array of `const char *` which acts as a temporary
+ * (potentially growing) buffer for
+ * bt_field_class_unsigned_enumeration_get_mapping_labels_by_value()
+ * and
+ * bt_field_class_signed_enumeration_get_mapping_labels_by_value().
+ *
+ * The actual strings are owned by the mappings above.
+ */
+ GPtrArray *label_buf;
+};
+
+struct bt_field_class_real {
+ struct bt_field_class common;
+ bool is_single_precision;
+};
+
+struct bt_field_class_string {
+ struct bt_field_class common;
+};
+
+/* A named field class is a (name, field class) pair */
+struct bt_named_field_class {
+ GString *name;
+
+ /* Owned by this */
+ struct bt_field_class *fc;
+};
+
+/*
+ * This is the base field class for a container of named field classes.
+ * Structure and variant field classes inherit this.
+ */
+struct bt_field_class_named_field_class_container {
+ struct bt_field_class common;
+
+ /*
+ * Key: `const char *`, not owned by this (owned by named field
+ * type objects contained in `named_fcs` below).
+ */
+ GHashTable *name_to_index;
+
+ /* Array of `struct bt_named_field_class` */
+ GArray *named_fcs;
+};
+
+struct bt_field_class_structure {
+ struct bt_field_class_named_field_class_container common;
+};
+
+struct bt_field_class_array {
+ struct bt_field_class common;
+
+ /* Owned by this */
+ struct bt_field_class *element_fc;
+};
+
+struct bt_field_class_static_array {
+ struct bt_field_class_array common;
+ uint64_t length;
+};
+
+struct bt_field_class_dynamic_array {
+ struct bt_field_class_array common;
+
+ /* Weak: never dereferenced, only use to find it elsewhere */
+ struct bt_field_class *length_fc;
+
+ /* Owned by this */
+ struct bt_field_path *length_field_path;
+};
+
+struct bt_field_class_variant {
+ struct bt_field_class_named_field_class_container common;
+
+ /* Weak: never dereferenced, only use to find it elsewhere */
+ struct bt_field_class *selector_fc;
+
+ /* Owned by this */
+ struct bt_field_path *selector_field_path;
+};
+
+static inline
+bool bt_field_class_has_known_id(struct bt_field_class *fc)
+{
+ return fc->id >= BT_FIELD_CLASS_ID_UNSIGNED_INTEGER &&
+ fc->id <= BT_FIELD_CLASS_ID_VARIANT;
+}
+
+BT_HIDDEN
+void _bt_field_class_freeze(struct bt_field_class *field_class);
+
+#ifdef BT_DEV_MODE
+# define bt_field_class_freeze _bt_field_class_freeze
+#else
+# define bt_field_class_freeze(_fc)
+#endif
+
+/*
+ * This function recursively marks `field_class` and its children as
+ * being part of a trace. This is used to validate that all field classes
+ * are used at a single location within trace objects even if they are
+ * shared objects for other purposes.
+ */
+BT_HIDDEN
+void _bt_field_class_make_part_of_trace(struct bt_field_class *field_class);
+
+#ifdef BT_DEV_MODE
+# define bt_field_class_make_part_of_trace _bt_field_class_make_part_of_trace
+#else
+# define bt_field_class_make_part_of_trace(_fc) ((void) _fc)
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_H
+#define BABELTRACE_TRACE_IR_FIELD_CLASSES_H
+
+/*
+ * BabelTrace - Trace IR: Event field classes
+ *
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@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_get() */
+#include <babeltrace/ref.h>
+
+/* For bt_bool */
+#include <babeltrace/types.h>
+
+#include <stdint.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_field_class;
+struct bt_field_path;
+struct bt_field_class_signed_enumeration_mapping_ranges;
+struct bt_field_class_unsigned_enumeration_mapping_ranges;
+
+typedef const char * const *bt_field_class_enumeration_mapping_label_array;
+
+enum bt_field_class_id {
+ BT_FIELD_CLASS_ID_UNSIGNED_INTEGER,
+ BT_FIELD_CLASS_ID_SIGNED_INTEGER,
+ BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION,
+ BT_FIELD_CLASS_ID_SIGNED_ENUMERATION,
+ BT_FIELD_CLASS_ID_REAL,
+ BT_FIELD_CLASS_ID_STRING,
+ BT_FIELD_CLASS_ID_STRUCTURE,
+ BT_FIELD_CLASS_ID_STATIC_ARRAY,
+ BT_FIELD_CLASS_ID_DYNAMIC_ARRAY,
+ BT_FIELD_CLASS_ID_VARIANT,
+};
+
+enum bt_field_class_integer_preferred_display_base {
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY,
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL,
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL,
+};
+
+extern enum bt_field_class_id bt_field_class_get_id(
+ struct bt_field_class *field_class);
+
+extern struct bt_field_class *bt_field_class_unsigned_integer_create(void);
+
+extern struct bt_field_class *bt_field_class_signed_integer_create(void);
+
+extern uint64_t bt_field_class_integer_get_field_value_range(
+ struct bt_field_class *field_class);
+
+extern int bt_field_class_integer_set_field_value_range(
+ struct bt_field_class *field_class, uint64_t size);
+
+extern enum bt_field_class_integer_preferred_display_base
+bt_field_class_integer_get_preferred_display_base(
+ struct bt_field_class *field_class);
+
+extern int bt_field_class_integer_set_preferred_display_base(
+ struct bt_field_class *field_class,
+ enum bt_field_class_integer_preferred_display_base base);
+
+extern struct bt_field_class *bt_field_class_real_create(void);
+
+extern bt_bool bt_field_class_real_is_single_precision(
+ struct bt_field_class *field_class);
+
+extern int bt_field_class_real_set_is_single_precision(
+ struct bt_field_class *field_class,
+ bt_bool is_single_precision);
+
+extern struct bt_field_class *bt_field_class_unsigned_enumeration_create(void);
+
+extern struct bt_field_class *bt_field_class_signed_enumeration_create(void);
+
+extern uint64_t bt_field_class_enumeration_get_mapping_count(
+ struct bt_field_class *field_class);
+
+extern void bt_field_class_unsigned_enumeration_borrow_mapping_by_index(
+ struct bt_field_class *field_class, uint64_t index,
+ const char **label,
+ struct bt_field_class_unsigned_enumeration_mapping_ranges **ranges);
+
+extern void bt_field_class_signed_enumeration_borrow_mapping_by_index(
+ struct bt_field_class *field_class, uint64_t index,
+ const char **label,
+ struct bt_field_class_signed_enumeration_mapping_ranges **ranges);
+
+extern uint64_t bt_field_class_unsigned_enumeration_mapping_ranges_get_range_count(
+ struct bt_field_class_unsigned_enumeration_mapping_ranges *ranges);
+
+extern uint64_t bt_field_class_signed_enumeration_mapping_ranges_get_range_count(
+ struct bt_field_class_signed_enumeration_mapping_ranges *ranges);
+
+extern void bt_field_class_unsigned_enumeration_mapping_ranges_get_range_by_index(
+ struct bt_field_class_unsigned_enumeration_mapping_ranges *ranges,
+ uint64_t index, uint64_t *lower, uint64_t *upper);
+
+extern void bt_field_class_signed_enumeration_mapping_ranges_get_range_by_index(
+ struct bt_field_class_unsigned_enumeration_mapping_ranges *ranges,
+ uint64_t index, int64_t *lower, int64_t *upper);
+
+extern int bt_field_class_unsigned_enumeration_get_mapping_labels_by_value(
+ struct bt_field_class *field_class, uint64_t value,
+ bt_field_class_enumeration_mapping_label_array *label_array,
+ uint64_t *count);
+
+extern int bt_field_class_signed_enumeration_get_mapping_labels_by_value(
+ struct bt_field_class *field_class, int64_t value,
+ bt_field_class_enumeration_mapping_label_array *label_array,
+ uint64_t *count);
+
+extern int bt_field_class_unsigned_enumeration_map_range(
+ struct bt_field_class *field_class, const char *label,
+ uint64_t range_lower, uint64_t range_upper);
+
+extern int bt_field_class_signed_enumeration_map_range(
+ struct bt_field_class *field_class, const char *label,
+ int64_t range_lower, int64_t range_upper);
+
+extern struct bt_field_class *bt_field_class_string_create(void);
+
+extern struct bt_field_class *bt_field_class_structure_create(void);
+
+extern uint64_t bt_field_class_structure_get_member_count(
+ struct bt_field_class *field_class);
+
+extern void bt_field_class_structure_borrow_member_by_index(
+ struct bt_field_class *struct_field_class, uint64_t index,
+ const char **name, struct bt_field_class **field_class);
+
+extern
+struct bt_field_class *bt_field_class_structure_borrow_member_field_class_by_name(
+ struct bt_field_class *field_class, const char *name);
+
+extern int bt_field_class_structure_append_member(
+ struct bt_field_class *struct_field_class, const char *name,
+ struct bt_field_class *field_class);
+
+extern struct bt_field_class *bt_field_class_static_array_create(
+ struct bt_field_class *elem_field_class,
+ uint64_t length);
+
+extern struct bt_field_class *bt_field_class_dynamic_array_create(
+ struct bt_field_class *elem_field_class);
+
+extern struct bt_field_class *bt_field_class_array_borrow_element_field_class(
+ struct bt_field_class *field_class);
+
+extern uint64_t bt_field_class_static_array_get_length(
+ struct bt_field_class *field_class);
+
+extern struct bt_field_path *
+bt_field_class_dynamic_array_borrow_length_field_path(
+ struct bt_field_class *field_class);
+
+extern int bt_field_class_dynamic_array_set_length_field_class(
+ struct bt_field_class *field_class,
+ struct bt_field_class *length_field_class);
+
+extern struct bt_field_class *bt_field_class_variant_create(void);
+
+extern struct bt_field_path *
+bt_field_class_variant_borrow_selector_field_path(
+ struct bt_field_class *field_class);
+
+extern int bt_field_class_variant_set_selector_field_class(
+ struct bt_field_class *field_class,
+ struct bt_field_class *selector_field_class);
+
+extern uint64_t bt_field_class_variant_get_option_count(
+ struct bt_field_class *field_class);
+
+extern void bt_field_class_variant_borrow_option_by_index(
+ struct bt_field_class *variant_field_class, uint64_t index,
+ const char **name, struct bt_field_class **field_class);
+
+extern
+struct bt_field_class *bt_field_class_variant_borrow_option_field_class_by_name(
+ struct bt_field_class *field_class,
+ const char *name);
+
+extern int bt_field_class_variant_append_option(
+ struct bt_field_class *var_field_class,
+ const char *name, struct bt_field_class *field_class);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_FIELD_TYPES_INTERNAL_H
-#define BABELTRACE_TRACE_IR_FIELD_TYPES_INTERNAL_H
-
-/*
- * BabelTrace - Trace IR: Event field types internal
- *
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@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.
- */
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/clock-class.h>
-#include <babeltrace/trace-ir/field-types.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/types.h>
-#include <stdint.h>
-#include <glib.h>
-
-#define BT_ASSERT_PRE_FT_IS_INT(_ft, _name) \
- BT_ASSERT_PRE( \
- ((struct bt_field_type *) (_ft))->id == BT_FIELD_TYPE_ID_UNSIGNED_INTEGER || \
- ((struct bt_field_type *) (_ft))->id == BT_FIELD_TYPE_ID_SIGNED_INTEGER || \
- ((struct bt_field_type *) (_ft))->id == BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION || \
- ((struct bt_field_type *) (_ft))->id == BT_FIELD_TYPE_ID_SIGNED_ENUMERATION, \
- _name " is not an integer field type: %![ft-]+F", (_ft))
-
-#define BT_ASSERT_PRE_FT_IS_UNSIGNED_INT(_ft, _name) \
- BT_ASSERT_PRE( \
- ((struct bt_field_type *) (_ft))->id == BT_FIELD_TYPE_ID_UNSIGNED_INTEGER || \
- ((struct bt_field_type *) (_ft))->id == BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION, \
- _name " is not an unsigned integer field type: %![ft-]+F", (_ft))
-
-#define BT_ASSERT_PRE_FT_IS_ENUM(_ft, _name) \
- BT_ASSERT_PRE( \
- ((struct bt_field_type *) (_ft))->id == BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION || \
- ((struct bt_field_type *) (_ft))->id == BT_FIELD_TYPE_ID_SIGNED_ENUMERATION, \
- _name " is not an enumeration field type: %![ft-]+F", (_ft))
-
-#define BT_ASSERT_PRE_FT_IS_ARRAY(_ft, _name) \
- BT_ASSERT_PRE( \
- ((struct bt_field_type *) (_ft))->id == BT_FIELD_TYPE_ID_STATIC_ARRAY || \
- ((struct bt_field_type *) (_ft))->id == BT_FIELD_TYPE_ID_DYNAMIC_ARRAY, \
- _name " is not an array field type: %![ft-]+F", (_ft))
-
-#define BT_ASSERT_PRE_FT_HAS_ID(_ft, _id, _name) \
- BT_ASSERT_PRE(((struct bt_field_type *) (_ft))->id == (_id), \
- _name " has the wrong ID: expected-id=%s, " \
- "%![ft-]+F", bt_common_field_type_id_string(_id), (_ft))
-
-#define BT_ASSERT_PRE_FT_HOT(_ft, _name) \
- BT_ASSERT_PRE_HOT((struct bt_field_type *) (_ft), \
- (_name), ": %!+F", (_ft))
-
-#define BT_FIELD_TYPE_NAMED_FT_AT_INDEX(_ft, _index) \
- (&g_array_index(((struct bt_field_type_named_field_types_container *) (_ft))->named_fts, \
- struct bt_named_field_type, (_index)))
-
-#define BT_FIELD_TYPE_ENUM_MAPPING_AT_INDEX(_ft, _index) \
- (&g_array_index(((struct bt_field_type_enumeration *) (_ft))->mappings, \
- struct bt_field_type_enumeration_mapping, (_index)))
-
-#define BT_FIELD_TYPE_ENUM_MAPPING_RANGE_AT_INDEX(_mapping, _index) \
- (&g_array_index((_mapping)->ranges, \
- struct bt_field_type_enumeration_mapping_range, (_index)))
-
-struct bt_field;
-struct bt_field_type;
-
-struct bt_field_type {
- struct bt_object base;
- enum bt_field_type_id id;
- bool frozen;
-
- /*
- * Only used in developer mode, this flag indicates whether or
- * not this field type is part of a trace.
- */
- bool part_of_trace;
-};
-
-struct bt_field_type_integer {
- struct bt_field_type common;
-
- /*
- * Value range of fields built from this integer field type:
- * this is an equivalent integer size in bits. More formally,
- * `range` is `n` in:
- *
- * Unsigned range: [0, 2^n - 1]
- * Signed range: [-2^(n - 1), 2^(n - 1) - 1]
- */
- uint64_t range;
-
- enum bt_field_type_integer_preferred_display_base base;
-};
-
-struct bt_field_type_enumeration_mapping_range {
- union {
- uint64_t u;
- int64_t i;
- } lower;
-
- union {
- uint64_t u;
- int64_t i;
- } upper;
-};
-
-struct bt_field_type_enumeration_mapping {
- GString *label;
-
- /* Array of `struct bt_field_type_enumeration_mapping_range` */
- GArray *ranges;
-};
-
-struct bt_field_type_enumeration {
- struct bt_field_type_integer common;
-
- /* Array of `struct bt_field_type_enumeration_mapping *` */
- GArray *mappings;
-
- /*
- * This is an array of `const char *` which acts as a temporary
- * (potentially growing) buffer for
- * bt_field_type_unsigned_enumeration_get_mapping_labels_by_value()
- * and
- * bt_field_type_signed_enumeration_get_mapping_labels_by_value().
- *
- * The actual strings are owned by the mappings above.
- */
- GPtrArray *label_buf;
-};
-
-struct bt_field_type_real {
- struct bt_field_type common;
- bool is_single_precision;
-};
-
-struct bt_field_type_string {
- struct bt_field_type common;
-};
-
-/* A named field type is a (name, field type) pair */
-struct bt_named_field_type {
- GString *name;
-
- /* Owned by this */
- struct bt_field_type *ft;
-};
-
-/*
- * This is the base field type for a container of named field types.
- * Structure and variant field types inherit this.
- */
-struct bt_field_type_named_field_types_container {
- struct bt_field_type common;
-
- /*
- * Key: `const char *`, not owned by this (owned by named field
- * type objects contained in `named_fts` below).
- */
- GHashTable *name_to_index;
-
- /* Array of `struct bt_named_field_type` */
- GArray *named_fts;
-};
-
-struct bt_field_type_structure {
- struct bt_field_type_named_field_types_container common;
-};
-
-struct bt_field_type_array {
- struct bt_field_type common;
-
- /* Owned by this */
- struct bt_field_type *element_ft;
-};
-
-struct bt_field_type_static_array {
- struct bt_field_type_array common;
- uint64_t length;
-};
-
-struct bt_field_type_dynamic_array {
- struct bt_field_type_array common;
-
- /* Weak: never dereferenced, only use to find it elsewhere */
- struct bt_field_type *length_ft;
-
- /* Owned by this */
- struct bt_field_path *length_field_path;
-};
-
-struct bt_field_type_variant {
- struct bt_field_type_named_field_types_container common;
-
- /* Weak: never dereferenced, only use to find it elsewhere */
- struct bt_field_type *selector_ft;
-
- /* Owned by this */
- struct bt_field_path *selector_field_path;
-};
-
-static inline
-bool bt_field_type_has_known_id(struct bt_field_type *ft)
-{
- return ft->id >= BT_FIELD_TYPE_ID_UNSIGNED_INTEGER &&
- ft->id <= BT_FIELD_TYPE_ID_VARIANT;
-}
-
-BT_HIDDEN
-void _bt_field_type_freeze(struct bt_field_type *field_type);
-
-#ifdef BT_DEV_MODE
-# define bt_field_type_freeze _bt_field_type_freeze
-#else
-# define bt_field_type_freeze(_ft)
-#endif
-
-/*
- * This function recursively marks `field_type` and its children as
- * being part of a trace. This is used to validate that all field types
- * are used at a single location within trace objects even if they are
- * shared objects for other purposes.
- */
-BT_HIDDEN
-void _bt_field_type_make_part_of_trace(struct bt_field_type *field_type);
-
-#ifdef BT_DEV_MODE
-# define bt_field_type_make_part_of_trace _bt_field_type_make_part_of_trace
-#else
-# define bt_field_type_make_part_of_trace(_ft) ((void) _ft)
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_FIELD_TYPES_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_FIELD_TYPES_H
-#define BABELTRACE_TRACE_IR_FIELD_TYPES_H
-
-/*
- * BabelTrace - Trace IR: Event field types
- *
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@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_get() */
-#include <babeltrace/ref.h>
-
-/* For bt_bool */
-#include <babeltrace/types.h>
-
-#include <stdint.h>
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_field_type;
-struct bt_field_path;
-struct bt_field_type_signed_enumeration_mapping_ranges;
-struct bt_field_type_unsigned_enumeration_mapping_ranges;
-
-typedef const char * const *bt_field_type_enumeration_mapping_label_array;
-
-enum bt_field_type_id {
- BT_FIELD_TYPE_ID_UNSIGNED_INTEGER,
- BT_FIELD_TYPE_ID_SIGNED_INTEGER,
- BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION,
- BT_FIELD_TYPE_ID_SIGNED_ENUMERATION,
- BT_FIELD_TYPE_ID_REAL,
- BT_FIELD_TYPE_ID_STRING,
- BT_FIELD_TYPE_ID_STRUCTURE,
- BT_FIELD_TYPE_ID_STATIC_ARRAY,
- BT_FIELD_TYPE_ID_DYNAMIC_ARRAY,
- BT_FIELD_TYPE_ID_VARIANT,
-};
-
-enum bt_field_type_integer_preferred_display_base {
- BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_BINARY,
- BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL,
- BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
- BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL,
-};
-
-extern enum bt_field_type_id bt_field_type_get_type_id(
- struct bt_field_type *field_type);
-
-extern struct bt_field_type *bt_field_type_unsigned_integer_create(void);
-
-extern struct bt_field_type *bt_field_type_signed_integer_create(void);
-
-extern uint64_t bt_field_type_integer_get_field_value_range(
- struct bt_field_type *field_type);
-
-extern int bt_field_type_integer_set_field_value_range(
- struct bt_field_type *field_type, uint64_t size);
-
-extern enum bt_field_type_integer_preferred_display_base
-bt_field_type_integer_get_preferred_display_base(
- struct bt_field_type *field_type);
-
-extern int bt_field_type_integer_set_preferred_display_base(
- struct bt_field_type *field_type,
- enum bt_field_type_integer_preferred_display_base base);
-
-extern struct bt_field_type *bt_field_type_real_create(void);
-
-extern bt_bool bt_field_type_real_is_single_precision(
- struct bt_field_type *field_type);
-
-extern int bt_field_type_real_set_is_single_precision(
- struct bt_field_type *field_type,
- bt_bool is_single_precision);
-
-extern struct bt_field_type *bt_field_type_unsigned_enumeration_create(void);
-
-extern struct bt_field_type *bt_field_type_signed_enumeration_create(void);
-
-extern uint64_t bt_field_type_enumeration_get_mapping_count(
- struct bt_field_type *field_type);
-
-extern void bt_field_type_unsigned_enumeration_borrow_mapping_by_index(
- struct bt_field_type *field_type, uint64_t index,
- const char **label,
- struct bt_field_type_unsigned_enumeration_mapping_ranges **ranges);
-
-extern void bt_field_type_signed_enumeration_borrow_mapping_by_index(
- struct bt_field_type *field_type, uint64_t index,
- const char **label,
- struct bt_field_type_signed_enumeration_mapping_ranges **ranges);
-
-extern uint64_t bt_field_type_unsigned_enumeration_mapping_ranges_get_range_count(
- struct bt_field_type_unsigned_enumeration_mapping_ranges *ranges);
-
-extern uint64_t bt_field_type_signed_enumeration_mapping_ranges_get_range_count(
- struct bt_field_type_signed_enumeration_mapping_ranges *ranges);
-
-extern void bt_field_type_unsigned_enumeration_mapping_ranges_get_range_by_index(
- struct bt_field_type_unsigned_enumeration_mapping_ranges *ranges,
- uint64_t index, uint64_t *lower, uint64_t *upper);
-
-extern void bt_field_type_signed_enumeration_mapping_ranges_get_range_by_index(
- struct bt_field_type_unsigned_enumeration_mapping_ranges *ranges,
- uint64_t index, int64_t *lower, int64_t *upper);
-
-extern int bt_field_type_unsigned_enumeration_get_mapping_labels_by_value(
- struct bt_field_type *field_type, uint64_t value,
- bt_field_type_enumeration_mapping_label_array *label_array,
- uint64_t *count);
-
-extern int bt_field_type_signed_enumeration_get_mapping_labels_by_value(
- struct bt_field_type *field_type, int64_t value,
- bt_field_type_enumeration_mapping_label_array *label_array,
- uint64_t *count);
-
-extern int bt_field_type_unsigned_enumeration_map_range(
- struct bt_field_type *field_type, const char *label,
- uint64_t range_lower, uint64_t range_upper);
-
-extern int bt_field_type_signed_enumeration_map_range(
- struct bt_field_type *field_type, const char *label,
- int64_t range_lower, int64_t range_upper);
-
-extern struct bt_field_type *bt_field_type_string_create(void);
-
-extern struct bt_field_type *bt_field_type_structure_create(void);
-
-extern uint64_t bt_field_type_structure_get_member_count(
- struct bt_field_type *field_type);
-
-extern void bt_field_type_structure_borrow_member_by_index(
- struct bt_field_type *struct_field_type, uint64_t index,
- const char **name, struct bt_field_type **field_type);
-
-extern
-struct bt_field_type *bt_field_type_structure_borrow_member_field_type_by_name(
- struct bt_field_type *field_type, const char *name);
-
-extern int bt_field_type_structure_append_member(
- struct bt_field_type *struct_field_type, const char *name,
- struct bt_field_type *field_type);
-
-extern struct bt_field_type *bt_field_type_static_array_create(
- struct bt_field_type *elem_field_type,
- uint64_t length);
-
-extern struct bt_field_type *bt_field_type_dynamic_array_create(
- struct bt_field_type *elem_field_type);
-
-extern struct bt_field_type *bt_field_type_array_borrow_element_field_type(
- struct bt_field_type *field_type);
-
-extern uint64_t bt_field_type_static_array_get_length(
- struct bt_field_type *field_type);
-
-extern struct bt_field_path *
-bt_field_type_dynamic_array_borrow_length_field_path(
- struct bt_field_type *field_type);
-
-extern int bt_field_type_dynamic_array_set_length_field_type(
- struct bt_field_type *field_type,
- struct bt_field_type *length_field_type);
-
-extern struct bt_field_type *bt_field_type_variant_create(void);
-
-extern struct bt_field_path *
-bt_field_type_variant_borrow_selector_field_path(
- struct bt_field_type *field_type);
-
-extern int bt_field_type_variant_set_selector_field_type(
- struct bt_field_type *field_type,
- struct bt_field_type *selector_field_type);
-
-extern uint64_t bt_field_type_variant_get_option_count(
- struct bt_field_type *field_type);
-
-extern void bt_field_type_variant_borrow_option_by_index(
- struct bt_field_type *variant_field_type, uint64_t index,
- const char **name, struct bt_field_type **field_type);
-
-extern
-struct bt_field_type *bt_field_type_variant_borrow_option_field_type_by_name(
- struct bt_field_type *field_type,
- const char *name);
-
-extern int bt_field_type_variant_append_option(
- struct bt_field_type *var_field_type,
- const char *name, struct bt_field_type *field_type);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_FIELD_TYPES_H */
BT_HIDDEN
struct bt_field_wrapper *bt_field_wrapper_create(
- struct bt_object_pool *pool, struct bt_field_type *ft);
+ struct bt_object_pool *pool, struct bt_field_class *fc);
#endif /* BABELTRACE_TRACE_IR_FIELD_WRAPPER_INTERNAL_H */
#include <babeltrace/assert-pre-internal.h>
#include <babeltrace/common-internal.h>
-#include <babeltrace/trace-ir/field-types-internal.h>
+#include <babeltrace/trace-ir/field-classes-internal.h>
#include <babeltrace/trace-ir/utils-internal.h>
#include <babeltrace/object-internal.h>
#include <babeltrace/babeltrace-internal.h>
#include <stdbool.h>
#include <glib.h>
-#define BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(_field, _type_id, _name) \
- BT_ASSERT_PRE(((struct bt_field *) (_field))->type->id == (_type_id), \
- _name " has the wrong type ID: expected-type-id=%s, " \
+#define BT_ASSERT_PRE_FIELD_HAS_CLASS_ID(_field, _cls_id, _name) \
+ BT_ASSERT_PRE(((struct bt_field *) (_field))->class->id == (_cls_id), \
+ _name " has the wrong class ID: expected-class-id=%s, " \
"%![field-]+f", \
- bt_common_field_type_id_string(_type_id), (_field))
+ bt_common_field_class_id_string(_cls_id), (_field))
#define BT_ASSERT_PRE_FIELD_IS_UNSIGNED_INT(_field, _name) \
BT_ASSERT_PRE( \
- ((struct bt_field *) (_field))->type->id == BT_FIELD_TYPE_ID_UNSIGNED_INTEGER || \
- ((struct bt_field *) (_field))->type->id == BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION, \
+ ((struct bt_field *) (_field))->class->id == BT_FIELD_CLASS_ID_UNSIGNED_INTEGER || \
+ ((struct bt_field *) (_field))->class->id == BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION, \
_name " is not an unsigned integer field: %![field-]+f", \
(_field))
#define BT_ASSERT_PRE_FIELD_IS_SIGNED_INT(_field, _name) \
BT_ASSERT_PRE( \
- ((struct bt_field *) (_field))->type->id == BT_FIELD_TYPE_ID_SIGNED_INTEGER || \
- ((struct bt_field *) (_field))->type->id == BT_FIELD_TYPE_ID_SIGNED_ENUMERATION, \
+ ((struct bt_field *) (_field))->class->id == BT_FIELD_CLASS_ID_SIGNED_INTEGER || \
+ ((struct bt_field *) (_field))->class->id == BT_FIELD_CLASS_ID_SIGNED_ENUMERATION, \
_name " is not a signed integer field: %![field-]+f", \
(_field))
#define BT_ASSERT_PRE_FIELD_IS_ARRAY(_field, _name) \
BT_ASSERT_PRE( \
- ((struct bt_field *) (_field))->type->id == BT_FIELD_TYPE_ID_STATIC_ARRAY || \
- ((struct bt_field *) (_field))->type->id == BT_FIELD_TYPE_ID_DYNAMIC_ARRAY, \
+ ((struct bt_field *) (_field))->class->id == BT_FIELD_CLASS_ID_STATIC_ARRAY || \
+ ((struct bt_field *) (_field))->class->id == BT_FIELD_CLASS_ID_DYNAMIC_ARRAY, \
_name " is not an array field: %![field-]+f", (_field))
#define BT_ASSERT_PRE_FIELD_IS_SET(_field, _name) \
struct bt_field;
-typedef struct bt_field *(* bt_field_create_func)(struct bt_field_type *);
+typedef struct bt_field *(* bt_field_create_func)(struct bt_field_class *);
typedef void (*bt_field_method_set_is_frozen)(struct bt_field *, bool);
typedef bool (*bt_field_method_is_set)(struct bt_field *);
typedef void (*bt_field_method_reset)(struct bt_field *);
struct bt_object base;
/* Owned by this */
- struct bt_field_type *type;
+ struct bt_field_class *class;
/* Virtual table for slow path (dev mode) operations */
struct bt_field_methods *methods;
goto end;
}
- BT_ASSERT(bt_field_type_has_known_id(field->type));
+ BT_ASSERT(bt_field_class_has_known_id(field->class));
BT_ASSERT(field->methods->is_set);
is_set = field->methods->is_set(field);
}
BT_HIDDEN
-struct bt_field *bt_field_create(struct bt_field_type *type);
+struct bt_field *bt_field_create(struct bt_field_class *class);
BT_HIDDEN
void bt_field_destroy(struct bt_field *field);
/* For bt_bool */
#include <babeltrace/types.h>
-/* For enum bt_field_type_id */
-#include <babeltrace/trace-ir/field-types.h>
+/* For enum bt_field_class_id */
+#include <babeltrace/trace-ir/field-classes.h>
#ifdef __cplusplus
extern "C" {
#endif
struct bt_field;
-struct bt_field_type;
-struct bt_field_type_enumeration_mapping_iterator;
+struct bt_field_class;
+struct bt_field_class_enumeration_mapping_iterator;
-extern struct bt_field_type *bt_field_borrow_type(struct bt_field *field);
+extern struct bt_field_class *bt_field_borrow_class(struct bt_field *field);
-extern enum bt_field_type_id bt_field_get_type_id(struct bt_field *field);
+extern enum bt_field_class_id bt_field_get_class_id(struct bt_field *field);
extern int64_t bt_field_signed_integer_get_value(struct bt_field *field);
extern int bt_field_unsigned_enumeration_get_mapping_labels(
struct bt_field *field,
- bt_field_type_enumeration_mapping_label_array *label_array,
+ bt_field_class_enumeration_mapping_label_array *label_array,
uint64_t *count);
extern int bt_field_signed_enumeration_get_mapping_labels(
struct bt_field *field,
- bt_field_type_enumeration_mapping_label_array *label_array,
+ bt_field_class_enumeration_mapping_label_array *label_array,
uint64_t *count);
extern const char *bt_field_string_get_value(struct bt_field *field);
*/
#include <babeltrace/object-internal.h>
-#include <babeltrace/trace-ir/field-types.h>
+#include <babeltrace/trace-ir/field-classes.h>
#include <babeltrace/trace-ir/field-path.h>
#include <glib.h>
struct bt_resolve_field_path_context {
- struct bt_field_type *packet_header;
- struct bt_field_type *packet_context;
- struct bt_field_type *event_header;
- struct bt_field_type *event_common_context;
- struct bt_field_type *event_specific_context;
- struct bt_field_type *event_payload;
+ 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;
};
BT_HIDDEN
-int bt_resolve_field_paths(struct bt_field_type *ft,
+int bt_resolve_field_paths(struct bt_field_class *field_class,
struct bt_resolve_field_path_context *ctx);
#endif /* BABELTRACE_TRACE_IR_RESOLVE_FIELD_PATH_INTERNAL */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_RESOLVE_INTERNAL_H
-#define BABELTRACE_TRACE_IR_RESOLVE_INTERNAL_H
-
-/*
- * Babeltrace - Trace IR: Type resolving internal
- *
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
- *
- * Authors: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- * 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.
- */
-
-#include <babeltrace/trace-ir/field-types.h>
-#include <babeltrace/trace-ir/field-types-internal.h>
-#include <babeltrace/values.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <glib.h>
-
-enum bt_resolve_flag {
- BT_RESOLVE_FLAG_PACKET_HEADER = 0x01,
- BT_RESOLVE_FLAG_PACKET_CONTEXT = 0x02,
- BT_RESOLVE_FLAG_EVENT_HEADER = 0x04,
- BT_RESOLVE_FLAG_STREAM_EVENT_CTX = 0x08,
- BT_RESOLVE_FLAG_EVENT_CONTEXT = 0x10,
- BT_RESOLVE_FLAG_EVENT_PAYLOAD = 0x20,
-};
-
-/*
- * Resolves Trace IR field types: recursively locates the tag and length
- * field types of resp. variant and sequence field types.
- *
- * All `*_type` parameters may be resolved, and may as well serve as
- * resolving targets.
- *
- * Resolving is performed based on the flags in `flags`.
- *
- * It is expected that, amongst all the provided types, no common
- * references to sequence variant field types exist. In other words,
- * this function does not copy field types.
- *
- * All parameters are owned by the caller.
- */
-BT_HIDDEN
-int bt_resolve_types(struct bt_value *environment,
- struct bt_field_type *packet_header_type,
- struct bt_field_type *packet_context_type,
- struct bt_field_type *event_header_type,
- struct bt_field_type *stream_event_ctx_type,
- struct bt_field_type *event_context_type,
- struct bt_field_type *event_payload_type,
- enum bt_resolve_flag flags);
-
-#endif /* BABELTRACE_TRACE_IR_RESOLVE_INTERNAL_H */
#include <babeltrace/assert-internal.h>
#include <babeltrace/common-internal.h>
-#include <babeltrace/trace-ir/field-types-internal.h>
+#include <babeltrace/trace-ir/field-classes-internal.h>
#include <babeltrace/trace-ir/utils-internal.h>
#include <babeltrace/trace-ir/stream-class.h>
#include <babeltrace/object-internal.h>
bool packets_have_packet_counter_snapshot;
bool packets_have_default_beginning_cv;
bool packets_have_default_end_cv;
- struct bt_field_type *packet_context_ft;
- struct bt_field_type *event_header_ft;
- struct bt_field_type *event_common_context_ft;
+ 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 *` */
extern uint64_t bt_stream_class_get_id(struct bt_stream_class *stream_class);
-extern struct bt_field_type *bt_stream_class_borrow_packet_context_field_type(
+extern struct bt_field_class *bt_stream_class_borrow_packet_context_field_class(
struct bt_stream_class *stream_class);
-extern int bt_stream_class_set_packet_context_field_type(
+extern int bt_stream_class_set_packet_context_field_class(
struct bt_stream_class *stream_class,
- struct bt_field_type *field_type);
+ struct bt_field_class *field_class);
-extern struct bt_field_type *
-bt_stream_class_borrow_event_header_field_type(
+extern struct bt_field_class *
+bt_stream_class_borrow_event_header_field_class(
struct bt_stream_class *stream_class);
-extern int bt_stream_class_set_event_header_field_type(
+extern int bt_stream_class_set_event_header_field_class(
struct bt_stream_class *stream_class,
- struct bt_field_type *field_type);
+ struct bt_field_class *field_class);
-extern struct bt_field_type *
-bt_stream_class_borrow_event_common_context_field_type(
+extern struct bt_field_class *
+bt_stream_class_borrow_event_common_context_field_class(
struct bt_stream_class *stream_class);
-extern int bt_stream_class_set_event_common_context_field_type(
+extern int bt_stream_class_set_event_common_context_field_class(
struct bt_stream_class *stream_class,
- struct bt_field_type *field_type);
+ struct bt_field_class *field_class);
extern uint64_t bt_stream_class_get_event_class_count(
struct bt_stream_class *stream_class);
#include <babeltrace/assert-pre-internal.h>
#include <babeltrace/trace-ir/trace.h>
#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/trace-ir/field-types.h>
+#include <babeltrace/trace-ir/field-classes.h>
#include <babeltrace/trace-ir/fields.h>
#include <babeltrace/trace-ir/attributes-internal.h>
#include <babeltrace/trace-ir/clock-class-internal.h>
*/
GHashTable *stream_classes_stream_count;
- struct bt_field_type *packet_header_ft;
+ struct bt_field_class *packet_header_fc;
bool assigns_automatic_stream_class_id;
GArray *is_static_listeners;
struct bt_trace;
struct bt_stream;
struct bt_stream_class;
-struct bt_field_type;
+struct bt_field_class;
struct bt_value;
struct bt_packet_header_field;
struct bt_trace *trace, const char *name,
const char *value);
-extern struct bt_field_type *bt_trace_borrow_packet_header_field_type(
+extern struct bt_field_class *bt_trace_borrow_packet_header_field_class(
struct bt_trace *trace);
-extern int bt_trace_set_packet_header_field_type(struct bt_trace *trace,
- struct bt_field_type *packet_header_type);
+extern int bt_trace_set_packet_header_field_class(struct bt_trace *trace,
+ struct bt_field_class *packet_header_field_class);
extern uint64_t bt_trace_get_stream_class_count(struct bt_trace *trace);
*/
#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/trace-ir/field-types.h>
+#include <babeltrace/trace-ir/field-classes.h>
#include <babeltrace/trace-ir/clock-class-internal.h>
#include <stdint.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/ref.h>
#include <babeltrace/trace-ir/fields.h>
-#include <babeltrace/trace-ir/field-types.h>
-#include <babeltrace/trace-ir/field-types-internal.h>
#include <babeltrace/trace-ir/event-internal.h>
#include <babeltrace/trace-ir/packet-internal.h>
#include <babeltrace/trace-ir/stream-internal.h>
#include <babeltrace/lib-logging-internal.h>
#include <babeltrace/values-internal.h>
#include <babeltrace/object-pool-internal.h>
-#include <babeltrace/trace-ir/field-types-internal.h>
+#include <babeltrace/trace-ir/field-classes-internal.h>
#include <babeltrace/trace-ir/fields-internal.h>
#include <babeltrace/trace-ir/event-class-internal.h>
#include <babeltrace/trace-ir/event-internal.h>
}
}
-static inline void format_integer_field_type(char **buf_ch,
+static inline void format_integer_field_class(char **buf_ch,
bool extended, const char *prefix,
- struct bt_field_type *field_type)
+ struct bt_field_class *field_class)
{
- struct bt_field_type_integer *int_ft = (void *) field_type;
+ struct bt_field_class_integer *int_fc = (void *) field_class;
BUF_APPEND(", %srange-size=%" PRIu64 ", %sbase=%s",
- PRFIELD(int_ft->range),
- PRFIELD(bt_common_field_type_integer_preferred_display_base_string(int_ft->base)));
+ PRFIELD(int_fc->range),
+ PRFIELD(bt_common_field_class_integer_preferred_display_base_string(int_fc->base)));
}
-static inline void format_array_field_type(char **buf_ch,
+static inline void format_array_field_class(char **buf_ch,
bool extended, const char *prefix,
- struct bt_field_type *field_type)
+ struct bt_field_class *field_class)
{
- struct bt_field_type_array *array_ft = (void *) field_type;
+ struct bt_field_class_array *array_fc = (void *) field_class;
- BUF_APPEND(", %selement-ft-addr=%p, %selement-ft-id=%s",
- PRFIELD(array_ft->element_ft),
- PRFIELD(bt_common_field_type_id_string(array_ft->element_ft->id)));
+ BUF_APPEND(", %selement-fc-addr=%p, %selement-fc-id=%s",
+ PRFIELD(array_fc->element_fc),
+ PRFIELD(bt_common_field_class_id_string(array_fc->element_fc->id)));
}
-static inline void format_field_type(char **buf_ch, bool extended,
- const char *prefix, struct bt_field_type *field_type)
+static inline void format_field_class(char **buf_ch, bool extended,
+ const char *prefix, struct bt_field_class *field_class)
{
char tmp_prefix[64];
BUF_APPEND(", %sid=%s",
- PRFIELD(bt_common_field_type_id_string(field_type->id)));
+ PRFIELD(bt_common_field_class_id_string(field_class->id)));
if (extended) {
- BUF_APPEND(", %sis-frozen=%d", PRFIELD(field_type->frozen));
+ BUF_APPEND(", %sis-frozen=%d", PRFIELD(field_class->frozen));
BUF_APPEND(", %sis-part-of-trace=%d",
- PRFIELD(field_type->part_of_trace));
+ PRFIELD(field_class->part_of_trace));
} else {
return;
}
- switch (field_type->id) {
- case BT_FIELD_TYPE_ID_UNSIGNED_INTEGER:
- case BT_FIELD_TYPE_ID_SIGNED_INTEGER:
+ switch (field_class->id) {
+ case BT_FIELD_CLASS_ID_UNSIGNED_INTEGER:
+ case BT_FIELD_CLASS_ID_SIGNED_INTEGER:
{
- format_integer_field_type(buf_ch, extended, prefix, field_type);
+ format_integer_field_class(buf_ch, extended, prefix, field_class);
break;
}
- case BT_FIELD_TYPE_ID_REAL:
+ case BT_FIELD_CLASS_ID_REAL:
{
- struct bt_field_type_real *real_ft = (void *) field_type;
+ struct bt_field_class_real *real_fc = (void *) field_class;
BUF_APPEND(", %sis-single-precision=%d",
- PRFIELD(real_ft->is_single_precision));
+ PRFIELD(real_fc->is_single_precision));
break;
}
- case BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION:
- case BT_FIELD_TYPE_ID_SIGNED_ENUMERATION:
+ case BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION:
+ case BT_FIELD_CLASS_ID_SIGNED_ENUMERATION:
{
- struct bt_field_type_enumeration *enum_ft =
- (void *) field_type;
+ struct bt_field_class_enumeration *enum_fc =
+ (void *) field_class;
- format_integer_field_type(buf_ch, extended, prefix, field_type);
+ format_integer_field_class(buf_ch, extended, prefix, field_class);
BUF_APPEND(", %smapping-count=%u",
- PRFIELD(enum_ft->mappings->len));
+ PRFIELD(enum_fc->mappings->len));
break;
}
- case BT_FIELD_TYPE_ID_STRUCTURE:
+ case BT_FIELD_CLASS_ID_STRUCTURE:
{
- struct bt_field_type_structure *struct_ft =
- (void *) field_type;
+ struct bt_field_class_structure *struct_fc =
+ (void *) field_class;
- if (struct_ft->common.named_fts) {
+ if (struct_fc->common.named_fcs) {
BUF_APPEND(", %smember-count=%u",
- PRFIELD(struct_ft->common.named_fts->len));
+ PRFIELD(struct_fc->common.named_fcs->len));
}
break;
}
- case BT_FIELD_TYPE_ID_STATIC_ARRAY:
+ case BT_FIELD_CLASS_ID_STATIC_ARRAY:
{
- struct bt_field_type_static_array *array_ft =
- (void *) field_type;
+ struct bt_field_class_static_array *array_fc =
+ (void *) field_class;
- format_array_field_type(buf_ch, extended, prefix, field_type);
- BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_ft->length));
+ format_array_field_class(buf_ch, extended, prefix, field_class);
+ BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_fc->length));
break;
}
- case BT_FIELD_TYPE_ID_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_ID_DYNAMIC_ARRAY:
{
- struct bt_field_type_dynamic_array *array_ft =
- (void *) field_type;
+ struct bt_field_class_dynamic_array *array_fc =
+ (void *) field_class;
- format_array_field_type(buf_ch, extended, prefix, field_type);
+ format_array_field_class(buf_ch, extended, prefix, field_class);
- if (array_ft->length_ft) {
- SET_TMP_PREFIX("length-ft-");
- format_field_type(buf_ch, extended, tmp_prefix,
- array_ft->length_ft);
+ if (array_fc->length_fc) {
+ SET_TMP_PREFIX("length-fc-");
+ format_field_class(buf_ch, extended, tmp_prefix,
+ array_fc->length_fc);
}
- if (array_ft->length_field_path) {
+ if (array_fc->length_field_path) {
SET_TMP_PREFIX("length-field-path-");
format_field_path(buf_ch, extended, tmp_prefix,
- array_ft->length_field_path);
+ array_fc->length_field_path);
}
break;
}
- case BT_FIELD_TYPE_ID_VARIANT:
+ case BT_FIELD_CLASS_ID_VARIANT:
{
- struct bt_field_type_variant *var_ft = (void *) field_type;
+ struct bt_field_class_variant *var_fc = (void *) field_class;
- if (var_ft->common.named_fts) {
+ if (var_fc->common.named_fcs) {
BUF_APPEND(", %soption-count=%u",
- PRFIELD(var_ft->common.named_fts->len));
+ PRFIELD(var_fc->common.named_fcs->len));
}
- if (var_ft->selector_ft) {
- SET_TMP_PREFIX("selector-ft-");
- format_field_type(buf_ch, extended, tmp_prefix,
- var_ft->selector_ft);
+ if (var_fc->selector_fc) {
+ SET_TMP_PREFIX("selector-fc-");
+ format_field_class(buf_ch, extended, tmp_prefix,
+ var_fc->selector_fc);
}
- if (var_ft->selector_field_path) {
+ if (var_fc->selector_field_path) {
SET_TMP_PREFIX("selector-field-path-");
format_field_path(buf_ch, extended, tmp_prefix,
- var_ft->selector_field_path);
+ var_fc->selector_field_path);
}
break;
const char *prefix, struct bt_field *field)
{
struct bt_field_integer *integer = (void *) field;
- struct bt_field_type_integer *field_type = (void *) field->type;
+ struct bt_field_class_integer *field_class = (void *) field->class;
const char *fmt = NULL;
- BT_ASSERT(field_type);
+ BT_ASSERT(field_class);
- if (field_type->base == BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL) {
+ if (field_class->base == BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL) {
fmt = ", %svalue=%" PRIo64;
- } else if (field_type->base == BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL) {
+ } else if (field_class->base == BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL) {
fmt = ", %svalue=%" PRIx64;
}
- if (field_type->common.id == BT_FIELD_TYPE_ID_SIGNED_INTEGER ||
- field_type->common.id == BT_FIELD_TYPE_ID_SIGNED_ENUMERATION) {
+ if (field_class->common.id == BT_FIELD_CLASS_ID_SIGNED_INTEGER ||
+ field_class->common.id == BT_FIELD_CLASS_ID_SIGNED_ENUMERATION) {
if (!fmt) {
fmt = ", %svalue=%" PRId64;
}
BUF_APPEND(", %sis-frozen=%d", PRFIELD(field->frozen));
}
- BUF_APPEND(", %stype-addr=%p", PRFIELD(field->type));
+ BUF_APPEND(", %stype-addr=%p", PRFIELD(field->class));
- if (!field->type) {
+ if (!field->class) {
return;
}
BUF_APPEND(", %stype-id=%s",
- PRFIELD(bt_common_field_type_id_string(field->type->id)));
+ PRFIELD(bt_common_field_class_id_string(field->class->id)));
if (!extended || !field->is_set) {
return;
}
- switch (field->type->id) {
- case BT_FIELD_TYPE_ID_UNSIGNED_INTEGER:
- case BT_FIELD_TYPE_ID_SIGNED_INTEGER:
- case BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION:
- case BT_FIELD_TYPE_ID_SIGNED_ENUMERATION:
+ switch (field->class->id) {
+ case BT_FIELD_CLASS_ID_UNSIGNED_INTEGER:
+ case BT_FIELD_CLASS_ID_SIGNED_INTEGER:
+ case BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION:
+ case BT_FIELD_CLASS_ID_SIGNED_ENUMERATION:
{
format_field_integer_extended(buf_ch, prefix, field);
break;
}
- case BT_FIELD_TYPE_ID_REAL:
+ case BT_FIELD_CLASS_ID_REAL:
{
struct bt_field_real *real_field = (void *) field;
BUF_APPEND(", %svalue=%f", PRFIELD(real_field->value));
break;
}
- case BT_FIELD_TYPE_ID_STRING:
+ case BT_FIELD_CLASS_ID_STRING:
{
struct bt_field_string *str = (void *) field;
break;
}
- case BT_FIELD_TYPE_ID_STATIC_ARRAY:
- case BT_FIELD_TYPE_ID_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_ID_STATIC_ARRAY:
+ case BT_FIELD_CLASS_ID_DYNAMIC_ARRAY:
{
struct bt_field_array *array_field = (void *) field;
break;
}
- case BT_FIELD_TYPE_ID_VARIANT:
+ case BT_FIELD_CLASS_ID_VARIANT:
{
struct bt_field_variant *var_field = (void *) field;
PRFIELD(trace->streams->len));
}
- BUF_APPEND(", %spacket-header-ft-addr=%p, %sis-static=%d, "
+ BUF_APPEND(", %spacket-header-fc-addr=%p, %sis-static=%d, "
"%sassigns-auto-sc-id=%d",
- PRFIELD(trace->packet_header_ft),
+ PRFIELD(trace->packet_header_fc),
PRFIELD(trace->is_static),
PRFIELD(trace->assigns_automatic_stream_class_id));
SET_TMP_PREFIX("phf-pool-");
PRFIELD(stream_class->event_classes->len));
}
- BUF_APPEND(", %spacket-context-ft-addr=%p, "
- "%sevent-header-ft-addr=%p, %sevent-common-context-ft-addr=%p",
- PRFIELD(stream_class->packet_context_ft),
- PRFIELD(stream_class->event_header_ft),
- PRFIELD(stream_class->event_common_context_ft));
+ BUF_APPEND(", %spacket-context-fc-addr=%p, "
+ "%sevent-header-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 = bt_stream_class_borrow_trace_inline(stream_class);
if (!trace) {
return;
PRFIELD(event_class->emf_uri.value));
}
- BUF_APPEND(", %sspecific-context-ft-addr=%p, %spayload-ft-addr=%p",
- PRFIELD(event_class->specific_context_ft),
- PRFIELD(event_class->payload_ft));
+ BUF_APPEND(", %sspecific-context-fc-addr=%p, %spayload-fc-addr=%p",
+ PRFIELD(event_class->specific_context_fc),
+ PRFIELD(event_class->payload_fc));
stream_class = bt_event_class_borrow_stream_class(event_class);
if (!stream_class) {
switch (*fmt_ch) {
case 'F':
- format_field_type(buf_ch, extended, prefix, obj);
+ format_field_class(buf_ch, extended, prefix, obj);
break;
case 'f':
format_field(buf_ch, extended, prefix, obj);
event-header-field.c \
field-wrapper.c \
fields.c \
- field-types.c \
+ field-classes.c \
field-path.c \
packet.c \
packet-context-field.c \
#include <babeltrace/assert-pre-internal.h>
#include <babeltrace/trace-ir/clock-value-internal.h>
#include <babeltrace/trace-ir/fields-internal.h>
-#include <babeltrace/trace-ir/field-types.h>
-#include <babeltrace/trace-ir/field-types-internal.h>
+#include <babeltrace/trace-ir/field-classes.h>
+#include <babeltrace/trace-ir/field-classes-internal.h>
#include <babeltrace/trace-ir/event-class.h>
#include <babeltrace/trace-ir/event-class-internal.h>
#include <babeltrace/trace-ir/event-internal.h>
g_string_free(event_class->emf_uri.str, TRUE);
}
- BT_LOGD_STR("Putting context field type.");
- bt_put(event_class->specific_context_ft);
- BT_LOGD_STR("Putting payload field type.");
- bt_put(event_class->payload_ft);
+ BT_LOGD_STR("Putting context field classe.");
+ bt_put(event_class->specific_context_fc);
+ BT_LOGD_STR("Putting payload field classe.");
+ bt_put(event_class->payload_fc);
bt_object_pool_finalize(&event_class->event_pool);
g_free(obj);
}
return bt_event_class_borrow_stream_class_inline(event_class);
}
-struct bt_field_type *bt_event_class_borrow_specific_context_field_type(
+struct bt_field_class *bt_event_class_borrow_specific_context_field_class(
struct bt_event_class *event_class)
{
BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
- return event_class->specific_context_ft;
+ return event_class->specific_context_fc;
}
-int bt_event_class_set_specific_context_field_type(
+int bt_event_class_set_specific_context_field_class(
struct bt_event_class *event_class,
- struct bt_field_type *field_type)
+ struct bt_field_class *field_class)
{
int ret;
struct bt_stream_class *stream_class;
.packet_context = NULL,
.event_header = NULL,
.event_common_context = NULL,
- .event_specific_context = field_type,
+ .event_specific_context = field_class,
.event_payload = NULL,
};
BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
- BT_ASSERT_PRE_NON_NULL(field_type, "Field type");
+ BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
BT_ASSERT_PRE_EVENT_CLASS_HOT(event_class);
- BT_ASSERT_PRE(bt_field_type_get_type_id(field_type) ==
- BT_FIELD_TYPE_ID_STRUCTURE,
- "Specific context field type is not a structure field type: "
- "%!+F", field_type);
+ BT_ASSERT_PRE(bt_field_class_get_id(field_class) ==
+ BT_FIELD_CLASS_ID_STRUCTURE,
+ "Specific context field classe is not a structure field classe: "
+ "%!+F", field_class);
stream_class = bt_event_class_borrow_stream_class_inline(
event_class);
trace = bt_stream_class_borrow_trace_inline(stream_class);
- resolve_ctx.packet_header = trace->packet_header_ft;
- resolve_ctx.packet_context = stream_class->packet_context_ft;
- resolve_ctx.event_header = stream_class->event_header_ft;
+ resolve_ctx.packet_header = trace->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_ft;
+ stream_class->event_common_context_fc;
- ret = bt_resolve_field_paths(field_type, &resolve_ctx);
+ ret = bt_resolve_field_paths(field_class, &resolve_ctx);
if (ret) {
goto end;
}
- bt_field_type_make_part_of_trace(field_type);
- bt_put(event_class->specific_context_ft);
- event_class->specific_context_ft = bt_get(field_type);
- bt_field_type_freeze(field_type);
- BT_LIB_LOGV("Set event class's specific context field type: %!+E",
+ bt_field_class_make_part_of_trace(field_class);
+ bt_put(event_class->specific_context_fc);
+ event_class->specific_context_fc = bt_get(field_class);
+ bt_field_class_freeze(field_class);
+ BT_LIB_LOGV("Set event class's specific context field classe: %!+E",
event_class);
end:
return ret;
}
-struct bt_field_type *bt_event_class_borrow_payload_field_type(
+struct bt_field_class *bt_event_class_borrow_payload_field_class(
struct bt_event_class *event_class)
{
BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
- return event_class->payload_ft;
+ return event_class->payload_fc;
}
-int bt_event_class_set_payload_field_type(struct bt_event_class *event_class,
- struct bt_field_type *field_type)
+int bt_event_class_set_payload_field_class(struct bt_event_class *event_class,
+ struct bt_field_class *field_class)
{
int ret;
struct bt_stream_class *stream_class;
.event_header = NULL,
.event_common_context = NULL,
.event_specific_context = NULL,
- .event_payload = field_type,
+ .event_payload = field_class,
};
BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
- BT_ASSERT_PRE_NON_NULL(field_type, "Field type");
+ BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
BT_ASSERT_PRE_EVENT_CLASS_HOT(event_class);
- BT_ASSERT_PRE(bt_field_type_get_type_id(field_type) ==
- BT_FIELD_TYPE_ID_STRUCTURE,
- "Payload field type is not a structure field type: %!+F",
- field_type);
+ BT_ASSERT_PRE(bt_field_class_get_id(field_class) ==
+ BT_FIELD_CLASS_ID_STRUCTURE,
+ "Payload field classe is not a structure field classe: %!+F",
+ field_class);
stream_class = bt_event_class_borrow_stream_class_inline(
event_class);
trace = bt_stream_class_borrow_trace_inline(stream_class);
- resolve_ctx.packet_header = trace->packet_header_ft;
- resolve_ctx.packet_context = stream_class->packet_context_ft;
- resolve_ctx.event_header = stream_class->event_header_ft;
+ resolve_ctx.packet_header = trace->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_ft;
- resolve_ctx.event_specific_context = event_class->specific_context_ft;
+ stream_class->event_common_context_fc;
+ resolve_ctx.event_specific_context = event_class->specific_context_fc;
- ret = bt_resolve_field_paths(field_type, &resolve_ctx);
+ ret = bt_resolve_field_paths(field_class, &resolve_ctx);
if (ret) {
goto end;
}
- bt_field_type_make_part_of_trace(field_type);
- bt_put(event_class->payload_ft);
- event_class->payload_ft = bt_get(field_type);
- bt_field_type_freeze(field_type);
- BT_LIB_LOGV("Set event class's payload field type: %!+E", event_class);
+ bt_field_class_make_part_of_trace(field_class);
+ bt_put(event_class->payload_fc);
+ event_class->payload_fc = bt_get(field_class);
+ bt_field_class_freeze(field_class);
+ BT_LIB_LOGV("Set event class's payload field classe: %!+E", event_class);
end:
return ret;
BT_HIDDEN
void _bt_event_class_freeze(struct bt_event_class *event_class)
{
- /* The field types are already frozen */
+ /* The field classes are already frozen */
BT_ASSERT(event_class);
BT_LIB_LOGD("Freezing event class: %!+E", event_class);
event_class->frozen = true;
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
BT_ASSERT_PRE(bt_stream_class_borrow_trace_inline(stream_class),
"Stream class is not part of a trace: %!+S", stream_class);
- BT_ASSERT_PRE(stream_class->event_header_ft,
- "Stream class has no event header field type: %!+S",
+ BT_ASSERT_PRE(stream_class->event_header_fc,
+ "Stream class has no event header field classe: %!+S",
stream_class);
field_wrapper = bt_field_wrapper_create(
&stream_class->event_header_field_pool,
- (void *) stream_class->event_header_ft);
+ (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);
#include <babeltrace/assert-pre-internal.h>
#include <babeltrace/trace-ir/fields-internal.h>
-#include <babeltrace/trace-ir/field-types-internal.h>
+#include <babeltrace/trace-ir/field-classes-internal.h>
#include <babeltrace/trace-ir/clock-class.h>
#include <babeltrace/trace-ir/clock-value.h>
#include <babeltrace/trace-ir/clock-value-internal.h>
field_wrapper = bt_field_wrapper_create(
&stream_class->event_header_field_pool,
- bt_stream_class_borrow_event_header_field_type(stream_class));
+ bt_stream_class_borrow_event_header_field_class(stream_class));
if (!field_wrapper) {
goto error;
}
{
struct bt_event *event = NULL;
struct bt_stream_class *stream_class;
- struct bt_field_type *ft;
+ struct bt_field_class *fc;
BT_ASSERT(event_class);
event = g_new0(struct bt_event, 1);
stream_class = bt_event_class_borrow_stream_class(event_class);
BT_ASSERT(stream_class);
- if (bt_stream_class_borrow_event_header_field_type(stream_class)) {
+ if (bt_stream_class_borrow_event_header_field_class(stream_class)) {
event->header_field = create_event_header_field(stream_class);
if (!event->header_field) {
BT_LOGE_STR("Cannot create event header field.");
}
}
- ft = bt_stream_class_borrow_event_common_context_field_type(
+ fc = bt_stream_class_borrow_event_common_context_field_class(
stream_class);
- if (ft) {
- event->common_context_field = bt_field_create(ft);
+ if (fc) {
+ event->common_context_field = bt_field_create(fc);
if (!event->common_context_field) {
/* bt_field_create() logs errors */
goto error;
}
}
- ft = bt_event_class_borrow_specific_context_field_type(event_class);
- if (ft) {
- event->specific_context_field = bt_field_create(ft);
+ fc = bt_event_class_borrow_specific_context_field_class(event_class);
+ if (fc) {
+ event->specific_context_field = bt_field_create(fc);
if (!event->specific_context_field) {
/* bt_field_create() logs errors */
goto error;
}
}
- ft = bt_event_class_borrow_payload_field_type(event_class);
- if (ft) {
- event->payload_field = bt_field_create(ft);
+ fc = bt_event_class_borrow_payload_field_class(event_class);
+ if (fc) {
+ event->payload_field = bt_field_create(fc);
if (!event->payload_field) {
/* bt_field_create() logs errors */
goto error;
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_ft,
- "Stream class has no event header field type: %!+S",
+ BT_ASSERT_PRE(stream_class->event_header_fc,
+ "Stream class has no event header field classe: %!+S",
stream_class);
/* Recycle current header field: always exists */
--- /dev/null
+/*
+ * field-classes.c
+ *
+ * Babeltrace trace IR - Event Types
+ *
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@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 "FIELD-CLASSES"
+#include <babeltrace/lib-logging-internal.h>
+
+#include <babeltrace/assert-pre-internal.h>
+#include <babeltrace/trace-ir/field-classes-internal.h>
+#include <babeltrace/trace-ir/field-path-internal.h>
+#include <babeltrace/trace-ir/fields-internal.h>
+#include <babeltrace/trace-ir/fields.h>
+#include <babeltrace/trace-ir/utils-internal.h>
+#include <babeltrace/ref.h>
+#include <babeltrace/trace-ir/clock-class.h>
+#include <babeltrace/trace-ir/clock-class-internal.h>
+#include <babeltrace/object-internal.h>
+#include <babeltrace/ref.h>
+#include <babeltrace/compiler-internal.h>
+#include <babeltrace/endian-internal.h>
+#include <babeltrace/assert-internal.h>
+#include <babeltrace/compat/glib-internal.h>
+#include <float.h>
+#include <inttypes.h>
+#include <stdlib.h>
+
+enum bt_field_class_id bt_field_class_get_id(struct bt_field_class *fc)
+{
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ return fc->id;
+}
+
+static
+void init_field_class(struct bt_field_class *fc, enum bt_field_class_id id,
+ bt_object_release_func release_func)
+{
+ BT_ASSERT(fc);
+ BT_ASSERT(bt_field_class_has_known_id(fc));
+ BT_ASSERT(release_func);
+ bt_object_init_shared(&fc->base, release_func);
+ fc->id = id;
+}
+
+static
+void init_integer_field_class(struct bt_field_class_integer *fc, enum bt_field_class_id id,
+ bt_object_release_func release_func)
+{
+ init_field_class((void *) fc, id, release_func);
+ fc->range = 64;
+ fc->base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL;
+}
+
+static
+void destroy_integer_field_class(struct bt_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_LIB_LOGD("Destroying integer field classe object: %!+F", obj);
+ g_free(obj);
+}
+
+static inline
+struct bt_field_class *create_integer_field_class(enum bt_field_class_id id)
+{
+ struct bt_field_class_integer *int_fc = NULL;
+
+ BT_LOGD("Creating default integer field classe object: id=%s",
+ bt_common_field_class_id_string(id));
+ int_fc = g_new0(struct bt_field_class_integer, 1);
+ if (!int_fc) {
+ BT_LOGE_STR("Failed to allocate one integer field classe.");
+ goto error;
+ }
+
+ init_integer_field_class(int_fc, id, destroy_integer_field_class);
+ BT_LIB_LOGD("Created integer field classe object: %!+F", int_fc);
+ goto end;
+
+error:
+ BT_PUT(int_fc);
+
+end:
+ return (void *) int_fc;
+}
+
+struct bt_field_class *bt_field_class_unsigned_integer_create(void)
+{
+ return create_integer_field_class(BT_FIELD_CLASS_ID_UNSIGNED_INTEGER);
+}
+
+struct bt_field_class *bt_field_class_signed_integer_create(void)
+{
+ return create_integer_field_class(BT_FIELD_CLASS_ID_SIGNED_INTEGER);
+}
+
+uint64_t bt_field_class_integer_get_field_value_range(
+ struct bt_field_class *fc)
+{
+ struct bt_field_class_integer *int_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_IS_INT(fc, "Field class");
+ return int_fc->range;
+}
+
+BT_ASSERT_PRE_FUNC
+static
+bool size_is_valid_for_enumeration_field_class(struct bt_field_class *fc,
+ uint64_t size)
+{
+ // TODO
+ return true;
+}
+
+int bt_field_class_integer_set_field_value_range(
+ struct bt_field_class *fc, uint64_t size)
+{
+ struct bt_field_class_integer *int_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_IS_INT(fc, "Field class");
+ BT_ASSERT_PRE_FC_HOT(fc, "Field class");
+ BT_ASSERT_PRE(size <= 64,
+ "Unsupported size for integer field classe's field value range "
+ "(maximum is 64): size=%" PRIu64, size);
+ BT_ASSERT_PRE(int_fc->common.id == BT_FIELD_CLASS_ID_UNSIGNED_INTEGER ||
+ int_fc->common.id == BT_FIELD_CLASS_ID_SIGNED_INTEGER ||
+ size_is_valid_for_enumeration_field_class(fc, size),
+ "Invalid field value range for enumeration field classe: "
+ "at least one of the current mapping ranges contains values "
+ "which are outside this range: %!+F, size=%" PRIu64, fc, size);
+ int_fc->range = size;
+ BT_LIB_LOGV("Set integer field classe's field value range: %!+F", fc);
+ return 0;
+}
+
+enum bt_field_class_integer_preferred_display_base
+bt_field_class_integer_get_preferred_display_base(struct bt_field_class *fc)
+{
+ struct bt_field_class_integer *int_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_IS_INT(fc, "Field class");
+ return int_fc->base;
+}
+
+int bt_field_class_integer_set_preferred_display_base(struct bt_field_class *fc,
+ enum bt_field_class_integer_preferred_display_base base)
+{
+ struct bt_field_class_integer *int_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_IS_INT(fc, "Field class");
+ BT_ASSERT_PRE_FC_HOT(fc, "Field class");
+ int_fc->base = base;
+ BT_LIB_LOGV("Set integer field classe's preferred display base: %!+F", fc);
+ return 0;
+}
+
+static
+void finalize_enumeration_field_class_mapping(
+ struct bt_field_class_enumeration_mapping *mapping)
+{
+ BT_ASSERT(mapping);
+
+ if (mapping->label) {
+ g_string_free(mapping->label, TRUE);
+ }
+
+ if (mapping->ranges) {
+ g_array_free(mapping->ranges, TRUE);
+ }
+}
+
+static
+void destroy_enumeration_field_class(struct bt_object *obj)
+{
+ struct bt_field_class_enumeration *fc = (void *) obj;
+
+ BT_ASSERT(fc);
+ BT_LIB_LOGD("Destroying enumeration field classe object: %!+F", fc);
+
+ if (fc->mappings) {
+ uint64_t i;
+
+ for (i = 0; i < fc->mappings->len; i++) {
+ finalize_enumeration_field_class_mapping(
+ BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(fc, i));
+ }
+
+ g_array_free(fc->mappings, TRUE);
+ }
+
+ if (fc->label_buf) {
+ g_ptr_array_free(fc->label_buf, TRUE);
+ }
+
+ g_free(fc);
+}
+
+static
+struct bt_field_class *create_enumeration_field_class(enum bt_field_class_id id)
+{
+ struct bt_field_class_enumeration *enum_fc = NULL;
+
+ BT_LOGD("Creating default enumeration field classe object: id=%s",
+ bt_common_field_class_id_string(id));
+ enum_fc = g_new0(struct bt_field_class_enumeration, 1);
+ if (!enum_fc) {
+ BT_LOGE_STR("Failed to allocate one enumeration field classe.");
+ goto error;
+ }
+
+ init_integer_field_class((void *) enum_fc, id,
+ destroy_enumeration_field_class);
+ enum_fc->mappings = g_array_new(FALSE, TRUE,
+ sizeof(struct bt_field_class_enumeration_mapping));
+ if (!enum_fc->mappings) {
+ BT_LOGE_STR("Failed to allocate a GArray.");
+ goto error;
+ }
+
+ enum_fc->label_buf = g_ptr_array_new();
+ if (!enum_fc->label_buf) {
+ BT_LOGE_STR("Failed to allocate a GArray.");
+ goto error;
+ }
+
+ BT_LIB_LOGD("Created enumeration field classe object: %!+F", enum_fc);
+ goto end;
+
+error:
+ BT_PUT(enum_fc);
+
+end:
+ return (void *) enum_fc;
+}
+
+struct bt_field_class *bt_field_class_unsigned_enumeration_create(void)
+{
+ return create_enumeration_field_class(
+ BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION);
+}
+
+struct bt_field_class *bt_field_class_signed_enumeration_create(void)
+{
+ return create_enumeration_field_class(
+ BT_FIELD_CLASS_ID_SIGNED_ENUMERATION);
+}
+
+uint64_t bt_field_class_enumeration_get_mapping_count(struct bt_field_class *fc)
+{
+ struct bt_field_class_enumeration *enum_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_IS_ENUM(fc, "Field class");
+ return (uint64_t) enum_fc->mappings->len;
+}
+
+void bt_field_class_unsigned_enumeration_borrow_mapping_by_index(
+ struct bt_field_class *fc, uint64_t index,
+ const char **name,
+ struct bt_field_class_unsigned_enumeration_mapping_ranges **ranges)
+{
+ struct bt_field_class_enumeration *enum_fc = (void *) fc;
+ struct bt_field_class_enumeration_mapping *mapping;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_NON_NULL(name, "Name (output)");
+ BT_ASSERT_PRE_NON_NULL(ranges, "Ranges (output)");
+ BT_ASSERT_PRE_VALID_INDEX(index, enum_fc->mappings->len);
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION,
+ "Field class");
+ mapping = BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(fc, index);
+ *name = mapping->label->str;
+ *ranges = (void *) mapping;
+}
+
+void bt_field_class_signed_enumeration_borrow_mapping_by_index(
+ struct bt_field_class *fc, uint64_t index,
+ const char **name,
+ struct bt_field_class_signed_enumeration_mapping_ranges **ranges)
+{
+ struct bt_field_class_enumeration *enum_fc = (void *) fc;
+ struct bt_field_class_enumeration_mapping *mapping;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_NON_NULL(name, "Name (output)");
+ BT_ASSERT_PRE_NON_NULL(ranges, "Ranges (output)");
+ BT_ASSERT_PRE_VALID_INDEX(index, enum_fc->mappings->len);
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_SIGNED_ENUMERATION,
+ "Field class");
+ mapping = BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(fc, index);
+ *name = mapping->label->str;
+ *ranges = (void *) mapping;
+}
+
+static inline
+uint64_t get_enumeration_field_class_mapping_range_count(
+ struct bt_field_class_enumeration_mapping *mapping)
+{
+ BT_ASSERT_PRE_NON_NULL(mapping, "Ranges");
+ return (uint64_t) mapping->ranges->len;
+}
+
+uint64_t bt_field_class_unsigned_enumeration_mapping_ranges_get_range_count(
+ struct bt_field_class_unsigned_enumeration_mapping_ranges *ranges)
+{
+ return get_enumeration_field_class_mapping_range_count((void *) ranges);
+}
+
+uint64_t bt_field_class_signed_enumeration_mapping_ranges_get_range_count(
+ struct bt_field_class_signed_enumeration_mapping_ranges *ranges)
+{
+ return get_enumeration_field_class_mapping_range_count((void *) ranges);
+}
+
+static inline
+void get_enumeration_field_class_mapping_range_at_index(
+ struct bt_field_class_enumeration_mapping *mapping,
+ uint64_t index, uint64_t *lower, uint64_t *upper)
+{
+ struct bt_field_class_enumeration_mapping_range *range;
+
+ BT_ASSERT_PRE_NON_NULL(mapping, "Ranges");
+ BT_ASSERT_PRE_NON_NULL(lower, "Range's lower (output)");
+ BT_ASSERT_PRE_NON_NULL(upper, "Range's upper (output)");
+ BT_ASSERT_PRE_VALID_INDEX(index, mapping->ranges->len);
+ range = BT_FIELD_CLASS_ENUM_MAPPING_RANGE_AT_INDEX(mapping, index);
+ *lower = range->lower.u;
+ *upper = range->upper.u;
+}
+
+void bt_field_class_unsigned_enumeration_mapping_ranges_get_range_by_index(
+ struct bt_field_class_unsigned_enumeration_mapping_ranges *ranges,
+ uint64_t index, uint64_t *lower, uint64_t *upper)
+{
+ get_enumeration_field_class_mapping_range_at_index((void *) ranges,
+ index, lower, upper);
+}
+
+void bt_field_class_signed_enumeration_mapping_ranges_get_range_by_index(
+ struct bt_field_class_unsigned_enumeration_mapping_ranges *ranges,
+ uint64_t index, int64_t *lower, int64_t *upper)
+{
+ get_enumeration_field_class_mapping_range_at_index((void *) ranges,
+ index, (uint64_t *) lower, (uint64_t *) upper);
+}
+
+
+
+int bt_field_class_unsigned_enumeration_get_mapping_labels_by_value(
+ struct bt_field_class *fc, uint64_t value,
+ bt_field_class_enumeration_mapping_label_array *label_array,
+ uint64_t *count)
+{
+ struct bt_field_class_enumeration *enum_fc = (void *) fc;
+ uint64_t i;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_NON_NULL(label_array, "Label array (output)");
+ BT_ASSERT_PRE_NON_NULL(count, "Count (output)");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION,
+ "Field class");
+ g_ptr_array_set_size(enum_fc->label_buf, 0);
+
+ for (i = 0; i < enum_fc->mappings->len; i++) {
+ uint64_t j;
+ struct bt_field_class_enumeration_mapping *mapping =
+ BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(enum_fc, i);
+
+ for (j = 0; j < mapping->ranges->len; j++) {
+ struct bt_field_class_enumeration_mapping_range *range =
+ BT_FIELD_CLASS_ENUM_MAPPING_RANGE_AT_INDEX(
+ mapping, j);
+
+ if (value >= range->lower.u &&
+ value <= range->upper.u) {
+ g_ptr_array_add(enum_fc->label_buf,
+ mapping->label->str);
+ break;
+ }
+ }
+ }
+
+ *label_array = (void *) enum_fc->label_buf->pdata;
+ *count = (uint64_t) enum_fc->label_buf->len;
+ return 0;
+}
+
+int bt_field_class_signed_enumeration_get_mapping_labels_by_value(
+ struct bt_field_class *fc, int64_t value,
+ bt_field_class_enumeration_mapping_label_array *label_array,
+ uint64_t *count)
+{
+ struct bt_field_class_enumeration *enum_fc = (void *) fc;
+ uint64_t i;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_NON_NULL(label_array, "Label array (output)");
+ BT_ASSERT_PRE_NON_NULL(count, "Count (output)");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_SIGNED_ENUMERATION,
+ "Field class");
+ g_ptr_array_set_size(enum_fc->label_buf, 0);
+
+ for (i = 0; i < enum_fc->mappings->len; i++) {
+ uint64_t j;
+ struct bt_field_class_enumeration_mapping *mapping =
+ BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(enum_fc, i);
+
+ for (j = 0; j < mapping->ranges->len; j++) {
+ struct bt_field_class_enumeration_mapping_range *range =
+ BT_FIELD_CLASS_ENUM_MAPPING_RANGE_AT_INDEX(
+ mapping, j);
+
+ if (value >= range->lower.i &&
+ value <= range->upper.i) {
+ g_ptr_array_add(enum_fc->label_buf,
+ mapping->label->str);
+ break;
+ }
+ }
+ }
+
+ *label_array = (void *) enum_fc->label_buf->pdata;
+ *count = (uint64_t) enum_fc->label_buf->len;
+ return 0;
+}
+
+static inline
+int add_mapping_to_enumeration_field_class(struct bt_field_class *fc,
+ const char *label, uint64_t lower, uint64_t upper)
+{
+ int ret = 0;
+ uint64_t i;
+ struct bt_field_class_enumeration *enum_fc = (void *) fc;
+ struct bt_field_class_enumeration_mapping *mapping = NULL;
+ struct bt_field_class_enumeration_mapping_range *range;
+
+ BT_ASSERT(fc);
+ BT_ASSERT_PRE_NON_NULL(label, "Label");
+
+ /* Find existing mapping identified by this label */
+ for (i = 0; i < enum_fc->mappings->len; i++) {
+ struct bt_field_class_enumeration_mapping *mapping_candidate =
+ BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(enum_fc, i);
+
+ if (strcmp(mapping_candidate->label->str, label) == 0) {
+ mapping = mapping_candidate;
+ break;
+ }
+ }
+
+ if (!mapping) {
+ /* Create new mapping for this label */
+ g_array_set_size(enum_fc->mappings, enum_fc->mappings->len + 1);
+ mapping = BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(enum_fc,
+ enum_fc->mappings->len - 1);
+ mapping->ranges = g_array_new(FALSE, TRUE,
+ sizeof(struct bt_field_class_enumeration_mapping_range));
+ if (!mapping->ranges) {
+ finalize_enumeration_field_class_mapping(mapping);
+ g_array_set_size(enum_fc->mappings,
+ enum_fc->mappings->len - 1);
+ ret = -1;
+ goto end;
+ }
+
+ mapping->label = g_string_new(label);
+ if (!mapping->label) {
+ finalize_enumeration_field_class_mapping(mapping);
+ g_array_set_size(enum_fc->mappings,
+ enum_fc->mappings->len - 1);
+ ret = -1;
+ goto end;
+ }
+ }
+
+ /* Add range */
+ BT_ASSERT(mapping);
+ g_array_set_size(mapping->ranges, mapping->ranges->len + 1);
+ range = BT_FIELD_CLASS_ENUM_MAPPING_RANGE_AT_INDEX(mapping,
+ mapping->ranges->len - 1);
+ range->lower.u = lower;
+ range->upper.u = upper;
+ BT_LIB_LOGV("Added mapping to enumeration field classe: "
+ "%![fc-]+F, label=\"%s\", lower-unsigned=%" PRIu64 ", "
+ "upper-unsigned=%" PRIu64, fc, label, lower, upper);
+
+end:
+ return ret;
+}
+
+int bt_field_class_unsigned_enumeration_map_range(
+ struct bt_field_class *fc, const char *label,
+ uint64_t range_lower, uint64_t range_upper)
+{
+ struct bt_field_class_enumeration *enum_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION,
+ "Field class");
+ BT_ASSERT_PRE(range_lower <= range_upper,
+ "Range's upper bound is less than lower bound: "
+ "upper=%" PRIu64 ", lower=%" PRIu64,
+ range_lower, range_upper);
+ BT_ASSERT_PRE(bt_util_value_is_in_range_unsigned(enum_fc->common.range,
+ range_lower),
+ "Range's lower bound is outside the enumeration field classe's value range: "
+ "%![fc-]+F, lower=%" PRIu64, fc, range_lower);
+ BT_ASSERT_PRE(bt_util_value_is_in_range_unsigned(enum_fc->common.range,
+ range_upper),
+ "Range's upper bound is outside the enumeration field classe's value range: "
+ "%![fc-]+F, upper=%" PRIu64, fc, range_upper);
+ return add_mapping_to_enumeration_field_class(fc, label, range_lower,
+ range_upper);
+}
+
+int bt_field_class_signed_enumeration_map_range(
+ struct bt_field_class *fc, const char *label,
+ int64_t range_lower, int64_t range_upper)
+{
+ struct bt_field_class_enumeration *enum_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_SIGNED_ENUMERATION,
+ "Field class");
+ BT_ASSERT_PRE(range_lower <= range_upper,
+ "Range's upper bound is less than lower bound: "
+ "upper=%" PRId64 ", lower=%" PRId64,
+ range_lower, range_upper);
+ BT_ASSERT_PRE(bt_util_value_is_in_range_signed(enum_fc->common.range,
+ range_lower),
+ "Range's lower bound is outside the enumeration field classe's value range: "
+ "%![fc-]+F, lower=%" PRId64, fc, range_lower);
+ BT_ASSERT_PRE(bt_util_value_is_in_range_signed(enum_fc->common.range,
+ range_upper),
+ "Range's upper bound is outside the enumeration field classe's value range: "
+ "%![fc-]+F, upper=%" PRId64, fc, range_upper);
+ return add_mapping_to_enumeration_field_class(fc, label, range_lower,
+ range_upper);
+}
+
+static
+void destroy_real_field_class(struct bt_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_LIB_LOGD("Destroying real field classe object: %!+F", obj);
+ g_free(obj);
+}
+
+struct bt_field_class *bt_field_class_real_create(void)
+{
+ struct bt_field_class_real *real_fc = NULL;
+
+ BT_LOGD_STR("Creating default real field classe object.");
+ real_fc = g_new0(struct bt_field_class_real, 1);
+ if (!real_fc) {
+ BT_LOGE_STR("Failed to allocate one real field classe.");
+ goto error;
+ }
+
+ init_field_class((void *) real_fc, BT_FIELD_CLASS_ID_REAL,
+ destroy_real_field_class);
+ BT_LIB_LOGD("Created real field classe object: %!+F", real_fc);
+ goto end;
+
+error:
+ BT_PUT(real_fc);
+
+end:
+ return (void *) real_fc;
+}
+
+bt_bool bt_field_class_real_is_single_precision(struct bt_field_class *fc)
+{
+ struct bt_field_class_real *real_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_REAL, "Field class");
+ return real_fc->is_single_precision;
+}
+
+int bt_field_class_real_set_is_single_precision(struct bt_field_class *fc,
+ bt_bool is_single_precision)
+{
+ struct bt_field_class_real *real_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_REAL, "Field class");
+ BT_ASSERT_PRE_FC_HOT(fc, "Field class");
+ real_fc->is_single_precision = (bool) is_single_precision;
+ BT_LIB_LOGV("Set real field classe's \"is single precision\" property: "
+ "%!+F", fc);
+ return 0;
+}
+
+static
+int init_named_field_classes_container(
+ struct bt_field_class_named_field_class_container *fc,
+ enum bt_field_class_id id, bt_object_release_func release_func)
+{
+ int ret = 0;
+
+ init_field_class((void *) fc, id, release_func);
+ fc->named_fcs = g_array_new(FALSE, TRUE,
+ sizeof(struct bt_named_field_class));
+ if (!fc->named_fcs) {
+ BT_LOGE_STR("Failed to allocate a GArray.");
+ ret = -1;
+ goto end;
+ }
+
+ fc->name_to_index = g_hash_table_new(g_str_hash, g_str_equal);
+ if (!fc->name_to_index) {
+ BT_LOGE_STR("Failed to allocate a GHashTable.");
+ ret = -1;
+ goto end;
+ }
+
+end:
+ return ret;
+}
+
+static
+void finalize_named_field_class(struct bt_named_field_class *named_fc)
+{
+ BT_ASSERT(named_fc);
+ BT_LIB_LOGD("Finalizing named field classe: "
+ "addr=%p, name=\"%s\", %![fc-]+F",
+ named_fc, named_fc->name ? named_fc->name->str : NULL,
+ named_fc->fc);
+
+ if (named_fc->name) {
+ g_string_free(named_fc->name, TRUE);
+ }
+
+ BT_LOGD_STR("Putting named field classe's field classe.");
+ bt_put(named_fc->fc);
+}
+
+static
+void finalize_named_field_classes_container(
+ struct bt_field_class_named_field_class_container *fc)
+{
+ uint64_t i;
+
+ BT_ASSERT(fc);
+
+ if (fc->named_fcs) {
+ for (i = 0; i < fc->named_fcs->len; i++) {
+ finalize_named_field_class(
+ &g_array_index(fc->named_fcs,
+ struct bt_named_field_class, i));
+ }
+
+ g_array_free(fc->named_fcs, TRUE);
+ }
+
+ if (fc->name_to_index) {
+ g_hash_table_destroy(fc->name_to_index);
+ }
+}
+
+static
+void destroy_structure_field_class(struct bt_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_LIB_LOGD("Destroying string field classe object: %!+F", obj);
+ finalize_named_field_classes_container((void *) obj);
+ g_free(obj);
+}
+
+struct bt_field_class *bt_field_class_structure_create(void)
+{
+ int ret;
+ struct bt_field_class_structure *struct_fc = NULL;
+
+ BT_LOGD_STR("Creating default structure field classe object.");
+ struct_fc = g_new0(struct bt_field_class_structure, 1);
+ if (!struct_fc) {
+ BT_LOGE_STR("Failed to allocate one structure field classe.");
+ goto error;
+ }
+
+ ret = init_named_field_classes_container((void *) struct_fc,
+ BT_FIELD_CLASS_ID_STRUCTURE, destroy_structure_field_class);
+ if (ret) {
+ goto error;
+ }
+
+ BT_LIB_LOGD("Created structure field classe object: %!+F", struct_fc);
+ goto end;
+
+error:
+ BT_PUT(struct_fc);
+
+end:
+ return (void *) struct_fc;
+}
+
+static
+int append_named_field_class_to_container_field_class(
+ struct bt_field_class_named_field_class_container *container_fc,
+ const char *name, struct bt_field_class *fc)
+{
+ int ret = 0;
+ struct bt_named_field_class *named_fc;
+ GString *name_str;
+
+ BT_ASSERT(container_fc);
+ BT_ASSERT_PRE_FC_HOT(container_fc, "Field class");
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE(!bt_g_hash_table_contains(container_fc->name_to_index,
+ name),
+ "Duplicate member/option name in structure/variant field classe: "
+ "%![container-fc-]+F, name=\"%s\"", container_fc, name);
+ name_str = g_string_new(name);
+ if (!name_str) {
+ BT_LOGE_STR("Failed to allocate a GString.");
+ ret = -1;
+ goto end;
+ }
+
+ g_array_set_size(container_fc->named_fcs,
+ container_fc->named_fcs->len + 1);
+ named_fc = &g_array_index(container_fc->named_fcs,
+ struct bt_named_field_class, container_fc->named_fcs->len - 1);
+ named_fc->name = name_str;
+ named_fc->fc = bt_get(fc);
+ g_hash_table_insert(container_fc->name_to_index, named_fc->name->str,
+ GUINT_TO_POINTER(container_fc->named_fcs->len - 1));
+ bt_field_class_freeze(fc);
+
+end:
+ return ret;
+}
+
+int bt_field_class_structure_append_member(struct bt_field_class *fc,
+ const char *name, struct bt_field_class *member_fc)
+{
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_STRUCTURE, "Field class");
+ return append_named_field_class_to_container_field_class((void *) fc,
+ name, member_fc);
+}
+
+uint64_t bt_field_class_structure_get_member_count(struct bt_field_class *fc)
+{
+ struct bt_field_class_structure *struct_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_STRUCTURE, "Field class");
+ return (uint64_t) struct_fc->common.named_fcs->len;
+}
+
+static
+void borrow_named_field_class_from_container_field_class_at_index(
+ struct bt_field_class_named_field_class_container *fc,
+ uint64_t index, const char **name,
+ struct bt_field_class **out_fc)
+{
+ struct bt_named_field_class *named_fc;
+
+ BT_ASSERT(fc);
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+ BT_ASSERT_PRE_NON_NULL(out_fc, "Field class (output)");
+ BT_ASSERT_PRE_VALID_INDEX(index, fc->named_fcs->len);
+ named_fc = BT_FIELD_CLASS_NAMED_FC_AT_INDEX(fc, index);
+ *name = named_fc->name->str;
+ *out_fc = named_fc->fc;
+}
+
+void bt_field_class_structure_borrow_member_by_index(
+ struct bt_field_class *fc, uint64_t index,
+ const char **name, struct bt_field_class **out_fc)
+{
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_STRUCTURE, "Field class");
+ borrow_named_field_class_from_container_field_class_at_index((void *) fc,
+ index, name, out_fc);
+}
+
+static
+struct bt_field_class *borrow_field_class_from_container_field_class_by_name(
+ struct bt_field_class_named_field_class_container *fc,
+ const char *name)
+{
+ struct bt_field_class *ret_fc = NULL;
+ struct bt_named_field_class *named_fc;
+ gpointer orig_key;
+ gpointer value;
+
+ BT_ASSERT(fc);
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+ if (!g_hash_table_lookup_extended(fc->name_to_index, name, &orig_key,
+ &value)) {
+ goto end;
+ }
+
+ named_fc = BT_FIELD_CLASS_NAMED_FC_AT_INDEX(fc,
+ GPOINTER_TO_UINT(value));
+ ret_fc = named_fc->fc;
+
+end:
+ return ret_fc;
+}
+
+struct bt_field_class *bt_field_class_structure_borrow_member_field_class_by_name(
+ struct bt_field_class *fc, const char *name)
+{
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_STRUCTURE, "Field class");
+ return borrow_field_class_from_container_field_class_by_name((void *) fc,
+ name);
+}
+
+static
+void destroy_variant_field_class(struct bt_object *obj)
+{
+ struct bt_field_class_variant *fc = (void *) obj;
+
+ BT_ASSERT(fc);
+ BT_LIB_LOGD("Destroying variant field classe object: %!+F", fc);
+ finalize_named_field_classes_container((void *) fc);
+ BT_LOGD_STR("Putting selector field path.");
+ bt_put(fc->selector_field_path);
+ g_free(fc);
+}
+
+struct bt_field_class *bt_field_class_variant_create(void)
+{
+ int ret;
+ struct bt_field_class_variant *var_fc = NULL;
+
+ BT_LOGD_STR("Creating default variant field classe object.");
+ var_fc = g_new0(struct bt_field_class_variant, 1);
+ if (!var_fc) {
+ BT_LOGE_STR("Failed to allocate one variant field classe.");
+ goto error;
+ }
+
+ ret = init_named_field_classes_container((void *) var_fc,
+ BT_FIELD_CLASS_ID_VARIANT, destroy_variant_field_class);
+ if (ret) {
+ goto error;
+ }
+
+ BT_LIB_LOGD("Created variant field classe object: %!+F", var_fc);
+ goto end;
+
+error:
+ BT_PUT(var_fc);
+
+end:
+ return (void *) var_fc;
+}
+
+int bt_field_class_variant_set_selector_field_class(
+ struct bt_field_class *fc, struct bt_field_class *selector_fc)
+{
+ struct bt_field_class_variant *var_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Variant field classe");
+ BT_ASSERT_PRE_NON_NULL(selector_fc, "Selector field classe");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_VARIANT, "Field class");
+ BT_ASSERT_PRE_FC_IS_ENUM(selector_fc, "Selector field classe");
+ BT_ASSERT_PRE_FC_HOT(fc, "Variant field classe");
+ var_fc->selector_fc = selector_fc;
+ bt_field_class_freeze(selector_fc);
+ return 0;
+}
+
+int bt_field_class_variant_append_option(struct bt_field_class *fc,
+ const char *name, struct bt_field_class *option_fc)
+{
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_VARIANT, "Field class");
+ return append_named_field_class_to_container_field_class((void *) fc,
+ name, option_fc);
+}
+
+struct bt_field_class *bt_field_class_variant_borrow_option_field_class_by_name(
+ struct bt_field_class *fc, const char *name)
+{
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_VARIANT, "Field class");
+ return borrow_field_class_from_container_field_class_by_name((void *) fc,
+ name);
+}
+
+uint64_t bt_field_class_variant_get_option_count(struct bt_field_class *fc)
+{
+ struct bt_field_class_variant *var_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_VARIANT, "Field class");
+ return (uint64_t) var_fc->common.named_fcs->len;
+}
+
+void bt_field_class_variant_borrow_option_by_index(
+ struct bt_field_class *fc, uint64_t index,
+ const char **name, struct bt_field_class **out_fc)
+{
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_VARIANT, "Field class");
+ borrow_named_field_class_from_container_field_class_at_index((void *) fc,
+ index, name, out_fc);
+}
+
+struct bt_field_path *bt_field_class_variant_borrow_selector_field_path(
+ struct bt_field_class *fc)
+{
+ struct bt_field_class_variant *var_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_VARIANT,
+ "Field class");
+ return var_fc->selector_field_path;
+}
+
+static
+void init_array_field_class(struct bt_field_class_array *fc,
+ enum bt_field_class_id id, bt_object_release_func release_func,
+ struct bt_field_class *element_fc)
+{
+ BT_ASSERT(element_fc);
+ init_field_class((void *) fc, id, release_func);
+ fc->element_fc = bt_get(element_fc);
+ bt_field_class_freeze(element_fc);
+}
+
+static
+void finalize_array_field_class(struct bt_field_class_array *array_fc)
+{
+ BT_ASSERT(array_fc);
+ BT_LOGD_STR("Putting element field classe.");
+ bt_put(array_fc->element_fc);
+}
+
+static
+void destroy_static_array_field_class(struct bt_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_LIB_LOGD("Destroying static array field classe object: %!+F", obj);
+ finalize_array_field_class((void *) obj);
+ g_free(obj);
+}
+
+struct bt_field_class *bt_field_class_static_array_create(
+ struct bt_field_class *element_fc, uint64_t length)
+{
+ struct bt_field_class_static_array *array_fc = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(element_fc, "Element field classe");
+ BT_LOGD_STR("Creating default static array field classe object.");
+ array_fc = g_new0(struct bt_field_class_static_array, 1);
+ if (!array_fc) {
+ BT_LOGE_STR("Failed to allocate one static array field classe.");
+ goto error;
+ }
+
+ init_array_field_class((void *) array_fc, BT_FIELD_CLASS_ID_STATIC_ARRAY,
+ destroy_static_array_field_class, element_fc);
+ array_fc->length = length;
+ BT_LIB_LOGD("Created static array field classe object: %!+F", array_fc);
+ goto end;
+
+error:
+ BT_PUT(array_fc);
+
+end:
+ return (void *) array_fc;
+}
+
+struct bt_field_class *bt_field_class_array_borrow_element_field_class(
+ struct bt_field_class *fc)
+{
+ struct bt_field_class_array *array_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_IS_ARRAY(fc, "Field class");
+ return array_fc->element_fc;
+}
+
+uint64_t bt_field_class_static_array_get_length(struct bt_field_class *fc)
+{
+ struct bt_field_class_static_array *array_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_STATIC_ARRAY,
+ "Field class");
+ return (uint64_t) array_fc->length;
+}
+
+static
+void destroy_dynamic_array_field_class(struct bt_object *obj)
+{
+ struct bt_field_class_dynamic_array *fc = (void *) obj;
+
+ BT_ASSERT(fc);
+ BT_LIB_LOGD("Destroying dynamic array field classe object: %!+F", fc);
+ finalize_array_field_class((void *) fc);
+ BT_LOGD_STR("Putting length field path.");
+ bt_put(fc->length_field_path);
+ g_free(fc);
+}
+
+struct bt_field_class *bt_field_class_dynamic_array_create(
+ struct bt_field_class *element_fc)
+{
+ struct bt_field_class_dynamic_array *array_fc = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(element_fc, "Element field classe");
+ BT_LOGD_STR("Creating default dynamic array field classe object.");
+ array_fc = g_new0(struct bt_field_class_dynamic_array, 1);
+ if (!array_fc) {
+ BT_LOGE_STR("Failed to allocate one dynamic array field classe.");
+ goto error;
+ }
+
+ init_array_field_class((void *) array_fc, BT_FIELD_CLASS_ID_DYNAMIC_ARRAY,
+ destroy_dynamic_array_field_class, element_fc);
+ BT_LIB_LOGD("Created dynamic array field classe object: %!+F", array_fc);
+ goto end;
+
+error:
+ BT_PUT(array_fc);
+
+end:
+ return (void *) array_fc;
+}
+
+int bt_field_class_dynamic_array_set_length_field_class(struct bt_field_class *fc,
+ struct bt_field_class *length_fc)
+{
+ struct bt_field_class_dynamic_array *array_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Dynamic array field classe");
+ BT_ASSERT_PRE_NON_NULL(length_fc, "Length field classe");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_DYNAMIC_ARRAY,
+ "Field class");
+ BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(length_fc, "Length field classe");
+ BT_ASSERT_PRE_FC_HOT(fc, "Dynamic array field classe");
+ array_fc->length_fc = length_fc;
+ bt_field_class_freeze(length_fc);
+ return 0;
+}
+
+struct bt_field_path *bt_field_class_dynamic_array_borrow_length_field_path(
+ struct bt_field_class *fc)
+{
+ struct bt_field_class_dynamic_array *seq_fc = (void *) fc;
+
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_DYNAMIC_ARRAY,
+ "Field class");
+ return seq_fc->length_field_path;
+}
+
+static
+void destroy_string_field_class(struct bt_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_LIB_LOGD("Destroying string field classe object: %!+F", obj);
+ g_free(obj);
+}
+
+struct bt_field_class *bt_field_class_string_create(void)
+{
+ struct bt_field_class_string *string_fc = NULL;
+
+ BT_LOGD_STR("Creating default string field classe object.");
+ string_fc = g_new0(struct bt_field_class_string, 1);
+ if (!string_fc) {
+ BT_LOGE_STR("Failed to allocate one string field classe.");
+ goto error;
+ }
+
+ init_field_class((void *) string_fc, BT_FIELD_CLASS_ID_STRING,
+ destroy_string_field_class);
+ BT_LIB_LOGD("Created string field classe object: %!+F", string_fc);
+ goto end;
+
+error:
+ BT_PUT(string_fc);
+
+end:
+ return (void *) string_fc;
+}
+
+BT_HIDDEN
+void _bt_field_class_freeze(struct bt_field_class *fc)
+{
+ /*
+ * Element/member/option field classes are frozen when added to
+ * their owner.
+ */
+ BT_ASSERT(fc);
+ fc->frozen = true;
+}
+
+BT_HIDDEN
+void _bt_field_class_make_part_of_trace(struct bt_field_class *fc)
+{
+ BT_ASSERT(fc);
+ BT_ASSERT_PRE(!fc->part_of_trace,
+ "Field class is already part of a trace: %!+F", fc);
+ fc->part_of_trace = true;
+
+ switch (fc->id) {
+ case BT_FIELD_CLASS_ID_STRUCTURE:
+ case BT_FIELD_CLASS_ID_VARIANT:
+ {
+ struct bt_field_class_named_field_class_container *container_fc =
+ (void *) fc;
+ uint64_t i;
+
+ for (i = 0; i < container_fc->named_fcs->len; i++) {
+ struct bt_named_field_class *named_fc =
+ BT_FIELD_CLASS_NAMED_FC_AT_INDEX(
+ container_fc, i);
+
+ bt_field_class_make_part_of_trace(named_fc->fc);
+ }
+
+ break;
+ }
+ case BT_FIELD_CLASS_ID_STATIC_ARRAY:
+ case BT_FIELD_CLASS_ID_DYNAMIC_ARRAY:
+ {
+ struct bt_field_class_array *array_fc = (void *) fc;
+
+ bt_field_class_make_part_of_trace(array_fc->element_fc);
+ break;
+ }
+ default:
+ break;
+ }
+}
#include <babeltrace/lib-logging-internal.h>
#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/field-types.h>
-#include <babeltrace/trace-ir/field-types-internal.h>
+#include <babeltrace/trace-ir/field-classes.h>
+#include <babeltrace/trace-ir/field-classes-internal.h>
#include <babeltrace/trace-ir/field-path-internal.h>
#include <babeltrace/trace-ir/field-path.h>
#include <limits.h>
+++ /dev/null
-/*
- * field-types.c
- *
- * Babeltrace trace IR - Event Types
- *
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@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 "FIELD-TYPES"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/field-types-internal.h>
-#include <babeltrace/trace-ir/field-path-internal.h>
-#include <babeltrace/trace-ir/fields-internal.h>
-#include <babeltrace/trace-ir/fields.h>
-#include <babeltrace/trace-ir/utils-internal.h>
-#include <babeltrace/ref.h>
-#include <babeltrace/trace-ir/clock-class.h>
-#include <babeltrace/trace-ir/clock-class-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/ref.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compat/glib-internal.h>
-#include <float.h>
-#include <inttypes.h>
-#include <stdlib.h>
-
-enum bt_field_type_id bt_field_type_get_type_id(struct bt_field_type *ft)
-{
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- return ft->id;
-}
-
-static
-void init_field_type(struct bt_field_type *ft, enum bt_field_type_id id,
- bt_object_release_func release_func)
-{
- BT_ASSERT(ft);
- BT_ASSERT(bt_field_type_has_known_id(ft));
- BT_ASSERT(release_func);
- bt_object_init_shared(&ft->base, release_func);
- ft->id = id;
-}
-
-static
-void init_integer_field_type(struct bt_field_type_integer *ft, enum bt_field_type_id id,
- bt_object_release_func release_func)
-{
- init_field_type((void *) ft, id, release_func);
- ft->range = 64;
- ft->base = BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL;
-}
-
-static
-void destroy_integer_field_type(struct bt_object *obj)
-{
- BT_ASSERT(obj);
- BT_LIB_LOGD("Destroying integer field type object: %!+F", obj);
- g_free(obj);
-}
-
-static inline
-struct bt_field_type *create_integer_field_type(enum bt_field_type_id id)
-{
- struct bt_field_type_integer *int_ft = NULL;
-
- BT_LOGD("Creating default integer field type object: id=%s",
- bt_common_field_type_id_string(id));
- int_ft = g_new0(struct bt_field_type_integer, 1);
- if (!int_ft) {
- BT_LOGE_STR("Failed to allocate one integer field type.");
- goto error;
- }
-
- init_integer_field_type(int_ft, id, destroy_integer_field_type);
- BT_LIB_LOGD("Created integer field type object: %!+F", int_ft);
- goto end;
-
-error:
- BT_PUT(int_ft);
-
-end:
- return (void *) int_ft;
-}
-
-struct bt_field_type *bt_field_type_unsigned_integer_create(void)
-{
- return create_integer_field_type(BT_FIELD_TYPE_ID_UNSIGNED_INTEGER);
-}
-
-struct bt_field_type *bt_field_type_signed_integer_create(void)
-{
- return create_integer_field_type(BT_FIELD_TYPE_ID_SIGNED_INTEGER);
-}
-
-uint64_t bt_field_type_integer_get_field_value_range(
- struct bt_field_type *ft)
-{
- struct bt_field_type_integer *int_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_IS_INT(ft, "Field type");
- return int_ft->range;
-}
-
-BT_ASSERT_PRE_FUNC
-static
-bool size_is_valid_for_enumeration_field_type(struct bt_field_type *ft,
- uint64_t size)
-{
- // TODO
- return true;
-}
-
-int bt_field_type_integer_set_field_value_range(
- struct bt_field_type *ft, uint64_t size)
-{
- struct bt_field_type_integer *int_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_IS_INT(ft, "Field type");
- BT_ASSERT_PRE_FT_HOT(ft, "Field type");
- BT_ASSERT_PRE(size <= 64,
- "Unsupported size for integer field type's field value range "
- "(maximum is 64): size=%" PRIu64, size);
- BT_ASSERT_PRE(int_ft->common.id == BT_FIELD_TYPE_ID_UNSIGNED_INTEGER ||
- int_ft->common.id == BT_FIELD_TYPE_ID_SIGNED_INTEGER ||
- size_is_valid_for_enumeration_field_type(ft, size),
- "Invalid field value range for enumeration field type: "
- "at least one of the current mapping ranges contains values "
- "which are outside this range: %!+F, size=%" PRIu64, ft, size);
- int_ft->range = size;
- BT_LIB_LOGV("Set integer field type's field value range: %!+F", ft);
- return 0;
-}
-
-enum bt_field_type_integer_preferred_display_base
-bt_field_type_integer_get_preferred_display_base(struct bt_field_type *ft)
-{
- struct bt_field_type_integer *int_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_IS_INT(ft, "Field type");
- return int_ft->base;
-}
-
-int bt_field_type_integer_set_preferred_display_base(struct bt_field_type *ft,
- enum bt_field_type_integer_preferred_display_base base)
-{
- struct bt_field_type_integer *int_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_IS_INT(ft, "Field type");
- BT_ASSERT_PRE_FT_HOT(ft, "Field type");
- int_ft->base = base;
- BT_LIB_LOGV("Set integer field type's preferred display base: %!+F", ft);
- return 0;
-}
-
-static
-void finalize_enumeration_field_type_mapping(
- struct bt_field_type_enumeration_mapping *mapping)
-{
- BT_ASSERT(mapping);
-
- if (mapping->label) {
- g_string_free(mapping->label, TRUE);
- }
-
- if (mapping->ranges) {
- g_array_free(mapping->ranges, TRUE);
- }
-}
-
-static
-void destroy_enumeration_field_type(struct bt_object *obj)
-{
- struct bt_field_type_enumeration *ft = (void *) obj;
-
- BT_ASSERT(ft);
- BT_LIB_LOGD("Destroying enumeration field type object: %!+F", ft);
-
- if (ft->mappings) {
- uint64_t i;
-
- for (i = 0; i < ft->mappings->len; i++) {
- finalize_enumeration_field_type_mapping(
- BT_FIELD_TYPE_ENUM_MAPPING_AT_INDEX(ft, i));
- }
-
- g_array_free(ft->mappings, TRUE);
- }
-
- if (ft->label_buf) {
- g_ptr_array_free(ft->label_buf, TRUE);
- }
-
- g_free(ft);
-}
-
-static
-struct bt_field_type *create_enumeration_field_type(enum bt_field_type_id id)
-{
- struct bt_field_type_enumeration *enum_ft = NULL;
-
- BT_LOGD("Creating default enumeration field type object: id=%s",
- bt_common_field_type_id_string(id));
- enum_ft = g_new0(struct bt_field_type_enumeration, 1);
- if (!enum_ft) {
- BT_LOGE_STR("Failed to allocate one enumeration field type.");
- goto error;
- }
-
- init_integer_field_type((void *) enum_ft, id,
- destroy_enumeration_field_type);
- enum_ft->mappings = g_array_new(FALSE, TRUE,
- sizeof(struct bt_field_type_enumeration_mapping));
- if (!enum_ft->mappings) {
- BT_LOGE_STR("Failed to allocate a GArray.");
- goto error;
- }
-
- enum_ft->label_buf = g_ptr_array_new();
- if (!enum_ft->label_buf) {
- BT_LOGE_STR("Failed to allocate a GArray.");
- goto error;
- }
-
- BT_LIB_LOGD("Created enumeration field type object: %!+F", enum_ft);
- goto end;
-
-error:
- BT_PUT(enum_ft);
-
-end:
- return (void *) enum_ft;
-}
-
-struct bt_field_type *bt_field_type_unsigned_enumeration_create(void)
-{
- return create_enumeration_field_type(
- BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION);
-}
-
-struct bt_field_type *bt_field_type_signed_enumeration_create(void)
-{
- return create_enumeration_field_type(
- BT_FIELD_TYPE_ID_SIGNED_ENUMERATION);
-}
-
-uint64_t bt_field_type_enumeration_get_mapping_count(struct bt_field_type *ft)
-{
- struct bt_field_type_enumeration *enum_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_IS_ENUM(ft, "Field type");
- return (uint64_t) enum_ft->mappings->len;
-}
-
-void bt_field_type_unsigned_enumeration_borrow_mapping_by_index(
- struct bt_field_type *ft, uint64_t index,
- const char **name,
- struct bt_field_type_unsigned_enumeration_mapping_ranges **ranges)
-{
- struct bt_field_type_enumeration *enum_ft = (void *) ft;
- struct bt_field_type_enumeration_mapping *mapping;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_NON_NULL(name, "Name (output)");
- BT_ASSERT_PRE_NON_NULL(ranges, "Ranges (output)");
- BT_ASSERT_PRE_VALID_INDEX(index, enum_ft->mappings->len);
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION,
- "Field type");
- mapping = BT_FIELD_TYPE_ENUM_MAPPING_AT_INDEX(ft, index);
- *name = mapping->label->str;
- *ranges = (void *) mapping;
-}
-
-void bt_field_type_signed_enumeration_borrow_mapping_by_index(
- struct bt_field_type *ft, uint64_t index,
- const char **name,
- struct bt_field_type_signed_enumeration_mapping_ranges **ranges)
-{
- struct bt_field_type_enumeration *enum_ft = (void *) ft;
- struct bt_field_type_enumeration_mapping *mapping;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_NON_NULL(name, "Name (output)");
- BT_ASSERT_PRE_NON_NULL(ranges, "Ranges (output)");
- BT_ASSERT_PRE_VALID_INDEX(index, enum_ft->mappings->len);
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_SIGNED_ENUMERATION,
- "Field type");
- mapping = BT_FIELD_TYPE_ENUM_MAPPING_AT_INDEX(ft, index);
- *name = mapping->label->str;
- *ranges = (void *) mapping;
-}
-
-static inline
-uint64_t get_enumeration_field_type_mapping_range_count(
- struct bt_field_type_enumeration_mapping *mapping)
-{
- BT_ASSERT_PRE_NON_NULL(mapping, "Ranges");
- return (uint64_t) mapping->ranges->len;
-}
-
-uint64_t bt_field_type_unsigned_enumeration_mapping_ranges_get_range_count(
- struct bt_field_type_unsigned_enumeration_mapping_ranges *ranges)
-{
- return get_enumeration_field_type_mapping_range_count((void *) ranges);
-}
-
-uint64_t bt_field_type_signed_enumeration_mapping_ranges_get_range_count(
- struct bt_field_type_signed_enumeration_mapping_ranges *ranges)
-{
- return get_enumeration_field_type_mapping_range_count((void *) ranges);
-}
-
-static inline
-void get_enumeration_field_type_mapping_range_at_index(
- struct bt_field_type_enumeration_mapping *mapping,
- uint64_t index, uint64_t *lower, uint64_t *upper)
-{
- struct bt_field_type_enumeration_mapping_range *range;
-
- BT_ASSERT_PRE_NON_NULL(mapping, "Ranges");
- BT_ASSERT_PRE_NON_NULL(lower, "Range's lower (output)");
- BT_ASSERT_PRE_NON_NULL(upper, "Range's upper (output)");
- BT_ASSERT_PRE_VALID_INDEX(index, mapping->ranges->len);
- range = BT_FIELD_TYPE_ENUM_MAPPING_RANGE_AT_INDEX(mapping, index);
- *lower = range->lower.u;
- *upper = range->upper.u;
-}
-
-void bt_field_type_unsigned_enumeration_mapping_ranges_get_range_by_index(
- struct bt_field_type_unsigned_enumeration_mapping_ranges *ranges,
- uint64_t index, uint64_t *lower, uint64_t *upper)
-{
- get_enumeration_field_type_mapping_range_at_index((void *) ranges,
- index, lower, upper);
-}
-
-void bt_field_type_signed_enumeration_mapping_ranges_get_range_by_index(
- struct bt_field_type_unsigned_enumeration_mapping_ranges *ranges,
- uint64_t index, int64_t *lower, int64_t *upper)
-{
- get_enumeration_field_type_mapping_range_at_index((void *) ranges,
- index, (uint64_t *) lower, (uint64_t *) upper);
-}
-
-
-
-int bt_field_type_unsigned_enumeration_get_mapping_labels_by_value(
- struct bt_field_type *ft, uint64_t value,
- bt_field_type_enumeration_mapping_label_array *label_array,
- uint64_t *count)
-{
- struct bt_field_type_enumeration *enum_ft = (void *) ft;
- uint64_t i;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_NON_NULL(label_array, "Label array (output)");
- BT_ASSERT_PRE_NON_NULL(count, "Count (output)");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION,
- "Field type");
- g_ptr_array_set_size(enum_ft->label_buf, 0);
-
- for (i = 0; i < enum_ft->mappings->len; i++) {
- uint64_t j;
- struct bt_field_type_enumeration_mapping *mapping =
- BT_FIELD_TYPE_ENUM_MAPPING_AT_INDEX(enum_ft, i);
-
- for (j = 0; j < mapping->ranges->len; j++) {
- struct bt_field_type_enumeration_mapping_range *range =
- BT_FIELD_TYPE_ENUM_MAPPING_RANGE_AT_INDEX(
- mapping, j);
-
- if (value >= range->lower.u &&
- value <= range->upper.u) {
- g_ptr_array_add(enum_ft->label_buf,
- mapping->label->str);
- break;
- }
- }
- }
-
- *label_array = (void *) enum_ft->label_buf->pdata;
- *count = (uint64_t) enum_ft->label_buf->len;
- return 0;
-}
-
-int bt_field_type_signed_enumeration_get_mapping_labels_by_value(
- struct bt_field_type *ft, int64_t value,
- bt_field_type_enumeration_mapping_label_array *label_array,
- uint64_t *count)
-{
- struct bt_field_type_enumeration *enum_ft = (void *) ft;
- uint64_t i;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_NON_NULL(label_array, "Label array (output)");
- BT_ASSERT_PRE_NON_NULL(count, "Count (output)");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_SIGNED_ENUMERATION,
- "Field type");
- g_ptr_array_set_size(enum_ft->label_buf, 0);
-
- for (i = 0; i < enum_ft->mappings->len; i++) {
- uint64_t j;
- struct bt_field_type_enumeration_mapping *mapping =
- BT_FIELD_TYPE_ENUM_MAPPING_AT_INDEX(enum_ft, i);
-
- for (j = 0; j < mapping->ranges->len; j++) {
- struct bt_field_type_enumeration_mapping_range *range =
- BT_FIELD_TYPE_ENUM_MAPPING_RANGE_AT_INDEX(
- mapping, j);
-
- if (value >= range->lower.i &&
- value <= range->upper.i) {
- g_ptr_array_add(enum_ft->label_buf,
- mapping->label->str);
- break;
- }
- }
- }
-
- *label_array = (void *) enum_ft->label_buf->pdata;
- *count = (uint64_t) enum_ft->label_buf->len;
- return 0;
-}
-
-static inline
-int add_mapping_to_enumeration_field_type(struct bt_field_type *ft,
- const char *label, uint64_t lower, uint64_t upper)
-{
- int ret = 0;
- uint64_t i;
- struct bt_field_type_enumeration *enum_ft = (void *) ft;
- struct bt_field_type_enumeration_mapping *mapping = NULL;
- struct bt_field_type_enumeration_mapping_range *range;
-
- BT_ASSERT(ft);
- BT_ASSERT_PRE_NON_NULL(label, "Label");
-
- /* Find existing mapping identified by this label */
- for (i = 0; i < enum_ft->mappings->len; i++) {
- struct bt_field_type_enumeration_mapping *mapping_candidate =
- BT_FIELD_TYPE_ENUM_MAPPING_AT_INDEX(enum_ft, i);
-
- if (strcmp(mapping_candidate->label->str, label) == 0) {
- mapping = mapping_candidate;
- break;
- }
- }
-
- if (!mapping) {
- /* Create new mapping for this label */
- g_array_set_size(enum_ft->mappings, enum_ft->mappings->len + 1);
- mapping = BT_FIELD_TYPE_ENUM_MAPPING_AT_INDEX(enum_ft,
- enum_ft->mappings->len - 1);
- mapping->ranges = g_array_new(FALSE, TRUE,
- sizeof(struct bt_field_type_enumeration_mapping_range));
- if (!mapping->ranges) {
- finalize_enumeration_field_type_mapping(mapping);
- g_array_set_size(enum_ft->mappings,
- enum_ft->mappings->len - 1);
- ret = -1;
- goto end;
- }
-
- mapping->label = g_string_new(label);
- if (!mapping->label) {
- finalize_enumeration_field_type_mapping(mapping);
- g_array_set_size(enum_ft->mappings,
- enum_ft->mappings->len - 1);
- ret = -1;
- goto end;
- }
- }
-
- /* Add range */
- BT_ASSERT(mapping);
- g_array_set_size(mapping->ranges, mapping->ranges->len + 1);
- range = BT_FIELD_TYPE_ENUM_MAPPING_RANGE_AT_INDEX(mapping,
- mapping->ranges->len - 1);
- range->lower.u = lower;
- range->upper.u = upper;
- BT_LIB_LOGV("Added mapping to enumeration field type: "
- "%![ft-]+F, label=\"%s\", lower-unsigned=%" PRIu64 ", "
- "upper-unsigned=%" PRIu64, ft, label, lower, upper);
-
-end:
- return ret;
-}
-
-int bt_field_type_unsigned_enumeration_map_range(
- struct bt_field_type *ft, const char *label,
- uint64_t range_lower, uint64_t range_upper)
-{
- struct bt_field_type_enumeration *enum_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION,
- "Field type");
- BT_ASSERT_PRE(range_lower <= range_upper,
- "Range's upper bound is less than lower bound: "
- "upper=%" PRIu64 ", lower=%" PRIu64,
- range_lower, range_upper);
- BT_ASSERT_PRE(bt_util_value_is_in_range_unsigned(enum_ft->common.range,
- range_lower),
- "Range's lower bound is outside the enumeration field type's value range: "
- "%![ft-]+F, lower=%" PRIu64, ft, range_lower);
- BT_ASSERT_PRE(bt_util_value_is_in_range_unsigned(enum_ft->common.range,
- range_upper),
- "Range's upper bound is outside the enumeration field type's value range: "
- "%![ft-]+F, upper=%" PRIu64, ft, range_upper);
- return add_mapping_to_enumeration_field_type(ft, label, range_lower,
- range_upper);
-}
-
-int bt_field_type_signed_enumeration_map_range(
- struct bt_field_type *ft, const char *label,
- int64_t range_lower, int64_t range_upper)
-{
- struct bt_field_type_enumeration *enum_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_SIGNED_ENUMERATION,
- "Field type");
- BT_ASSERT_PRE(range_lower <= range_upper,
- "Range's upper bound is less than lower bound: "
- "upper=%" PRId64 ", lower=%" PRId64,
- range_lower, range_upper);
- BT_ASSERT_PRE(bt_util_value_is_in_range_signed(enum_ft->common.range,
- range_lower),
- "Range's lower bound is outside the enumeration field type's value range: "
- "%![ft-]+F, lower=%" PRId64, ft, range_lower);
- BT_ASSERT_PRE(bt_util_value_is_in_range_signed(enum_ft->common.range,
- range_upper),
- "Range's upper bound is outside the enumeration field type's value range: "
- "%![ft-]+F, upper=%" PRId64, ft, range_upper);
- return add_mapping_to_enumeration_field_type(ft, label, range_lower,
- range_upper);
-}
-
-static
-void destroy_real_field_type(struct bt_object *obj)
-{
- BT_ASSERT(obj);
- BT_LIB_LOGD("Destroying real field type object: %!+F", obj);
- g_free(obj);
-}
-
-struct bt_field_type *bt_field_type_real_create(void)
-{
- struct bt_field_type_real *real_ft = NULL;
-
- BT_LOGD_STR("Creating default real field type object.");
- real_ft = g_new0(struct bt_field_type_real, 1);
- if (!real_ft) {
- BT_LOGE_STR("Failed to allocate one real field type.");
- goto error;
- }
-
- init_field_type((void *) real_ft, BT_FIELD_TYPE_ID_REAL,
- destroy_real_field_type);
- BT_LIB_LOGD("Created real field type object: %!+F", real_ft);
- goto end;
-
-error:
- BT_PUT(real_ft);
-
-end:
- return (void *) real_ft;
-}
-
-bt_bool bt_field_type_real_is_single_precision(struct bt_field_type *ft)
-{
- struct bt_field_type_real *real_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_REAL, "Field type");
- return real_ft->is_single_precision;
-}
-
-int bt_field_type_real_set_is_single_precision(struct bt_field_type *ft,
- bt_bool is_single_precision)
-{
- struct bt_field_type_real *real_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_REAL, "Field type");
- BT_ASSERT_PRE_FT_HOT(ft, "Field type");
- real_ft->is_single_precision = (bool) is_single_precision;
- BT_LIB_LOGV("Set real field type's \"is single precision\" property: "
- "%!+F", ft);
- return 0;
-}
-
-static
-int init_named_field_types_container(
- struct bt_field_type_named_field_types_container *ft,
- enum bt_field_type_id id, bt_object_release_func release_func)
-{
- int ret = 0;
-
- init_field_type((void *) ft, id, release_func);
- ft->named_fts = g_array_new(FALSE, TRUE,
- sizeof(struct bt_named_field_type));
- if (!ft->named_fts) {
- BT_LOGE_STR("Failed to allocate a GArray.");
- ret = -1;
- goto end;
- }
-
- ft->name_to_index = g_hash_table_new(g_str_hash, g_str_equal);
- if (!ft->name_to_index) {
- BT_LOGE_STR("Failed to allocate a GHashTable.");
- ret = -1;
- goto end;
- }
-
-end:
- return ret;
-}
-
-static
-void finalize_named_field_type(struct bt_named_field_type *named_ft)
-{
- BT_ASSERT(named_ft);
- BT_LIB_LOGD("Finalizing named field type: "
- "addr=%p, name=\"%s\", %![ft-]+F",
- named_ft, named_ft->name ? named_ft->name->str : NULL,
- named_ft->ft);
-
- if (named_ft->name) {
- g_string_free(named_ft->name, TRUE);
- }
-
- BT_LOGD_STR("Putting named field type's field type.");
- bt_put(named_ft->ft);
-}
-
-static
-void finalize_named_field_types_container(
- struct bt_field_type_named_field_types_container *ft)
-{
- uint64_t i;
-
- BT_ASSERT(ft);
-
- if (ft->named_fts) {
- for (i = 0; i < ft->named_fts->len; i++) {
- finalize_named_field_type(
- &g_array_index(ft->named_fts,
- struct bt_named_field_type, i));
- }
-
- g_array_free(ft->named_fts, TRUE);
- }
-
- if (ft->name_to_index) {
- g_hash_table_destroy(ft->name_to_index);
- }
-}
-
-static
-void destroy_structure_field_type(struct bt_object *obj)
-{
- BT_ASSERT(obj);
- BT_LIB_LOGD("Destroying string field type object: %!+F", obj);
- finalize_named_field_types_container((void *) obj);
- g_free(obj);
-}
-
-struct bt_field_type *bt_field_type_structure_create(void)
-{
- int ret;
- struct bt_field_type_structure *struct_ft = NULL;
-
- BT_LOGD_STR("Creating default structure field type object.");
- struct_ft = g_new0(struct bt_field_type_structure, 1);
- if (!struct_ft) {
- BT_LOGE_STR("Failed to allocate one structure field type.");
- goto error;
- }
-
- ret = init_named_field_types_container((void *) struct_ft,
- BT_FIELD_TYPE_ID_STRUCTURE, destroy_structure_field_type);
- if (ret) {
- goto error;
- }
-
- BT_LIB_LOGD("Created structure field type object: %!+F", struct_ft);
- goto end;
-
-error:
- BT_PUT(struct_ft);
-
-end:
- return (void *) struct_ft;
-}
-
-static
-int append_named_field_type_to_container_field_type(
- struct bt_field_type_named_field_types_container *container_ft,
- const char *name, struct bt_field_type *ft)
-{
- int ret = 0;
- struct bt_named_field_type *named_ft;
- GString *name_str;
-
- BT_ASSERT(container_ft);
- BT_ASSERT_PRE_FT_HOT(container_ft, "Field type");
- BT_ASSERT_PRE_NON_NULL(name, "Name");
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE(!bt_g_hash_table_contains(container_ft->name_to_index,
- name),
- "Duplicate member/option name in structure/variant field type: "
- "%![container-ft-]+F, name=\"%s\"", container_ft, name);
- name_str = g_string_new(name);
- if (!name_str) {
- BT_LOGE_STR("Failed to allocate a GString.");
- ret = -1;
- goto end;
- }
-
- g_array_set_size(container_ft->named_fts,
- container_ft->named_fts->len + 1);
- named_ft = &g_array_index(container_ft->named_fts,
- struct bt_named_field_type, container_ft->named_fts->len - 1);
- named_ft->name = name_str;
- named_ft->ft = bt_get(ft);
- g_hash_table_insert(container_ft->name_to_index, named_ft->name->str,
- GUINT_TO_POINTER(container_ft->named_fts->len - 1));
- bt_field_type_freeze(ft);
-
-end:
- return ret;
-}
-
-int bt_field_type_structure_append_member(struct bt_field_type *ft,
- const char *name, struct bt_field_type *member_ft)
-{
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCTURE, "Field type");
- return append_named_field_type_to_container_field_type((void *) ft,
- name, member_ft);
-}
-
-uint64_t bt_field_type_structure_get_member_count(struct bt_field_type *ft)
-{
- struct bt_field_type_structure *struct_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCTURE, "Field type");
- return (uint64_t) struct_ft->common.named_fts->len;
-}
-
-static
-void borrow_named_field_type_from_container_field_type_at_index(
- struct bt_field_type_named_field_types_container *ft,
- uint64_t index, const char **name,
- struct bt_field_type **out_ft)
-{
- struct bt_named_field_type *named_ft;
-
- BT_ASSERT(ft);
- BT_ASSERT_PRE_NON_NULL(name, "Name");
- BT_ASSERT_PRE_NON_NULL(out_ft, "Field type (output)");
- BT_ASSERT_PRE_VALID_INDEX(index, ft->named_fts->len);
- named_ft = BT_FIELD_TYPE_NAMED_FT_AT_INDEX(ft, index);
- *name = named_ft->name->str;
- *out_ft = named_ft->ft;
-}
-
-void bt_field_type_structure_borrow_member_by_index(
- struct bt_field_type *ft, uint64_t index,
- const char **name, struct bt_field_type **out_ft)
-{
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCTURE, "Field type");
- borrow_named_field_type_from_container_field_type_at_index((void *) ft,
- index, name, out_ft);
-}
-
-static
-struct bt_field_type *borrow_field_type_from_container_field_type_by_name(
- struct bt_field_type_named_field_types_container *ft,
- const char *name)
-{
- struct bt_field_type *ret_ft = NULL;
- struct bt_named_field_type *named_ft;
- gpointer orig_key;
- gpointer value;
-
- BT_ASSERT(ft);
- BT_ASSERT_PRE_NON_NULL(name, "Name");
- if (!g_hash_table_lookup_extended(ft->name_to_index, name, &orig_key,
- &value)) {
- goto end;
- }
-
- named_ft = BT_FIELD_TYPE_NAMED_FT_AT_INDEX(ft,
- GPOINTER_TO_UINT(value));
- ret_ft = named_ft->ft;
-
-end:
- return ret_ft;
-}
-
-struct bt_field_type *bt_field_type_structure_borrow_member_field_type_by_name(
- struct bt_field_type *ft, const char *name)
-{
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCTURE, "Field type");
- return borrow_field_type_from_container_field_type_by_name((void *) ft,
- name);
-}
-
-static
-void destroy_variant_field_type(struct bt_object *obj)
-{
- struct bt_field_type_variant *ft = (void *) obj;
-
- BT_ASSERT(ft);
- BT_LIB_LOGD("Destroying variant field type object: %!+F", ft);
- finalize_named_field_types_container((void *) ft);
- BT_LOGD_STR("Putting selector field path.");
- bt_put(ft->selector_field_path);
- g_free(ft);
-}
-
-struct bt_field_type *bt_field_type_variant_create(void)
-{
- int ret;
- struct bt_field_type_variant *var_ft = NULL;
-
- BT_LOGD_STR("Creating default variant field type object.");
- var_ft = g_new0(struct bt_field_type_variant, 1);
- if (!var_ft) {
- BT_LOGE_STR("Failed to allocate one variant field type.");
- goto error;
- }
-
- ret = init_named_field_types_container((void *) var_ft,
- BT_FIELD_TYPE_ID_VARIANT, destroy_variant_field_type);
- if (ret) {
- goto error;
- }
-
- BT_LIB_LOGD("Created variant field type object: %!+F", var_ft);
- goto end;
-
-error:
- BT_PUT(var_ft);
-
-end:
- return (void *) var_ft;
-}
-
-int bt_field_type_variant_set_selector_field_type(
- struct bt_field_type *ft, struct bt_field_type *selector_ft)
-{
- struct bt_field_type_variant *var_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Variant field type");
- BT_ASSERT_PRE_NON_NULL(selector_ft, "Selector field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT, "Field type");
- BT_ASSERT_PRE_FT_IS_ENUM(selector_ft, "Selector field type");
- BT_ASSERT_PRE_FT_HOT(ft, "Variant field type");
- var_ft->selector_ft = selector_ft;
- bt_field_type_freeze(selector_ft);
- return 0;
-}
-
-int bt_field_type_variant_append_option(struct bt_field_type *ft,
- const char *name, struct bt_field_type *option_ft)
-{
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT, "Field type");
- return append_named_field_type_to_container_field_type((void *) ft,
- name, option_ft);
-}
-
-struct bt_field_type *bt_field_type_variant_borrow_option_field_type_by_name(
- struct bt_field_type *ft, const char *name)
-{
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT, "Field type");
- return borrow_field_type_from_container_field_type_by_name((void *) ft,
- name);
-}
-
-uint64_t bt_field_type_variant_get_option_count(struct bt_field_type *ft)
-{
- struct bt_field_type_variant *var_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT, "Field type");
- return (uint64_t) var_ft->common.named_fts->len;
-}
-
-void bt_field_type_variant_borrow_option_by_index(
- struct bt_field_type *ft, uint64_t index,
- const char **name, struct bt_field_type **out_ft)
-{
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT, "Field type");
- borrow_named_field_type_from_container_field_type_at_index((void *) ft,
- index, name, out_ft);
-}
-
-struct bt_field_path *bt_field_type_variant_borrow_selector_field_path(
- struct bt_field_type *ft)
-{
- struct bt_field_type_variant *var_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
- "Field type");
- return var_ft->selector_field_path;
-}
-
-static
-void init_array_field_type(struct bt_field_type_array *ft,
- enum bt_field_type_id id, bt_object_release_func release_func,
- struct bt_field_type *element_ft)
-{
- BT_ASSERT(element_ft);
- init_field_type((void *) ft, id, release_func);
- ft->element_ft = bt_get(element_ft);
- bt_field_type_freeze(element_ft);
-}
-
-static
-void finalize_array_field_type(struct bt_field_type_array *array_ft)
-{
- BT_ASSERT(array_ft);
- BT_LOGD_STR("Putting element field type.");
- bt_put(array_ft->element_ft);
-}
-
-static
-void destroy_static_array_field_type(struct bt_object *obj)
-{
- BT_ASSERT(obj);
- BT_LIB_LOGD("Destroying static array field type object: %!+F", obj);
- finalize_array_field_type((void *) obj);
- g_free(obj);
-}
-
-struct bt_field_type *bt_field_type_static_array_create(
- struct bt_field_type *element_ft, uint64_t length)
-{
- struct bt_field_type_static_array *array_ft = NULL;
-
- BT_ASSERT_PRE_NON_NULL(element_ft, "Element field type");
- BT_LOGD_STR("Creating default static array field type object.");
- array_ft = g_new0(struct bt_field_type_static_array, 1);
- if (!array_ft) {
- BT_LOGE_STR("Failed to allocate one static array field type.");
- goto error;
- }
-
- init_array_field_type((void *) array_ft, BT_FIELD_TYPE_ID_STATIC_ARRAY,
- destroy_static_array_field_type, element_ft);
- array_ft->length = length;
- BT_LIB_LOGD("Created static array field type object: %!+F", array_ft);
- goto end;
-
-error:
- BT_PUT(array_ft);
-
-end:
- return (void *) array_ft;
-}
-
-struct bt_field_type *bt_field_type_array_borrow_element_field_type(
- struct bt_field_type *ft)
-{
- struct bt_field_type_array *array_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_IS_ARRAY(ft, "Field type");
- return array_ft->element_ft;
-}
-
-uint64_t bt_field_type_static_array_get_length(struct bt_field_type *ft)
-{
- struct bt_field_type_static_array *array_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_STATIC_ARRAY,
- "Field type");
- return (uint64_t) array_ft->length;
-}
-
-static
-void destroy_dynamic_array_field_type(struct bt_object *obj)
-{
- struct bt_field_type_dynamic_array *ft = (void *) obj;
-
- BT_ASSERT(ft);
- BT_LIB_LOGD("Destroying dynamic array field type object: %!+F", ft);
- finalize_array_field_type((void *) ft);
- BT_LOGD_STR("Putting length field path.");
- bt_put(ft->length_field_path);
- g_free(ft);
-}
-
-struct bt_field_type *bt_field_type_dynamic_array_create(
- struct bt_field_type *element_ft)
-{
- struct bt_field_type_dynamic_array *array_ft = NULL;
-
- BT_ASSERT_PRE_NON_NULL(element_ft, "Element field type");
- BT_LOGD_STR("Creating default dynamic array field type object.");
- array_ft = g_new0(struct bt_field_type_dynamic_array, 1);
- if (!array_ft) {
- BT_LOGE_STR("Failed to allocate one dynamic array field type.");
- goto error;
- }
-
- init_array_field_type((void *) array_ft, BT_FIELD_TYPE_ID_DYNAMIC_ARRAY,
- destroy_dynamic_array_field_type, element_ft);
- BT_LIB_LOGD("Created dynamic array field type object: %!+F", array_ft);
- goto end;
-
-error:
- BT_PUT(array_ft);
-
-end:
- return (void *) array_ft;
-}
-
-int bt_field_type_dynamic_array_set_length_field_type(struct bt_field_type *ft,
- struct bt_field_type *length_ft)
-{
- struct bt_field_type_dynamic_array *array_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Dynamic array field type");
- BT_ASSERT_PRE_NON_NULL(length_ft, "Length field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_DYNAMIC_ARRAY,
- "Field type");
- BT_ASSERT_PRE_FT_IS_UNSIGNED_INT(length_ft, "Length field type");
- BT_ASSERT_PRE_FT_HOT(ft, "Dynamic array field type");
- array_ft->length_ft = length_ft;
- bt_field_type_freeze(length_ft);
- return 0;
-}
-
-struct bt_field_path *bt_field_type_dynamic_array_borrow_length_field_path(
- struct bt_field_type *ft)
-{
- struct bt_field_type_dynamic_array *seq_ft = (void *) ft;
-
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_DYNAMIC_ARRAY,
- "Field type");
- return seq_ft->length_field_path;
-}
-
-static
-void destroy_string_field_type(struct bt_object *obj)
-{
- BT_ASSERT(obj);
- BT_LIB_LOGD("Destroying string field type object: %!+F", obj);
- g_free(obj);
-}
-
-struct bt_field_type *bt_field_type_string_create(void)
-{
- struct bt_field_type_string *string_ft = NULL;
-
- BT_LOGD_STR("Creating default string field type object.");
- string_ft = g_new0(struct bt_field_type_string, 1);
- if (!string_ft) {
- BT_LOGE_STR("Failed to allocate one string field type.");
- goto error;
- }
-
- init_field_type((void *) string_ft, BT_FIELD_TYPE_ID_STRING,
- destroy_string_field_type);
- BT_LIB_LOGD("Created string field type object: %!+F", string_ft);
- goto end;
-
-error:
- BT_PUT(string_ft);
-
-end:
- return (void *) string_ft;
-}
-
-BT_HIDDEN
-void _bt_field_type_freeze(struct bt_field_type *ft)
-{
- /*
- * Element/member/option field types are frozen when added to
- * their owner.
- */
- BT_ASSERT(ft);
- ft->frozen = true;
-}
-
-BT_HIDDEN
-void _bt_field_type_make_part_of_trace(struct bt_field_type *ft)
-{
- BT_ASSERT(ft);
- BT_ASSERT_PRE(!ft->part_of_trace,
- "Field type is already part of a trace: %!+F", ft);
- ft->part_of_trace = true;
-
- switch (ft->id) {
- case BT_FIELD_TYPE_ID_STRUCTURE:
- case BT_FIELD_TYPE_ID_VARIANT:
- {
- struct bt_field_type_named_field_types_container *container_ft =
- (void *) ft;
- uint64_t i;
-
- for (i = 0; i < container_ft->named_fts->len; i++) {
- struct bt_named_field_type *named_ft =
- BT_FIELD_TYPE_NAMED_FT_AT_INDEX(
- container_ft, i);
-
- bt_field_type_make_part_of_trace(named_ft->ft);
- }
-
- break;
- }
- case BT_FIELD_TYPE_ID_STATIC_ARRAY:
- case BT_FIELD_TYPE_ID_DYNAMIC_ARRAY:
- {
- struct bt_field_type_array *array_ft = (void *) ft;
-
- bt_field_type_make_part_of_trace(array_ft->element_ft);
- break;
- }
- default:
- break;
- }
-}
BT_HIDDEN
struct bt_field_wrapper *bt_field_wrapper_create(
- struct bt_object_pool *pool, struct bt_field_type *ft)
+ struct bt_object_pool *pool, struct bt_field_class *fc)
{
struct bt_field_wrapper *field_wrapper = NULL;
BT_ASSERT(pool);
- BT_ASSERT(ft);
+ BT_ASSERT(fc);
field_wrapper = bt_object_pool_create_object(pool);
if (!field_wrapper) {
BT_LIB_LOGE("Cannot allocate one field wrapper from field wrapper pool: "
}
if (!field_wrapper->field) {
- field_wrapper->field = (void *) bt_field_create(ft);
+ field_wrapper->field = (void *) bt_field_create(fc);
if (!field_wrapper->field) {
- BT_LIB_LOGE("Cannot create field wrapper from field type: "
- "%![ft-]+F", ft);
+ BT_LIB_LOGE("Cannot create field wrapper from field classe: "
+ "%![fc-]+F", fc);
goto error;
}
#include <babeltrace/assert-pre-internal.h>
#include <babeltrace/trace-ir/fields.h>
#include <babeltrace/trace-ir/fields-internal.h>
-#include <babeltrace/trace-ir/field-types-internal.h>
+#include <babeltrace/trace-ir/field-classes-internal.h>
#include <babeltrace/object-internal.h>
#include <babeltrace/ref.h>
#include <babeltrace/compiler-internal.h>
};
static
-struct bt_field *create_integer_field(struct bt_field_type *);
+struct bt_field *create_integer_field(struct bt_field_class *);
static
-struct bt_field *create_real_field(struct bt_field_type *);
+struct bt_field *create_real_field(struct bt_field_class *);
static
-struct bt_field *create_string_field(struct bt_field_type *);
+struct bt_field *create_string_field(struct bt_field_class *);
static
-struct bt_field *create_structure_field(struct bt_field_type *);
+struct bt_field *create_structure_field(struct bt_field_class *);
static
-struct bt_field *create_static_array_field(struct bt_field_type *);
+struct bt_field *create_static_array_field(struct bt_field_class *);
static
-struct bt_field *create_dynamic_array_field(struct bt_field_type *);
+struct bt_field *create_dynamic_array_field(struct bt_field_class *);
static
-struct bt_field *create_variant_field(struct bt_field_type *);
+struct bt_field *create_variant_field(struct bt_field_class *);
static
-struct bt_field *(* const field_create_funcs[])(struct bt_field_type *) = {
- [BT_FIELD_TYPE_ID_UNSIGNED_INTEGER] = create_integer_field,
- [BT_FIELD_TYPE_ID_SIGNED_INTEGER] = create_integer_field,
- [BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION] = create_integer_field,
- [BT_FIELD_TYPE_ID_SIGNED_ENUMERATION] = create_integer_field,
- [BT_FIELD_TYPE_ID_REAL] = create_real_field,
- [BT_FIELD_TYPE_ID_STRING] = create_string_field,
- [BT_FIELD_TYPE_ID_STRUCTURE] = create_structure_field,
- [BT_FIELD_TYPE_ID_STATIC_ARRAY] = create_static_array_field,
- [BT_FIELD_TYPE_ID_DYNAMIC_ARRAY] = create_dynamic_array_field,
- [BT_FIELD_TYPE_ID_VARIANT] = create_variant_field,
+struct bt_field *(* const field_create_funcs[])(struct bt_field_class *) = {
+ [BT_FIELD_CLASS_ID_UNSIGNED_INTEGER] = create_integer_field,
+ [BT_FIELD_CLASS_ID_SIGNED_INTEGER] = create_integer_field,
+ [BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION] = create_integer_field,
+ [BT_FIELD_CLASS_ID_SIGNED_ENUMERATION] = create_integer_field,
+ [BT_FIELD_CLASS_ID_REAL] = create_real_field,
+ [BT_FIELD_CLASS_ID_STRING] = create_string_field,
+ [BT_FIELD_CLASS_ID_STRUCTURE] = create_structure_field,
+ [BT_FIELD_CLASS_ID_STATIC_ARRAY] = create_static_array_field,
+ [BT_FIELD_CLASS_ID_DYNAMIC_ARRAY] = create_dynamic_array_field,
+ [BT_FIELD_CLASS_ID_VARIANT] = create_variant_field,
};
static
static
void (* const field_destroy_funcs[])(struct bt_field *) = {
- [BT_FIELD_TYPE_ID_UNSIGNED_INTEGER] = destroy_integer_field,
- [BT_FIELD_TYPE_ID_SIGNED_INTEGER] = destroy_integer_field,
- [BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION] = destroy_integer_field,
- [BT_FIELD_TYPE_ID_SIGNED_ENUMERATION] = destroy_integer_field,
- [BT_FIELD_TYPE_ID_REAL] = destroy_real_field,
- [BT_FIELD_TYPE_ID_STRING] = destroy_string_field,
- [BT_FIELD_TYPE_ID_STRUCTURE] = destroy_structure_field,
- [BT_FIELD_TYPE_ID_STATIC_ARRAY] = destroy_array_field,
- [BT_FIELD_TYPE_ID_DYNAMIC_ARRAY] = destroy_array_field,
- [BT_FIELD_TYPE_ID_VARIANT] = destroy_variant_field,
+ [BT_FIELD_CLASS_ID_UNSIGNED_INTEGER] = destroy_integer_field,
+ [BT_FIELD_CLASS_ID_SIGNED_INTEGER] = destroy_integer_field,
+ [BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION] = destroy_integer_field,
+ [BT_FIELD_CLASS_ID_SIGNED_ENUMERATION] = destroy_integer_field,
+ [BT_FIELD_CLASS_ID_REAL] = destroy_real_field,
+ [BT_FIELD_CLASS_ID_STRING] = destroy_string_field,
+ [BT_FIELD_CLASS_ID_STRUCTURE] = destroy_structure_field,
+ [BT_FIELD_CLASS_ID_STATIC_ARRAY] = destroy_array_field,
+ [BT_FIELD_CLASS_ID_DYNAMIC_ARRAY] = destroy_array_field,
+ [BT_FIELD_CLASS_ID_VARIANT] = destroy_variant_field,
};
-struct bt_field_type *bt_field_borrow_type(struct bt_field *field)
+struct bt_field_class *bt_field_borrow_class(struct bt_field *field)
{
BT_ASSERT_PRE_NON_NULL(field, "Field");
- return field->type;
+ return field->class;
}
-enum bt_field_type_id bt_field_get_type_id(struct bt_field *field)
+enum bt_field_class_id bt_field_get_class_id(struct bt_field *field)
{
BT_ASSERT_PRE_NON_NULL(field, "Field");
- return field->type->id;
+ return field->class->id;
}
BT_HIDDEN
-struct bt_field *bt_field_create(struct bt_field_type *ft)
+struct bt_field *bt_field_create(struct bt_field_class *fc)
{
struct bt_field *field = NULL;
- BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT(bt_field_type_has_known_id(ft));
- field = field_create_funcs[ft->id](ft);
+ BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+ BT_ASSERT(bt_field_class_has_known_id(fc));
+ field = field_create_funcs[fc->id](fc);
if (!field) {
- BT_LIB_LOGE("Cannot create field object from field type: "
- "%![ft-]+F", ft);
+ BT_LIB_LOGE("Cannot create field object from field classe: "
+ "%![fc-]+F", fc);
goto end;
}
}
static inline
-void init_field(struct bt_field *field, struct bt_field_type *ft,
+void init_field(struct bt_field *field, struct bt_field_class *fc,
struct bt_field_methods *methods)
{
BT_ASSERT(field);
- BT_ASSERT(ft);
+ BT_ASSERT(fc);
bt_object_init_unique(&field->base);
field->methods = methods;
- field->type = bt_get(ft);
+ field->class = bt_get(fc);
}
static
-struct bt_field *create_integer_field(struct bt_field_type *ft)
+struct bt_field *create_integer_field(struct bt_field_class *fc)
{
struct bt_field_integer *int_field;
- BT_LIB_LOGD("Creating integer field object: %![ft-]+F", ft);
+ BT_LIB_LOGD("Creating integer field object: %![fc-]+F", fc);
int_field = g_new0(struct bt_field_integer, 1);
if (!int_field) {
BT_LOGE_STR("Failed to allocate one integer field.");
goto end;
}
- init_field((void *) int_field, ft, &integer_field_methods);
+ init_field((void *) int_field, fc, &integer_field_methods);
BT_LIB_LOGD("Created integer field object: %!+f", int_field);
end:
}
static
-struct bt_field *create_real_field(struct bt_field_type *ft)
+struct bt_field *create_real_field(struct bt_field_class *fc)
{
struct bt_field_real *real_field;
- BT_LIB_LOGD("Creating real field object: %![ft-]+F", ft);
+ BT_LIB_LOGD("Creating real field object: %![fc-]+F", fc);
real_field = g_new0(struct bt_field_real, 1);
if (!real_field) {
BT_LOGE_STR("Failed to allocate one real field.");
goto end;
}
- init_field((void *) real_field, ft, &real_field_methods);
+ init_field((void *) real_field, fc, &real_field_methods);
BT_LIB_LOGD("Created real field object: %!+f", real_field);
end:
}
static
-struct bt_field *create_string_field(struct bt_field_type *ft)
+struct bt_field *create_string_field(struct bt_field_class *fc)
{
struct bt_field_string *string_field;
- BT_LIB_LOGD("Creating string field object: %![ft-]+F", ft);
+ BT_LIB_LOGD("Creating string field object: %![fc-]+F", fc);
string_field = g_new0(struct bt_field_string, 1);
if (!string_field) {
BT_LOGE_STR("Failed to allocate one string field.");
goto end;
}
- init_field((void *) string_field, ft, &string_field_methods);
+ init_field((void *) string_field, fc, &string_field_methods);
string_field->buf = g_array_sized_new(FALSE, FALSE,
sizeof(char), 1);
if (!string_field->buf) {
}
static inline
-int create_fields_from_named_field_types(
- struct bt_field_type_named_field_types_container *ft,
+int create_fields_from_named_field_classes(
+ struct bt_field_class_named_field_class_container *fc,
GPtrArray **fields)
{
int ret = 0;
goto end;
}
- g_ptr_array_set_size(*fields, ft->named_fts->len);
+ g_ptr_array_set_size(*fields, fc->named_fcs->len);
- for (i = 0; i < ft->named_fts->len; i++) {
+ for (i = 0; i < fc->named_fcs->len; i++) {
struct bt_field *field;
- struct bt_named_field_type *named_ft =
- BT_FIELD_TYPE_NAMED_FT_AT_INDEX(ft, i);
+ struct bt_named_field_class *named_fc =
+ BT_FIELD_CLASS_NAMED_FC_AT_INDEX(fc, i);
- field = bt_field_create(named_ft->ft);
+ field = bt_field_create(named_fc->fc);
if (!field) {
BT_LIB_LOGE("Failed to create structure member or variant option field: "
- "name=\"%s\", %![ft-]+F",
- named_ft->name->str, named_ft->ft);
+ "name=\"%s\", %![fc-]+F",
+ named_fc->name->str, named_fc->fc);
ret = -1;
goto end;
}
}
static
-struct bt_field *create_structure_field(struct bt_field_type *ft)
+struct bt_field *create_structure_field(struct bt_field_class *fc)
{
struct bt_field_structure *struct_field;
- BT_LIB_LOGD("Creating structure field object: %![ft-]+F", ft);
+ BT_LIB_LOGD("Creating structure field object: %![fc-]+F", fc);
struct_field = g_new0(struct bt_field_structure, 1);
if (!struct_field) {
BT_LOGE_STR("Failed to allocate one structure field.");
goto end;
}
- init_field((void *) struct_field, ft, &structure_field_methods);
+ init_field((void *) struct_field, fc, &structure_field_methods);
- if (create_fields_from_named_field_types((void *) ft,
+ if (create_fields_from_named_field_classes((void *) fc,
&struct_field->fields)) {
BT_LIB_LOGE("Cannot create structure member fields: "
- "%![ft-]+F", ft);
+ "%![fc-]+F", fc);
BT_PUT(struct_field);
goto end;
}
}
static
-struct bt_field *create_variant_field(struct bt_field_type *ft)
+struct bt_field *create_variant_field(struct bt_field_class *fc)
{
struct bt_field_variant *var_field;
- BT_LIB_LOGD("Creating variant field object: %![ft-]+F", ft);
+ BT_LIB_LOGD("Creating variant field object: %![fc-]+F", fc);
var_field = g_new0(struct bt_field_variant, 1);
if (!var_field) {
BT_LOGE_STR("Failed to allocate one variant field.");
goto end;
}
- init_field((void *) var_field, ft, &variant_field_methods);
+ init_field((void *) var_field, fc, &variant_field_methods);
- if (create_fields_from_named_field_types((void *) ft,
+ if (create_fields_from_named_field_classes((void *) fc,
&var_field->fields)) {
BT_LIB_LOGE("Cannot create variant member fields: "
- "%![ft-]+F", ft);
+ "%![fc-]+F", fc);
BT_PUT(var_field);
goto end;
}
{
int ret = 0;
uint64_t i;
- struct bt_field_type_array *array_ft;
+ struct bt_field_class_array *array_fc;
BT_ASSERT(array_field);
- array_ft = (void *) array_field->common.type;
+ array_fc = (void *) array_field->common.class;
array_field->fields = g_ptr_array_sized_new(array_field->length);
if (!array_field->fields) {
BT_LOGE_STR("Failed to allocate a GPtrArray.");
for (i = 0; i < array_field->length; i++) {
array_field->fields->pdata[i] = bt_field_create(
- array_ft->element_ft);
+ array_fc->element_fc);
if (!array_field->fields->pdata[i]) {
BT_LIB_LOGE("Cannot create array field's element field: "
- "index=%" PRIu64 ", %![ft-]+F", i, array_ft);
+ "index=%" PRIu64 ", %![fc-]+F", i, array_fc);
ret = -1;
goto end;
}
}
static
-struct bt_field *create_static_array_field(struct bt_field_type *ft)
+struct bt_field *create_static_array_field(struct bt_field_class *fc)
{
- struct bt_field_type_static_array *array_ft = (void *) ft;
+ struct bt_field_class_static_array *array_fc = (void *) fc;
struct bt_field_array *array_field;
- BT_LIB_LOGD("Creating static array field object: %![ft-]+F", ft);
+ BT_LIB_LOGD("Creating static array field object: %![fc-]+F", fc);
array_field = g_new0(struct bt_field_array, 1);
if (!array_field) {
BT_LOGE_STR("Failed to allocate one static array field.");
goto end;
}
- init_field((void *) array_field, ft, &array_field_methods);
- array_field->length = array_ft->length;
+ init_field((void *) array_field, fc, &array_field_methods);
+ array_field->length = array_fc->length;
if (init_array_field_fields(array_field)) {
BT_LIB_LOGE("Cannot create static array fields: "
- "%![ft-]+F", ft);
+ "%![fc-]+F", fc);
BT_PUT(array_field);
goto end;
}
}
static
-struct bt_field *create_dynamic_array_field(struct bt_field_type *ft)
+struct bt_field *create_dynamic_array_field(struct bt_field_class *fc)
{
struct bt_field_array *array_field;
- BT_LIB_LOGD("Creating dynamic array field object: %![ft-]+F", ft);
+ BT_LIB_LOGD("Creating dynamic array field object: %![fc-]+F", fc);
array_field = g_new0(struct bt_field_array, 1);
if (!array_field) {
BT_LOGE_STR("Failed to allocate one dynamic array field.");
goto end;
}
- init_field((void *) array_field, ft, &array_field_methods);
+ init_field((void *) array_field, fc, &array_field_methods);
if (init_array_field_fields(array_field)) {
BT_LIB_LOGE("Cannot create dynamic array fields: "
- "%![ft-]+F", ft);
+ "%![fc-]+F", fc);
BT_PUT(array_field);
goto end;
}
BT_ASSERT_PRE_FIELD_IS_SIGNED_INT(field, "Field");
BT_ASSERT_PRE_FIELD_HOT(field, "Field");
BT_ASSERT_PRE(bt_util_value_is_in_range_signed(
- ((struct bt_field_type_integer *) field->type)->range, value),
+ ((struct bt_field_class_integer *) field->class)->range, value),
"Value is out of bounds: value=%" PRId64 ", %![field-]+f, "
- "%![ft-]+F", value, field, field->type);
+ "%![fc-]+F", value, field, field->class);
int_field->value.i = value;
bt_field_set_single(field, true);
}
BT_ASSERT_PRE_FIELD_IS_UNSIGNED_INT(field, "Field");
BT_ASSERT_PRE_FIELD_HOT(field, "Field");
BT_ASSERT_PRE(bt_util_value_is_in_range_unsigned(
- ((struct bt_field_type_integer *) field->type)->range, value),
+ ((struct bt_field_class_integer *) field->class)->range, value),
"Value is out of bounds: value=%" PRIu64 ", %![field-]+f, "
- "%![ft-]+F", value, field, field->type);
+ "%![fc-]+F", value, field, field->class);
int_field->value.u = value;
bt_field_set_single(field, true);
}
BT_ASSERT_PRE_NON_NULL(field, "Field");
BT_ASSERT_PRE_FIELD_IS_SET(field, "Field");
- BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field, BT_FIELD_TYPE_ID_REAL, "Field");
+ BT_ASSERT_PRE_FIELD_HAS_CLASS_ID(field, BT_FIELD_CLASS_ID_REAL, "Field");
return real_field->value;
}
struct bt_field_real *real_field = (void *) field;
BT_ASSERT_PRE_NON_NULL(field, "Field");
- BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field, BT_FIELD_TYPE_ID_REAL, "Field");
+ BT_ASSERT_PRE_FIELD_HAS_CLASS_ID(field, BT_FIELD_CLASS_ID_REAL, "Field");
BT_ASSERT_PRE_FIELD_HOT(field, "Field");
BT_ASSERT_PRE(
- !((struct bt_field_type_real *) field->type)->is_single_precision ||
+ !((struct bt_field_class_real *) field->class)->is_single_precision ||
(double) (float) value == value,
"Invalid value for a single-precision real number: value=%f, "
- "%![ft-]+F", value, field->type);
+ "%![fc-]+F", value, field->class);
real_field->value = value;
bt_field_set_single(field, true);
}
int bt_field_unsigned_enumeration_get_mapping_labels(struct bt_field *field,
- bt_field_type_enumeration_mapping_label_array *label_array,
+ bt_field_class_enumeration_mapping_label_array *label_array,
uint64_t *count)
{
struct bt_field_integer *int_field = (void *) field;
BT_ASSERT_PRE_NON_NULL(label_array, "Label array (output)");
BT_ASSERT_PRE_NON_NULL(label_array, "Count (output)");
BT_ASSERT_PRE_FIELD_IS_SET(field, "Field");
- BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION, "Field");
- return bt_field_type_unsigned_enumeration_get_mapping_labels_by_value(
- field->type, int_field->value.u, label_array, count);
+ BT_ASSERT_PRE_FIELD_HAS_CLASS_ID(field,
+ BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION, "Field");
+ return bt_field_class_unsigned_enumeration_get_mapping_labels_by_value(
+ field->class, int_field->value.u, label_array, count);
}
int bt_field_signed_enumeration_get_mapping_labels(struct bt_field *field,
- bt_field_type_enumeration_mapping_label_array *label_array,
+ bt_field_class_enumeration_mapping_label_array *label_array,
uint64_t *count)
{
struct bt_field_integer *int_field = (void *) field;
BT_ASSERT_PRE_NON_NULL(label_array, "Label array (output)");
BT_ASSERT_PRE_NON_NULL(label_array, "Count (output)");
BT_ASSERT_PRE_FIELD_IS_SET(field, "Field");
- BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_SIGNED_ENUMERATION, "Field");
- return bt_field_type_signed_enumeration_get_mapping_labels_by_value(
- field->type, int_field->value.i, label_array, count);
+ BT_ASSERT_PRE_FIELD_HAS_CLASS_ID(field,
+ BT_FIELD_CLASS_ID_SIGNED_ENUMERATION, "Field");
+ return bt_field_class_signed_enumeration_get_mapping_labels_by_value(
+ field->class, int_field->value.i, label_array, count);
}
const char *bt_field_string_get_value(struct bt_field *field)
BT_ASSERT_PRE_NON_NULL(field, "Field");
BT_ASSERT_PRE_FIELD_IS_SET(field, "Field");
- BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field, BT_FIELD_TYPE_ID_STRING,
+ BT_ASSERT_PRE_FIELD_HAS_CLASS_ID(field, BT_FIELD_CLASS_ID_STRING,
"Field");
return (const char *) string_field->buf->data;
}
BT_ASSERT_PRE_NON_NULL(field, "Field");
BT_ASSERT_PRE_FIELD_IS_SET(field, "Field");
- BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field, BT_FIELD_TYPE_ID_STRING,
+ BT_ASSERT_PRE_FIELD_HAS_CLASS_ID(field, BT_FIELD_CLASS_ID_STRING,
"Field");
return string_field->length;
}
BT_ASSERT_PRE_NON_NULL(field, "Field");
BT_ASSERT_PRE_NON_NULL(value, "Value");
BT_ASSERT_PRE_FIELD_HOT(field, "Field");
- BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field, BT_FIELD_TYPE_ID_STRING,
+ BT_ASSERT_PRE_FIELD_HAS_CLASS_ID(field, BT_FIELD_CLASS_ID_STRING,
"Field");
bt_field_string_clear(field);
return bt_field_string_append_with_length(field, value,
BT_ASSERT_PRE_NON_NULL(field, "Field");
BT_ASSERT_PRE_NON_NULL(value, "Value");
BT_ASSERT_PRE_FIELD_HOT(field, "Field");
- BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_STRING, "Field");
+ BT_ASSERT_PRE_FIELD_HAS_CLASS_ID(field,
+ BT_FIELD_CLASS_ID_STRING, "Field");
/* Make sure no null bytes are appended */
BT_ASSERT_PRE(memchr(value, '\0', length) == NULL,
BT_ASSERT_PRE_NON_NULL(field, "Field");
BT_ASSERT_PRE_FIELD_HOT(field, "Field");
- BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_STRING, "Field");
+ BT_ASSERT_PRE_FIELD_HAS_CLASS_ID(field,
+ BT_FIELD_CLASS_ID_STRING, "Field");
string_field->length = 0;
bt_field_set_single(field, true);
return 0;
struct bt_field_array *array_field = (void *) field;
BT_ASSERT_PRE_NON_NULL(field, "Field");
- BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_DYNAMIC_ARRAY, "Field");
+ BT_ASSERT_PRE_FIELD_HAS_CLASS_ID(field,
+ BT_FIELD_CLASS_ID_DYNAMIC_ARRAY, "Field");
BT_ASSERT_PRE_FIELD_HOT(field, "Field");
if (unlikely(length > array_field->fields->len)) {
/* Make more room */
- struct bt_field_type_array *array_ft;
+ struct bt_field_class_array *array_fc;
uint64_t cur_len = array_field->fields->len;
uint64_t i;
g_ptr_array_set_size(array_field->fields, length);
- array_ft = (void *) field->type;
+ array_fc = (void *) field->class;
for (i = cur_len; i < array_field->fields->len; i++) {
struct bt_field *elem_field = bt_field_create(
- array_ft->element_ft);
+ array_fc->element_fc);
if (!elem_field) {
BT_LIB_LOGE("Cannot create element field for "
struct bt_field_structure *struct_field = (void *) field;
BT_ASSERT_PRE_NON_NULL(field, "Field");
- BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_STRUCTURE, "Field");
+ BT_ASSERT_PRE_FIELD_HAS_CLASS_ID(field,
+ BT_FIELD_CLASS_ID_STRUCTURE, "Field");
BT_ASSERT_PRE_VALID_INDEX(index, struct_field->fields->len);
return struct_field->fields->pdata[index];
}
struct bt_field *field, const char *name)
{
struct bt_field *ret_field = NULL;
- struct bt_field_type_structure *struct_ft;
+ struct bt_field_class_structure *struct_fc;
struct bt_field_structure *struct_field = (void *) field;
gpointer orig_key;
gpointer index;
BT_ASSERT_PRE_NON_NULL(field, "Field");
BT_ASSERT_PRE_NON_NULL(name, "Field name");
- BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_STRUCTURE, "Field");
- struct_ft = (void *) field->type;
+ BT_ASSERT_PRE_FIELD_HAS_CLASS_ID(field,
+ BT_FIELD_CLASS_ID_STRUCTURE, "Field");
+ struct_fc = (void *) field->class;
- if (!g_hash_table_lookup_extended(struct_ft->common.name_to_index, name,
+ if (!g_hash_table_lookup_extended(struct_fc->common.name_to_index, name,
&orig_key, &index)) {
goto end;
}
struct bt_field_variant *var_field = (void *) field;
BT_ASSERT_PRE_NON_NULL(field, "Field");
- BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_VARIANT, "Field");
+ BT_ASSERT_PRE_FIELD_HAS_CLASS_ID(field,
+ BT_FIELD_CLASS_ID_VARIANT, "Field");
BT_ASSERT_PRE(var_field->selected_field,
"Variant field has no selected field: %!+f", field);
return var_field->selected_field;
struct bt_field_variant *var_field = (void *) field;
BT_ASSERT_PRE_NON_NULL(field, "Field");
- BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_VARIANT, "Field");
+ BT_ASSERT_PRE_FIELD_HAS_CLASS_ID(field,
+ BT_FIELD_CLASS_ID_VARIANT, "Field");
BT_ASSERT_PRE_FIELD_HOT(field, "Field");
BT_ASSERT_PRE_VALID_INDEX(index, var_field->fields->len);
var_field->selected_field = var_field->fields->pdata[index];
struct bt_field_variant *var_field = (void *) field;
BT_ASSERT_PRE_NON_NULL(field, "Field");
- BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_VARIANT, "Field");
+ BT_ASSERT_PRE_FIELD_HAS_CLASS_ID(field,
+ BT_FIELD_CLASS_ID_VARIANT, "Field");
BT_ASSERT_PRE(var_field->selected_field,
"Variant field has no selected field: %!+f", field);
return var_field->selected_index;
void bt_field_finalize(struct bt_field *field)
{
BT_ASSERT(field);
- BT_LOGD_STR("Putting field's type.");
- bt_put(field->type);
+ BT_LOGD_STR("Putting field's class.");
+ bt_put(field->class);
}
static
void bt_field_destroy(struct bt_field *field)
{
BT_ASSERT(field);
- BT_ASSERT(bt_field_type_has_known_id(field->type));
- field_destroy_funcs[field->type->id](field);
+ BT_ASSERT(bt_field_class_has_known_id(field->class));
+ field_destroy_funcs[field->class->id](field);
}
static
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
BT_ASSERT_PRE(stream_class->frozen,
"Stream class is not part of a trace: %!+S", stream_class);
- BT_ASSERT_PRE(stream_class->packet_context_ft,
- "Stream class has no packet context field type: %!+S",
+ BT_ASSERT_PRE(stream_class->packet_context_fc,
+ "Stream class has no packet context field classe: %!+S",
stream_class);
field_wrapper = bt_field_wrapper_create(
&stream_class->packet_context_field_pool,
- (void *) stream_class->packet_context_ft);
+ (void *) stream_class->packet_context_fc);
if (!field_wrapper) {
BT_LIB_LOGE("Cannot allocate one packet context field from stream class: "
"%![sc-]+S", stream_class);
struct bt_field_wrapper *field_wrapper;
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE(trace->packet_header_ft,
- "Trace has no packet header field type: %!+t", trace);
+ BT_ASSERT_PRE(trace->packet_header_fc,
+ "Trace has no packet header field classe: %!+t", trace);
field_wrapper = bt_field_wrapper_create(
&trace->packet_header_field_pool,
- (void *) trace->packet_header_ft);
+ (void *) trace->packet_header_fc);
if (!field_wrapper) {
BT_LIB_LOGE("Cannot allocate one packet header field from trace: "
"%![trace-]+t", trace);
trace = bt_stream_class_borrow_trace_inline(stream->class);
BT_ASSERT(trace);
- if (trace->packet_header_ft) {
+ if (trace->packet_header_fc) {
BT_LOGD_STR("Creating initial packet header field.");
packet->header_field = bt_field_wrapper_create(
&trace->packet_header_field_pool,
- trace->packet_header_ft);
+ trace->packet_header_fc);
if (!packet->header_field) {
BT_LOGE_STR("Cannot create packet header field wrapper.");
goto error;
}
}
- if (stream->class->packet_context_ft) {
+ if (stream->class->packet_context_fc) {
BT_LOGD_STR("Creating initial packet context field.");
packet->context_field = bt_field_wrapper_create(
&stream->class->packet_context_field_pool,
- stream->class->packet_context_ft);
+ stream->class->packet_context_fc);
if (!packet->context_field) {
BT_LOGE_STR("Cannot create packet context field wrapper.");
goto error;
BT_ASSERT_PRE_NON_NULL(field_wrapper, "Header field");
BT_ASSERT_PRE_PACKET_HOT(packet);
trace = bt_stream_class_borrow_trace_inline(packet->stream->class);
- BT_ASSERT_PRE(trace->packet_header_ft,
- "Trace has no packet header field type: %!+t",
+ BT_ASSERT_PRE(trace->packet_header_fc,
+ "Trace has no packet header field classe: %!+t",
trace);
- BT_ASSERT_PRE(field_wrapper->field->type ==
- trace->packet_header_ft,
- "Unexpected packet header field's type: "
- "%![ft-]+F, %![expected-ft-]+F", field_wrapper->field->type,
- trace->packet_header_ft);
+ BT_ASSERT_PRE(field_wrapper->field->class ==
+ trace->packet_header_fc,
+ "Unexpected packet header field's class: "
+ "%![fc-]+F, %![expected-fc-]+F", field_wrapper->field->class,
+ trace->packet_header_fc);
/* Recycle current header field: always exists */
BT_ASSERT(packet->header_field);
BT_ASSERT_PRE_NON_NULL(field_wrapper, "Context field");
BT_ASSERT_PRE_HOT(packet, "Packet", ": %!+a", packet);
stream_class = packet->stream->class;
- BT_ASSERT_PRE(stream_class->packet_context_ft,
- "Stream class has no packet context field type: %!+S",
+ BT_ASSERT_PRE(stream_class->packet_context_fc,
+ "Stream class has no packet context field classe: %!+S",
stream_class);
- BT_ASSERT_PRE(field_wrapper->field->type ==
- stream_class->packet_context_ft,
- "Unexpected packet header field's type: "
- "%![ft-]+F, %![expected-ft-]+F", field_wrapper->field->type,
- stream_class->packet_context_ft);
+ BT_ASSERT_PRE(field_wrapper->field->class ==
+ stream_class->packet_context_fc,
+ "Unexpected packet header field's class: "
+ "%![fc-]+F, %![expected-fc-]+F", field_wrapper->field->class,
+ stream_class->packet_context_fc);
/* Recycle current context field: always exists */
BT_ASSERT(packet->context_field);
#include <babeltrace/assert-pre-internal.h>
#include <babeltrace/assert-internal.h>
-#include <babeltrace/trace-ir/field-types-internal.h>
+#include <babeltrace/trace-ir/field-classes-internal.h>
#include <babeltrace/trace-ir/field-path-internal.h>
#include <babeltrace/trace-ir/field-path.h>
#include <babeltrace/trace-ir/resolve-field-path-internal.h>
#include <glib.h>
static
-bool find_field_type_recursive(struct bt_field_type *ft,
- struct bt_field_type *tgt_ft, struct bt_field_path *field_path)
+bool find_field_class_recursive(struct bt_field_class *fc,
+ struct bt_field_class *tgt_fc, struct bt_field_path *field_path)
{
bool found = false;
- if (tgt_ft == ft) {
+ if (tgt_fc == fc) {
found = true;
goto end;
}
- switch (ft->id) {
- case BT_FIELD_TYPE_ID_STRUCTURE:
- case BT_FIELD_TYPE_ID_VARIANT:
+ switch (fc->id) {
+ case BT_FIELD_CLASS_ID_STRUCTURE:
+ case BT_FIELD_CLASS_ID_VARIANT:
{
- struct bt_field_type_named_field_types_container *container_ft =
- (void *) ft;
+ struct bt_field_class_named_field_class_container *container_fc =
+ (void *) fc;
uint64_t i;
- for (i = 0; i < container_ft->named_fts->len; i++) {
- struct bt_named_field_type *named_ft =
- BT_FIELD_TYPE_NAMED_FT_AT_INDEX(
- container_ft, i);
+ for (i = 0; i < container_fc->named_fcs->len; i++) {
+ struct bt_named_field_class *named_fc =
+ BT_FIELD_CLASS_NAMED_FC_AT_INDEX(
+ container_fc, i);
g_array_append_val(field_path->indexes, i);
- found = find_field_type_recursive(named_ft->ft,
- tgt_ft, field_path);
+ found = find_field_class_recursive(named_fc->fc,
+ tgt_fc, field_path);
if (found) {
goto end;
}
break;
}
- case BT_FIELD_TYPE_ID_STATIC_ARRAY:
- case BT_FIELD_TYPE_ID_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_ID_STATIC_ARRAY:
+ case BT_FIELD_CLASS_ID_DYNAMIC_ARRAY:
{
- struct bt_field_type_array *array_ft = (void *) ft;
+ struct bt_field_class_array *array_fc = (void *) fc;
- found = find_field_type_recursive(array_ft->element_ft,
- tgt_ft, field_path);
+ found = find_field_class_recursive(array_fc->element_fc,
+ tgt_fc, field_path);
break;
}
default:
}
static
-int find_field_type(struct bt_field_type *root_ft,
- enum bt_scope root_scope, struct bt_field_type *tgt_ft,
+int find_field_class(struct bt_field_class *root_fc,
+ enum bt_scope root_scope, struct bt_field_class *tgt_fc,
struct bt_field_path **ret_field_path)
{
int ret = 0;
struct bt_field_path *field_path = NULL;
- if (!root_ft) {
+ if (!root_fc) {
goto end;
}
}
field_path->root = root_scope;
- if (!find_field_type_recursive(root_ft, tgt_ft, field_path)) {
+ if (!find_field_class_recursive(root_fc, tgt_fc, field_path)) {
/* Not found here */
BT_PUT(field_path);
}
}
static
-struct bt_field_path *find_field_type_in_ctx(struct bt_field_type *ft,
+struct bt_field_path *find_field_class_in_ctx(struct bt_field_class *fc,
struct bt_resolve_field_path_context *ctx)
{
struct bt_field_path *field_path = NULL;
int ret;
- ret = find_field_type(ctx->packet_header, BT_SCOPE_PACKET_HEADER,
- ft, &field_path);
+ ret = find_field_class(ctx->packet_header, BT_SCOPE_PACKET_HEADER,
+ fc, &field_path);
if (ret || field_path) {
goto end;
}
- ret = find_field_type(ctx->packet_context, BT_SCOPE_PACKET_CONTEXT,
- ft, &field_path);
+ ret = find_field_class(ctx->packet_context, BT_SCOPE_PACKET_CONTEXT,
+ fc, &field_path);
if (ret || field_path) {
goto end;
}
- ret = find_field_type(ctx->event_header, BT_SCOPE_EVENT_HEADER,
- ft, &field_path);
+ ret = find_field_class(ctx->event_header, BT_SCOPE_EVENT_HEADER,
+ fc, &field_path);
if (ret || field_path) {
goto end;
}
- ret = find_field_type(ctx->event_common_context,
- BT_SCOPE_EVENT_COMMON_CONTEXT, ft, &field_path);
+ ret = find_field_class(ctx->event_common_context,
+ BT_SCOPE_EVENT_COMMON_CONTEXT, fc, &field_path);
if (ret || field_path) {
goto end;
}
- ret = find_field_type(ctx->event_specific_context,
- BT_SCOPE_EVENT_SPECIFIC_CONTEXT, ft, &field_path);
+ ret = find_field_class(ctx->event_specific_context,
+ BT_SCOPE_EVENT_SPECIFIC_CONTEXT, fc, &field_path);
if (ret || field_path) {
goto end;
}
- ret = find_field_type(ctx->event_payload, BT_SCOPE_EVENT_PAYLOAD,
- ft, &field_path);
+ ret = find_field_class(ctx->event_payload, BT_SCOPE_EVENT_PAYLOAD,
+ fc, &field_path);
if (ret || field_path) {
goto end;
}
BT_ASSERT_PRE_FUNC
static inline
-struct bt_field_type *borrow_root_field_type(
+struct bt_field_class *borrow_root_field_class(
struct bt_resolve_field_path_context *ctx, enum bt_scope scope)
{
switch (scope) {
BT_ASSERT_PRE_FUNC
static inline
-struct bt_field_type *borrow_child_field_type(struct bt_field_type *parent_ft,
+struct bt_field_class *borrow_child_field_class(struct bt_field_class *parent_fc,
uint64_t index, bool *advance)
{
- struct bt_field_type *child_ft = NULL;
+ struct bt_field_class *child_fc = NULL;
- switch (parent_ft->id) {
- case BT_FIELD_TYPE_ID_STRUCTURE:
- case BT_FIELD_TYPE_ID_VARIANT:
+ switch (parent_fc->id) {
+ case BT_FIELD_CLASS_ID_STRUCTURE:
+ case BT_FIELD_CLASS_ID_VARIANT:
{
- struct bt_named_field_type *named_ft =
- BT_FIELD_TYPE_NAMED_FT_AT_INDEX(parent_ft, index);
+ struct bt_named_field_class *named_fc =
+ BT_FIELD_CLASS_NAMED_FC_AT_INDEX(parent_fc, index);
- child_ft = named_ft->ft;
+ child_fc = named_fc->fc;
*advance = true;
break;
}
- case BT_FIELD_TYPE_ID_STATIC_ARRAY:
- case BT_FIELD_TYPE_ID_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_ID_STATIC_ARRAY:
+ case BT_FIELD_CLASS_ID_DYNAMIC_ARRAY:
{
- struct bt_field_type_array *array_ft = (void *) parent_ft;
+ struct bt_field_class_array *array_fc = (void *) parent_fc;
- child_ft = array_ft->element_ft;
+ child_fc = array_fc->element_fc;
*advance = false;
break;
}
break;
}
- return child_ft;
+ return child_fc;
}
BT_ASSERT_PRE_FUNC
static inline
-bool target_field_path_in_different_scope_has_struct_ft_only(
+bool target_field_path_in_different_scope_has_struct_fc_only(
struct bt_field_path *src_field_path,
struct bt_field_path *tgt_field_path,
struct bt_resolve_field_path_context *ctx)
{
bool is_valid = true;
uint64_t i = 0;
- struct bt_field_type *ft;
+ struct bt_field_class *fc;
if (src_field_path->root == tgt_field_path->root) {
goto end;
}
- ft = borrow_root_field_type(ctx, tgt_field_path->root);
+ fc = borrow_root_field_class(ctx, tgt_field_path->root);
while (i < tgt_field_path->indexes->len) {
uint64_t index = bt_field_path_get_index_by_index_inline(
tgt_field_path, i);
bool advance;
- if (ft->id == BT_FIELD_TYPE_ID_STATIC_ARRAY ||
- ft->id == BT_FIELD_TYPE_ID_DYNAMIC_ARRAY ||
- ft->id == BT_FIELD_TYPE_ID_VARIANT) {
+ if (fc->id == BT_FIELD_CLASS_ID_STATIC_ARRAY ||
+ fc->id == BT_FIELD_CLASS_ID_DYNAMIC_ARRAY ||
+ fc->id == BT_FIELD_CLASS_ID_VARIANT) {
is_valid = false;
goto end;
}
- ft = borrow_child_field_type(ft, index, &advance);
+ fc = borrow_child_field_class(fc, index, &advance);
if (advance) {
i++;
BT_ASSERT_PRE_FUNC
static inline
-bool lca_is_structure_field_type(struct bt_field_path *src_field_path,
+bool lca_is_structure_field_class(struct bt_field_path *src_field_path,
struct bt_field_path *tgt_field_path,
struct bt_resolve_field_path_context *ctx)
{
bool is_valid = true;
- struct bt_field_type *src_ft;
- struct bt_field_type *tgt_ft;
- struct bt_field_type *prev_ft = NULL;
+ struct bt_field_class *src_fc;
+ struct bt_field_class *tgt_fc;
+ struct bt_field_class *prev_fc = NULL;
uint64_t src_i = 0, tgt_i = 0;
if (src_field_path->root != tgt_field_path->root) {
goto end;
}
- src_ft = borrow_root_field_type(ctx, src_field_path->root);
- tgt_ft = borrow_root_field_type(ctx, tgt_field_path->root);
- BT_ASSERT(src_ft);
- BT_ASSERT(tgt_ft);
+ src_fc = borrow_root_field_class(ctx, src_field_path->root);
+ tgt_fc = borrow_root_field_class(ctx, tgt_field_path->root);
+ BT_ASSERT(src_fc);
+ BT_ASSERT(tgt_fc);
while (src_i < src_field_path->indexes->len &&
tgt_i < tgt_field_path->indexes->len) {
uint64_t tgt_index = bt_field_path_get_index_by_index_inline(
tgt_field_path, tgt_i);
- if (src_ft != tgt_ft) {
- if (!prev_ft) {
+ if (src_fc != tgt_fc) {
+ if (!prev_fc) {
/*
* This is correct: the LCA is the root
- * scope field type, which must be a
- * structure field type.
+ * scope field classe, which must be a
+ * structure field classe.
*/
break;
}
- if (prev_ft->id != BT_FIELD_TYPE_ID_STRUCTURE) {
+ if (prev_fc->id != BT_FIELD_CLASS_ID_STRUCTURE) {
is_valid = false;
}
break;
}
- prev_ft = src_ft;
- src_ft = borrow_child_field_type(src_ft, src_index, &advance);
+ prev_fc = src_fc;
+ src_fc = borrow_child_field_class(src_fc, src_index, &advance);
if (advance) {
src_i++;
}
- tgt_ft = borrow_child_field_type(tgt_ft, tgt_index, &advance);
+ tgt_fc = borrow_child_field_class(tgt_fc, tgt_index, &advance);
if (advance) {
tgt_i++;
BT_ASSERT_PRE_FUNC
static inline
-bool lca_to_target_has_struct_ft_only(struct bt_field_path *src_field_path,
+bool lca_to_target_has_struct_fc_only(struct bt_field_path *src_field_path,
struct bt_field_path *tgt_field_path,
struct bt_resolve_field_path_context *ctx)
{
bool is_valid = true;
- struct bt_field_type *src_ft;
- struct bt_field_type *tgt_ft;
+ struct bt_field_class *src_fc;
+ struct bt_field_class *tgt_fc;
uint64_t src_i = 0, tgt_i = 0;
if (src_field_path->root != tgt_field_path->root) {
goto end;
}
- src_ft = borrow_root_field_type(ctx, src_field_path->root);
- tgt_ft = borrow_root_field_type(ctx, tgt_field_path->root);
- BT_ASSERT(src_ft);
- BT_ASSERT(tgt_ft);
- BT_ASSERT(src_ft == tgt_ft);
+ src_fc = borrow_root_field_class(ctx, src_field_path->root);
+ tgt_fc = borrow_root_field_class(ctx, tgt_field_path->root);
+ BT_ASSERT(src_fc);
+ BT_ASSERT(tgt_fc);
+ BT_ASSERT(src_fc == tgt_fc);
/* Find LCA */
while (src_i < src_field_path->indexes->len &&
tgt_field_path, tgt_i);
if (src_i != tgt_i) {
- /* Next FT is different: LCA is `tgt_ft` */
+ /* Next field class is different: LCA is `tgt_fc` */
break;
}
- src_ft = borrow_child_field_type(src_ft, src_index, &advance);
+ src_fc = borrow_child_field_class(src_fc, src_index, &advance);
if (advance) {
src_i++;
}
- tgt_ft = borrow_child_field_type(tgt_ft, tgt_index, &advance);
+ tgt_fc = borrow_child_field_class(tgt_fc, tgt_index, &advance);
if (advance) {
tgt_i++;
}
}
- /* Only structure field types to the target */
+ /* Only structure field classes to the target */
while (tgt_i < tgt_field_path->indexes->len) {
bool advance;
uint64_t tgt_index = bt_field_path_get_index_by_index_inline(
tgt_field_path, tgt_i);
- if (tgt_ft->id == BT_FIELD_TYPE_ID_STATIC_ARRAY ||
- tgt_ft->id == BT_FIELD_TYPE_ID_DYNAMIC_ARRAY ||
- tgt_ft->id == BT_FIELD_TYPE_ID_VARIANT) {
+ if (tgt_fc->id == BT_FIELD_CLASS_ID_STATIC_ARRAY ||
+ tgt_fc->id == BT_FIELD_CLASS_ID_DYNAMIC_ARRAY ||
+ tgt_fc->id == BT_FIELD_CLASS_ID_VARIANT) {
is_valid = false;
goto end;
}
- tgt_ft = borrow_child_field_type(tgt_ft, tgt_index, &advance);
+ tgt_fc = borrow_child_field_class(tgt_fc, tgt_index, &advance);
if (advance) {
tgt_i++;
BT_ASSERT_PRE_FUNC
static inline
-bool field_path_is_valid(struct bt_field_type *src_ft,
- struct bt_field_type *tgt_ft,
+bool field_path_is_valid(struct bt_field_class *src_fc,
+ struct bt_field_class *tgt_fc,
struct bt_resolve_field_path_context *ctx)
{
bool is_valid = true;
- struct bt_field_path *src_field_path = find_field_type_in_ctx(
- src_ft, ctx);
- struct bt_field_path *tgt_field_path = find_field_type_in_ctx(
- tgt_ft, ctx);
+ struct bt_field_path *src_field_path = find_field_class_in_ctx(
+ src_fc, ctx);
+ struct bt_field_path *tgt_field_path = find_field_class_in_ctx(
+ tgt_fc, ctx);
if (!src_field_path) {
- BT_ASSERT_PRE_MSG("Cannot find requesting field type in "
- "resolving context: %!+F", src_ft);
+ BT_ASSERT_PRE_MSG("Cannot find requesting field classe in "
+ "resolving context: %!+F", src_fc);
is_valid = false;
goto end;
}
if (!tgt_field_path) {
- BT_ASSERT_PRE_MSG("Cannot find target field type in "
- "resolving context: %!+F", tgt_ft);
+ BT_ASSERT_PRE_MSG("Cannot find target field classe in "
+ "resolving context: %!+F", tgt_fc);
is_valid = false;
goto end;
}
/* Target must be before source */
if (!target_is_before_source(src_field_path, tgt_field_path)) {
- BT_ASSERT_PRE_MSG("Target field type is located after "
- "requesting field type: %![req-ft-]+F, %![tgt-ft-]+F",
- src_ft, tgt_ft);
+ BT_ASSERT_PRE_MSG("Target field classe is located after "
+ "requesting field classe: %![req-fc-]+F, %![tgt-fc-]+F",
+ src_fc, tgt_fc);
is_valid = false;
goto end;
}
/*
* If target is in a different scope than source, there are no
- * array or variant field types on the way to the target.
+ * array or variant field classes on the way to the target.
*/
- if (!target_field_path_in_different_scope_has_struct_ft_only(
+ if (!target_field_path_in_different_scope_has_struct_fc_only(
src_field_path, tgt_field_path, ctx)) {
- BT_ASSERT_PRE_MSG("Target field type is located in a "
- "different scope than requesting field type, "
- "but within an array or a variant field type: "
- "%![req-ft-]+F, %![tgt-ft-]+F",
- src_ft, tgt_ft);
+ BT_ASSERT_PRE_MSG("Target field classe is located in a "
+ "different scope than requesting field classe, "
+ "but within an array or a variant field classe: "
+ "%![req-fc-]+F, %![tgt-fc-]+F",
+ src_fc, tgt_fc);
is_valid = false;
goto end;
}
- /* Same scope: LCA must be a structure field type */
- if (!lca_is_structure_field_type(src_field_path, tgt_field_path, ctx)) {
+ /* Same scope: LCA must be a structure field classe */
+ if (!lca_is_structure_field_class(src_field_path, tgt_field_path, ctx)) {
BT_ASSERT_PRE_MSG("Lowest common ancestor of target and "
- "requesting field types is not a structure field type: "
- "%![req-ft-]+F, %![tgt-ft-]+F",
- src_ft, tgt_ft);
+ "requesting field classes is not a structure field classe: "
+ "%![req-fc-]+F, %![tgt-fc-]+F",
+ src_fc, tgt_fc);
is_valid = false;
goto end;
}
/* Same scope: path from LCA to target has no array/variant FTs */
- if (!lca_to_target_has_struct_ft_only(src_field_path, tgt_field_path,
+ if (!lca_to_target_has_struct_fc_only(src_field_path, tgt_field_path,
ctx)) {
BT_ASSERT_PRE_MSG("Path from lowest common ancestor of target "
- "and requesting field types to target field type "
- "contains an array or a variant field type: "
- "%![req-ft-]+F, %![tgt-ft-]+F", src_ft, tgt_ft);
+ "and requesting field classes to target field classe "
+ "contains an array or a variant field classe: "
+ "%![req-fc-]+F, %![tgt-fc-]+F", src_fc, tgt_fc);
is_valid = false;
goto end;
}
}
static
-struct bt_field_path *resolve_field_path(struct bt_field_type *src_ft,
- struct bt_field_type *tgt_ft,
+struct bt_field_path *resolve_field_path(struct bt_field_class *src_fc,
+ struct bt_field_class *tgt_fc,
struct bt_resolve_field_path_context *ctx)
{
- BT_ASSERT_PRE(field_path_is_valid(src_ft, tgt_ft, ctx),
- "Invalid target field type: %![req-ft-]+F, %![tgt-ft-]+F",
- src_ft, tgt_ft);
- return find_field_type_in_ctx(tgt_ft, ctx);
+ BT_ASSERT_PRE(field_path_is_valid(src_fc, tgt_fc, ctx),
+ "Invalid target field classe: %![req-fc-]+F, %![tgt-fc-]+F",
+ src_fc, tgt_fc);
+ return find_field_class_in_ctx(tgt_fc, ctx);
}
BT_HIDDEN
-int bt_resolve_field_paths(struct bt_field_type *ft,
+int bt_resolve_field_paths(struct bt_field_class *fc,
struct bt_resolve_field_path_context *ctx)
{
int ret = 0;
- BT_ASSERT(ft);
+ BT_ASSERT(fc);
- /* Resolving part for dynamic array and variant field types */
- switch (ft->id) {
- case BT_FIELD_TYPE_ID_DYNAMIC_ARRAY:
+ /* Resolving part for dynamic array and variant field classes */
+ switch (fc->id) {
+ case BT_FIELD_CLASS_ID_DYNAMIC_ARRAY:
{
- struct bt_field_type_dynamic_array *dyn_array_ft = (void *) ft;
+ struct bt_field_class_dynamic_array *dyn_array_fc = (void *) fc;
- if (dyn_array_ft->length_ft) {
- BT_ASSERT(!dyn_array_ft->length_field_path);
- dyn_array_ft->length_field_path = resolve_field_path(
- ft, dyn_array_ft->length_ft, ctx);
- if (!dyn_array_ft->length_field_path) {
+ if (dyn_array_fc->length_fc) {
+ BT_ASSERT(!dyn_array_fc->length_field_path);
+ dyn_array_fc->length_field_path = resolve_field_path(
+ fc, dyn_array_fc->length_fc, ctx);
+ if (!dyn_array_fc->length_field_path) {
ret = -1;
goto end;
}
break;
}
- case BT_FIELD_TYPE_ID_VARIANT:
+ case BT_FIELD_CLASS_ID_VARIANT:
{
- struct bt_field_type_variant *var_ft = (void *) ft;
-
- if (var_ft->selector_ft) {
- BT_ASSERT(!var_ft->selector_field_path);
- var_ft->selector_field_path =
- resolve_field_path(ft,
- var_ft->selector_ft, ctx);
- if (!var_ft->selector_field_path) {
+ struct bt_field_class_variant *var_fc = (void *) fc;
+
+ if (var_fc->selector_fc) {
+ BT_ASSERT(!var_fc->selector_field_path);
+ var_fc->selector_field_path =
+ resolve_field_path(fc,
+ var_fc->selector_fc, ctx);
+ if (!var_fc->selector_field_path) {
ret = -1;
goto end;
}
}
/* Recursive part */
- switch (ft->id) {
- case BT_FIELD_TYPE_ID_STRUCTURE:
- case BT_FIELD_TYPE_ID_VARIANT:
+ switch (fc->id) {
+ case BT_FIELD_CLASS_ID_STRUCTURE:
+ case BT_FIELD_CLASS_ID_VARIANT:
{
- struct bt_field_type_named_field_types_container *container_ft =
- (void *) ft;
+ struct bt_field_class_named_field_class_container *container_fc =
+ (void *) fc;
uint64_t i;
- for (i = 0; i < container_ft->named_fts->len; i++) {
- struct bt_named_field_type *named_ft =
- BT_FIELD_TYPE_NAMED_FT_AT_INDEX(
- container_ft, i);
+ for (i = 0; i < container_fc->named_fcs->len; i++) {
+ struct bt_named_field_class *named_fc =
+ BT_FIELD_CLASS_NAMED_FC_AT_INDEX(
+ container_fc, i);
- ret = bt_resolve_field_paths(named_ft->ft, ctx);
+ ret = bt_resolve_field_paths(named_fc->fc, ctx);
if (ret) {
goto end;
}
break;
}
- case BT_FIELD_TYPE_ID_STATIC_ARRAY:
- case BT_FIELD_TYPE_ID_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_ID_STATIC_ARRAY:
+ case BT_FIELD_CLASS_ID_DYNAMIC_ARRAY:
{
- struct bt_field_type_array *array_ft = (void *) ft;
+ struct bt_field_class_array *array_fc = (void *) fc;
- ret = bt_resolve_field_paths(array_ft->element_ft, ctx);
+ ret = bt_resolve_field_paths(array_fc->element_fc, ctx);
break;
}
default:
#include <babeltrace/assert-pre-internal.h>
#include <babeltrace/trace-ir/clock-class-internal.h>
#include <babeltrace/trace-ir/event-class-internal.h>
-#include <babeltrace/trace-ir/field-types-internal.h>
+#include <babeltrace/trace-ir/field-classes-internal.h>
#include <babeltrace/trace-ir/fields-internal.h>
#include <babeltrace/trace-ir/stream-class-internal.h>
#include <babeltrace/trace-ir/utils-internal.h>
g_string_free(stream_class->name.str, TRUE);
}
- BT_LOGD_STR("Putting event header field type.");
- bt_put(stream_class->event_header_ft);
- BT_LOGD_STR("Putting packet context field type.");
- bt_put(stream_class->packet_context_ft);
- BT_LOGD_STR("Putting event common context field type.");
- bt_put(stream_class->event_common_context_ft);
+ BT_LOGD_STR("Putting event header field classe.");
+ bt_put(stream_class->event_header_fc);
+ BT_LOGD_STR("Putting packet context field classe.");
+ bt_put(stream_class->packet_context_fc);
+ BT_LOGD_STR("Putting event common context field classe.");
+ bt_put(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);
return event_class;
}
-struct bt_field_type *bt_stream_class_borrow_packet_context_field_type(
+struct bt_field_class *bt_stream_class_borrow_packet_context_field_class(
struct bt_stream_class *stream_class)
{
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- return stream_class->packet_context_ft;
+ return stream_class->packet_context_fc;
}
-int bt_stream_class_set_packet_context_field_type(
+int bt_stream_class_set_packet_context_field_class(
struct bt_stream_class *stream_class,
- struct bt_field_type *field_type)
+ struct bt_field_class *field_class)
{
int ret;
struct bt_resolve_field_path_context resolve_ctx = {
.packet_header = NULL,
- .packet_context = field_type,
+ .packet_context = field_class,
.event_header = NULL,
.event_common_context = NULL,
.event_specific_context = NULL,
};
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- BT_ASSERT_PRE_NON_NULL(field_type, "Field type");
+ BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
- BT_ASSERT_PRE(bt_field_type_get_type_id(field_type) ==
- BT_FIELD_TYPE_ID_STRUCTURE,
- "Packet context field type is not a structure field type: %!+F",
- field_type);
+ BT_ASSERT_PRE(bt_field_class_get_id(field_class) ==
+ BT_FIELD_CLASS_ID_STRUCTURE,
+ "Packet context field classe is not a structure field classe: %!+F",
+ field_class);
resolve_ctx.packet_header =
- bt_stream_class_borrow_trace_inline(stream_class)->packet_header_ft;
- ret = bt_resolve_field_paths(field_type, &resolve_ctx);
+ bt_stream_class_borrow_trace_inline(stream_class)->packet_header_fc;
+ ret = bt_resolve_field_paths(field_class, &resolve_ctx);
if (ret) {
goto end;
}
- bt_field_type_make_part_of_trace(field_type);
- bt_put(stream_class->packet_context_ft);
- stream_class->packet_context_ft = bt_get(field_type);
- bt_field_type_freeze(field_type);
- BT_LIB_LOGV("Set stream class's packet context field type: %!+S",
+ bt_field_class_make_part_of_trace(field_class);
+ bt_put(stream_class->packet_context_fc);
+ stream_class->packet_context_fc = bt_get(field_class);
+ bt_field_class_freeze(field_class);
+ BT_LIB_LOGV("Set stream class's packet context field classe: %!+S",
stream_class);
end:
return ret;
}
-struct bt_field_type *bt_stream_class_borrow_event_header_field_type(
+struct bt_field_class *bt_stream_class_borrow_event_header_field_class(
struct bt_stream_class *stream_class)
{
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- return stream_class->event_header_ft;
+ return stream_class->event_header_fc;
}
-int bt_stream_class_set_event_header_field_type(
+int bt_stream_class_set_event_header_field_class(
struct bt_stream_class *stream_class,
- struct bt_field_type *field_type)
+ 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_type,
+ .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_type, "Field type");
+ BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
- BT_ASSERT_PRE(bt_field_type_get_type_id(field_type) ==
- BT_FIELD_TYPE_ID_STRUCTURE,
- "Event header field type is not a structure field type: %!+F",
- field_type);
+ BT_ASSERT_PRE(bt_field_class_get_id(field_class) ==
+ BT_FIELD_CLASS_ID_STRUCTURE,
+ "Event header field classe is not a structure field classe: %!+F",
+ field_class);
resolve_ctx.packet_header =
- bt_stream_class_borrow_trace_inline(stream_class)->packet_header_ft;
- resolve_ctx.packet_context = stream_class->packet_context_ft;
- ret = bt_resolve_field_paths(field_type, &resolve_ctx);
+ bt_stream_class_borrow_trace_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) {
goto end;
}
- bt_field_type_make_part_of_trace(field_type);
- bt_put(stream_class->event_header_ft);
- stream_class->event_header_ft = bt_get(field_type);
- bt_field_type_freeze(field_type);
- BT_LIB_LOGV("Set stream class's event header field type: %!+S",
+ bt_field_class_make_part_of_trace(field_class);
+ bt_put(stream_class->event_header_fc);
+ stream_class->event_header_fc = bt_get(field_class);
+ bt_field_class_freeze(field_class);
+ BT_LIB_LOGV("Set stream class's event header field classe: %!+S",
stream_class);
end:
return ret;
}
-struct bt_field_type *bt_stream_class_borrow_event_common_context_field_type(
+struct bt_field_class *bt_stream_class_borrow_event_common_context_field_class(
struct bt_stream_class *stream_class)
{
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- return stream_class->event_common_context_ft;
+ return stream_class->event_common_context_fc;
}
-int bt_stream_class_set_event_common_context_field_type(
+int bt_stream_class_set_event_common_context_field_class(
struct bt_stream_class *stream_class,
- struct bt_field_type *field_type)
+ struct bt_field_class *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_type,
+ .event_common_context = field_class,
.event_specific_context = NULL,
.event_payload = NULL,
};
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- BT_ASSERT_PRE_NON_NULL(field_type, "Field type");
+ BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
- BT_ASSERT_PRE(bt_field_type_get_type_id(field_type) ==
- BT_FIELD_TYPE_ID_STRUCTURE,
- "Event common context field type is not a structure field type: %!+F",
- field_type);
+ BT_ASSERT_PRE(bt_field_class_get_id(field_class) ==
+ BT_FIELD_CLASS_ID_STRUCTURE,
+ "Event common context field classe is not a structure field classe: %!+F",
+ field_class);
resolve_ctx.packet_header =
- bt_stream_class_borrow_trace_inline(stream_class)->packet_header_ft;
- resolve_ctx.packet_context = stream_class->packet_context_ft;
- resolve_ctx.event_header = stream_class->event_header_ft;
- ret = bt_resolve_field_paths(field_type, &resolve_ctx);
+ bt_stream_class_borrow_trace_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) {
goto end;
}
- bt_field_type_make_part_of_trace(field_type);
- bt_put(stream_class->event_common_context_ft);
- stream_class->event_common_context_ft = bt_get(field_type);
- bt_field_type_freeze(field_type);
- BT_LIB_LOGV("Set stream class's event common context field type: %!+S",
+ bt_field_class_make_part_of_trace(field_class);
+ bt_put(stream_class->event_common_context_fc);
+ stream_class->event_common_context_fc = bt_get(field_class);
+ bt_field_class_freeze(field_class);
+ BT_LIB_LOGV("Set stream class's event common context field classe: %!+S",
stream_class);
end:
BT_HIDDEN
void _bt_stream_class_freeze(struct bt_stream_class *stream_class)
{
- /* The field types and default clock class are already frozen */
+ /* The field classes and default clock class are already frozen */
BT_ASSERT(stream_class);
BT_LIB_LOGD("Freezing stream class: %!+S", stream_class);
stream_class->frozen = true;
BT_HIDDEN
void _bt_stream_freeze(struct bt_stream *stream)
{
- /* The field types and default clock class are already frozen */
+ /* The field classes and default clock class are already frozen */
BT_ASSERT(stream);
BT_LIB_LOGD("Freezing stream: %!+s", stream);
stream->frozen = true;
#include <babeltrace/ctf-writer/functor-internal.h>
#include <babeltrace/ctf-writer/clock-internal.h>
#include <babeltrace/trace-ir/field-wrapper-internal.h>
-#include <babeltrace/trace-ir/field-types-internal.h>
+#include <babeltrace/trace-ir/field-classes-internal.h>
#include <babeltrace/trace-ir/attributes-internal.h>
#include <babeltrace/trace-ir/utils-internal.h>
#include <babeltrace/trace-ir/resolve-field-path-internal.h>
g_hash_table_destroy(trace->stream_classes_stream_count);
}
- BT_LOGD_STR("Putting packet header field type.");
- bt_put(trace->packet_header_ft);
+ BT_LOGD_STR("Putting packet header field classe.");
+ bt_put(trace->packet_header_fc);
g_free(trace);
}
return stream_class;
}
-struct bt_field_type *bt_trace_borrow_packet_header_field_type(
+struct bt_field_class *bt_trace_borrow_packet_header_field_class(
struct bt_trace *trace)
{
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return trace->packet_header_ft;
+ return trace->packet_header_fc;
}
-int bt_trace_set_packet_header_field_type(struct bt_trace *trace,
- struct bt_field_type *field_type)
+int bt_trace_set_packet_header_field_class(struct bt_trace *trace,
+ struct bt_field_class *field_class)
{
int ret;
struct bt_resolve_field_path_context resolve_ctx = {
- .packet_header = field_type,
+ .packet_header = field_class,
.packet_context = NULL,
.event_header = NULL,
.event_common_context = NULL,
};
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE_NON_NULL(field_type, "Field type");
+ BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
BT_ASSERT_PRE_TRACE_HOT(trace);
- BT_ASSERT_PRE(bt_field_type_get_type_id(field_type) ==
- BT_FIELD_TYPE_ID_STRUCTURE,
- "Packet header field type is not a structure field type: %!+F",
- field_type);
- ret = bt_resolve_field_paths(field_type, &resolve_ctx);
+ BT_ASSERT_PRE(bt_field_class_get_id(field_class) ==
+ BT_FIELD_CLASS_ID_STRUCTURE,
+ "Packet header field classe is not a structure field classe: %!+F",
+ field_class);
+ ret = bt_resolve_field_paths(field_class, &resolve_ctx);
if (ret) {
goto end;
}
- bt_field_type_make_part_of_trace(field_type);
- bt_put(trace->packet_header_ft);
- trace->packet_header_ft = bt_get(field_type);
- bt_field_type_freeze(field_type);
- BT_LIB_LOGV("Set trace's packet header field type: %!+t", trace);
+ bt_field_class_make_part_of_trace(field_class);
+ bt_put(trace->packet_header_fc);
+ trace->packet_header_fc = bt_get(field_class);
+ bt_field_class_freeze(field_class);
+ BT_LIB_LOGV("Set trace's packet header field classe: %!+t", trace);
end:
return ret;
BT_HIDDEN
void _bt_trace_freeze(struct bt_trace *trace)
{
- /* The packet header field type is already frozen */
+ /* The packet header field classe is already frozen */
BT_ASSERT(trace);
BT_LIB_LOGD("Freezing trace: %!+t", trace);
trace->frozen = true;
#include <stdlib.h>
#include <glib.h>
-#include <babeltrace/trace-ir/field-types-internal.h>
+#include <babeltrace/trace-ir/field-classes-internal.h>
#include <babeltrace/trace-ir/clock-class.h>
#include <babeltrace/ref.h>
#include <babeltrace/assert-internal.h>
-SUBDIRS = metadata btr notif-iter utils
+SUBDIRS = metadata bfcr notif-iter utils
noinst_LTLIBRARIES = libbabeltrace-plugin-ctf-common.la
libbabeltrace_plugin_ctf_common_la_SOURCES = print.h
libbabeltrace_plugin_ctf_common_la_LIBADD = \
$(builddir)/metadata/libctf-parser.la \
$(builddir)/metadata/libctf-ast.la \
- $(builddir)/btr/libctf-btr.la \
+ $(builddir)/bfcr/libctf-bfcr.la \
$(builddir)/notif-iter/libctf-notif-iter.la \
$(builddir)/utils/libctf-utils.la
--- /dev/null
+noinst_LTLIBRARIES = libctf-bfcr.la
+libctf_bfcr_la_SOURCES = \
+ bfcr.c \
+ bfcr.h \
+ logging.c \
+ logging.h
--- /dev/null
+/*
+ * Babeltrace - CTF binary field class reader (BFCR)
+ *
+ * Copyright (c) 2015-2016 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2015-2016 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 "PLUGIN-CTF-BFCR"
+#include "logging.h"
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <stdbool.h>
+#include <babeltrace/assert-internal.h>
+#include <string.h>
+#include <babeltrace/bitfield-internal.h>
+#include <babeltrace/common-internal.h>
+#include <babeltrace/babeltrace.h>
+#include <babeltrace/ref.h>
+#include <babeltrace/align-internal.h>
+#include <glib.h>
+
+#include "bfcr.h"
+#include "../metadata/ctf-meta.h"
+
+#define DIV8(_x) ((_x) >> 3)
+#define BYTES_TO_BITS(_x) ((_x) * 8)
+#define BITS_TO_BYTES_FLOOR(_x) DIV8(_x)
+#define BITS_TO_BYTES_CEIL(_x) DIV8((_x) + 7)
+#define IN_BYTE_OFFSET(_at) ((_at) & 7)
+
+/* A visit stack entry */
+struct stack_entry {
+ /*
+ * Current class of base field, one of:
+ *
+ * * Structure
+ * * Array
+ * * Sequence
+ * * Variant
+ */
+ struct ctf_field_class *base_class;
+
+ /* Length of base field (always 1 for a variant class) */
+ int64_t base_len;
+
+ /* Index of next field to read */
+ int64_t index;
+};
+
+/* Visit stack */
+struct stack {
+ /* Entries (struct stack_entry) */
+ GArray *entries;
+
+ /* Number of active entries */
+ size_t size;
+};
+
+/* Reading states */
+enum bfcr_state {
+ BFCR_STATE_NEXT_FIELD,
+ BFCR_STATE_ALIGN_BASIC,
+ BFCR_STATE_ALIGN_COMPOUND,
+ BFCR_STATE_READ_BASIC_BEGIN,
+ BFCR_STATE_READ_BASIC_CONTINUE,
+ BFCR_STATE_DONE,
+};
+
+/* Binary class reader */
+struct bt_bfcr {
+ /* Bisit stack */
+ struct stack *stack;
+
+ /* Current basic field class */
+ struct ctf_field_class *cur_basic_field_class;
+
+ /* Current state */
+ enum bfcr_state state;
+
+ /*
+ * Last basic field class's byte order.
+ *
+ * This is used to detect errors since two contiguous basic
+ * classes for which the common boundary is not the boundary of
+ * a byte cannot have different byte orders.
+ *
+ * This is set to -1 on reset and when the last basic field class
+ * was a string class.
+ */
+ enum ctf_byte_order last_bo;
+
+ /* Current byte order (copied to last_bo after a successful read) */
+ enum ctf_byte_order cur_bo;
+
+ /* Stitch buffer infos */
+ struct {
+ /* Stitch buffer */
+ uint8_t buf[16];
+
+ /* Offset, within stitch buffer, of first bit */
+ size_t offset;
+
+ /* Length (bits) of data in stitch buffer from offset */
+ size_t at;
+ } stitch;
+
+ /* User buffer infos */
+ struct {
+ /* Address */
+ const uint8_t *addr;
+
+ /* Offset of data from address (bits) */
+ size_t offset;
+
+ /* Current position from offset (bits) */
+ size_t at;
+
+ /* Offset of offset within whole packet (bits) */
+ size_t packet_offset;
+
+ /* Data size in buffer (bits) */
+ size_t sz;
+
+ /* Buffer size (bytes) */
+ size_t buf_sz;
+ } buf;
+
+ /* User stuff */
+ struct {
+ /* Callback functions */
+ struct bt_bfcr_cbs cbs;
+
+ /* Private data */
+ void *data;
+ } user;
+};
+
+static inline
+const char *bfcr_state_string(enum bfcr_state state)
+{
+ switch (state) {
+ case BFCR_STATE_NEXT_FIELD:
+ return "BFCR_STATE_NEXT_FIELD";
+ case BFCR_STATE_ALIGN_BASIC:
+ return "BFCR_STATE_ALIGN_BASIC";
+ case BFCR_STATE_ALIGN_COMPOUND:
+ return "BFCR_STATE_ALIGN_COMPOUND";
+ case BFCR_STATE_READ_BASIC_BEGIN:
+ return "BFCR_STATE_READ_BASIC_BEGIN";
+ case BFCR_STATE_READ_BASIC_CONTINUE:
+ return "BFCR_STATE_READ_BASIC_CONTINUE";
+ case BFCR_STATE_DONE:
+ return "BFCR_STATE_DONE";
+ default:
+ return "(unknown)";
+ }
+}
+
+static
+struct stack *stack_new(void)
+{
+ struct stack *stack = NULL;
+
+ stack = g_new0(struct stack, 1);
+ if (!stack) {
+ BT_LOGE_STR("Failed to allocate one stack.");
+ goto error;
+ }
+
+ stack->entries = g_array_new(FALSE, TRUE, sizeof(struct stack_entry));
+ if (!stack->entries) {
+ BT_LOGE_STR("Failed to allocate a GArray.");
+ goto error;
+ }
+
+ BT_LOGD("Created stack: addr=%p", stack);
+ return stack;
+
+error:
+ g_free(stack);
+ return NULL;
+}
+
+static
+void stack_destroy(struct stack *stack)
+{
+ if (!stack) {
+ return;
+ }
+
+ BT_LOGD("Destroying stack: addr=%p", stack);
+
+ if (stack->entries) {
+ g_array_free(stack->entries, TRUE);
+ }
+
+ g_free(stack);
+}
+
+static
+int stack_push(struct stack *stack, struct ctf_field_class *base_class,
+ size_t base_len)
+{
+ struct stack_entry *entry;
+
+ BT_ASSERT(stack);
+ BT_ASSERT(base_class);
+ BT_LOGV("Pushing field class on stack: stack-addr=%p, "
+ "fc-addr=%p, fc-id=%d, base-length=%zu, "
+ "stack-size-before=%zu, stack-size-after=%zu",
+ stack, base_class, base_class->id,
+ base_len, stack->size, stack->size + 1);
+
+ if (stack->entries->len == stack->size) {
+ g_array_set_size(stack->entries, stack->size + 1);
+ }
+
+ entry = &g_array_index(stack->entries, struct stack_entry, stack->size);
+ entry->base_class = base_class;
+ entry->base_len = base_len;
+ entry->index = 0;
+ stack->size++;
+ return 0;
+}
+
+static inline
+int64_t get_compound_field_class_length(struct bt_bfcr *bfcr,
+ struct ctf_field_class *fc)
+{
+ int64_t length;
+
+ switch (fc->id) {
+ case CTF_FIELD_CLASS_ID_STRUCT:
+ {
+ struct ctf_field_class_struct *struct_fc = (void *) fc;
+
+ length = (int64_t) struct_fc->members->len;
+ break;
+ }
+ case CTF_FIELD_CLASS_ID_VARIANT:
+ {
+ /* Variant field classes always "contain" a single class */
+ length = 1;
+ break;
+ }
+ case CTF_FIELD_CLASS_ID_ARRAY:
+ {
+ struct ctf_field_class_array *array_fc = (void *) fc;
+
+ length = (int64_t) array_fc->length;
+ break;
+ }
+ case CTF_FIELD_CLASS_ID_SEQUENCE:
+ length = bfcr->user.cbs.query.get_sequence_length(fc,
+ bfcr->user.data);
+ break;
+ default:
+ abort();
+ }
+
+ return length;
+}
+
+static
+int stack_push_with_len(struct bt_bfcr *bfcr, struct ctf_field_class *base_class)
+{
+ int ret;
+ int64_t length = get_compound_field_class_length(bfcr, base_class);
+
+ if (length < 0) {
+ BT_LOGW("Cannot get compound field class's field count: "
+ "bfcr-addr=%p, fc-addr=%p, fc-id=%d",
+ bfcr, base_class, base_class->id);
+ ret = BT_BFCR_STATUS_ERROR;
+ goto end;
+ }
+
+ ret = stack_push(bfcr->stack, base_class, (size_t) length);
+
+end:
+ return ret;
+}
+
+static inline
+unsigned int stack_size(struct stack *stack)
+{
+ BT_ASSERT(stack);
+ return stack->size;
+}
+
+static
+void stack_pop(struct stack *stack)
+{
+ BT_ASSERT(stack);
+ BT_ASSERT(stack_size(stack));
+ BT_LOGV("Popping from stack: "
+ "stack-addr=%p, stack-size-before=%u, stack-size-after=%u",
+ stack, stack->entries->len, stack->entries->len - 1);
+ stack->size--;
+}
+
+static inline
+bool stack_empty(struct stack *stack)
+{
+ return stack_size(stack) == 0;
+}
+
+static
+void stack_clear(struct stack *stack)
+{
+ BT_ASSERT(stack);
+ stack->size = 0;
+}
+
+static inline
+struct stack_entry *stack_top(struct stack *stack)
+{
+ BT_ASSERT(stack);
+ BT_ASSERT(stack_size(stack));
+ return &g_array_index(stack->entries, struct stack_entry,
+ stack->size - 1);
+}
+
+static inline
+size_t available_bits(struct bt_bfcr *bfcr)
+{
+ return bfcr->buf.sz - bfcr->buf.at;
+}
+
+static inline
+void consume_bits(struct bt_bfcr *bfcr, size_t incr)
+{
+ BT_LOGV("Advancing cursor: bfcr-addr=%p, cur-before=%zu, cur-after=%zu",
+ bfcr, bfcr->buf.at, bfcr->buf.at + incr);
+ bfcr->buf.at += incr;
+}
+
+static inline
+bool has_enough_bits(struct bt_bfcr *bfcr, size_t sz)
+{
+ return available_bits(bfcr) >= sz;
+}
+
+static inline
+bool at_least_one_bit_left(struct bt_bfcr *bfcr)
+{
+ return has_enough_bits(bfcr, 1);
+}
+
+static inline
+size_t packet_at(struct bt_bfcr *bfcr)
+{
+ return bfcr->buf.packet_offset + bfcr->buf.at;
+}
+
+static inline
+size_t buf_at_from_addr(struct bt_bfcr *bfcr)
+{
+ /*
+ * Considering this:
+ *
+ * ====== offset ===== (17)
+ *
+ * xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
+ * ^
+ * addr (0) ==== at ==== (12)
+ *
+ * We want this:
+ *
+ * =============================== (29)
+ */
+ return bfcr->buf.offset + bfcr->buf.at;
+}
+
+static
+void stitch_reset(struct bt_bfcr *bfcr)
+{
+ bfcr->stitch.offset = 0;
+ bfcr->stitch.at = 0;
+}
+
+static inline
+size_t stitch_at_from_addr(struct bt_bfcr *bfcr)
+{
+ return bfcr->stitch.offset + bfcr->stitch.at;
+}
+
+static
+void stitch_append_from_buf(struct bt_bfcr *bfcr, size_t sz)
+{
+ size_t stitch_byte_at;
+ size_t buf_byte_at;
+ size_t nb_bytes;
+
+ if (sz == 0) {
+ return;
+ }
+
+ stitch_byte_at =
+ BITS_TO_BYTES_FLOOR(stitch_at_from_addr(bfcr));
+ buf_byte_at = BITS_TO_BYTES_FLOOR(buf_at_from_addr(bfcr));
+ nb_bytes = BITS_TO_BYTES_CEIL(sz);
+ BT_ASSERT(nb_bytes > 0);
+ BT_ASSERT(bfcr->buf.addr);
+ memcpy(&bfcr->stitch.buf[stitch_byte_at], &bfcr->buf.addr[buf_byte_at],
+ nb_bytes);
+ bfcr->stitch.at += sz;
+ consume_bits(bfcr, sz);
+}
+
+static
+void stitch_append_from_remaining_buf(struct bt_bfcr *bfcr)
+{
+ stitch_append_from_buf(bfcr, available_bits(bfcr));
+}
+
+static
+void stitch_set_from_remaining_buf(struct bt_bfcr *bfcr)
+{
+ stitch_reset(bfcr);
+ bfcr->stitch.offset = IN_BYTE_OFFSET(buf_at_from_addr(bfcr));
+ stitch_append_from_remaining_buf(bfcr);
+}
+
+static inline
+void read_unsigned_bitfield(const uint8_t *buf, size_t at,
+ unsigned int field_size, enum ctf_byte_order bo,
+ uint64_t *v)
+{
+ switch (bo) {
+ case CTF_BYTE_ORDER_BIG:
+ bt_bitfield_read_be(buf, uint8_t, at, field_size, v);
+ break;
+ case CTF_BYTE_ORDER_LITTLE:
+ bt_bitfield_read_le(buf, uint8_t, at, field_size, v);
+ break;
+ default:
+ abort();
+ }
+
+ BT_LOGV("Read unsigned bit array: cur=%zu, size=%u, "
+ "bo=%d, val=%" PRIu64, at, field_size, bo, *v);
+}
+
+static inline
+void read_signed_bitfield(const uint8_t *buf, size_t at,
+ unsigned int field_size, enum ctf_byte_order bo, int64_t *v)
+{
+ switch (bo) {
+ case CTF_BYTE_ORDER_BIG:
+ bt_bitfield_read_be(buf, uint8_t, at, field_size, v);
+ break;
+ case CTF_BYTE_ORDER_LITTLE:
+ bt_bitfield_read_le(buf, uint8_t, at, field_size, v);
+ break;
+ default:
+ abort();
+ }
+
+ BT_LOGV("Read signed bit array: cur=%zu, size=%u, "
+ "bo=%d, val=%" PRId64, at, field_size, bo, *v);
+}
+
+typedef enum bt_bfcr_status (* read_basic_and_call_cb_t)(struct bt_bfcr *,
+ const uint8_t *, size_t);
+
+static inline
+enum bt_bfcr_status validate_contiguous_bo(struct bt_bfcr *bfcr,
+ enum ctf_byte_order next_bo)
+{
+ enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
+
+ /* Always valid when at a byte boundary */
+ if (packet_at(bfcr) % 8 == 0) {
+ goto end;
+ }
+
+ /* Always valid if last byte order is unknown */
+ if (bfcr->last_bo == -1) {
+ goto end;
+ }
+
+ /* Always valid if next byte order is unknown */
+ if (next_bo == -1) {
+ goto end;
+ }
+
+ /* Make sure last byte order is compatible with the next byte order */
+ switch (bfcr->last_bo) {
+ case CTF_BYTE_ORDER_BIG:
+ if (next_bo != CTF_BYTE_ORDER_BIG) {
+ status = BT_BFCR_STATUS_ERROR;
+ }
+ break;
+ case CTF_BYTE_ORDER_LITTLE:
+ if (next_bo != CTF_BYTE_ORDER_LITTLE) {
+ status = BT_BFCR_STATUS_ERROR;
+ }
+ break;
+ default:
+ status = BT_BFCR_STATUS_ERROR;
+ }
+
+end:
+ if (status < 0) {
+ BT_LOGW("Cannot read bit array: two different byte orders not at a byte boundary: "
+ "bfcr-addr=%p, last-bo=%d, next-bo=%d",
+ bfcr, bfcr->last_bo, next_bo);
+ }
+
+ return status;
+}
+
+static
+enum bt_bfcr_status read_basic_float_and_call_cb(struct bt_bfcr *bfcr,
+ const uint8_t *buf, size_t at)
+{
+ double dblval;
+ unsigned int field_size;
+ enum ctf_byte_order bo;
+ enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
+ struct ctf_field_class_float *fc = (void *) bfcr->cur_basic_field_class;
+
+ BT_ASSERT(fc);
+ field_size = fc->base.size;
+ bo = fc->base.byte_order;
+ bfcr->cur_bo = bo;
+
+ switch (field_size) {
+ case 32:
+ {
+ uint64_t v;
+ union {
+ uint32_t u;
+ float f;
+ } f32;
+
+ read_unsigned_bitfield(buf, at, field_size, bo, &v);
+ f32.u = (uint32_t) v;
+ dblval = (double) f32.f;
+ break;
+ }
+ case 64:
+ {
+ union {
+ uint64_t u;
+ double d;
+ } f64;
+
+ read_unsigned_bitfield(buf, at, field_size, bo, &f64.u);
+ dblval = f64.d;
+ break;
+ }
+ default:
+ /* Only 32-bit and 64-bit fields are supported currently */
+ abort();
+ }
+
+ BT_LOGV("Read floating point number value: bfcr=%p, cur=%zu, val=%f",
+ bfcr, at, dblval);
+
+ if (bfcr->user.cbs.classes.floating_point) {
+ BT_LOGV("Calling user function (floating point number).");
+ status = bfcr->user.cbs.classes.floating_point(dblval,
+ bfcr->cur_basic_field_class, bfcr->user.data);
+ BT_LOGV("User function returned: status=%s",
+ bt_bfcr_status_string(status));
+ if (status != BT_BFCR_STATUS_OK) {
+ BT_LOGW("User function failed: bfcr-addr=%p, status=%s",
+ bfcr, bt_bfcr_status_string(status));
+ }
+ }
+
+ return status;
+}
+
+static inline
+enum bt_bfcr_status read_basic_int_and_call_cb(struct bt_bfcr *bfcr,
+ const uint8_t *buf, size_t at)
+{
+ unsigned int field_size;
+ enum ctf_byte_order bo;
+ enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
+ struct ctf_field_class_int *fc = (void *) bfcr->cur_basic_field_class;
+
+ field_size = fc->base.size;
+ bo = fc->base.byte_order;
+
+ /*
+ * Update current byte order now because we could be reading
+ * the integer value of an enumeration class, and thus we know
+ * here the actual supporting integer class's byte order.
+ */
+ bfcr->cur_bo = bo;
+
+ if (fc->is_signed) {
+ int64_t v;
+
+ read_signed_bitfield(buf, at, field_size, bo, &v);
+
+ if (bfcr->user.cbs.classes.signed_int) {
+ BT_LOGV("Calling user function (signed integer).");
+ status = bfcr->user.cbs.classes.signed_int(v,
+ bfcr->cur_basic_field_class, bfcr->user.data);
+ BT_LOGV("User function returned: status=%s",
+ bt_bfcr_status_string(status));
+ if (status != BT_BFCR_STATUS_OK) {
+ BT_LOGW("User function failed: "
+ "bfcr-addr=%p, status=%s",
+ bfcr, bt_bfcr_status_string(status));
+ }
+ }
+ } else {
+ uint64_t v;
+
+ read_unsigned_bitfield(buf, at, field_size, bo, &v);
+
+ if (bfcr->user.cbs.classes.unsigned_int) {
+ BT_LOGV("Calling user function (unsigned integer).");
+ status = bfcr->user.cbs.classes.unsigned_int(v,
+ bfcr->cur_basic_field_class, bfcr->user.data);
+ BT_LOGV("User function returned: status=%s",
+ bt_bfcr_status_string(status));
+ if (status != BT_BFCR_STATUS_OK) {
+ BT_LOGW("User function failed: "
+ "bfcr-addr=%p, status=%s",
+ bfcr, bt_bfcr_status_string(status));
+ }
+ }
+ }
+
+ return status;
+}
+
+static inline
+enum bt_bfcr_status read_bit_array_class_and_call_continue(struct bt_bfcr *bfcr,
+ read_basic_and_call_cb_t read_basic_and_call_cb)
+{
+ size_t available;
+ size_t needed_bits;
+ enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
+ struct ctf_field_class_bit_array *fc =
+ (void *) bfcr->cur_basic_field_class;
+
+ if (!at_least_one_bit_left(bfcr)) {
+ BT_LOGV("Reached end of data: bfcr-addr=%p", bfcr);
+ status = BT_BFCR_STATUS_EOF;
+ goto end;
+ }
+
+ available = available_bits(bfcr);
+ needed_bits = fc->size - bfcr->stitch.at;
+ BT_LOGV("Continuing basic field decoding: "
+ "bfcr-addr=%p, field-size=%u, needed-size=%" PRId64 ", "
+ "available-size=%zu",
+ bfcr, fc->size, needed_bits, available);
+ if (needed_bits <= available) {
+ /* We have all the bits; append to stitch, then decode */
+ stitch_append_from_buf(bfcr, needed_bits);
+ status = read_basic_and_call_cb(bfcr, bfcr->stitch.buf,
+ bfcr->stitch.offset);
+ if (status != BT_BFCR_STATUS_OK) {
+ BT_LOGW("Cannot read basic field: "
+ "bfcr-addr=%p, fc-addr=%p, status=%s",
+ bfcr, bfcr->cur_basic_field_class,
+ bt_bfcr_status_string(status));
+ goto end;
+ }
+
+ if (stack_empty(bfcr->stack)) {
+ /* Root is a basic class */
+ bfcr->state = BFCR_STATE_DONE;
+ } else {
+ /* Go to next field */
+ stack_top(bfcr->stack)->index++;
+ bfcr->state = BFCR_STATE_NEXT_FIELD;
+ bfcr->last_bo = bfcr->cur_bo;
+ }
+ goto end;
+ }
+
+ /* We are here; it means we don't have enough data to decode this */
+ BT_LOGV_STR("Not enough data to read the next basic field: appending to stitch buffer.");
+ stitch_append_from_remaining_buf(bfcr);
+ status = BT_BFCR_STATUS_EOF;
+
+end:
+ return status;
+}
+
+static inline
+enum bt_bfcr_status read_bit_array_class_and_call_begin(struct bt_bfcr *bfcr,
+ read_basic_and_call_cb_t read_basic_and_call_cb)
+{
+ size_t available;
+ enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
+ struct ctf_field_class_bit_array *fc =
+ (void *) bfcr->cur_basic_field_class;
+
+ if (!at_least_one_bit_left(bfcr)) {
+ BT_LOGV("Reached end of data: bfcr-addr=%p", bfcr);
+ status = BT_BFCR_STATUS_EOF;
+ goto end;
+ }
+
+ status = validate_contiguous_bo(bfcr, fc->byte_order);
+ if (status != BT_BFCR_STATUS_OK) {
+ /* validate_contiguous_bo() logs errors */
+ goto end;
+ }
+
+ available = available_bits(bfcr);
+
+ if (fc->size <= available) {
+ /* We have all the bits; decode and set now */
+ BT_ASSERT(bfcr->buf.addr);
+ status = read_basic_and_call_cb(bfcr, bfcr->buf.addr,
+ buf_at_from_addr(bfcr));
+ if (status != BT_BFCR_STATUS_OK) {
+ BT_LOGW("Cannot read basic field: "
+ "bfcr-addr=%p, fc-addr=%p, status=%s",
+ bfcr, bfcr->cur_basic_field_class,
+ bt_bfcr_status_string(status));
+ goto end;
+ }
+
+ consume_bits(bfcr, fc->size);
+
+ if (stack_empty(bfcr->stack)) {
+ /* Root is a basic class */
+ bfcr->state = BFCR_STATE_DONE;
+ } else {
+ /* Go to next field */
+ stack_top(bfcr->stack)->index++;
+ bfcr->state = BFCR_STATE_NEXT_FIELD;
+ bfcr->last_bo = bfcr->cur_bo;
+ }
+
+ goto end;
+ }
+
+ /* We are here; it means we don't have enough data to decode this */
+ BT_LOGV_STR("Not enough data to read the next basic field: setting stitch buffer.");
+ stitch_set_from_remaining_buf(bfcr);
+ bfcr->state = BFCR_STATE_READ_BASIC_CONTINUE;
+ status = BT_BFCR_STATUS_EOF;
+
+end:
+ return status;
+}
+
+static inline
+enum bt_bfcr_status read_basic_int_class_and_call_begin(
+ struct bt_bfcr *bfcr)
+{
+ return read_bit_array_class_and_call_begin(bfcr, read_basic_int_and_call_cb);
+}
+
+static inline
+enum bt_bfcr_status read_basic_int_class_and_call_continue(
+ struct bt_bfcr *bfcr)
+{
+ return read_bit_array_class_and_call_continue(bfcr,
+ read_basic_int_and_call_cb);
+}
+
+static inline
+enum bt_bfcr_status read_basic_float_class_and_call_begin(
+ struct bt_bfcr *bfcr)
+{
+ return read_bit_array_class_and_call_begin(bfcr,
+ read_basic_float_and_call_cb);
+}
+
+static inline
+enum bt_bfcr_status read_basic_float_class_and_call_continue(
+ struct bt_bfcr *bfcr)
+{
+ return read_bit_array_class_and_call_continue(bfcr,
+ read_basic_float_and_call_cb);
+}
+
+static inline
+enum bt_bfcr_status read_basic_string_class_and_call(
+ struct bt_bfcr *bfcr, bool begin)
+{
+ size_t buf_at_bytes;
+ const uint8_t *result;
+ size_t available_bytes;
+ const uint8_t *first_chr;
+ enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
+
+ if (!at_least_one_bit_left(bfcr)) {
+ BT_LOGV("Reached end of data: bfcr-addr=%p", bfcr);
+ status = BT_BFCR_STATUS_EOF;
+ goto end;
+ }
+
+ BT_ASSERT(buf_at_from_addr(bfcr) % 8 == 0);
+ available_bytes = BITS_TO_BYTES_FLOOR(available_bits(bfcr));
+ buf_at_bytes = BITS_TO_BYTES_FLOOR(buf_at_from_addr(bfcr));
+ BT_ASSERT(bfcr->buf.addr);
+ first_chr = &bfcr->buf.addr[buf_at_bytes];
+ result = memchr(first_chr, '\0', available_bytes);
+
+ if (begin && bfcr->user.cbs.classes.string_begin) {
+ BT_LOGV("Calling user function (string, beginning).");
+ status = bfcr->user.cbs.classes.string_begin(
+ bfcr->cur_basic_field_class, bfcr->user.data);
+ BT_LOGV("User function returned: status=%s",
+ bt_bfcr_status_string(status));
+ if (status != BT_BFCR_STATUS_OK) {
+ BT_LOGW("User function failed: bfcr-addr=%p, status=%s",
+ bfcr, bt_bfcr_status_string(status));
+ goto end;
+ }
+ }
+
+ if (!result) {
+ /* No null character yet */
+ if (bfcr->user.cbs.classes.string) {
+ BT_LOGV("Calling user function (substring).");
+ status = bfcr->user.cbs.classes.string(
+ (const char *) first_chr,
+ available_bytes, bfcr->cur_basic_field_class,
+ bfcr->user.data);
+ BT_LOGV("User function returned: status=%s",
+ bt_bfcr_status_string(status));
+ if (status != BT_BFCR_STATUS_OK) {
+ BT_LOGW("User function failed: "
+ "bfcr-addr=%p, status=%s",
+ bfcr, bt_bfcr_status_string(status));
+ goto end;
+ }
+ }
+
+ consume_bits(bfcr, BYTES_TO_BITS(available_bytes));
+ bfcr->state = BFCR_STATE_READ_BASIC_CONTINUE;
+ status = BT_BFCR_STATUS_EOF;
+ } else {
+ /* Found the null character */
+ size_t result_len = (size_t) (result - first_chr);
+
+ if (bfcr->user.cbs.classes.string && result_len) {
+ BT_LOGV("Calling user function (substring).");
+ status = bfcr->user.cbs.classes.string(
+ (const char *) first_chr,
+ result_len, bfcr->cur_basic_field_class,
+ bfcr->user.data);
+ BT_LOGV("User function returned: status=%s",
+ bt_bfcr_status_string(status));
+ if (status != BT_BFCR_STATUS_OK) {
+ BT_LOGW("User function failed: "
+ "bfcr-addr=%p, status=%s",
+ bfcr, bt_bfcr_status_string(status));
+ goto end;
+ }
+ }
+
+ if (bfcr->user.cbs.classes.string_end) {
+ BT_LOGV("Calling user function (string, end).");
+ status = bfcr->user.cbs.classes.string_end(
+ bfcr->cur_basic_field_class, bfcr->user.data);
+ BT_LOGV("User function returned: status=%s",
+ bt_bfcr_status_string(status));
+ if (status != BT_BFCR_STATUS_OK) {
+ BT_LOGW("User function failed: "
+ "bfcr-addr=%p, status=%s",
+ bfcr, bt_bfcr_status_string(status));
+ goto end;
+ }
+ }
+
+ consume_bits(bfcr, BYTES_TO_BITS(result_len + 1));
+
+ if (stack_empty(bfcr->stack)) {
+ /* Root is a basic class */
+ bfcr->state = BFCR_STATE_DONE;
+ } else {
+ /* Go to next field */
+ stack_top(bfcr->stack)->index++;
+ bfcr->state = BFCR_STATE_NEXT_FIELD;
+ bfcr->last_bo = bfcr->cur_bo;
+ }
+ }
+
+end:
+ return status;
+}
+
+static inline
+enum bt_bfcr_status read_basic_begin_state(struct bt_bfcr *bfcr)
+{
+ enum bt_bfcr_status status;
+
+ BT_ASSERT(bfcr->cur_basic_field_class);
+
+ switch (bfcr->cur_basic_field_class->id) {
+ case CTF_FIELD_CLASS_ID_INT:
+ case CTF_FIELD_CLASS_ID_ENUM:
+ status = read_basic_int_class_and_call_begin(bfcr);
+ break;
+ case CTF_FIELD_CLASS_ID_FLOAT:
+ status = read_basic_float_class_and_call_begin(bfcr);
+ break;
+ case CTF_FIELD_CLASS_ID_STRING:
+ status = read_basic_string_class_and_call(bfcr, true);
+ break;
+ default:
+ abort();
+ }
+
+ return status;
+}
+
+static inline
+enum bt_bfcr_status read_basic_continue_state(struct bt_bfcr *bfcr)
+{
+ enum bt_bfcr_status status;
+
+ BT_ASSERT(bfcr->cur_basic_field_class);
+
+ switch (bfcr->cur_basic_field_class->id) {
+ case CTF_FIELD_CLASS_ID_INT:
+ case CTF_FIELD_CLASS_ID_ENUM:
+ status = read_basic_int_class_and_call_continue(bfcr);
+ break;
+ case CTF_FIELD_CLASS_ID_FLOAT:
+ status = read_basic_float_class_and_call_continue(bfcr);
+ break;
+ case CTF_FIELD_CLASS_ID_STRING:
+ status = read_basic_string_class_and_call(bfcr, false);
+ break;
+ default:
+ abort();
+ }
+
+ return status;
+}
+
+static inline
+size_t bits_to_skip_to_align_to(struct bt_bfcr *bfcr, size_t align)
+{
+ size_t aligned_packet_at;
+
+ aligned_packet_at = ALIGN(packet_at(bfcr), align);
+ return aligned_packet_at - packet_at(bfcr);
+}
+
+static inline
+enum bt_bfcr_status align_class_state(struct bt_bfcr *bfcr,
+ struct ctf_field_class *field_class, enum bfcr_state next_state)
+{
+ unsigned int field_alignment;
+ size_t skip_bits;
+ enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
+
+ /* Get field's alignment */
+ field_alignment = field_class->alignment;
+
+ /*
+ * 0 means "undefined" for variants; what we really want is 1
+ * (always aligned)
+ */
+ BT_ASSERT(field_alignment >= 1);
+
+ /* Compute how many bits we need to skip */
+ skip_bits = bits_to_skip_to_align_to(bfcr, (size_t) field_alignment);
+
+ /* Nothing to skip? aligned */
+ if (skip_bits == 0) {
+ bfcr->state = next_state;
+ goto end;
+ }
+
+ /* Make sure there's at least one bit left */
+ if (!at_least_one_bit_left(bfcr)) {
+ status = BT_BFCR_STATUS_EOF;
+ goto end;
+ }
+
+ /* Consume as many bits as possible in what's left */
+ consume_bits(bfcr, MIN(available_bits(bfcr), skip_bits));
+
+ /* Are we done now? */
+ skip_bits = bits_to_skip_to_align_to(bfcr, field_alignment);
+ if (skip_bits == 0) {
+ /* Yes: go to next state */
+ bfcr->state = next_state;
+ goto end;
+ } else {
+ /* No: need more data */
+ BT_LOGV("Reached end of data when aligning: bfcr-addr=%p", bfcr);
+ status = BT_BFCR_STATUS_EOF;
+ }
+
+end:
+ return status;
+}
+
+static inline
+enum bt_bfcr_status next_field_state(struct bt_bfcr *bfcr)
+{
+ int ret;
+ struct stack_entry *top;
+ struct ctf_field_class *next_field_class = NULL;
+ enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
+
+ if (stack_empty(bfcr->stack)) {
+ goto end;
+ }
+
+ top = stack_top(bfcr->stack);
+
+ /* Are we done with this base class? */
+ while (top->index == top->base_len) {
+ if (bfcr->user.cbs.classes.compound_end) {
+ BT_LOGV("Calling user function (compound, end).");
+ status = bfcr->user.cbs.classes.compound_end(
+ top->base_class, bfcr->user.data);
+ BT_LOGV("User function returned: status=%s",
+ bt_bfcr_status_string(status));
+ if (status != BT_BFCR_STATUS_OK) {
+ BT_LOGW("User function failed: bfcr-addr=%p, status=%s",
+ bfcr, bt_bfcr_status_string(status));
+ goto end;
+ }
+ }
+
+ stack_pop(bfcr->stack);
+
+ /* Are we done with the root class? */
+ if (stack_empty(bfcr->stack)) {
+ bfcr->state = BFCR_STATE_DONE;
+ goto end;
+ }
+
+ top = stack_top(bfcr->stack);
+ top->index++;
+ }
+
+ /* Get next field's class */
+ switch (top->base_class->id) {
+ case CTF_FIELD_CLASS_ID_STRUCT:
+ next_field_class = ctf_field_class_struct_borrow_member_by_index(
+ (void *) top->base_class, (uint64_t) top->index)->fc;
+ break;
+ case CTF_FIELD_CLASS_ID_ARRAY:
+ case CTF_FIELD_CLASS_ID_SEQUENCE:
+ {
+ struct ctf_field_class_array_base *array_fc =
+ (void *) top->base_class;
+
+ next_field_class = array_fc->elem_fc;
+ break;
+ }
+ case CTF_FIELD_CLASS_ID_VARIANT:
+ /* Variant classes are dynamic: the user should know! */
+ next_field_class =
+ bfcr->user.cbs.query.borrow_variant_selected_field_class(
+ top->base_class, bfcr->user.data);
+ break;
+ default:
+ break;
+ }
+
+ if (!next_field_class) {
+ BT_LOGW("Cannot get the field class of the next field: "
+ "bfcr-addr=%p, base-fc-addr=%p, base-fc-id=%d, "
+ "index=%" PRId64,
+ bfcr, top->base_class, top->base_class->id, top->index);
+ status = BT_BFCR_STATUS_ERROR;
+ goto end;
+ }
+
+ if (next_field_class->is_compound) {
+ if (bfcr->user.cbs.classes.compound_begin) {
+ BT_LOGV("Calling user function (compound, begin).");
+ status = bfcr->user.cbs.classes.compound_begin(
+ next_field_class, bfcr->user.data);
+ BT_LOGV("User function returned: status=%s",
+ bt_bfcr_status_string(status));
+ if (status != BT_BFCR_STATUS_OK) {
+ BT_LOGW("User function failed: bfcr-addr=%p, status=%s",
+ bfcr, bt_bfcr_status_string(status));
+ goto end;
+ }
+ }
+
+ ret = stack_push_with_len(bfcr, next_field_class);
+ if (ret) {
+ /* stack_push_with_len() logs errors */
+ status = BT_BFCR_STATUS_ERROR;
+ goto end;
+ }
+
+ /* Next state: align a compound class */
+ bfcr->state = BFCR_STATE_ALIGN_COMPOUND;
+ } else {
+ /* Replace current basic field class */
+ BT_LOGV("Replacing current basic field class: "
+ "bfcr-addr=%p, cur-basic-fc-addr=%p, "
+ "next-basic-fc-addr=%p",
+ bfcr, bfcr->cur_basic_field_class, next_field_class);
+ bfcr->cur_basic_field_class = next_field_class;
+
+ /* Next state: align a basic class */
+ bfcr->state = BFCR_STATE_ALIGN_BASIC;
+ }
+
+end:
+ return status;
+}
+
+static inline
+enum bt_bfcr_status handle_state(struct bt_bfcr *bfcr)
+{
+ enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
+
+ BT_LOGV("Handling state: bfcr-addr=%p, state=%s",
+ bfcr, bfcr_state_string(bfcr->state));
+
+ switch (bfcr->state) {
+ case BFCR_STATE_NEXT_FIELD:
+ status = next_field_state(bfcr);
+ break;
+ case BFCR_STATE_ALIGN_BASIC:
+ status = align_class_state(bfcr, bfcr->cur_basic_field_class,
+ BFCR_STATE_READ_BASIC_BEGIN);
+ break;
+ case BFCR_STATE_ALIGN_COMPOUND:
+ status = align_class_state(bfcr, stack_top(bfcr->stack)->base_class,
+ BFCR_STATE_NEXT_FIELD);
+ break;
+ case BFCR_STATE_READ_BASIC_BEGIN:
+ status = read_basic_begin_state(bfcr);
+ break;
+ case BFCR_STATE_READ_BASIC_CONTINUE:
+ status = read_basic_continue_state(bfcr);
+ break;
+ case BFCR_STATE_DONE:
+ break;
+ }
+
+ BT_LOGV("Handled state: bfcr-addr=%p, status=%s",
+ bfcr, bt_bfcr_status_string(status));
+ return status;
+}
+
+BT_HIDDEN
+struct bt_bfcr *bt_bfcr_create(struct bt_bfcr_cbs cbs, void *data)
+{
+ struct bt_bfcr *bfcr;
+
+ BT_LOGD_STR("Creating binary class reader (BFCR).");
+ bfcr = g_new0(struct bt_bfcr, 1);
+ if (!bfcr) {
+ BT_LOGE_STR("Failed to allocate one binary class reader.");
+ goto end;
+ }
+
+ bfcr->stack = stack_new();
+ if (!bfcr->stack) {
+ BT_LOGE_STR("Cannot create BFCR's stack.");
+ bt_bfcr_destroy(bfcr);
+ bfcr = NULL;
+ goto end;
+ }
+
+ bfcr->state = BFCR_STATE_NEXT_FIELD;
+ bfcr->user.cbs = cbs;
+ bfcr->user.data = data;
+ BT_LOGD("Created BFCR: addr=%p", bfcr);
+
+end:
+ return bfcr;
+}
+
+BT_HIDDEN
+void bt_bfcr_destroy(struct bt_bfcr *bfcr)
+{
+ if (bfcr->stack) {
+ stack_destroy(bfcr->stack);
+ }
+
+ BT_LOGD("Destroying BFCR: addr=%p", bfcr);
+ g_free(bfcr);
+}
+
+static
+void reset(struct bt_bfcr *bfcr)
+{
+ BT_LOGD("Resetting BFCR: addr=%p", bfcr);
+ stack_clear(bfcr->stack);
+ stitch_reset(bfcr);
+ bfcr->buf.addr = NULL;
+ bfcr->last_bo = -1;
+}
+
+static
+void update_packet_offset(struct bt_bfcr *bfcr)
+{
+ BT_LOGV("Updating packet offset for next call: "
+ "bfcr-addr=%p, cur-packet-offset=%zu, next-packet-offset=%zu",
+ bfcr, bfcr->buf.packet_offset,
+ bfcr->buf.packet_offset + bfcr->buf.at);
+ bfcr->buf.packet_offset += bfcr->buf.at;
+}
+
+BT_HIDDEN
+size_t bt_bfcr_start(struct bt_bfcr *bfcr,
+ struct ctf_field_class *cls, const uint8_t *buf,
+ size_t offset, size_t packet_offset, size_t sz,
+ enum bt_bfcr_status *status)
+{
+ BT_ASSERT(bfcr);
+ BT_ASSERT(BYTES_TO_BITS(sz) >= offset);
+ reset(bfcr);
+ bfcr->buf.addr = buf;
+ bfcr->buf.offset = offset;
+ bfcr->buf.at = 0;
+ bfcr->buf.packet_offset = packet_offset;
+ bfcr->buf.buf_sz = sz;
+ bfcr->buf.sz = BYTES_TO_BITS(sz) - offset;
+ *status = BT_BFCR_STATUS_OK;
+
+ BT_LOGV("Starting decoding: bfcr-addr=%p, fc-addr=%p, "
+ "buf-addr=%p, buf-size=%zu, offset=%zu, "
+ "packet-offset=%zu",
+ bfcr, cls, buf, sz, offset, packet_offset);
+
+ /* Set root class */
+ if (cls->is_compound) {
+ /* Compound class: push on visit stack */
+ int stack_ret;
+
+ if (bfcr->user.cbs.classes.compound_begin) {
+ BT_LOGV("Calling user function (compound, begin).");
+ *status = bfcr->user.cbs.classes.compound_begin(
+ cls, bfcr->user.data);
+ BT_LOGV("User function returned: status=%s",
+ bt_bfcr_status_string(*status));
+ if (*status != BT_BFCR_STATUS_OK) {
+ BT_LOGW("User function failed: bfcr-addr=%p, status=%s",
+ bfcr, bt_bfcr_status_string(*status));
+ goto end;
+ }
+ }
+
+ stack_ret = stack_push_with_len(bfcr, cls);
+ if (stack_ret) {
+ /* stack_push_with_len() logs errors */
+ *status = BT_BFCR_STATUS_ERROR;
+ goto end;
+ }
+
+ bfcr->state = BFCR_STATE_ALIGN_COMPOUND;
+ } else {
+ /* Basic class: set as current basic class */
+ bfcr->cur_basic_field_class = cls;
+ bfcr->state = BFCR_STATE_ALIGN_BASIC;
+ }
+
+ /* Run the machine! */
+ BT_LOGV_STR("Running the state machine.");
+
+ while (true) {
+ *status = handle_state(bfcr);
+ if (*status != BT_BFCR_STATUS_OK ||
+ bfcr->state == BFCR_STATE_DONE) {
+ break;
+ }
+ }
+
+ /* Update packet offset for next time */
+ update_packet_offset(bfcr);
+
+end:
+ return bfcr->buf.at;
+}
+
+BT_HIDDEN
+size_t bt_bfcr_continue(struct bt_bfcr *bfcr, const uint8_t *buf, size_t sz,
+ enum bt_bfcr_status *status)
+{
+ BT_ASSERT(bfcr);
+ BT_ASSERT(buf);
+ BT_ASSERT(sz > 0);
+ bfcr->buf.addr = buf;
+ bfcr->buf.offset = 0;
+ bfcr->buf.at = 0;
+ bfcr->buf.buf_sz = sz;
+ bfcr->buf.sz = BYTES_TO_BITS(sz);
+ *status = BT_BFCR_STATUS_OK;
+
+ BT_LOGV("Continuing decoding: bfcr-addr=%p, buf-addr=%p, buf-size=%zu",
+ bfcr, buf, sz);
+
+ /* Continue running the machine */
+ BT_LOGV_STR("Running the state machine.");
+
+ while (true) {
+ *status = handle_state(bfcr);
+ if (*status != BT_BFCR_STATUS_OK ||
+ bfcr->state == BFCR_STATE_DONE) {
+ break;
+ }
+ }
+
+ /* Update packet offset for next time */
+ update_packet_offset(bfcr);
+ return bfcr->buf.at;
+}
+
+BT_HIDDEN
+void bt_bfcr_set_unsigned_int_cb(struct bt_bfcr *bfcr,
+ bt_bfcr_unsigned_int_cb_func cb)
+{
+ BT_ASSERT(bfcr);
+ BT_ASSERT(cb);
+ bfcr->user.cbs.classes.unsigned_int = cb;
+}
--- /dev/null
+#ifndef CTF_BFCR_H
+#define CTF_BFCR_H
+
+/*
+ * Babeltrace - CTF binary field class reader (BFCR)
+ *
+ * Copyright (c) 2015-2016 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2015-2016 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.
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
+
+#include "../metadata/ctf-meta.h"
+
+/**
+ * @file bfcr.h
+ *
+ * Event-driven CTF binary field class reader (BFCR).
+ *
+ * This is a common, internal API used by CTF source plugins. It allows
+ * a binary CTF IR field class to be decoded from user-provided buffers.
+ * As the class is decoded (and, possibly, its nested classes),
+ * registered user callback functions are called.
+ *
+ * This API is only concerned with reading one CTF class at a time from
+ * one or more buffer of bytes. It does not know CTF dynamic scopes,
+ * events, or streams. Sequence lengths and selected variant classes are
+ * requested to the user when needed.
+ */
+
+/**
+ * Binary class reader API status codes.
+ */
+enum bt_bfcr_status {
+ /** Out of memory. */
+ BT_BFCR_STATUS_ENOMEM = -5,
+ /**
+ * The binary stream reader reached the end of the user-provided
+ * buffer, but data is still needed to finish decoding the
+ * requested class.
+ *
+ * The user needs to call bt_bfcr_continue() as long as
+ * #BT_BFCR_STATUS_EOF is returned to complete the decoding
+ * process of a given class.
+ */
+ BT_BFCR_STATUS_EOF = 1,
+
+ /** Invalid argument. */
+ BT_BFCR_STATUS_INVAL = -3,
+
+ /** General error. */
+ BT_BFCR_STATUS_ERROR = -1,
+
+ /** Everything okay. */
+ BT_BFCR_STATUS_OK = 0,
+};
+
+/** Field class reader. */
+struct bt_bfcr;
+
+typedef enum bt_bfcr_status (* bt_bfcr_unsigned_int_cb_func)(uint64_t,
+ struct ctf_field_class *, void *);
+
+/*
+ * Field class reader user callback functions.
+ */
+struct bt_bfcr_cbs {
+ /**
+ * Field class callback functions.
+ *
+ * This CTF binary class reader is event-driven. The following
+ * functions are called during the decoding process, either when
+ * a compound class begins/ends, or when a basic class is
+ * completely decoded (along with its value).
+ *
+ * Each function also receives the CTF field class associated
+ * with the call, and user data (registered to the class reader
+ * calling them).
+ *
+ * Actual trace IR fields are \em not created here; this would
+ * be the responsibility of a class reader's user (the provider
+ * of those callback functions).
+ *
+ * All the class callback functions return one of the following
+ * values:
+ *
+ * - <b>#BT_BFCR_STATUS_OK</b>: Everything is okay;
+ * continue the decoding process.
+ * - <b>#BT_BFCR_STATUS_ERROR</b>: General error (reported
+ * to class reader's user).
+ *
+ * Any member of this structure may be set to \c NULL, should
+ * a specific notification be not needed.
+ */
+ struct {
+ /**
+ * Called when a signed integer class is completely
+ * decoded. This could also be the supporting signed
+ * integer class of an enumeration class (\p class will
+ * indicate this).
+ *
+ * @param value Signed integer value
+ * @param class Integer or enumeration class
+ * @param data User data
+ * @returns #BT_BFCR_STATUS_OK or
+ * #BT_BFCR_STATUS_ERROR
+ */
+ enum bt_bfcr_status (* signed_int)(int64_t value,
+ struct ctf_field_class *cls, void *data);
+
+ /**
+ * Called when an unsigned integer class is completely
+ * decoded. This could also be the supporting signed
+ * integer class of an enumeration class (\p class will
+ * indicate this).
+ *
+ * @param value Unsigned integer value
+ * @param class Integer or enumeration class
+ * @param data User data
+ * @returns #BT_BFCR_STATUS_OK or
+ * #BT_BFCR_STATUS_ERROR
+ */
+ bt_bfcr_unsigned_int_cb_func unsigned_int;
+
+ /**
+ * Called when a floating point number class is
+ * completely decoded.
+ *
+ * @param value Floating point number value
+ * @param class Floating point number class
+ * @param data User data
+ * @returns #BT_BFCR_STATUS_OK or
+ * #BT_BFCR_STATUS_ERROR
+ */
+ enum bt_bfcr_status (* floating_point)(double value,
+ struct ctf_field_class *cls, void *data);
+
+ /**
+ * Called when a string class begins.
+ *
+ * All the following user callback function calls will
+ * be made to bt_bfcr_cbs::classes::string(), each of
+ * them providing one substring of the complete string
+ * class's value.
+ *
+ * @param class Beginning string class
+ * @param data User data
+ * @returns #BT_BFCR_STATUS_OK or
+ * #BT_BFCR_STATUS_ERROR
+ */
+ enum bt_bfcr_status (* string_begin)(
+ struct ctf_field_class *cls, void *data);
+
+ /**
+ * Called when a string class's substring is decoded
+ * (between a call to bt_bfcr_cbs::classes::string_begin()
+ * and a call to bt_bfcr_cbs::classes::string_end()).
+ *
+ * @param value String value (\em not null-terminated)
+ * @param len String value length
+ * @param class String class
+ * @param data User data
+ * @returns #BT_BFCR_STATUS_OK or
+ * #BT_BFCR_STATUS_ERROR
+ */
+ enum bt_bfcr_status (* string)(const char *value,
+ size_t len, struct ctf_field_class *cls,
+ void *data);
+
+ /**
+ * Called when a string class ends.
+ *
+ * @param class Ending string class
+ * @param data User data
+ * @returns #BT_BFCR_STATUS_OK or
+ * #BT_BFCR_STATUS_ERROR
+ */
+ enum bt_bfcr_status (* string_end)(
+ struct ctf_field_class *cls, void *data);
+
+ /**
+ * Called when a compound class begins.
+ *
+ * All the following class callback function calls will
+ * signal sequential elements of this compound class,
+ * until the next corresponding
+ * bt_bfcr_cbs::classes::compound_end() is called.
+ *
+ * If \p class is a variant class, then only one class
+ * callback function call will follow before the call to
+ * bt_bfcr_cbs::classes::compound_end(). This single
+ * call indicates the selected class of this variant
+ * class.
+ *
+ * @param class Beginning compound class
+ * @param data User data
+ * @returns #BT_BFCR_STATUS_OK or
+ * #BT_BFCR_STATUS_ERROR
+ */
+ enum bt_bfcr_status (* compound_begin)(
+ struct ctf_field_class *cls, void *data);
+
+ /**
+ * Called when a compound class ends.
+ *
+ * @param class Ending compound class
+ * @param data User data
+ * @returns #BT_BFCR_STATUS_OK or
+ * #BT_BFCR_STATUS_ERROR
+ */
+ enum bt_bfcr_status (* compound_end)(
+ struct ctf_field_class *cls, void *data);
+ } classes;
+
+ /**
+ * Query callback functions are used when the class reader needs
+ * dynamic information, i.e. a sequence class's current length
+ * or a variant class's current selected class.
+ *
+ * Both functions need to be set unless it is known that no
+ * sequences or variants will have to be decoded.
+ */
+ struct {
+ /**
+ * Called to query the current length of a given sequence
+ * class.
+ *
+ * @param class Sequence class
+ * @param data User data
+ * @returns Sequence length or
+ * #BT_BFCR_STATUS_ERROR on error
+ */
+ int64_t (* get_sequence_length)(struct ctf_field_class *cls,
+ void *data);
+
+ /**
+ * Called to query the current selected class of a given
+ * variant class.
+ *
+ * @param class Variant class
+ * @param data User data
+ * @returns Current selected class (owned by
+ * this) or \c NULL on error
+ */
+ struct ctf_field_class * (* borrow_variant_selected_field_class)(
+ struct ctf_field_class *cls, void *data);
+ } query;
+};
+
+/**
+ * Creates a CTF binary class reader.
+ *
+ * @param cbs User callback functions
+ * @param data User data (passed to user callback functions)
+ * @returns New binary class reader on success, or \c NULL on error
+ */
+BT_HIDDEN
+struct bt_bfcr *bt_bfcr_create(struct bt_bfcr_cbs cbs, void *data);
+
+/**
+ * Destroys a CTF binary class reader, freeing all internal resources.
+ *
+ * @param bfcr Binary class reader
+ */
+BT_HIDDEN
+void bt_bfcr_destroy(struct bt_bfcr *bfcr);
+
+/**
+ * Decodes a given CTF class from a buffer of bytes.
+ *
+ * The number of \em bits consumed by this function is returned.
+ *
+ * The \p status output parameter is where a status is written, amongst
+ * the following:
+ *
+ * - <b>#BT_BFCR_STATUS_OK</b>: Decoding is done.
+ * - <b>#BT_BFCR_STATUS_EOF</b>: The end of the buffer was reached,
+ * but more data is needed to finish the decoding process of the
+ * requested class. The user needs to call bt_bfcr_continue()
+ * as long as #BT_BFCR_STATUS_EOF is returned to complete the
+ * decoding process of the original class.
+ * - <b>#BT_BFCR_STATUS_INVAL</b>: Invalid argument.
+ * - <b>#BT_BFCR_STATUS_ERROR</b>: General error.
+ *
+ * Calling this function resets the class reader's internal state. If
+ * #BT_BFCR_STATUS_EOF is returned, bt_bfcr_continue() needs to
+ * be called next, \em not bt_bfcr_decode().
+ *
+ * @param bfcr Binary class reader
+ * @param class Field class to decode
+ * @param buf Buffer
+ * @param offset Offset of first bit from \p buf (bits)
+ * @param packet_offset Offset of \p offset within the CTF
+ * binary packet containing \p class (bits)
+ * @param sz Size of buffer in bytes (from \p buf)
+ * @param status Returned status (see description above)
+ * @returns Number of consumed bits
+ */
+BT_HIDDEN
+size_t bt_bfcr_start(struct bt_bfcr *bfcr,
+ struct ctf_field_class *cls, const uint8_t *buf,
+ size_t offset, size_t packet_offset, size_t sz,
+ enum bt_bfcr_status *status);
+
+/**
+ * Continues the decoding process a given CTF class.
+ *
+ * The number of bits consumed by this function is returned.
+ *
+ * The \p status output parameter is where a status is placed, amongst
+ * the following:
+ *
+ * - <b>#BT_BFCR_STATUS_OK</b>: decoding is done.
+ * - <b>#BT_BFCR_STATUS_EOF</b>: the end of the buffer was reached,
+ * but more data is needed to finish the decoding process of the
+ * requested class. The user needs to call bt_bfcr_continue()
+ * as long as #BT_BFCR_STATUS_EOF is returned to complete the
+ * decoding process of the original class.
+ * - <b>#BT_BFCR_STATUS_INVAL</b>: invalid argument.
+ * - <b>#BT_BFCR_STATUS_ERROR</b>: general error.
+ *
+ * @param bfcr Binary class reader
+ * @param buf Buffer
+ * @param sz Size of buffer in bytes (from \p offset)
+ * @param status Returned status (see description above)
+ * @returns Number of consumed bits
+ */
+BT_HIDDEN
+size_t bt_bfcr_continue(struct bt_bfcr *bfcr,
+ const uint8_t *buf, size_t sz,
+ enum bt_bfcr_status *status);
+
+BT_HIDDEN
+void bt_bfcr_set_unsigned_int_cb(struct bt_bfcr *bfcr,
+ bt_bfcr_unsigned_int_cb_func cb);
+
+static inline
+const char *bt_bfcr_status_string(enum bt_bfcr_status status)
+{
+ switch (status) {
+ case BT_BFCR_STATUS_ENOMEM:
+ return "BT_BFCR_STATUS_ENOMEM";
+ case BT_BFCR_STATUS_EOF:
+ return "BT_BFCR_STATUS_EOF";
+ case BT_BFCR_STATUS_INVAL:
+ return "BT_BFCR_STATUS_INVAL";
+ case BT_BFCR_STATUS_ERROR:
+ return "BT_BFCR_STATUS_ERROR";
+ case BT_BFCR_STATUS_OK:
+ return "BT_BFCR_STATUS_OK";
+ default:
+ return "(unknown)";
+ }
+}
+
+#endif /* CTF_BFCR_H */
--- /dev/null
+define ctf-btr-show-stack
+ if (stack_empty($arg0))
+ printf "stack is empty!\n"
+ else
+ set $stack_size = stack_size($arg0)
+ set $stack_at = (int) ($stack_size - 1)
+ printf "%3s %10s %4s %3s\n", "pos", "base addr", "blen", "idx"
+
+ while ($stack_at >= 0)
+ set $stack_entry = (struct stack_entry *) g_ptr_array_index($arg0->entries, $stack_at)
+
+ if ($stack_at == $stack_size - 1)
+ printf "%3d %10p %3d %3d <-- top\n", $stack_at, \
+ $stack_entry->base_class, $stack_entry->base_len, \
+ $stack_entry->index
+ else
+ printf "%3d %10p %3d %3d\n", $stack_at, \
+ $stack_entry->base_class, $stack_entry->base_len, \
+ $stack_entry->index
+ end
+ set $stack_at = $stack_at - 1
+ end
+ end
+end
--- /dev/null
+/*
+ * Copyright (c) 2017 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_OUTPUT_LEVEL bfcr_log_level
+#include <babeltrace/logging-internal.h>
+
+BT_LOG_INIT_LOG_LEVEL(bfcr_log_level, "BABELTRACE_PLUGIN_CTF_BFCR_LOG_LEVEL");
--- /dev/null
+#ifndef CTF_BFCR_LOGGING_H
+#define CTF_BFCR_LOGGING_H
+
+/*
+ * Copyright (c) 2017 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_OUTPUT_LEVEL bfcr_log_level
+#include <babeltrace/logging-internal.h>
+
+BT_LOG_LEVEL_EXTERN_SYMBOL(bfcr_log_level);
+
+#endif /* CTF_BFCR_LOGGING_H */
+++ /dev/null
-noinst_LTLIBRARIES = libctf-btr.la
-libctf_btr_la_SOURCES = \
- btr.c \
- btr.h \
- logging.c \
- logging.h
+++ /dev/null
-/*
- * Babeltrace - CTF binary type reader (BTR)
- *
- * Copyright (c) 2015-2016 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2015-2016 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 "PLUGIN-CTF-BTR"
-#include "logging.h"
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <stdbool.h>
-#include <babeltrace/assert-internal.h>
-#include <string.h>
-#include <babeltrace/bitfield-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/ref.h>
-#include <babeltrace/align-internal.h>
-#include <glib.h>
-
-#include "btr.h"
-#include "../metadata/ctf-meta.h"
-
-#define DIV8(_x) ((_x) >> 3)
-#define BYTES_TO_BITS(_x) ((_x) * 8)
-#define BITS_TO_BYTES_FLOOR(_x) DIV8(_x)
-#define BITS_TO_BYTES_CEIL(_x) DIV8((_x) + 7)
-#define IN_BYTE_OFFSET(_at) ((_at) & 7)
-
-/* A visit stack entry */
-struct stack_entry {
- /*
- * Current type of base field, one of:
- *
- * * Structure
- * * Array
- * * Sequence
- * * Variant
- */
- struct ctf_field_type *base_type;
-
- /* Length of base field (always 1 for variant types) */
- int64_t base_len;
-
- /* Index of next field to read */
- int64_t index;
-};
-
-/* Visit stack */
-struct stack {
- /* Entries (struct stack_entry) */
- GArray *entries;
-
- /* Number of active entries */
- size_t size;
-};
-
-/* Reading states */
-enum btr_state {
- BTR_STATE_NEXT_FIELD,
- BTR_STATE_ALIGN_BASIC,
- BTR_STATE_ALIGN_COMPOUND,
- BTR_STATE_READ_BASIC_BEGIN,
- BTR_STATE_READ_BASIC_CONTINUE,
- BTR_STATE_DONE,
-};
-
-/* Binary type reader */
-struct bt_btr {
- /* Bisit stack */
- struct stack *stack;
-
- /* Current basic field type */
- struct ctf_field_type *cur_basic_field_type;
-
- /* Current state */
- enum btr_state state;
-
- /*
- * Last basic field type's byte order.
- *
- * This is used to detect errors since two contiguous basic
- * types for which the common boundary is not the boundary of
- * a byte cannot have different byte orders.
- *
- * This is set to -1 on reset and when the last basic field type
- * was a string type.
- */
- enum ctf_byte_order last_bo;
-
- /* Current byte order (copied to last_bo after a successful read) */
- enum ctf_byte_order cur_bo;
-
- /* Stitch buffer infos */
- struct {
- /* Stitch buffer */
- uint8_t buf[16];
-
- /* Offset, within stitch buffer, of first bit */
- size_t offset;
-
- /* Length (bits) of data in stitch buffer from offset */
- size_t at;
- } stitch;
-
- /* User buffer infos */
- struct {
- /* Address */
- const uint8_t *addr;
-
- /* Offset of data from address (bits) */
- size_t offset;
-
- /* Current position from offset (bits) */
- size_t at;
-
- /* Offset of offset within whole packet (bits) */
- size_t packet_offset;
-
- /* Data size in buffer (bits) */
- size_t sz;
-
- /* Buffer size (bytes) */
- size_t buf_sz;
- } buf;
-
- /* User stuff */
- struct {
- /* Callback functions */
- struct bt_btr_cbs cbs;
-
- /* Private data */
- void *data;
- } user;
-};
-
-static inline
-const char *btr_state_string(enum btr_state state)
-{
- switch (state) {
- case BTR_STATE_NEXT_FIELD:
- return "BTR_STATE_NEXT_FIELD";
- case BTR_STATE_ALIGN_BASIC:
- return "BTR_STATE_ALIGN_BASIC";
- case BTR_STATE_ALIGN_COMPOUND:
- return "BTR_STATE_ALIGN_COMPOUND";
- case BTR_STATE_READ_BASIC_BEGIN:
- return "BTR_STATE_READ_BASIC_BEGIN";
- case BTR_STATE_READ_BASIC_CONTINUE:
- return "BTR_STATE_READ_BASIC_CONTINUE";
- case BTR_STATE_DONE:
- return "BTR_STATE_DONE";
- default:
- return "(unknown)";
- }
-}
-
-static
-struct stack *stack_new(void)
-{
- struct stack *stack = NULL;
-
- stack = g_new0(struct stack, 1);
- if (!stack) {
- BT_LOGE_STR("Failed to allocate one stack.");
- goto error;
- }
-
- stack->entries = g_array_new(FALSE, TRUE, sizeof(struct stack_entry));
- if (!stack->entries) {
- BT_LOGE_STR("Failed to allocate a GArray.");
- goto error;
- }
-
- BT_LOGD("Created stack: addr=%p", stack);
- return stack;
-
-error:
- g_free(stack);
- return NULL;
-}
-
-static
-void stack_destroy(struct stack *stack)
-{
- if (!stack) {
- return;
- }
-
- BT_LOGD("Destroying stack: addr=%p", stack);
-
- if (stack->entries) {
- g_array_free(stack->entries, TRUE);
- }
-
- g_free(stack);
-}
-
-static
-int stack_push(struct stack *stack, struct ctf_field_type *base_type,
- size_t base_len)
-{
- struct stack_entry *entry;
-
- BT_ASSERT(stack);
- BT_ASSERT(base_type);
- BT_LOGV("Pushing field type on stack: stack-addr=%p, "
- "ft-addr=%p, ft-id=%d, base-length=%zu, "
- "stack-size-before=%zu, stack-size-after=%zu",
- stack, base_type, base_type->id,
- base_len, stack->size, stack->size + 1);
-
- if (stack->entries->len == stack->size) {
- g_array_set_size(stack->entries, stack->size + 1);
- }
-
- entry = &g_array_index(stack->entries, struct stack_entry, stack->size);
- entry->base_type = base_type;
- entry->base_len = base_len;
- entry->index = 0;
- stack->size++;
- return 0;
-}
-
-static inline
-int64_t get_compound_field_type_length(struct bt_btr *btr,
- struct ctf_field_type *ft)
-{
- int64_t length;
-
- switch (ft->id) {
- case CTF_FIELD_TYPE_ID_STRUCT:
- {
- struct ctf_field_type_struct *struct_ft = (void *) ft;
-
- length = (int64_t) struct_ft->members->len;
- break;
- }
- case CTF_FIELD_TYPE_ID_VARIANT:
- {
- /* Variant field types always "contain" a single type */
- length = 1;
- break;
- }
- case CTF_FIELD_TYPE_ID_ARRAY:
- {
- struct ctf_field_type_array *array_ft = (void *) ft;
-
- length = (int64_t) array_ft->length;
- break;
- }
- case CTF_FIELD_TYPE_ID_SEQUENCE:
- length = btr->user.cbs.query.get_sequence_length(ft,
- btr->user.data);
- break;
- default:
- abort();
- }
-
- return length;
-}
-
-static
-int stack_push_with_len(struct bt_btr *btr, struct ctf_field_type *base_type)
-{
- int ret;
- int64_t length = get_compound_field_type_length(btr, base_type);
-
- if (length < 0) {
- BT_LOGW("Cannot get compound field type's field count: "
- "btr-addr=%p, ft-addr=%p, ft-id=%d",
- btr, base_type, base_type->id);
- ret = BT_BTR_STATUS_ERROR;
- goto end;
- }
-
- ret = stack_push(btr->stack, base_type, (size_t) length);
-
-end:
- return ret;
-}
-
-static inline
-unsigned int stack_size(struct stack *stack)
-{
- BT_ASSERT(stack);
- return stack->size;
-}
-
-static
-void stack_pop(struct stack *stack)
-{
- BT_ASSERT(stack);
- BT_ASSERT(stack_size(stack));
- BT_LOGV("Popping from stack: "
- "stack-addr=%p, stack-size-before=%u, stack-size-after=%u",
- stack, stack->entries->len, stack->entries->len - 1);
- stack->size--;
-}
-
-static inline
-bool stack_empty(struct stack *stack)
-{
- return stack_size(stack) == 0;
-}
-
-static
-void stack_clear(struct stack *stack)
-{
- BT_ASSERT(stack);
- stack->size = 0;
-}
-
-static inline
-struct stack_entry *stack_top(struct stack *stack)
-{
- BT_ASSERT(stack);
- BT_ASSERT(stack_size(stack));
- return &g_array_index(stack->entries, struct stack_entry,
- stack->size - 1);
-}
-
-static inline
-size_t available_bits(struct bt_btr *btr)
-{
- return btr->buf.sz - btr->buf.at;
-}
-
-static inline
-void consume_bits(struct bt_btr *btr, size_t incr)
-{
- BT_LOGV("Advancing cursor: btr-addr=%p, cur-before=%zu, cur-after=%zu",
- btr, btr->buf.at, btr->buf.at + incr);
- btr->buf.at += incr;
-}
-
-static inline
-bool has_enough_bits(struct bt_btr *btr, size_t sz)
-{
- return available_bits(btr) >= sz;
-}
-
-static inline
-bool at_least_one_bit_left(struct bt_btr *btr)
-{
- return has_enough_bits(btr, 1);
-}
-
-static inline
-size_t packet_at(struct bt_btr *btr)
-{
- return btr->buf.packet_offset + btr->buf.at;
-}
-
-static inline
-size_t buf_at_from_addr(struct bt_btr *btr)
-{
- /*
- * Considering this:
- *
- * ====== offset ===== (17)
- *
- * xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
- * ^
- * addr (0) ==== at ==== (12)
- *
- * We want this:
- *
- * =============================== (29)
- */
- return btr->buf.offset + btr->buf.at;
-}
-
-static
-void stitch_reset(struct bt_btr *btr)
-{
- btr->stitch.offset = 0;
- btr->stitch.at = 0;
-}
-
-static inline
-size_t stitch_at_from_addr(struct bt_btr *btr)
-{
- return btr->stitch.offset + btr->stitch.at;
-}
-
-static
-void stitch_append_from_buf(struct bt_btr *btr, size_t sz)
-{
- size_t stitch_byte_at;
- size_t buf_byte_at;
- size_t nb_bytes;
-
- if (sz == 0) {
- return;
- }
-
- stitch_byte_at =
- BITS_TO_BYTES_FLOOR(stitch_at_from_addr(btr));
- buf_byte_at = BITS_TO_BYTES_FLOOR(buf_at_from_addr(btr));
- nb_bytes = BITS_TO_BYTES_CEIL(sz);
- BT_ASSERT(nb_bytes > 0);
- BT_ASSERT(btr->buf.addr);
- memcpy(&btr->stitch.buf[stitch_byte_at], &btr->buf.addr[buf_byte_at],
- nb_bytes);
- btr->stitch.at += sz;
- consume_bits(btr, sz);
-}
-
-static
-void stitch_append_from_remaining_buf(struct bt_btr *btr)
-{
- stitch_append_from_buf(btr, available_bits(btr));
-}
-
-static
-void stitch_set_from_remaining_buf(struct bt_btr *btr)
-{
- stitch_reset(btr);
- btr->stitch.offset = IN_BYTE_OFFSET(buf_at_from_addr(btr));
- stitch_append_from_remaining_buf(btr);
-}
-
-static inline
-void read_unsigned_bitfield(const uint8_t *buf, size_t at,
- unsigned int field_size, enum ctf_byte_order bo,
- uint64_t *v)
-{
- switch (bo) {
- case CTF_BYTE_ORDER_BIG:
- bt_bitfield_read_be(buf, uint8_t, at, field_size, v);
- break;
- case CTF_BYTE_ORDER_LITTLE:
- bt_bitfield_read_le(buf, uint8_t, at, field_size, v);
- break;
- default:
- abort();
- }
-
- BT_LOGV("Read unsigned bit array: cur=%zu, size=%u, "
- "bo=%d, val=%" PRIu64, at, field_size, bo, *v);
-}
-
-static inline
-void read_signed_bitfield(const uint8_t *buf, size_t at,
- unsigned int field_size, enum ctf_byte_order bo, int64_t *v)
-{
- switch (bo) {
- case CTF_BYTE_ORDER_BIG:
- bt_bitfield_read_be(buf, uint8_t, at, field_size, v);
- break;
- case CTF_BYTE_ORDER_LITTLE:
- bt_bitfield_read_le(buf, uint8_t, at, field_size, v);
- break;
- default:
- abort();
- }
-
- BT_LOGV("Read signed bit array: cur=%zu, size=%u, "
- "bo=%d, val=%" PRId64, at, field_size, bo, *v);
-}
-
-typedef enum bt_btr_status (* read_basic_and_call_cb_t)(struct bt_btr *,
- const uint8_t *, size_t);
-
-static inline
-enum bt_btr_status validate_contiguous_bo(struct bt_btr *btr,
- enum ctf_byte_order next_bo)
-{
- enum bt_btr_status status = BT_BTR_STATUS_OK;
-
- /* Always valid when at a byte boundary */
- if (packet_at(btr) % 8 == 0) {
- goto end;
- }
-
- /* Always valid if last byte order is unknown */
- if (btr->last_bo == -1) {
- goto end;
- }
-
- /* Always valid if next byte order is unknown */
- if (next_bo == -1) {
- goto end;
- }
-
- /* Make sure last byte order is compatible with the next byte order */
- switch (btr->last_bo) {
- case CTF_BYTE_ORDER_BIG:
- if (next_bo != CTF_BYTE_ORDER_BIG) {
- status = BT_BTR_STATUS_ERROR;
- }
- break;
- case CTF_BYTE_ORDER_LITTLE:
- if (next_bo != CTF_BYTE_ORDER_LITTLE) {
- status = BT_BTR_STATUS_ERROR;
- }
- break;
- default:
- status = BT_BTR_STATUS_ERROR;
- }
-
-end:
- if (status < 0) {
- BT_LOGW("Cannot read bit array: two different byte orders not at a byte boundary: "
- "btr-addr=%p, last-bo=%d, next-bo=%d",
- btr, btr->last_bo, next_bo);
- }
-
- return status;
-}
-
-static
-enum bt_btr_status read_basic_float_and_call_cb(struct bt_btr *btr,
- const uint8_t *buf, size_t at)
-{
- double dblval;
- unsigned int field_size;
- enum ctf_byte_order bo;
- enum bt_btr_status status = BT_BTR_STATUS_OK;
- struct ctf_field_type_float *ft = (void *) btr->cur_basic_field_type;
-
- BT_ASSERT(ft);
- field_size = ft->base.size;
- bo = ft->base.byte_order;
- btr->cur_bo = bo;
-
- switch (field_size) {
- case 32:
- {
- uint64_t v;
- union {
- uint32_t u;
- float f;
- } f32;
-
- read_unsigned_bitfield(buf, at, field_size, bo, &v);
- f32.u = (uint32_t) v;
- dblval = (double) f32.f;
- break;
- }
- case 64:
- {
- union {
- uint64_t u;
- double d;
- } f64;
-
- read_unsigned_bitfield(buf, at, field_size, bo, &f64.u);
- dblval = f64.d;
- break;
- }
- default:
- /* Only 32-bit and 64-bit fields are supported currently */
- abort();
- }
-
- BT_LOGV("Read floating point number value: btr=%p, cur=%zu, val=%f",
- btr, at, dblval);
-
- if (btr->user.cbs.types.floating_point) {
- BT_LOGV("Calling user function (floating point number).");
- status = btr->user.cbs.types.floating_point(dblval,
- btr->cur_basic_field_type, btr->user.data);
- BT_LOGV("User function returned: status=%s",
- bt_btr_status_string(status));
- if (status != BT_BTR_STATUS_OK) {
- BT_LOGW("User function failed: btr-addr=%p, status=%s",
- btr, bt_btr_status_string(status));
- }
- }
-
- return status;
-}
-
-static inline
-enum bt_btr_status read_basic_int_and_call_cb(struct bt_btr *btr,
- const uint8_t *buf, size_t at)
-{
- unsigned int field_size;
- enum ctf_byte_order bo;
- enum bt_btr_status status = BT_BTR_STATUS_OK;
- struct ctf_field_type_int *ft = (void *) btr->cur_basic_field_type;
-
- field_size = ft->base.size;
- bo = ft->base.byte_order;
-
- /*
- * Update current byte order now because we could be reading
- * the integer value of an enumeration type, and thus we know
- * here the actual supporting integer type's byte order.
- */
- btr->cur_bo = bo;
-
- if (ft->is_signed) {
- int64_t v;
-
- read_signed_bitfield(buf, at, field_size, bo, &v);
-
- if (btr->user.cbs.types.signed_int) {
- BT_LOGV("Calling user function (signed integer).");
- status = btr->user.cbs.types.signed_int(v,
- btr->cur_basic_field_type, btr->user.data);
- BT_LOGV("User function returned: status=%s",
- bt_btr_status_string(status));
- if (status != BT_BTR_STATUS_OK) {
- BT_LOGW("User function failed: "
- "btr-addr=%p, status=%s",
- btr, bt_btr_status_string(status));
- }
- }
- } else {
- uint64_t v;
-
- read_unsigned_bitfield(buf, at, field_size, bo, &v);
-
- if (btr->user.cbs.types.unsigned_int) {
- BT_LOGV("Calling user function (unsigned integer).");
- status = btr->user.cbs.types.unsigned_int(v,
- btr->cur_basic_field_type, btr->user.data);
- BT_LOGV("User function returned: status=%s",
- bt_btr_status_string(status));
- if (status != BT_BTR_STATUS_OK) {
- BT_LOGW("User function failed: "
- "btr-addr=%p, status=%s",
- btr, bt_btr_status_string(status));
- }
- }
- }
-
- return status;
-}
-
-static inline
-enum bt_btr_status read_bit_array_type_and_call_continue(struct bt_btr *btr,
- read_basic_and_call_cb_t read_basic_and_call_cb)
-{
- size_t available;
- size_t needed_bits;
- enum bt_btr_status status = BT_BTR_STATUS_OK;
- struct ctf_field_type_bit_array *ft =
- (void *) btr->cur_basic_field_type;
-
- if (!at_least_one_bit_left(btr)) {
- BT_LOGV("Reached end of data: btr-addr=%p", btr);
- status = BT_BTR_STATUS_EOF;
- goto end;
- }
-
- available = available_bits(btr);
- needed_bits = ft->size - btr->stitch.at;
- BT_LOGV("Continuing basic field decoding: "
- "btr-addr=%p, field-size=%u, needed-size=%" PRId64 ", "
- "available-size=%zu",
- btr, ft->size, needed_bits, available);
- if (needed_bits <= available) {
- /* We have all the bits; append to stitch, then decode */
- stitch_append_from_buf(btr, needed_bits);
- status = read_basic_and_call_cb(btr, btr->stitch.buf,
- btr->stitch.offset);
- if (status != BT_BTR_STATUS_OK) {
- BT_LOGW("Cannot read basic field: "
- "btr-addr=%p, ft-addr=%p, status=%s",
- btr, btr->cur_basic_field_type,
- bt_btr_status_string(status));
- goto end;
- }
-
- if (stack_empty(btr->stack)) {
- /* Root is a basic type */
- btr->state = BTR_STATE_DONE;
- } else {
- /* Go to next field */
- stack_top(btr->stack)->index++;
- btr->state = BTR_STATE_NEXT_FIELD;
- btr->last_bo = btr->cur_bo;
- }
- goto end;
- }
-
- /* We are here; it means we don't have enough data to decode this */
- BT_LOGV_STR("Not enough data to read the next basic field: appending to stitch buffer.");
- stitch_append_from_remaining_buf(btr);
- status = BT_BTR_STATUS_EOF;
-
-end:
- return status;
-}
-
-static inline
-enum bt_btr_status read_bit_array_type_and_call_begin(struct bt_btr *btr,
- read_basic_and_call_cb_t read_basic_and_call_cb)
-{
- size_t available;
- enum bt_btr_status status = BT_BTR_STATUS_OK;
- struct ctf_field_type_bit_array *ft =
- (void *) btr->cur_basic_field_type;
-
- if (!at_least_one_bit_left(btr)) {
- BT_LOGV("Reached end of data: btr-addr=%p", btr);
- status = BT_BTR_STATUS_EOF;
- goto end;
- }
-
- status = validate_contiguous_bo(btr, ft->byte_order);
- if (status != BT_BTR_STATUS_OK) {
- /* validate_contiguous_bo() logs errors */
- goto end;
- }
-
- available = available_bits(btr);
-
- if (ft->size <= available) {
- /* We have all the bits; decode and set now */
- BT_ASSERT(btr->buf.addr);
- status = read_basic_and_call_cb(btr, btr->buf.addr,
- buf_at_from_addr(btr));
- if (status != BT_BTR_STATUS_OK) {
- BT_LOGW("Cannot read basic field: "
- "btr-addr=%p, ft-addr=%p, status=%s",
- btr, btr->cur_basic_field_type,
- bt_btr_status_string(status));
- goto end;
- }
-
- consume_bits(btr, ft->size);
-
- if (stack_empty(btr->stack)) {
- /* Root is a basic type */
- btr->state = BTR_STATE_DONE;
- } else {
- /* Go to next field */
- stack_top(btr->stack)->index++;
- btr->state = BTR_STATE_NEXT_FIELD;
- btr->last_bo = btr->cur_bo;
- }
-
- goto end;
- }
-
- /* We are here; it means we don't have enough data to decode this */
- BT_LOGV_STR("Not enough data to read the next basic field: setting stitch buffer.");
- stitch_set_from_remaining_buf(btr);
- btr->state = BTR_STATE_READ_BASIC_CONTINUE;
- status = BT_BTR_STATUS_EOF;
-
-end:
- return status;
-}
-
-static inline
-enum bt_btr_status read_basic_int_type_and_call_begin(
- struct bt_btr *btr)
-{
- return read_bit_array_type_and_call_begin(btr, read_basic_int_and_call_cb);
-}
-
-static inline
-enum bt_btr_status read_basic_int_type_and_call_continue(
- struct bt_btr *btr)
-{
- return read_bit_array_type_and_call_continue(btr,
- read_basic_int_and_call_cb);
-}
-
-static inline
-enum bt_btr_status read_basic_float_type_and_call_begin(
- struct bt_btr *btr)
-{
- return read_bit_array_type_and_call_begin(btr,
- read_basic_float_and_call_cb);
-}
-
-static inline
-enum bt_btr_status read_basic_float_type_and_call_continue(
- struct bt_btr *btr)
-{
- return read_bit_array_type_and_call_continue(btr,
- read_basic_float_and_call_cb);
-}
-
-static inline
-enum bt_btr_status read_basic_string_type_and_call(
- struct bt_btr *btr, bool begin)
-{
- size_t buf_at_bytes;
- const uint8_t *result;
- size_t available_bytes;
- const uint8_t *first_chr;
- enum bt_btr_status status = BT_BTR_STATUS_OK;
-
- if (!at_least_one_bit_left(btr)) {
- BT_LOGV("Reached end of data: btr-addr=%p", btr);
- status = BT_BTR_STATUS_EOF;
- goto end;
- }
-
- BT_ASSERT(buf_at_from_addr(btr) % 8 == 0);
- available_bytes = BITS_TO_BYTES_FLOOR(available_bits(btr));
- buf_at_bytes = BITS_TO_BYTES_FLOOR(buf_at_from_addr(btr));
- BT_ASSERT(btr->buf.addr);
- first_chr = &btr->buf.addr[buf_at_bytes];
- result = memchr(first_chr, '\0', available_bytes);
-
- if (begin && btr->user.cbs.types.string_begin) {
- BT_LOGV("Calling user function (string, beginning).");
- status = btr->user.cbs.types.string_begin(
- btr->cur_basic_field_type, btr->user.data);
- BT_LOGV("User function returned: status=%s",
- bt_btr_status_string(status));
- if (status != BT_BTR_STATUS_OK) {
- BT_LOGW("User function failed: btr-addr=%p, status=%s",
- btr, bt_btr_status_string(status));
- goto end;
- }
- }
-
- if (!result) {
- /* No null character yet */
- if (btr->user.cbs.types.string) {
- BT_LOGV("Calling user function (substring).");
- status = btr->user.cbs.types.string(
- (const char *) first_chr,
- available_bytes, btr->cur_basic_field_type,
- btr->user.data);
- BT_LOGV("User function returned: status=%s",
- bt_btr_status_string(status));
- if (status != BT_BTR_STATUS_OK) {
- BT_LOGW("User function failed: "
- "btr-addr=%p, status=%s",
- btr, bt_btr_status_string(status));
- goto end;
- }
- }
-
- consume_bits(btr, BYTES_TO_BITS(available_bytes));
- btr->state = BTR_STATE_READ_BASIC_CONTINUE;
- status = BT_BTR_STATUS_EOF;
- } else {
- /* Found the null character */
- size_t result_len = (size_t) (result - first_chr);
-
- if (btr->user.cbs.types.string && result_len) {
- BT_LOGV("Calling user function (substring).");
- status = btr->user.cbs.types.string(
- (const char *) first_chr,
- result_len, btr->cur_basic_field_type,
- btr->user.data);
- BT_LOGV("User function returned: status=%s",
- bt_btr_status_string(status));
- if (status != BT_BTR_STATUS_OK) {
- BT_LOGW("User function failed: "
- "btr-addr=%p, status=%s",
- btr, bt_btr_status_string(status));
- goto end;
- }
- }
-
- if (btr->user.cbs.types.string_end) {
- BT_LOGV("Calling user function (string, end).");
- status = btr->user.cbs.types.string_end(
- btr->cur_basic_field_type, btr->user.data);
- BT_LOGV("User function returned: status=%s",
- bt_btr_status_string(status));
- if (status != BT_BTR_STATUS_OK) {
- BT_LOGW("User function failed: "
- "btr-addr=%p, status=%s",
- btr, bt_btr_status_string(status));
- goto end;
- }
- }
-
- consume_bits(btr, BYTES_TO_BITS(result_len + 1));
-
- if (stack_empty(btr->stack)) {
- /* Root is a basic type */
- btr->state = BTR_STATE_DONE;
- } else {
- /* Go to next field */
- stack_top(btr->stack)->index++;
- btr->state = BTR_STATE_NEXT_FIELD;
- btr->last_bo = btr->cur_bo;
- }
- }
-
-end:
- return status;
-}
-
-static inline
-enum bt_btr_status read_basic_begin_state(struct bt_btr *btr)
-{
- enum bt_btr_status status;
-
- BT_ASSERT(btr->cur_basic_field_type);
-
- switch (btr->cur_basic_field_type->id) {
- case CTF_FIELD_TYPE_ID_INT:
- case CTF_FIELD_TYPE_ID_ENUM:
- status = read_basic_int_type_and_call_begin(btr);
- break;
- case CTF_FIELD_TYPE_ID_FLOAT:
- status = read_basic_float_type_and_call_begin(btr);
- break;
- case CTF_FIELD_TYPE_ID_STRING:
- status = read_basic_string_type_and_call(btr, true);
- break;
- default:
- abort();
- }
-
- return status;
-}
-
-static inline
-enum bt_btr_status read_basic_continue_state(struct bt_btr *btr)
-{
- enum bt_btr_status status;
-
- BT_ASSERT(btr->cur_basic_field_type);
-
- switch (btr->cur_basic_field_type->id) {
- case CTF_FIELD_TYPE_ID_INT:
- case CTF_FIELD_TYPE_ID_ENUM:
- status = read_basic_int_type_and_call_continue(btr);
- break;
- case CTF_FIELD_TYPE_ID_FLOAT:
- status = read_basic_float_type_and_call_continue(btr);
- break;
- case CTF_FIELD_TYPE_ID_STRING:
- status = read_basic_string_type_and_call(btr, false);
- break;
- default:
- abort();
- }
-
- return status;
-}
-
-static inline
-size_t bits_to_skip_to_align_to(struct bt_btr *btr, size_t align)
-{
- size_t aligned_packet_at;
-
- aligned_packet_at = ALIGN(packet_at(btr), align);
- return aligned_packet_at - packet_at(btr);
-}
-
-static inline
-enum bt_btr_status align_type_state(struct bt_btr *btr,
- struct ctf_field_type *field_type, enum btr_state next_state)
-{
- unsigned int field_alignment;
- size_t skip_bits;
- enum bt_btr_status status = BT_BTR_STATUS_OK;
-
- /* Get field's alignment */
- field_alignment = field_type->alignment;
-
- /*
- * 0 means "undefined" for variants; what we really want is 1
- * (always aligned)
- */
- BT_ASSERT(field_alignment >= 1);
-
- /* Compute how many bits we need to skip */
- skip_bits = bits_to_skip_to_align_to(btr, (size_t) field_alignment);
-
- /* Nothing to skip? aligned */
- if (skip_bits == 0) {
- btr->state = next_state;
- goto end;
- }
-
- /* Make sure there's at least one bit left */
- if (!at_least_one_bit_left(btr)) {
- status = BT_BTR_STATUS_EOF;
- goto end;
- }
-
- /* Consume as many bits as possible in what's left */
- consume_bits(btr, MIN(available_bits(btr), skip_bits));
-
- /* Are we done now? */
- skip_bits = bits_to_skip_to_align_to(btr, field_alignment);
- if (skip_bits == 0) {
- /* Yes: go to next state */
- btr->state = next_state;
- goto end;
- } else {
- /* No: need more data */
- BT_LOGV("Reached end of data when aligning: btr-addr=%p", btr);
- status = BT_BTR_STATUS_EOF;
- }
-
-end:
- return status;
-}
-
-static inline
-enum bt_btr_status next_field_state(struct bt_btr *btr)
-{
- int ret;
- struct stack_entry *top;
- struct ctf_field_type *next_field_type = NULL;
- enum bt_btr_status status = BT_BTR_STATUS_OK;
-
- if (stack_empty(btr->stack)) {
- goto end;
- }
-
- top = stack_top(btr->stack);
-
- /* Are we done with this base type? */
- while (top->index == top->base_len) {
- if (btr->user.cbs.types.compound_end) {
- BT_LOGV("Calling user function (compound, end).");
- status = btr->user.cbs.types.compound_end(
- top->base_type, btr->user.data);
- BT_LOGV("User function returned: status=%s",
- bt_btr_status_string(status));
- if (status != BT_BTR_STATUS_OK) {
- BT_LOGW("User function failed: btr-addr=%p, status=%s",
- btr, bt_btr_status_string(status));
- goto end;
- }
- }
-
- stack_pop(btr->stack);
-
- /* Are we done with the root type? */
- if (stack_empty(btr->stack)) {
- btr->state = BTR_STATE_DONE;
- goto end;
- }
-
- top = stack_top(btr->stack);
- top->index++;
- }
-
- /* Get next field's type */
- switch (top->base_type->id) {
- case CTF_FIELD_TYPE_ID_STRUCT:
- next_field_type = ctf_field_type_struct_borrow_member_by_index(
- (void *) top->base_type, (uint64_t) top->index)->ft;
- break;
- case CTF_FIELD_TYPE_ID_ARRAY:
- case CTF_FIELD_TYPE_ID_SEQUENCE:
- {
- struct ctf_field_type_array_base *array_ft =
- (void *) top->base_type;
-
- next_field_type = array_ft->elem_ft;
- break;
- }
- case CTF_FIELD_TYPE_ID_VARIANT:
- /* Variant types are dynamic: query the user, he should know! */
- next_field_type =
- btr->user.cbs.query.borrow_variant_selected_field_type(
- top->base_type, btr->user.data);
- break;
- default:
- break;
- }
-
- if (!next_field_type) {
- BT_LOGW("Cannot get the field type of the next field: "
- "btr-addr=%p, base-ft-addr=%p, base-ft-id=%d, "
- "index=%" PRId64,
- btr, top->base_type, top->base_type->id, top->index);
- status = BT_BTR_STATUS_ERROR;
- goto end;
- }
-
- if (next_field_type->is_compound) {
- if (btr->user.cbs.types.compound_begin) {
- BT_LOGV("Calling user function (compound, begin).");
- status = btr->user.cbs.types.compound_begin(
- next_field_type, btr->user.data);
- BT_LOGV("User function returned: status=%s",
- bt_btr_status_string(status));
- if (status != BT_BTR_STATUS_OK) {
- BT_LOGW("User function failed: btr-addr=%p, status=%s",
- btr, bt_btr_status_string(status));
- goto end;
- }
- }
-
- ret = stack_push_with_len(btr, next_field_type);
- if (ret) {
- /* stack_push_with_len() logs errors */
- status = BT_BTR_STATUS_ERROR;
- goto end;
- }
-
- /* Next state: align a compound type */
- btr->state = BTR_STATE_ALIGN_COMPOUND;
- } else {
- /* Replace current basic field type */
- BT_LOGV("Replacing current basic field type: "
- "btr-addr=%p, cur-basic-ft-addr=%p, "
- "next-basic-ft-addr=%p",
- btr, btr->cur_basic_field_type, next_field_type);
- btr->cur_basic_field_type = next_field_type;
-
- /* Next state: align a basic type */
- btr->state = BTR_STATE_ALIGN_BASIC;
- }
-
-end:
- return status;
-}
-
-static inline
-enum bt_btr_status handle_state(struct bt_btr *btr)
-{
- enum bt_btr_status status = BT_BTR_STATUS_OK;
-
- BT_LOGV("Handling state: btr-addr=%p, state=%s",
- btr, btr_state_string(btr->state));
-
- switch (btr->state) {
- case BTR_STATE_NEXT_FIELD:
- status = next_field_state(btr);
- break;
- case BTR_STATE_ALIGN_BASIC:
- status = align_type_state(btr, btr->cur_basic_field_type,
- BTR_STATE_READ_BASIC_BEGIN);
- break;
- case BTR_STATE_ALIGN_COMPOUND:
- status = align_type_state(btr, stack_top(btr->stack)->base_type,
- BTR_STATE_NEXT_FIELD);
- break;
- case BTR_STATE_READ_BASIC_BEGIN:
- status = read_basic_begin_state(btr);
- break;
- case BTR_STATE_READ_BASIC_CONTINUE:
- status = read_basic_continue_state(btr);
- break;
- case BTR_STATE_DONE:
- break;
- }
-
- BT_LOGV("Handled state: btr-addr=%p, status=%s",
- btr, bt_btr_status_string(status));
- return status;
-}
-
-BT_HIDDEN
-struct bt_btr *bt_btr_create(struct bt_btr_cbs cbs, void *data)
-{
- struct bt_btr *btr;
-
- BT_LOGD_STR("Creating binary type reader (BTR).");
- btr = g_new0(struct bt_btr, 1);
- if (!btr) {
- BT_LOGE_STR("Failed to allocate one binary type reader.");
- goto end;
- }
-
- btr->stack = stack_new();
- if (!btr->stack) {
- BT_LOGE_STR("Cannot create BTR's stack.");
- bt_btr_destroy(btr);
- btr = NULL;
- goto end;
- }
-
- btr->state = BTR_STATE_NEXT_FIELD;
- btr->user.cbs = cbs;
- btr->user.data = data;
- BT_LOGD("Created BTR: addr=%p", btr);
-
-end:
- return btr;
-}
-
-BT_HIDDEN
-void bt_btr_destroy(struct bt_btr *btr)
-{
- if (btr->stack) {
- stack_destroy(btr->stack);
- }
-
- BT_LOGD("Destroying BTR: addr=%p", btr);
- g_free(btr);
-}
-
-static
-void reset(struct bt_btr *btr)
-{
- BT_LOGD("Resetting BTR: addr=%p", btr);
- stack_clear(btr->stack);
- stitch_reset(btr);
- btr->buf.addr = NULL;
- btr->last_bo = -1;
-}
-
-static
-void update_packet_offset(struct bt_btr *btr)
-{
- BT_LOGV("Updating packet offset for next call: "
- "btr-addr=%p, cur-packet-offset=%zu, next-packet-offset=%zu",
- btr, btr->buf.packet_offset,
- btr->buf.packet_offset + btr->buf.at);
- btr->buf.packet_offset += btr->buf.at;
-}
-
-BT_HIDDEN
-size_t bt_btr_start(struct bt_btr *btr,
- struct ctf_field_type *type, const uint8_t *buf,
- size_t offset, size_t packet_offset, size_t sz,
- enum bt_btr_status *status)
-{
- BT_ASSERT(btr);
- BT_ASSERT(BYTES_TO_BITS(sz) >= offset);
- reset(btr);
- btr->buf.addr = buf;
- btr->buf.offset = offset;
- btr->buf.at = 0;
- btr->buf.packet_offset = packet_offset;
- btr->buf.buf_sz = sz;
- btr->buf.sz = BYTES_TO_BITS(sz) - offset;
- *status = BT_BTR_STATUS_OK;
-
- BT_LOGV("Starting decoding: btr-addr=%p, ft-addr=%p, "
- "buf-addr=%p, buf-size=%zu, offset=%zu, "
- "packet-offset=%zu",
- btr, type, buf, sz, offset, packet_offset);
-
- /* Set root type */
- if (type->is_compound) {
- /* Compound type: push on visit stack */
- int stack_ret;
-
- if (btr->user.cbs.types.compound_begin) {
- BT_LOGV("Calling user function (compound, begin).");
- *status = btr->user.cbs.types.compound_begin(
- type, btr->user.data);
- BT_LOGV("User function returned: status=%s",
- bt_btr_status_string(*status));
- if (*status != BT_BTR_STATUS_OK) {
- BT_LOGW("User function failed: btr-addr=%p, status=%s",
- btr, bt_btr_status_string(*status));
- goto end;
- }
- }
-
- stack_ret = stack_push_with_len(btr, type);
- if (stack_ret) {
- /* stack_push_with_len() logs errors */
- *status = BT_BTR_STATUS_ERROR;
- goto end;
- }
-
- btr->state = BTR_STATE_ALIGN_COMPOUND;
- } else {
- /* Basic type: set as current basic type */
- btr->cur_basic_field_type = type;
- btr->state = BTR_STATE_ALIGN_BASIC;
- }
-
- /* Run the machine! */
- BT_LOGV_STR("Running the state machine.");
-
- while (true) {
- *status = handle_state(btr);
- if (*status != BT_BTR_STATUS_OK ||
- btr->state == BTR_STATE_DONE) {
- break;
- }
- }
-
- /* Update packet offset for next time */
- update_packet_offset(btr);
-
-end:
- return btr->buf.at;
-}
-
-BT_HIDDEN
-size_t bt_btr_continue(struct bt_btr *btr, const uint8_t *buf, size_t sz,
- enum bt_btr_status *status)
-{
- BT_ASSERT(btr);
- BT_ASSERT(buf);
- BT_ASSERT(sz > 0);
- btr->buf.addr = buf;
- btr->buf.offset = 0;
- btr->buf.at = 0;
- btr->buf.buf_sz = sz;
- btr->buf.sz = BYTES_TO_BITS(sz);
- *status = BT_BTR_STATUS_OK;
-
- BT_LOGV("Continuing decoding: btr-addr=%p, buf-addr=%p, buf-size=%zu",
- btr, buf, sz);
-
- /* Continue running the machine */
- BT_LOGV_STR("Running the state machine.");
-
- while (true) {
- *status = handle_state(btr);
- if (*status != BT_BTR_STATUS_OK ||
- btr->state == BTR_STATE_DONE) {
- break;
- }
- }
-
- /* Update packet offset for next time */
- update_packet_offset(btr);
- return btr->buf.at;
-}
-
-BT_HIDDEN
-void bt_btr_set_unsigned_int_cb(struct bt_btr *btr,
- bt_btr_unsigned_int_cb_func cb)
-{
- BT_ASSERT(btr);
- BT_ASSERT(cb);
- btr->user.cbs.types.unsigned_int = cb;
-}
+++ /dev/null
-define ctf-btr-show-stack
- if (stack_empty($arg0))
- printf "stack is empty!\n"
- else
- set $stack_size = stack_size($arg0)
- set $stack_at = (int) ($stack_size - 1)
- printf "%3s %10s %4s %3s\n", "pos", "base addr", "blen", "idx"
-
- while ($stack_at >= 0)
- set $stack_entry = (struct stack_entry *) g_ptr_array_index($arg0->entries, $stack_at)
-
- if ($stack_at == $stack_size - 1)
- printf "%3d %10p %3d %3d <-- top\n", $stack_at, \
- $stack_entry->base_type, $stack_entry->base_len, \
- $stack_entry->index
- else
- printf "%3d %10p %3d %3d\n", $stack_at, \
- $stack_entry->base_type, $stack_entry->base_len, \
- $stack_entry->index
- end
- set $stack_at = $stack_at - 1
- end
- end
-end
+++ /dev/null
-#ifndef CTF_BTR_H
-#define CTF_BTR_H
-
-/*
- * Babeltrace - CTF binary type reader (BTR)
- *
- * Copyright (c) 2015-2016 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2015-2016 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.
- */
-
-#include <stdint.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
-
-#include "../metadata/ctf-meta.h"
-
-/**
- * @file ctf-btr.h
- *
- * Event-driven CTF binary type reader (BTR).
- *
- * This is a common, internal API used by CTF source plugins. It allows
- * a binary CTF IR field type to be decoded from user-provided buffers.
- * As the type is decoded (and, possibly, its nested types), registered
- * user callback functions are called.
- *
- * This API is only concerned with reading one CTF type at a time from
- * one or more buffer of bytes. It does not know CTF dynamic scopes,
- * events, or streams. Sequence lengths and selected variant types are
- * requested to the user when needed.
- */
-
-/**
- * Binary type reader API status codes.
- */
-enum bt_btr_status {
- /** Out of memory. */
- BT_BTR_STATUS_ENOMEM = -5,
- /**
- * The binary stream reader reached the end of the user-provided
- * buffer, but data is still needed to finish decoding the
- * requested type.
- *
- * The user needs to call bt_btr_continue() as long as
- * #BT_BTR_STATUS_EOF is returned to complete the decoding
- * process of a given type.
- */
- BT_BTR_STATUS_EOF = 1,
-
- /** Invalid argument. */
- BT_BTR_STATUS_INVAL = -3,
-
- /** General error. */
- BT_BTR_STATUS_ERROR = -1,
-
- /** Everything okay. */
- BT_BTR_STATUS_OK = 0,
-};
-
-/** Type reader. */
-struct bt_btr;
-
-typedef enum bt_btr_status (* bt_btr_unsigned_int_cb_func)(uint64_t,
- struct ctf_field_type *, void *);
-
-/*
- * Type reader user callback functions.
- */
-struct bt_btr_cbs {
- /**
- * Type callback functions.
- *
- * This CTF binary type reader is event-driven. The following
- * functions are called during the decoding process, either when
- * a compound type begins/ends, or when a basic type is
- * completely decoded (along with its value).
- *
- * Each function also receives the CTF field type associated
- * with the call, and user data (registered to the type reader
- * calling them).
- *
- * Actual trace IR fields are \em not created here; this would
- * be the responsibility of a type reader's user (the provider
- * of those callback functions).
- *
- * All the type callback functions return one of the following
- * values:
- *
- * - <b>#BT_BTR_STATUS_OK</b>: Everything is okay;
- * continue the decoding process.
- * - <b>#BT_BTR_STATUS_ERROR</b>: General error (reported
- * to type reader's user).
- *
- * Any member of this structure may be set to \c NULL, should
- * a specific notification be not needed.
- */
- struct {
- /**
- * Called when a signed integer type is completely
- * decoded. This could also be the supporting signed
- * integer type of an enumeration type (\p type will
- * indicate this).
- *
- * @param value Signed integer value
- * @param type Integer or enumeration type
- * @param data User data
- * @returns #BT_BTR_STATUS_OK or
- * #BT_BTR_STATUS_ERROR
- */
- enum bt_btr_status (* signed_int)(int64_t value,
- struct ctf_field_type *type, void *data);
-
- /**
- * Called when an unsigned integer type is completely
- * decoded. This could also be the supporting signed
- * integer type of an enumeration type (\p type will
- * indicate this).
- *
- * @param value Unsigned integer value
- * @param type Integer or enumeration type
- * @param data User data
- * @returns #BT_BTR_STATUS_OK or
- * #BT_BTR_STATUS_ERROR
- */
- bt_btr_unsigned_int_cb_func unsigned_int;
-
- /**
- * Called when a floating point number type is
- * completely decoded.
- *
- * @param value Floating point number value
- * @param type Floating point number type
- * @param data User data
- * @returns #BT_BTR_STATUS_OK or
- * #BT_BTR_STATUS_ERROR
- */
- enum bt_btr_status (* floating_point)(double value,
- struct ctf_field_type *type, void *data);
-
- /**
- * Called when a string type begins.
- *
- * All the following user callback function calls will
- * be made to bt_btr_cbs::types::string(), each of
- * them providing one substring of the complete string
- * type's value.
- *
- * @param type Beginning string type
- * @param data User data
- * @returns #BT_BTR_STATUS_OK or
- * #BT_BTR_STATUS_ERROR
- */
- enum bt_btr_status (* string_begin)(
- struct ctf_field_type *type, void *data);
-
- /**
- * Called when a string type's substring is decoded
- * (between a call to bt_btr_cbs::types::string_begin()
- * and a call to bt_btr_cbs::types::string_end()).
- *
- * @param value String value (\em not null-terminated)
- * @param len String value length
- * @param type String type
- * @param data User data
- * @returns #BT_BTR_STATUS_OK or
- * #BT_BTR_STATUS_ERROR
- */
- enum bt_btr_status (* string)(const char *value,
- size_t len, struct ctf_field_type *type,
- void *data);
-
- /**
- * Called when a string type ends.
- *
- * @param type Ending string type
- * @param data User data
- * @returns #BT_BTR_STATUS_OK or
- * #BT_BTR_STATUS_ERROR
- */
- enum bt_btr_status (* string_end)(
- struct ctf_field_type *type, void *data);
-
- /**
- * Called when a compound type begins.
- *
- * All the following type callback function calls will
- * signal sequential elements of this compound type,
- * until the next corresponding
- * bt_btr_cbs::types::compound_end() is called.
- *
- * If \p type is a variant type, then only one type
- * callback function call will follow before the call to
- * bt_btr_cbs::types::compound_end(). This single
- * call indicates the selected type of this variant
- * type.
- *
- * @param type Beginning compound type
- * @param data User data
- * @returns #BT_BTR_STATUS_OK or
- * #BT_BTR_STATUS_ERROR
- */
- enum bt_btr_status (* compound_begin)(
- struct ctf_field_type *type, void *data);
-
- /**
- * Called when a compound type ends.
- *
- * @param type Ending compound type
- * @param data User data
- * @returns #BT_BTR_STATUS_OK or
- * #BT_BTR_STATUS_ERROR
- */
- enum bt_btr_status (* compound_end)(
- struct ctf_field_type *type, void *data);
- } types;
-
- /**
- * Query callback functions are used when the type reader needs
- * dynamic information, i.e. a sequence type's current length
- * or a variant type's current selected type.
- *
- * Both functions need to be set unless it is known that no
- * sequences or variants will have to be decoded.
- */
- struct {
- /**
- * Called to query the current length of a given sequence
- * type.
- *
- * @param type Sequence type
- * @param data User data
- * @returns Sequence length or
- * #BT_BTR_STATUS_ERROR on error
- */
- int64_t (* get_sequence_length)(struct ctf_field_type *type,
- void *data);
-
- /**
- * Called to query the current selected type of a given
- * variant type.
- *
- * @param type Variant type
- * @param data User data
- * @returns Current selected type (owned by
- * this) or \c NULL on error
- */
- struct ctf_field_type * (* borrow_variant_selected_field_type)(
- struct ctf_field_type *type, void *data);
- } query;
-};
-
-/**
- * Creates a CTF binary type reader.
- *
- * @param cbs User callback functions
- * @param data User data (passed to user callback functions)
- * @returns New binary type reader on success, or \c NULL on error
- */
-BT_HIDDEN
-struct bt_btr *bt_btr_create(struct bt_btr_cbs cbs, void *data);
-
-/**
- * Destroys a CTF binary type reader, freeing all internal resources.
- *
- * @param btr Binary type reader
- */
-BT_HIDDEN
-void bt_btr_destroy(struct bt_btr *btr);
-
-/**
- * Decodes a given CTF type from a buffer of bytes.
- *
- * The number of \em bits consumed by this function is returned.
- *
- * The \p status output parameter is where a status is written, amongst
- * the following:
- *
- * - <b>#BT_BTR_STATUS_OK</b>: Decoding is done.
- * - <b>#BT_BTR_STATUS_EOF</b>: The end of the buffer was reached,
- * but more data is needed to finish the decoding process of the
- * requested type. The user needs to call bt_btr_continue()
- * as long as #BT_BTR_STATUS_EOF is returned to complete the
- * decoding process of the original type.
- * - <b>#BT_BTR_STATUS_INVAL</b>: Invalid argument.
- * - <b>#BT_BTR_STATUS_ERROR</b>: General error.
- *
- * Calling this function resets the type reader's internal state. If
- * #BT_BTR_STATUS_EOF is returned, bt_btr_continue() needs to
- * be called next, \em not bt_btr_decode().
- *
- * @param btr Binary type reader
- * @param type Type to decode
- * @param buf Buffer
- * @param offset Offset of first bit from \p buf (bits)
- * @param packet_offset Offset of \p offset within the CTF
- * binary packet containing \p type (bits)
- * @param sz Size of buffer in bytes (from \p buf)
- * @param status Returned status (see description above)
- * @returns Number of consumed bits
- */
-BT_HIDDEN
-size_t bt_btr_start(struct bt_btr *btr,
- struct ctf_field_type *type, const uint8_t *buf,
- size_t offset, size_t packet_offset, size_t sz,
- enum bt_btr_status *status);
-
-/**
- * Continues the decoding process a given CTF type.
- *
- * The number of bits consumed by this function is returned.
- *
- * The \p status output parameter is where a status is placed, amongst
- * the following:
- *
- * - <b>#BT_BTR_STATUS_OK</b>: decoding is done.
- * - <b>#BT_BTR_STATUS_EOF</b>: the end of the buffer was reached,
- * but more data is needed to finish the decoding process of the
- * requested type. The user needs to call bt_btr_continue()
- * as long as #BT_BTR_STATUS_EOF is returned to complete the
- * decoding process of the original type.
- * - <b>#BT_BTR_STATUS_INVAL</b>: invalid argument.
- * - <b>#BT_BTR_STATUS_ERROR</b>: general error.
- *
- * @param btr Binary type reader
- * @param buf Buffer
- * @param sz Size of buffer in bytes (from \p offset)
- * @param status Returned status (see description above)
- * @returns Number of consumed bits
- */
-BT_HIDDEN
-size_t bt_btr_continue(struct bt_btr *btr,
- const uint8_t *buf, size_t sz,
- enum bt_btr_status *status);
-
-BT_HIDDEN
-void bt_btr_set_unsigned_int_cb(struct bt_btr *btr,
- bt_btr_unsigned_int_cb_func cb);
-
-static inline
-const char *bt_btr_status_string(enum bt_btr_status status)
-{
- switch (status) {
- case BT_BTR_STATUS_ENOMEM:
- return "BT_BTR_STATUS_ENOMEM";
- case BT_BTR_STATUS_EOF:
- return "BT_BTR_STATUS_EOF";
- case BT_BTR_STATUS_INVAL:
- return "BT_BTR_STATUS_INVAL";
- case BT_BTR_STATUS_ERROR:
- return "BT_BTR_STATUS_ERROR";
- case BT_BTR_STATUS_OK:
- return "BT_BTR_STATUS_OK";
- default:
- return "(unknown)";
- }
-}
-
-#endif /* CTF_BTR_H */
+++ /dev/null
-/*
- * Copyright (c) 2017 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_OUTPUT_LEVEL btr_log_level
-#include <babeltrace/logging-internal.h>
-
-BT_LOG_INIT_LOG_LEVEL(btr_log_level, "BABELTRACE_PLUGIN_CTF_BTR_LOG_LEVEL");
+++ /dev/null
-#ifndef CTF_BTR_LOGGING_H
-#define CTF_BTR_LOGGING_H
-
-/*
- * Copyright (c) 2017 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_OUTPUT_LEVEL btr_log_level
-#include <babeltrace/logging-internal.h>
-
-BT_LOG_LEVEL_EXTERN_SYMBOL(btr_log_level);
-
-#endif /* CTF_BTR_LOGGING_H */
} unknown;
struct {
/*
- * Children nodes are ctf_expression, typedef,
- * typealias and type_specifier_list.
+ * Children nodes are ctf_expression, field_class_def,
+ * field_class_alias and field_class_specifier_list.
*/
struct bt_list_head declaration_list;
struct bt_list_head trace;
} root;
struct {
/*
- * Children nodes are ctf_expression, typedef,
- * typealias and type_specifier_list.
+ * Children nodes are ctf_expression, field_class_def,
+ * field_class_alias and field_class_specifier_list.
*/
struct bt_list_head declaration_list;
} event;
struct {
/*
- * Children nodes are ctf_expression, typedef,
- * typealias and type_specifier_list.
+ * Children nodes are ctf_expression, field_class_def,
+ * field_class_alias and field_class_specifier_list.
*/
struct bt_list_head declaration_list;
} stream;
struct {
/*
- * Children nodes are ctf_expression, typedef,
- * typealias and type_specifier_list.
+ * Children nodes are ctf_expression, field_class_def,
+ * field_class_alias and field_class_specifier_list.
*/
struct bt_list_head declaration_list;
} env;
struct {
/*
- * Children nodes are ctf_expression, typedef,
- * typealias and type_specifier_list.
+ * Children nodes are ctf_expression, field_class_def,
+ * field_class_alias and field_class_specifier_list.
*/
struct bt_list_head declaration_list;
} trace;
struct {
/*
- * Children nodes are ctf_expression, typedef,
- * typealias and type_specifier_list.
+ * Children nodes are ctf_expression, field_class_def,
+ * field_class_alias and field_class_specifier_list.
*/
struct bt_list_head declaration_list;
} clock;
struct {
/*
- * Children nodes are ctf_expression, typedef,
- * typealias and type_specifier_list.
+ * Children nodes are ctf_expression, field_class_def,
+ * field_class_alias and field_class_specifier_list.
*/
struct bt_list_head declaration_list;
} callsite;
} link;
} unary_expression;
struct {
- struct ctf_node *type_specifier_list;
- struct bt_list_head type_declarators;
- } _typedef;
+ struct ctf_node *field_class_specifier_list;
+ struct bt_list_head field_class_declarators;
+ } field_class_def;
/* new type is "alias", existing type "target" */
struct {
- struct ctf_node *type_specifier_list;
- struct bt_list_head type_declarators;
- } typealias_target;
+ struct ctf_node *field_class_specifier_list;
+ struct bt_list_head field_class_declarators;
+ } field_class_alias_target;
struct {
- struct ctf_node *type_specifier_list;
- struct bt_list_head type_declarators;
- } typealias_alias;
+ struct ctf_node *field_class_specifier_list;
+ struct bt_list_head field_class_declarators;
+ } field_class_alias_name;
struct {
struct ctf_node *target;
struct ctf_node *alias;
- } typealias;
+ } field_class_alias;
struct {
enum {
TYPESPEC_UNKNOWN = 0,
/* For struct, variant and enum */
struct ctf_node *node;
const char *id_type;
- } type_specifier;
+ } field_class_specifier;
struct {
- /* list of type_specifier */
+ /* list of field_class_specifier */
struct bt_list_head head;
- } type_specifier_list;
+ } field_class_specifier_list;
struct {
unsigned int const_qualifier;
} pointer;
char *id;
struct {
/* typedec has no pointer list */
- struct ctf_node *type_declarator;
+ struct ctf_node *field_class_declarator;
/*
* unary expression (value) or
- * type_specifier_list.
+ * field_class_specifier_list.
*/
struct bt_list_head length;
/* for abstract type declarator */
} nested;
} u;
struct ctf_node *bitfield_len;
- } type_declarator;
+ } field_class_declarator;
struct {
/* Children nodes are ctf_expression. */
struct bt_list_head expressions;
char *enum_id;
/*
* Either NULL, or points to unary expression or
- * type_specifier_list.
+ * field_class_specifier_list.
*/
- struct ctf_node *container_type;
+ struct ctf_node *container_field_class;
struct bt_list_head enumerator_list;
int has_body;
} _enum;
struct {
- struct ctf_node *type_specifier_list;
- struct bt_list_head type_declarators;
+ struct ctf_node *field_class_specifier_list;
+ struct bt_list_head field_class_declarators;
} struct_or_variant_declaration;
struct {
char *name;
char *choice;
- /* list of typedef, typealias and declarations */
+ /*
+ * list of field_class_def, field_class_alias and
+ * declarations
+ */
struct bt_list_head declaration_list;
int has_body;
} variant;
struct {
char *name;
- /* list of typedef, typealias and declarations */
+ /*
+ * list of field_class_def, field_class_alias and
+ * declarations
+ */
struct bt_list_head declaration_list;
int has_body;
struct bt_list_head min_align; /* align() attribute */
#include "ctf-meta-visitors.h"
-typedef GPtrArray field_type_stack;
+typedef GPtrArray field_class_stack;
/*
* A stack frame.
*
- * `type` contains a compound field type (structure, variant, array,
- * or sequence) and `index` indicates the index of the field type in
- * the upper frame (-1 for array and sequence field types). `name`
- * indicates the name of the field type in the upper frame (empty
- * string for array and sequence field types).
+ * `fc` contains a compound field class (structure, variant, array,
+ * or sequence) and `index` indicates the index of the field class in
+ * the upper frame (-1 for array and sequence field classes). `name`
+ * indicates the name of the field class in the upper frame (empty
+ * string for array and sequence field classes).
*/
-struct field_type_stack_frame {
- struct ctf_field_type *ft;
+struct field_class_stack_frame {
+ struct ctf_field_class *fc;
int64_t index;
};
struct ctf_event_class *ec;
struct {
- struct ctf_field_type *packet_header;
- struct ctf_field_type *packet_context;
- struct ctf_field_type *event_header;
- struct ctf_field_type *event_common_context;
- struct ctf_field_type *event_spec_context;
- struct ctf_field_type *event_payload;
+ struct ctf_field_class *packet_header;
+ struct ctf_field_class *packet_context;
+ struct ctf_field_class *event_header;
+ struct ctf_field_class *event_common_context;
+ struct ctf_field_class *event_spec_context;
+ struct ctf_field_class *event_payload;
} scopes;
/* Root scope being visited */
enum bt_scope root_scope;
- field_type_stack *field_type_stack;
- struct ctf_field_type *cur_ft;
+ 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
-void destroy_field_type_stack_frame(struct field_type_stack_frame *frame)
+void destroy_field_class_stack_frame(struct field_class_stack_frame *frame)
{
if (!frame) {
return;
}
/*
- * Creates a type stack.
+ * Creates a class stack.
*/
static
-field_type_stack *field_type_stack_create(void)
+field_class_stack *field_class_stack_create(void)
{
return g_ptr_array_new_with_free_func(
- (GDestroyNotify) destroy_field_type_stack_frame);
+ (GDestroyNotify) destroy_field_class_stack_frame);
}
/*
- * Destroys a type stack.
+ * Destroys a class stack.
*/
static
-void field_type_stack_destroy(field_type_stack *stack)
+void field_class_stack_destroy(field_class_stack *stack)
{
if (stack) {
g_ptr_array_free(stack, TRUE);
}
/*
- * Pushes a field type onto a type stack.
+ * Pushes a field class onto a class stack.
*/
static
-int field_type_stack_push(field_type_stack *stack, struct ctf_field_type *ft)
+int field_class_stack_push(field_class_stack *stack, struct ctf_field_class *fc)
{
int ret = 0;
- struct field_type_stack_frame *frame = NULL;
+ struct field_class_stack_frame *frame = NULL;
- if (!stack || !ft) {
- BT_LOGE("Invalid parameter: stack or type is NULL.");
+ if (!stack || !fc) {
+ BT_LOGE("Invalid parameter: stack or field class is NULL.");
ret = -1;
goto end;
}
- frame = g_new0(struct field_type_stack_frame, 1);
+ frame = g_new0(struct field_class_stack_frame, 1);
if (!frame) {
- BT_LOGE_STR("Failed to allocate one field type stack frame.");
+ BT_LOGE_STR("Failed to allocate one field class stack frame.");
ret = -1;
goto end;
}
- BT_LOGV("Pushing field type on context's stack: "
- "ft-addr=%p, stack-size-before=%u", ft, stack->len);
- frame->ft = ft;
+ BT_LOGV("Pushing field class on context's stack: "
+ "fc-addr=%p, stack-size-before=%u", fc, stack->len);
+ frame->fc = fc;
g_ptr_array_add(stack, frame);
end:
* Checks whether or not `stack` is empty.
*/
static
-bool field_type_stack_empty(field_type_stack *stack)
+bool field_class_stack_empty(field_class_stack *stack)
{
return stack->len == 0;
}
* Returns the number of frames in `stack`.
*/
static
-size_t field_type_stack_size(field_type_stack *stack)
+size_t field_class_stack_size(field_class_stack *stack)
{
return stack->len;
}
* Returns the top frame of `stack`.
*/
static
-struct field_type_stack_frame *field_type_stack_peek(field_type_stack *stack)
+struct field_class_stack_frame *field_class_stack_peek(field_class_stack *stack)
{
- struct field_type_stack_frame *entry = NULL;
+ struct field_class_stack_frame *entry = NULL;
- if (!stack || field_type_stack_empty(stack)) {
+ if (!stack || field_class_stack_empty(stack)) {
goto end;
}
* Returns the frame at index `index` in `stack`.
*/
static
-struct field_type_stack_frame *field_type_stack_at(field_type_stack *stack,
+struct field_class_stack_frame *field_class_stack_at(field_class_stack *stack,
size_t index)
{
- struct field_type_stack_frame *entry = NULL;
+ struct field_class_stack_frame *entry = NULL;
if (!stack || index >= stack->len) {
goto end;
* Removes the top frame of `stack`.
*/
static
-void field_type_stack_pop(field_type_stack *stack)
+void field_class_stack_pop(field_class_stack *stack)
{
- if (!field_type_stack_empty(stack)) {
+ if (!field_class_stack_empty(stack)) {
/*
* This will call the frame's destructor and free it, as
- * well as put its contained field type.
+ * well as put its contained field class.
*/
BT_LOGV("Popping context's stack: stack-size-before=%u",
stack->len);
}
/*
- * Returns the scope field type of `scope` in the context `ctx`.
+ * Returns the scope field class of `scope` in the context `ctx`.
*/
static
-struct ctf_field_type *borrow_type_from_ctx(struct resolve_context *ctx,
+struct ctf_field_class *borrow_class_from_ctx(struct resolve_context *ctx,
enum bt_scope scope)
{
switch (scope) {
/*
* Converts a path token list to a field path object. The path token
- * list is relative from `ft`. The index of the source looking for its
- * target within `ft` is indicated by `src_index`. This can be `INT64_MAX`
- * if the source is contained in `ft`.
+ * list is relative from `fc`. The index of the source looking for its
+ * target within `fc` is indicated by `src_index`. This can be `INT64_MAX`
+ * if the source is contained in `fc`.
*
* `field_path` is an output parameter owned by the caller that must be
* filled here.
*/
static
int ptokens_to_field_path(GList *ptokens, struct ctf_field_path *field_path,
- struct ctf_field_type *ft, int64_t src_index)
+ struct ctf_field_class *fc, int64_t src_index)
{
int ret = 0;
GList *cur_ptoken = ptokens;
/* Locate target */
while (cur_ptoken) {
int64_t child_index;
- struct ctf_field_type *child_ft;
+ struct ctf_field_class *child_fc;
const char *ft_name = ptoken_get_string(cur_ptoken);
BT_LOGV("Current path token: token=\"%s\"", ft_name);
/* Find to which index corresponds the current path token */
- if (ft->id == CTF_FIELD_TYPE_ID_ARRAY ||
- ft->id == CTF_FIELD_TYPE_ID_SEQUENCE) {
+ if (fc->id == CTF_FIELD_CLASS_ID_ARRAY ||
+ fc->id == CTF_FIELD_CLASS_ID_SEQUENCE) {
child_index = -1;
} else {
child_index =
- ctf_field_type_compound_get_field_type_index_from_name(
- ft, ft_name);
+ ctf_field_class_compound_get_field_class_index_from_name(
+ fc, ft_name);
if (child_index < 0) {
/*
* Error: field name does not exist or
- * wrong current type.
+ * wrong current class.
*/
- BT_LOGV("Cannot get index of field type: "
+ BT_LOGV("Cannot get index of field class: "
"field-name=\"%s\", "
"src-index=%" PRId64 ", "
"child-index=%" PRId64 ", "
goto end;
} else if (child_index > src_index &&
!first_level_done) {
- BT_LOGV("Child field type is located after source field type: "
+ BT_LOGV("Child field class is located after source field class: "
"field-name=\"%s\", "
"src-index=%" PRId64 ", "
"child-index=%" PRId64 ", "
/* Create new field path entry */
ctf_field_path_append_index(field_path, child_index);
- /* Get child field type */
- child_ft = ctf_field_type_compound_borrow_field_type_by_index(
- ft, child_index);
- BT_ASSERT(child_ft);
+ /* Get child field class */
+ child_fc = ctf_field_class_compound_borrow_field_class_by_index(
+ fc, child_index);
+ BT_ASSERT(child_fc);
- /* Move child type to current type */
- ft = child_ft;
+ /* Move child class to current class */
+ fc = child_fc;
}
end:
{
int ret = 0;
GList *cur_ptoken;
- struct ctf_field_type *ft;
+ struct ctf_field_class *fc;
/*
* Make sure we're not referring to a scope within a translated
cur_ptoken = g_list_nth(ptokens,
absolute_path_prefix_ptoken_counts[field_path->root]);
- /* Start with root type */
- ft = borrow_type_from_ctx(ctx, field_path->root);
- if (!ft) {
- /* Error: root type is not available */
- BT_LOGE("Root field type is not available: "
+ /* Start with root class */
+ fc = borrow_class_from_ctx(ctx, field_path->root);
+ if (!fc) {
+ /* Error: root class is not available */
+ BT_LOGE("Root field class is not available: "
"root-scope=%s",
bt_common_scope_string(field_path->root));
ret = -1;
}
/* Locate target */
- ret = ptokens_to_field_path(cur_ptoken, field_path, ft, INT64_MAX);
+ ret = ptokens_to_field_path(cur_ptoken, field_path, fc, INT64_MAX);
end:
return ret;
struct ctf_field_path tail_field_path;
ctf_field_path_init(&tail_field_path);
- parent_pos_in_stack = field_type_stack_size(ctx->field_type_stack) - 1;
+ parent_pos_in_stack = field_class_stack_size(ctx->field_class_stack) - 1;
while (parent_pos_in_stack >= 0) {
- struct ctf_field_type *parent_type =
- field_type_stack_at(ctx->field_type_stack,
- parent_pos_in_stack)->ft;
- int64_t cur_index = field_type_stack_at(ctx->field_type_stack,
+ struct ctf_field_class *parent_class =
+ field_class_stack_at(ctx->field_class_stack,
+ parent_pos_in_stack)->fc;
+ int64_t cur_index = field_class_stack_at(ctx->field_class_stack,
parent_pos_in_stack)->index;
- BT_LOGV("Locating target field type from current parent field type: "
- "parent-pos=%" PRId64 ", parent-ft-addr=%p, "
+ BT_LOGV("Locating target field class from current parent field class: "
+ "parent-pos=%" PRId64 ", parent-fc-addr=%p, "
"cur-index=%" PRId64,
- parent_pos_in_stack, parent_type, cur_index);
+ parent_pos_in_stack, parent_class, cur_index);
- /* Locate target from current parent type */
+ /* Locate target from current parent class */
ret = ptokens_to_field_path(ptokens, &tail_field_path,
- parent_type, cur_index);
+ parent_class, cur_index);
if (ret) {
/* Not found... yet */
BT_LOGV_STR("Not found at this point.");
tail_field_path.path->len;
while (BT_TRUE) {
- struct ctf_field_type *cur_type =
- field_type_stack_at(ctx->field_type_stack,
- i)->ft;
- int64_t index = field_type_stack_at(
- ctx->field_type_stack, i)->index;
+ struct ctf_field_class *cur_class =
+ field_class_stack_at(
+ ctx->field_class_stack, i)->fc;
+ int64_t index = field_class_stack_at(
+ ctx->field_class_stack, i)->index;
- if (cur_type == parent_type) {
+ if (cur_class == parent_class) {
break;
}
}
/*
- * Retrieves a field type by following the field path `field_path` in
+ * Retrieves a field class by following the field path `field_path` in
* the resolving context `ctx`.
*/
static
-struct ctf_field_type *field_path_to_field_type(
+struct ctf_field_class *field_path_to_field_class(
struct ctf_field_path *field_path, struct resolve_context *ctx)
{
uint64_t i;
- struct ctf_field_type *ft;
+ struct ctf_field_class *fc;
- /* Start with root type */
- ft = borrow_type_from_ctx(ctx, field_path->root);
- if (!ft) {
- /* Error: root type is not available */
- BT_LOGE("Root field type is not available: root-scope=%s",
+ /* Start with root class */
+ fc = borrow_class_from_ctx(ctx, field_path->root);
+ if (!fc) {
+ /* Error: root class is not available */
+ BT_LOGE("Root field class is not available: root-scope=%s",
bt_common_scope_string(field_path->root));
goto end;
}
/* Locate target */
for (i = 0; i < field_path->path->len; i++) {
- struct ctf_field_type *child_ft;
+ struct ctf_field_class *child_fc;
int64_t child_index =
ctf_field_path_borrow_index_by_index(field_path, i);
- /* Get child field type */
- child_ft = ctf_field_type_compound_borrow_field_type_by_index(
- ft, child_index);
- BT_ASSERT(child_ft);
+ /* Get child field class */
+ child_fc = ctf_field_class_compound_borrow_field_class_by_index(
+ fc, child_index);
+ BT_ASSERT(child_fc);
- /* Move child type to current type */
- ft = child_ft;
+ /* Move child class to current class */
+ fc = child_fc;
}
end:
- return ft;
+ return fc;
}
/*
- * Fills the equivalent field path object of the context type stack.
+ * Fills the equivalent field path object of the context class stack.
*/
static
void get_ctx_stack_field_path(struct resolve_context *ctx,
field_path->root = ctx->root_scope;
ctf_field_path_clear(field_path);
- for (i = 0; i < field_type_stack_size(ctx->field_type_stack); i++) {
- struct field_type_stack_frame *frame =
- field_type_stack_at(ctx->field_type_stack, i);
+ for (i = 0; i < field_class_stack_size(ctx->field_class_stack); i++) {
+ struct field_class_stack_frame *frame =
+ field_class_stack_at(ctx->field_class_stack, i);
ctf_field_path_append_index(field_path, frame->index);
}
* This is invalid because the target cannot be
* an ancestor of the source.
*/
- BT_LOGE("Source field type is an ancestor of target field type or vice versa: "
+ BT_LOGE("Source field class is an ancestor of target field class or vice versa: "
"lca-index=%" PRId64 ", "
"field-path-1-len=%" PRIu64 ", "
"field-path-2-len=%" PRIu64,
*/
static
int validate_target_field_path(struct ctf_field_path *target_field_path,
- struct ctf_field_type *target_ft,
+ struct ctf_field_class *target_fc,
struct resolve_context *ctx)
{
int ret = 0;
* after the context field path's root.
*/
if (target_field_path->root > ctx_field_path.root) {
- BT_LOGE("Target field type is located after source field type: "
+ BT_LOGE("Target field class is located after source field class: "
"target-root=%s, source-root=%s",
bt_common_scope_string(target_field_path->root),
bt_common_scope_string(ctx_field_path.root));
&ctx_field_path, (uint64_t) lca_index);
if (target_index >= ctx_index) {
- BT_LOGE("Target field type's index is greater than or equal to source field type's index in LCA: "
+ BT_LOGE("Target field class's index is greater than or equal to source field class's index in LCA: "
"lca-index=%" PRId64 ", "
"target-index=%" PRId64 ", "
"source-index=%" PRId64,
}
/*
- * Make sure the target type has the right type and properties.
+ * Make sure the target class has the right class and properties.
*/
- switch (ctx->cur_ft->id) {
- case CTF_FIELD_TYPE_ID_VARIANT:
- if (target_ft->id != CTF_FIELD_TYPE_ID_ENUM) {
- BT_LOGE("Variant field type's tag field type is not an enumeration field type: "
- "tag-ft-addr=%p, tag-ft-id=%d",
- target_ft, target_ft->id);
+ switch (ctx->cur_fc->id) {
+ case CTF_FIELD_CLASS_ID_VARIANT:
+ if (target_fc->id != CTF_FIELD_CLASS_ID_ENUM) {
+ BT_LOGE("Variant field class's tag field class is not an enumeration field class: "
+ "tag-fc-addr=%p, tag-fc-id=%d",
+ target_fc, target_fc->id);
ret = -1;
goto end;
}
break;
- case CTF_FIELD_TYPE_ID_SEQUENCE:
+ case CTF_FIELD_CLASS_ID_SEQUENCE:
{
- struct ctf_field_type_int *int_ft = (void *) target_ft;
+ struct ctf_field_class_int *int_fc = (void *) target_fc;
- if (target_ft->id != CTF_FIELD_TYPE_ID_INT &&
- target_ft->id != CTF_FIELD_TYPE_ID_ENUM) {
- BT_LOGE("Sequence field type's length field type is not an unsigned integer field type: "
- "length-ft-addr=%p, length-ft-id=%d",
- target_ft, target_ft->id);
+ if (target_fc->id != CTF_FIELD_CLASS_ID_INT &&
+ target_fc->id != CTF_FIELD_CLASS_ID_ENUM) {
+ BT_LOGE("Sequence field class's length field class is not an unsigned integer field class: "
+ "length-fc-addr=%p, length-fc-id=%d",
+ target_fc, target_fc->id);
ret = -1;
goto end;
}
- if (int_ft->is_signed) {
- BT_LOGE("Sequence field type's length field type is not an unsigned integer field type: "
- "length-ft-addr=%p, length-ft-id=%d",
- target_ft, target_ft->id);
+ if (int_fc->is_signed) {
+ BT_LOGE("Sequence field class's length field class is not an unsigned integer field class: "
+ "length-fc-addr=%p, length-fc-id=%d",
+ target_fc, target_fc->id);
ret = -1;
goto end;
}
}
/*
- * Resolves a variant or sequence field type `ft`.
+ * Resolves a variant or sequence field class `fc`.
*/
static
-int resolve_sequence_or_variant_field_type(struct ctf_field_type *ft,
+int resolve_sequence_or_variant_field_class(struct ctf_field_class *fc,
struct resolve_context *ctx)
{
int ret = 0;
const char *pathstr;
struct ctf_field_path target_field_path;
- struct ctf_field_type *target_ft = NULL;
+ struct ctf_field_class *target_fc = NULL;
GString *target_field_path_pretty = NULL;
const char *target_field_path_pretty_str;
ctf_field_path_init(&target_field_path);
/* Get path string */
- switch (ft->id) {
- case CTF_FIELD_TYPE_ID_SEQUENCE:
+ switch (fc->id) {
+ case CTF_FIELD_CLASS_ID_SEQUENCE:
{
- struct ctf_field_type_sequence *seq_ft = (void *) ft;
- pathstr = seq_ft->length_ref->str;
+ struct ctf_field_class_sequence *seq_fc = (void *) fc;
+ pathstr = seq_fc->length_ref->str;
break;
}
- case CTF_FIELD_TYPE_ID_VARIANT:
+ case CTF_FIELD_CLASS_ID_VARIANT:
{
- struct ctf_field_type_variant *var_ft = (void *) ft;
- pathstr = var_ft->tag_ref->str;
+ struct ctf_field_class_variant *var_fc = (void *) fc;
+ pathstr = var_fc->tag_ref->str;
break;
}
default:
target_field_path_pretty_str =
target_field_path_pretty ? target_field_path_pretty->str : NULL;
- /* Get target field type */
- target_ft = field_path_to_field_type(&target_field_path, ctx);
- if (!target_ft) {
- BT_LOGE("Cannot get target field type for path string: "
+ /* Get target field class */
+ target_fc = field_path_to_field_class(&target_field_path, ctx);
+ if (!target_fc) {
+ BT_LOGE("Cannot get target field class for path string: "
"path=\"%s\", target-field-path=\"%s\"",
pathstr, target_field_path_pretty_str);
ret = -1;
}
ret = validate_target_field_path(&target_field_path,
- target_ft, ctx);
+ target_fc, ctx);
if (ret) {
BT_LOGE("Invalid target field path for path string: "
"path=\"%s\", target-field-path=\"%s\"",
goto end;
}
- /* Set target field path and target field type */
- switch (ft->id) {
- case CTF_FIELD_TYPE_ID_SEQUENCE:
+ /* Set target field path and target field class */
+ switch (fc->id) {
+ case CTF_FIELD_CLASS_ID_SEQUENCE:
{
- struct ctf_field_type_sequence *seq_ft = (void *) ft;
+ struct ctf_field_class_sequence *seq_fc = (void *) fc;
- ctf_field_path_copy_content(&seq_ft->length_path,
+ ctf_field_path_copy_content(&seq_fc->length_path,
&target_field_path);
- seq_ft->length_ft = (void *) target_ft;
+ seq_fc->length_fc = (void *) target_fc;
break;
}
- case CTF_FIELD_TYPE_ID_VARIANT:
+ case CTF_FIELD_CLASS_ID_VARIANT:
{
- struct ctf_field_type_variant *var_ft = (void *) ft;
+ struct ctf_field_class_variant *var_fc = (void *) fc;
- ctf_field_path_copy_content(&var_ft->tag_path,
+ ctf_field_path_copy_content(&var_fc->tag_path,
&target_field_path);
- ctf_field_type_variant_set_tag_field_type(var_ft,
- (void *) target_ft);
+ ctf_field_class_variant_set_tag_field_class(var_fc,
+ (void *) target_fc);
break;
}
default:
}
/*
- * Resolves a field type `ft`.
+ * Resolves a field class `fc`.
*/
static
-int resolve_field_type(struct ctf_field_type *ft, struct resolve_context *ctx)
+int resolve_field_class(struct ctf_field_class *fc, struct resolve_context *ctx)
{
int ret = 0;
- if (!ft) {
- /* Type is not available; still valid */
+ if (!fc) {
+ /* Field class is not available; still valid */
goto end;
}
- ctx->cur_ft = ft;
+ ctx->cur_fc = fc;
- /* Resolve sequence/variant field type */
- switch (ft->id) {
- case CTF_FIELD_TYPE_ID_SEQUENCE:
- case CTF_FIELD_TYPE_ID_VARIANT:
- ret = resolve_sequence_or_variant_field_type(ft, ctx);
+ /* Resolve sequence/variant field class */
+ switch (fc->id) {
+ case CTF_FIELD_CLASS_ID_SEQUENCE:
+ case CTF_FIELD_CLASS_ID_VARIANT:
+ ret = resolve_sequence_or_variant_field_class(fc, ctx);
if (ret) {
- BT_LOGE("Cannot resolve sequence field type's length or variant field type's tag: "
- "ret=%d, ft-addr=%p", ret, ft);
+ BT_LOGE("Cannot resolve sequence field class's length or variant field class's tag: "
+ "ret=%d, fc-addr=%p", ret, fc);
goto end;
}
break;
}
- /* Recurse into compound types */
- switch (ft->id) {
- case CTF_FIELD_TYPE_ID_STRUCT:
- case CTF_FIELD_TYPE_ID_VARIANT:
- case CTF_FIELD_TYPE_ID_SEQUENCE:
- case CTF_FIELD_TYPE_ID_ARRAY:
+ /* Recurse into compound classes */
+ switch (fc->id) {
+ case CTF_FIELD_CLASS_ID_STRUCT:
+ case CTF_FIELD_CLASS_ID_VARIANT:
+ case CTF_FIELD_CLASS_ID_SEQUENCE:
+ case CTF_FIELD_CLASS_ID_ARRAY:
{
uint64_t i;
uint64_t field_count =
- ctf_field_type_compound_get_field_type_count(ft);
+ ctf_field_class_compound_get_field_class_count(fc);
- ret = field_type_stack_push(ctx->field_type_stack, ft);
+ ret = field_class_stack_push(ctx->field_class_stack, fc);
if (ret) {
- BT_LOGE("Cannot push field type on context's stack: "
- "ft-addr=%p", ft);
+ BT_LOGE("Cannot push field class on context's stack: "
+ "fc-addr=%p", fc);
goto end;
}
for (i = 0; i < field_count; i++) {
- struct ctf_field_type *child_ft =
- ctf_field_type_compound_borrow_field_type_by_index(
- ft, i);
+ struct ctf_field_class *child_fc =
+ ctf_field_class_compound_borrow_field_class_by_index(
+ fc, i);
- BT_ASSERT(child_ft);
+ BT_ASSERT(child_fc);
- if (ft->id == CTF_FIELD_TYPE_ID_ARRAY||
- ft->id == CTF_FIELD_TYPE_ID_SEQUENCE) {
- field_type_stack_peek(
- ctx->field_type_stack)->index = -1;
+ if (fc->id == CTF_FIELD_CLASS_ID_ARRAY||
+ fc->id == CTF_FIELD_CLASS_ID_SEQUENCE) {
+ field_class_stack_peek(
+ ctx->field_class_stack)->index = -1;
} else {
- field_type_stack_peek(
- ctx->field_type_stack)->index =
+ field_class_stack_peek(
+ ctx->field_class_stack)->index =
(int64_t) i;
}
- BT_LOGV("Resolving field type's child field type: "
- "parent-ft-addr=%p, child-ft-addr=%p, "
+ BT_LOGV("Resolving field class's child field class: "
+ "parent-fc-addr=%p, child-fc-addr=%p, "
"index=%" PRIu64 ", count=%" PRIu64,
- ft, child_ft, i, field_count);
- ret = resolve_field_type(child_ft, ctx);
+ fc, child_fc, i, field_count);
+ ret = resolve_field_class(child_fc, ctx);
if (ret) {
goto end;
}
}
- field_type_stack_pop(ctx->field_type_stack);
+ field_class_stack_pop(ctx->field_class_stack);
break;
}
default:
}
/*
- * Resolves the root field type corresponding to the scope `root_scope`.
+ * Resolves the root field class corresponding to the scope `root_scope`.
*/
static
-int resolve_root_type(enum bt_scope root_scope, struct resolve_context *ctx)
+int resolve_root_class(enum bt_scope root_scope, struct resolve_context *ctx)
{
int ret;
- BT_ASSERT(field_type_stack_size(ctx->field_type_stack) == 0);
+ BT_ASSERT(field_class_stack_size(ctx->field_class_stack) == 0);
ctx->root_scope = root_scope;
- ret = resolve_field_type(borrow_type_from_ctx(ctx, root_scope), ctx);
+ ret = resolve_field_class(borrow_class_from_ctx(ctx, root_scope), ctx);
ctx->root_scope = -1;
return ret;
}
static
-int resolve_event_class_field_types(struct resolve_context *ctx,
+int resolve_event_class_field_classes(struct resolve_context *ctx,
struct ctf_event_class *ec)
{
int ret = 0;
}
ctx->ec = ec;
- ctx->scopes.event_spec_context = ec->spec_context_ft;
- ret = resolve_root_type(BT_SCOPE_EVENT_COMMON_CONTEXT, ctx);
+ ctx->scopes.event_spec_context = ec->spec_context_fc;
+ ret = resolve_root_class(BT_SCOPE_EVENT_COMMON_CONTEXT, ctx);
if (ret) {
- BT_LOGE("Cannot resolve event specific context field type: "
+ BT_LOGE("Cannot resolve event specific context field class: "
"ret=%d", ret);
goto end;
}
- ctx->scopes.event_payload = ec->payload_ft;
- ret = resolve_root_type(BT_SCOPE_EVENT_PAYLOAD, ctx);
+ ctx->scopes.event_payload = ec->payload_fc;
+ ret = resolve_root_class(BT_SCOPE_EVENT_PAYLOAD, ctx);
if (ret) {
- BT_LOGE("Cannot resolve event payload field type: "
+ BT_LOGE("Cannot resolve event payload field class: "
"ret=%d", ret);
goto end;
}
}
static
-int resolve_stream_class_field_types(struct resolve_context *ctx,
+int resolve_stream_class_field_classes(struct resolve_context *ctx,
struct ctf_stream_class *sc)
{
int ret = 0;
ctx->sc = sc;
if (!sc->is_translated) {
- ctx->scopes.packet_context = sc->packet_context_ft;
- ret = resolve_root_type(BT_SCOPE_PACKET_CONTEXT, ctx);
+ ctx->scopes.packet_context = sc->packet_context_fc;
+ ret = resolve_root_class(BT_SCOPE_PACKET_CONTEXT, ctx);
if (ret) {
- BT_LOGE("Cannot resolve packet context field type: "
+ BT_LOGE("Cannot resolve packet context field class: "
"ret=%d", ret);
goto end;
}
- ctx->scopes.event_header = sc->event_header_ft;
- ret = resolve_root_type(BT_SCOPE_EVENT_HEADER, ctx);
+ ctx->scopes.event_header = sc->event_header_fc;
+ ret = resolve_root_class(BT_SCOPE_EVENT_HEADER, ctx);
if (ret) {
- BT_LOGE("Cannot resolve event header field type: "
+ BT_LOGE("Cannot resolve event header field class: "
"ret=%d", ret);
goto end;
}
- ctx->scopes.event_common_context = sc->event_common_context_ft;
- ret = resolve_root_type(BT_SCOPE_EVENT_SPECIFIC_CONTEXT, ctx);
+ ctx->scopes.event_common_context = sc->event_common_context_fc;
+ ret = resolve_root_class(BT_SCOPE_EVENT_SPECIFIC_CONTEXT, ctx);
if (ret) {
- BT_LOGE("Cannot resolve event common context field type: "
+ BT_LOGE("Cannot resolve event common context field class: "
"ret=%d", ret);
goto end;
}
}
- ctx->scopes.packet_context = sc->packet_context_ft;
- ctx->scopes.event_header = sc->event_header_ft;
- ctx->scopes.event_common_context = sc->event_common_context_ft;
+ ctx->scopes.packet_context = sc->packet_context_fc;
+ ctx->scopes.event_header = sc->event_header_fc;
+ ctx->scopes.event_common_context = sc->event_common_context_fc;
for (i = 0; i < sc->event_classes->len; i++) {
struct ctf_event_class *ec = sc->event_classes->pdata[i];
- ret = resolve_event_class_field_types(ctx, ec);
+ ret = resolve_event_class_field_classes(ctx, ec);
if (ret) {
- BT_LOGE("Cannot resolve event class's field types: "
+ BT_LOGE("Cannot resolve event class's field classes: "
"ec-id=%" PRIu64 ", ec-name=\"%s\"",
ec->id, ec->name->str);
goto end;
}
BT_HIDDEN
-int ctf_trace_class_resolve_field_types(struct ctf_trace_class *tc)
+int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc)
{
int ret = 0;
uint64_t i;
.sc = NULL,
.ec = NULL,
.scopes = {
- .packet_header = tc->packet_header_ft,
+ .packet_header = tc->packet_header_fc,
.packet_context = NULL,
.event_header = NULL,
.event_common_context = NULL,
.event_payload = NULL,
},
.root_scope = BT_SCOPE_PACKET_HEADER,
- .cur_ft = NULL,
+ .cur_fc = NULL,
};
- /* Initialize type stack */
- ctx.field_type_stack = field_type_stack_create();
- if (!ctx.field_type_stack) {
- BT_LOGE_STR("Cannot create field type stack.");
+ /* Initialize class stack */
+ ctx.field_class_stack = field_class_stack_create();
+ if (!ctx.field_class_stack) {
+ BT_LOGE_STR("Cannot create field class stack.");
ret = -1;
goto end;
}
if (!tc->is_translated) {
- ctx.scopes.packet_header = tc->packet_header_ft;
- ret = resolve_root_type(BT_SCOPE_PACKET_HEADER, &ctx);
+ ctx.scopes.packet_header = tc->packet_header_fc;
+ ret = resolve_root_class(BT_SCOPE_PACKET_HEADER, &ctx);
if (ret) {
- BT_LOGE("Cannot resolve packet header field type: "
+ BT_LOGE("Cannot resolve packet header field class: "
"ret=%d", ret);
goto end;
}
}
- ctx.scopes.packet_header = tc->packet_header_ft;
+ ctx.scopes.packet_header = tc->packet_header_fc;
for (i = 0; i < tc->stream_classes->len; i++) {
struct ctf_stream_class *sc = tc->stream_classes->pdata[i];
- ret = resolve_stream_class_field_types(&ctx, sc);
+ ret = resolve_stream_class_field_classes(&ctx, sc);
if (ret) {
- BT_LOGE("Cannot resolve stream class's field types: "
+ BT_LOGE("Cannot resolve stream class's field classes: "
"sc-id=%" PRIu64, sc->id);
goto end;
}
}
end:
- field_type_stack_destroy(ctx.field_type_stack);
+ field_class_stack_destroy(ctx.field_class_stack);
return ret;
}
#include "ctf-meta-visitors.h"
static inline
-struct bt_field_type *ctf_field_type_to_ir(struct ctf_field_type *ft,
+struct bt_field_class *ctf_field_class_to_ir(struct ctf_field_class *fc,
struct ctf_trace_class *tc,
struct ctf_stream_class *sc,
struct ctf_event_class *ec);
static inline
-void ctf_field_type_int_set_props(struct ctf_field_type_int *ft,
- struct bt_field_type *ir_ft)
+void ctf_field_class_int_set_props(struct ctf_field_class_int *fc,
+ struct bt_field_class *ir_fc)
{
int ret;
- ret = bt_field_type_integer_set_field_value_range(ir_ft, ft->base.size);
+ ret = bt_field_class_integer_set_field_value_range(ir_fc, fc->base.size);
BT_ASSERT(ret == 0);
- ret = bt_field_type_integer_set_preferred_display_base(ir_ft,
- ft->disp_base);
+ ret = bt_field_class_integer_set_preferred_display_base(ir_fc,
+ fc->disp_base);
BT_ASSERT(ret == 0);
}
static inline
-struct bt_field_type *ctf_field_type_int_to_ir(struct ctf_field_type_int *ft)
+struct bt_field_class *ctf_field_class_int_to_ir(struct ctf_field_class_int *fc)
{
- struct bt_field_type *ir_ft;
+ struct bt_field_class *ir_fc;
- if (ft->is_signed) {
- ir_ft = bt_field_type_signed_integer_create();
+ if (fc->is_signed) {
+ ir_fc = bt_field_class_signed_integer_create();
} else {
- ir_ft = bt_field_type_unsigned_integer_create();
+ ir_fc = bt_field_class_unsigned_integer_create();
}
- BT_ASSERT(ir_ft);
- ctf_field_type_int_set_props(ft, ir_ft);
- return ir_ft;
+ BT_ASSERT(ir_fc);
+ ctf_field_class_int_set_props(fc, ir_fc);
+ return ir_fc;
}
static inline
-struct bt_field_type *ctf_field_type_enum_to_ir(struct ctf_field_type_enum *ft)
+struct bt_field_class *ctf_field_class_enum_to_ir(struct ctf_field_class_enum *fc)
{
int ret;
- struct bt_field_type *ir_ft;
+ struct bt_field_class *ir_fc;
uint64_t i;
- if (ft->base.is_signed) {
- ir_ft = bt_field_type_signed_enumeration_create();
+ if (fc->base.is_signed) {
+ ir_fc = bt_field_class_signed_enumeration_create();
} else {
- ir_ft = bt_field_type_unsigned_enumeration_create();
+ ir_fc = bt_field_class_unsigned_enumeration_create();
}
- BT_ASSERT(ir_ft);
- ctf_field_type_int_set_props((void *) ft, ir_ft);
+ BT_ASSERT(ir_fc);
+ ctf_field_class_int_set_props((void *) fc, ir_fc);
- for (i = 0; i < ft->mappings->len; i++) {
- struct ctf_field_type_enum_mapping *mapping =
- ctf_field_type_enum_borrow_mapping_by_index(ft, i);
+ for (i = 0; i < fc->mappings->len; i++) {
+ struct ctf_field_class_enum_mapping *mapping =
+ ctf_field_class_enum_borrow_mapping_by_index(fc, i);
- if (ft->base.is_signed) {
- ret = bt_field_type_signed_enumeration_map_range(
- ir_ft, mapping->label->str,
+ if (fc->base.is_signed) {
+ ret = bt_field_class_signed_enumeration_map_range(
+ ir_fc, mapping->label->str,
mapping->range.lower.i, mapping->range.upper.i);
} else {
- ret = bt_field_type_unsigned_enumeration_map_range(
- ir_ft, mapping->label->str,
+ ret = bt_field_class_unsigned_enumeration_map_range(
+ ir_fc, mapping->label->str,
mapping->range.lower.u, mapping->range.upper.u);
}
BT_ASSERT(ret == 0);
}
- return ir_ft;
+ return ir_fc;
}
static inline
-struct bt_field_type *ctf_field_type_float_to_ir(
- struct ctf_field_type_float *ft)
+struct bt_field_class *ctf_field_class_float_to_ir(
+ struct ctf_field_class_float *fc)
{
- struct bt_field_type *ir_ft;
+ struct bt_field_class *ir_fc;
int ret;
- ir_ft = bt_field_type_real_create();
- BT_ASSERT(ir_ft);
+ ir_fc = bt_field_class_real_create();
+ BT_ASSERT(ir_fc);
- if (ft->base.size == 32) {
- ret = bt_field_type_real_set_is_single_precision(ir_ft,
+ if (fc->base.size == 32) {
+ ret = bt_field_class_real_set_is_single_precision(ir_fc,
BT_TRUE);
BT_ASSERT(ret == 0);
}
- return ir_ft;
+ return ir_fc;
}
static inline
-struct bt_field_type *ctf_field_type_string_to_ir(
- struct ctf_field_type_string *ft)
+struct bt_field_class *ctf_field_class_string_to_ir(
+ struct ctf_field_class_string *fc)
{
- struct bt_field_type *ir_ft = bt_field_type_string_create();
+ struct bt_field_class *ir_fc = bt_field_class_string_create();
- BT_ASSERT(ir_ft);
- return ir_ft;
+ BT_ASSERT(ir_fc);
+ return ir_fc;
}
static inline
-struct bt_field_type *ctf_field_type_struct_to_ir(
- struct ctf_field_type_struct *ft,
+struct bt_field_class *ctf_field_class_struct_to_ir(
+ struct ctf_field_class_struct *fc,
struct ctf_trace_class *tc,
struct ctf_stream_class *sc,
struct ctf_event_class *ec)
{
int ret;
- struct bt_field_type *ir_ft = bt_field_type_structure_create();
+ struct bt_field_class *ir_fc = bt_field_class_structure_create();
uint64_t i;
- BT_ASSERT(ir_ft);
+ BT_ASSERT(ir_fc);
- 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);
- struct bt_field_type *member_ir_ft;
+ 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);
+ struct bt_field_class *member_ir_fc;
- if (!named_ft->ft->in_ir) {
+ if (!named_fc->fc->in_ir) {
continue;
}
- member_ir_ft = ctf_field_type_to_ir(named_ft->ft, tc, sc, ec);
- BT_ASSERT(member_ir_ft);
- ret = bt_field_type_structure_append_member(ir_ft,
- named_ft->name->str, member_ir_ft);
+ member_ir_fc = ctf_field_class_to_ir(named_fc->fc, tc, sc, ec);
+ BT_ASSERT(member_ir_fc);
+ ret = bt_field_class_structure_append_member(ir_fc,
+ named_fc->name->str, member_ir_fc);
BT_ASSERT(ret == 0);
- bt_put(member_ir_ft);
+ bt_put(member_ir_fc);
}
- return ir_ft;
+ return ir_fc;
}
static inline
-struct bt_field_type *borrow_ir_ft_from_field_path(
+struct 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)
{
- struct bt_field_type *ir_ft = NULL;
- struct ctf_field_type *ft = ctf_field_path_borrow_field_type(
+ struct bt_field_class *ir_fc = NULL;
+ struct ctf_field_class *fc = ctf_field_path_borrow_field_class(
field_path, tc, sc, ec);
- BT_ASSERT(ft);
+ BT_ASSERT(fc);
- if (ft->in_ir) {
- ir_ft = ft->ir_ft;
+ if (fc->in_ir) {
+ ir_fc = fc->ir_fc;
}
- return ir_ft;
+ return ir_fc;
}
static inline
-struct bt_field_type *ctf_field_type_variant_to_ir(
- struct ctf_field_type_variant *ft,
+struct bt_field_class *ctf_field_class_variant_to_ir(
+ struct ctf_field_class_variant *fc,
struct ctf_trace_class *tc,
struct ctf_stream_class *sc,
struct ctf_event_class *ec)
{
int ret;
- struct bt_field_type *ir_ft = bt_field_type_variant_create();
+ struct bt_field_class *ir_fc = bt_field_class_variant_create();
uint64_t i;
- BT_ASSERT(ir_ft);
- ret = bt_field_type_variant_set_selector_field_type(ir_ft,
- borrow_ir_ft_from_field_path(&ft->tag_path, tc, sc, ec));
+ 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);
- 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);
- struct bt_field_type *option_ir_ft;
+ 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);
+ struct bt_field_class *option_ir_fc;
- BT_ASSERT(named_ft->ft->in_ir);
- option_ir_ft = ctf_field_type_to_ir(named_ft->ft, tc, sc, ec);
- BT_ASSERT(option_ir_ft);
- ret = bt_field_type_variant_append_option(ir_ft,
- named_ft->name->str, option_ir_ft);
+ BT_ASSERT(named_fc->fc->in_ir);
+ option_ir_fc = ctf_field_class_to_ir(named_fc->fc, tc, sc, ec);
+ BT_ASSERT(option_ir_fc);
+ ret = bt_field_class_variant_append_option(ir_fc,
+ named_fc->name->str, option_ir_fc);
BT_ASSERT(ret == 0);
- bt_put(option_ir_ft);
+ bt_put(option_ir_fc);
}
- return ir_ft;
+ return ir_fc;
}
static inline
-struct bt_field_type *ctf_field_type_array_to_ir(
- struct ctf_field_type_array *ft,
+struct bt_field_class *ctf_field_class_array_to_ir(
+ struct ctf_field_class_array *fc,
struct ctf_trace_class *tc,
struct ctf_stream_class *sc,
struct ctf_event_class *ec)
{
- struct bt_field_type *ir_ft;
- struct bt_field_type *elem_ir_ft;
+ struct bt_field_class *ir_fc;
+ struct bt_field_class *elem_ir_fc;
- if (ft->base.is_text) {
- ir_ft = bt_field_type_string_create();
- BT_ASSERT(ir_ft);
+ if (fc->base.is_text) {
+ ir_fc = bt_field_class_string_create();
+ BT_ASSERT(ir_fc);
goto end;
}
- elem_ir_ft = ctf_field_type_to_ir(ft->base.elem_ft, tc, sc, ec);
- BT_ASSERT(elem_ir_ft);
- ir_ft = bt_field_type_static_array_create(elem_ir_ft, ft->length);
- BT_ASSERT(ir_ft);
- bt_put(elem_ir_ft);
+ elem_ir_fc = ctf_field_class_to_ir(fc->base.elem_fc, tc, sc, ec);
+ BT_ASSERT(elem_ir_fc);
+ ir_fc = bt_field_class_static_array_create(elem_ir_fc, fc->length);
+ BT_ASSERT(ir_fc);
+ bt_put(elem_ir_fc);
end:
- return ir_ft;
+ return ir_fc;
}
static inline
-struct bt_field_type *ctf_field_type_sequence_to_ir(
- struct ctf_field_type_sequence *ft,
+struct bt_field_class *ctf_field_class_sequence_to_ir(
+ struct ctf_field_class_sequence *fc,
struct ctf_trace_class *tc,
struct ctf_stream_class *sc,
struct ctf_event_class *ec)
{
int ret;
- struct bt_field_type *ir_ft;
- struct bt_field_type *elem_ir_ft;
+ struct bt_field_class *ir_fc;
+ struct bt_field_class *elem_ir_fc;
- if (ft->base.is_text) {
- ir_ft = bt_field_type_string_create();
- BT_ASSERT(ir_ft);
+ if (fc->base.is_text) {
+ ir_fc = bt_field_class_string_create();
+ BT_ASSERT(ir_fc);
goto end;
}
- elem_ir_ft = ctf_field_type_to_ir(ft->base.elem_ft, tc, sc, ec);
- BT_ASSERT(elem_ir_ft);
- ir_ft = bt_field_type_dynamic_array_create(elem_ir_ft);
- BT_ASSERT(ir_ft);
- bt_put(elem_ir_ft);
- BT_ASSERT(ir_ft);
- ret = bt_field_type_dynamic_array_set_length_field_type(ir_ft,
- borrow_ir_ft_from_field_path(&ft->length_path, tc, sc, ec));
+ elem_ir_fc = ctf_field_class_to_ir(fc->base.elem_fc, tc, sc, ec);
+ BT_ASSERT(elem_ir_fc);
+ ir_fc = bt_field_class_dynamic_array_create(elem_ir_fc);
+ BT_ASSERT(ir_fc);
+ bt_put(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);
end:
- return ir_ft;
+ return ir_fc;
}
static inline
-struct bt_field_type *ctf_field_type_to_ir(struct ctf_field_type *ft,
+struct bt_field_class *ctf_field_class_to_ir(struct ctf_field_class *fc,
struct ctf_trace_class *tc,
struct ctf_stream_class *sc,
struct ctf_event_class *ec)
{
- struct bt_field_type *ir_ft = NULL;
+ struct bt_field_class *ir_fc = NULL;
- BT_ASSERT(ft);
- BT_ASSERT(ft->in_ir);
+ BT_ASSERT(fc);
+ BT_ASSERT(fc->in_ir);
- switch (ft->id) {
- case CTF_FIELD_TYPE_ID_INT:
- ir_ft = ctf_field_type_int_to_ir((void *) ft);
+ switch (fc->id) {
+ case CTF_FIELD_CLASS_ID_INT:
+ ir_fc = ctf_field_class_int_to_ir((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_ENUM:
- ir_ft = ctf_field_type_enum_to_ir((void *) ft);
+ case CTF_FIELD_CLASS_ID_ENUM:
+ ir_fc = ctf_field_class_enum_to_ir((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_FLOAT:
- ir_ft = ctf_field_type_float_to_ir((void *) ft);
+ case CTF_FIELD_CLASS_ID_FLOAT:
+ ir_fc = ctf_field_class_float_to_ir((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_STRING:
- ir_ft = ctf_field_type_string_to_ir((void *) ft);
+ case CTF_FIELD_CLASS_ID_STRING:
+ ir_fc = ctf_field_class_string_to_ir((void *) fc);
break;
- case CTF_FIELD_TYPE_ID_STRUCT:
- ir_ft = ctf_field_type_struct_to_ir((void *) ft, tc, sc, ec);
+ case CTF_FIELD_CLASS_ID_STRUCT:
+ ir_fc = ctf_field_class_struct_to_ir((void *) fc, tc, sc, ec);
break;
- case CTF_FIELD_TYPE_ID_ARRAY:
- ir_ft = ctf_field_type_array_to_ir((void *) ft, tc, sc, ec);
+ case CTF_FIELD_CLASS_ID_ARRAY:
+ ir_fc = ctf_field_class_array_to_ir((void *) fc, tc, sc, ec);
break;
- case CTF_FIELD_TYPE_ID_SEQUENCE:
- ir_ft = ctf_field_type_sequence_to_ir((void *) ft, tc, sc, ec);
+ case CTF_FIELD_CLASS_ID_SEQUENCE:
+ ir_fc = ctf_field_class_sequence_to_ir((void *) fc, tc, sc, ec);
break;
- case CTF_FIELD_TYPE_ID_VARIANT:
- ir_ft = ctf_field_type_variant_to_ir((void *) ft, tc, sc, ec);
+ case CTF_FIELD_CLASS_ID_VARIANT:
+ ir_fc = ctf_field_class_variant_to_ir((void *) fc, tc, sc, ec);
break;
default:
abort();
}
- ft->ir_ft = ir_ft;
- return ir_ft;
+ fc->ir_fc = ir_fc;
+ return ir_fc;
}
static inline
-bool ctf_field_type_struct_has_immediate_member_in_ir(
- struct ctf_field_type_struct *ft)
+bool ctf_field_class_struct_has_immediate_member_in_ir(
+ struct ctf_field_class_struct *fc)
{
uint64_t i;
bool has_immediate_member_in_ir = false;
- 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 (named_ft->ft->in_ir) {
+ if (named_fc->fc->in_ir) {
has_immediate_member_in_ir = true;
goto end;
}
}
static inline
-struct bt_field_type *scope_ctf_field_type_to_ir(struct ctf_field_type *ft,
+struct bt_field_class *scope_ctf_field_class_to_ir(struct ctf_field_class *fc,
struct ctf_trace_class *tc,
struct ctf_stream_class *sc,
struct ctf_event_class *ec)
{
- struct bt_field_type *ir_ft = NULL;
+ struct bt_field_class *ir_fc = NULL;
- if (!ft) {
+ if (!fc) {
goto end;
}
- BT_ASSERT(ft->id == CTF_FIELD_TYPE_ID_STRUCT);
+ BT_ASSERT(fc->id == CTF_FIELD_CLASS_ID_STRUCT);
- if (!ctf_field_type_struct_has_immediate_member_in_ir((void *) ft)) {
+ 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;
}
- ir_ft = ctf_field_type_to_ir(ft, tc, sc, ec);
+ ir_fc = ctf_field_class_to_ir(fc, tc, sc, ec);
end:
- return ir_ft;
+ return ir_fc;
}
static inline
-struct ctf_field_type_int *borrow_named_int_field_type(
- struct ctf_field_type_struct *struct_ft, const char *name)
+struct ctf_field_class_int *borrow_named_int_field_class(
+ struct ctf_field_class_struct *struct_fc, const char *name)
{
- struct ctf_named_field_type *named_ft = NULL;
- struct ctf_field_type_int *int_ft = NULL;
+ struct ctf_named_field_class *named_fc = NULL;
+ struct ctf_field_class_int *int_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;
}
- if (named_ft->ft->id != CTF_FIELD_TYPE_ID_INT &&
- named_ft->ft->id != CTF_FIELD_TYPE_ID_ENUM) {
+ if (named_fc->fc->id != CTF_FIELD_CLASS_ID_INT &&
+ named_fc->fc->id != CTF_FIELD_CLASS_ID_ENUM) {
goto end;
}
- int_ft = (void *) named_ft->ft;
+ int_fc = (void *) named_fc->fc;
end:
- return int_ft;
+ return int_fc;
}
static inline
BT_ASSERT(ir_ec);
bt_put(ir_ec);
- if (ec->spec_context_ft) {
- struct bt_field_type *ir_ft = scope_ctf_field_type_to_ir(
- ec->spec_context_ft, tc, sc, ec);
+ if (ec->spec_context_fc) {
+ struct bt_field_class *ir_fc = scope_ctf_field_class_to_ir(
+ ec->spec_context_fc, tc, sc, ec);
- if (ir_ft) {
- ret = bt_event_class_set_specific_context_field_type(
- ir_ec, ir_ft);
+ if (ir_fc) {
+ ret = bt_event_class_set_specific_context_field_class(
+ ir_ec, ir_fc);
BT_ASSERT(ret == 0);
- bt_put(ir_ft);
+ bt_put(ir_fc);
}
}
- if (ec->payload_ft) {
- struct bt_field_type *ir_ft = scope_ctf_field_type_to_ir(
- ec->payload_ft, tc, sc, ec);
+ if (ec->payload_fc) {
+ struct bt_field_class *ir_fc = scope_ctf_field_class_to_ir(
+ ec->payload_fc, tc, sc, ec);
- if (ir_ft) {
- ret = bt_event_class_set_payload_field_type(ir_ec,
- ir_ft);
+ if (ir_fc) {
+ ret = bt_event_class_set_payload_field_class(ir_ec,
+ ir_fc);
BT_ASSERT(ret == 0);
- bt_put(ir_ft);
+ bt_put(ir_fc);
}
}
{
int ret;
struct bt_stream_class *ir_sc = NULL;
- struct ctf_field_type_int *int_ft;
+ struct ctf_field_class_int *int_fc;
if (sc->is_translated) {
ir_sc = bt_trace_borrow_stream_class_by_id(ir_trace, sc->id);
BT_ASSERT(ir_sc);
bt_put(ir_sc);
- if (sc->packet_context_ft) {
- struct bt_field_type *ir_ft = scope_ctf_field_type_to_ir(
- sc->packet_context_ft, tc, sc, NULL);
+ if (sc->packet_context_fc) {
+ struct bt_field_class *ir_fc = scope_ctf_field_class_to_ir(
+ sc->packet_context_fc, tc, sc, NULL);
- if (ir_ft) {
- ret = bt_stream_class_set_packet_context_field_type(
- ir_sc, ir_ft);
+ if (ir_fc) {
+ ret = bt_stream_class_set_packet_context_field_class(
+ ir_sc, ir_fc);
BT_ASSERT(ret == 0);
- bt_put(ir_ft);
+ bt_put(ir_fc);
}
}
- if (sc->event_header_ft) {
- struct bt_field_type *ir_ft = scope_ctf_field_type_to_ir(
- sc->event_header_ft, tc, sc, NULL);
+ if (sc->event_header_fc) {
+ struct bt_field_class *ir_fc = scope_ctf_field_class_to_ir(
+ sc->event_header_fc, tc, sc, NULL);
- if (ir_ft) {
- ret = bt_stream_class_set_event_header_field_type(ir_sc,
- ir_ft);
+ if (ir_fc) {
+ ret = bt_stream_class_set_event_header_field_class(ir_sc,
+ ir_fc);
BT_ASSERT(ret == 0);
- bt_put(ir_ft);
+ bt_put(ir_fc);
}
}
- if (sc->event_common_context_ft) {
- struct bt_field_type *ir_ft = scope_ctf_field_type_to_ir(
- sc->event_common_context_ft, tc, sc, NULL);
+ if (sc->event_common_context_fc) {
+ struct bt_field_class *ir_fc = scope_ctf_field_class_to_ir(
+ sc->event_common_context_fc, tc, sc, NULL);
- if (ir_ft) {
- ret = bt_stream_class_set_event_common_context_field_type(
- ir_sc, ir_ft);
+ if (ir_fc) {
+ ret = bt_stream_class_set_event_common_context_field_class(
+ ir_sc, ir_fc);
BT_ASSERT(ret == 0);
- bt_put(ir_ft);
+ bt_put(ir_fc);
}
}
BT_ASSERT(ret == 0);
}
- int_ft = borrow_named_int_field_type((void *) sc->packet_context_ft,
+ int_fc = borrow_named_int_field_class((void *) sc->packet_context_fc,
"events_discarded");
- if (int_ft) {
- if (int_ft->meaning == CTF_FIELD_TYPE_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT) {
+ if (int_fc) {
+ if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT) {
ret = bt_stream_class_set_packets_have_discarded_event_counter_snapshot(
ir_sc, BT_TRUE);
BT_ASSERT(ret == 0);
}
}
- int_ft = borrow_named_int_field_type((void *) sc->packet_context_ft,
+ int_fc = borrow_named_int_field_class((void *) sc->packet_context_fc,
"packet_seq_num");
- if (int_ft) {
- if (int_ft->meaning == CTF_FIELD_TYPE_MEANING_PACKET_COUNTER_SNAPSHOT) {
+ if (int_fc) {
+ if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT) {
ret = bt_stream_class_set_packets_have_packet_counter_snapshot(
ir_sc, BT_TRUE);
BT_ASSERT(ret == 0);
}
}
- int_ft = borrow_named_int_field_type((void *) sc->packet_context_ft,
+ int_fc = borrow_named_int_field_class((void *) sc->packet_context_fc,
"timestamp_begin");
- if (int_ft) {
- if (int_ft->meaning == CTF_FIELD_TYPE_MEANING_PACKET_BEGINNING_TIME) {
+ if (int_fc) {
+ if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME) {
ret = bt_stream_class_set_packets_have_default_beginning_clock_value(
ir_sc, BT_TRUE);
BT_ASSERT(ret == 0);
}
}
- int_ft = borrow_named_int_field_type((void *) sc->packet_context_ft,
+ int_fc = borrow_named_int_field_class((void *) sc->packet_context_fc,
"timestamp_end");
- if (int_ft) {
- if (int_ft->meaning == CTF_FIELD_TYPE_MEANING_PACKET_END_TIME) {
+ if (int_fc) {
+ if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_END_TIME) {
ret = bt_stream_class_set_packets_have_default_end_clock_value(
ir_sc, BT_TRUE);
BT_ASSERT(ret == 0);
goto end;
}
- if (tc->packet_header_ft) {
- struct bt_field_type *ir_ft = scope_ctf_field_type_to_ir(
- tc->packet_header_ft, tc, NULL, NULL);
+ if (tc->packet_header_fc) {
+ struct bt_field_class *ir_fc = scope_ctf_field_class_to_ir(
+ tc->packet_header_fc, tc, NULL, NULL);
- if (ir_ft) {
- ret = bt_trace_set_packet_header_field_type(ir_trace,
- ir_ft);
+ if (ir_fc) {
+ ret = bt_trace_set_packet_header_field_class(ir_trace,
+ ir_fc);
BT_ASSERT(ret == 0);
- bt_put(ir_ft);
+ bt_put(ir_fc);
}
}
#include "ctf-meta-visitors.h"
static inline
-int find_mapped_clock_class(struct ctf_field_type *ft,
+int find_mapped_clock_class(struct ctf_field_class *fc,
struct bt_clock_class **clock_class)
{
int ret = 0;
uint64_t i;
- if (!ft) {
+ if (!fc) {
goto end;
}
- switch (ft->id) {
- case CTF_FIELD_TYPE_ID_INT:
- case CTF_FIELD_TYPE_ID_ENUM:
+ switch (fc->id) {
+ case CTF_FIELD_CLASS_ID_INT:
+ case CTF_FIELD_CLASS_ID_ENUM:
{
- struct ctf_field_type_int *int_ft = (void *) ft;
+ struct ctf_field_class_int *int_fc = (void *) fc;
- if (int_ft->mapped_clock_class) {
+ if (int_fc->mapped_clock_class) {
if (*clock_class && *clock_class !=
- int_ft->mapped_clock_class) {
+ int_fc->mapped_clock_class) {
BT_LOGE("Stream class contains more than one "
"clock class: expected-cc-name=\"%s\", "
"other-cc-name=\"%s\"",
bt_clock_class_get_name(*clock_class),
- bt_clock_class_get_name(int_ft->mapped_clock_class));
+ bt_clock_class_get_name(int_fc->mapped_clock_class));
ret = -1;
goto end;
}
- *clock_class = int_ft->mapped_clock_class;
+ *clock_class = int_fc->mapped_clock_class;
}
break;
}
- case CTF_FIELD_TYPE_ID_STRUCT:
+ case CTF_FIELD_CLASS_ID_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);
- ret = find_mapped_clock_class(named_ft->ft,
+ ret = find_mapped_clock_class(named_fc->fc,
clock_class);
if (ret) {
goto end;
break;
}
- case CTF_FIELD_TYPE_ID_VARIANT:
+ case CTF_FIELD_CLASS_ID_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);
- ret = find_mapped_clock_class(named_ft->ft,
+ ret = find_mapped_clock_class(named_fc->fc,
clock_class);
if (ret) {
goto end;
break;
}
- case CTF_FIELD_TYPE_ID_ARRAY:
- case CTF_FIELD_TYPE_ID_SEQUENCE:
+ case CTF_FIELD_CLASS_ID_ARRAY:
+ case CTF_FIELD_CLASS_ID_SEQUENCE:
{
- struct ctf_field_type_array_base *array_ft = (void *) ft;
+ struct ctf_field_class_array_base *array_fc = (void *) fc;
- ret = find_mapped_clock_class(array_ft->elem_ft, clock_class);
+ ret = find_mapped_clock_class(array_fc->elem_fc, clock_class);
if (ret) {
goto end;
}
struct bt_clock_class *clock_class = stream_class->default_clock_class;
uint64_t i;
- ret = find_mapped_clock_class(stream_class->packet_context_ft,
+ ret = find_mapped_clock_class(stream_class->packet_context_fc,
&clock_class);
if (ret) {
goto end;
}
- ret = find_mapped_clock_class(stream_class->event_header_ft,
+ ret = find_mapped_clock_class(stream_class->event_header_fc,
&clock_class);
if (ret) {
goto end;
}
- ret = find_mapped_clock_class(stream_class->event_common_context_ft,
+ ret = find_mapped_clock_class(stream_class->event_common_context_fc,
&clock_class);
if (ret) {
goto end;
struct ctf_event_class *event_class =
stream_class->event_classes->pdata[i];
- ret = find_mapped_clock_class(event_class->spec_context_ft,
+ ret = find_mapped_clock_class(event_class->spec_context_fc,
&clock_class);
if (ret) {
goto end;
}
- ret = find_mapped_clock_class(event_class->payload_ft,
+ ret = find_mapped_clock_class(event_class->payload_fc,
&clock_class);
if (ret) {
goto end;
int ret = 0;
struct bt_clock_class *clock_class = NULL;
- ret = find_mapped_clock_class(ctf_tc->packet_header_ft,
+ ret = find_mapped_clock_class(ctf_tc->packet_header_fc,
&clock_class);
if (ret) {
goto end;
#include "ctf-meta-visitors.h"
static
-void update_field_type_in_ir(struct ctf_field_type *ft,
+void update_field_class_in_ir(struct ctf_field_class *fc,
GHashTable *ft_dependents)
{
int64_t i;
- if (!ft) {
+ if (!fc) {
goto end;
}
- switch (ft->id) {
- case CTF_FIELD_TYPE_ID_INT:
- case CTF_FIELD_TYPE_ID_ENUM:
+ switch (fc->id) {
+ case CTF_FIELD_CLASS_ID_INT:
+ case CTF_FIELD_CLASS_ID_ENUM:
{
- struct ctf_field_type_int *int_ft = (void *) ft;
+ struct ctf_field_class_int *int_fc = (void *) fc;
- if (int_ft->mapped_clock_class ||
- int_ft->meaning == CTF_FIELD_TYPE_MEANING_NONE ||
- bt_g_hash_table_contains(ft_dependents, ft)) {
+ if (int_fc->mapped_clock_class ||
+ int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE ||
+ bt_g_hash_table_contains(ft_dependents, fc)) {
/*
- * Field type does not update a clock, has no
+ * Field class does not update a clock, has no
* special meaning, and no sequence/variant
- * field type which is part of IR depends on it.
+ * field class which is part of IR depends on it.
*/
- ft->in_ir = true;
+ fc->in_ir = true;
}
break;
}
- case CTF_FIELD_TYPE_ID_STRUCT:
+ case CTF_FIELD_CLASS_ID_STRUCT:
{
- struct ctf_field_type_struct *struct_ft = (void *) ft;
+ struct ctf_field_class_struct *struct_fc = (void *) fc;
/* Reverse order */
- for (i = (int64_t) struct_ft->members->len - 1; i >= 0; i--) {
- struct ctf_named_field_type *named_ft =
- ctf_field_type_struct_borrow_member_by_index(
- struct_ft, i);
+ for (i = (int64_t) struct_fc->members->len - 1; i >= 0; i--) {
+ struct ctf_named_field_class *named_fc =
+ ctf_field_class_struct_borrow_member_by_index(
+ struct_fc, i);
- update_field_type_in_ir(named_ft->ft, ft_dependents);
+ update_field_class_in_ir(named_fc->fc, ft_dependents);
- if (named_ft->ft->in_ir) {
+ if (named_fc->fc->in_ir) {
/* At least one member is part of IR */
- ft->in_ir = true;
+ fc->in_ir = true;
}
}
break;
}
- case CTF_FIELD_TYPE_ID_VARIANT:
+ case CTF_FIELD_CLASS_ID_VARIANT:
{
- struct ctf_named_field_type *named_ft;
- struct ctf_field_type_variant *var_ft = (void *) ft;
+ struct ctf_named_field_class *named_fc;
+ struct ctf_field_class_variant *var_fc = (void *) fc;
/*
* Reverse order, although it is not important for this
- * loop because a field type within a variant field
- * type's option cannot depend on a field type in
- * another option of the same variant field type.
+ * loop because a field class within a variant field
+ * type's option cannot depend on a field class in
+ * another option of the same variant field class.
*/
- for (i = (int64_t) var_ft->options->len - 1; i >= 0; i--) {
- named_ft =
- ctf_field_type_variant_borrow_option_by_index(
- var_ft, i);
+ for (i = (int64_t) var_fc->options->len - 1; i >= 0; i--) {
+ named_fc =
+ ctf_field_class_variant_borrow_option_by_index(
+ var_fc, i);
- update_field_type_in_ir(named_ft->ft, ft_dependents);
+ update_field_class_in_ir(named_fc->fc, ft_dependents);
- if (named_ft->ft->in_ir) {
+ if (named_fc->fc->in_ir) {
/* At least one option is part of IR */
- ft->in_ir = true;
+ fc->in_ir = true;
}
}
- if (ft->in_ir) {
+ if (fc->in_ir) {
/*
* At least one option will make it to IR. In
* this case, make all options part of IR
* example, but at least all the options are
* selectable.
*/
- for (i = 0; i < var_ft->options->len; i++) {
- ctf_field_type_variant_borrow_option_by_index(
- var_ft, i)->ft->in_ir = true;
+ for (i = 0; i < var_fc->options->len; i++) {
+ ctf_field_class_variant_borrow_option_by_index(
+ var_fc, i)->fc->in_ir = true;
}
/*
- * This variant field type is part of IR and
- * depends on a tag field type (which must also
+ * This variant field class is part of IR and
+ * depends on a tag field class (which must also
* be part of IR).
*/
- g_hash_table_insert(ft_dependents, var_ft->tag_ft,
- var_ft->tag_ft);
+ g_hash_table_insert(ft_dependents, var_fc->tag_fc,
+ var_fc->tag_fc);
}
break;
}
- case CTF_FIELD_TYPE_ID_ARRAY:
- case CTF_FIELD_TYPE_ID_SEQUENCE:
+ case CTF_FIELD_CLASS_ID_ARRAY:
+ case CTF_FIELD_CLASS_ID_SEQUENCE:
{
- struct ctf_field_type_array_base *array_ft = (void *) ft;
+ struct ctf_field_class_array_base *array_fc = (void *) fc;
- update_field_type_in_ir(array_ft->elem_ft, ft_dependents);
- ft->in_ir = array_ft->elem_ft->in_ir;
+ update_field_class_in_ir(array_fc->elem_fc, ft_dependents);
+ fc->in_ir = array_fc->elem_fc->in_ir;
- if (ft->id == CTF_FIELD_TYPE_ID_ARRAY) {
- struct ctf_field_type_array *arr_ft = (void *) ft;
+ if (fc->id == CTF_FIELD_CLASS_ID_ARRAY) {
+ struct ctf_field_class_array *arr_fc = (void *) fc;
- assert(arr_ft->meaning == CTF_FIELD_TYPE_MEANING_NONE ||
- arr_ft->meaning == CTF_FIELD_TYPE_MEANING_UUID);
+ assert(arr_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE ||
+ arr_fc->meaning == CTF_FIELD_CLASS_MEANING_UUID);
/*
- * UUID field type: nothing depends on this, so
+ * UUID field class: nothing depends on this, so
* it's not part of IR.
*/
- if (arr_ft->meaning == CTF_FIELD_TYPE_MEANING_UUID) {
- ft->in_ir = false;
- array_ft->elem_ft->in_ir = false;
+ if (arr_fc->meaning == CTF_FIELD_CLASS_MEANING_UUID) {
+ fc->in_ir = false;
+ array_fc->elem_fc->in_ir = false;
}
- } else if (ft->id == CTF_FIELD_TYPE_ID_SEQUENCE) {
- if (ft->in_ir) {
- struct ctf_field_type_sequence *seq_ft = (void *) ft;
+ } else if (fc->id == CTF_FIELD_CLASS_ID_SEQUENCE) {
+ if (fc->in_ir) {
+ struct ctf_field_class_sequence *seq_fc = (void *) fc;
/*
- * This sequence field type is part of
- * IR and depends on a length field type
+ * This sequence field class is part of
+ * IR and depends on a length field class
* (which must also be part of IR).
*/
g_hash_table_insert(ft_dependents,
- seq_ft->length_ft, seq_ft->length_ft);
+ seq_fc->length_fc, seq_fc->length_fc);
}
}
break;
}
default:
- ft->in_ir = true;
+ fc->in_ir = true;
break;
}
}
/*
- * Scopes and field types are processed in reverse order because we need
- * to know if a given integer field type has dependents (sequence or
- * variant field types) when we reach it. Dependents can only be located
- * after the length/tag field type in the metadata tree.
+ * Scopes and field classes are processed in reverse order because we need
+ * to know if a given integer field class has dependents (sequence or
+ * variant field classes) when we reach it. Dependents can only be located
+ * after the length/tag field class in the metadata tree.
*/
BT_HIDDEN
int ctf_trace_class_update_in_ir(struct ctf_trace_class *ctf_tc)
continue;
}
- update_field_type_in_ir(ec->payload_ft, ft_dependents);
- update_field_type_in_ir(ec->spec_context_ft,
+ update_field_class_in_ir(ec->payload_fc, ft_dependents);
+ update_field_class_in_ir(ec->spec_context_fc,
ft_dependents);
}
if (!sc->is_translated) {
- update_field_type_in_ir(sc->event_common_context_ft,
+ update_field_class_in_ir(sc->event_common_context_fc,
ft_dependents);
- update_field_type_in_ir(sc->event_header_ft,
+ update_field_class_in_ir(sc->event_header_fc,
ft_dependents);
- update_field_type_in_ir(sc->packet_context_ft,
+ update_field_class_in_ir(sc->packet_context_fc,
ft_dependents);
}
}
if (!ctf_tc->is_translated) {
- update_field_type_in_ir(ctf_tc->packet_header_ft,
+ update_field_class_in_ir(ctf_tc->packet_header_fc,
ft_dependents);
}
#include "ctf-meta-visitors.h"
static
-int set_int_field_type_meaning_by_name(struct ctf_field_type *ft,
+int set_int_field_class_meaning_by_name(struct ctf_field_class *fc,
const char *field_name, const char *id_name,
- enum ctf_field_type_meaning meaning)
+ enum ctf_field_class_meaning meaning)
{
int ret = 0;
uint64_t i;
- if (!ft) {
+ if (!fc) {
goto end;
}
- switch (ft->id) {
- case CTF_FIELD_TYPE_ID_INT:
- case CTF_FIELD_TYPE_ID_ENUM:
+ switch (fc->id) {
+ case CTF_FIELD_CLASS_ID_INT:
+ case CTF_FIELD_CLASS_ID_ENUM:
{
- struct ctf_field_type_int *int_ft = (void *) ft;
+ struct ctf_field_class_int *int_fc = (void *) fc;
if (field_name && strcmp(field_name, id_name) == 0) {
- int_ft->meaning = meaning;
+ int_fc->meaning = meaning;
}
break;
}
- case CTF_FIELD_TYPE_ID_STRUCT:
+ case CTF_FIELD_CLASS_ID_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);
- ret = set_int_field_type_meaning_by_name(named_ft->ft,
- named_ft->name->str, id_name, meaning);
+ ret = set_int_field_class_meaning_by_name(named_fc->fc,
+ named_fc->name->str, id_name, meaning);
if (ret) {
goto end;
}
break;
}
- case CTF_FIELD_TYPE_ID_VARIANT:
+ case CTF_FIELD_CLASS_ID_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);
- ret = set_int_field_type_meaning_by_name(named_ft->ft,
+ ret = set_int_field_class_meaning_by_name(named_fc->fc,
NULL, id_name, meaning);
if (ret) {
goto end;
break;
}
- case CTF_FIELD_TYPE_ID_ARRAY:
- case CTF_FIELD_TYPE_ID_SEQUENCE:
+ case CTF_FIELD_CLASS_ID_ARRAY:
+ case CTF_FIELD_CLASS_ID_SEQUENCE:
{
- struct ctf_field_type_array_base *array_ft = (void *) ft;
+ struct ctf_field_class_array_base *array_fc = (void *) fc;
- ret = set_int_field_type_meaning_by_name(array_ft->elem_ft,
+ ret = set_int_field_class_meaning_by_name(array_fc->elem_fc,
NULL, id_name, meaning);
if (ret) {
goto end;
int update_stream_class_meanings(struct ctf_stream_class *sc)
{
int ret = 0;
- struct ctf_field_type_int *int_ft;
+ struct ctf_field_class_int *int_fc;
uint64_t i;
if (!sc->is_translated) {
- int_ft = ctf_field_type_struct_borrow_member_int_field_type_by_name(
- (void *) sc->packet_context_ft, "timestamp_begin");
- if (int_ft) {
- int_ft->meaning = CTF_FIELD_TYPE_MEANING_PACKET_BEGINNING_TIME;
+ int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
+ (void *) sc->packet_context_fc, "timestamp_begin");
+ if (int_fc) {
+ int_fc->meaning = CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME;
}
- int_ft = ctf_field_type_struct_borrow_member_int_field_type_by_name(
- (void *) sc->packet_context_ft, "timestamp_end");
- if (int_ft) {
- int_ft->meaning = CTF_FIELD_TYPE_MEANING_PACKET_END_TIME;
+ int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
+ (void *) sc->packet_context_fc, "timestamp_end");
+ if (int_fc) {
+ int_fc->meaning = CTF_FIELD_CLASS_MEANING_PACKET_END_TIME;
/*
* Remove mapped clock class to avoid updating
* the clock immediately when decoding.
*/
- int_ft->mapped_clock_class = NULL;
+ int_fc->mapped_clock_class = NULL;
}
- int_ft = ctf_field_type_struct_borrow_member_int_field_type_by_name(
- (void *) sc->packet_context_ft, "events_discarded");
- if (int_ft) {
- int_ft->meaning = CTF_FIELD_TYPE_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT;
+ int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
+ (void *) sc->packet_context_fc, "events_discarded");
+ if (int_fc) {
+ int_fc->meaning = CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT;
}
- int_ft = ctf_field_type_struct_borrow_member_int_field_type_by_name(
- (void *) sc->packet_context_ft, "packet_seq_num");
- if (int_ft) {
- int_ft->meaning = CTF_FIELD_TYPE_MEANING_PACKET_COUNTER_SNAPSHOT;
+ int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
+ (void *) sc->packet_context_fc, "packet_seq_num");
+ if (int_fc) {
+ int_fc->meaning = CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT;
}
- int_ft = ctf_field_type_struct_borrow_member_int_field_type_by_name(
- (void *) sc->packet_context_ft, "packet_size");
- if (int_ft) {
- int_ft->meaning = CTF_FIELD_TYPE_MEANING_EXP_PACKET_TOTAL_SIZE;
+ int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
+ (void *) sc->packet_context_fc, "packet_size");
+ if (int_fc) {
+ int_fc->meaning = CTF_FIELD_CLASS_MEANING_EXP_PACKET_TOTAL_SIZE;
}
- int_ft = ctf_field_type_struct_borrow_member_int_field_type_by_name(
- (void *) sc->packet_context_ft, "content_size");
- if (int_ft) {
- int_ft->meaning = CTF_FIELD_TYPE_MEANING_EXP_PACKET_CONTENT_SIZE;
+ int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
+ (void *) sc->packet_context_fc, "content_size");
+ if (int_fc) {
+ int_fc->meaning = CTF_FIELD_CLASS_MEANING_EXP_PACKET_CONTENT_SIZE;
}
- ret = set_int_field_type_meaning_by_name(
- sc->event_header_ft, NULL, "id",
- CTF_FIELD_TYPE_MEANING_EVENT_CLASS_ID);
+ ret = set_int_field_class_meaning_by_name(
+ sc->event_header_fc, NULL, "id",
+ CTF_FIELD_CLASS_MEANING_EVENT_CLASS_ID);
if (ret) {
goto end;
}
int ctf_trace_class_update_meanings(struct ctf_trace_class *ctf_tc)
{
int ret = 0;
- struct ctf_field_type_int *int_ft;
- struct ctf_named_field_type *named_ft;
+ struct ctf_field_class_int *int_fc;
+ struct ctf_named_field_class *named_fc;
uint64_t i;
if (!ctf_tc->is_translated) {
- int_ft = ctf_field_type_struct_borrow_member_int_field_type_by_name(
- (void *) ctf_tc->packet_header_ft, "magic");
- if (int_ft) {
- int_ft->meaning = CTF_FIELD_TYPE_MEANING_MAGIC;
+ int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
+ (void *) ctf_tc->packet_header_fc, "magic");
+ if (int_fc) {
+ int_fc->meaning = CTF_FIELD_CLASS_MEANING_MAGIC;
}
- int_ft = ctf_field_type_struct_borrow_member_int_field_type_by_name(
- (void *) ctf_tc->packet_header_ft, "stream_id");
- if (int_ft) {
- int_ft->meaning = CTF_FIELD_TYPE_MEANING_STREAM_CLASS_ID;
+ int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
+ (void *) ctf_tc->packet_header_fc, "stream_id");
+ if (int_fc) {
+ int_fc->meaning = CTF_FIELD_CLASS_MEANING_STREAM_CLASS_ID;
}
- int_ft = ctf_field_type_struct_borrow_member_int_field_type_by_name(
- (void *) ctf_tc->packet_header_ft,
+ int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
+ (void *) ctf_tc->packet_header_fc,
"stream_instance_id");
- if (int_ft) {
- int_ft->meaning = CTF_FIELD_TYPE_MEANING_DATA_STREAM_ID;
+ if (int_fc) {
+ int_fc->meaning = CTF_FIELD_CLASS_MEANING_DATA_STREAM_ID;
}
- named_ft = ctf_field_type_struct_borrow_member_by_name(
- (void *) ctf_tc->packet_header_ft, "uuid");
- if (named_ft && named_ft->ft->id == CTF_FIELD_TYPE_ID_ARRAY) {
- struct ctf_field_type_array *array_ft =
- (void *) named_ft->ft;
+ named_fc = ctf_field_class_struct_borrow_member_by_name(
+ (void *) ctf_tc->packet_header_fc, "uuid");
+ if (named_fc && named_fc->fc->id == CTF_FIELD_CLASS_ID_ARRAY) {
+ struct ctf_field_class_array *array_fc =
+ (void *) named_fc->fc;
- array_ft->meaning = CTF_FIELD_TYPE_MEANING_UUID;
+ array_fc->meaning = CTF_FIELD_CLASS_MEANING_UUID;
}
}
#include "ctf-meta-visitors.h"
static inline
-int set_text_array_sequence_field_type(struct ctf_field_type *ft)
+int set_text_array_sequence_field_class(struct ctf_field_class *fc)
{
int ret = 0;
uint64_t i;
- if (!ft) {
+ if (!fc) {
goto end;
}
- switch (ft->id) {
- case CTF_FIELD_TYPE_ID_STRUCT:
+ switch (fc->id) {
+ case CTF_FIELD_CLASS_ID_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);
- ret = set_text_array_sequence_field_type(named_ft->ft);
+ ret = set_text_array_sequence_field_class(named_fc->fc);
if (ret) {
goto end;
}
break;
}
- case CTF_FIELD_TYPE_ID_VARIANT:
+ case CTF_FIELD_CLASS_ID_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);
- ret = set_text_array_sequence_field_type(named_ft->ft);
+ ret = set_text_array_sequence_field_class(named_fc->fc);
if (ret) {
goto end;
}
break;
}
- case CTF_FIELD_TYPE_ID_ARRAY:
- case CTF_FIELD_TYPE_ID_SEQUENCE:
+ case CTF_FIELD_CLASS_ID_ARRAY:
+ case CTF_FIELD_CLASS_ID_SEQUENCE:
{
- struct ctf_field_type_array_base *array_ft = (void *) ft;
+ struct ctf_field_class_array_base *array_fc = (void *) fc;
- if (array_ft->elem_ft->id == CTF_FIELD_TYPE_ID_INT ||
- array_ft->elem_ft->id == CTF_FIELD_TYPE_ID_ENUM) {
- struct ctf_field_type_int *int_ft =
- (void *) array_ft->elem_ft;
+ if (array_fc->elem_fc->id == CTF_FIELD_CLASS_ID_INT ||
+ array_fc->elem_fc->id == CTF_FIELD_CLASS_ID_ENUM) {
+ struct ctf_field_class_int *int_fc =
+ (void *) array_fc->elem_fc;
- if (int_ft->base.base.alignment == 8 &&
- int_ft->base.size == 8 &&
- int_ft->encoding == CTF_ENCODING_UTF8) {
- array_ft->is_text = true;
+ if (int_fc->base.base.alignment == 8 &&
+ int_fc->base.size == 8 &&
+ int_fc->encoding == CTF_ENCODING_UTF8) {
+ array_fc->is_text = true;
/*
* Force integer element to be unsigned;
* array/sequence and we can safely
* decode bytes as characters anyway.
*/
- int_ft->is_signed = false;
+ int_fc->is_signed = false;
}
}
- ret = set_text_array_sequence_field_type(array_ft->elem_ft);
+ ret = set_text_array_sequence_field_class(array_fc->elem_fc);
if (ret) {
goto end;
}
uint64_t i;
if (!ctf_tc->is_translated) {
- ret = set_text_array_sequence_field_type(
- ctf_tc->packet_header_ft);
+ ret = set_text_array_sequence_field_class(
+ ctf_tc->packet_header_fc);
if (ret) {
goto end;
}
uint64_t j;
if (!sc->is_translated) {
- ret = set_text_array_sequence_field_type(
- sc->packet_context_ft);
+ ret = set_text_array_sequence_field_class(
+ sc->packet_context_fc);
if (ret) {
goto end;
}
- ret = set_text_array_sequence_field_type(
- sc->event_header_ft);
+ ret = set_text_array_sequence_field_class(
+ sc->event_header_fc);
if (ret) {
goto end;
}
- ret = set_text_array_sequence_field_type(
- sc->event_common_context_ft);
+ ret = set_text_array_sequence_field_class(
+ sc->event_common_context_fc);
if (ret) {
goto end;
}
continue;
}
- ret = set_text_array_sequence_field_type(
- ec->spec_context_ft);
+ ret = set_text_array_sequence_field_class(
+ ec->spec_context_fc);
if (ret) {
goto end;
}
- ret = set_text_array_sequence_field_type(
- ec->payload_ft);
+ ret = set_text_array_sequence_field_class(
+ ec->payload_fc);
if (ret) {
goto end;
}
#include "ctf-meta-visitors.h"
static
-int update_field_type_stored_value_index(struct ctf_field_type *ft,
+int update_field_class_stored_value_index(struct ctf_field_class *fc,
struct ctf_trace_class *tc,
struct ctf_stream_class *sc,
struct ctf_event_class *ec)
int ret = 0;
uint64_t i;
struct ctf_field_path *field_path = NULL;
- struct ctf_field_type_int *tgt_ft = NULL;
+ struct ctf_field_class_int *tgt_fc = NULL;
uint64_t *stored_value_index = NULL;
- if (!ft) {
+ if (!fc) {
goto end;
}
- switch (ft->id) {
- case CTF_FIELD_TYPE_ID_VARIANT:
+ switch (fc->id) {
+ case CTF_FIELD_CLASS_ID_VARIANT:
{
- struct ctf_field_type_variant *var_ft = (void *) ft;
+ struct ctf_field_class_variant *var_fc = (void *) fc;
- field_path = &var_ft->tag_path;
- stored_value_index = &var_ft->stored_tag_index;
- tgt_ft = (void *) var_ft->tag_ft;
+ field_path = &var_fc->tag_path;
+ stored_value_index = &var_fc->stored_tag_index;
+ tgt_fc = (void *) var_fc->tag_fc;
break;
}
- case CTF_FIELD_TYPE_ID_SEQUENCE:
+ case CTF_FIELD_CLASS_ID_SEQUENCE:
{
- struct ctf_field_type_sequence *seq_ft = (void *) ft;
+ struct ctf_field_class_sequence *seq_fc = (void *) fc;
- field_path = &seq_ft->length_path;
- stored_value_index = &seq_ft->stored_length_index;
- tgt_ft = seq_ft->length_ft;
+ field_path = &seq_fc->length_path;
+ stored_value_index = &seq_fc->stored_length_index;
+ tgt_fc = seq_fc->length_fc;
break;
}
default:
}
if (field_path) {
- BT_ASSERT(tgt_ft);
- BT_ASSERT(tgt_ft->base.base.id == CTF_FIELD_TYPE_ID_INT ||
- tgt_ft->base.base.id == CTF_FIELD_TYPE_ID_ENUM);
- if (tgt_ft->storing_index >= 0) {
+ BT_ASSERT(tgt_fc);
+ BT_ASSERT(tgt_fc->base.base.id == CTF_FIELD_CLASS_ID_INT ||
+ tgt_fc->base.base.id == CTF_FIELD_CLASS_ID_ENUM);
+ if (tgt_fc->storing_index >= 0) {
/* Already storing its value */
- *stored_value_index = (uint64_t) tgt_ft->storing_index;
+ *stored_value_index = (uint64_t) tgt_fc->storing_index;
} else {
/* Not storing its value: allocate new index */
- tgt_ft->storing_index = tc->stored_value_count;
- *stored_value_index = (uint64_t) tgt_ft->storing_index;
+ tgt_fc->storing_index = tc->stored_value_count;
+ *stored_value_index = (uint64_t) tgt_fc->storing_index;
tc->stored_value_count++;
}
}
- switch (ft->id) {
- case CTF_FIELD_TYPE_ID_STRUCT:
+ switch (fc->id) {
+ case CTF_FIELD_CLASS_ID_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);
- ret = update_field_type_stored_value_index(named_ft->ft,
+ ret = update_field_class_stored_value_index(named_fc->fc,
tc, sc, ec);
if (ret) {
goto end;
break;
}
- case CTF_FIELD_TYPE_ID_VARIANT:
+ case CTF_FIELD_CLASS_ID_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);
- ret = update_field_type_stored_value_index(named_ft->ft,
+ ret = update_field_class_stored_value_index(named_fc->fc,
tc, sc, ec);
if (ret) {
goto end;
break;
}
- case CTF_FIELD_TYPE_ID_ARRAY:
- case CTF_FIELD_TYPE_ID_SEQUENCE:
+ case CTF_FIELD_CLASS_ID_ARRAY:
+ case CTF_FIELD_CLASS_ID_SEQUENCE:
{
- struct ctf_field_type_array_base *array_ft = (void *) ft;
+ struct ctf_field_class_array_base *array_fc = (void *) fc;
- ret = update_field_type_stored_value_index(array_ft->elem_ft,
+ ret = update_field_class_stored_value_index(array_fc->elem_fc,
tc, sc, ec);
if (ret) {
goto end;
uint64_t i;
if (!ctf_tc->is_translated) {
- update_field_type_stored_value_index(
- ctf_tc->packet_header_ft, ctf_tc, NULL, NULL);
+ update_field_class_stored_value_index(
+ ctf_tc->packet_header_fc, ctf_tc, NULL, NULL);
}
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) {
- update_field_type_stored_value_index(sc->packet_context_ft,
+ update_field_class_stored_value_index(sc->packet_context_fc,
ctf_tc, sc, NULL);
- update_field_type_stored_value_index(sc->event_header_ft,
+ update_field_class_stored_value_index(sc->event_header_fc,
ctf_tc, sc, NULL);
- update_field_type_stored_value_index(
- sc->event_common_context_ft, ctf_tc, sc, NULL);
+ update_field_class_stored_value_index(
+ sc->event_common_context_fc, ctf_tc, sc, NULL);
}
for (j = 0; j < sc->event_classes->len; j++) {
sc->event_classes->pdata[j];
if (!ec->is_translated) {
- update_field_type_stored_value_index(
- ec->spec_context_ft, ctf_tc, sc, ec);
- update_field_type_stored_value_index(
- ec->payload_ft, ctf_tc, sc, ec);
+ update_field_class_stored_value_index(
+ ec->spec_context_fc, ctf_tc, sc, ec);
+ update_field_class_stored_value_index(
+ ec->payload_fc, ctf_tc, sc, ec);
}
}
}
int validate_stream_class(struct ctf_stream_class *sc)
{
int ret = 0;
- struct ctf_field_type_int *int_ft;
- struct ctf_field_type *ft;
+ struct ctf_field_class_int *int_fc;
+ struct ctf_field_class *fc;
bool has_total_size = false;
bool has_content_size = false;
goto end;
}
- ft = ctf_field_type_struct_borrow_member_field_type_by_name(
- (void *) sc->packet_context_ft, "timestamp_begin");
- if (ft) {
- if (ft->id != CTF_FIELD_TYPE_ID_INT &&
- ft->id != CTF_FIELD_TYPE_ID_ENUM) {
- BT_LOGE_STR("Invalid packet context field type: "
- "`timestamp_begin` member is not an integer field type.");
+ fc = ctf_field_class_struct_borrow_member_field_class_by_name(
+ (void *) sc->packet_context_fc, "timestamp_begin");
+ if (fc) {
+ if (fc->id != CTF_FIELD_CLASS_ID_INT &&
+ fc->id != CTF_FIELD_CLASS_ID_ENUM) {
+ BT_LOGE_STR("Invalid packet context field class: "
+ "`timestamp_begin` member is not an integer field class.");
goto invalid;
}
- int_ft = (void *) ft;
+ int_fc = (void *) fc;
- if (int_ft->is_signed) {
- BT_LOGE_STR("Invalid packet context field type: "
+ if (int_fc->is_signed) {
+ BT_LOGE_STR("Invalid packet context field class: "
"`timestamp_begin` member is signed.");
goto invalid;
}
}
- ft = ctf_field_type_struct_borrow_member_field_type_by_name(
- (void *) sc->packet_context_ft, "timestamp_end");
- if (ft) {
- if (ft->id != CTF_FIELD_TYPE_ID_INT &&
- ft->id != CTF_FIELD_TYPE_ID_ENUM) {
- BT_LOGE_STR("Invalid packet context field type: "
- "`timestamp_end` member is not an integer field type.");
+ fc = ctf_field_class_struct_borrow_member_field_class_by_name(
+ (void *) sc->packet_context_fc, "timestamp_end");
+ if (fc) {
+ if (fc->id != CTF_FIELD_CLASS_ID_INT &&
+ fc->id != CTF_FIELD_CLASS_ID_ENUM) {
+ BT_LOGE_STR("Invalid packet context field class: "
+ "`timestamp_end` member is not an integer field class.");
goto invalid;
}
- int_ft = (void *) ft;
+ int_fc = (void *) fc;
- if (int_ft->is_signed) {
- BT_LOGE_STR("Invalid packet context field type: "
+ if (int_fc->is_signed) {
+ BT_LOGE_STR("Invalid packet context field class: "
"`timestamp_end` member is signed.");
goto invalid;
}
}
- ft = ctf_field_type_struct_borrow_member_field_type_by_name(
- (void *) sc->packet_context_ft, "events_discarded");
- if (ft) {
- if (ft->id != CTF_FIELD_TYPE_ID_INT &&
- ft->id != CTF_FIELD_TYPE_ID_ENUM) {
- BT_LOGE_STR("Invalid packet context field type: "
- "`events_discarded` member is not an integer field type.");
+ fc = ctf_field_class_struct_borrow_member_field_class_by_name(
+ (void *) sc->packet_context_fc, "events_discarded");
+ if (fc) {
+ if (fc->id != CTF_FIELD_CLASS_ID_INT &&
+ fc->id != CTF_FIELD_CLASS_ID_ENUM) {
+ BT_LOGE_STR("Invalid packet context field class: "
+ "`events_discarded` member is not an integer field class.");
goto invalid;
}
- int_ft = (void *) ft;
+ int_fc = (void *) fc;
- if (int_ft->is_signed) {
- BT_LOGE_STR("Invalid packet context field type: "
+ if (int_fc->is_signed) {
+ BT_LOGE_STR("Invalid packet context field class: "
"`events_discarded` member is signed.");
goto invalid;
}
}
- ft = ctf_field_type_struct_borrow_member_field_type_by_name(
- (void *) sc->packet_context_ft, "packet_seq_num");
- if (ft) {
- if (ft->id != CTF_FIELD_TYPE_ID_INT &&
- ft->id != CTF_FIELD_TYPE_ID_ENUM) {
- BT_LOGE_STR("Invalid packet context field type: "
- "`packet_seq_num` member is not an integer field type.");
+ fc = ctf_field_class_struct_borrow_member_field_class_by_name(
+ (void *) sc->packet_context_fc, "packet_seq_num");
+ if (fc) {
+ if (fc->id != CTF_FIELD_CLASS_ID_INT &&
+ fc->id != CTF_FIELD_CLASS_ID_ENUM) {
+ BT_LOGE_STR("Invalid packet context field class: "
+ "`packet_seq_num` member is not an integer field class.");
goto invalid;
}
- int_ft = (void *) ft;
+ int_fc = (void *) fc;
- if (int_ft->is_signed) {
- BT_LOGE_STR("Invalid packet context field type: "
+ if (int_fc->is_signed) {
+ BT_LOGE_STR("Invalid packet context field class: "
"`packet_seq_num` member is signed.");
goto invalid;
}
}
- ft = ctf_field_type_struct_borrow_member_field_type_by_name(
- (void *) sc->packet_context_ft, "packet_size");
- if (ft) {
- if (ft->id != CTF_FIELD_TYPE_ID_INT &&
- ft->id != CTF_FIELD_TYPE_ID_ENUM) {
- BT_LOGE_STR("Invalid packet context field type: "
- "`packet_size` member is not an integer field type.");
+ fc = ctf_field_class_struct_borrow_member_field_class_by_name(
+ (void *) sc->packet_context_fc, "packet_size");
+ if (fc) {
+ if (fc->id != CTF_FIELD_CLASS_ID_INT &&
+ fc->id != CTF_FIELD_CLASS_ID_ENUM) {
+ BT_LOGE_STR("Invalid packet context field class: "
+ "`packet_size` member is not an integer field class.");
goto invalid;
}
- int_ft = (void *) ft;
+ int_fc = (void *) fc;
- if (int_ft->is_signed) {
- BT_LOGE_STR("Invalid packet context field type: "
+ if (int_fc->is_signed) {
+ BT_LOGE_STR("Invalid packet context field class: "
"`packet_size` member is signed.");
goto invalid;
}
has_total_size = true;
}
- ft = ctf_field_type_struct_borrow_member_field_type_by_name(
- (void *) sc->packet_context_ft, "content_size");
- if (ft) {
- if (ft->id != CTF_FIELD_TYPE_ID_INT &&
- ft->id != CTF_FIELD_TYPE_ID_ENUM) {
- BT_LOGE_STR("Invalid packet context field type: "
- "`content_size` member is not an integer field type.");
+ fc = ctf_field_class_struct_borrow_member_field_class_by_name(
+ (void *) sc->packet_context_fc, "content_size");
+ if (fc) {
+ if (fc->id != CTF_FIELD_CLASS_ID_INT &&
+ fc->id != CTF_FIELD_CLASS_ID_ENUM) {
+ BT_LOGE_STR("Invalid packet context field class: "
+ "`content_size` member is not an integer field class.");
goto invalid;
}
- int_ft = (void *) ft;
+ int_fc = (void *) fc;
- if (int_ft->is_signed) {
- BT_LOGE_STR("Invalid packet context field type: "
+ if (int_fc->is_signed) {
+ BT_LOGE_STR("Invalid packet context field class: "
"`content_size` member is signed.");
goto invalid;
}
}
if (has_content_size && !has_total_size) {
- BT_LOGE_STR("Invalid packet context field type: "
+ BT_LOGE_STR("Invalid packet context field class: "
"`content_size` member exists without "
"`packet_size` member.");
goto invalid;
}
- ft = ctf_field_type_struct_borrow_member_field_type_by_name(
- (void *) sc->event_header_ft, "id");
- if (ft) {
- if (ft->id != CTF_FIELD_TYPE_ID_INT &&
- ft->id != CTF_FIELD_TYPE_ID_ENUM) {
- BT_LOGE_STR("Invalid event header field type: "
- "`id` member is not an integer field type.");
+ fc = ctf_field_class_struct_borrow_member_field_class_by_name(
+ (void *) sc->event_header_fc, "id");
+ if (fc) {
+ if (fc->id != CTF_FIELD_CLASS_ID_INT &&
+ fc->id != CTF_FIELD_CLASS_ID_ENUM) {
+ BT_LOGE_STR("Invalid event header field class: "
+ "`id` member is not an integer field class.");
goto invalid;
}
- int_ft = (void *) ft;
+ int_fc = (void *) fc;
- if (int_ft->is_signed) {
- BT_LOGE_STR("Invalid event header field type: "
+ if (int_fc->is_signed) {
+ BT_LOGE_STR("Invalid event header field class: "
"`id` member is signed.");
goto invalid;
}
} else {
if (sc->event_classes->len > 1) {
- BT_LOGE_STR("Invalid event header field type: "
+ BT_LOGE_STR("Invalid event header field class: "
"missing `id` member as there's "
"more than one event class.");
goto invalid;
int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc)
{
int ret = 0;
- struct ctf_field_type_int *int_ft;
+ struct ctf_field_class_int *int_fc;
uint64_t i;
if (!ctf_tc->is_translated) {
- struct ctf_field_type *ft;
-
- ft = ctf_field_type_struct_borrow_member_field_type_by_name(
- (void *) ctf_tc->packet_header_ft, "magic");
- if (ft) {
- struct ctf_named_field_type *named_ft =
- ctf_field_type_struct_borrow_member_by_index(
- (void *) ctf_tc->packet_header_ft,
+ struct ctf_field_class *fc;
+
+ fc = ctf_field_class_struct_borrow_member_field_class_by_name(
+ (void *) ctf_tc->packet_header_fc, "magic");
+ if (fc) {
+ struct ctf_named_field_class *named_fc =
+ ctf_field_class_struct_borrow_member_by_index(
+ (void *) ctf_tc->packet_header_fc,
0);
- if (named_ft->ft != ft) {
- BT_LOGE_STR("Invalid packet header field type: "
+ if (named_fc->fc != fc) {
+ BT_LOGE_STR("Invalid packet header field class: "
"`magic` member is not the first member.");
goto invalid;
}
- if (ft->id != CTF_FIELD_TYPE_ID_INT &&
- ft->id != CTF_FIELD_TYPE_ID_ENUM) {
- BT_LOGE_STR("Invalid packet header field type: "
- "`magic` member is not an integer field type.");
+ if (fc->id != CTF_FIELD_CLASS_ID_INT &&
+ fc->id != CTF_FIELD_CLASS_ID_ENUM) {
+ BT_LOGE_STR("Invalid packet header field class: "
+ "`magic` member is not an integer field class.");
goto invalid;
}
- int_ft = (void *) ft;
+ int_fc = (void *) fc;
- if (int_ft->is_signed) {
- BT_LOGE_STR("Invalid packet header field type: "
+ if (int_fc->is_signed) {
+ BT_LOGE_STR("Invalid packet header field class: "
"`magic` member is signed.");
goto invalid;
}
- if (int_ft->base.size != 32) {
- BT_LOGE_STR("Invalid packet header field type: "
+ if (int_fc->base.size != 32) {
+ BT_LOGE_STR("Invalid packet header field class: "
"`magic` member is not 32-bit.");
goto invalid;
}
}
- ft = ctf_field_type_struct_borrow_member_field_type_by_name(
- (void *) ctf_tc->packet_header_ft, "stream_id");
- if (ft) {
- if (ft->id != CTF_FIELD_TYPE_ID_INT &&
- ft->id != CTF_FIELD_TYPE_ID_ENUM) {
- BT_LOGE_STR("Invalid packet header field type: "
- "`stream_id` member is not an integer field type.");
+ fc = ctf_field_class_struct_borrow_member_field_class_by_name(
+ (void *) ctf_tc->packet_header_fc, "stream_id");
+ if (fc) {
+ if (fc->id != CTF_FIELD_CLASS_ID_INT &&
+ fc->id != CTF_FIELD_CLASS_ID_ENUM) {
+ BT_LOGE_STR("Invalid packet header field class: "
+ "`stream_id` member is not an integer field class.");
goto invalid;
}
- int_ft = (void *) ft;
+ int_fc = (void *) fc;
- if (int_ft->is_signed) {
- BT_LOGE_STR("Invalid packet header field type: "
+ if (int_fc->is_signed) {
+ BT_LOGE_STR("Invalid packet header field class: "
"`stream_id` member is signed.");
goto invalid;
}
} else {
if (ctf_tc->stream_classes->len > 1) {
- BT_LOGE_STR("Invalid packet header field type: "
+ BT_LOGE_STR("Invalid packet header field class: "
"missing `stream_id` member as there's "
"more than one stream class.");
goto invalid;
}
}
- ft = ctf_field_type_struct_borrow_member_field_type_by_name(
- (void *) ctf_tc->packet_header_ft,
+ fc = ctf_field_class_struct_borrow_member_field_class_by_name(
+ (void *) ctf_tc->packet_header_fc,
"stream_instance_id");
- if (ft) {
- if (ft->id != CTF_FIELD_TYPE_ID_INT &&
- ft->id != CTF_FIELD_TYPE_ID_ENUM) {
- BT_LOGE_STR("Invalid packet header field type: "
- "`stream_instance_id` member is not an integer field type.");
+ if (fc) {
+ if (fc->id != CTF_FIELD_CLASS_ID_INT &&
+ fc->id != CTF_FIELD_CLASS_ID_ENUM) {
+ BT_LOGE_STR("Invalid packet header field class: "
+ "`stream_instance_id` member is not an integer field class.");
goto invalid;
}
- int_ft = (void *) ft;
+ int_fc = (void *) fc;
- if (int_ft->is_signed) {
- BT_LOGE_STR("Invalid packet header field type: "
+ if (int_fc->is_signed) {
+ BT_LOGE_STR("Invalid packet header field class: "
"`stream_instance_id` member is signed.");
goto invalid;
}
}
- ft = ctf_field_type_struct_borrow_member_field_type_by_name(
- (void *) ctf_tc->packet_header_ft, "uuid");
- if (ft) {
- struct ctf_field_type_array *array_ft = (void *) ft;
+ fc = ctf_field_class_struct_borrow_member_field_class_by_name(
+ (void *) ctf_tc->packet_header_fc, "uuid");
+ if (fc) {
+ struct ctf_field_class_array *array_fc = (void *) fc;
- if (ft->id != CTF_FIELD_TYPE_ID_ARRAY) {
- BT_LOGE_STR("Invalid packet header field type: "
- "`uuid` member is not an array field type.");
+ if (fc->id != CTF_FIELD_CLASS_ID_ARRAY) {
+ BT_LOGE_STR("Invalid packet header field class: "
+ "`uuid` member is not an array field class.");
goto invalid;
}
- array_ft = (void *) ft;
+ array_fc = (void *) fc;
- if (array_ft->length != 16) {
- BT_LOGE_STR("Invalid packet header field type: "
- "`uuid` member is not a 16-element array field type.");
+ if (array_fc->length != 16) {
+ BT_LOGE_STR("Invalid packet header field class: "
+ "`uuid` member is not a 16-element array field class.");
goto invalid;
}
- if (array_ft->base.elem_ft->id != CTF_FIELD_TYPE_ID_INT) {
- BT_LOGE_STR("Invalid packet header field type: "
- "`uuid` member's element field type is not "
- "an integer field type.");
+ if (array_fc->base.elem_fc->id != CTF_FIELD_CLASS_ID_INT) {
+ BT_LOGE_STR("Invalid packet header field class: "
+ "`uuid` member's element field class is not "
+ "an integer field class.");
goto invalid;
}
- int_ft = (void *) array_ft->base.elem_ft;
+ int_fc = (void *) array_fc->base.elem_fc;
- if (int_ft->is_signed) {
- BT_LOGE_STR("Invalid packet header field type: "
- "`uuid` member's element field type "
- "is a signed integer field type.");
+ if (int_fc->is_signed) {
+ BT_LOGE_STR("Invalid packet header field class: "
+ "`uuid` member's element field class "
+ "is a signed integer field class.");
goto invalid;
}
- if (int_ft->base.size != 8) {
- BT_LOGE_STR("Invalid packet header field type: "
- "`uuid` member's element field type "
- "is not an 8-bit integer field type.");
+ if (int_fc->base.size != 8) {
+ BT_LOGE_STR("Invalid packet header field class: "
+ "`uuid` member's element field class "
+ "is not an 8-bit integer field class.");
goto invalid;
}
- if (int_ft->base.base.alignment != 8) {
- BT_LOGE_STR("Invalid packet header field type: "
- "`uuid` member's element field type's "
+ if (int_fc->base.base.alignment != 8) {
+ BT_LOGE_STR("Invalid packet header field class: "
+ "`uuid` member's element field class's "
"alignment is not 8.");
goto invalid;
}
#include "ctf-meta.h"
BT_HIDDEN
-int ctf_trace_class_resolve_field_types(struct ctf_trace_class *tc);
+int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc);
BT_HIDDEN
int ctf_trace_class_translate(struct bt_trace *ir_trace,
#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_id {
+ CTF_FIELD_CLASS_ID_INT,
+ CTF_FIELD_CLASS_ID_ENUM,
+ CTF_FIELD_CLASS_ID_FLOAT,
+ CTF_FIELD_CLASS_ID_STRING,
+ CTF_FIELD_CLASS_ID_STRUCT,
+ CTF_FIELD_CLASS_ID_ARRAY,
+ CTF_FIELD_CLASS_ID_SEQUENCE,
+ CTF_FIELD_CLASS_ID_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;
+struct ctf_field_class {
+ enum ctf_field_class_id id;
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;
+ struct 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;
+ enum bt_field_class_integer_preferred_display_base disp_base;
enum ctf_encoding encoding;
int64_t storing_index;
} 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;
};
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 {
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;
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;
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;
};
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,
+void _ctf_field_class_init(struct ctf_field_class *fc, enum ctf_field_class_id id,
unsigned int alignment)
{
- BT_ASSERT(ft);
- ft->id = id;
- ft->alignment = alignment;
- ft->in_ir = false;
+ BT_ASSERT(fc);
+ fc->id = id;
+ 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_id id)
{
- _ctf_field_type_init((void *) ft, id, 1);
+ _ctf_field_class_init((void *) fc, id, 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_id id)
{
- _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, id);
+ 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_ID_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_ID_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_ID_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_ID_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_ID_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_ID_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_ID_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_ID_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);
+ bt_put(fc->mapped_clock_class);
+ 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);
+ bt_put(fc->base.mapped_clock_class);
- 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->id) {
+ case CTF_FIELD_CLASS_ID_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_ID_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_ID_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_ID_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_ID_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_ID_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_ID_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_ID_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.id != CTF_FIELD_CLASS_ID_INT &&
+ int_fc->base.base.id != CTF_FIELD_CLASS_ID_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->id) {
+ case CTF_FIELD_CLASS_ID_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_ID_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_ID_ARRAY:
+ case CTF_FIELD_CLASS_ID_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->id) {
+ case CTF_FIELD_CLASS_ID_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_ID_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_ID_ARRAY:
+ case CTF_FIELD_CLASS_ID_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->id) {
+ case CTF_FIELD_CLASS_ID_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_ID_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;
}
}
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;
+ fc = tc->packet_header_fc;
break;
case BT_SCOPE_PACKET_CONTEXT:
- ft = sc->packet_context_ft;
+ fc = sc->packet_context_fc;
break;
case BT_SCOPE_EVENT_HEADER:
- ft = sc->event_header_ft;
+ fc = sc->event_header_fc;
break;
case BT_SCOPE_EVENT_COMMON_CONTEXT:
- ft = sc->event_common_context_ft;
+ fc = sc->event_common_context_fc;
break;
case BT_SCOPE_EVENT_SPECIFIC_CONTEXT:
- ft = ec->spec_context_ft;
+ fc = ec->spec_context_fc;
break;
case BT_SCOPE_EVENT_PAYLOAD:
- ft = ec->payload_ft;
+ 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 = bt_get(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->id) {
+ case CTF_FIELD_CLASS_ID_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_ID_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_ID_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_ID_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_ID_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_ID_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_ID_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_ID_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->id = fc->id;
+ 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);
+ 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);
bt_put(sc->default_clock_class);
g_free(sc);
}
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);
struct ctf_scanner_scope *parent)
{
scope->parent = parent;
- scope->types = g_hash_table_new_full(g_str_hash, g_str_equal,
+ scope->classes = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
}
static void finalize_scope(struct ctf_scanner_scope *scope)
{
- g_hash_table_destroy(scope->types);
+ g_hash_table_destroy(scope->classes);
}
static void push_scope(struct ctf_scanner *scanner)
{
int ret;
- ret = GPOINTER_TO_INT(g_hash_table_lookup(s->types, id));
+ ret = GPOINTER_TO_INT(g_hash_table_lookup(s->classes, id));
BT_LOGV("Looked up type: scanner-addr=%p, id=\"%s\", ret=%d",
s, id, ret);
return ret;
scanner, id);
if (lookup_type(scanner->cs, id))
return;
- g_hash_table_insert(scanner->cs->types, id, id);
+ g_hash_table_insert(scanner->cs->classes, id, id);
}
static struct ctf_node *make_node(struct ctf_scanner *scanner,
case NODE_UNARY_EXPRESSION:
break;
case NODE_TYPEDEF:
- BT_INIT_LIST_HEAD(&node->u._typedef.type_declarators);
+ BT_INIT_LIST_HEAD(&node->u.field_class_def.field_class_declarators);
break;
case NODE_TYPEALIAS_TARGET:
- BT_INIT_LIST_HEAD(&node->u.typealias_target.type_declarators);
+ BT_INIT_LIST_HEAD(&node->u.field_class_alias_target.field_class_declarators);
break;
case NODE_TYPEALIAS_ALIAS:
- BT_INIT_LIST_HEAD(&node->u.typealias_alias.type_declarators);
+ BT_INIT_LIST_HEAD(&node->u.field_class_alias_name.field_class_declarators);
break;
case NODE_TYPEALIAS:
break;
case NODE_TYPE_SPECIFIER:
break;
case NODE_TYPE_SPECIFIER_LIST:
- BT_INIT_LIST_HEAD(&node->u.type_specifier_list.head);
+ BT_INIT_LIST_HEAD(&node->u.field_class_specifier_list.head);
break;
case NODE_POINTER:
break;
case NODE_TYPE_DECLARATOR:
- BT_INIT_LIST_HEAD(&node->u.type_declarator.pointers);
+ BT_INIT_LIST_HEAD(&node->u.field_class_declarator.pointers);
break;
case NODE_FLOATING_POINT:
BT_INIT_LIST_HEAD(&node->u.floating_point.expressions);
BT_INIT_LIST_HEAD(&node->u._enum.enumerator_list);
break;
case NODE_STRUCT_OR_VARIANT_DECLARATION:
- BT_INIT_LIST_HEAD(&node->u.struct_or_variant_declaration.type_declarators);
+ BT_INIT_LIST_HEAD(&node->u.struct_or_variant_declaration.field_class_declarators);
break;
case NODE_VARIANT:
BT_INIT_LIST_HEAD(&node->u.variant.declaration_list);
return 0;
}
-static int reparent_typealias(struct ctf_node *node, struct ctf_node *parent)
+static int reparent_field_class_alias(struct ctf_node *node, struct ctf_node *parent)
{
switch (parent->type) {
case NODE_ROOT:
return 0;
}
-static int reparent_type_specifier(struct ctf_node *node,
+static int reparent_field_class_specifier(struct ctf_node *node,
struct ctf_node *parent)
{
switch (parent->type) {
case NODE_TYPE_SPECIFIER_LIST:
- _bt_list_splice_tail(&node->tmp_head, &parent->u.type_specifier_list.head);
+ _bt_list_splice_tail(&node->tmp_head, &parent->u.field_class_specifier_list.head);
break;
case NODE_TYPE_SPECIFIER:
return 0;
}
-static int reparent_type_specifier_list(struct ctf_node *node,
+static int reparent_field_class_specifier_list(struct ctf_node *node,
struct ctf_node *parent)
{
switch (parent->type) {
bt_list_add_tail(&node->siblings, &parent->u._struct.declaration_list);
break;
case NODE_TYPEDEF:
- parent->u._typedef.type_specifier_list = node;
+ parent->u.field_class_def.field_class_specifier_list = node;
break;
case NODE_TYPEALIAS_TARGET:
- parent->u.typealias_target.type_specifier_list = node;
+ parent->u.field_class_alias_target.field_class_specifier_list = node;
break;
case NODE_TYPEALIAS_ALIAS:
- parent->u.typealias_alias.type_specifier_list = node;
+ parent->u.field_class_alias_name.field_class_specifier_list = node;
break;
case NODE_ENUM:
- parent->u._enum.container_type = node;
+ parent->u._enum.container_field_class = node;
break;
case NODE_STRUCT_OR_VARIANT_DECLARATION:
- parent->u.struct_or_variant_declaration.type_specifier_list = node;
+ parent->u.struct_or_variant_declaration.field_class_specifier_list = node;
break;
case NODE_TYPE_DECLARATOR:
case NODE_TYPE_SPECIFIER:
return 0;
}
-static int reparent_type_declarator(struct ctf_node *node,
+static int reparent_field_class_declarator(struct ctf_node *node,
struct ctf_node *parent)
{
switch (parent->type) {
case NODE_TYPE_DECLARATOR:
- parent->u.type_declarator.type = TYPEDEC_NESTED;
- parent->u.type_declarator.u.nested.type_declarator = node;
+ parent->u.field_class_declarator.type = TYPEDEC_NESTED;
+ parent->u.field_class_declarator.u.nested.field_class_declarator = node;
break;
case NODE_STRUCT_OR_VARIANT_DECLARATION:
- _bt_list_splice_tail(&node->tmp_head, &parent->u.struct_or_variant_declaration.type_declarators);
+ _bt_list_splice_tail(&node->tmp_head, &parent->u.struct_or_variant_declaration.field_class_declarators);
break;
case NODE_TYPEDEF:
- _bt_list_splice_tail(&node->tmp_head, &parent->u._typedef.type_declarators);
+ _bt_list_splice_tail(&node->tmp_head, &parent->u.field_class_def.field_class_declarators);
break;
case NODE_TYPEALIAS_TARGET:
- _bt_list_splice_tail(&node->tmp_head, &parent->u.typealias_target.type_declarators);
+ _bt_list_splice_tail(&node->tmp_head, &parent->u.field_class_alias_target.field_class_declarators);
break;
case NODE_TYPEALIAS_ALIAS:
- _bt_list_splice_tail(&node->tmp_head, &parent->u.typealias_alias.type_declarators);
+ _bt_list_splice_tail(&node->tmp_head, &parent->u.field_class_alias_name.field_class_declarators);
break;
case NODE_ROOT:
return reparent_ctf_expression(node, parent);
case NODE_UNARY_EXPRESSION:
if (parent->type == NODE_TYPE_DECLARATOR)
- parent->u.type_declarator.bitfield_len = node;
+ parent->u.field_class_declarator.bitfield_len = node;
else
return -EPERM;
break;
return reparent_typedef(node, parent);
case NODE_TYPEALIAS_TARGET:
if (parent->type == NODE_TYPEALIAS)
- parent->u.typealias.target = node;
+ parent->u.field_class_alias.target = node;
else
return -EINVAL;
case NODE_TYPEALIAS_ALIAS:
if (parent->type == NODE_TYPEALIAS)
- parent->u.typealias.alias = node;
+ parent->u.field_class_alias.alias = node;
else
return -EINVAL;
case NODE_TYPEALIAS:
- return reparent_typealias(node, parent);
+ return reparent_field_class_alias(node, parent);
case NODE_POINTER:
if (parent->type == NODE_TYPE_DECLARATOR) {
- _bt_list_splice_tail(&node->tmp_head, &parent->u.type_declarator.pointers);
+ _bt_list_splice_tail(&node->tmp_head, &parent->u.field_class_declarator.pointers);
} else
return -EPERM;
break;
case NODE_TYPE_DECLARATOR:
- return reparent_type_declarator(node, parent);
+ return reparent_field_class_declarator(node, parent);
case NODE_TYPE_SPECIFIER_LIST:
- return reparent_type_specifier_list(node, parent);
+ return reparent_field_class_specifier_list(node, parent);
case NODE_TYPE_SPECIFIER:
- return reparent_type_specifier(node, parent);
+ return reparent_field_class_specifier(node, parent);
case NODE_FLOATING_POINT:
case NODE_INTEGER:
%type <n> declaration_specifiers
%type <n> alias_declaration_specifiers
-%type <n> type_declarator_list
-%type <n> integer_type_specifier
-%type <n> type_specifier
-%type <n> struct_type_specifier
-%type <n> variant_type_specifier
-%type <n> enum_type_specifier
+%type <n> field_class_declarator_list
+%type <n> integer_field_class_specifier
+%type <n> field_class_specifier
+%type <n> struct_class_specifier
+%type <n> variant_field_class_specifier
+%type <n> enum_field_class_specifier
%type <n> struct_or_variant_declaration_list
%type <n> struct_or_variant_declaration
%type <n> struct_or_variant_declarator_list
%type <n> direct_alias_abstract_declarator
%type <n> declarator
%type <n> direct_declarator
-%type <n> type_declarator
-%type <n> direct_type_declarator
+%type <n> field_class_declarator
+%type <n> direct_field_class_declarator
%type <n> pointer
%type <n> ctf_assignment_expression_list
%type <n> ctf_assignment_expression
{ $$ = $1; }
| callsite_declaration
{ $$ = $1; }
- | declaration_specifiers CTF_TYPEDEF declaration_specifiers type_declarator_list CTF_SEMICOLON
+ | declaration_specifiers CTF_TYPEDEF declaration_specifiers field_class_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
$$ = make_node(scanner, NODE_TYPEDEF);
list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
- $$->u._typedef.type_specifier_list = list;
- _bt_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
- _bt_list_splice_tail(&($3)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
- _bt_list_splice_tail(&($4)->tmp_head, &($$)->u._typedef.type_declarators);
+ $$->u.field_class_def.field_class_specifier_list = list;
+ _bt_list_splice_tail(&($1)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
+ _bt_list_splice_tail(&($3)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
+ _bt_list_splice_tail(&($4)->tmp_head, &($$)->u.field_class_def.field_class_declarators);
}
- | CTF_TYPEDEF declaration_specifiers type_declarator_list CTF_SEMICOLON
+ | CTF_TYPEDEF declaration_specifiers field_class_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
$$ = make_node(scanner, NODE_TYPEDEF);
list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
- $$->u._typedef.type_specifier_list = list;
- _bt_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
- _bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
+ $$->u.field_class_def.field_class_specifier_list = list;
+ _bt_list_splice_tail(&($2)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
+ _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.field_class_def.field_class_declarators);
}
- | declaration_specifiers CTF_TYPEDEF type_declarator_list CTF_SEMICOLON
+ | declaration_specifiers CTF_TYPEDEF field_class_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
$$ = make_node(scanner, NODE_TYPEDEF);
list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
- $$->u._typedef.type_specifier_list = list;
- _bt_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
- _bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
+ $$->u.field_class_def.field_class_specifier_list = list;
+ _bt_list_splice_tail(&($1)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
+ _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.field_class_def.field_class_declarators);
}
| CTF_TYPEALIAS declaration_specifiers abstract_declarator_list CTF_TYPEASSIGN alias_declaration_specifiers alias_abstract_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
$$ = make_node(scanner, NODE_TYPEALIAS);
- $$->u.typealias.target = make_node(scanner, NODE_TYPEALIAS_TARGET);
- $$->u.typealias.alias = make_node(scanner, NODE_TYPEALIAS_ALIAS);
+ $$->u.field_class_alias.target = make_node(scanner, NODE_TYPEALIAS_TARGET);
+ $$->u.field_class_alias.alias = make_node(scanner, NODE_TYPEALIAS_ALIAS);
list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
- $$->u.typealias.target->u.typealias_target.type_specifier_list = list;
- _bt_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
- _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.typealias.target->u.typealias_target.type_declarators);
+ $$->u.field_class_alias.target->u.field_class_alias_target.field_class_specifier_list = list;
+ _bt_list_splice_tail(&($2)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
+ _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.field_class_alias.target->u.field_class_alias_target.field_class_declarators);
list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
- $$->u.typealias.alias->u.typealias_alias.type_specifier_list = list;
- _bt_list_splice_tail(&($5)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
- _bt_list_splice_tail(&($6)->tmp_head, &($$)->u.typealias.alias->u.typealias_alias.type_declarators);
+ $$->u.field_class_alias.alias->u.field_class_alias_name.field_class_specifier_list = list;
+ _bt_list_splice_tail(&($5)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
+ _bt_list_splice_tail(&($6)->tmp_head, &($$)->u.field_class_alias.alias->u.field_class_alias_name.field_class_declarators);
}
;
$$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
node = make_node(scanner, NODE_TYPE_SPECIFIER);
- node->u.type_specifier.type = TYPESPEC_CONST;
- bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
+ node->u.field_class_specifier.type = TYPESPEC_CONST;
+ bt_list_add_tail(&node->siblings, &($$)->u.field_class_specifier_list.head);
}
- | integer_type_specifier
+ | integer_field_class_specifier
{
struct ctf_node *node;
$$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
node = $1;
- bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
+ bt_list_add_tail(&node->siblings, &($$)->u.field_class_specifier_list.head);
}
| integer_declaration_specifiers CTF_CONST
{
$$ = $1;
node = make_node(scanner, NODE_TYPE_SPECIFIER);
- node->u.type_specifier.type = TYPESPEC_CONST;
- bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
+ node->u.field_class_specifier.type = TYPESPEC_CONST;
+ bt_list_add_tail(&node->siblings, &($$)->u.field_class_specifier_list.head);
}
- | integer_declaration_specifiers integer_type_specifier
+ | integer_declaration_specifiers integer_field_class_specifier
{
$$ = $1;
- bt_list_add_tail(&($2)->siblings, &($$)->u.type_specifier_list.head);
+ bt_list_add_tail(&($2)->siblings, &($$)->u.field_class_specifier_list.head);
}
;
$$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
node = make_node(scanner, NODE_TYPE_SPECIFIER);
- node->u.type_specifier.type = TYPESPEC_CONST;
- bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
+ node->u.field_class_specifier.type = TYPESPEC_CONST;
+ bt_list_add_tail(&node->siblings, &($$)->u.field_class_specifier_list.head);
}
- | type_specifier
+ | field_class_specifier
{
struct ctf_node *node;
$$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
node = $1;
- bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
+ bt_list_add_tail(&node->siblings, &($$)->u.field_class_specifier_list.head);
}
| declaration_specifiers CTF_CONST
{
$$ = $1;
node = make_node(scanner, NODE_TYPE_SPECIFIER);
- node->u.type_specifier.type = TYPESPEC_CONST;
- bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
+ node->u.field_class_specifier.type = TYPESPEC_CONST;
+ bt_list_add_tail(&node->siblings, &($$)->u.field_class_specifier_list.head);
}
- | declaration_specifiers type_specifier
+ | declaration_specifiers field_class_specifier
{
$$ = $1;
- bt_list_add_tail(&($2)->siblings, &($$)->u.type_specifier_list.head);
+ bt_list_add_tail(&($2)->siblings, &($$)->u.field_class_specifier_list.head);
}
;
-type_declarator_list:
- type_declarator
+field_class_declarator_list:
+ field_class_declarator
{ $$ = $1; }
- | type_declarator_list CTF_COMMA type_declarator
+ | field_class_declarator_list CTF_COMMA field_class_declarator
{
$$ = $1;
bt_list_add_tail(&($3)->siblings, &($$)->tmp_head);
}
;
-integer_type_specifier:
+integer_field_class_specifier:
CTF_CHAR
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_CHAR;
+ $$->u.field_class_specifier.type = TYPESPEC_CHAR;
}
| CTF_SHORT
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_SHORT;
+ $$->u.field_class_specifier.type = TYPESPEC_SHORT;
}
| CTF_INT
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_INT;
+ $$->u.field_class_specifier.type = TYPESPEC_INT;
}
| CTF_LONG
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_LONG;
+ $$->u.field_class_specifier.type = TYPESPEC_LONG;
}
| CTF_SIGNED
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_SIGNED;
+ $$->u.field_class_specifier.type = TYPESPEC_SIGNED;
}
| CTF_UNSIGNED
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_UNSIGNED;
+ $$->u.field_class_specifier.type = TYPESPEC_UNSIGNED;
}
| CTF_BOOL
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_BOOL;
+ $$->u.field_class_specifier.type = TYPESPEC_BOOL;
}
| ID_TYPE
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_ID_TYPE;
- $$->u.type_specifier.id_type = yylval.s;
+ $$->u.field_class_specifier.type = TYPESPEC_ID_TYPE;
+ $$->u.field_class_specifier.id_type = yylval.s;
}
| CTF_INTEGER CTF_LBRAC CTF_RBRAC
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_INTEGER;
- $$->u.type_specifier.node = make_node(scanner, NODE_INTEGER);
+ $$->u.field_class_specifier.type = TYPESPEC_INTEGER;
+ $$->u.field_class_specifier.node = make_node(scanner, NODE_INTEGER);
}
| CTF_INTEGER CTF_LBRAC ctf_assignment_expression_list CTF_RBRAC
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_INTEGER;
- $$->u.type_specifier.node = make_node(scanner, NODE_INTEGER);
- if (set_parent_node($3, $$->u.type_specifier.node))
+ $$->u.field_class_specifier.type = TYPESPEC_INTEGER;
+ $$->u.field_class_specifier.node = make_node(scanner, NODE_INTEGER);
+ if (set_parent_node($3, $$->u.field_class_specifier.node))
reparent_error(scanner, "integer reparent error");
}
;
-type_specifier:
+field_class_specifier:
CTF_VOID
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_VOID;
+ $$->u.field_class_specifier.type = TYPESPEC_VOID;
}
| CTF_CHAR
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_CHAR;
+ $$->u.field_class_specifier.type = TYPESPEC_CHAR;
}
| CTF_SHORT
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_SHORT;
+ $$->u.field_class_specifier.type = TYPESPEC_SHORT;
}
| CTF_INT
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_INT;
+ $$->u.field_class_specifier.type = TYPESPEC_INT;
}
| CTF_LONG
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_LONG;
+ $$->u.field_class_specifier.type = TYPESPEC_LONG;
}
| CTF_FLOAT
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_FLOAT;
+ $$->u.field_class_specifier.type = TYPESPEC_FLOAT;
}
| CTF_DOUBLE
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_DOUBLE;
+ $$->u.field_class_specifier.type = TYPESPEC_DOUBLE;
}
| CTF_SIGNED
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_SIGNED;
+ $$->u.field_class_specifier.type = TYPESPEC_SIGNED;
}
| CTF_UNSIGNED
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_UNSIGNED;
+ $$->u.field_class_specifier.type = TYPESPEC_UNSIGNED;
}
| CTF_BOOL
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_BOOL;
+ $$->u.field_class_specifier.type = TYPESPEC_BOOL;
}
| CTF_COMPLEX
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_COMPLEX;
+ $$->u.field_class_specifier.type = TYPESPEC_COMPLEX;
}
| CTF_IMAGINARY
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_IMAGINARY;
+ $$->u.field_class_specifier.type = TYPESPEC_IMAGINARY;
}
| ID_TYPE
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_ID_TYPE;
- $$->u.type_specifier.id_type = yylval.s;
+ $$->u.field_class_specifier.type = TYPESPEC_ID_TYPE;
+ $$->u.field_class_specifier.id_type = yylval.s;
}
| CTF_FLOATING_POINT CTF_LBRAC CTF_RBRAC
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_FLOATING_POINT;
- $$->u.type_specifier.node = make_node(scanner, NODE_FLOATING_POINT);
+ $$->u.field_class_specifier.type = TYPESPEC_FLOATING_POINT;
+ $$->u.field_class_specifier.node = make_node(scanner, NODE_FLOATING_POINT);
}
| CTF_FLOATING_POINT CTF_LBRAC ctf_assignment_expression_list CTF_RBRAC
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_FLOATING_POINT;
- $$->u.type_specifier.node = make_node(scanner, NODE_FLOATING_POINT);
- if (set_parent_node($3, $$->u.type_specifier.node))
+ $$->u.field_class_specifier.type = TYPESPEC_FLOATING_POINT;
+ $$->u.field_class_specifier.node = make_node(scanner, NODE_FLOATING_POINT);
+ if (set_parent_node($3, $$->u.field_class_specifier.node))
reparent_error(scanner, "floating point reparent error");
}
| CTF_INTEGER CTF_LBRAC CTF_RBRAC
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_INTEGER;
- $$->u.type_specifier.node = make_node(scanner, NODE_INTEGER);
+ $$->u.field_class_specifier.type = TYPESPEC_INTEGER;
+ $$->u.field_class_specifier.node = make_node(scanner, NODE_INTEGER);
}
| CTF_INTEGER CTF_LBRAC ctf_assignment_expression_list CTF_RBRAC
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_INTEGER;
- $$->u.type_specifier.node = make_node(scanner, NODE_INTEGER);
- if (set_parent_node($3, $$->u.type_specifier.node))
+ $$->u.field_class_specifier.type = TYPESPEC_INTEGER;
+ $$->u.field_class_specifier.node = make_node(scanner, NODE_INTEGER);
+ if (set_parent_node($3, $$->u.field_class_specifier.node))
reparent_error(scanner, "integer reparent error");
}
| CTF_STRING
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_STRING;
- $$->u.type_specifier.node = make_node(scanner, NODE_STRING);
+ $$->u.field_class_specifier.type = TYPESPEC_STRING;
+ $$->u.field_class_specifier.node = make_node(scanner, NODE_STRING);
}
| CTF_STRING CTF_LBRAC CTF_RBRAC
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_STRING;
- $$->u.type_specifier.node = make_node(scanner, NODE_STRING);
+ $$->u.field_class_specifier.type = TYPESPEC_STRING;
+ $$->u.field_class_specifier.node = make_node(scanner, NODE_STRING);
}
| CTF_STRING CTF_LBRAC ctf_assignment_expression_list CTF_RBRAC
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_STRING;
- $$->u.type_specifier.node = make_node(scanner, NODE_STRING);
- if (set_parent_node($3, $$->u.type_specifier.node))
+ $$->u.field_class_specifier.type = TYPESPEC_STRING;
+ $$->u.field_class_specifier.node = make_node(scanner, NODE_STRING);
+ if (set_parent_node($3, $$->u.field_class_specifier.node))
reparent_error(scanner, "string reparent error");
}
- | CTF_ENUM enum_type_specifier
+ | CTF_ENUM enum_field_class_specifier
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_ENUM;
- $$->u.type_specifier.node = $2;
+ $$->u.field_class_specifier.type = TYPESPEC_ENUM;
+ $$->u.field_class_specifier.node = $2;
}
- | CTF_VARIANT variant_type_specifier
+ | CTF_VARIANT variant_field_class_specifier
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_VARIANT;
- $$->u.type_specifier.node = $2;
+ $$->u.field_class_specifier.type = TYPESPEC_VARIANT;
+ $$->u.field_class_specifier.node = $2;
}
- | CTF_STRUCT struct_type_specifier
+ | CTF_STRUCT struct_class_specifier
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_STRUCT;
- $$->u.type_specifier.node = $2;
+ $$->u.field_class_specifier.type = TYPESPEC_STRUCT;
+ $$->u.field_class_specifier.node = $2;
}
;
-struct_type_specifier:
+struct_class_specifier:
struct_declaration_begin struct_or_variant_declaration_list struct_declaration_end
{
$$ = make_node(scanner, NODE_STRUCT);
{ pop_scope(scanner); }
;
-variant_type_specifier:
+variant_field_class_specifier:
variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
{
$$ = make_node(scanner, NODE_VARIANT);
{ pop_scope(scanner); }
;
-enum_type_specifier:
+enum_field_class_specifier:
CTF_LBRAC enumerator_list CTF_RBRAC
{
$$ = make_node(scanner, NODE_ENUM);
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
- ($$)->u._enum.container_type = $2;
+ ($$)->u._enum.container_field_class = $2;
_bt_list_splice_tail(&($4)->tmp_head, &($$)->u._enum.enumerator_list);
}
| IDENTIFIER CTF_LBRAC enumerator_list CTF_RBRAC
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
$$->u._enum.enum_id = $1;
- ($$)->u._enum.container_type = $3;
+ ($$)->u._enum.container_field_class = $3;
_bt_list_splice_tail(&($5)->tmp_head, &($$)->u._enum.enumerator_list);
}
| ID_TYPE CTF_LBRAC enumerator_list CTF_RBRAC
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
$$->u._enum.enum_id = $1;
- ($$)->u._enum.container_type = $3;
+ ($$)->u._enum.container_field_class = $3;
_bt_list_splice_tail(&($5)->tmp_head, &($$)->u._enum.enumerator_list);
}
| CTF_LBRAC enumerator_list CTF_COMMA CTF_RBRAC
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
- ($$)->u._enum.container_type = $2;
+ ($$)->u._enum.container_field_class = $2;
_bt_list_splice_tail(&($4)->tmp_head, &($$)->u._enum.enumerator_list);
}
| IDENTIFIER CTF_LBRAC enumerator_list CTF_COMMA CTF_RBRAC
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
$$->u._enum.enum_id = $1;
- ($$)->u._enum.container_type = $3;
+ ($$)->u._enum.container_field_class = $3;
_bt_list_splice_tail(&($5)->tmp_head, &($$)->u._enum.enumerator_list);
}
| IDENTIFIER
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
$$->u._enum.enum_id = $1;
- ($$)->u._enum.container_type = $3;
+ ($$)->u._enum.container_field_class = $3;
_bt_list_splice_tail(&($5)->tmp_head, &($$)->u._enum.enumerator_list);
}
| ID_TYPE
struct ctf_node *list;
list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
- _bt_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
+ _bt_list_splice_tail(&($1)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
$$ = make_node(scanner, NODE_STRUCT_OR_VARIANT_DECLARATION);
- ($$)->u.struct_or_variant_declaration.type_specifier_list = list;
- _bt_list_splice_tail(&($2)->tmp_head, &($$)->u.struct_or_variant_declaration.type_declarators);
+ ($$)->u.struct_or_variant_declaration.field_class_specifier_list = list;
+ _bt_list_splice_tail(&($2)->tmp_head, &($$)->u.struct_or_variant_declaration.field_class_declarators);
}
- | declaration_specifiers CTF_TYPEDEF declaration_specifiers type_declarator_list CTF_SEMICOLON
+ | declaration_specifiers CTF_TYPEDEF declaration_specifiers field_class_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
$$ = make_node(scanner, NODE_TYPEDEF);
list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
- $$->u._typedef.type_specifier_list = list;
- _bt_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
- _bt_list_splice_tail(&($3)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
- _bt_list_splice_tail(&($4)->tmp_head, &($$)->u._typedef.type_declarators);
+ $$->u.field_class_def.field_class_specifier_list = list;
+ _bt_list_splice_tail(&($1)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
+ _bt_list_splice_tail(&($3)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
+ _bt_list_splice_tail(&($4)->tmp_head, &($$)->u.field_class_def.field_class_declarators);
}
- | CTF_TYPEDEF declaration_specifiers type_declarator_list CTF_SEMICOLON
+ | CTF_TYPEDEF declaration_specifiers field_class_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
$$ = make_node(scanner, NODE_TYPEDEF);
list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
- $$->u._typedef.type_specifier_list = list;
- _bt_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
- _bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
+ $$->u.field_class_def.field_class_specifier_list = list;
+ _bt_list_splice_tail(&($2)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
+ _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.field_class_def.field_class_declarators);
}
- | declaration_specifiers CTF_TYPEDEF type_declarator_list CTF_SEMICOLON
+ | declaration_specifiers CTF_TYPEDEF field_class_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
- _bt_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
+ _bt_list_splice_tail(&($1)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
$$ = make_node(scanner, NODE_TYPEDEF);
- ($$)->u.struct_or_variant_declaration.type_specifier_list = list;
- _bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
+ ($$)->u.struct_or_variant_declaration.field_class_specifier_list = list;
+ _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.field_class_def.field_class_declarators);
}
| CTF_TYPEALIAS declaration_specifiers abstract_declarator_list CTF_TYPEASSIGN alias_declaration_specifiers alias_abstract_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
$$ = make_node(scanner, NODE_TYPEALIAS);
- $$->u.typealias.target = make_node(scanner, NODE_TYPEALIAS_TARGET);
- $$->u.typealias.alias = make_node(scanner, NODE_TYPEALIAS_ALIAS);
+ $$->u.field_class_alias.target = make_node(scanner, NODE_TYPEALIAS_TARGET);
+ $$->u.field_class_alias.alias = make_node(scanner, NODE_TYPEALIAS_ALIAS);
list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
- $$->u.typealias.target->u.typealias_target.type_specifier_list = list;
- _bt_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
- _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.typealias.target->u.typealias_target.type_declarators);
+ $$->u.field_class_alias.target->u.field_class_alias_target.field_class_specifier_list = list;
+ _bt_list_splice_tail(&($2)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
+ _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.field_class_alias.target->u.field_class_alias_target.field_class_declarators);
list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
- $$->u.typealias.alias->u.typealias_alias.type_specifier_list = list;
- _bt_list_splice_tail(&($5)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
- _bt_list_splice_tail(&($6)->tmp_head, &($$)->u.typealias.alias->u.typealias_alias.type_declarators);
+ $$->u.field_class_alias.alias->u.field_class_alias_name.field_class_specifier_list = list;
+ _bt_list_splice_tail(&($5)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
+ _bt_list_splice_tail(&($6)->tmp_head, &($$)->u.field_class_alias.alias->u.field_class_alias_name.field_class_declarators);
}
;
$$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
node = make_node(scanner, NODE_TYPE_SPECIFIER);
- node->u.type_specifier.type = TYPESPEC_CONST;
- bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
+ node->u.field_class_specifier.type = TYPESPEC_CONST;
+ bt_list_add_tail(&node->siblings, &($$)->u.field_class_specifier_list.head);
}
- | type_specifier
+ | field_class_specifier
{
struct ctf_node *node;
$$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
node = $1;
- bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
+ bt_list_add_tail(&node->siblings, &($$)->u.field_class_specifier_list.head);
}
| IDENTIFIER
{
add_type(scanner, $1);
$$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
node = make_node(scanner, NODE_TYPE_SPECIFIER);
- node->u.type_specifier.type = TYPESPEC_ID_TYPE;
- node->u.type_specifier.id_type = yylval.s;
- bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
+ node->u.field_class_specifier.type = TYPESPEC_ID_TYPE;
+ node->u.field_class_specifier.id_type = yylval.s;
+ bt_list_add_tail(&node->siblings, &($$)->u.field_class_specifier_list.head);
}
| alias_declaration_specifiers CTF_CONST
{
$$ = $1;
node = make_node(scanner, NODE_TYPE_SPECIFIER);
- node->u.type_specifier.type = TYPESPEC_CONST;
- bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
+ node->u.field_class_specifier.type = TYPESPEC_CONST;
+ bt_list_add_tail(&node->siblings, &($$)->u.field_class_specifier_list.head);
}
- | alias_declaration_specifiers type_specifier
+ | alias_declaration_specifiers field_class_specifier
{
$$ = $1;
- bt_list_add_tail(&($2)->siblings, &($$)->u.type_specifier_list.head);
+ bt_list_add_tail(&($2)->siblings, &($$)->u.field_class_specifier_list.head);
}
| alias_declaration_specifiers IDENTIFIER
{
add_type(scanner, $2);
$$ = $1;
node = make_node(scanner, NODE_TYPE_SPECIFIER);
- node->u.type_specifier.type = TYPESPEC_ID_TYPE;
- node->u.type_specifier.id_type = yylval.s;
- bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
+ node->u.field_class_specifier.type = TYPESPEC_ID_TYPE;
+ node->u.field_class_specifier.id_type = yylval.s;
+ bt_list_add_tail(&node->siblings, &($$)->u.field_class_specifier_list.head);
}
;
| pointer direct_abstract_declarator
{
$$ = $2;
- bt_list_splice(&($1)->tmp_head, &($$)->u.type_declarator.pointers);
+ bt_list_splice(&($1)->tmp_head, &($$)->u.field_class_declarator.pointers);
}
;
/* empty */
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
- $$->u.type_declarator.type = TYPEDEC_ID;
+ $$->u.field_class_declarator.type = TYPEDEC_ID;
/* id is NULL */
}
| IDENTIFIER
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
- $$->u.type_declarator.type = TYPEDEC_ID;
- $$->u.type_declarator.u.id = $1;
+ $$->u.field_class_declarator.type = TYPEDEC_ID;
+ $$->u.field_class_declarator.u.id = $1;
}
| CTF_LPAREN abstract_declarator CTF_RPAREN
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
- $$->u.type_declarator.type = TYPEDEC_NESTED;
- $$->u.type_declarator.u.nested.type_declarator = $2;
+ $$->u.field_class_declarator.type = TYPEDEC_NESTED;
+ $$->u.field_class_declarator.u.nested.field_class_declarator = $2;
}
| direct_abstract_declarator CTF_LSBRAC unary_expression CTF_RSBRAC
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
- $$->u.type_declarator.type = TYPEDEC_NESTED;
- $$->u.type_declarator.u.nested.type_declarator = $1;
- BT_INIT_LIST_HEAD(&($$)->u.type_declarator.u.nested.length);
- _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.type_declarator.u.nested.length);
+ $$->u.field_class_declarator.type = TYPEDEC_NESTED;
+ $$->u.field_class_declarator.u.nested.field_class_declarator = $1;
+ BT_INIT_LIST_HEAD(&($$)->u.field_class_declarator.u.nested.length);
+ _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.field_class_declarator.u.nested.length);
}
| direct_abstract_declarator CTF_LSBRAC CTF_RSBRAC
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
- $$->u.type_declarator.type = TYPEDEC_NESTED;
- $$->u.type_declarator.u.nested.type_declarator = $1;
- $$->u.type_declarator.u.nested.abstract_array = 1;
+ $$->u.field_class_declarator.type = TYPEDEC_NESTED;
+ $$->u.field_class_declarator.u.nested.field_class_declarator = $1;
+ $$->u.field_class_declarator.u.nested.abstract_array = 1;
}
;
| pointer direct_alias_abstract_declarator
{
$$ = $2;
- bt_list_splice(&($1)->tmp_head, &($$)->u.type_declarator.pointers);
+ bt_list_splice(&($1)->tmp_head, &($$)->u.field_class_declarator.pointers);
}
;
/* empty */
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
- $$->u.type_declarator.type = TYPEDEC_ID;
+ $$->u.field_class_declarator.type = TYPEDEC_ID;
/* id is NULL */
}
| CTF_LPAREN alias_abstract_declarator CTF_RPAREN
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
- $$->u.type_declarator.type = TYPEDEC_NESTED;
- $$->u.type_declarator.u.nested.type_declarator = $2;
+ $$->u.field_class_declarator.type = TYPEDEC_NESTED;
+ $$->u.field_class_declarator.u.nested.field_class_declarator = $2;
}
| direct_alias_abstract_declarator CTF_LSBRAC unary_expression CTF_RSBRAC
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
- $$->u.type_declarator.type = TYPEDEC_NESTED;
- $$->u.type_declarator.u.nested.type_declarator = $1;
- BT_INIT_LIST_HEAD(&($$)->u.type_declarator.u.nested.length);
- _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.type_declarator.u.nested.length);
+ $$->u.field_class_declarator.type = TYPEDEC_NESTED;
+ $$->u.field_class_declarator.u.nested.field_class_declarator = $1;
+ BT_INIT_LIST_HEAD(&($$)->u.field_class_declarator.u.nested.length);
+ _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.field_class_declarator.u.nested.length);
}
| direct_alias_abstract_declarator CTF_LSBRAC CTF_RSBRAC
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
- $$->u.type_declarator.type = TYPEDEC_NESTED;
- $$->u.type_declarator.u.nested.type_declarator = $1;
- $$->u.type_declarator.u.nested.abstract_array = 1;
+ $$->u.field_class_declarator.type = TYPEDEC_NESTED;
+ $$->u.field_class_declarator.u.nested.field_class_declarator = $1;
+ $$->u.field_class_declarator.u.nested.abstract_array = 1;
}
;
| pointer direct_declarator
{
$$ = $2;
- bt_list_splice(&($1)->tmp_head, &($$)->u.type_declarator.pointers);
+ bt_list_splice(&($1)->tmp_head, &($$)->u.field_class_declarator.pointers);
}
;
IDENTIFIER
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
- $$->u.type_declarator.type = TYPEDEC_ID;
- $$->u.type_declarator.u.id = $1;
+ $$->u.field_class_declarator.type = TYPEDEC_ID;
+ $$->u.field_class_declarator.u.id = $1;
}
| CTF_LPAREN declarator CTF_RPAREN
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
- $$->u.type_declarator.type = TYPEDEC_NESTED;
- $$->u.type_declarator.u.nested.type_declarator = $2;
+ $$->u.field_class_declarator.type = TYPEDEC_NESTED;
+ $$->u.field_class_declarator.u.nested.field_class_declarator = $2;
}
| direct_declarator CTF_LSBRAC unary_expression CTF_RSBRAC
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
- $$->u.type_declarator.type = TYPEDEC_NESTED;
- $$->u.type_declarator.u.nested.type_declarator = $1;
- BT_INIT_LIST_HEAD(&($$)->u.type_declarator.u.nested.length);
- _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.type_declarator.u.nested.length);
+ $$->u.field_class_declarator.type = TYPEDEC_NESTED;
+ $$->u.field_class_declarator.u.nested.field_class_declarator = $1;
+ BT_INIT_LIST_HEAD(&($$)->u.field_class_declarator.u.nested.length);
+ _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.field_class_declarator.u.nested.length);
}
;
-type_declarator:
- direct_type_declarator
+field_class_declarator:
+ direct_field_class_declarator
{ $$ = $1; }
- | pointer direct_type_declarator
+ | pointer direct_field_class_declarator
{
$$ = $2;
- bt_list_splice(&($1)->tmp_head, &($$)->u.type_declarator.pointers);
+ bt_list_splice(&($1)->tmp_head, &($$)->u.field_class_declarator.pointers);
}
;
-direct_type_declarator:
+direct_field_class_declarator:
IDENTIFIER
{
add_type(scanner, $1);
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
- $$->u.type_declarator.type = TYPEDEC_ID;
- $$->u.type_declarator.u.id = $1;
+ $$->u.field_class_declarator.type = TYPEDEC_ID;
+ $$->u.field_class_declarator.u.id = $1;
}
- | CTF_LPAREN type_declarator CTF_RPAREN
+ | CTF_LPAREN field_class_declarator CTF_RPAREN
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
- $$->u.type_declarator.type = TYPEDEC_NESTED;
- $$->u.type_declarator.u.nested.type_declarator = $2;
+ $$->u.field_class_declarator.type = TYPEDEC_NESTED;
+ $$->u.field_class_declarator.u.nested.field_class_declarator = $2;
}
- | direct_type_declarator CTF_LSBRAC unary_expression CTF_RSBRAC
+ | direct_field_class_declarator CTF_LSBRAC unary_expression CTF_RSBRAC
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
- $$->u.type_declarator.type = TYPEDEC_NESTED;
- $$->u.type_declarator.u.nested.type_declarator = $1;
- BT_INIT_LIST_HEAD(&($$)->u.type_declarator.u.nested.length);
- _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.type_declarator.u.nested.length);
+ $$->u.field_class_declarator.type = TYPEDEC_NESTED;
+ $$->u.field_class_declarator.u.nested.field_class_declarator = $1;
+ BT_INIT_LIST_HEAD(&($$)->u.field_class_declarator.u.nested.length);
+ _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.field_class_declarator.u.nested.length);
}
;
reparent_error(scanner, "ctf_assignment_expression left expects string");
bt_list_add_tail(&($3)->siblings, &($$)->u.ctf_expression.right);
}
- | declaration_specifiers CTF_TYPEDEF declaration_specifiers type_declarator_list
+ | declaration_specifiers CTF_TYPEDEF declaration_specifiers field_class_declarator_list
{
struct ctf_node *list;
list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
- _bt_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
- _bt_list_splice_tail(&($3)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
+ _bt_list_splice_tail(&($1)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
+ _bt_list_splice_tail(&($3)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
$$ = make_node(scanner, NODE_TYPEDEF);
- ($$)->u.struct_or_variant_declaration.type_specifier_list = list;
- _bt_list_splice_tail(&($4)->tmp_head, &($$)->u._typedef.type_declarators);
+ ($$)->u.struct_or_variant_declaration.field_class_specifier_list = list;
+ _bt_list_splice_tail(&($4)->tmp_head, &($$)->u.field_class_def.field_class_declarators);
}
- | CTF_TYPEDEF declaration_specifiers type_declarator_list
+ | CTF_TYPEDEF declaration_specifiers field_class_declarator_list
{
struct ctf_node *list;
$$ = make_node(scanner, NODE_TYPEDEF);
list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
- $$->u._typedef.type_specifier_list = list;
- _bt_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
- _bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
+ $$->u.field_class_def.field_class_specifier_list = list;
+ _bt_list_splice_tail(&($2)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
+ _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.field_class_def.field_class_declarators);
}
- | declaration_specifiers CTF_TYPEDEF type_declarator_list
+ | declaration_specifiers CTF_TYPEDEF field_class_declarator_list
{
struct ctf_node *list;
list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
- _bt_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
+ _bt_list_splice_tail(&($1)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
$$ = make_node(scanner, NODE_TYPEDEF);
- ($$)->u.struct_or_variant_declaration.type_specifier_list = list;
- _bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
+ ($$)->u.struct_or_variant_declaration.field_class_specifier_list = list;
+ _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.field_class_def.field_class_declarators);
}
| CTF_TYPEALIAS declaration_specifiers abstract_declarator_list CTF_TYPEASSIGN alias_declaration_specifiers alias_abstract_declarator_list
{
struct ctf_node *list;
$$ = make_node(scanner, NODE_TYPEALIAS);
- $$->u.typealias.target = make_node(scanner, NODE_TYPEALIAS_TARGET);
- $$->u.typealias.alias = make_node(scanner, NODE_TYPEALIAS_ALIAS);
+ $$->u.field_class_alias.target = make_node(scanner, NODE_TYPEALIAS_TARGET);
+ $$->u.field_class_alias.alias = make_node(scanner, NODE_TYPEALIAS_ALIAS);
list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
- $$->u.typealias.target->u.typealias_target.type_specifier_list = list;
- _bt_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
- _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.typealias.target->u.typealias_target.type_declarators);
+ $$->u.field_class_alias.target->u.field_class_alias_target.field_class_specifier_list = list;
+ _bt_list_splice_tail(&($2)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
+ _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.field_class_alias.target->u.field_class_alias_target.field_class_declarators);
list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
- $$->u.typealias.alias->u.typealias_alias.type_specifier_list = list;
- _bt_list_splice_tail(&($5)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
- _bt_list_splice_tail(&($6)->tmp_head, &($$)->u.typealias.alias->u.typealias_alias.type_declarators);
+ $$->u.field_class_alias.alias->u.field_class_alias_name.field_class_specifier_list = list;
+ _bt_list_splice_tail(&($5)->u.field_class_specifier_list.head, &list->u.field_class_specifier_list.head);
+ _bt_list_splice_tail(&($6)->tmp_head, &($$)->u.field_class_alias.alias->u.field_class_alias_name.field_class_declarators);
}
;
struct ctf_scanner_scope;
struct ctf_scanner_scope {
struct ctf_scanner_scope *parent;
- GHashTable *types;
+ GHashTable *classes;
};
struct ctf_scanner {
_NR_LOGLEVELS = 15,
};
-/* Prefixes of type aliases */
+/* Prefixes of class aliases */
#define _PREFIX_ALIAS 'a'
#define _PREFIX_ENUM 'e'
#define _PREFIX_STRUCT 's'
#define _PREFIX_VARIANT 'v'
/* First entry in a BT list */
-#define _BT_LIST_FIRST_ENTRY(_ptr, _type, _member) \
- bt_list_entry((_ptr)->next, _type, _member)
+#define _BT_LIST_FIRST_ENTRY(_ptr, _class, _member) \
+ bt_list_entry((_ptr)->next, _class, _member)
#define _BT_LOGE_DUP_ATTR(_node, _attr, _entity) \
_BT_LOGE_LINENO((_node)->lineno, \
*/
struct ctx_decl_scope {
/*
- * Alias name to field type.
+ * Alias name to field class.
*
- * GQuark -> struct ctf_field_type * (owned by this)
+ * GQuark -> struct ctf_field_class * (owned by this)
*/
GHashTable *decl_map;
}
scope->decl_map = g_hash_table_new_full(g_direct_hash, g_direct_equal,
- NULL, (GDestroyNotify) ctf_field_type_destroy);
+ NULL, (GDestroyNotify) ctf_field_class_destroy);
scope->parent_scope = par_scope;
end:
}
/**
- * Looks up a prefixed type alias within a declaration scope.
+ * Looks up a prefixed class alias within a declaration scope.
*
* @param scope Declaration scope
* @param prefix Prefix character
* or NULL if not found
*/
static
-struct ctf_field_type *ctx_decl_scope_lookup_prefix_alias(
+struct ctf_field_class *ctx_decl_scope_lookup_prefix_alias(
struct ctx_decl_scope *scope, char prefix, const char *name,
int levels, bool copy)
{
GQuark qname = 0;
int cur_levels = 0;
- struct ctf_field_type *decl = NULL;
+ struct ctf_field_class *decl = NULL;
struct ctx_decl_scope *cur_scope = scope;
BT_ASSERT(scope);
if (decl) {
/* Caller's reference */
if (copy) {
- decl = ctf_field_type_copy(decl);
+ decl = ctf_field_class_copy(decl);
BT_ASSERT(decl);
}
}
/**
- * Looks up a type alias within a declaration scope.
+ * Looks up a class alias within a declaration scope.
*
* @param scope Declaration scope
* @param name Alias name
* or NULL if not found
*/
static
-struct ctf_field_type *ctx_decl_scope_lookup_alias(
+struct ctf_field_class *ctx_decl_scope_lookup_alias(
struct ctx_decl_scope *scope, const char *name, int levels,
bool copy)
{
* or NULL if not found
*/
static
-struct ctf_field_type_enum *ctx_decl_scope_lookup_enum(
+struct ctf_field_class_enum *ctx_decl_scope_lookup_enum(
struct ctx_decl_scope *scope, const char *name, int levels,
bool copy)
{
* or NULL if not found
*/
static
-struct ctf_field_type_struct *ctx_decl_scope_lookup_struct(
+struct ctf_field_class_struct *ctx_decl_scope_lookup_struct(
struct ctx_decl_scope *scope, const char *name, int levels,
bool copy)
{
* or NULL if not found
*/
static
-struct ctf_field_type_variant *ctx_decl_scope_lookup_variant(
+struct ctf_field_class_variant *ctx_decl_scope_lookup_variant(
struct ctx_decl_scope *scope, const char *name, int levels,
bool copy)
{
}
/**
- * Registers a prefixed type alias within a declaration scope.
+ * Registers a prefixed class alias within a declaration scope.
*
* @param scope Declaration scope
* @param prefix Prefix character
* @param name Alias name (non-NULL)
- * @param decl Field type to register (copied)
+ * @param decl Field class to register (copied)
* @returns 0 if registration went okay, negative value otherwise
*/
static
int ctx_decl_scope_register_prefix_alias(struct ctx_decl_scope *scope,
- char prefix, const char *name, struct ctf_field_type *decl)
+ char prefix, const char *name, struct ctf_field_class *decl)
{
int ret = 0;
GQuark qname = 0;
goto end;
}
- decl = ctf_field_type_copy(decl);
+ decl = ctf_field_class_copy(decl);
BT_ASSERT(decl);
g_hash_table_insert(scope->decl_map, GUINT_TO_POINTER(qname), decl);
}
/**
- * Registers a type alias within a declaration scope.
+ * Registers a class alias within a declaration scope.
*
* @param scope Declaration scope
* @param name Alias name (non-NULL)
- * @param decl Field type to register (copied)
+ * @param decl Field class to register (copied)
* @returns 0 if registration went okay, negative value otherwise
*/
static
int ctx_decl_scope_register_alias(struct ctx_decl_scope *scope,
- const char *name, struct ctf_field_type *decl)
+ const char *name, struct ctf_field_class *decl)
{
return ctx_decl_scope_register_prefix_alias(scope, _PREFIX_ALIAS,
name, (void *) decl);
*
* @param scope Declaration scope
* @param name Enumeration name (non-NULL)
- * @param decl Enumeration field type to register (copied)
+ * @param decl Enumeration field class to register (copied)
* @returns 0 if registration went okay, negative value otherwise
*/
static
int ctx_decl_scope_register_enum(struct ctx_decl_scope *scope,
- const char *name, struct ctf_field_type_enum *decl)
+ const char *name, struct ctf_field_class_enum *decl)
{
return ctx_decl_scope_register_prefix_alias(scope, _PREFIX_ENUM,
name, (void *) decl);
*
* @param scope Declaration scope
* @param name Structure name (non-NULL)
- * @param decl Structure field type to register (copied)
+ * @param decl Structure field class to register (copied)
* @returns 0 if registration went okay, negative value otherwise
*/
static
int ctx_decl_scope_register_struct(struct ctx_decl_scope *scope,
- const char *name, struct ctf_field_type_struct *decl)
+ const char *name, struct ctf_field_class_struct *decl)
{
return ctx_decl_scope_register_prefix_alias(scope, _PREFIX_STRUCT,
name, (void *) decl);
*
* @param scope Declaration scope
* @param name Variant name (non-NULL)
- * @param decl Variant field type to register
+ * @param decl Variant field class to register
* @returns 0 if registration went okay, negative value otherwise
*/
static
int ctx_decl_scope_register_variant(struct ctx_decl_scope *scope,
- const char *name, struct ctf_field_type_variant *decl)
+ const char *name, struct ctf_field_class_variant *decl)
{
return ctx_decl_scope_register_prefix_alias(scope, _PREFIX_VARIANT,
name, (void *) decl);
}
static
-int visit_type_specifier_list(struct ctx *ctx, struct ctf_node *ts_list,
- struct ctf_field_type **decl);
+int visit_field_class_specifier_list(struct ctx *ctx, struct ctf_node *ts_list,
+ struct ctf_field_class **decl);
static
char *remove_underscores_from_field_ref(const char *field_ref)
}
static
-int get_type_specifier_name(struct ctx *ctx, struct ctf_node *type_specifier,
+int get_class_specifier_name(struct ctx *ctx, struct ctf_node *cls_specifier,
GString *str)
{
int ret = 0;
- if (type_specifier->type != NODE_TYPE_SPECIFIER) {
- _BT_LOGE_NODE(type_specifier,
+ if (cls_specifier->type != NODE_TYPE_SPECIFIER) {
+ _BT_LOGE_NODE(cls_specifier,
"Unexpected node type: node-type=%d",
- type_specifier->type);
+ cls_specifier->type);
ret = -EINVAL;
goto end;
}
- switch (type_specifier->u.type_specifier.type) {
+ switch (cls_specifier->u.field_class_specifier.type) {
case TYPESPEC_VOID:
g_string_append(str, "void");
break;
g_string_append(str, "const");
break;
case TYPESPEC_ID_TYPE:
- if (type_specifier->u.type_specifier.id_type) {
+ if (cls_specifier->u.field_class_specifier.id_type) {
g_string_append(str,
- type_specifier->u.type_specifier.id_type);
+ cls_specifier->u.field_class_specifier.id_type);
}
break;
case TYPESPEC_STRUCT:
{
- struct ctf_node *node = type_specifier->u.type_specifier.node;
+ struct ctf_node *node = cls_specifier->u.field_class_specifier.node;
if (!node->u._struct.name) {
- _BT_LOGE_NODE(node, "Unexpected empty structure field type name.");
+ _BT_LOGE_NODE(node, "Unexpected empty structure field class name.");
ret = -EINVAL;
goto end;
}
}
case TYPESPEC_VARIANT:
{
- struct ctf_node *node = type_specifier->u.type_specifier.node;
+ struct ctf_node *node = cls_specifier->u.field_class_specifier.node;
if (!node->u.variant.name) {
- _BT_LOGE_NODE(node, "Unexpected empty variant field type name.");
+ _BT_LOGE_NODE(node, "Unexpected empty variant field class name.");
ret = -EINVAL;
goto end;
}
}
case TYPESPEC_ENUM:
{
- struct ctf_node *node = type_specifier->u.type_specifier.node;
+ struct ctf_node *node = cls_specifier->u.field_class_specifier.node;
if (!node->u._enum.enum_id) {
_BT_LOGE_NODE(node,
- "Unexpected empty enumeration field type (`enum`) name.");
+ "Unexpected empty enumeration field class (`enum`) name.");
ret = -EINVAL;
goto end;
}
case TYPESPEC_INTEGER:
case TYPESPEC_STRING:
default:
- _BT_LOGE_NODE(type_specifier->u.type_specifier.node,
- "Unexpected type specifier type: %d",
- type_specifier->u.type_specifier.type);
+ _BT_LOGE_NODE(cls_specifier->u.field_class_specifier.node,
+ "Unexpected field class specifier type: %d",
+ cls_specifier->u.field_class_specifier.type);
ret = -EINVAL;
goto end;
}
}
static
-int get_type_specifier_list_name(struct ctx *ctx,
- struct ctf_node *type_specifier_list, GString *str)
+int get_class_specifier_list_name(struct ctx *ctx,
+ struct ctf_node *cls_specifier_list, GString *str)
{
int ret = 0;
struct ctf_node *iter;
int alias_item_nr = 0;
struct bt_list_head *head =
- &type_specifier_list->u.type_specifier_list.head;
+ &cls_specifier_list->u.field_class_specifier_list.head;
bt_list_for_each_entry(iter, head, siblings) {
if (alias_item_nr != 0) {
}
alias_item_nr++;
- ret = get_type_specifier_name(ctx, iter, str);
+ ret = get_class_specifier_name(ctx, iter, str);
if (ret) {
goto end;
}
}
static
-GQuark create_typealias_identifier(struct ctx *ctx,
- struct ctf_node *type_specifier_list,
- struct ctf_node *node_type_declarator)
+GQuark create_class_alias_identifier(struct ctx *ctx,
+ struct ctf_node *cls_specifier_list,
+ struct ctf_node *node_field_class_declarator)
{
int ret;
char *str_c;
GQuark qalias = 0;
struct ctf_node *iter;
struct bt_list_head *pointers =
- &node_type_declarator->u.type_declarator.pointers;
+ &node_field_class_declarator->u.field_class_declarator.pointers;
str = g_string_new("");
- ret = get_type_specifier_list_name(ctx, type_specifier_list, str);
+ ret = get_class_specifier_list_name(ctx, cls_specifier_list, str);
if (ret) {
g_string_free(str, TRUE);
goto end;
}
static
-int visit_type_declarator(struct ctx *ctx, struct ctf_node *type_specifier_list,
- GQuark *field_name, struct ctf_node *node_type_declarator,
- struct ctf_field_type **field_decl,
- struct ctf_field_type *nested_decl)
+int visit_field_class_declarator(struct ctx *ctx,
+ struct ctf_node *cls_specifier_list,
+ GQuark *field_name, struct ctf_node *node_field_class_declarator,
+ struct ctf_field_class **field_decl,
+ struct ctf_field_class *nested_decl)
{
/*
* During this whole function, nested_decl is always OURS,
int ret = 0;
*field_decl = NULL;
- /* Validate type declarator node */
- if (node_type_declarator) {
- if (node_type_declarator->u.type_declarator.type ==
+ /* Validate field class declarator node */
+ if (node_field_class_declarator) {
+ if (node_field_class_declarator->u.field_class_declarator.type ==
TYPEDEC_UNKNOWN) {
- _BT_LOGE_NODE(node_type_declarator,
- "Unexpected type declarator type: type=%d",
- node_type_declarator->u.type_declarator.type);
+ _BT_LOGE_NODE(node_field_class_declarator,
+ "Unexpected field class declarator type: type=%d",
+ node_field_class_declarator->u.field_class_declarator.type);
ret = -EINVAL;
goto error;
}
/* TODO: GCC bitfields not supported yet */
- if (node_type_declarator->u.type_declarator.bitfield_len !=
+ if (node_field_class_declarator->u.field_class_declarator.bitfield_len !=
NULL) {
- _BT_LOGE_NODE(node_type_declarator,
+ _BT_LOGE_NODE(node_field_class_declarator,
"GCC bitfields are not supported as of this version.");
ret = -EPERM;
goto error;
/* Find the right nested declaration if not provided */
if (!nested_decl) {
struct bt_list_head *pointers =
- &node_type_declarator->u.type_declarator.pointers;
+ &node_field_class_declarator->u.field_class_declarator.pointers;
- if (node_type_declarator && !bt_list_empty(pointers)) {
+ if (node_field_class_declarator && !bt_list_empty(pointers)) {
GQuark qalias;
/*
* If we have a pointer declarator, it HAS to
- * be present in the typealiases (else fail).
+ * be present in the field class aliases (else
+ * fail).
*/
- qalias = create_typealias_identifier(ctx,
- type_specifier_list, node_type_declarator);
+ qalias = create_class_alias_identifier(ctx,
+ cls_specifier_list, node_field_class_declarator);
nested_decl =
ctx_decl_scope_lookup_alias(ctx->current_scope,
g_quark_to_string(qalias), -1, true);
if (!nested_decl) {
- _BT_LOGE_NODE(node_type_declarator,
- "Cannot find type alias: name=\"%s\"",
+ _BT_LOGE_NODE(node_field_class_declarator,
+ "Cannot find class alias: name=\"%s\"",
g_quark_to_string(qalias));
ret = -EINVAL;
goto error;
}
- if (nested_decl->id == CTF_FIELD_TYPE_ID_INT) {
+ if (nested_decl->id == CTF_FIELD_CLASS_ID_INT) {
/* Pointer: force integer's base to 16 */
- struct ctf_field_type_int *int_ft =
+ struct ctf_field_class_int *int_fc =
(void *) nested_decl;
- int_ft->disp_base =
- BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL;
+ int_fc->disp_base =
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL;
}
} else {
- ret = visit_type_specifier_list(ctx,
- type_specifier_list, &nested_decl);
+ ret = visit_field_class_specifier_list(ctx,
+ cls_specifier_list, &nested_decl);
if (ret) {
BT_ASSERT(!nested_decl);
goto error;
BT_ASSERT(nested_decl);
- if (!node_type_declarator) {
+ if (!node_field_class_declarator) {
*field_decl = nested_decl;
nested_decl = NULL;
goto end;
}
- if (node_type_declarator->u.type_declarator.type == TYPEDEC_ID) {
- if (node_type_declarator->u.type_declarator.u.id) {
+ if (node_field_class_declarator->u.field_class_declarator.type == TYPEDEC_ID) {
+ if (node_field_class_declarator->u.field_class_declarator.u.id) {
const char *id =
- node_type_declarator->u.type_declarator.u.id;
+ node_field_class_declarator->u.field_class_declarator.u.id;
if (id[0] == '_') {
id++;
goto end;
} else {
struct ctf_node *first;
- struct ctf_field_type *decl = NULL;
- struct ctf_field_type *outer_field_decl = NULL;
+ struct ctf_field_class *decl = NULL;
+ struct ctf_field_class *outer_field_decl = NULL;
struct bt_list_head *length =
- &node_type_declarator->
- u.type_declarator.u.nested.length;
+ &node_field_class_declarator->
+ u.field_class_declarator.u.nested.length;
/* Create array/sequence, pass nested_decl as child */
if (bt_list_empty(length)) {
- _BT_LOGE_NODE(node_type_declarator,
+ _BT_LOGE_NODE(node_field_class_declarator,
"Expecting length field reference or value.");
ret = -EINVAL;
goto error;
switch (first->u.unary_expression.type) {
case UNARY_UNSIGNED_CONSTANT:
{
- struct ctf_field_type_array *array_decl = NULL;
+ struct ctf_field_class_array *array_decl = NULL;
- array_decl = ctf_field_type_array_create();
+ array_decl = ctf_field_class_array_create();
BT_ASSERT(array_decl);
array_decl->length =
first->u.unary_expression.u.unsigned_constant;
- array_decl->base.elem_ft = nested_decl;
+ array_decl->base.elem_fc = nested_decl;
nested_decl = NULL;
decl = (void *) array_decl;
break;
case UNARY_STRING:
{
/* Lookup unsigned integer definition, create seq. */
- struct ctf_field_type_sequence *seq_decl = NULL;
+ struct ctf_field_class_sequence *seq_decl = NULL;
char *length_name = concatenate_unary_strings(length);
if (!length_name) {
- _BT_LOGE_NODE(node_type_declarator,
+ _BT_LOGE_NODE(node_field_class_declarator,
"Cannot concatenate unary strings.");
ret = -EINVAL;
goto error;
struct ctf_trace_class_env_entry *env_entry =
ctf_trace_class_borrow_env_entry_by_name(
ctx->ctf_tc, env_entry_name);
- struct ctf_field_type_array *array_decl;
+ struct ctf_field_class_array *array_decl;
if (!env_entry) {
- _BT_LOGE_NODE(node_type_declarator,
+ _BT_LOGE_NODE(node_field_class_declarator,
"Cannot find environment entry: "
"name=\"%s\"", env_entry_name);
ret = -EINVAL;
}
if (env_entry->type != CTF_TRACE_CLASS_ENV_ENTRY_TYPE_INT) {
- _BT_LOGE_NODE(node_type_declarator,
+ _BT_LOGE_NODE(node_field_class_declarator,
"Wrong environment entry type "
"(expecting integer): "
"name=\"%s\"", env_entry_name);
}
if (env_entry->value.i < 0) {
- _BT_LOGE_NODE(node_type_declarator,
+ _BT_LOGE_NODE(node_field_class_declarator,
"Invalid, negative array length: "
"env-entry-name=\"%s\", "
"value=%" PRId64,
goto error;
}
- array_decl = ctf_field_type_array_create();
+ array_decl = ctf_field_class_array_create();
BT_ASSERT(array_decl);
array_decl->length =
(uint64_t) env_entry->value.i;
- array_decl->base.elem_ft = nested_decl;
+ array_decl->base.elem_fc = nested_decl;
nested_decl = NULL;
decl = (void *) array_decl;
} else {
ret = -EINVAL;
goto error;
}
- seq_decl = ctf_field_type_sequence_create();
+ seq_decl = ctf_field_class_sequence_create();
BT_ASSERT(seq_decl);
- seq_decl->base.elem_ft = nested_decl;
+ seq_decl->base.elem_fc = nested_decl;
nested_decl = NULL;
g_string_assign(seq_decl->length_ref,
length_name_no_underscore);
* nested declaration as the content of the outer
* container, MOVING its ownership.
*/
- ret = visit_type_declarator(ctx, type_specifier_list,
+ ret = visit_field_class_declarator(ctx, cls_specifier_list,
field_name,
- node_type_declarator->
- u.type_declarator.u.nested.type_declarator,
+ node_field_class_declarator->
+ u.field_class_declarator.u.nested.field_class_declarator,
&outer_field_decl, decl);
decl = NULL;
if (ret) {
goto end;
error:
- ctf_field_type_destroy(*field_decl);
+ ctf_field_class_destroy(*field_decl);
*field_decl = NULL;
if (ret >= 0) {
}
end:
- ctf_field_type_destroy(nested_decl);
+ ctf_field_class_destroy(nested_decl);
nested_decl = NULL;
return ret;
}
static
int visit_struct_decl_field(struct ctx *ctx,
- struct ctf_field_type_struct *struct_decl,
- struct ctf_node *type_specifier_list,
- struct bt_list_head *type_declarators)
+ struct ctf_field_class_struct *struct_decl,
+ struct ctf_node *cls_specifier_list,
+ struct bt_list_head *field_class_declarators)
{
int ret = 0;
struct ctf_node *iter;
- struct ctf_field_type *field_decl = NULL;
+ struct ctf_field_class *field_decl = NULL;
- bt_list_for_each_entry(iter, type_declarators, siblings) {
+ bt_list_for_each_entry(iter, field_class_declarators, siblings) {
field_decl = NULL;
GQuark qfield_name;
const char *field_name;
- ret = visit_type_declarator(ctx, type_specifier_list,
+ ret = visit_field_class_declarator(ctx, cls_specifier_list,
&qfield_name, iter, &field_decl, NULL);
if (ret) {
BT_ASSERT(!field_decl);
- _BT_LOGE_NODE(type_specifier_list,
- "Cannot visit type declarator: ret=%d", ret);
+ _BT_LOGE_NODE(cls_specifier_list,
+ "Cannot visit field class declarator: ret=%d", ret);
goto error;
}
field_name = g_quark_to_string(qfield_name);
/* Check if field with same name already exists */
- if (ctf_field_type_struct_borrow_member_by_name(
+ if (ctf_field_class_struct_borrow_member_by_name(
struct_decl, field_name)) {
- _BT_LOGE_NODE(type_specifier_list,
- "Duplicate field in structure field type: "
+ _BT_LOGE_NODE(cls_specifier_list,
+ "Duplicate field in structure field class: "
"field-name=\"%s\"", field_name);
ret = -EINVAL;
goto error;
}
/* Add field to structure */
- ctf_field_type_struct_append_member(struct_decl,
+ ctf_field_class_struct_append_member(struct_decl,
field_name, field_decl);
field_decl = NULL;
}
return 0;
error:
- ctf_field_type_destroy(field_decl);
+ ctf_field_class_destroy(field_decl);
field_decl = NULL;
return ret;
}
static
int visit_variant_decl_field(struct ctx *ctx,
- struct ctf_field_type_variant *variant_decl,
- struct ctf_node *type_specifier_list,
- struct bt_list_head *type_declarators)
+ struct ctf_field_class_variant *variant_decl,
+ struct ctf_node *cls_specifier_list,
+ struct bt_list_head *field_class_declarators)
{
int ret = 0;
struct ctf_node *iter;
- struct ctf_field_type *field_decl = NULL;
+ struct ctf_field_class *field_decl = NULL;
- bt_list_for_each_entry(iter, type_declarators, siblings) {
+ bt_list_for_each_entry(iter, field_class_declarators, siblings) {
field_decl = NULL;
GQuark qfield_name;
const char *field_name;
- ret = visit_type_declarator(ctx, type_specifier_list,
+ ret = visit_field_class_declarator(ctx, cls_specifier_list,
&qfield_name, iter, &field_decl, NULL);
if (ret) {
BT_ASSERT(!field_decl);
- _BT_LOGE_NODE(type_specifier_list,
- "Cannot visit type declarator: ret=%d", ret);
+ _BT_LOGE_NODE(cls_specifier_list,
+ "Cannot visit field class declarator: ret=%d", ret);
goto error;
}
field_name = g_quark_to_string(qfield_name);
/* Check if field with same name already exists */
- if (ctf_field_type_variant_borrow_option_by_name(
+ if (ctf_field_class_variant_borrow_option_by_name(
variant_decl, field_name)) {
- _BT_LOGE_NODE(type_specifier_list,
- "Duplicate field in variant field type: "
+ _BT_LOGE_NODE(cls_specifier_list,
+ "Duplicate field in variant field class: "
"field-name=\"%s\"", field_name);
ret = -EINVAL;
goto error;
}
/* Add field to structure */
- ctf_field_type_variant_append_option(variant_decl,
+ ctf_field_class_variant_append_option(variant_decl,
field_name, field_decl);
field_decl = NULL;
}
return 0;
error:
- ctf_field_type_destroy(field_decl);
+ ctf_field_class_destroy(field_decl);
field_decl = NULL;
return ret;
}
static
-int visit_typedef(struct ctx *ctx, struct ctf_node *type_specifier_list,
- struct bt_list_head *type_declarators)
+int visit_field_class_def(struct ctx *ctx, struct ctf_node *cls_specifier_list,
+ struct bt_list_head *field_class_declarators)
{
int ret = 0;
GQuark qidentifier;
struct ctf_node *iter;
- struct ctf_field_type *type_decl = NULL;
+ struct ctf_field_class *class_decl = NULL;
- bt_list_for_each_entry(iter, type_declarators, siblings) {
- ret = visit_type_declarator(ctx, type_specifier_list,
- &qidentifier, iter, &type_decl, NULL);
+ bt_list_for_each_entry(iter, field_class_declarators, siblings) {
+ ret = visit_field_class_declarator(ctx, cls_specifier_list,
+ &qidentifier, iter, &class_decl, NULL);
if (ret) {
_BT_LOGE_NODE(iter,
- "Cannot visit type declarator: ret=%d", ret);
+ "Cannot visit field class declarator: ret=%d", ret);
ret = -EINVAL;
goto end;
}
- /* Do not allow typedef and typealias of untagged variants */
- if (type_decl->id == CTF_FIELD_TYPE_ID_VARIANT) {
- struct ctf_field_type_variant *var_ft =
- (void *) type_decl;
+ /* Do not allow field class def and alias of untagged variants */
+ if (class_decl->id == CTF_FIELD_CLASS_ID_VARIANT) {
+ struct ctf_field_class_variant *var_fc =
+ (void *) class_decl;
- if (var_ft->tag_path.path->len == 0) {
+ if (var_fc->tag_path.path->len == 0) {
_BT_LOGE_NODE(iter,
- "Type definition of untagged variant field type is not allowed.");
+ "Type definition of untagged variant field class is not allowed.");
ret = -EPERM;
goto end;
}
}
ret = ctx_decl_scope_register_alias(ctx->current_scope,
- g_quark_to_string(qidentifier), type_decl);
+ g_quark_to_string(qidentifier), class_decl);
if (ret) {
_BT_LOGE_NODE(iter,
- "Cannot register type definition: name=\"%s\"",
+ "Cannot register field class alias: name=\"%s\"",
g_quark_to_string(qidentifier));
goto end;
}
}
end:
- ctf_field_type_destroy(type_decl);
- type_decl = NULL;
+ ctf_field_class_destroy(class_decl);
+ class_decl = NULL;
return ret;
}
static
-int visit_typealias(struct ctx *ctx, struct ctf_node *target,
+int visit_field_class_alias(struct ctx *ctx, struct ctf_node *target,
struct ctf_node *alias)
{
int ret = 0;
GQuark qalias;
struct ctf_node *node;
GQuark qdummy_field_name;
- struct ctf_field_type *type_decl = NULL;
+ struct ctf_field_class *class_decl = NULL;
- /* Create target type declaration */
- if (bt_list_empty(&target->u.typealias_target.type_declarators)) {
+ /* Create target field class */
+ if (bt_list_empty(&target->u.field_class_alias_target.field_class_declarators)) {
node = NULL;
} else {
node = _BT_LIST_FIRST_ENTRY(
- &target->u.typealias_target.type_declarators,
+ &target->u.field_class_alias_target.field_class_declarators,
struct ctf_node, siblings);
}
- ret = visit_type_declarator(ctx,
- target->u.typealias_target.type_specifier_list,
- &qdummy_field_name, node, &type_decl, NULL);
+ ret = visit_field_class_declarator(ctx,
+ target->u.field_class_alias_target.field_class_specifier_list,
+ &qdummy_field_name, node, &class_decl, NULL);
if (ret) {
- BT_ASSERT(!type_decl);
+ BT_ASSERT(!class_decl);
_BT_LOGE_NODE(node,
- "Cannot visit type declarator: ret=%d", ret);
+ "Cannot visit field class declarator: ret=%d", ret);
goto end;
}
- /* Do not allow typedef and typealias of untagged variants */
- if (type_decl->id == CTF_FIELD_TYPE_ID_VARIANT) {
- struct ctf_field_type_variant *var_ft = (void *) type_decl;
+ /* Do not allow field class def and alias of untagged variants */
+ if (class_decl->id == CTF_FIELD_CLASS_ID_VARIANT) {
+ struct ctf_field_class_variant *var_fc = (void *) class_decl;
- if (var_ft->tag_path.path->len == 0) {
+ if (var_fc->tag_path.path->len == 0) {
_BT_LOGE_NODE(target,
- "Type definition of untagged variant field type is not allowed.");
+ "Type definition of untagged variant field class is not allowed.");
ret = -EPERM;
goto end;
}
}
/* Create alias identifier */
- node = _BT_LIST_FIRST_ENTRY(&alias->u.typealias_alias.type_declarators,
+ node = _BT_LIST_FIRST_ENTRY(&alias->u.field_class_alias_name.field_class_declarators,
struct ctf_node, siblings);
- qalias = create_typealias_identifier(ctx,
- alias->u.typealias_alias.type_specifier_list, node);
+ qalias = create_class_alias_identifier(ctx,
+ alias->u.field_class_alias_name.field_class_specifier_list, node);
ret = ctx_decl_scope_register_alias(ctx->current_scope,
- g_quark_to_string(qalias), type_decl);
+ g_quark_to_string(qalias), class_decl);
if (ret) {
_BT_LOGE_NODE(node,
- "Cannot register type alias: name=\"%s\"",
+ "Cannot register class alias: name=\"%s\"",
g_quark_to_string(qalias));
goto end;
}
end:
- ctf_field_type_destroy(type_decl);
- type_decl = NULL;
+ ctf_field_class_destroy(class_decl);
+ class_decl = NULL;
return ret;
}
static
int visit_struct_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
- struct ctf_field_type_struct *struct_decl)
+ struct ctf_field_class_struct *struct_decl)
{
int ret = 0;
switch (entry_node->type) {
case NODE_TYPEDEF:
- ret = visit_typedef(ctx,
- entry_node->u._typedef.type_specifier_list,
- &entry_node->u._typedef.type_declarators);
+ ret = visit_field_class_def(ctx,
+ entry_node->u.field_class_def.field_class_specifier_list,
+ &entry_node->u.field_class_def.field_class_declarators);
if (ret) {
_BT_LOGE_NODE(entry_node,
- "Cannot add type definition found in structure field type: ret=%d",
+ "Cannot add field class found in structure field class: ret=%d",
ret);
goto end;
}
break;
case NODE_TYPEALIAS:
- ret = visit_typealias(ctx, entry_node->u.typealias.target,
- entry_node->u.typealias.alias);
+ ret = visit_field_class_alias(ctx, entry_node->u.field_class_alias.target,
+ entry_node->u.field_class_alias.alias);
if (ret) {
_BT_LOGE_NODE(entry_node,
- "Cannot add type alias found in structure field type: ret=%d",
+ "Cannot add field class alias found in structure field class: ret=%d",
ret);
goto end;
}
/* Field */
ret = visit_struct_decl_field(ctx, struct_decl,
entry_node->u.struct_or_variant_declaration.
- type_specifier_list,
+ field_class_specifier_list,
&entry_node->u.struct_or_variant_declaration.
- type_declarators);
+ field_class_declarators);
if (ret) {
goto end;
}
static
int visit_variant_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
- struct ctf_field_type_variant *variant_decl)
+ struct ctf_field_class_variant *variant_decl)
{
int ret = 0;
switch (entry_node->type) {
case NODE_TYPEDEF:
- ret = visit_typedef(ctx,
- entry_node->u._typedef.type_specifier_list,
- &entry_node->u._typedef.type_declarators);
+ ret = visit_field_class_def(ctx,
+ entry_node->u.field_class_def.field_class_specifier_list,
+ &entry_node->u.field_class_def.field_class_declarators);
if (ret) {
_BT_LOGE_NODE(entry_node,
- "Cannot add type definition found in variant field type: ret=%d",
+ "Cannot add field class found in variant field class: ret=%d",
ret);
goto end;
}
break;
case NODE_TYPEALIAS:
- ret = visit_typealias(ctx, entry_node->u.typealias.target,
- entry_node->u.typealias.alias);
+ ret = visit_field_class_alias(ctx, entry_node->u.field_class_alias.target,
+ entry_node->u.field_class_alias.alias);
if (ret) {
_BT_LOGE_NODE(entry_node,
- "Cannot add type alias found in variant field type: ret=%d",
+ "Cannot add field class alias found in variant field class: ret=%d",
ret);
goto end;
}
/* Field */
ret = visit_variant_decl_field(ctx, variant_decl,
entry_node->u.struct_or_variant_declaration.
- type_specifier_list,
+ field_class_specifier_list,
&entry_node->u.struct_or_variant_declaration.
- type_declarators);
+ field_class_declarators);
if (ret) {
goto end;
}
int visit_struct_decl(struct ctx *ctx, const char *name,
struct bt_list_head *decl_list, int has_body,
struct bt_list_head *min_align,
- struct ctf_field_type_struct **struct_decl)
+ struct ctf_field_class_struct **struct_decl)
{
int ret = 0;
/* For named struct (without body), lookup in declaration scope */
if (!has_body) {
if (!name) {
- BT_LOGE_STR("Bodyless structure field type: missing name.");
+ BT_LOGE_STR("Bodyless structure field class: missing name.");
ret = -EPERM;
goto error;
}
*struct_decl = ctx_decl_scope_lookup_struct(ctx->current_scope,
name, -1, true);
if (!*struct_decl) {
- BT_LOGE("Cannot find structure field type: name=\"struct %s\"",
+ BT_LOGE("Cannot find structure field class: name=\"struct %s\"",
name);
ret = -EINVAL;
goto error;
if (name) {
if (ctx_decl_scope_lookup_struct(
ctx->current_scope, name, 1, false)) {
- BT_LOGE("Structure field type already declared in local scope: "
+ BT_LOGE("Structure field class already declared in local scope: "
"name=\"struct %s\"", name);
ret = -EINVAL;
goto error;
if (!bt_list_empty(min_align)) {
ret = get_unary_unsigned(min_align, &min_align_value);
if (ret) {
- BT_LOGE("Unexpected unary expression for structure field type's `align` attribute: "
+ BT_LOGE("Unexpected unary expression for structure field class's `align` attribute: "
"ret=%d", ret);
goto error;
}
}
- *struct_decl = ctf_field_type_struct_create();
+ *struct_decl = ctf_field_class_struct_create();
BT_ASSERT(*struct_decl);
if (min_align_value != 0) {
*struct_decl);
if (ret) {
_BT_LOGE_NODE(entry_node,
- "Cannot visit structure field type entry: "
+ "Cannot visit structure field class entry: "
"ret=%d", ret);
ctx_pop_scope(ctx);
goto error;
ret = ctx_decl_scope_register_struct(ctx->current_scope,
name, *struct_decl);
if (ret) {
- BT_LOGE("Cannot register structure field type in declaration scope: "
+ BT_LOGE("Cannot register structure field class in declaration scope: "
"name=\"struct %s\", ret=%d", name, ret);
goto error;
}
return 0;
error:
- ctf_field_type_destroy((void *) *struct_decl);
+ ctf_field_class_destroy((void *) *struct_decl);
*struct_decl = NULL;
return ret;
}
static
int visit_variant_decl(struct ctx *ctx, const char *name,
const char *tag, struct bt_list_head *decl_list,
- int has_body, struct ctf_field_type_variant **variant_decl)
+ int has_body, struct ctf_field_class_variant **variant_decl)
{
int ret = 0;
- struct ctf_field_type_variant *untagged_variant_decl = NULL;
+ struct ctf_field_class_variant *untagged_variant_decl = NULL;
BT_ASSERT(variant_decl);
*variant_decl = NULL;
/* For named variant (without body), lookup in declaration scope */
if (!has_body) {
if (!name) {
- BT_LOGE_STR("Bodyless variant field type: missing name.");
+ BT_LOGE_STR("Bodyless variant field class: missing name.");
ret = -EPERM;
goto error;
}
ctx_decl_scope_lookup_variant(ctx->current_scope,
name, -1, true);
if (!untagged_variant_decl) {
- BT_LOGE("Cannot find variant field type: name=\"variant %s\"",
+ BT_LOGE("Cannot find variant field class: name=\"variant %s\"",
name);
ret = -EINVAL;
goto error;
if (name) {
if (ctx_decl_scope_lookup_variant(ctx->current_scope,
name, 1, false)) {
- BT_LOGE("Variant field type already declared in local scope: "
+ BT_LOGE("Variant field class already declared in local scope: "
"name=\"variant %s\"", name);
ret = -EINVAL;
goto error;
}
}
- untagged_variant_decl = ctf_field_type_variant_create();
+ untagged_variant_decl = ctf_field_class_variant_create();
BT_ASSERT(untagged_variant_decl);
_TRY_PUSH_SCOPE_OR_GOTO_ERROR();
untagged_variant_decl);
if (ret) {
_BT_LOGE_NODE(entry_node,
- "Cannot visit variant field type entry: "
+ "Cannot visit variant field class entry: "
"ret=%d", ret);
ctx_pop_scope(ctx);
goto error;
ctx->current_scope, name,
untagged_variant_decl);
if (ret) {
- BT_LOGE("Cannot register variant field type in declaration scope: "
+ BT_LOGE("Cannot register variant field class in declaration scope: "
"name=\"variant %s\", ret=%d", name, ret);
goto error;
}
return 0;
error:
- ctf_field_type_destroy((void *) untagged_variant_decl);
+ ctf_field_class_destroy((void *) untagged_variant_decl);
untagged_variant_decl = NULL;
- ctf_field_type_destroy((void *) *variant_decl);
+ ctf_field_class_destroy((void *) *variant_decl);
*variant_decl = NULL;
return ret;
}
static
int visit_enum_decl_entry(struct ctx *ctx, struct ctf_node *enumerator,
- struct ctf_field_type_enum *enum_decl, struct uori *last)
+ struct ctf_field_class_enum *enum_decl, struct uori *last)
{
int ret = 0;
int nr_vals = 0;
if (iter->type != NODE_UNARY_EXPRESSION) {
_BT_LOGE_NODE(iter,
- "Wrong expression for enumeration field type label: "
+ "Wrong expression for enumeration field class label: "
"node-type=%d, label=\"%s\"", iter->type,
label);
ret = -EINVAL;
break;
default:
_BT_LOGE_NODE(iter,
- "Invalid enumeration field type entry: "
+ "Invalid enumeration field class entry: "
"expecting constant signed or unsigned integer: "
"node-type=%d, label=\"%s\"",
iter->u.unary_expression.type, label);
if (nr_vals > 1) {
_BT_LOGE_NODE(iter,
- "Invalid enumeration field type entry: label=\"%s\"",
+ "Invalid enumeration field class entry: label=\"%s\"",
label);
ret = -EINVAL;
goto error;
if (label[0] == '_') {
/*
* Strip the first underscore of any enumeration field
- * type's label in case this enumeration FT is used as
- * a variant FT tag later. The variant FT choice names
+ * class's label in case this enumeration FC is used as
+ * a variant FC tag later. The variant FC choice names
* could also start with `_`, in which case the prefix
* is removed, and it the resulting choice name needs to
* match tag labels.
effective_label = &label[1];
}
- ctf_field_type_enum_append_mapping(enum_decl, effective_label,
+ ctf_field_class_enum_append_mapping(enum_decl, effective_label,
start.value.u, end.value.u);
return 0;
static
int visit_enum_decl(struct ctx *ctx, const char *name,
- struct ctf_node *container_type,
+ struct ctf_node *container_cls,
struct bt_list_head *enumerator_list,
- int has_body, struct ctf_field_type_enum **enum_decl)
+ int has_body, struct ctf_field_class_enum **enum_decl)
{
int ret = 0;
GQuark qdummy_id;
- struct ctf_field_type_int *integer_decl = NULL;
+ struct ctf_field_class_int *integer_decl = NULL;
BT_ASSERT(enum_decl);
*enum_decl = NULL;
/* For named enum (without body), lookup in declaration scope */
if (!has_body) {
if (!name) {
- BT_LOGE_STR("Bodyless enumeration field type: missing name.");
+ BT_LOGE_STR("Bodyless enumeration field class: missing name.");
ret = -EPERM;
goto error;
}
*enum_decl = ctx_decl_scope_lookup_enum(ctx->current_scope,
name, -1, true);
if (!*enum_decl) {
- BT_LOGE("Cannot find enumeration field type: "
+ BT_LOGE("Cannot find enumeration field class: "
"name=\"enum %s\"", name);
ret = -EINVAL;
goto error;
if (name) {
if (ctx_decl_scope_lookup_enum(ctx->current_scope,
name, 1, false)) {
- BT_LOGE("Enumeration field type already declared in local scope: "
+ BT_LOGE("Enumeration field class already declared in local scope: "
"name=\"enum %s\"", name);
ret = -EINVAL;
goto error;
}
}
- if (!container_type) {
+ if (!container_cls) {
integer_decl = (void *) ctx_decl_scope_lookup_alias(
ctx->current_scope, "int", -1, true);
if (!integer_decl) {
- BT_LOGE_STR("Cannot find implicit `int` field type alias for enumeration field type.");
+ BT_LOGE_STR("Cannot find implicit `int` field class alias for enumeration field class.");
ret = -EINVAL;
goto error;
}
} else {
- ret = visit_type_declarator(ctx, container_type,
+ ret = visit_field_class_declarator(ctx, container_cls,
&qdummy_id, NULL, (void *) &integer_decl,
NULL);
if (ret) {
BT_ASSERT(integer_decl);
- if (integer_decl->base.base.id != CTF_FIELD_TYPE_ID_INT) {
- BT_LOGE("Container field type for enumeration field type is not an integer field type: "
- "ft-id=%d", integer_decl->base.base.id);
+ if (integer_decl->base.base.id != CTF_FIELD_CLASS_ID_INT) {
+ BT_LOGE("Container field class for enumeration field class is not an integer field class: "
+ "fc-id=%d", integer_decl->base.base.id);
ret = -EINVAL;
goto error;
}
- *enum_decl = ctf_field_type_enum_create();
+ *enum_decl = ctf_field_class_enum_create();
BT_ASSERT(*enum_decl);
(*enum_decl)->base.base.base.alignment =
integer_decl->base.base.alignment;
- ctf_field_type_int_copy_content((void *) *enum_decl,
+ ctf_field_class_int_copy_content((void *) *enum_decl,
(void *) integer_decl);
last_value.is_signed = (*enum_decl)->base.is_signed;
&last_value);
if (ret) {
_BT_LOGE_NODE(iter,
- "Cannot visit enumeration field type entry: "
+ "Cannot visit enumeration field class entry: "
"ret=%d", ret);
goto error;
}
ret = ctx_decl_scope_register_enum(ctx->current_scope,
name, *enum_decl);
if (ret) {
- BT_LOGE("Cannot register enumeration field type in declaration scope: "
+ BT_LOGE("Cannot register enumeration field class in declaration scope: "
"ret=%d", ret);
goto error;
}
goto end;
error:
- ctf_field_type_destroy((void *) *enum_decl);
+ ctf_field_class_destroy((void *) *enum_decl);
*enum_decl = NULL;
end:
- ctf_field_type_destroy((void *) integer_decl);
+ ctf_field_class_destroy((void *) integer_decl);
integer_decl = NULL;
return ret;
}
static
-int visit_type_specifier(struct ctx *ctx,
- struct ctf_node *type_specifier_list,
- struct ctf_field_type **decl)
+int visit_field_class_specifier(struct ctx *ctx,
+ struct ctf_node *cls_specifier_list,
+ struct ctf_field_class **decl)
{
int ret = 0;
GString *str = NULL;
*decl = NULL;
str = g_string_new("");
- ret = get_type_specifier_list_name(ctx, type_specifier_list, str);
+ ret = get_class_specifier_list_name(ctx, cls_specifier_list, str);
if (ret) {
- _BT_LOGE_NODE(type_specifier_list,
- "Cannot get type specifier list's name: ret=%d", ret);
+ _BT_LOGE_NODE(cls_specifier_list,
+ "Cannot get field class specifier list's name: ret=%d", ret);
goto error;
}
*decl = ctx_decl_scope_lookup_alias(ctx->current_scope, str->str, -1,
true);
if (!*decl) {
- _BT_LOGE_NODE(type_specifier_list,
- "Cannot find type alias: name=\"%s\"", str->str);
+ _BT_LOGE_NODE(cls_specifier_list,
+ "Cannot find field class alias: name=\"%s\"", str->str);
ret = -EINVAL;
goto error;
}
goto end;
error:
- ctf_field_type_destroy(*decl);
+ ctf_field_class_destroy(*decl);
*decl = NULL;
end:
static
int visit_integer_decl(struct ctx *ctx,
struct bt_list_head *expressions,
- struct ctf_field_type_int **integer_decl)
+ struct ctf_field_class_int **integer_decl)
{
int set = 0;
int ret = 0;
uint64_t alignment = 0, size = 0;
struct bt_clock_class *mapped_clock_class = NULL;
enum ctf_encoding encoding = CTF_ENCODING_NONE;
- enum bt_field_type_integer_preferred_display_base base =
- BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL;
+ enum bt_field_class_integer_preferred_display_base base =
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL;
enum ctf_byte_order byte_order = ctx->ctf_tc->default_byte_order;
*integer_decl = NULL;
if (!strcmp(left->u.unary_expression.u.string, "signed")) {
if (_IS_SET(&set, _INTEGER_SIGNED_SET)) {
_BT_LOGE_DUP_ATTR(left, "signed",
- "integer field type");
+ "integer field class");
ret = -EPERM;
goto error;
}
signedness = get_boolean(right);
if (signedness < 0) {
_BT_LOGE_NODE(right,
- "Invalid boolean value for integer field type's `signed` attribute: "
+ "Invalid boolean value for integer field class's `signed` attribute: "
"ret=%d", ret);
ret = -EINVAL;
goto error;
"byte_order")) {
if (_IS_SET(&set, _INTEGER_BYTE_ORDER_SET)) {
_BT_LOGE_DUP_ATTR(left, "byte_order",
- "integer field type");
+ "integer field class");
ret = -EPERM;
goto error;
}
byte_order = get_real_byte_order(ctx, right);
if (byte_order == -1) {
_BT_LOGE_NODE(right,
- "Invalid `byte_order` attribute in integer field type: "
+ "Invalid `byte_order` attribute in integer field class: "
"ret=%d", ret);
ret = -EINVAL;
goto error;
} else if (!strcmp(left->u.unary_expression.u.string, "size")) {
if (_IS_SET(&set, _INTEGER_SIZE_SET)) {
_BT_LOGE_DUP_ATTR(left, "size",
- "integer field type");
+ "integer field class");
ret = -EPERM;
goto error;
}
if (right->u.unary_expression.type !=
UNARY_UNSIGNED_CONSTANT) {
_BT_LOGE_NODE(right,
- "Invalid `size` attribute in integer field type: "
+ "Invalid `size` attribute in integer field class: "
"expecting unsigned constant integer: "
"node-type=%d",
right->u.unary_expression.type);
size = right->u.unary_expression.u.unsigned_constant;
if (size == 0) {
_BT_LOGE_NODE(right,
- "Invalid `size` attribute in integer field type: "
+ "Invalid `size` attribute in integer field class: "
"expecting positive constant integer: "
"size=%" PRIu64, size);
ret = -EINVAL;
goto error;
} else if (size > 64) {
_BT_LOGE_NODE(right,
- "Invalid `size` attribute in integer field type: "
+ "Invalid `size` attribute in integer field class: "
"integer fields over 64 bits are not supported as of this version: "
"size=%" PRIu64, size);
ret = -EINVAL;
"align")) {
if (_IS_SET(&set, _INTEGER_ALIGN_SET)) {
_BT_LOGE_DUP_ATTR(left, "align",
- "integer field type");
+ "integer field class");
ret = -EPERM;
goto error;
}
if (right->u.unary_expression.type !=
UNARY_UNSIGNED_CONSTANT) {
_BT_LOGE_NODE(right,
- "Invalid `align` attribute in integer field type: "
+ "Invalid `align` attribute in integer field class: "
"expecting unsigned constant integer: "
"node-type=%d",
right->u.unary_expression.type);
right->u.unary_expression.u.unsigned_constant;
if (!is_align_valid(alignment)) {
_BT_LOGE_NODE(right,
- "Invalid `align` attribute in integer field type: "
+ "Invalid `align` attribute in integer field class: "
"expecting power of two: "
"align=%" PRIu64, alignment);
ret = -EINVAL;
} else if (!strcmp(left->u.unary_expression.u.string, "base")) {
if (_IS_SET(&set, _INTEGER_BASE_SET)) {
_BT_LOGE_DUP_ATTR(left, "base",
- "integer field type");
+ "integer field class");
ret = -EPERM;
goto error;
}
switch (constant) {
case 2:
- base = BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_BINARY;
+ base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY;
break;
case 8:
- base = BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL;
+ base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL;
break;
case 10:
- base = BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL;
+ base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL;
break;
case 16:
- base = BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL;
+ base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL;
break;
default:
_BT_LOGE_NODE(right,
- "Invalid `base` attribute in integer field type: "
+ "Invalid `base` attribute in integer field class: "
"base=%" PRIu64,
right->u.unary_expression.u.unsigned_constant);
ret = -EINVAL;
&expression->u.ctf_expression.right);
if (!s_right) {
_BT_LOGE_NODE(right,
- "Unexpected unary expression for integer field type's `base` attribute.");
+ "Unexpected unary expression for integer field class's `base` attribute.");
ret = -EINVAL;
goto error;
}
!strcmp(s_right, "d") ||
!strcmp(s_right, "i") ||
!strcmp(s_right, "u")) {
- base = BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL;
+ base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL;
} else if (!strcmp(s_right, "hexadecimal") ||
!strcmp(s_right, "hex") ||
!strcmp(s_right, "x") ||
!strcmp(s_right, "X") ||
!strcmp(s_right, "p")) {
- base = BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL;
+ base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL;
} else if (!strcmp(s_right, "octal") ||
!strcmp(s_right, "oct") ||
!strcmp(s_right, "o")) {
- base = BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL;
+ base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL;
} else if (!strcmp(s_right, "binary") ||
!strcmp(s_right, "b")) {
- base = BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_BINARY;
+ base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY;
} else {
_BT_LOGE_NODE(right,
- "Unexpected unary expression for integer field type's `base` attribute: "
+ "Unexpected unary expression for integer field class's `base` attribute: "
"base=\"%s\"", s_right);
g_free(s_right);
ret = -EINVAL;
}
default:
_BT_LOGE_NODE(right,
- "Invalid `base` attribute in integer field type: "
+ "Invalid `base` attribute in integer field class: "
"expecting unsigned constant integer or unary string.");
ret = -EINVAL;
goto error;
if (_IS_SET(&set, _INTEGER_ENCODING_SET)) {
_BT_LOGE_DUP_ATTR(left, "encoding",
- "integer field type");
+ "integer field class");
ret = -EPERM;
goto error;
}
if (right->u.unary_expression.type != UNARY_STRING) {
_BT_LOGE_NODE(right,
- "Invalid `encoding` attribute in integer field type: "
+ "Invalid `encoding` attribute in integer field class: "
"expecting unary string.");
ret = -EINVAL;
goto error;
&expression->u.ctf_expression.right);
if (!s_right) {
_BT_LOGE_NODE(right,
- "Unexpected unary expression for integer field type's `encoding` attribute.");
+ "Unexpected unary expression for integer field class's `encoding` attribute.");
ret = -EINVAL;
goto error;
}
encoding = CTF_ENCODING_NONE;
} else {
_BT_LOGE_NODE(right,
- "Invalid `encoding` attribute in integer field type: "
+ "Invalid `encoding` attribute in integer field class: "
"unknown encoding: encoding=\"%s\"",
s_right);
g_free(s_right);
if (_IS_SET(&set, _INTEGER_MAP_SET)) {
_BT_LOGE_DUP_ATTR(left, "map",
- "integer field type");
+ "integer field class");
ret = -EPERM;
goto error;
}
if (right->u.unary_expression.type != UNARY_STRING) {
_BT_LOGE_NODE(right,
- "Invalid `map` attribute in integer field type: "
+ "Invalid `map` attribute in integer field class: "
"expecting unary string.");
ret = -EINVAL;
goto error;
if (!s_right) {
_BT_LOGE_NODE(right,
- "Unexpected unary expression for integer field type's `map` attribute.");
+ "Unexpected unary expression for integer field class's `map` attribute.");
ret = -EINVAL;
goto error;
}
_BT_LOGE_NODE(right,
- "Invalid `map` attribute in integer field type: "
+ "Invalid `map` attribute in integer field class: "
"cannot find clock class at this point: name=\"%s\"",
s_right);
_SET(&set, _INTEGER_MAP_SET);
ctx->ctf_tc, clock_name);
if (!mapped_clock_class) {
_BT_LOGE_NODE(right,
- "Invalid `map` attribute in integer field type: "
+ "Invalid `map` attribute in integer field class: "
"cannot find clock class at this point: name=\"%s\"",
clock_name);
ret = -EINVAL;
_SET(&set, _INTEGER_MAP_SET);
} else {
_BT_LOGW_NODE(left,
- "Unknown attribute in integer field type: "
+ "Unknown attribute in integer field class: "
"attr-name=\"%s\"",
left->u.unary_expression.u.string);
}
}
if (!_IS_SET(&set, _INTEGER_SIZE_SET)) {
- BT_LOGE_STR("Missing `size` attribute in integer field type.");
+ BT_LOGE_STR("Missing `size` attribute in integer field class.");
ret = -EPERM;
goto error;
}
}
}
- *integer_decl = ctf_field_type_int_create();
+ *integer_decl = ctf_field_class_int_create();
BT_ASSERT(*integer_decl);
(*integer_decl)->base.base.alignment = alignment;
(*integer_decl)->base.byte_order = byte_order;
return 0;
error:
- ctf_field_type_destroy((void *) *integer_decl);
+ ctf_field_class_destroy((void *) *integer_decl);
*integer_decl = NULL;
return ret;
}
static
int visit_floating_point_number_decl(struct ctx *ctx,
struct bt_list_head *expressions,
- struct ctf_field_type_float **float_decl)
+ struct ctf_field_class_float **float_decl)
{
int set = 0;
int ret = 0;
if (!strcmp(left->u.unary_expression.u.string, "byte_order")) {
if (_IS_SET(&set, _FLOAT_BYTE_ORDER_SET)) {
_BT_LOGE_DUP_ATTR(left, "byte_order",
- "floating point number field type");
+ "floating point number field class");
ret = -EPERM;
goto error;
}
byte_order = get_real_byte_order(ctx, right);
if (byte_order == -1) {
_BT_LOGE_NODE(right,
- "Invalid `byte_order` attribute in floating point number field type: "
+ "Invalid `byte_order` attribute in floating point number field class: "
"ret=%d", ret);
ret = -EINVAL;
goto error;
"exp_dig")) {
if (_IS_SET(&set, _FLOAT_EXP_DIG_SET)) {
_BT_LOGE_DUP_ATTR(left, "exp_dig",
- "floating point number field type");
+ "floating point number field class");
ret = -EPERM;
goto error;
}
if (right->u.unary_expression.type !=
UNARY_UNSIGNED_CONSTANT) {
_BT_LOGE_NODE(right,
- "Invalid `exp_dig` attribute in floating point number field type: "
+ "Invalid `exp_dig` attribute in floating point number field class: "
"expecting unsigned constant integer: "
"node-type=%d",
right->u.unary_expression.type);
"mant_dig")) {
if (_IS_SET(&set, _FLOAT_MANT_DIG_SET)) {
_BT_LOGE_DUP_ATTR(left, "mant_dig",
- "floating point number field type");
+ "floating point number field class");
ret = -EPERM;
goto error;
}
if (right->u.unary_expression.type !=
UNARY_UNSIGNED_CONSTANT) {
_BT_LOGE_NODE(right,
- "Invalid `mant_dig` attribute in floating point number field type: "
+ "Invalid `mant_dig` attribute in floating point number field class: "
"expecting unsigned constant integer: "
"node-type=%d",
right->u.unary_expression.type);
"align")) {
if (_IS_SET(&set, _FLOAT_ALIGN_SET)) {
_BT_LOGE_DUP_ATTR(left, "align",
- "floating point number field type");
+ "floating point number field class");
ret = -EPERM;
goto error;
}
if (right->u.unary_expression.type !=
UNARY_UNSIGNED_CONSTANT) {
_BT_LOGE_NODE(right,
- "Invalid `align` attribute in floating point number field type: "
+ "Invalid `align` attribute in floating point number field class: "
"expecting unsigned constant integer: "
"node-type=%d",
right->u.unary_expression.type);
if (!is_align_valid(alignment)) {
_BT_LOGE_NODE(right,
- "Invalid `align` attribute in floating point number field type: "
+ "Invalid `align` attribute in floating point number field class: "
"expecting power of two: "
"align=%" PRIu64, alignment);
ret = -EINVAL;
_SET(&set, _FLOAT_ALIGN_SET);
} else {
_BT_LOGW_NODE(left,
- "Unknown attribute in floating point number field type: "
+ "Unknown attribute in floating point number field class: "
"attr-name=\"%s\"",
left->u.unary_expression.u.string);
}
}
if (!_IS_SET(&set, _FLOAT_MANT_DIG_SET)) {
- BT_LOGE_STR("Missing `mant_dig` attribute in floating point number field type.");
+ BT_LOGE_STR("Missing `mant_dig` attribute in floating point number field class.");
ret = -EPERM;
goto error;
}
if (!_IS_SET(&set, _FLOAT_EXP_DIG_SET)) {
- BT_LOGE_STR("Missing `exp_dig` attribute in floating point number field type.");
+ BT_LOGE_STR("Missing `exp_dig` attribute in floating point number field class.");
ret = -EPERM;
goto error;
}
}
}
- *float_decl = ctf_field_type_float_create();
+ *float_decl = ctf_field_class_float_create();
BT_ASSERT(*float_decl);
(*float_decl)->base.base.alignment = alignment;
(*float_decl)->base.byte_order = byte_order;
return 0;
error:
- ctf_field_type_destroy((void *) *float_decl);
+ ctf_field_class_destroy((void *) *float_decl);
*float_decl = NULL;
return ret;
}
static
int visit_string_decl(struct ctx *ctx,
struct bt_list_head *expressions,
- struct ctf_field_type_string **string_decl)
+ struct ctf_field_class_string **string_decl)
{
int set = 0;
int ret = 0;
if (_IS_SET(&set, _STRING_ENCODING_SET)) {
_BT_LOGE_DUP_ATTR(left, "encoding",
- "string field type");
+ "string field class");
ret = -EPERM;
goto error;
}
if (right->u.unary_expression.type != UNARY_STRING) {
_BT_LOGE_NODE(right,
- "Invalid `encoding` attribute in string field type: "
+ "Invalid `encoding` attribute in string field class: "
"expecting unary string.");
ret = -EINVAL;
goto error;
&expression->u.ctf_expression.right);
if (!s_right) {
_BT_LOGE_NODE(right,
- "Unexpected unary expression for string field type's `encoding` attribute.");
+ "Unexpected unary expression for string field class's `encoding` attribute.");
ret = -EINVAL;
goto error;
}
encoding = CTF_ENCODING_NONE;
} else {
_BT_LOGE_NODE(right,
- "Invalid `encoding` attribute in string field type: "
+ "Invalid `encoding` attribute in string field class: "
"unknown encoding: encoding=\"%s\"",
s_right);
g_free(s_right);
_SET(&set, _STRING_ENCODING_SET);
} else {
_BT_LOGW_NODE(left,
- "Unknown attribute in string field type: "
+ "Unknown attribute in string field class: "
"attr-name=\"%s\"",
left->u.unary_expression.u.string);
}
}
- *string_decl = ctf_field_type_string_create();
+ *string_decl = ctf_field_class_string_create();
BT_ASSERT(*string_decl);
(*string_decl)->encoding = encoding;
return 0;
error:
- ctf_field_type_destroy((void *) *string_decl);
+ ctf_field_class_destroy((void *) *string_decl);
*string_decl = NULL;
return ret;
}
static
-int visit_type_specifier_list(struct ctx *ctx,
- struct ctf_node *ts_list, struct ctf_field_type **decl)
+int visit_field_class_specifier_list(struct ctx *ctx,
+ struct ctf_node *ts_list, struct ctf_field_class **decl)
{
int ret = 0;
struct ctf_node *first, *node;
goto error;
}
- first = _BT_LIST_FIRST_ENTRY(&ts_list->u.type_specifier_list.head,
+ first = _BT_LIST_FIRST_ENTRY(&ts_list->u.field_class_specifier_list.head,
struct ctf_node, siblings);
if (first->type != NODE_TYPE_SPECIFIER) {
_BT_LOGE_NODE(first,
goto error;
}
- node = first->u.type_specifier.node;
+ node = first->u.field_class_specifier.node;
- switch (first->u.type_specifier.type) {
+ switch (first->u.field_class_specifier.type) {
case TYPESPEC_INTEGER:
ret = visit_integer_decl(ctx, &node->u.integer.expressions,
(void *) decl);
break;
case TYPESPEC_ENUM:
ret = visit_enum_decl(ctx, node->u._enum.enum_id,
- node->u._enum.container_type,
+ node->u._enum.container_field_class,
&node->u._enum.enumerator_list,
node->u._enum.has_body, (void *) decl);
if (ret) {
case TYPESPEC_IMAGINARY:
case TYPESPEC_CONST:
case TYPESPEC_ID_TYPE:
- ret = visit_type_specifier(ctx, ts_list, decl);
+ ret = visit_field_class_specifier(ctx, ts_list, decl);
if (ret) {
_BT_LOGE_NODE(first,
- "Cannot visit type specifier: ret=%d",
+ "Cannot visit field class specifier: ret=%d",
ret);
BT_ASSERT(!*decl);
goto error;
break;
default:
_BT_LOGE_NODE(first,
- "Unexpected type specifier type: node-type=%d",
- first->u.type_specifier.type);
+ "Unexpected field class specifier type: node-type=%d",
+ first->u.field_class_specifier.type);
ret = -EINVAL;
goto error;
}
return 0;
error:
- ctf_field_type_destroy((void *) *decl);
+ ctf_field_class_destroy((void *) *decl);
*decl = NULL;
return ret;
}
switch (node->type) {
case NODE_TYPEDEF:
- ret = visit_typedef(ctx, node->u._typedef.type_specifier_list,
- &node->u._typedef.type_declarators);
+ ret = visit_field_class_def(ctx, node->u.field_class_def.field_class_specifier_list,
+ &node->u.field_class_def.field_class_declarators);
if (ret) {
_BT_LOGE_NODE(node,
- "Cannot add type definition found in event class.");
+ "Cannot add field class found in event class.");
goto error;
}
break;
case NODE_TYPEALIAS:
- ret = visit_typealias(ctx, node->u.typealias.target,
- node->u.typealias.alias);
+ ret = visit_field_class_alias(ctx, node->u.field_class_alias.target,
+ node->u.field_class_alias.alias);
if (ret) {
_BT_LOGE_NODE(node,
- "Cannot add type alias found in event class.");
+ "Cannot add field class alias found in event class.");
goto error;
}
break;
goto error;
}
- ret = visit_type_specifier_list(ctx,
+ ret = visit_field_class_specifier_list(ctx,
_BT_LIST_FIRST_ENTRY(
&node->u.ctf_expression.right,
struct ctf_node, siblings),
- &event_class->spec_context_ft);
+ &event_class->spec_context_fc);
if (ret) {
_BT_LOGE_NODE(node,
- "Cannot create event class's context field type.");
+ "Cannot create event class's context field class.");
goto error;
}
- BT_ASSERT(event_class->spec_context_ft);
+ BT_ASSERT(event_class->spec_context_fc);
_SET(set, _EVENT_CONTEXT_SET);
} else if (!strcmp(left, "fields")) {
if (_IS_SET(set, _EVENT_FIELDS_SET)) {
goto error;
}
- ret = visit_type_specifier_list(ctx,
+ ret = visit_field_class_specifier_list(ctx,
_BT_LIST_FIRST_ENTRY(
&node->u.ctf_expression.right,
struct ctf_node, siblings),
- &event_class->payload_ft);
+ &event_class->payload_fc);
if (ret) {
_BT_LOGE_NODE(node,
- "Cannot create event class's payload field type.");
+ "Cannot create event class's payload field class.");
goto error;
}
- BT_ASSERT(event_class->payload_ft);
+ BT_ASSERT(event_class->payload_fc);
_SET(set, _EVENT_FIELDS_SET);
} else if (!strcmp(left, "loglevel")) {
uint64_t loglevel_value;
static
int auto_map_field_to_trace_clock_class(struct ctx *ctx,
- struct ctf_field_type *ft)
+ struct ctf_field_class *fc)
{
struct bt_clock_class *clock_class_to_map_to = NULL;
- struct ctf_field_type_int *int_ft = (void *) ft;
+ struct ctf_field_class_int *int_fc = (void *) fc;
int ret = 0;
uint64_t clock_class_count;
- if (!ft) {
+ if (!fc) {
goto end;
}
- if (ft->id != CTF_FIELD_TYPE_ID_INT &&
- ft->id != CTF_FIELD_TYPE_ID_ENUM) {
+ if (fc->id != CTF_FIELD_CLASS_ID_INT &&
+ fc->id != CTF_FIELD_CLASS_ID_ENUM) {
goto end;
}
- if (int_ft->mapped_clock_class) {
+ if (int_fc->mapped_clock_class) {
/* Already mapped */
goto end;
}
}
BT_ASSERT(clock_class_to_map_to);
- int_ft->mapped_clock_class = bt_get(clock_class_to_map_to);
+ int_fc->mapped_clock_class = bt_get(clock_class_to_map_to);
end:
bt_put(clock_class_to_map_to);
static
int auto_map_fields_to_trace_clock_class(struct ctx *ctx,
- struct ctf_field_type *root_ft, const char *field_name)
+ struct ctf_field_class *root_fc, const char *field_name)
{
int ret = 0;
uint64_t i, count;
- struct ctf_field_type_struct *struct_ft = (void *) root_ft;
- struct ctf_field_type_variant *var_ft = (void *) root_ft;
+ struct ctf_field_class_struct *struct_fc = (void *) root_fc;
+ struct ctf_field_class_variant *var_fc = (void *) root_fc;
- if (!root_ft) {
+ if (!root_fc) {
goto end;
}
- if (root_ft->id != CTF_FIELD_TYPE_ID_STRUCT &&
- root_ft->id != CTF_FIELD_TYPE_ID_VARIANT) {
+ if (root_fc->id != CTF_FIELD_CLASS_ID_STRUCT &&
+ root_fc->id != CTF_FIELD_CLASS_ID_VARIANT) {
goto end;
}
- if (root_ft->id == CTF_FIELD_TYPE_ID_STRUCT) {
- count = struct_ft->members->len;
+ if (root_fc->id == CTF_FIELD_CLASS_ID_STRUCT) {
+ count = struct_fc->members->len;
} else {
- count = var_ft->options->len;
+ count = var_fc->options->len;
}
for (i = 0; i < count; i++) {
- struct ctf_named_field_type *named_ft = NULL;
+ struct ctf_named_field_class *named_fc = NULL;
- if (root_ft->id == CTF_FIELD_TYPE_ID_STRUCT) {
- named_ft = ctf_field_type_struct_borrow_member_by_index(
- struct_ft, i);
- } else if (root_ft->id == CTF_FIELD_TYPE_ID_VARIANT) {
- named_ft = ctf_field_type_variant_borrow_option_by_index(
- var_ft, i);
+ if (root_fc->id == CTF_FIELD_CLASS_ID_STRUCT) {
+ named_fc = ctf_field_class_struct_borrow_member_by_index(
+ struct_fc, i);
+ } else if (root_fc->id == CTF_FIELD_CLASS_ID_VARIANT) {
+ named_fc = ctf_field_class_variant_borrow_option_by_index(
+ var_fc, i);
}
- if (strcmp(named_ft->name->str, field_name) == 0) {
+ if (strcmp(named_fc->name->str, field_name) == 0) {
ret = auto_map_field_to_trace_clock_class(ctx,
- named_ft->ft);
+ named_fc->fc);
if (ret) {
BT_LOGE("Cannot automatically map field to trace's clock class: "
"field-name=\"%s\"", field_name);
}
}
- ret = auto_map_fields_to_trace_clock_class(ctx, named_ft->ft,
+ ret = auto_map_fields_to_trace_clock_class(ctx, named_fc->fc,
field_name);
if (ret) {
- BT_LOGE("Cannot automatically map structure or variant field type's fields to trace's clock class: "
+ BT_LOGE("Cannot automatically map structure or variant field class's fields to trace's clock class: "
"field-name=\"%s\", root-field-name=\"%s\"",
- field_name, named_ft->name->str);
+ field_name, named_fc->name->str);
goto end;
}
}
switch (node->type) {
case NODE_TYPEDEF:
- ret = visit_typedef(ctx, node->u._typedef.type_specifier_list,
- &node->u._typedef.type_declarators);
+ ret = visit_field_class_def(ctx, node->u.field_class_def.field_class_specifier_list,
+ &node->u.field_class_def.field_class_declarators);
if (ret) {
_BT_LOGE_NODE(node,
- "Cannot add type definition found in stream class.");
+ "Cannot add field class found in stream class.");
goto error;
}
break;
case NODE_TYPEALIAS:
- ret = visit_typealias(ctx, node->u.typealias.target,
- node->u.typealias.alias);
+ ret = visit_field_class_alias(ctx, node->u.field_class_alias.target,
+ node->u.field_class_alias.alias);
if (ret) {
_BT_LOGE_NODE(node,
- "Cannot add type alias found in stream class.");
+ "Cannot add field class alias found in stream class.");
goto error;
}
break;
goto error;
}
- ret = visit_type_specifier_list(ctx,
+ ret = visit_field_class_specifier_list(ctx,
_BT_LIST_FIRST_ENTRY(
&node->u.ctf_expression.right,
struct ctf_node, siblings),
- &stream_class->event_header_ft);
+ &stream_class->event_header_fc);
if (ret) {
_BT_LOGE_NODE(node,
- "Cannot create stream class's event header field type.");
+ "Cannot create stream class's event header field class.");
goto error;
}
- BT_ASSERT(stream_class->event_header_ft);
+ BT_ASSERT(stream_class->event_header_fc);
ret = auto_map_fields_to_trace_clock_class(ctx,
- stream_class->event_header_ft, "timestamp");
+ stream_class->event_header_fc, "timestamp");
if (ret) {
_BT_LOGE_NODE(node,
- "Cannot automatically map specific event header field type fields named `timestamp` to trace's clock class.");
+ "Cannot automatically map specific event header field class fields named `timestamp` to trace's clock class.");
goto error;
}
goto error;
}
- ret = visit_type_specifier_list(ctx,
+ ret = visit_field_class_specifier_list(ctx,
_BT_LIST_FIRST_ENTRY(
&node->u.ctf_expression.right,
struct ctf_node, siblings),
- &stream_class->event_common_context_ft);
+ &stream_class->event_common_context_fc);
if (ret) {
_BT_LOGE_NODE(node,
- "Cannot create stream class's event context field type.");
+ "Cannot create stream class's event context field class.");
goto error;
}
- BT_ASSERT(stream_class->event_common_context_ft);
+ BT_ASSERT(stream_class->event_common_context_fc);
_SET(set, _STREAM_EVENT_CONTEXT_SET);
} else if (!strcmp(left, "packet.context")) {
if (_IS_SET(set, _STREAM_PACKET_CONTEXT_SET)) {
goto error;
}
- ret = visit_type_specifier_list(ctx,
+ ret = visit_field_class_specifier_list(ctx,
_BT_LIST_FIRST_ENTRY(
&node->u.ctf_expression.right,
struct ctf_node, siblings),
- &stream_class->packet_context_ft);
+ &stream_class->packet_context_fc);
if (ret) {
_BT_LOGE_NODE(node,
- "Cannot create stream class's packet context field type.");
+ "Cannot create stream class's packet context field class.");
goto error;
}
- BT_ASSERT(stream_class->packet_context_ft);
+ BT_ASSERT(stream_class->packet_context_fc);
ret = auto_map_fields_to_trace_clock_class(ctx,
- stream_class->packet_context_ft,
+ stream_class->packet_context_fc,
"timestamp_begin");
if (ret) {
_BT_LOGE_NODE(node,
- "Cannot automatically map specific packet context field type fields named `timestamp_begin` to trace's clock class.");
+ "Cannot automatically map specific packet context field class fields named `timestamp_begin` to trace's clock class.");
goto error;
}
ret = auto_map_fields_to_trace_clock_class(ctx,
- stream_class->packet_context_ft,
+ stream_class->packet_context_fc,
"timestamp_end");
if (ret) {
_BT_LOGE_NODE(node,
- "Cannot automatically map specific packet context field type fields named `timestamp_end` to trace's clock class.");
+ "Cannot automatically map specific packet context field class fields named `timestamp_end` to trace's clock class.");
goto error;
}
if (_IS_SET(&set, _STREAM_ID_SET)) {
/* Check that packet header has `stream_id` field */
- struct ctf_named_field_type *named_ft = NULL;
+ struct ctf_named_field_class *named_fc = NULL;
- if (!ctx->ctf_tc->packet_header_ft) {
+ if (!ctx->ctf_tc->packet_header_fc) {
_BT_LOGE_NODE(node,
"Stream class has a `id` attribute, "
- "but trace has no packet header field type.");
+ "but trace has no packet header field class.");
goto error;
}
- named_ft = ctf_field_type_struct_borrow_member_by_name(
- (void *) ctx->ctf_tc->packet_header_ft, "stream_id");
- if (!named_ft) {
+ named_fc = ctf_field_class_struct_borrow_member_by_name(
+ (void *) ctx->ctf_tc->packet_header_fc, "stream_id");
+ if (!named_fc) {
_BT_LOGE_NODE(node,
"Stream class has a `id` attribute, "
- "but trace's packet header field type has no `stream_id` field.");
+ "but trace's packet header field class has no `stream_id` field.");
goto error;
}
- if (named_ft->ft->id != CTF_FIELD_TYPE_ID_INT &&
- named_ft->ft->id != CTF_FIELD_TYPE_ID_ENUM) {
+ if (named_fc->fc->id != CTF_FIELD_CLASS_ID_INT &&
+ named_fc->fc->id != CTF_FIELD_CLASS_ID_ENUM) {
_BT_LOGE_NODE(node,
"Stream class has a `id` attribute, "
- "but trace's packet header field type's `stream_id` field is not an integer field type.");
+ "but trace's packet header field class's `stream_id` field is not an integer field class.");
goto error;
}
} else {
switch (node->type) {
case NODE_TYPEDEF:
- ret = visit_typedef(ctx, node->u._typedef.type_specifier_list,
- &node->u._typedef.type_declarators);
+ ret = visit_field_class_def(ctx, node->u.field_class_def.field_class_specifier_list,
+ &node->u.field_class_def.field_class_declarators);
if (ret) {
_BT_LOGE_NODE(node,
- "Cannot add type definition found in trace (`trace` block).");
+ "Cannot add field class found in trace (`trace` block).");
goto error;
}
break;
case NODE_TYPEALIAS:
- ret = visit_typealias(ctx, node->u.typealias.target,
- node->u.typealias.alias);
+ ret = visit_field_class_alias(ctx, node->u.field_class_alias.target,
+ node->u.field_class_alias.alias);
if (ret) {
_BT_LOGE_NODE(node,
- "Cannot add type alias found in trace (`trace` block).");
+ "Cannot add field class alias found in trace (`trace` block).");
goto error;
}
break;
goto error;
}
- ret = visit_type_specifier_list(ctx,
+ ret = visit_field_class_specifier_list(ctx,
_BT_LIST_FIRST_ENTRY(
&node->u.ctf_expression.right,
struct ctf_node, siblings),
- &ctx->ctf_tc->packet_header_ft);
+ &ctx->ctf_tc->packet_header_fc);
if (ret) {
_BT_LOGE_NODE(node,
- "Cannot create trace's packet header field type.");
+ "Cannot create trace's packet header field class.");
goto error;
}
- BT_ASSERT(ctx->ctf_tc->packet_header_ft);
+ BT_ASSERT(ctx->ctf_tc->packet_header_fc);
_SET(set, _TRACE_PACKET_HEADER_SET);
} else {
_BT_LOGW_NODE(node,
switch (root_decl_node->type) {
case NODE_TYPEDEF:
- ret = visit_typedef(ctx,
- root_decl_node->u._typedef.type_specifier_list,
- &root_decl_node->u._typedef.type_declarators);
+ ret = visit_field_class_def(ctx,
+ root_decl_node->u.field_class_def.field_class_specifier_list,
+ &root_decl_node->u.field_class_def.field_class_declarators);
if (ret) {
_BT_LOGE_NODE(root_decl_node,
- "Cannot add type definition found in root scope.");
+ "Cannot add field class found in root scope.");
goto end;
}
break;
case NODE_TYPEALIAS:
- ret = visit_typealias(ctx, root_decl_node->u.typealias.target,
- root_decl_node->u.typealias.alias);
+ ret = visit_field_class_alias(ctx, root_decl_node->u.field_class_alias.target,
+ root_decl_node->u.field_class_alias.alias);
if (ret) {
_BT_LOGE_NODE(root_decl_node,
- "Cannot add type alias found in root scope.");
+ "Cannot add field class alias found in root scope.");
goto end;
}
break;
case NODE_TYPE_SPECIFIER_LIST:
{
- struct ctf_field_type *decl = NULL;
+ struct ctf_field_class *decl = NULL;
/*
- * Just add the type specifier to the root
+ * Just add the field class specifier to the root
* declaration scope. Put local reference.
*/
- ret = visit_type_specifier_list(ctx, root_decl_node, &decl);
+ ret = visit_field_class_specifier_list(ctx, root_decl_node, &decl);
if (ret) {
_BT_LOGE_NODE(root_decl_node,
- "Cannot visit root scope's field type: "
+ "Cannot visit root scope's field class: "
"ret=%d", ret);
BT_ASSERT(!decl);
goto end;
}
- ctf_field_type_destroy(decl);
+ ctf_field_class_destroy(decl);
decl = NULL;
break;
}
/*
* The first thing we need is the native byte order of
- * the trace block, because early type aliases can have
+ * the trace block, because early class aliases can have
* a `byte_order` attribute set to `native`. If we don't
* have the native byte order yet, and we don't have any
* trace block yet, then fail with EINCOMPLETE.
}
/* Resolve sequence lengths and variant tags */
- ret = ctf_trace_class_resolve_field_types(ctx->ctf_tc);
+ ret = ctf_trace_class_resolve_field_classes(ctx->ctf_tc);
if (ret) {
ret = -EINVAL;
goto end;
}
- /* Update "in IR" for field types */
+ /* Update "in IR" for field classes */
ret = ctf_trace_class_update_in_ir(ctx->ctf_tc);
if (ret) {
ret = -EINVAL;
{
int ret;
- switch (node->u.type_specifier.type) {
+ switch (node->u.field_class_specifier.type) {
case TYPESPEC_VOID:
case TYPESPEC_CHAR:
case TYPESPEC_SHORT:
case TYPESPEC_STRUCT:
case TYPESPEC_VARIANT:
case TYPESPEC_ENUM:
- node->u.type_specifier.node->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, node->u.type_specifier.node);
+ node->u.field_class_specifier.node->parent = node;
+ ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_specifier.node);
if (ret)
return ret;
break;
default:
_BT_LOGE_LINENO(node->lineno,
"Unknown type specifier: type=%d\n",
- node->u.type_specifier.type);
+ node->u.field_class_specifier.type);
return -EINVAL;
}
return 0;
}
static
-int ctf_visitor_type_declarator(int depth, struct ctf_node *node)
+int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node)
{
int ret = 0;
struct ctf_node *iter;
depth++;
- bt_list_for_each_entry(iter, &node->u.type_declarator.pointers,
+ bt_list_for_each_entry(iter, &node->u.field_class_declarator.pointers,
siblings) {
iter->parent = node;
ret = ctf_visitor_parent_links(depth + 1, iter);
return ret;
}
- switch (node->u.type_declarator.type) {
+ switch (node->u.field_class_declarator.type) {
case TYPEDEC_ID:
break;
case TYPEDEC_NESTED:
- if (node->u.type_declarator.u.nested.type_declarator) {
- node->u.type_declarator.u.nested.type_declarator->parent = node;
+ if (node->u.field_class_declarator.u.nested.field_class_declarator) {
+ node->u.field_class_declarator.u.nested.field_class_declarator->parent = node;
ret = ctf_visitor_parent_links(depth + 1,
- node->u.type_declarator.u.nested.type_declarator);
+ node->u.field_class_declarator.u.nested.field_class_declarator);
if (ret)
return ret;
}
- if (!node->u.type_declarator.u.nested.abstract_array) {
- bt_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
+ if (!node->u.field_class_declarator.u.nested.abstract_array) {
+ bt_list_for_each_entry(iter, &node->u.field_class_declarator.u.nested.length,
siblings) {
iter->parent = node;
ret = ctf_visitor_parent_links(depth + 1, iter);
return ret;
}
}
- if (node->u.type_declarator.bitfield_len) {
- node->u.type_declarator.bitfield_len = node;
+ if (node->u.field_class_declarator.bitfield_len) {
+ node->u.field_class_declarator.bitfield_len = node;
ret = ctf_visitor_parent_links(depth + 1,
- node->u.type_declarator.bitfield_len);
+ node->u.field_class_declarator.bitfield_len);
if (ret)
return ret;
}
default:
_BT_LOGE_LINENO(node->lineno,
"Unknown type declarator: type=%d\n",
- node->u.type_declarator.type);
+ node->u.field_class_declarator.type);
return -EINVAL;
}
depth--;
case NODE_TYPEDEF:
depth++;
- node->u._typedef.type_specifier_list->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, node->u._typedef.type_specifier_list);
+ node->u.field_class_def.field_class_specifier_list->parent = node;
+ ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_def.field_class_specifier_list);
if (ret)
return ret;
- bt_list_for_each_entry(iter, &node->u._typedef.type_declarators, siblings) {
+ bt_list_for_each_entry(iter, &node->u.field_class_def.field_class_declarators, siblings) {
iter->parent = node;
ret = ctf_visitor_parent_links(depth + 1, iter);
if (ret)
break;
case NODE_TYPEALIAS_TARGET:
depth++;
- node->u.typealias_target.type_specifier_list->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, node->u.typealias_target.type_specifier_list);
+ node->u.field_class_alias_target.field_class_specifier_list->parent = node;
+ ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_alias_target.field_class_specifier_list);
if (ret)
return ret;
- bt_list_for_each_entry(iter, &node->u.typealias_target.type_declarators, siblings) {
+ bt_list_for_each_entry(iter, &node->u.field_class_alias_target.field_class_declarators, siblings) {
iter->parent = node;
ret = ctf_visitor_parent_links(depth + 1, iter);
if (ret)
break;
case NODE_TYPEALIAS_ALIAS:
depth++;
- node->u.typealias_alias.type_specifier_list->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, node->u.typealias_alias.type_specifier_list);
+ node->u.field_class_alias_name.field_class_specifier_list->parent = node;
+ ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_alias_name.field_class_specifier_list);
if (ret)
return ret;
- bt_list_for_each_entry(iter, &node->u.typealias_alias.type_declarators, siblings) {
+ bt_list_for_each_entry(iter, &node->u.field_class_alias_name.field_class_declarators, siblings) {
iter->parent = node;
ret = ctf_visitor_parent_links(depth + 1, iter);
if (ret)
depth--;
break;
case NODE_TYPEALIAS:
- node->u.typealias.target->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, node->u.typealias.target);
+ node->u.field_class_alias.target->parent = node;
+ ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_alias.target);
if (ret)
return ret;
- node->u.typealias.alias->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, node->u.typealias.alias);
+ node->u.field_class_alias.alias->parent = node;
+ ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_alias.alias);
if (ret)
return ret;
break;
case NODE_TYPE_SPECIFIER_LIST:
- bt_list_for_each_entry(iter, &node->u.type_specifier_list.head, siblings) {
+ bt_list_for_each_entry(iter, &node->u.field_class_specifier_list.head, siblings) {
iter->parent = node;
ret = ctf_visitor_parent_links(depth + 1, iter);
if (ret)
case NODE_POINTER:
break;
case NODE_TYPE_DECLARATOR:
- ret = ctf_visitor_type_declarator(depth, node);
+ ret = ctf_visitor_field_class_declarator(depth, node);
if (ret)
return ret;
break;
break;
case NODE_ENUM:
depth++;
- if (node->u._enum.container_type) {
- ret = ctf_visitor_parent_links(depth + 1, node->u._enum.container_type);
+ if (node->u._enum.container_field_class) {
+ ret = ctf_visitor_parent_links(depth + 1, node->u._enum.container_field_class);
if (ret)
return ret;
}
depth--;
break;
case NODE_STRUCT_OR_VARIANT_DECLARATION:
- node->u.struct_or_variant_declaration.type_specifier_list->parent = node;
+ node->u.struct_or_variant_declaration.field_class_specifier_list->parent = node;
ret = ctf_visitor_parent_links(depth + 1,
- node->u.struct_or_variant_declaration.type_specifier_list);
+ node->u.struct_or_variant_declaration.field_class_specifier_list);
if (ret)
return ret;
- bt_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.type_declarators, siblings) {
+ bt_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.field_class_declarators, siblings) {
iter->parent = node;
ret = ctf_visitor_parent_links(depth + 1, iter);
if (ret)
break;
default:
_BT_LOGE_LINENO(node->lineno,
- "Children of type declarator and `enum` can only be unsigned numeric constants or references to fields (e.g., `a.b.c`).");
+ "Children of field class declarator and `enum` can only be unsigned numeric constants or references to fields (e.g., `a.b.c`).");
goto errperm;
}
break; /* OK */
}
static
-int ctf_visitor_type_specifier_list(int depth, struct ctf_node *node)
+int ctf_visitor_field_class_specifier_list(int depth, struct ctf_node *node)
{
switch (node->parent->type) {
case NODE_CTF_EXPRESSION:
}
static
-int ctf_visitor_type_specifier(int depth, struct ctf_node *node)
+int ctf_visitor_field_class_specifier(int depth, struct ctf_node *node)
{
switch (node->parent->type) {
case NODE_TYPE_SPECIFIER_LIST:
}
static
-int ctf_visitor_type_declarator(int depth, struct ctf_node *node)
+int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node)
{
int ret = 0;
struct ctf_node *iter;
switch (node->parent->type) {
case NODE_TYPE_DECLARATOR:
/*
- * A nested type declarator is not allowed to contain pointers.
+ * A nested field class declarator is not allowed to
+ * contain pointers.
*/
- if (!bt_list_empty(&node->u.type_declarator.pointers))
+ if (!bt_list_empty(&node->u.field_class_declarator.pointers))
goto errperm;
break; /* OK */
case NODE_TYPEALIAS_TARGET:
* NOT accepting alias names containing [] (would otherwise
* cause semantic clash for later declarations of
* arrays/sequences of elements, where elements could be
- * arrays/sequences themselves (if allowed in typealias).
+ * arrays/sequences themselves (if allowed in field class alias).
* NOT accepting alias with identifier. The declarator should
* be either empty or contain pointer(s).
*/
- if (node->u.type_declarator.type == TYPEDEC_NESTED)
+ if (node->u.field_class_declarator.type == TYPEDEC_NESTED)
goto errperm;
- bt_list_for_each_entry(iter, &node->parent->u.typealias_alias.type_specifier_list->u.type_specifier_list.head,
+ bt_list_for_each_entry(iter, &node->parent->u.field_class_alias_name.field_class_specifier_list->u.field_class_specifier_list.head,
siblings) {
- switch (iter->u.type_specifier.type) {
+ switch (iter->u.field_class_specifier.type) {
case TYPESPEC_FLOATING_POINT:
case TYPESPEC_INTEGER:
case TYPESPEC_STRING:
case TYPESPEC_STRUCT:
case TYPESPEC_VARIANT:
case TYPESPEC_ENUM:
- if (bt_list_empty(&node->u.type_declarator.pointers))
+ if (bt_list_empty(&node->u.field_class_declarator.pointers))
goto errperm;
break;
default:
break;
}
}
- if (node->u.type_declarator.type == TYPEDEC_ID &&
- node->u.type_declarator.u.id != NULL)
+ if (node->u.field_class_declarator.type == TYPEDEC_ID &&
+ node->u.field_class_declarator.u.id != NULL)
goto errperm;
break; /* OK */
case NODE_TYPEDEF:
goto errinval;
}
- bt_list_for_each_entry(iter, &node->u.type_declarator.pointers,
+ bt_list_for_each_entry(iter, &node->u.field_class_declarator.pointers,
siblings) {
ret = _ctf_visitor_semantic_check(depth + 1, iter);
if (ret)
return ret;
}
- switch (node->u.type_declarator.type) {
+ switch (node->u.field_class_declarator.type) {
case TYPEDEC_ID:
break;
case TYPEDEC_NESTED:
{
- if (node->u.type_declarator.u.nested.type_declarator) {
+ if (node->u.field_class_declarator.u.nested.field_class_declarator) {
ret = _ctf_visitor_semantic_check(depth + 1,
- node->u.type_declarator.u.nested.type_declarator);
+ node->u.field_class_declarator.u.nested.field_class_declarator);
if (ret)
return ret;
}
- if (!node->u.type_declarator.u.nested.abstract_array) {
- bt_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
+ if (!node->u.field_class_declarator.u.nested.abstract_array) {
+ bt_list_for_each_entry(iter, &node->u.field_class_declarator.u.nested.length,
siblings) {
if (iter->type != NODE_UNARY_EXPRESSION) {
_BT_LOGE_LINENO(node->lineno,
} else {
if (node->parent->type == NODE_TYPEALIAS_TARGET) {
_BT_LOGE_LINENO(node->lineno,
- "Abstract array declarator not permitted as target of type alias.");
+ "Abstract array declarator not permitted as target of field class alias.");
return -EINVAL;
}
}
- if (node->u.type_declarator.bitfield_len) {
+ if (node->u.field_class_declarator.bitfield_len) {
ret = _ctf_visitor_semantic_check(depth + 1,
- node->u.type_declarator.bitfield_len);
+ node->u.field_class_declarator.bitfield_len);
if (ret)
return ret;
}
case TYPEDEC_UNKNOWN:
default:
_BT_LOGE_LINENO(node->lineno,
- "Unknown type declarator: type=%d",
- node->u.type_declarator.type);
+ "Unknown field class declarator: type=%d",
+ node->u.field_class_declarator.type);
return -EINVAL;
}
depth--;
depth++;
ret = _ctf_visitor_semantic_check(depth + 1,
- node->u._typedef.type_specifier_list);
+ node->u.field_class_def.field_class_specifier_list);
if (ret)
return ret;
- bt_list_for_each_entry(iter, &node->u._typedef.type_declarators, siblings) {
+ bt_list_for_each_entry(iter, &node->u.field_class_def.field_class_declarators, siblings) {
ret = _ctf_visitor_semantic_check(depth + 1, iter);
if (ret)
return ret;
depth++;
ret = _ctf_visitor_semantic_check(depth + 1,
- node->u.typealias_target.type_specifier_list);
+ node->u.field_class_alias_target.field_class_specifier_list);
if (ret)
return ret;
nr_declarators = 0;
- bt_list_for_each_entry(iter, &node->u.typealias_target.type_declarators, siblings) {
+ bt_list_for_each_entry(iter, &node->u.field_class_alias_target.field_class_declarators, siblings) {
ret = _ctf_visitor_semantic_check(depth + 1, iter);
if (ret)
return ret;
}
if (nr_declarators > 1) {
_BT_LOGE_LINENO(node->lineno,
- "Too many declarators in type alias's name (maximum is 1): count=%d",
+ "Too many declarators in field class alias's name (maximum is 1): count=%d",
nr_declarators);
return -EINVAL;
}
depth++;
ret = _ctf_visitor_semantic_check(depth + 1,
- node->u.typealias_alias.type_specifier_list);
+ node->u.field_class_alias_name.field_class_specifier_list);
if (ret)
return ret;
nr_declarators = 0;
- bt_list_for_each_entry(iter, &node->u.typealias_alias.type_declarators, siblings) {
+ bt_list_for_each_entry(iter, &node->u.field_class_alias_name.field_class_declarators, siblings) {
ret = _ctf_visitor_semantic_check(depth + 1, iter);
if (ret)
return ret;
}
if (nr_declarators > 1) {
_BT_LOGE_LINENO(node->lineno,
- "Too many declarators in type alias's name (maximum is 1): count=%d",
+ "Too many declarators in field class alias's name (maximum is 1): count=%d",
nr_declarators);
return -EINVAL;
}
goto errinval;
}
- ret = _ctf_visitor_semantic_check(depth + 1, node->u.typealias.target);
+ ret = _ctf_visitor_semantic_check(depth + 1, node->u.field_class_alias.target);
if (ret)
return ret;
- ret = _ctf_visitor_semantic_check(depth + 1, node->u.typealias.alias);
+ ret = _ctf_visitor_semantic_check(depth + 1, node->u.field_class_alias.alias);
if (ret)
return ret;
break;
case NODE_TYPE_SPECIFIER_LIST:
- ret = ctf_visitor_type_specifier_list(depth, node);
+ ret = ctf_visitor_field_class_specifier_list(depth, node);
if (ret)
return ret;
break;
case NODE_TYPE_SPECIFIER:
- ret = ctf_visitor_type_specifier(depth, node);
+ ret = ctf_visitor_field_class_specifier(depth, node);
if (ret)
return ret;
break;
}
break;
case NODE_TYPE_DECLARATOR:
- ret = ctf_visitor_type_declarator(depth, node);
+ ret = ctf_visitor_field_class_declarator(depth, node);
if (ret)
return ret;
break;
}
depth++;
- ret = _ctf_visitor_semantic_check(depth + 1, node->u._enum.container_type);
+ ret = _ctf_visitor_semantic_check(depth + 1, node->u._enum.container_field_class);
if (ret)
return ret;
goto errinval;
}
ret = _ctf_visitor_semantic_check(depth + 1,
- node->u.struct_or_variant_declaration.type_specifier_list);
+ node->u.struct_or_variant_declaration.field_class_specifier_list);
if (ret)
return ret;
- bt_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.type_declarators, siblings) {
+ bt_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.field_class_declarators, siblings) {
ret = _ctf_visitor_semantic_check(depth + 1, iter);
if (ret)
return ret;
#include <stdlib.h>
#include "notif-iter.h"
-#include "../btr/btr.h"
+#include "../bfcr/bfcr.h"
struct bt_notif_iter;
} buf;
/* Binary type reader */
- struct bt_btr *btr;
+ struct bt_bfcr *bfcr;
/* Current medium data */
struct {
static
enum bt_notif_iter_status read_dscope_begin_state(
struct bt_notif_iter *notit,
- struct ctf_field_type *dscope_ft,
+ struct ctf_field_class *dscope_fc,
enum state done_state, enum state continue_state,
struct bt_field *dscope_field)
{
enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK;
- enum bt_btr_status btr_status;
+ enum bt_bfcr_status bfcr_status;
size_t consumed_bits;
notit->cur_dscope_field = dscope_field;
- BT_LOGV("Starting BTR: notit-addr=%p, btr-addr=%p, ft-addr=%p",
- notit, notit->btr, dscope_ft);
- consumed_bits = bt_btr_start(notit->btr, dscope_ft,
+ BT_LOGV("Starting BFCR: notit-addr=%p, bfcr-addr=%p, fc-addr=%p",
+ notit, notit->bfcr, dscope_fc);
+ consumed_bits = bt_bfcr_start(notit->bfcr, dscope_fc,
notit->buf.addr, notit->buf.at, packet_at(notit),
- notit->buf.sz, &btr_status);
- BT_LOGV("BTR consumed bits: size=%zu", consumed_bits);
+ notit->buf.sz, &bfcr_status);
+ BT_LOGV("BFCR consumed bits: size=%zu", consumed_bits);
- switch (btr_status) {
- case BT_BTR_STATUS_OK:
- /* type was read completely */
+ switch (bfcr_status) {
+ case BT_BFCR_STATUS_OK:
+ /* Field class was read completely */
BT_LOGV_STR("Field was completely decoded.");
notit->state = done_state;
break;
- case BT_BTR_STATUS_EOF:
- BT_LOGV_STR("BTR needs more data to decode field completely.");
+ case BT_BFCR_STATUS_EOF:
+ BT_LOGV_STR("BFCR needs more data to decode field completely.");
notit->state = continue_state;
break;
default:
- BT_LOGW("BTR failed to start: notit-addr=%p, btr-addr=%p, "
- "status=%s", notit, notit->btr,
- bt_btr_status_string(btr_status));
+ BT_LOGW("BFCR failed to start: notit-addr=%p, bfcr-addr=%p, "
+ "status=%s", notit, notit->bfcr,
+ bt_bfcr_status_string(bfcr_status));
status = BT_NOTIF_ITER_STATUS_ERROR;
goto end;
}
struct bt_notif_iter *notit, enum state done_state)
{
enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK;
- enum bt_btr_status btr_status;
+ enum bt_bfcr_status bfcr_status;
size_t consumed_bits;
- BT_LOGV("Continuing BTR: notit-addr=%p, btr-addr=%p",
- notit, notit->btr);
+ BT_LOGV("Continuing BFCR: notit-addr=%p, bfcr-addr=%p",
+ notit, notit->bfcr);
status = buf_ensure_available_bits(notit);
if (status != BT_NOTIF_ITER_STATUS_OK) {
goto end;
}
- consumed_bits = bt_btr_continue(notit->btr, notit->buf.addr,
- notit->buf.sz, &btr_status);
- BT_LOGV("BTR consumed bits: size=%zu", consumed_bits);
+ consumed_bits = bt_bfcr_continue(notit->bfcr, notit->buf.addr,
+ notit->buf.sz, &bfcr_status);
+ BT_LOGV("BFCR consumed bits: size=%zu", consumed_bits);
- switch (btr_status) {
- case BT_BTR_STATUS_OK:
+ switch (bfcr_status) {
+ case BT_BFCR_STATUS_OK:
/* Type was read completely. */
BT_LOGV_STR("Field was completely decoded.");
notit->state = done_state;
break;
- case BT_BTR_STATUS_EOF:
+ case BT_BFCR_STATUS_EOF:
/* Stay in this continue state. */
- BT_LOGV_STR("BTR needs more data to decode field completely.");
+ BT_LOGV_STR("BFCR needs more data to decode field completely.");
break;
default:
- BT_LOGW("BTR failed to continue: notit-addr=%p, btr-addr=%p, "
- "status=%s", notit, notit->btr,
- bt_btr_status_string(btr_status));
+ BT_LOGW("BFCR failed to continue: notit-addr=%p, bfcr-addr=%p, "
+ "status=%s", notit, notit->bfcr,
+ bt_bfcr_status_string(bfcr_status));
status = BT_NOTIF_ITER_STATUS_ERROR;
goto end;
}
enum bt_notif_iter_status read_packet_header_begin_state(
struct bt_notif_iter *notit)
{
- struct ctf_field_type *packet_header_ft = NULL;
+ struct ctf_field_class *packet_header_fc = NULL;
enum bt_notif_iter_status ret = BT_NOTIF_ITER_STATUS_OK;
if (bt_notif_iter_switch_packet(notit)) {
goto end;
}
- /* Packet header type is common to the whole trace. */
- packet_header_ft = notit->meta.tc->packet_header_ft;
- if (!packet_header_ft) {
+ /* Packet header class is common to the whole trace. */
+ packet_header_fc = notit->meta.tc->packet_header_fc;
+ if (!packet_header_fc) {
notit->state = STATE_AFTER_TRACE_PACKET_HEADER;
goto end;
}
BT_ASSERT(!notit->packet_header_field);
- if (packet_header_ft->in_ir) {
+ if (packet_header_fc->in_ir) {
/*
* Create free packet header field from trace. This
* field is going to be moved to the packet once we
notit->cur_event_class_id = -1;
notit->cur_data_stream_id = -1;
BT_LOGV("Decoding packet header field:"
- "notit-addr=%p, trace-addr=%p, trace-name=\"%s\", ft-addr=%p",
+ "notit-addr=%p, trace-addr=%p, trace-name=\"%s\", fc-addr=%p",
notit, notit->meta.tc,
- notit->meta.tc->name->str, packet_header_ft);
- ret = read_dscope_begin_state(notit, packet_header_ft,
+ notit->meta.tc->name->str, 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);
if (ret < 0) {
BT_LOGW("Cannot decode packet header field: "
"notit-addr=%p, trace-addr=%p, "
- "trace-name=\"%s\", ft-addr=%p",
+ "trace-name=\"%s\", fc-addr=%p",
notit, notit->meta.tc,
notit->meta.tc->name->str,
- packet_header_ft);
+ packet_header_fc);
}
end:
struct bt_notif_iter *notit)
{
enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK;
- struct ctf_field_type *packet_context_ft;
+ struct ctf_field_class *packet_context_fc;
BT_ASSERT(notit->meta.sc);
- packet_context_ft = notit->meta.sc->packet_context_ft;
- if (!packet_context_ft) {
- BT_LOGV("No packet packet context field type in stream class: continuing: "
+ packet_context_fc = notit->meta.sc->packet_context_fc;
+ if (!packet_context_fc) {
+ BT_LOGV("No packet packet context field class in stream class: continuing: "
"notit-addr=%p, stream-class-addr=%p, "
"stream-class-id=%" PRId64,
notit, notit->meta.sc,
BT_ASSERT(!notit->packet_context_field);
- if (packet_context_ft->in_ir) {
+ if (packet_context_fc->in_ir) {
/*
* Create free packet context field from stream class.
* This field is going to be moved to the packet once we
BT_LOGV("Decoding packet context field: "
"notit-addr=%p, stream-class-addr=%p, "
- "stream-class-id=%" PRId64 ", ft-addr=%p",
+ "stream-class-id=%" PRId64 ", fc-addr=%p",
notit, notit->meta.sc,
- notit->meta.sc->id, packet_context_ft);
- status = read_dscope_begin_state(notit, packet_context_ft,
+ notit->meta.sc->id, packet_context_fc);
+ status = read_dscope_begin_state(notit, packet_context_fc,
STATE_AFTER_STREAM_PACKET_CONTEXT,
STATE_DSCOPE_STREAM_PACKET_CONTEXT_CONTINUE,
notit->dscopes.stream_packet_context);
if (status < 0) {
BT_LOGW("Cannot decode packet context field: "
"notit-addr=%p, stream-class-addr=%p, "
- "stream-class-id=%" PRId64 ", ft-addr=%p",
+ "stream-class-id=%" PRId64 ", fc-addr=%p",
notit, notit->meta.sc,
notit->meta.sc->id,
- packet_context_ft);
+ packet_context_fc);
}
end:
struct bt_notif_iter *notit)
{
enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK;
- struct ctf_field_type *event_header_ft = NULL;
+ struct ctf_field_class *event_header_fc = NULL;
/* Reset the position of the last event header */
notit->buf.last_eh_at = notit->buf.at;
release_event_dscopes(notit);
BT_ASSERT(notit->meta.sc);
- event_header_ft = notit->meta.sc->event_header_ft;
- if (!event_header_ft) {
+ event_header_fc = notit->meta.sc->event_header_fc;
+ if (!event_header_fc) {
notit->state = STATE_AFTER_EVENT_HEADER;
goto end;
}
- if (event_header_ft->in_ir) {
+ 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);
BT_LOGV("Decoding event header field: "
"notit-addr=%p, stream-class-addr=%p, "
"stream-class-id=%" PRId64 ", "
- "ft-addr=%p",
+ "fc-addr=%p",
notit, notit->meta.sc,
notit->meta.sc->id,
- event_header_ft);
- status = read_dscope_begin_state(notit, event_header_ft,
+ 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);
if (status < 0) {
BT_LOGW("Cannot decode event header field: "
"notit-addr=%p, stream-class-addr=%p, "
- "stream-class-id=%" PRId64 ", ft-addr=%p",
+ "stream-class-id=%" PRId64 ", fc-addr=%p",
notit, notit->meta.sc,
notit->meta.sc->id,
- event_header_ft);
+ event_header_fc);
}
end:
struct bt_notif_iter *notit)
{
enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK;
- struct ctf_field_type *event_common_context_ft;
+ struct ctf_field_class *event_common_context_fc;
- event_common_context_ft = notit->meta.sc->event_common_context_ft;
- if (!event_common_context_ft) {
+ event_common_context_fc = notit->meta.sc->event_common_context_fc;
+ if (!event_common_context_fc) {
notit->state = STATE_DSCOPE_EVENT_SPEC_CONTEXT_BEGIN;
goto end;
}
- if (event_common_context_ft->in_ir) {
+ if (event_common_context_fc->in_ir) {
BT_ASSERT(!notit->dscopes.event_common_context);
notit->dscopes.event_common_context =
bt_event_borrow_common_context_field(notit->event);
BT_LOGV("Decoding event common context field: "
"notit-addr=%p, stream-class-addr=%p, "
"stream-class-id=%" PRId64 ", "
- "ft-addr=%p",
+ "fc-addr=%p",
notit, notit->meta.sc,
notit->meta.sc->id,
- event_common_context_ft);
- status = read_dscope_begin_state(notit, event_common_context_ft,
+ event_common_context_fc);
+ status = read_dscope_begin_state(notit, event_common_context_fc,
STATE_DSCOPE_EVENT_SPEC_CONTEXT_BEGIN,
STATE_DSCOPE_EVENT_COMMON_CONTEXT_CONTINUE,
notit->dscopes.event_common_context);
if (status < 0) {
BT_LOGW("Cannot decode event common context field: "
"notit-addr=%p, stream-class-addr=%p, "
- "stream-class-id=%" PRId64 ", ft-addr=%p",
+ "stream-class-id=%" PRId64 ", fc-addr=%p",
notit, notit->meta.sc,
notit->meta.sc->id,
- event_common_context_ft);
+ event_common_context_fc);
}
end:
struct bt_notif_iter *notit)
{
enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK;
- struct ctf_field_type *event_spec_context_ft;
+ struct ctf_field_class *event_spec_context_fc;
- event_spec_context_ft = notit->meta.ec->spec_context_ft;
- if (!event_spec_context_ft) {
+ event_spec_context_fc = notit->meta.ec->spec_context_fc;
+ if (!event_spec_context_fc) {
notit->state = STATE_DSCOPE_EVENT_PAYLOAD_BEGIN;
goto end;
}
- if (event_spec_context_ft->in_ir) {
+ if (event_spec_context_fc->in_ir) {
BT_ASSERT(!notit->dscopes.event_spec_context);
notit->dscopes.event_spec_context = bt_event_borrow_specific_context_field(
notit->event);
BT_LOGV("Decoding event specific context field: "
"notit-addr=%p, event-class-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64 ", "
- "ft-addr=%p",
+ "fc-addr=%p",
notit, notit->meta.ec,
notit->meta.ec->name->str,
notit->meta.ec->id,
- event_spec_context_ft);
- status = read_dscope_begin_state(notit, event_spec_context_ft,
+ event_spec_context_fc);
+ status = read_dscope_begin_state(notit, event_spec_context_fc,
STATE_DSCOPE_EVENT_PAYLOAD_BEGIN,
STATE_DSCOPE_EVENT_SPEC_CONTEXT_CONTINUE,
notit->dscopes.event_spec_context);
BT_LOGW("Cannot decode event specific context field: "
"notit-addr=%p, event-class-addr=%p, "
"event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", ft-addr=%p",
+ "event-class-id=%" PRId64 ", fc-addr=%p",
notit, notit->meta.ec,
notit->meta.ec->name->str,
notit->meta.ec->id,
- event_spec_context_ft);
+ event_spec_context_fc);
}
end:
struct bt_notif_iter *notit)
{
enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK;
- struct ctf_field_type *event_payload_ft;
+ struct ctf_field_class *event_payload_fc;
- event_payload_ft = notit->meta.ec->payload_ft;
- if (!event_payload_ft) {
+ event_payload_fc = notit->meta.ec->payload_fc;
+ if (!event_payload_fc) {
notit->state = STATE_EMIT_NOTIF_EVENT;
goto end;
}
- if (event_payload_ft->in_ir) {
+ if (event_payload_fc->in_ir) {
BT_ASSERT(!notit->dscopes.event_payload);
notit->dscopes.event_payload = bt_event_borrow_payload_field(
notit->event);
BT_LOGV("Decoding event payload field: "
"notit-addr=%p, event-class-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64 ", "
- "ft-addr=%p",
+ "fc-addr=%p",
notit, notit->meta.ec,
notit->meta.ec->name->str,
notit->meta.ec->id,
- event_payload_ft);
- status = read_dscope_begin_state(notit, event_payload_ft,
+ event_payload_fc);
+ status = read_dscope_begin_state(notit, event_payload_fc,
STATE_EMIT_NOTIF_EVENT,
STATE_DSCOPE_EVENT_PAYLOAD_CONTINUE,
notit->dscopes.event_payload);
BT_LOGW("Cannot decode event payload field: "
"notit-addr=%p, event-class-addr=%p, "
"event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", ft-addr=%p",
+ "event-class-id=%" PRId64 ", fc-addr=%p",
notit, notit->meta.ec,
notit->meta.ec->name->str,
notit->meta.ec->id,
- event_payload_ft);
+ event_payload_fc);
}
end:
{
struct bt_field *next_field = NULL;
struct bt_field *base_field;
- struct bt_field_type *base_ft;
+ struct bt_field_class *base_fc;
size_t index;
BT_ASSERT(!stack_empty(notit->stack));
index = stack_top(notit->stack)->index;
base_field = stack_top(notit->stack)->base;
BT_ASSERT(base_field);
- base_ft = bt_field_borrow_type(base_field);
- BT_ASSERT(base_ft);
+ base_fc = bt_field_borrow_class(base_field);
+ BT_ASSERT(base_fc);
- switch (bt_field_type_get_type_id(base_ft)) {
- case BT_FIELD_TYPE_ID_STRUCTURE:
+ switch (bt_field_class_get_id(base_fc)) {
+ case BT_FIELD_CLASS_ID_STRUCTURE:
{
BT_ASSERT(index <
- bt_field_type_structure_get_member_count(
- bt_field_borrow_type(base_field)));
+ bt_field_class_structure_get_member_count(
+ bt_field_borrow_class(base_field)));
next_field = bt_field_structure_borrow_member_field_by_index(
base_field, index);
break;
}
- case BT_FIELD_TYPE_ID_STATIC_ARRAY:
- case BT_FIELD_TYPE_ID_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_ID_STATIC_ARRAY:
+ case BT_FIELD_CLASS_ID_DYNAMIC_ARRAY:
BT_ASSERT(index < bt_field_array_get_length(base_field));
next_field = bt_field_array_borrow_element_field_by_index(
base_field, index);
break;
- case BT_FIELD_TYPE_ID_VARIANT:
+ case BT_FIELD_CLASS_ID_VARIANT:
BT_ASSERT(index == 0);
next_field = bt_field_variant_borrow_selected_option_field(
base_field);
}
static
-enum bt_btr_status btr_unsigned_int_cb(uint64_t value,
- struct ctf_field_type *ft, void *data)
+enum bt_bfcr_status bfcr_unsigned_int_cb(uint64_t value,
+ struct ctf_field_class *fc, void *data)
{
struct bt_notif_iter *notit = data;
- enum bt_btr_status status = BT_BTR_STATUS_OK;
+ enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
struct bt_field *field = NULL;
- struct ctf_field_type_int *int_ft = (void *) ft;
+ struct ctf_field_class_int *int_fc = (void *) fc;
- BT_LOGV("Unsigned integer function called from BTR: "
- "notit-addr=%p, btr-addr=%p, ft-addr=%p, "
- "ft-id=%d, ft-in-ir=%d, value=%" PRIu64,
- notit, notit->btr, ft, ft->id, ft->in_ir, value);
+ BT_LOGV("Unsigned integer function called from BFCR: "
+ "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
+ "fc-id=%d, fc-in-ir=%d, value=%" PRIu64,
+ notit, notit->bfcr, fc, fc->id, fc->in_ir, value);
- if (likely(int_ft->meaning == CTF_FIELD_TYPE_MEANING_NONE)) {
+ if (likely(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE)) {
goto update_def_clock;
}
- switch (int_ft->meaning) {
- case CTF_FIELD_TYPE_MEANING_EVENT_CLASS_ID:
+ switch (int_fc->meaning) {
+ case CTF_FIELD_CLASS_MEANING_EVENT_CLASS_ID:
notit->cur_event_class_id = value;
break;
- case CTF_FIELD_TYPE_MEANING_DATA_STREAM_ID:
+ case CTF_FIELD_CLASS_MEANING_DATA_STREAM_ID:
notit->cur_data_stream_id = value;
break;
- case CTF_FIELD_TYPE_MEANING_PACKET_BEGINNING_TIME:
+ case CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME:
notit->snapshots.beginning_clock = value;
break;
- case CTF_FIELD_TYPE_MEANING_PACKET_END_TIME:
+ case CTF_FIELD_CLASS_MEANING_PACKET_END_TIME:
notit->snapshots.end_clock = value;
break;
- case CTF_FIELD_TYPE_MEANING_STREAM_CLASS_ID:
+ case CTF_FIELD_CLASS_MEANING_STREAM_CLASS_ID:
notit->cur_stream_class_id = value;
break;
- case CTF_FIELD_TYPE_MEANING_MAGIC:
+ case CTF_FIELD_CLASS_MEANING_MAGIC:
if (value != 0xc1fc1fc1) {
BT_LOGW("Invalid CTF magic number: notit-addr=%p, "
"magic=%" PRIx64, notit, value);
- status = BT_BTR_STATUS_ERROR;
+ status = BT_BFCR_STATUS_ERROR;
goto end;
}
break;
- case CTF_FIELD_TYPE_MEANING_PACKET_COUNTER_SNAPSHOT:
+ case CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT:
notit->snapshots.packets = value;
break;
- case CTF_FIELD_TYPE_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT:
+ case CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT:
notit->snapshots.discarded_events = value;
break;
- case CTF_FIELD_TYPE_MEANING_EXP_PACKET_TOTAL_SIZE:
+ case CTF_FIELD_CLASS_MEANING_EXP_PACKET_TOTAL_SIZE:
notit->cur_exp_packet_total_size = value;
break;
- case CTF_FIELD_TYPE_MEANING_EXP_PACKET_CONTENT_SIZE:
+ case CTF_FIELD_CLASS_MEANING_EXP_PACKET_CONTENT_SIZE:
notit->cur_exp_packet_content_size = value;
break;
default:
}
update_def_clock:
- if (unlikely(int_ft->mapped_clock_class)) {
- update_default_clock(notit, value, int_ft->base.size);
+ if (unlikely(int_fc->mapped_clock_class)) {
+ update_default_clock(notit, value, int_fc->base.size);
}
- if (unlikely(int_ft->storing_index >= 0)) {
+ if (unlikely(int_fc->storing_index >= 0)) {
g_array_index(notit->stored_values, uint64_t,
- (uint64_t) int_ft->storing_index) = value;
+ (uint64_t) int_fc->storing_index) = value;
}
- if (unlikely(!ft->in_ir)) {
+ if (unlikely(!fc->in_ir)) {
goto end;
}
field = borrow_next_field(notit);
BT_ASSERT(field);
- BT_ASSERT(bt_field_borrow_type(field) == ft->ir_ft);
- BT_ASSERT(bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_UNSIGNED_INTEGER ||
- bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION);
+ BT_ASSERT(bt_field_borrow_class(field) == fc->ir_fc);
+ BT_ASSERT(bt_field_get_class_id(field) == BT_FIELD_CLASS_ID_UNSIGNED_INTEGER ||
+ bt_field_get_class_id(field) == BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION);
bt_field_unsigned_integer_set_value(field, value);
stack_top(notit->stack)->index++;
}
static
-enum bt_btr_status btr_unsigned_int_char_cb(uint64_t value,
- struct ctf_field_type *ft, void *data)
+enum bt_bfcr_status bfcr_unsigned_int_char_cb(uint64_t value,
+ struct ctf_field_class *fc, void *data)
{
int ret;
struct bt_notif_iter *notit = data;
- enum bt_btr_status status = BT_BTR_STATUS_OK;
+ enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
struct bt_field *string_field = NULL;
- struct ctf_field_type_int *int_ft = (void *) ft;
+ struct ctf_field_class_int *int_fc = (void *) fc;
char str[2] = {'\0', '\0'};
- BT_LOGV("Unsigned integer character function called from BTR: "
- "notit-addr=%p, btr-addr=%p, ft-addr=%p, "
- "ft-id=%d, ft-in-ir=%d, value=%" PRIu64,
- notit, notit->btr, ft, ft->id, ft->in_ir, value);
- BT_ASSERT(int_ft->meaning == CTF_FIELD_TYPE_MEANING_NONE);
- BT_ASSERT(!int_ft->mapped_clock_class);
- BT_ASSERT(int_ft->storing_index < 0);
+ BT_LOGV("Unsigned integer character function called from BFCR: "
+ "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
+ "fc-id=%d, fc-in-ir=%d, value=%" PRIu64,
+ notit, notit->bfcr, fc, fc->id, fc->in_ir, value);
+ BT_ASSERT(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE);
+ BT_ASSERT(!int_fc->mapped_clock_class);
+ BT_ASSERT(int_fc->storing_index < 0);
- if (unlikely(!ft->in_ir)) {
+ if (unlikely(!fc->in_ir)) {
goto end;
}
}
string_field = stack_top(notit->stack)->base;
- BT_ASSERT(bt_field_get_type_id(string_field) == BT_FIELD_TYPE_ID_STRING);
+ BT_ASSERT(bt_field_get_class_id(string_field) == BT_FIELD_CLASS_ID_STRING);
/* Append character */
str[0] = (char) value;
BT_LOGE("Cannot append character to string field's value: "
"notit-addr=%p, field-addr=%p, ret=%d",
notit, string_field, ret);
- status = BT_BTR_STATUS_ERROR;
+ status = BT_BFCR_STATUS_ERROR;
goto end;
}
}
static
-enum bt_btr_status btr_signed_int_cb(int64_t value,
- struct ctf_field_type *ft, void *data)
+enum bt_bfcr_status bfcr_signed_int_cb(int64_t value,
+ struct ctf_field_class *fc, void *data)
{
- enum bt_btr_status status = BT_BTR_STATUS_OK;
+ enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
struct bt_field *field = NULL;
struct bt_notif_iter *notit = data;
- struct ctf_field_type_int *int_ft = (void *) ft;
+ struct ctf_field_class_int *int_fc = (void *) fc;
- BT_LOGV("Signed integer function called from BTR: "
- "notit-addr=%p, btr-addr=%p, ft-addr=%p, "
- "ft-id=%d, ft-in-ir=%d, value=%" PRId64,
- notit, notit->btr, ft, ft->id, ft->in_ir, value);
- BT_ASSERT(int_ft->meaning == CTF_FIELD_TYPE_MEANING_NONE);
+ BT_LOGV("Signed integer function called from BFCR: "
+ "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
+ "fc-id=%d, fc-in-ir=%d, value=%" PRId64,
+ notit, notit->bfcr, fc, fc->id, fc->in_ir, value);
+ BT_ASSERT(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE);
- if (unlikely(int_ft->storing_index >= 0)) {
+ if (unlikely(int_fc->storing_index >= 0)) {
g_array_index(notit->stored_values, uint64_t,
- (uint64_t) int_ft->storing_index) = (uint64_t) value;
+ (uint64_t) int_fc->storing_index) = (uint64_t) value;
}
- if (unlikely(!ft->in_ir)) {
+ if (unlikely(!fc->in_ir)) {
goto end;
}
field = borrow_next_field(notit);
BT_ASSERT(field);
- BT_ASSERT(bt_field_borrow_type(field) == ft->ir_ft);
- BT_ASSERT(bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_SIGNED_INTEGER ||
- bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_SIGNED_ENUMERATION);
+ BT_ASSERT(bt_field_borrow_class(field) == fc->ir_fc);
+ BT_ASSERT(bt_field_get_class_id(field) == BT_FIELD_CLASS_ID_SIGNED_INTEGER ||
+ bt_field_get_class_id(field) == BT_FIELD_CLASS_ID_SIGNED_ENUMERATION);
bt_field_signed_integer_set_value(field, value);
stack_top(notit->stack)->index++;
}
static
-enum bt_btr_status btr_floating_point_cb(double value,
- struct ctf_field_type *ft, void *data)
+enum bt_bfcr_status bfcr_floating_point_cb(double value,
+ struct ctf_field_class *fc, void *data)
{
- enum bt_btr_status status = BT_BTR_STATUS_OK;
+ enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
struct bt_field *field = NULL;
struct bt_notif_iter *notit = data;
- BT_LOGV("Floating point number function called from BTR: "
- "notit-addr=%p, btr-addr=%p, ft-addr=%p, "
- "ft-id=%d, ft-in-ir=%d, value=%f",
- notit, notit->btr, ft, ft->id, ft->in_ir, value);
- BT_ASSERT(ft->in_ir);
+ BT_LOGV("Floating point number function called from BFCR: "
+ "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
+ "fc-id=%d, fc-in-ir=%d, value=%f",
+ notit, notit->bfcr, fc, fc->id, fc->in_ir, value);
+ BT_ASSERT(fc->in_ir);
field = borrow_next_field(notit);
BT_ASSERT(field);
- BT_ASSERT(bt_field_borrow_type(field) == ft->ir_ft);
- BT_ASSERT(bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_REAL);
+ BT_ASSERT(bt_field_borrow_class(field) == fc->ir_fc);
+ BT_ASSERT(bt_field_get_class_id(field) == BT_FIELD_CLASS_ID_REAL);
bt_field_real_set_value(field, value);
stack_top(notit->stack)->index++;
return status;
}
static
-enum bt_btr_status btr_string_begin_cb(
- struct ctf_field_type *ft, void *data)
+enum bt_bfcr_status bfcr_string_begin_cb(
+ struct ctf_field_class *fc, void *data)
{
struct bt_field *field = NULL;
struct bt_notif_iter *notit = data;
int ret;
- BT_LOGV("String (beginning) function called from BTR: "
- "notit-addr=%p, btr-addr=%p, ft-addr=%p, "
- "ft-id=%d, ft-in-ir=%d",
- notit, notit->btr, ft, ft->id, ft->in_ir);
+ BT_LOGV("String (beginning) function called from BFCR: "
+ "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
+ "fc-id=%d, fc-in-ir=%d",
+ notit, notit->bfcr, fc, fc->id, fc->in_ir);
- BT_ASSERT(ft->in_ir);
+ BT_ASSERT(fc->in_ir);
field = borrow_next_field(notit);
BT_ASSERT(field);
- BT_ASSERT(bt_field_borrow_type(field) == ft->ir_ft);
- BT_ASSERT(bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_STRING);
+ BT_ASSERT(bt_field_borrow_class(field) == fc->ir_fc);
+ BT_ASSERT(bt_field_get_class_id(field) == BT_FIELD_CLASS_ID_STRING);
ret = bt_field_string_clear(field);
BT_ASSERT(ret == 0);
/*
- * Push on stack. Not a compound type per se, but we know that
- * only btr_string_cb() may be called between this call and a
- * subsequent call to btr_string_end_cb().
+ * Push on stack. Not a compound class per se, but we know that
+ * only bfcr_string_cb() may be called between this call and a
+ * subsequent call to bfcr_string_end_cb().
*/
stack_push(notit->stack, field);
- return BT_BTR_STATUS_OK;
+ return BT_BFCR_STATUS_OK;
}
static
-enum bt_btr_status btr_string_cb(const char *value,
- size_t len, struct ctf_field_type *ft, void *data)
+enum bt_bfcr_status bfcr_string_cb(const char *value,
+ size_t len, struct ctf_field_class *fc, void *data)
{
- enum bt_btr_status status = BT_BTR_STATUS_OK;
+ enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
struct bt_field *field = NULL;
struct bt_notif_iter *notit = data;
int ret;
- BT_LOGV("String (substring) function called from BTR: "
- "notit-addr=%p, btr-addr=%p, ft-addr=%p, "
- "ft-id=%d, ft-in-ir=%d, string-length=%zu",
- notit, notit->btr, ft, ft->id, ft->in_ir,
+ BT_LOGV("String (substring) function called from BFCR: "
+ "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
+ "fc-id=%d, fc-in-ir=%d, string-length=%zu",
+ notit, notit->bfcr, fc, fc->id, fc->in_ir,
len);
- BT_ASSERT(ft->in_ir);
+ BT_ASSERT(fc->in_ir);
field = stack_top(notit->stack)->base;
BT_ASSERT(field);
BT_LOGE("Cannot append substring to string field's value: "
"notit-addr=%p, field-addr=%p, string-length=%zu, "
"ret=%d", notit, field, len, ret);
- status = BT_BTR_STATUS_ERROR;
+ status = BT_BFCR_STATUS_ERROR;
goto end;
}
}
static
-enum bt_btr_status btr_string_end_cb(
- struct ctf_field_type *ft, void *data)
+enum bt_bfcr_status bfcr_string_end_cb(
+ struct ctf_field_class *fc, void *data)
{
struct bt_notif_iter *notit = data;
- BT_LOGV("String (end) function called from BTR: "
- "notit-addr=%p, btr-addr=%p, ft-addr=%p, "
- "ft-id=%d, ft-in-ir=%d",
- notit, notit->btr, ft, ft->id, ft->in_ir);
- BT_ASSERT(ft->in_ir);
+ BT_LOGV("String (end) function called from BFCR: "
+ "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
+ "fc-id=%d, fc-in-ir=%d",
+ notit, notit->bfcr, fc, fc->id, fc->in_ir);
+ BT_ASSERT(fc->in_ir);
/* Pop string field */
stack_pop(notit->stack);
/* Go to next field */
stack_top(notit->stack)->index++;
- return BT_BTR_STATUS_OK;
+ return BT_BFCR_STATUS_OK;
}
-enum bt_btr_status btr_compound_begin_cb(
- struct ctf_field_type *ft, void *data)
+enum bt_bfcr_status bfcr_compound_begin_cb(
+ struct ctf_field_class *fc, void *data)
{
struct bt_notif_iter *notit = data;
struct bt_field *field;
- BT_LOGV("Compound (beginning) function called from BTR: "
- "notit-addr=%p, btr-addr=%p, ft-addr=%p, "
- "ft-id=%d, ft-in-ir=%d",
- notit, notit->btr, ft, ft->id, ft->in_ir);
+ BT_LOGV("Compound (beginning) function called from BFCR: "
+ "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
+ "fc-id=%d, fc-in-ir=%d",
+ notit, notit->bfcr, fc, fc->id, fc->in_ir);
- if (!ft->in_ir) {
+ if (!fc->in_ir) {
goto end;
}
/* Push field */
BT_ASSERT(field);
- BT_ASSERT(bt_field_borrow_type(field) == ft->ir_ft);
+ BT_ASSERT(bt_field_borrow_class(field) == fc->ir_fc);
stack_push(notit->stack, field);
/*
- * Change BTR "unsigned int" callback if it's a text
+ * Change BFCR "unsigned int" callback if it's a text
* array/sequence.
*/
- if (ft->id == CTF_FIELD_TYPE_ID_ARRAY ||
- ft->id == CTF_FIELD_TYPE_ID_SEQUENCE) {
- struct ctf_field_type_array_base *array_ft = (void *) ft;
+ if (fc->id == CTF_FIELD_CLASS_ID_ARRAY ||
+ fc->id == CTF_FIELD_CLASS_ID_SEQUENCE) {
+ struct ctf_field_class_array_base *array_fc = (void *) fc;
- if (array_ft->is_text) {
+ if (array_fc->is_text) {
int ret;
- BT_ASSERT(bt_field_get_type_id(field) ==
- BT_FIELD_TYPE_ID_STRING);
+ BT_ASSERT(bt_field_get_class_id(field) ==
+ BT_FIELD_CLASS_ID_STRING);
notit->done_filling_string = false;
ret = bt_field_string_clear(field);
BT_ASSERT(ret == 0);
- bt_btr_set_unsigned_int_cb(notit->btr,
- btr_unsigned_int_char_cb);
+ bt_bfcr_set_unsigned_int_cb(notit->bfcr,
+ bfcr_unsigned_int_char_cb);
}
}
end:
- return BT_BTR_STATUS_OK;
+ return BT_BFCR_STATUS_OK;
}
-enum bt_btr_status btr_compound_end_cb(
- struct ctf_field_type *ft, void *data)
+enum bt_bfcr_status bfcr_compound_end_cb(
+ struct ctf_field_class *fc, void *data)
{
struct bt_notif_iter *notit = data;
- BT_LOGV("Compound (end) function called from BTR: "
- "notit-addr=%p, btr-addr=%p, ft-addr=%p, "
- "ft-id=%d, ft-in-ir=%d",
- notit, notit->btr, ft, ft->id, ft->in_ir);
+ BT_LOGV("Compound (end) function called from BFCR: "
+ "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
+ "fc-id=%d, fc-in-ir=%d",
+ notit, notit->bfcr, fc, fc->id, fc->in_ir);
- if (!ft->in_ir) {
+ if (!fc->in_ir) {
goto end;
}
BT_ASSERT(!stack_empty(notit->stack));
- BT_ASSERT(bt_field_borrow_type(stack_top(notit->stack)->base) ==
- ft->ir_ft);
+ BT_ASSERT(bt_field_borrow_class(stack_top(notit->stack)->base) ==
+ fc->ir_fc);
/*
- * Reset BTR "unsigned int" callback if it's a text
+ * Reset BFCR "unsigned int" callback if it's a text
* array/sequence.
*/
- if (ft->id == CTF_FIELD_TYPE_ID_ARRAY ||
- ft->id == CTF_FIELD_TYPE_ID_SEQUENCE) {
- struct ctf_field_type_array_base *array_ft = (void *) ft;
+ if (fc->id == CTF_FIELD_CLASS_ID_ARRAY ||
+ fc->id == CTF_FIELD_CLASS_ID_SEQUENCE) {
+ struct ctf_field_class_array_base *array_fc = (void *) fc;
- if (array_ft->is_text) {
- BT_ASSERT(bt_field_get_type_id(
+ if (array_fc->is_text) {
+ BT_ASSERT(bt_field_get_class_id(
stack_top(notit->stack)->base) ==
- BT_FIELD_TYPE_ID_STRING);
- bt_btr_set_unsigned_int_cb(notit->btr,
- btr_unsigned_int_cb);
+ BT_FIELD_CLASS_ID_STRING);
+ bt_bfcr_set_unsigned_int_cb(notit->bfcr,
+ bfcr_unsigned_int_cb);
}
}
}
end:
- return BT_BTR_STATUS_OK;
+ return BT_BFCR_STATUS_OK;
}
static
-int64_t btr_get_sequence_length_cb(struct ctf_field_type *ft, void *data)
+int64_t bfcr_get_sequence_length_cb(struct ctf_field_class *fc, void *data)
{
struct bt_field *seq_field;
struct bt_notif_iter *notit = data;
- struct ctf_field_type_sequence *seq_ft = (void *) ft;
+ struct ctf_field_class_sequence *seq_fc = (void *) fc;
int64_t length = -1;
int ret;
length = (uint64_t) g_array_index(notit->stored_values, uint64_t,
- seq_ft->stored_length_index);
+ seq_fc->stored_length_index);
seq_field = stack_top(notit->stack)->base;
BT_ASSERT(seq_field);
ret = bt_field_dynamic_array_set_length(seq_field, (uint64_t) length);
}
static
-struct ctf_field_type *btr_borrow_variant_selected_field_type_cb(
- struct ctf_field_type *ft, void *data)
+struct ctf_field_class *bfcr_borrow_variant_selected_field_class_cb(
+ struct ctf_field_class *fc, void *data)
{
int ret;
uint64_t i;
int64_t option_index = -1;
struct bt_notif_iter *notit = data;
- struct ctf_field_type_variant *var_ft = (void *) ft;
- struct ctf_named_field_type *selected_option = NULL;
- struct ctf_field_type *ret_ft = NULL;
+ struct ctf_field_class_variant *var_fc = (void *) fc;
+ struct ctf_named_field_class *selected_option = NULL;
+ struct ctf_field_class *ret_fc = NULL;
union {
uint64_t u;
int64_t i;
/* Get variant's tag */
tag.u = g_array_index(notit->stored_values, uint64_t,
- var_ft->stored_tag_index);
+ var_fc->stored_tag_index);
/*
* Check each range to find the selected option's index.
*/
- if (var_ft->tag_ft->base.is_signed) {
- for (i = 0; i < var_ft->ranges->len; i++) {
- struct ctf_field_type_variant_range *range =
- ctf_field_type_variant_borrow_range_by_index(
- var_ft, i);
+ if (var_fc->tag_fc->base.is_signed) {
+ for (i = 0; i < var_fc->ranges->len; i++) {
+ struct ctf_field_class_variant_range *range =
+ ctf_field_class_variant_borrow_range_by_index(
+ var_fc, i);
if (tag.i >= range->range.lower.i &&
tag.i <= range->range.upper.i) {
}
}
} else {
- for (i = 0; i < var_ft->ranges->len; i++) {
- struct ctf_field_type_variant_range *range =
- ctf_field_type_variant_borrow_range_by_index(
- var_ft, i);
+ for (i = 0; i < var_fc->ranges->len; i++) {
+ struct ctf_field_class_variant_range *range =
+ ctf_field_class_variant_borrow_range_by_index(
+ var_fc, i);
if (tag.u >= range->range.lower.u &&
tag.u <= range->range.upper.u) {
}
if (option_index < 0) {
- BT_LOGW("Cannot find variant field type's option: "
- "notit-addr=%p, var-ft-addr=%p, u-tag=%" PRIu64 ", "
- "i-tag=%" PRId64, notit, var_ft, tag.u, tag.i);
+ BT_LOGW("Cannot find variant field class's option: "
+ "notit-addr=%p, var-fc-addr=%p, u-tag=%" PRIu64 ", "
+ "i-tag=%" PRId64, notit, var_fc, tag.u, tag.i);
goto end;
}
- selected_option = ctf_field_type_variant_borrow_option_by_index(
- var_ft, (uint64_t) option_index);
+ selected_option = ctf_field_class_variant_borrow_option_by_index(
+ var_fc, (uint64_t) option_index);
- if (selected_option->ft->in_ir) {
+ if (selected_option->fc->in_ir) {
struct bt_field *var_field = stack_top(notit->stack)->base;
ret = bt_field_variant_select_option_field(var_field,
}
}
- ret_ft = selected_option->ft;
+ ret_fc = selected_option->fc;
end:
- return ret_ft;
+ return ret_fc;
}
static
struct bt_notif_iter_medium_ops medops, void *data)
{
struct bt_notif_iter *notit = NULL;
- struct bt_btr_cbs cbs = {
- .types = {
- .signed_int = btr_signed_int_cb,
- .unsigned_int = btr_unsigned_int_cb,
- .floating_point = btr_floating_point_cb,
- .string_begin = btr_string_begin_cb,
- .string = btr_string_cb,
- .string_end = btr_string_end_cb,
- .compound_begin = btr_compound_begin_cb,
- .compound_end = btr_compound_end_cb,
+ struct bt_bfcr_cbs cbs = {
+ .classes = {
+ .signed_int = bfcr_signed_int_cb,
+ .unsigned_int = bfcr_unsigned_int_cb,
+ .floating_point = bfcr_floating_point_cb,
+ .string_begin = bfcr_string_begin_cb,
+ .string = bfcr_string_cb,
+ .string_end = bfcr_string_end_cb,
+ .compound_begin = bfcr_compound_begin_cb,
+ .compound_end = bfcr_compound_end_cb,
},
.query = {
- .get_sequence_length = btr_get_sequence_length_cb,
- .borrow_variant_selected_field_type = btr_borrow_variant_selected_field_type_cb,
+ .get_sequence_length = bfcr_get_sequence_length_cb,
+ .borrow_variant_selected_field_class = bfcr_borrow_variant_selected_field_class_cb,
},
};
goto error;
}
- notit->btr = bt_btr_create(cbs, notit);
- if (!notit->btr) {
- BT_LOGE_STR("Failed to create binary type reader (BTR).");
+ notit->bfcr = bt_bfcr_create(cbs, notit);
+ if (!notit->bfcr) {
+ BT_LOGE_STR("Failed to create binary class reader (BFCR).");
goto error;
}
stack_destroy(notit->stack);
}
- if (notit->btr) {
- BT_LOGD("Destroying BTR: btr-addr=%p", notit->btr);
- bt_btr_destroy(notit->btr);
+ if (notit->bfcr) {
+ BT_LOGD("Destroying BFCR: bfcr-addr=%p", notit->bfcr);
+ bt_bfcr_destroy(notit->bfcr);
}
if (notit->stored_values) {
struct bt_event *event, const char *field_name)
{
struct bt_field *field = NULL, *payload = NULL;
- struct bt_field_type *payload_type = NULL;
+ struct bt_field_class *payload_class = NULL;
payload = bt_event_get_payload(event, NULL);
BT_ASSERT(payload);
- payload_type = bt_field_get_type(payload);
- BT_ASSERT(payload_type);
+ payload_class = bt_field_get_class(payload);
+ BT_ASSERT(payload_class);
- if (bt_field_type_get_type_id(payload_type) != BT_FIELD_TYPE_ID_STRUCT) {
+ if (bt_field_class_id(payload_class) != BT_FIELD_CLASS_ID_STRUCT) {
BT_LOGE("Wrong type, expected struct: field-name=\"%s\"",
field_name);
goto end;
field = bt_field_structure_get_field_by_name(payload, field_name);
end:
- bt_put(payload_type);
+ bt_put(payload_class);
bt_put(payload);
return field;
}
struct bt_event *event, const char *field_name)
{
struct bt_field *field = NULL, *sec = NULL;
- struct bt_field_type *sec_type = NULL;
+ struct bt_field_class *sec_class = NULL;
sec = bt_event_get_stream_event_context(event);
if (!sec) {
goto end;
}
- sec_type = bt_field_get_type(sec);
- BT_ASSERT(sec_type);
+ sec_class = bt_field_get_class(sec);
+ BT_ASSERT(sec_class);
- if (bt_field_type_get_type_id(sec_type) != BT_FIELD_TYPE_ID_STRUCT) {
+ if (bt_field_class_id(sec_class) != BT_FIELD_CLASS_ID_STRUCT) {
BT_LOGE("Wrong type, expected struct, field-name=\"%s\"",
field_name);
goto end;
field = bt_field_structure_get_field_by_name(sec, field_name);
end:
- bt_put(sec_type);
+ bt_put(sec_class);
bt_put(sec);
return field;
}
{
int ret;
struct bt_field *field = NULL;
- struct bt_field_type *field_type = NULL;
+ struct bt_field_class *field_class = NULL;
field = get_stream_event_context_field(err, event, field_name);
if (!field) {
goto error;
}
- field_type = bt_field_get_type(field);
- BT_ASSERT(field_type);
+ field_class = bt_field_get_class(field);
+ BT_ASSERT(field_class);
- if (bt_field_type_get_type_id(field_type) != BT_FIELD_TYPE_ID_INTEGER) {
+ if (bt_field_class_id(field_class) != BT_FIELD_CLASS_ID_INTEGER) {
BT_LOGE("Wrong type, expected integer: field-name=\"%s\"",
field_name);
goto error;
}
- if (bt_ctf_field_type_integer_get_signed(field_type) != 0) {
+ if (bt_ctf_field_class_integer_get_signed(field_class) != 0) {
BT_LOGE("Wrong type, expected unsigned integer: field-name=\"%s\"",
field_name);
goto error;
error:
ret = -1;
end:
- bt_put(field_type);
+ bt_put(field_class);
bt_put(field);
return ret;
}
const char *field_name, int64_t *value)
{
struct bt_field *field = NULL;
- struct bt_field_type *field_type = NULL;
+ struct bt_field_class *field_class = NULL;
int ret;
field = get_stream_event_context_field(err, event, field_name);
goto error;
}
- field_type = bt_field_get_type(field);
- BT_ASSERT(field_type);
+ field_class = bt_field_get_class(field);
+ BT_ASSERT(field_class);
- if (bt_field_type_get_type_id(field_type) != BT_FIELD_TYPE_ID_INTEGER) {
+ if (bt_field_class_id(field_class) != BT_FIELD_CLASS_ID_INTEGER) {
BT_LOGE("Wrong type, expected integer: field-name=\"%s\"", field_name);
goto error;
}
- if (bt_ctf_field_type_integer_get_signed(field_type) != 1) {
+ if (bt_ctf_field_class_integer_get_signed(field_class) != 1) {
BT_LOGE("Wrong type, expected signed integer: field-name=\"%s\"",
field_name);
goto error;
error:
ret = -1;
end:
- bt_put(field_type);
+ bt_put(field_class);
bt_put(field);
return ret;
}
uint64_t *value)
{
struct bt_field *field = NULL;
- struct bt_field_type *field_type = NULL;
+ struct bt_field_class *field_class = NULL;
int ret;
field = get_payload_field(err, event, field_name);
goto error;
}
- field_type = bt_field_get_type(field);
- BT_ASSERT(field_type);
+ field_class = bt_field_get_class(field);
+ BT_ASSERT(field_class);
- if (bt_field_type_get_type_id(field_type) != BT_FIELD_TYPE_ID_INTEGER) {
+ if (bt_field_class_id(field_class) != BT_FIELD_CLASS_ID_INTEGER) {
BT_LOGE("Wrong type, expected integer: field-name=\"%s\"",
field_name);
goto error;
}
- if (bt_ctf_field_type_integer_get_signed(field_type) != 0) {
+ if (bt_ctf_field_class_integer_get_signed(field_class) != 0) {
BT_LOGE("Wrong type, expected unsigned integer: field-name=\"%s\"",
field_name);
goto error;
error:
ret = -1;
end:
- bt_put(field_type);
+ bt_put(field_class);
bt_put(field);
return ret;
}
const char *field_name, int64_t *value)
{
struct bt_field *field = NULL;
- struct bt_field_type *field_type = NULL;
+ struct bt_field_class *field_class = NULL;
int ret;
field = get_payload_field(err, event, field_name);
goto error;
}
- field_type = bt_field_get_type(field);
- BT_ASSERT(field_type);
+ field_class = bt_field_get_class(field);
+ BT_ASSERT(field_class);
- if (bt_field_type_get_type_id(field_type) != BT_FIELD_TYPE_ID_INTEGER) {
+ if (bt_field_class_id(field_class) != BT_FIELD_CLASS_ID_INTEGER) {
BT_LOGE("Wrong type, expected integer: field-name=\"%s\"", field_name);
goto error;
}
- if (bt_ctf_field_type_integer_get_signed(field_type) != 1) {
+ if (bt_ctf_field_class_integer_get_signed(field_class) != 1) {
BT_LOGE("Wrong type, expected signed integer field-name=\"%s\"",
field_name);
goto error;
error:
ret = -1;
end:
- bt_put(field_type);
+ bt_put(field_class);
bt_put(field);
return ret;
}
const char **value)
{
struct bt_field *field = NULL;
- struct bt_field_type *field_type = NULL;
+ struct bt_field_class *field_class = NULL;
int ret;
/*
goto error;
}
- field_type = bt_field_get_type(field);
- BT_ASSERT(field_type);
+ field_class = bt_field_get_class(field);
+ BT_ASSERT(field_class);
- if (bt_field_type_get_type_id(field_type) != BT_FIELD_TYPE_ID_STRING) {
+ if (bt_field_class_id(field_class) != BT_FIELD_CLASS_ID_STRING) {
BT_LOGE("Wrong type, expected string: field-name=\"%s\"",
field_name);
goto error;
error:
ret = -1;
end:
- bt_put(field_type);
+ bt_put(field_class);
bt_put(field);
return ret;
}
uint8_t **build_id, uint64_t *build_id_len)
{
struct bt_field *field = NULL, *seq_len = NULL;
- struct bt_field_type *field_type = NULL;
+ struct bt_field_class *field_class = NULL;
struct bt_field *seq_field = NULL;
uint64_t i;
int ret;
goto error;
}
- field_type = bt_field_get_type(field);
- BT_ASSERT(field_type);
+ field_class = bt_field_get_class(field);
+ BT_ASSERT(field_class);
- if (bt_field_type_get_type_id(field_type) != BT_FIELD_TYPE_ID_SEQUENCE) {
+ if (bt_field_class_id(field_class) != BT_FIELD_CLASS_ID_SEQUENCE) {
BT_LOGE("Wrong type, expected sequence: field-name=\"%s\"", field_name);
goto error;
}
- BT_PUT(field_type);
+ BT_PUT(field_class);
seq_len = bt_field_sequence_get_length(field);
BT_ASSERT(seq_len);
g_free(*build_id);
ret = -1;
end:
- bt_put(field_type);
+ bt_put(field_class);
bt_put(field);
return ret;
}
static
int add_debug_info_fields(FILE *err,
- struct bt_field_type *writer_event_context_type,
+ struct bt_field_class *writer_event_context_class,
struct debug_info_component *component)
{
- struct bt_field_type *ip_field = NULL, *debug_field_type = NULL,
- *bin_field_type = NULL, *func_field_type = NULL,
- *src_field_type = NULL;
+ struct bt_field_class *ip_field = NULL, *debug_field_class = NULL,
+ *bin_field_class = NULL, *func_field_class = NULL,
+ *src_field_class = NULL;
int ret = 0;
- ip_field = bt_field_type_structure_get_field_type_by_name(
- writer_event_context_type, IP_FIELD_NAME);
+ ip_field = bt_field_class_structure_get_field_class_by_name(
+ writer_event_context_class, IP_FIELD_NAME);
/* No ip field, so no debug info. */
if (!ip_field) {
goto end;
}
BT_PUT(ip_field);
- debug_field_type = bt_field_type_structure_get_field_type_by_name(
- writer_event_context_type,
+ debug_field_class = bt_field_class_structure_get_field_class_by_name(
+ writer_event_context_class,
component->arg_debug_info_field_name);
/* Already existing debug_info field, no need to add it. */
- if (debug_field_type) {
+ if (debug_field_class) {
goto end;
}
- debug_field_type = bt_field_type_structure_create();
- if (!debug_field_type) {
+ debug_field_class = bt_field_class_structure_create();
+ if (!debug_field_class) {
BT_LOGE_STR("Failed to create debug_info structure.");
goto error;
}
- bin_field_type = bt_field_type_string_create();
- if (!bin_field_type) {
+ bin_field_class = bt_field_class_string_create();
+ if (!bin_field_class) {
BT_LOGE_STR("Failed to create string for field=bin.");
goto error;
}
- func_field_type = bt_field_type_string_create();
- if (!func_field_type) {
+ func_field_class = bt_field_class_string_create();
+ if (!func_field_class) {
BT_LOGE_STR("Failed to create string for field=func.");
goto error;
}
- src_field_type = bt_field_type_string_create();
- if (!src_field_type) {
+ src_field_class = bt_field_class_string_create();
+ if (!src_field_class) {
BT_LOGE_STR("Failed to create string for field=src.");
goto error;
}
- ret = bt_field_type_structure_add_field(debug_field_type,
- bin_field_type, "bin");
+ ret = bt_field_class_structure_add_field(debug_field_class,
+ bin_field_class, "bin");
if (ret) {
BT_LOGE_STR("Failed to add a field to debug_info struct: field=bin.");
goto error;
}
- ret = bt_field_type_structure_add_field(debug_field_type,
- func_field_type, "func");
+ ret = bt_field_class_structure_add_field(debug_field_class,
+ func_field_class, "func");
if (ret) {
BT_LOGE_STR("Failed to add a field to debug_info struct: field=func.");
goto error;
}
- ret = bt_field_type_structure_add_field(debug_field_type,
- src_field_type, "src");
+ ret = bt_field_class_structure_add_field(debug_field_class,
+ src_field_class, "src");
if (ret) {
BT_LOGE_STR("Failed to add a field to debug_info struct: field=src.");
goto error;
}
- ret = bt_field_type_structure_add_field(writer_event_context_type,
- debug_field_type, component->arg_debug_info_field_name);
+ ret = bt_field_class_structure_add_field(writer_event_context_class,
+ debug_field_class, component->arg_debug_info_field_name);
if (ret) {
BT_LOGE_STR("Failed to add debug_info field to event_context.");
goto error;
goto end;
error:
- BT_PUT(debug_field_type);
+ BT_PUT(debug_field_class);
ret = -1;
end:
- bt_put(src_field_type);
- bt_put(func_field_type);
- bt_put(bin_field_type);
- bt_put(debug_field_type);
+ bt_put(src_field_class);
+ bt_put(func_field_class);
+ bt_put(bin_field_class);
+ bt_put(debug_field_class);
return ret;
}
static
-int create_debug_info_event_context_type(FILE *err,
- struct bt_field_type *event_context_type,
- struct bt_field_type *writer_event_context_type,
+int create_debug_info_event_context_class(FILE *err,
+ struct bt_field_class *event_context_class,
+ struct bt_field_class *writer_event_context_class,
struct debug_info_component *component)
{
int ret, nr_fields, i;
- nr_fields = bt_field_type_structure_get_field_count(event_context_type);
+ nr_fields = bt_field_class_structure_get_field_count(event_context_class);
for (i = 0; i < nr_fields; i++) {
- struct bt_field_type *field_type = NULL;
+ struct bt_field_class *field_class = NULL;
const char *field_name;
- if (bt_field_type_structure_get_field_by_index(event_context_type,
- &field_name, &field_type, i) < 0) {
+ if (bt_field_class_structure_get_field_by_index(event_context_class,
+ &field_name, &field_class, i) < 0) {
BT_LOGE("Failed to get a field from the event-context: field-name=\"%s\"",
field_name);
goto error;
}
- ret = bt_field_type_structure_add_field(writer_event_context_type,
- field_type, field_name);
- BT_PUT(field_type);
+ ret = bt_field_class_structure_add_field(writer_event_context_class,
+ field_class, field_name);
+ BT_PUT(field_class);
if (ret) {
BT_LOGE("Failed to add a field to the event-context: field-name=\"%s\"",
field_name);
}
}
- ret = add_debug_info_fields(err, writer_event_context_type,
+ ret = add_debug_info_fields(err, writer_event_context_class,
component);
goto end;
struct bt_trace *writer_trace,
struct debug_info_component *component)
{
- struct bt_field_type *type = NULL;
+ struct bt_field_class *cls = NULL;
struct bt_stream_class *writer_stream_class = NULL;
- struct bt_field_type *writer_event_context_type = NULL;
+ struct bt_field_class *writer_event_context_class = NULL;
int ret_int;
const char *name = bt_stream_class_get_name(stream_class);
goto error;
}
- type = bt_stream_class_get_packet_context_type(stream_class);
+ type = bt_stream_class_get_packet_context_class(stream_class);
if (type) {
- ret_int = bt_stream_class_set_packet_context_type(
+ ret_int = bt_stream_class_set_packet_context_class(
writer_stream_class, type);
if (ret_int < 0) {
BT_LOGE_STR("Failed to set packet_context type.");
BT_PUT(type);
}
- type = bt_stream_class_get_event_context_type(stream_class);
+ type = bt_stream_class_get_event_context_class(stream_class);
if (type) {
- writer_event_context_type = bt_field_type_structure_create();
- if (!writer_event_context_type) {
+ writer_event_context_class = bt_field_class_structure_create();
+ if (!writer_event_context_class) {
BT_LOGE_STR("Failed to create writer_event_context struct type.");
goto error;
}
- ret_int = create_debug_info_event_context_type(err, type,
- writer_event_context_type, component);
+ ret_int = create_debug_info_event_context_class(err, type,
+ writer_event_context_class, component);
if (ret_int) {
BT_LOGE_STR("Failed to create debug_info event_context type.");
goto error;
}
BT_PUT(type);
- ret_int = bt_stream_class_set_event_context_type(
- writer_stream_class, writer_event_context_type);
+ ret_int = bt_stream_class_set_event_context_class(
+ writer_stream_class, writer_event_context_class);
if (ret_int < 0) {
BT_LOGE_STR("Failed to set event_context type.");
goto error;
}
- BT_PUT(writer_event_context_type);
+ BT_PUT(writer_event_context_class);
}
goto end;
error:
BT_PUT(writer_stream_class);
end:
- bt_put(writer_event_context_type);
+ bt_put(writer_event_context_class);
bt_put(type);
return writer_stream_class;
}
struct debug_info_component *component)
{
int i, nr_fields, ret = 0;
- struct bt_field_type *debug_field_type = NULL;
+ struct bt_field_class *debug_field_class = NULL;
struct bt_field *field = NULL;
- struct bt_field_type *field_type = NULL;
+ struct bt_field_class *field_class = NULL;
- debug_field_type = bt_field_get_type(debug_field);
- BT_ASSERT(debug_field_type);
+ debug_field_class = bt_field_get_class(debug_field);
+ BT_ASSERT(debug_field_class);
- nr_fields = bt_field_type_structure_get_field_count(debug_field_type);
+ nr_fields = bt_field_class_structure_get_field_count(debug_field_class);
for (i = 0; i < nr_fields; i++) {
const char *field_name;
- if (bt_field_type_structure_get_field_by_index(debug_field_type,
- &field_name, &field_type, i) < 0) {
+ if (bt_field_class_structure_get_field_by_index(debug_field_class,
+ &field_name, &field_class, i) < 0) {
BT_LOGE("Failed to get field from debug_info struct: field-name=\"%s\"",
field_name);
goto error;
}
- BT_PUT(field_type);
+ BT_PUT(field_class);
field = bt_field_structure_get_field_by_index(debug_field, i);
if (!strcmp(field_name, "bin")) {
error:
ret = -1;
end:
- bt_put(field_type);
+ bt_put(field_class);
bt_put(field);
- bt_put(debug_field_type);
+ bt_put(debug_field_class);
return ret;
}
struct debug_info *debug_info,
struct debug_info_component *component)
{
- struct bt_field_type *writer_event_context_type = NULL,
- *event_context_type = NULL;
+ struct bt_field_class *writer_event_context_class = NULL,
+ *event_context_class = NULL;
struct bt_field *writer_event_context = NULL;
struct bt_field *field = NULL, *copy_field = NULL, *debug_field = NULL;
- struct bt_field_type *field_type = NULL;
+ struct bt_field_class *field_class = NULL;
struct debug_info_source *dbg_info_src;
int ret, nr_fields, i;
writer_event_context = bt_event_get_stream_event_context(writer_event);
BT_ASSERT(writer_event_context);
- writer_event_context_type = bt_field_get_type(writer_event_context);
- BT_ASSERT(writer_event_context_type);
+ writer_event_context_class = bt_field_get_class(writer_event_context);
+ BT_ASSERT(writer_event_context_class);
- event_context_type = bt_field_get_type(event_context);
- BT_ASSERT(event_context_type);
+ event_context_class = bt_field_get_class(event_context);
+ BT_ASSERT(event_context_class);
/*
* If it is not a structure, we did not modify it to add the debug info
* fields, so just assign it as is.
*/
- if (bt_field_type_get_type_id(writer_event_context_type) != BT_FIELD_TYPE_ID_STRUCT) {
+ if (bt_field_class_id(writer_event_context_class) != BT_FIELD_CLASS_ID_STRUCT) {
ret = bt_event_set_event_context(writer_event, event_context);
goto end;
}
dbg_info_src = lookup_debug_info(err, event, debug_info);
- nr_fields = bt_field_type_structure_get_field_count(writer_event_context_type);
+ nr_fields = bt_field_class_structure_get_field_count(writer_event_context_class);
for (i = 0; i < nr_fields; i++) {
const char *field_name;
- if (bt_field_type_structure_get_field_by_index(writer_event_context_type,
- &field_name, &field_type, i) < 0) {
+ if (bt_field_class_structure_get_field_by_index(writer_event_context_class,
+ &field_name, &field_class, i) < 0) {
BT_LOGE("Failed to get field from event-context: field-name=\"%s\"",
field_name);
goto error;
/*
* Prevent illegal access in the event_context.
*/
- if (i < bt_field_type_structure_get_field_count(event_context_type)) {
+ if (i < bt_field_class_structure_get_field_count(event_context_class)) {
field = bt_field_structure_get_field_by_index(event_context, i);
}
/*
}
BT_PUT(copy_field);
}
- BT_PUT(field_type);
+ BT_PUT(field_class);
BT_PUT(field);
}
error:
ret = -1;
end:
- bt_put(event_context_type);
- bt_put(writer_event_context_type);
+ bt_put(event_context_class);
+ bt_put(writer_event_context_class);
bt_put(writer_event_context);
bt_put(field);
bt_put(copy_field);
bt_put(debug_field);
- bt_put(field_type);
+ bt_put(field_class);
return ret;
}
};
static
-struct bt_field_type *create_event_payload_ft(void)
+struct bt_field_class *create_event_payload_fc(void)
{
- struct bt_field_type *root_ft = NULL;
- struct bt_field_type *ft = NULL;
+ struct bt_field_class *root_fc = NULL;
+ struct bt_field_class *fc = NULL;
int ret;
- root_ft = bt_field_type_structure_create();
- if (!root_ft) {
- BT_LOGE_STR("Cannot create an empty structure field type object.");
+ root_fc = bt_field_class_structure_create();
+ if (!root_fc) {
+ BT_LOGE_STR("Cannot create an empty structure field class object.");
goto error;
}
- ft = bt_field_type_string_create();
- if (!ft) {
- BT_LOGE_STR("Cannot create a string field type object.");
+ fc = bt_field_class_string_create();
+ if (!fc) {
+ BT_LOGE_STR("Cannot create a string field class object.");
goto error;
}
- ret = bt_field_type_structure_append_member(root_ft, "str", ft);
+ ret = bt_field_class_structure_append_member(root_fc, "str", fc);
if (ret) {
- BT_LOGE("Cannot add `str` member to structure field type: "
+ BT_LOGE("Cannot add `str` member to structure field class: "
"ret=%d", ret);
goto error;
}
goto end;
error:
- BT_PUT(root_ft);
+ BT_PUT(root_fc);
end:
- bt_put(ft);
- return root_ft;
+ bt_put(fc);
+ return root_fc;
}
static
int create_meta(struct dmesg_component *dmesg_comp, bool has_ts)
{
- struct bt_field_type *ft = NULL;
+ struct bt_field_class *fc = NULL;
const char *trace_name = NULL;
gchar *basename = NULL;
int ret = 0;
goto error;
}
- ft = create_event_payload_ft();
- if (!ft) {
- BT_LOGE_STR("Cannot create event payload field type.");
+ fc = create_event_payload_fc();
+ if (!fc) {
+ BT_LOGE_STR("Cannot create event payload field class.");
goto error;
}
- ret = bt_event_class_set_payload_field_type(dmesg_comp->event_class, ft);
+ ret = bt_event_class_set_payload_field_class(dmesg_comp->event_class, fc);
if (ret) {
- BT_LOGE_STR("Cannot set event class's event payload field type.");
+ BT_LOGE_STR("Cannot set event class's event payload field class.");
goto error;
}
ret = -1;
end:
- bt_put(ft);
+ bt_put(fc);
if (basename) {
g_free(basename);
skip_ts:
/*
* At this point, we know if the stream class's event header
- * field type should have a timestamp or not, so we can lazily
+ * field class should have a timestamp or not, so we can lazily
* create the metadata, stream, and packet objects.
*/
ret = try_create_meta_stream_packet(dmesg_comp, has_timestamp);
struct bt_field *field)
{
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
- enum bt_field_type_integer_preferred_display_base base;
- struct bt_field_type *int_ft;
+ enum bt_field_class_integer_preferred_display_base base;
+ struct bt_field_class *int_fc;
union {
uint64_t u;
int64_t s;
} v;
bool rst_color = false;
- enum bt_field_type_id ft_id;
+ enum bt_field_class_id ft_id;
- int_ft = bt_field_borrow_type(field);
- BT_ASSERT(int_ft);
- ft_id = bt_field_get_type_id(field);
- if (ft_id == BT_FIELD_TYPE_ID_UNSIGNED_INTEGER ||
- ft_id == BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION) {
+ int_fc = bt_field_borrow_class(field);
+ BT_ASSERT(int_fc);
+ ft_id = bt_field_get_class_id(field);
+ if (ft_id == BT_FIELD_CLASS_ID_UNSIGNED_INTEGER ||
+ ft_id == BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION) {
v.u = bt_field_unsigned_integer_get_value(field);
} else {
v.s = bt_field_signed_integer_get_value(field);
rst_color = true;
}
- base = bt_field_type_integer_get_preferred_display_base(int_ft);
+ base = bt_field_class_integer_get_preferred_display_base(int_fc);
switch (base) {
- case BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_BINARY:
+ case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY:
{
int bitnr, len;
- len = bt_field_type_integer_get_field_value_range(int_ft);
+ len = bt_field_class_integer_get_field_value_range(int_fc);
g_string_append(pretty->string, "0b");
v.u = _bt_piecewise_lshift(v.u, 64 - len);
for (bitnr = 0; bitnr < len; bitnr++) {
}
break;
}
- case BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL:
+ case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL:
{
- if (ft_id == BT_FIELD_TYPE_ID_SIGNED_INTEGER ||
- ft_id == BT_FIELD_TYPE_ID_SIGNED_ENUMERATION) {
+ if (ft_id == BT_FIELD_CLASS_ID_SIGNED_INTEGER ||
+ ft_id == BT_FIELD_CLASS_ID_SIGNED_ENUMERATION) {
int len;
- len = bt_field_type_integer_get_field_value_range(
- int_ft);
+ len = bt_field_class_integer_get_field_value_range(
+ int_fc);
if (len < 64) {
size_t rounded_len;
g_string_append_printf(pretty->string, "0%" PRIo64, v.u);
break;
}
- case BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL:
- if (ft_id == BT_FIELD_TYPE_ID_UNSIGNED_INTEGER ||
- ft_id == BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION) {
+ case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL:
+ if (ft_id == BT_FIELD_CLASS_ID_UNSIGNED_INTEGER ||
+ ft_id == BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION) {
g_string_append_printf(pretty->string, "%" PRIu64, v.u);
} else {
g_string_append_printf(pretty->string, "%" PRId64, v.s);
}
break;
- case BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL:
+ case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL:
{
int len;
- len = bt_field_type_integer_get_field_value_range(int_ft);
+ len = bt_field_class_integer_get_field_value_range(int_fc);
if (len < 64) {
/* Round length to the nearest nibble */
uint8_t rounded_len = ((len + 3) & ~0x3);
struct bt_field *field)
{
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
- struct bt_field_type *enumeration_field_type = NULL;
- bt_field_type_enumeration_mapping_label_array label_array;
+ struct bt_field_class *enumeration_field_class = NULL;
+ bt_field_class_enumeration_mapping_label_array label_array;
uint64_t label_count;
uint64_t i;
- enumeration_field_type = bt_field_borrow_type(field);
- if (!enumeration_field_type) {
+ enumeration_field_class = bt_field_borrow_class(field);
+ if (!enumeration_field_class) {
ret = BT_COMPONENT_STATUS_ERROR;
goto end;
}
- switch (bt_field_get_type_id(field)) {
- case BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION:
+ switch (bt_field_get_class_id(field)) {
+ case BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION:
ret = bt_field_unsigned_enumeration_get_mapping_labels(field,
&label_array, &label_count);
break;
- case BT_FIELD_TYPE_ID_SIGNED_ENUMERATION:
+ case BT_FIELD_CLASS_ID_SIGNED_ENUMERATION:
ret = bt_field_signed_enumeration_get_mapping_labels(field,
&label_array, &label_count);
break;
static
enum bt_component_status print_struct_field(struct pretty_component *pretty,
struct bt_field *_struct,
- struct bt_field_type *struct_type,
+ struct bt_field_class *struct_class,
uint64_t i, bool print_names, uint64_t *nr_printed_fields,
GQuark *filter_fields, int filter_array_len)
{
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
const char *field_name;
struct bt_field *field = NULL;
- struct bt_field_type *field_type = NULL;;
+ struct bt_field_class *field_class = NULL;;
field = bt_field_structure_borrow_member_field_by_index(_struct, i);
if (!field) {
goto end;
}
- bt_field_type_structure_borrow_member_by_index(struct_type, i,
- &field_name, &field_type);
+ bt_field_class_structure_borrow_member_by_index(struct_class, i,
+ &field_name, &field_class);
if (filter_fields && !filter_field_name(pretty, field_name,
filter_fields, filter_array_len)) {
GQuark *filter_fields, int filter_array_len)
{
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
- struct bt_field_type *struct_type = NULL;
+ struct bt_field_class *struct_class = NULL;
uint64_t nr_fields, i, nr_printed_fields;
- struct_type = bt_field_borrow_type(_struct);
- if (!struct_type) {
+ struct_class = bt_field_borrow_class(_struct);
+ if (!struct_class) {
ret = BT_COMPONENT_STATUS_ERROR;
goto end;
}
- nr_fields = bt_field_type_structure_get_member_count(struct_type);
+ nr_fields = bt_field_class_structure_get_member_count(struct_class);
if (nr_fields < 0) {
ret = BT_COMPONENT_STATUS_ERROR;
goto end;
pretty->depth++;
nr_printed_fields = 0;
for (i = 0; i < nr_fields; i++) {
- ret = print_struct_field(pretty, _struct, struct_type, i,
+ ret = print_struct_field(pretty, _struct, struct_class, i,
print_names, &nr_printed_fields, filter_fields,
filter_array_len);
if (ret != BT_COMPONENT_STATUS_OK) {
struct bt_field *array, bool print_names)
{
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
- struct bt_field_type *array_type = NULL;
+ struct bt_field_class *array_class = NULL;
uint64_t len;
uint64_t i;
- array_type = bt_field_borrow_type(array);
- if (!array_type) {
+ array_class = bt_field_borrow_class(array);
+ if (!array_class) {
ret = BT_COMPONENT_STATUS_ERROR;
goto end;
}
struct bt_field *field, bool print_names,
GQuark *filter_fields, int filter_array_len)
{
- enum bt_field_type_id type_id;
+ enum bt_field_class_id class_id;
- type_id = bt_field_get_type_id(field);
- switch (type_id) {
- case BT_FIELD_TYPE_ID_UNSIGNED_INTEGER:
- case BT_FIELD_TYPE_ID_SIGNED_INTEGER:
+ class_id = bt_field_get_class_id(field);
+ switch (class_id) {
+ case BT_FIELD_CLASS_ID_UNSIGNED_INTEGER:
+ case BT_FIELD_CLASS_ID_SIGNED_INTEGER:
return print_integer(pretty, field);
- case BT_FIELD_TYPE_ID_REAL:
+ case BT_FIELD_CLASS_ID_REAL:
{
double v;
}
return BT_COMPONENT_STATUS_OK;
}
- case BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION:
- case BT_FIELD_TYPE_ID_SIGNED_ENUMERATION:
+ case BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION:
+ case BT_FIELD_CLASS_ID_SIGNED_ENUMERATION:
return print_enum(pretty, field);
- case BT_FIELD_TYPE_ID_STRING:
+ case BT_FIELD_CLASS_ID_STRING:
{
const char *str;
}
return BT_COMPONENT_STATUS_OK;
}
- case BT_FIELD_TYPE_ID_STRUCTURE:
+ case BT_FIELD_CLASS_ID_STRUCTURE:
return print_struct(pretty, field, print_names, filter_fields,
filter_array_len);
- case BT_FIELD_TYPE_ID_VARIANT:
+ case BT_FIELD_CLASS_ID_VARIANT:
return print_variant(pretty, field, print_names);
- case BT_FIELD_TYPE_ID_STATIC_ARRAY:
+ case BT_FIELD_CLASS_ID_STATIC_ARRAY:
return print_array(pretty, field, print_names);
- case BT_FIELD_TYPE_ID_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_ID_DYNAMIC_ARRAY:
return print_sequence(pretty, field, print_names);
default:
// TODO: log instead
- fprintf(pretty->err, "[error] Unknown type id: %d\n", (int) type_id);
+ fprintf(pretty->err, "[error] Unknown type id: %d\n", (int) class_id);
return BT_COMPONENT_STATUS_ERROR;
}
}
{
enum bt_component_status ret;
struct bt_field *packet_context = NULL, *writer_packet_context = NULL;
- struct bt_field_type *struct_type = NULL, *field_type = NULL;
+ struct bt_field_class *struct_class = NULL, *field_class = NULL;
struct bt_field *field = NULL, *writer_field = NULL;
int nr_fields, i, int_ret;
packet_context = bt_packet_get_context(writer_packet);
BT_ASSERT(packet_context);
- struct_type = bt_field_get_type(packet_context);
- BT_ASSERT(struct_type);
+ struct_class = bt_field_get_class(packet_context);
+ BT_ASSERT(struct_class);
writer_packet_context = bt_packet_get_context(writer_packet);
BT_ASSERT(writer_packet_context);
- nr_fields = bt_field_type_structure_get_field_count(struct_type);
+ nr_fields = bt_field_class_structure_get_field_count(struct_class);
for (i = 0; i < nr_fields; i++) {
const char *field_name;
name);
goto error;
}
- if (bt_field_type_structure_get_field_by_index(struct_type,
- &field_name, &field_type, i) < 0) {
+ if (bt_field_class_structure_get_field_by_index(struct_class,
+ &field_name, &field_class, i) < 0) {
BT_LOGE("Failed to get field: field-name=\"%s\"",
field_name);
goto error;
}
if (strcmp(field_name, name)) {
- BT_PUT(field_type);
+ BT_PUT(field_class);
BT_PUT(field);
continue;
}
- if (bt_field_type_get_type_id(field_type) !=
- BT_FIELD_TYPE_ID_INTEGER) {
+ if (bt_field_class_id(field_class) !=
+ BT_FIELD_CLASS_ID_INTEGER) {
BT_LOGE("Expecting an integer for this field: field-name=\"%s\"",
name);
goto error;
BT_ASSERT(int_ret == 0);
BT_PUT(writer_field);
- BT_PUT(field_type);
+ BT_PUT(field_class);
BT_PUT(field);
}
error:
bt_put(writer_field);
- bt_put(field_type);
+ bt_put(field_class);
bt_put(field);
ret = BT_COMPONENT_STATUS_ERROR;
end:
- bt_put(struct_type);
+ bt_put(struct_class);
bt_put(packet_context);
return ret;
}
int ret = 0;
int is_signed;
uint64_t raw_clock_value;
- struct bt_field_type *integer_type = NULL;
+ struct bt_field_class *integer_class = NULL;
struct bt_clock_class *clock_class = NULL;
struct bt_clock_value *clock_value = NULL;
- integer_type = bt_field_get_type(integer);
- BT_ASSERT(integer_type);
- clock_class = bt_field_type_integer_get_mapped_clock_class(
- integer_type);
+ integer_class = bt_field_get_class(integer);
+ BT_ASSERT(integer_class);
+ clock_class = bt_field_class_integer_get_mapped_clock_class(
+ integer_class);
if (!clock_class) {
ret = -1;
goto end;
}
- is_signed = bt_field_type_integer_is_signed(integer_type);
+ is_signed = bt_field_class_integer_is_signed(integer_class);
if (!is_signed) {
ret = bt_field_unsigned_integer_get_value(integer,
&raw_clock_value);
ret = bt_clock_value_get_value_ns_from_epoch(clock_value, ns);
end:
- bt_put(integer_type);
+ bt_put(integer_class);
bt_put(clock_class);
bt_put(clock_value);
return ret;
#include <babeltrace/assert-internal.h>
#include <babeltrace/trace-ir/event-class.h>
#include <babeltrace/trace-ir/event.h>
-#include <babeltrace/trace-ir/field-types.h>
+#include <babeltrace/trace-ir/field-classes.h>
#include <babeltrace/trace-ir/fields.h>
#include <babeltrace/trace-ir/packet.h>
#include <babeltrace/trace-ir/stream-class.h>
+++ /dev/null
-/*
- * test_ir_visit.c
- *
- * Trace IR visitor interface test
- *
- * Copyright 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; under version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "tap/tap.h"
-#include <babeltrace/ref.h>
-#include <babeltrace/trace-ir/event-class.h>
-#include <babeltrace/trace-ir/field-types.h>
-#include <babeltrace/trace-ir/stream-class.h>
-#include <babeltrace/trace-ir/trace.h>
-#include <babeltrace/trace-ir/visitor.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-#include <babeltrace/assert-internal.h>
-
-#define NR_TESTS 13
-
-struct visitor_state {
- int i;
-};
-
-struct expected_result {
- const char *object_name;
- enum bt_visitor_object_type object_type;
-};
-
-struct expected_result expected_results[] = {
- { NULL, BT_VISITOR_OBJECT_TYPE_TRACE },
- { "sc1", BT_VISITOR_OBJECT_TYPE_STREAM_CLASS },
- { "ec1", BT_VISITOR_OBJECT_TYPE_EVENT_CLASS },
- { "sc2", BT_VISITOR_OBJECT_TYPE_STREAM_CLASS },
- { "ec2", BT_VISITOR_OBJECT_TYPE_EVENT_CLASS },
- { "ec3", BT_VISITOR_OBJECT_TYPE_EVENT_CLASS },
-};
-
-const char *object_type_str(enum bt_visitor_object_type type)
-{
- switch (type) {
- case BT_VISITOR_OBJECT_TYPE_TRACE:
- return "trace";
- case BT_VISITOR_OBJECT_TYPE_STREAM_CLASS:
- return "stream class";
- case BT_VISITOR_OBJECT_TYPE_STREAM:
- return "stream";
- case BT_VISITOR_OBJECT_TYPE_EVENT_CLASS:
- return "event class";
- case BT_VISITOR_OBJECT_TYPE_EVENT:
- return "event";
- default:
- return "unknown";
- }
-}
-
-struct bt_event_class *init_event_class(const char *name)
-{
- int ret;
- struct bt_event_class *ec = bt_event_class_create(name);
- struct bt_field_type *payload_ft = NULL;;
- struct bt_field_type *int_field =
- bt_field_type_integer_create(8);
-
- if (!ec || !int_field) {
- goto error;
- }
-
- payload_ft = bt_event_class_get_payload_field_type(ec);
- ret = bt_field_type_structure_add_field(payload_ft,
- int_field, "an_int_field");
- if (ret) {
- goto error;
- }
-
- BT_PUT(int_field);
- BT_PUT(payload_ft);
- return ec;
-error:
- BT_PUT(ec);
- BT_PUT(int_field);
- BT_PUT(payload_ft);
- return NULL;
-}
-
-static void set_stream_class_field_types(
- struct bt_stream_class *stream_class)
-{
- struct bt_field_type *packet_context_type;
- struct bt_field_type *event_header_type;
- struct bt_field_type *ft;
- int ret;
-
- packet_context_type = bt_field_type_structure_create();
- BT_ASSERT(packet_context_type);
- ft = bt_field_type_integer_create(32);
- BT_ASSERT(ft);
- ret = bt_field_type_structure_add_field(packet_context_type,
- ft, "packet_size");
- BT_ASSERT(ret == 0);
- bt_put(ft);
- ft = bt_field_type_integer_create(32);
- BT_ASSERT(ft);
- ret = bt_field_type_structure_add_field(packet_context_type,
- ft, "content_size");
- BT_ASSERT(ret == 0);
- bt_put(ft);
-
- event_header_type = bt_field_type_structure_create();
- BT_ASSERT(event_header_type);
- ft = bt_field_type_integer_create(32);
- BT_ASSERT(ft);
- ret = bt_field_type_structure_add_field(event_header_type,
- ft, "id");
- BT_ASSERT(ret == 0);
- bt_put(ft);
-
- ret = bt_stream_class_set_packet_context_field_type(stream_class,
- packet_context_type);
- BT_ASSERT(ret == 0);
- ret = bt_stream_class_set_event_header_field_type(stream_class,
- event_header_type);
- BT_ASSERT(ret == 0);
-
- bt_put(packet_context_type);
- bt_put(event_header_type);
-}
-
-static void set_trace_packet_header(struct bt_trace *trace)
-{
- struct bt_field_type *packet_header_type;
- struct bt_field_type *ft;
- int ret;
-
- packet_header_type = bt_field_type_structure_create();
- BT_ASSERT(packet_header_type);
- ft = bt_field_type_integer_create(32);
- BT_ASSERT(ft);
- ret = bt_field_type_structure_add_field(packet_header_type,
- ft, "stream_id");
- BT_ASSERT(ret == 0);
- bt_put(ft);
-
- ret = bt_trace_set_packet_header_field_type(trace,
- packet_header_type);
- BT_ASSERT(ret == 0);
-
- bt_put(packet_header_type);
-}
-
-struct bt_trace *init_trace(void)
-{
- int ret;
- struct bt_trace *trace = bt_trace_create();
- struct bt_stream_class *sc1 = bt_stream_class_create("sc1");
- struct bt_stream_class *sc2 = bt_stream_class_create("sc2");
- struct bt_event_class *ec1 = init_event_class("ec1");
- struct bt_event_class *ec2 = init_event_class("ec2");
- struct bt_event_class *ec3 = init_event_class("ec3");
-
- if (!trace || !sc1 || !sc2 || !ec1 || !ec2 || !ec3) {
- goto end;
- }
-
- set_trace_packet_header(trace);
- set_stream_class_field_types(sc1);
- set_stream_class_field_types(sc2);
- ret = bt_stream_class_add_event_class(sc1, ec1);
- if (ret) {
- goto error;
- }
-
- ret = bt_stream_class_add_event_class(sc2, ec2);
- if (ret) {
- goto error;
- }
-
- ret = bt_stream_class_add_event_class(sc2, ec3);
- if (ret) {
- goto error;
- }
-
- ret = bt_trace_add_stream_class(trace, sc1);
- if (ret) {
- goto error;
- }
-
- ret = bt_trace_add_stream_class(trace, sc2);
- if (ret) {
- goto error;
- }
-end:
- BT_PUT(sc1);
- BT_PUT(sc2);
- BT_PUT(ec1);
- BT_PUT(ec2);
- BT_PUT(ec3);
- return trace;
-error:
- BT_PUT(trace);
- goto end;
-}
-
-int visitor(struct bt_visitor_object *object, void *data)
-{
- int ret = 0;
- bool names_match;
- const char *object_name;
- struct visitor_state *state = data;
- struct expected_result *expected = &expected_results[state->i++];
-
- switch (bt_visitor_object_get_type(object)) {
- case BT_VISITOR_OBJECT_TYPE_TRACE:
- object_name = NULL;
- names_match = expected->object_name == NULL;
- break;
- case BT_VISITOR_OBJECT_TYPE_STREAM_CLASS:
- object_name = bt_stream_class_get_name(
- bt_visitor_object_get_object(object));
- if (!object_name) {
- ret = -1;
- goto end;
- }
-
- names_match = !strcmp(object_name, expected->object_name);
- break;
- case BT_VISITOR_OBJECT_TYPE_EVENT_CLASS:
- object_name = bt_event_class_get_name(
- bt_visitor_object_get_object(object));
- if (!object_name) {
- ret = -1;
- goto end;
- }
-
- names_match = !strcmp(object_name, expected->object_name);
- break;
- default:
- diag("Encountered an unexpected type while visiting trace");
- ret = -1;
- goto end;
- }
-
- ok(expected->object_type == bt_visitor_object_get_type(object),
- "Encoutered object type %s, expected %s",
- object_type_str(expected->object_type),
- object_type_str(bt_visitor_object_get_type(object)));
- ok(names_match, "Element name is %s, expected %s",
- object_name ? : "NULL",
- expected->object_name ? : "NULL");
-end:
- return ret;
-}
-
-int main(int argc, char **argv)
-{
- int ret;
- struct bt_trace *trace;
- struct visitor_state state = { 0 };
-
- plan_tests(NR_TESTS);
-
- /*
- * Initialize a reference trace which we'll walk using the
- * bt_*_visit() interface.
- */
- trace = init_trace();
- if (!trace) {
- diag("Failed to initialize reference trace, aborting.");
- exit(-1);
- }
-
- ret = bt_trace_visit(trace, visitor, &state);
- ok(!ret, "bt_trace_visit returned success");
-
- BT_PUT(trace);
- return exit_status();
-}
-
* - uint16_t payload_16;
* - uint32_t payload_32;
*/
-static struct bt_field_type *create_integer_struct(void)
+static struct bt_field_class *create_integer_struct(void)
{
int ret;
- struct bt_field_type *structure = NULL;
- struct bt_field_type *ui8 = NULL, *ui16 = NULL, *ui32 = NULL;
+ struct bt_field_class *structure = NULL;
+ struct bt_field_class *ui8 = NULL, *ui16 = NULL, *ui32 = NULL;
- structure = bt_field_type_structure_create();
+ structure = bt_field_class_structure_create();
BT_ASSERT(structure);
- ui8 = bt_field_type_unsigned_integer_create();
+ ui8 = bt_field_class_unsigned_integer_create();
BT_ASSERT(ui8);
- ret = bt_field_type_integer_set_field_value_range(ui8, 8);
+ ret = bt_field_class_integer_set_field_value_range(ui8, 8);
BT_ASSERT(ret == 0);
- ret = bt_field_type_structure_append_member(structure,
+ ret = bt_field_class_structure_append_member(structure,
"payload_8", ui8);
BT_ASSERT(ret == 0);
- ui16 = bt_field_type_unsigned_integer_create();
+ ui16 = bt_field_class_unsigned_integer_create();
BT_ASSERT(ui16);
- ret = bt_field_type_integer_set_field_value_range(ui16, 16);
+ ret = bt_field_class_integer_set_field_value_range(ui16, 16);
BT_ASSERT(ret == 0);
- ret = bt_field_type_structure_append_member(structure,
+ ret = bt_field_class_structure_append_member(structure,
"payload_16", ui16);
BT_ASSERT(ret == 0);
- ui32 = bt_field_type_unsigned_integer_create();
+ ui32 = bt_field_class_unsigned_integer_create();
BT_ASSERT(ui32);
- ret = bt_field_type_integer_set_field_value_range(ui32, 32);
+ ret = bt_field_class_integer_set_field_value_range(ui32, 32);
BT_ASSERT(ret == 0);
- ret = bt_field_type_structure_append_member(structure,
+ ret = bt_field_class_structure_append_member(structure,
"payload_32", ui32);
BT_ASSERT(ret == 0);
BT_PUT(ui8);
{
int ret;
struct bt_event_class *event = NULL;
- struct bt_field_type *payload = NULL;
+ struct bt_field_class *payload = NULL;
BT_ASSERT(name);
event = bt_event_class_create(sc);
BT_ASSERT(ret == 0);
payload = create_integer_struct();
BT_ASSERT(payload);
- ret = bt_event_class_set_payload_field_type(event, payload);
+ ret = bt_event_class_set_payload_field_class(event, payload);
BT_ASSERT(ret == 0);
BT_PUT(payload);
return event;
{
int ret;
struct bt_event_class *event = NULL;
- struct bt_field_type *inner = NULL, *outer = NULL;
+ struct bt_field_class *inner = NULL, *outer = NULL;
BT_ASSERT(name);
event = bt_event_class_create(sc);
BT_ASSERT(outer);
inner = create_integer_struct();
BT_ASSERT(inner);
- ret = bt_field_type_structure_append_member(outer,
+ ret = bt_field_class_structure_append_member(outer,
"payload_struct", inner);
BT_ASSERT(ret == 0);
- ret = bt_event_class_set_payload_field_type(event, outer);
+ ret = bt_event_class_set_payload_field_class(event, outer);
BT_ASSERT(ret == 0);
BT_PUT(inner);
BT_PUT(outer);
return event;
}
-static void set_stream_class_field_types(
+static void set_stream_class_field_classes(
struct bt_stream_class *stream_class)
{
- struct bt_field_type *packet_context_type;
- struct bt_field_type *event_header_type;
- struct bt_field_type *ft;
+ struct bt_field_class *packet_context_type;
+ struct bt_field_class *event_header_type;
+ struct bt_field_class *fc;
int ret;
- packet_context_type = bt_field_type_structure_create();
+ packet_context_type = bt_field_class_structure_create();
BT_ASSERT(packet_context_type);
- ft = bt_field_type_unsigned_integer_create();
- BT_ASSERT(ft);
- ret = bt_field_type_integer_set_field_value_range(ft, 32);
+ fc = bt_field_class_unsigned_integer_create();
+ BT_ASSERT(fc);
+ ret = bt_field_class_integer_set_field_value_range(fc, 32);
BT_ASSERT(ret == 0);
- ret = bt_field_type_structure_append_member(packet_context_type,
- "packet_size", ft);
+ ret = bt_field_class_structure_append_member(packet_context_type,
+ "packet_size", fc);
BT_ASSERT(ret == 0);
- bt_put(ft);
- ft = bt_field_type_unsigned_integer_create();
- BT_ASSERT(ft);
- ret = bt_field_type_integer_set_field_value_range(ft, 32);
+ bt_put(fc);
+ fc = bt_field_class_unsigned_integer_create();
+ BT_ASSERT(fc);
+ ret = bt_field_class_integer_set_field_value_range(fc, 32);
BT_ASSERT(ret == 0);
- ret = bt_field_type_structure_append_member(packet_context_type,
- "content_size", ft);
+ ret = bt_field_class_structure_append_member(packet_context_type,
+ "content_size", fc);
BT_ASSERT(ret == 0);
- bt_put(ft);
- event_header_type = bt_field_type_structure_create();
+ bt_put(fc);
+ event_header_type = bt_field_class_structure_create();
BT_ASSERT(event_header_type);
- ft = bt_field_type_unsigned_integer_create();
- BT_ASSERT(ft);
- ret = bt_field_type_integer_set_field_value_range(ft, 32);
+ fc = bt_field_class_unsigned_integer_create();
+ BT_ASSERT(fc);
+ ret = bt_field_class_integer_set_field_value_range(fc, 32);
BT_ASSERT(ret == 0);
- ret = bt_field_type_structure_append_member(event_header_type,
- "id", ft);
+ ret = bt_field_class_structure_append_member(event_header_type,
+ "id", fc);
BT_ASSERT(ret == 0);
- bt_put(ft);
- ret = bt_stream_class_set_packet_context_field_type(stream_class,
+ bt_put(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_type(stream_class,
+ ret = bt_stream_class_set_event_header_field_class(stream_class,
event_header_type);
BT_ASSERT(ret == 0);
bt_put(packet_context_type);
BT_ASSERT(sc1);
ret = bt_stream_class_set_name(sc1, "sc1");
BT_ASSERT(ret == 0);
- set_stream_class_field_types(sc1);
+ set_stream_class_field_classes(sc1);
ec1 = create_complex_event(sc1, "ec1");
BT_ASSERT(ec1);
ec2 = create_simple_event(sc1, "ec2");
BT_ASSERT(sc2);
ret = bt_stream_class_set_name(sc2, "sc2");
BT_ASSERT(ret == 0);
- set_stream_class_field_types(sc2);
+ set_stream_class_field_classes(sc2);
ec3 = create_simple_event(sc2, "ec3");
ret_stream = bt_event_class_borrow_stream_class(ec3);
ok(ret_stream == sc2, "Borrow parent stream SC2 from EC3");
static void set_trace_packet_header(struct bt_trace *trace)
{
- struct bt_field_type *packet_header_type;
- struct bt_field_type *ft;
+ struct bt_field_class *packet_header_type;
+ struct bt_field_class *fc;
int ret;
- packet_header_type = bt_field_type_structure_create();
+ packet_header_type = bt_field_class_structure_create();
BT_ASSERT(packet_header_type);
- ft = bt_field_type_unsigned_integer_create();
- BT_ASSERT(ft);
- ret = bt_field_type_integer_set_field_value_range(ft, 32);
+ fc = bt_field_class_unsigned_integer_create();
+ BT_ASSERT(fc);
+ ret = bt_field_class_integer_set_field_value_range(fc, 32);
BT_ASSERT(ret == 0);
- ret = bt_field_type_structure_append_member(packet_header_type,
- "stream_id", ft);
+ ret = bt_field_class_structure_append_member(packet_header_type,
+ "stream_id", fc);
BT_ASSERT(ret == 0);
- bt_put(ft);
- ret = bt_trace_set_packet_header_field_type(trace,
+ bt_put(fc);
+ ret = bt_trace_set_packet_header_field_class(trace,
packet_header_type);
BT_ASSERT(ret == 0);