lib: commonize some precondition assertion macros
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 16 Apr 2020 17:12:55 +0000 (13:12 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 23 Apr 2020 03:45:20 +0000 (23:45 -0400)
1. Rename `assert-cond.h` to `assert-cond-base.h`.

2. Move common specialized pre/postcondition macros from
   `assert-cond-base.h` to `assert-cond.h`.

   Now `assert-cond-base.h` only contains the very basic
   pre/postcondition assertion macros.

3. Move common specialized macros from various internal header files to
   `assert-cond.h`.

4. Add new common specialized macros to `assert-cond.h`, mostly "non
   null" precondition assertion macros.

The goal of this patch is to make it easy to change code for many sites
at the same time when those sites use the same macro.

This patch introduces the common precondition assertion macros, but
does not use them in source files (future patch).

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I2456e459bab9d942e4e11953b4afc5a6f4d30620
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3433

src/lib/Makefile.am
src/lib/assert-cond-base.h [new file with mode: 0644]
src/lib/assert-cond.h
src/lib/graph/message/message.h
src/lib/trace-ir/field-class.h
src/lib/trace-ir/field.c
src/lib/trace-ir/field.h
src/lib/value.c

index ce6ba4a4f664ec5d3279fc5511265192a8af61c3..d36a4436c013920156e934d98a6ca1357b27bedd 100644 (file)
@@ -5,6 +5,7 @@ SUBDIRS = trace-ir prio-heap plugin graph
 lib_LTLIBRARIES = libbabeltrace2.la
 
 libbabeltrace2_la_SOURCES = \
+       assert-cond-base.h \
        assert-cond.h \
        babeltrace2.c \
        current-thread.c \
diff --git a/src/lib/assert-cond-base.h b/src/lib/assert-cond-base.h
new file mode 100644 (file)
index 0000000..269107f
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2018-2020 Philippe Proulx <pproulx@efficios.com>
+ */
+
+#ifndef BABELTRACE_ASSERT_COND_BASE_INTERNAL_H
+#define BABELTRACE_ASSERT_COND_BASE_INTERNAL_H
+
+/*
+ * The macros in this header use macros defined in "lib/logging.h". We
+ * don't want this header to automatically include "lib/logging.h"
+ * because you need to manually define BT_LOG_TAG before including
+ * "lib/logging.h" and it is unexpected that you also need to define it
+ * before including this header.
+ *
+ * This is a reminder that in order to use "lib/assert-cond.h", you also
+ * need to use logging explicitly.
+ */
+
+#ifndef BT_LIB_LOG_SUPPORTED
+# error Include "lib/logging.h" before this header.
+#endif
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include "common/common.h"
+#include "common/macros.h"
+
+/*
+ * Prints the details of an unsatisfied precondition or postcondition
+ * without immediately aborting. You should use this within a function
+ * which checks preconditions or postconditions, but which is called
+ * from a BT_ASSERT_PRE() or BT_ASSERT_POST() context, so that the
+ * function can still return its result for
+ * BT_ASSERT_PRE()/BT_ASSERT_POST() to evaluate it.
+ *
+ * Example:
+ *
+ *     static inline bool check_complex_precond(...)
+ *     {
+ *         ...
+ *
+ *         if (...) {
+ *             BT_ASSERT_COND_MSG("Invalid object: ...", ...);
+ *             return false;
+ *         }
+ *
+ *         ...
+ *     }
+ *
+ *     ...
+ *
+ *     BT_ASSERT_PRE(check_complex_precond(...),
+ *                   "Precondition is not satisfied: ...", ...);
+ */
+#define BT_ASSERT_COND_MSG(_fmt, ...)                                  \
+       do {                                                            \
+               bt_lib_log(_BT_LOG_SRCLOC_FUNCTION, __FILE__,           \
+                       __LINE__, BT_LOG_FATAL, BT_LOG_TAG,             \
+                       (_fmt), ##__VA_ARGS__);                         \
+       } while (0)
+
+/*
+ * Internal to this file: asserts that the library condition `_cond` of
+ * type `_cond_type` (`pre` or `post`) is satisfied.
+ *
+ * If `_cond` is false, this macro logs a fatal message using `_fmt` and
+ * the optional arguments (same usage as BT_LIB_LOGF()), and abort.
+ *
+ * To assert that an internal precondition or postcondition is
+ * satisfied, use BT_ASSERT() or BT_ASSERT_DBG().
+ */
+#define _BT_ASSERT_COND(_cond_type, _cond, _fmt, ...)                  \
+       do {                                                            \
+               if (!(_cond)) {                                         \
+                       BT_ASSERT_COND_MSG("Babeltrace 2 library " _cond_type "condition not satisfied. Error is:"); \
+                       BT_ASSERT_COND_MSG(_fmt, ##__VA_ARGS__);        \
+                       BT_ASSERT_COND_MSG("Aborting...");              \
+                       bt_common_abort();                              \
+               }                                                       \
+       } while (0)
+
+/*
+ * Asserts that the library precondition `_cond` is satisfied.
+ *
+ * If `_cond` is false, log a fatal message using `_fmt` and the
+ * optional arguments (same usage as BT_LIB_LOGF()), and abort.
+ *
+ * To assert that a library postcondition is satisfied (return from user
+ * code), use BT_ASSERT_POST().
+ *
+ * To assert that an internal precondition or postcondition is
+ * satisfied, use BT_ASSERT() or BT_ASSERT_DBG().
+ */
+#define BT_ASSERT_PRE(_cond, _fmt, ...)                                        \
+       _BT_ASSERT_COND("pre", _cond, _fmt, ##__VA_ARGS__)
+
+/*
+ * Asserts that the library postcondition `_cond` is satisfied.
+ *
+ * If `_cond` is false, log a fatal message using `_fmt` and the
+ * optional arguments (same usage as BT_LIB_LOGF()), and abort.
+ *
+ * To assert that a library precondition is satisfied (return from user
+ * code), use BT_ASSERT_PRE().
+ *
+ * To assert that an internal precondition or postcondition is
+ * satisfied, use BT_ASSERT() or BT_ASSERT_DBG().
+ */
+#define BT_ASSERT_POST(_cond, _fmt, ...)                                       \
+       _BT_ASSERT_COND("post", _cond, _fmt, ##__VA_ARGS__)
+
+#ifdef BT_DEV_MODE
+/* Developer mode version of BT_ASSERT_PRE(). */
+# define BT_ASSERT_PRE_DEV(_cond, _fmt, ...)                           \
+       BT_ASSERT_PRE((_cond), _fmt, ##__VA_ARGS__)
+
+/* Developer mode version of BT_ASSERT_POST(). */
+# define BT_ASSERT_POST_DEV(_cond, _fmt, ...)                          \
+       BT_ASSERT_POST((_cond), _fmt, ##__VA_ARGS__)
+
+/* Developer mode version of BT_ASSERT_COND_MSG(). */
+# define BT_ASSERT_COND_DEV_MSG(_fmt, ...)                             \
+       BT_ASSERT_COND_MSG(_fmt, ##__VA_ARGS__)
+
+/*
+ * Marks a function as being only used within a BT_ASSERT_PRE_DEV() or
+ * BT_ASSERT_POST_DEV() context.
+ */
+# define BT_ASSERT_COND_DEV_FUNC
+#else
+# define BT_ASSERT_COND_DEV_MSG(_fmt, ...)
+
+# define BT_ASSERT_PRE_DEV(_cond, _fmt, ...)   ((void) sizeof((void) (_cond), 0))
+
+# define BT_ASSERT_POST_DEV(_cond, _fmt, ...)  ((void) sizeof((void) (_cond), 0))
+
+# define BT_ASSERT_COND_DEV_FUNC       __attribute__((unused))
+#endif /* BT_DEV_MODE */
+
+/*
+ * Mark anything that includes this file as supporting precondition and
+ * postcondition assertion macros.
+ */
+#define BT_ASSERT_COND_SUPPORTED
+
+#endif /* BABELTRACE_ASSERT_COND_BASE_INTERNAL_H */
index 6fe6bed1ceec23dc5dc14d6505c175b1375ffb1b..d4e815db09f25fd1d3fe52922203f7445e7f5045 100644 (file)
@@ -8,110 +8,7 @@
 #ifndef BABELTRACE_ASSERT_COND_INTERNAL_H
 #define BABELTRACE_ASSERT_COND_INTERNAL_H
 
-/*
- * The macros in this header use macros defined in "lib/logging.h". We
- * don't want this header to automatically include "lib/logging.h"
- * because you need to manually define BT_LOG_TAG before including
- * "lib/logging.h" and it is unexpected that you also need to define it
- * before including this header.
- *
- * This is a reminder that in order to use "lib/assert-cond.h", you also
- * need to use logging explicitly.
- */
-
-#ifndef BT_LIB_LOG_SUPPORTED
-# error Include "lib/logging.h" before this header.
-#endif
-
-#include <stdbool.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include "common/common.h"
-#include "common/macros.h"
-
-/*
- * Prints the details of an unsatisfied precondition or postcondition
- * without immediately aborting. You should use this within a function
- * which checks preconditions or postconditions, but which is called
- * from a BT_ASSERT_PRE() or BT_ASSERT_POST() context, so that the
- * function can still return its result for
- * BT_ASSERT_PRE()/BT_ASSERT_POST() to evaluate it.
- *
- * Example:
- *
- *     static inline bool check_complex_precond(...)
- *     {
- *         ...
- *
- *         if (...) {
- *             BT_ASSERT_COND_MSG("Invalid object: ...", ...);
- *             return false;
- *         }
- *
- *         ...
- *     }
- *
- *     ...
- *
- *     BT_ASSERT_PRE(check_complex_precond(...),
- *                   "Precondition is not satisfied: ...", ...);
- */
-#define BT_ASSERT_COND_MSG(_fmt, ...)                                  \
-       do {                                                            \
-               bt_lib_log(_BT_LOG_SRCLOC_FUNCTION, __FILE__,           \
-                       __LINE__, BT_LOG_FATAL, BT_LOG_TAG,             \
-                       (_fmt), ##__VA_ARGS__);                         \
-       } while (0)
-
-/*
- * Internal to this file: asserts that the library condition `_cond` of
- * type `_cond_type` (`pre` or `post`) is satisfied.
- *
- * If `_cond` is false, this macro logs a fatal message using `_fmt` and
- * the optional arguments (same usage as BT_LIB_LOGF()), and abort.
- *
- * To assert that an internal precondition or postcondition is
- * satisfied, use BT_ASSERT() or BT_ASSERT_DBG().
- */
-#define _BT_ASSERT_COND(_cond_type, _cond, _fmt, ...)                  \
-       do {                                                            \
-               if (!(_cond)) {                                         \
-                       BT_ASSERT_COND_MSG("Babeltrace 2 library " _cond_type "condition not satisfied. Error is:"); \
-                       BT_ASSERT_COND_MSG(_fmt, ##__VA_ARGS__);        \
-                       BT_ASSERT_COND_MSG("Aborting...");              \
-                       bt_common_abort();                              \
-               }                                                       \
-       } while (0)
-
-/*
- * Asserts that the library precondition `_cond` is satisfied.
- *
- * If `_cond` is false, log a fatal message using `_fmt` and the
- * optional arguments (same usage as BT_LIB_LOGF()), and abort.
- *
- * To assert that a library postcondition is satisfied (return from user
- * code), use BT_ASSERT_POST().
- *
- * To assert that an internal precondition or postcondition is
- * satisfied, use BT_ASSERT() or BT_ASSERT_DBG().
- */
-#define BT_ASSERT_PRE(_cond, _fmt, ...)                                        \
-       _BT_ASSERT_COND("pre", _cond, _fmt, ##__VA_ARGS__)
-
-/*
- * Asserts that the library postcondition `_cond` is satisfied.
- *
- * If `_cond` is false, log a fatal message using `_fmt` and the
- * optional arguments (same usage as BT_LIB_LOGF()), and abort.
- *
- * To assert that a library precondition is satisfied (return from user
- * code), use BT_ASSERT_PRE().
- *
- * To assert that an internal precondition or postcondition is
- * satisfied, use BT_ASSERT() or BT_ASSERT_DBG().
- */
-#define BT_ASSERT_POST(_cond, _fmt, ...)                                       \
-       _BT_ASSERT_COND("post", _cond, _fmt, ##__VA_ARGS__)
+#include "assert-cond-base.h"
 
 /*
  * Asserts that a given variable `_obj` named `_obj_name` (capitalized)
        BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(0)
 
 #ifdef BT_DEV_MODE
-/* Developer mode version of BT_ASSERT_PRE(). */
-# define BT_ASSERT_PRE_DEV(_cond, _fmt, ...)                           \
-       BT_ASSERT_PRE((_cond), _fmt, ##__VA_ARGS__)
-
 /* Developer mode version of BT_ASSERT_PRE_NON_NULL() */
 # define BT_ASSERT_PRE_DEV_NON_NULL(_obj, _obj_name)                   \
        BT_ASSERT_PRE_NON_NULL((_obj), (_obj_name))
        BT_ASSERT_PRE_VALID_INDEX((_index), (_length))
 
 /* Developer mode version of BT_ASSERT_PRE_NO_ERROR(). */
-# define BT_ASSERT_PRE_DEV_NO_ERROR() \
+# define BT_ASSERT_PRE_DEV_NO_ERROR()                                  \
        BT_ASSERT_PRE_NO_ERROR()
 
-/* Developer mode version of BT_ASSERT_POST(). */
-# define BT_ASSERT_POST_DEV(_cond, _fmt, ...)                          \
-       BT_ASSERT_POST((_cond), _fmt, ##__VA_ARGS__)
-
 /*
  * Developer mode version of
  * BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS().
  */
-# define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_status) \
+# define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_status)       \
        BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_status)
 
 /* Developer mode version of BT_ASSERT_POST_NO_ERROR(). */
-# define BT_ASSERT_POST_DEV_NO_ERROR() \
+# define BT_ASSERT_POST_DEV_NO_ERROR()                                 \
        BT_ASSERT_POST_NO_ERROR()
 
-/* Developer mode version of BT_ASSERT_COND_MSG(). */
-# define BT_ASSERT_COND_DEV_MSG(_fmt, ...)                             \
-       BT_ASSERT_COND_MSG(_fmt, ##__VA_ARGS__)
-
 /*
  * Marks a function as being only used within a BT_ASSERT_PRE_DEV() or
  * BT_ASSERT_POST_DEV() context.
  */
 # define BT_ASSERT_COND_DEV_FUNC
 #else
-# define BT_ASSERT_COND_DEV_MSG(_fmt, ...)
-# define BT_ASSERT_PRE_DEV(_cond, _fmt, ...)   ((void) sizeof((void) (_cond), 0))
 # define BT_ASSERT_PRE_DEV_NON_NULL(_obj, _obj_name)                   \
        ((void) sizeof((void) (_obj), (void) (_obj_name), 0))
+
 # define BT_ASSERT_PRE_DEV_HOT(_obj, _obj_name, _fmt, ...)             \
        ((void) sizeof((void) (_obj), (void) (_obj_name), 0))
+
 # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length)                        \
        ((void) sizeof((void) (_index), (void) (_length), 0))
+
 # define BT_ASSERT_PRE_DEV_NO_ERROR()
-# define BT_ASSERT_POST_DEV(_cond, _fmt, ...)  ((void) sizeof((void) (_cond), 0))
-# define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_status) \
+
+# define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_status)       \
        ((void) sizeof((void) (_status), 0))
+
 # define BT_ASSERT_POST_DEV_NO_ERROR()
-# define BT_ASSERT_COND_DEV_FUNC       __attribute__((unused))
 #endif /* BT_DEV_MODE */
 
-/*
- * Mark anything that includes this file as supporting precondition and
- * postcondition assertion macros.
- */
-#define BT_ASSERT_COND_SUPPORTED
+#define _BT_ASSERT_PRE_CLK_CLS_NAME    "Clock class"
+
+#define BT_ASSERT_PRE_CLK_CLS_NON_NULL(_cc)                            \
+       BT_ASSERT_PRE_NON_NULL(clock_class, _BT_ASSERT_PRE_CLK_CLS_NAME)
+
+#define BT_ASSERT_PRE_DEV_CLK_CLS_NON_NULL(_cc)                                \
+       BT_ASSERT_PRE_DEV_NON_NULL(clock_class, _BT_ASSERT_PRE_CLK_CLS_NAME)
+
+#define _BT_ASSERT_PRE_DEF_CLK_CLS_NAME        "Default clock class"
+
+#define BT_ASSERT_PRE_DEF_CLK_CLS_NON_NULL(_cc)                                \
+       BT_ASSERT_PRE_NON_NULL(clock_class, _BT_ASSERT_PRE_DEF_CLK_CLS_NAME)
+
+#define BT_ASSERT_PRE_DEV_DEF_CLK_CLS_NON_NULL(_cc)                    \
+       BT_ASSERT_PRE_DEV_NON_NULL(clock_class, _BT_ASSERT_PRE_DEF_CLK_CLS_NAME)
+
+#define _BT_ASSERT_PRE_CS_NAME "Clock snapshot"
+
+#define BT_ASSERT_PRE_CS_NON_NULL(_cs)                                 \
+       BT_ASSERT_PRE_NON_NULL(_cs, _BT_ASSERT_PRE_CS_NAME)
+
+#define BT_ASSERT_PRE_DEV_CS_NON_NULL(_cs)                             \
+       BT_ASSERT_PRE_DEV_NON_NULL(_cs, _BT_ASSERT_PRE_CS_NAME)
+
+#define _BT_ASSERT_PRE_EVENT_NAME      "Event"
+
+#define BT_ASSERT_PRE_EVENT_NON_NULL(_ec)                              \
+       BT_ASSERT_PRE_NON_NULL(_ec, _BT_ASSERT_PRE_EVENT_NAME)
+
+#define BT_ASSERT_PRE_DEV_EVENT_NON_NULL(_ec)                          \
+       BT_ASSERT_PRE_DEV_NON_NULL(_ec, _BT_ASSERT_PRE_EVENT_NAME)
+
+#define _BT_ASSERT_PRE_EC_NAME "Event class"
+
+#define BT_ASSERT_PRE_EC_NON_NULL(_ec)                                 \
+       BT_ASSERT_PRE_NON_NULL(_ec, _BT_ASSERT_PRE_EC_NAME)
+
+#define BT_ASSERT_PRE_DEV_EC_NON_NULL(_ec)                             \
+       BT_ASSERT_PRE_DEV_NON_NULL(_ec, _BT_ASSERT_PRE_EC_NAME)
+
+#define _BT_ASSERT_PRE_FC_IS_INT_COND(_fc)                             \
+       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION)
+
+#define _BT_ASSERT_PRE_FC_IS_INT_FMT(_name)                            \
+       _name " is not an integer field class: %![fc-]+F"
+
+#define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc)                    \
+       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION)
+
+#define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name)                   \
+       _name " is not an unsigned integer field class: %![fc-]+F"
+
+
+#define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc)                      \
+       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION)
+
+#define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name)                     \
+       _name " is not a signed integer field class: %![fc-]+F"
+
+#define _BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc)                            \
+       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION)
+
+#define _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name)                           \
+       _name " is not an enumeration field class: %![fc-]+F"
+
+#define _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc)                           \
+       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD)
+
+#define _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name)                          \
+       _name " is not an array field class: %![fc-]+F"
+
+#define _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc)                          \
+       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
+
+#define _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name)                         \
+       _name " is not an option field class: %![fc-]+F"
+
+#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc)                 \
+       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
+
+#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name)                \
+       _name " is not an option field class with a selector: %![fc-]+F"
+
+#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc)             \
+       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
+
+#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name)            \
+       _name " is not an option field class with an integer selector: %![fc-]+F"
+
+#define _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name)                         \
+       _name " is not a structure field class: %![fc-]+F"
+
+#define _BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc)                          \
+       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STRUCTURE)
+
+#define _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc)                         \
+       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
+
+#define _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name)                                \
+       _name " is not a variant field class: %![fc-]+F"
+
+#define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc)                        \
+       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
+       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
+
+#define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name)               \
+       _name " is not a variant field class with a selector: %![fc-]+F"
+
+#define _BT_ASSERT_PRE_FC_HAS_ID_COND(_fc, _type)                      \
+       (((const struct bt_field_class *) (_fc))->type == (_type))
+
+#define _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name)                            \
+       _name " has the wrong type: expected-type=%s, %![fc-]+F"
+
+#define BT_ASSERT_PRE_FC_IS_INT(_fc, _name)                            \
+       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_INT_COND(_fc),               \
+               _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(_fc, _name)                   \
+       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc),      \
+               _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_SIGNED_INT(_fc, _name)                     \
+       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc),        \
+               _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_ENUM(_fc, _name)                           \
+       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc),              \
+               _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_ARRAY(_fc, _name)                          \
+       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc),             \
+               _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_STRUCT(_fc, _name)                         \
+       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc),            \
+               _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_OPTION(_fc, _name)                         \
+       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc),            \
+               _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL(_fc, _name)                        \
+       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc),   \
+               _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL(_fc, _name)            \
+       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \
+               _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_VARIANT(_fc, _name)                                \
+       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc),           \
+               _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL(_fc, _name)               \
+       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc),  \
+               _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_FC_HAS_ID(_fc, _type, _name)                     \
+       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_HAS_ID_COND((_fc), (_type)),    \
+               _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name),                    \
+               bt_common_field_class_type_string(_type), (_fc))
+
+#define BT_ASSERT_PRE_DEV_FC_IS_INT(_fc, _name)                                \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_INT_COND(_fc),           \
+               _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_DEV_FC_IS_UNSIGNED_INT(_fc, _name)               \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc),  \
+               _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_DEV_FC_IS_SIGNED_INT(_fc, _name)                 \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc),    \
+               _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_DEV_FC_IS_ENUM(_fc, _name)                       \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc),          \
+               _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_DEV_FC_IS_ARRAY(_fc, _name)                      \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc),         \
+               _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_DEV_FC_IS_STRUCT(_fc, _name)                     \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc),        \
+               _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_DEV_FC_IS_OPTION(_fc, _name)                     \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc),        \
+               _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_SEL(_fc, _name)            \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \
+               _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_INT_SEL(_fc, _name)                \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \
+               _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_DEV_FC_IS_VARIANT(_fc, _name)                    \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc),       \
+               _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_DEV_FC_IS_VARIANT_WITH_SEL(_fc, _name)           \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc), \
+               _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc))
+
+#define BT_ASSERT_PRE_DEV_FC_HAS_ID(_fc, _type, _name)                 \
+       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_HAS_ID_COND((_fc), (_type)), \
+               _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name),                    \
+               bt_common_field_class_type_string(_type), (_fc))
+
+#define BT_ASSERT_PRE_DEV_FC_HOT(_fc, _name)                           \
+       BT_ASSERT_PRE_DEV_HOT((const struct bt_field_class *) (_fc),    \
+               (_name), ": %!+F", (_fc))
+
+#define _BT_ASSERT_PRE_FC_NAME "Field class"
+
+#define BT_ASSERT_PRE_FC_NON_NULL(_fc)                                 \
+       BT_ASSERT_PRE_NON_NULL(_fc, _BT_ASSERT_PRE_FC_NAME)
+
+#define BT_ASSERT_PRE_DEV_FC_NON_NULL(_fc)                             \
+       BT_ASSERT_PRE_DEV_NON_NULL(_fc, _BT_ASSERT_PRE_FC_NAME)
+
+#define _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME   "Structure field class member"
+
+#define BT_ASSERT_PRE_STRUCT_FC_MEMBER_NON_NULL(_fc)                   \
+       BT_ASSERT_PRE_NON_NULL(_fc, _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME)
+
+#define BT_ASSERT_PRE_DEV_STRUCT_FC_MEMBER_NON_NULL(_fc)               \
+       BT_ASSERT_PRE_DEV_NON_NULL(_fc, _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME)
+
+#define _BT_ASSERT_PRE_VAR_FC_OPT_NAME "Variant field class option"
+
+#define BT_ASSERT_PRE_VAR_FC_OPT_NON_NULL(_fc)                         \
+       BT_ASSERT_PRE_NON_NULL(_fc, _BT_ASSERT_PRE_VAR_FC_OPT_NAME)
+
+#define BT_ASSERT_PRE_DEV_VAR_FC_OPT_NON_NULL(_fc)                     \
+       BT_ASSERT_PRE_DEV_NON_NULL(_fc, _BT_ASSERT_PRE_VAR_FC_OPT_NAME)
+
+#define _BT_ASSERT_PRE_FP_NAME "Field path"
+
+#define BT_ASSERT_PRE_FP_NON_NULL(_fp)                                 \
+       BT_ASSERT_PRE_NON_NULL(_fp, _BT_ASSERT_PRE_FP_NAME)
+
+#define BT_ASSERT_PRE_DEV_FP_NON_NULL(_fp)                             \
+       BT_ASSERT_PRE_DEV_NON_NULL(_fp, _BT_ASSERT_PRE_FP_NAME)
+
+#define BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(_field, _cls_type, _name) \
+       BT_ASSERT_PRE_DEV(((const struct bt_field *) (_field))->class->type == (_cls_type), \
+               _name " has the wrong class type: expected-class-type=%s, " \
+               "%![field-]+f",                                         \
+               bt_common_field_class_type_string(_cls_type), (_field))
+
+#define BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(_field, _name)         \
+       BT_ASSERT_PRE_DEV(                                              \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, \
+               _name " is not an unsigned integer field: %![field-]+f", \
+               (_field))
+
+#define BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(_field, _name)           \
+       BT_ASSERT_PRE_DEV(                                              \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, \
+               _name " is not a signed integer field: %![field-]+f",   \
+               (_field))
+
+#define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(_field, _name)                        \
+       BT_ASSERT_PRE_DEV(                                              \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \
+               _name " is not an array field: %![field-]+f", (_field))
+
+#define BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(_field, _name)                \
+       BT_ASSERT_PRE_DEV(                                              \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \
+               _name " is not a dynamic array field: %![field-]+f", (_field))
+
+#define BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(_field, _name)               \
+       BT_ASSERT_PRE_DEV(                                              \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD, \
+               _name " is not an option field: %![field-]+f", (_field))
+
+#define BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(_field, _name)              \
+       BT_ASSERT_PRE_DEV(                                              \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD, \
+               _name " is not a variant field: %![field-]+f", (_field))
+
+#define BT_ASSERT_PRE_DEV_FIELD_IS_SET(_field, _name)                  \
+       BT_ASSERT_PRE_DEV(bt_field_is_set(_field),                      \
+               _name " is not set: %!+f", (_field))
+
+#define _BT_ASSERT_PRE_FIELD_NAME      "Field"
+
+#define BT_ASSERT_PRE_FIELD_NON_NULL(_field)                           \
+       BT_ASSERT_PRE_NON_NULL(_field, _BT_ASSERT_PRE_FIELD_NAME)
+
+#define BT_ASSERT_PRE_DEV_FIELD_NON_NULL(_field)                       \
+       BT_ASSERT_PRE_DEV_NON_NULL(_field, _BT_ASSERT_PRE_FIELD_NAME)
+
+#define _BT_ASSERT_PRE_PACKET_NAME     "Packet"
+
+#define BT_ASSERT_PRE_PACKET_NON_NULL(_packet)                         \
+       BT_ASSERT_PRE_NON_NULL(_packet, _BT_ASSERT_PRE_PACKET_NAME)
+
+#define BT_ASSERT_PRE_DEV_PACKET_NON_NULL(_packet)                     \
+       BT_ASSERT_PRE_DEV_NON_NULL(_packet, _BT_ASSERT_PRE_PACKET_NAME)
+
+#define _BT_ASSERT_PRE_SC_NAME "Stream class"
+
+#define BT_ASSERT_PRE_SC_NON_NULL(_sc)                                 \
+       BT_ASSERT_PRE_NON_NULL(_sc, _BT_ASSERT_PRE_SC_NAME)
+
+#define BT_ASSERT_PRE_DEV_SC_NON_NULL(_sc)                             \
+       BT_ASSERT_PRE_DEV_NON_NULL(_sc, _BT_ASSERT_PRE_SC_NAME)
+
+#define _BT_ASSERT_PRE_STREAM_NAME     "Stream"
+
+#define BT_ASSERT_PRE_STREAM_NON_NULL(_stream)                         \
+       BT_ASSERT_PRE_NON_NULL(_stream, _BT_ASSERT_PRE_STREAM_NAME)
+
+#define BT_ASSERT_PRE_DEV_STREAM_NON_NULL(_stream)                     \
+       BT_ASSERT_PRE_DEV_NON_NULL(_stream, _BT_ASSERT_PRE_STREAM_NAME)
+
+#define _BT_ASSERT_PRE_TC_NAME "Trace class"
+
+#define BT_ASSERT_PRE_TC_NON_NULL(_tc)                                 \
+       BT_ASSERT_PRE_NON_NULL(_tc, _BT_ASSERT_PRE_TC_NAME)
+
+#define BT_ASSERT_PRE_DEV_TC_NON_NULL(_tc)                             \
+       BT_ASSERT_PRE_DEV_NON_NULL(_tc, _BT_ASSERT_PRE_TC_NAME)
+
+#define _BT_ASSERT_PRE_TRACE_NAME      "Trace"
+
+#define BT_ASSERT_PRE_TRACE_NON_NULL(_trace)                           \
+       BT_ASSERT_PRE_NON_NULL(_trace, _BT_ASSERT_PRE_TRACE_NAME)
+
+#define BT_ASSERT_PRE_DEV_TRACE_NON_NULL(_trace)                       \
+       BT_ASSERT_PRE_DEV_NON_NULL(_trace, _BT_ASSERT_PRE_TRACE_NAME)
+
+#define _BT_ASSERT_PRE_USER_ATTRS_NAME "User attributes"
+
+#define BT_ASSERT_PRE_USER_ATTRS_NON_NULL(_ua)                         \
+       BT_ASSERT_PRE_NON_NULL(_ua, _BT_ASSERT_PRE_USER_ATTRS_NAME)
+
+#define BT_ASSERT_PRE_DEV_USER_ATTRS_NON_NULL(_ua)                     \
+       BT_ASSERT_PRE_DEV_NON_NULL(_ua, _BT_ASSERT_PRE_USER_ATTRS_NAME)
+
+#define BT_ASSERT_PRE_USER_ATTRS_IS_MAP(_ua)                           \
+       BT_ASSERT_PRE((_ua)->type == BT_VALUE_TYPE_MAP,                 \
+               _BT_ASSERT_PRE_USER_ATTRS_NAME                          \
+               " object is not a map value object.")
+
+#define BT_ASSERT_COND_LISTENER_FUNC_NAME      "Listener function"
+
+#define BT_ASSERT_PRE_LISTENER_FUNC_NON_NULL(_func)                    \
+       BT_ASSERT_PRE_NON_NULL(_func, BT_ASSERT_COND_LISTENER_FUNC_NAME)
+
+#define BT_ASSERT_PRE_DEV_LISTENER_FUNC_NON_NULL(_func)                        \
+       BT_ASSERT_PRE_DEV_NON_NULL(_func, BT_ASSERT_COND_LISTENER_FUNC_NAME)
+
+#define _BT_ASSERT_PRE_MSG_ITER_NAME   "Message iterator"
+
+#define BT_ASSERT_PRE_MSG_ITER_NON_NULL(_msg_iter)                     \
+       BT_ASSERT_PRE_NON_NULL(_msg_iter, _BT_ASSERT_PRE_MSG_ITER_NAME)
+
+#define BT_ASSERT_PRE_DEV_MSG_ITER_NON_NULL(_msg_iter)                 \
+       BT_ASSERT_PRE_DEV_NON_NULL(_msg_iter, _BT_ASSERT_PRE_MSG_ITER_NAME)
+
+#define BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS(_msg, _sc)                        \
+       BT_ASSERT_PRE_DEV((_sc)->default_clock_class,                   \
+               "Message's stream's class has no default clock class: " \
+               "%![msg-]+n, %![sc-]+S", (_msg), (_sc));
+
+#define _BT_ASSERT_PRE_MSG_IS_TYPE_COND(_msg, _type)                   \
+       (((struct bt_message *) (_msg))->type == (_type))
+
+#define _BT_ASSERT_PRE_MSG_IS_TYPE_FMT                                 \
+       "Message has the wrong type: expected-type=%s, %![msg-]+n"
+
+#define BT_ASSERT_PRE_MSG_IS_TYPE(_msg, _type)                         \
+       BT_ASSERT_PRE(                                                  \
+               _BT_ASSERT_PRE_MSG_IS_TYPE_COND((_msg), (_type)),       \
+               _BT_ASSERT_PRE_MSG_IS_TYPE_FMT,                         \
+               bt_message_type_string(_type), (_msg))
+
+#define BT_ASSERT_PRE_DEV_MSG_IS_TYPE(_msg, _type)                     \
+       BT_ASSERT_PRE_DEV(                                              \
+               _BT_ASSERT_PRE_MSG_IS_TYPE_COND((_msg), (_type)),       \
+               _BT_ASSERT_PRE_MSG_IS_TYPE_FMT,                         \
+               bt_message_type_string(_type), (_msg))
+
+#define _BT_ASSERT_PRE_MSG_NAME        "Message"
+
+#define BT_ASSERT_PRE_MSG_NON_NULL(_msg_iter)                          \
+       BT_ASSERT_PRE_NON_NULL(_msg_iter, _BT_ASSERT_PRE_MSG_NAME)
+
+#define BT_ASSERT_PRE_DEV_MSG_NON_NULL(_msg_iter)                      \
+       BT_ASSERT_PRE_DEV_NON_NULL(_msg_iter, _BT_ASSERT_PRE_MSG_NAME)
+
+#define BT_ASSERT_PRE_BEGIN_LE_END(_msg_iter, _begin, _end)            \
+       BT_ASSERT_PRE(                                                  \
+               _begin <= _end,                                         \
+               "Beginning default clock snapshot value is greater "    \
+               "than end default clock snapshot value: "               \
+               "cs-begin-val=%" PRIu64 ", cs-end-val=%" PRIu64 ", "    \
+               "%![msg-iter-]+i",                                      \
+               _begin, _end, _msg_iter);
+
+#define BT_ASSERT_PRE_DEV_MSG_HOT(_msg)                                        \
+       BT_ASSERT_PRE_DEV_HOT((_msg), "Message", ": %!+n", (_msg));
+
+#define _BT_ASSERT_PRE_MSG_ITER_CLS_NAME       "Message iterator class"
+
+#define BT_ASSERT_PRE_MSG_ITER_CLS_NON_NULL(_msg_iter_cls)             \
+       BT_ASSERT_PRE_NON_NULL(_msg_iter_cls, _BT_ASSERT_PRE_MSG_ITER_CLS_NAME)
+
+#define BT_ASSERT_PRE_DEV_MSG_ITER_CLS_NON_NULL(_msg_iter_cls)         \
+       BT_ASSERT_PRE_DEV_NON_NULL(_msg_iter_cls, _BT_ASSERT_PRE_MSG_ITER_CLS_NAME)
+
+#define _BT_ASSERT_PRE_COMP_CLS_NAME   "Component class"
+
+#define BT_ASSERT_PRE_COMP_CLS_NON_NULL(_comp_cls)                     \
+       BT_ASSERT_PRE_NON_NULL(_comp_cls, _BT_ASSERT_PRE_COMP_CLS_NAME)
+
+#define BT_ASSERT_PRE_DEV_COMP_CLS_NON_NULL(_comp_cls)                 \
+       BT_ASSERT_PRE_DEV_NON_NULL(_comp_cls, _BT_ASSERT_PRE_COMP_CLS_NAME)
+
+#define _BT_ASSERT_PRE_COMP_DESCR_SET_NAME     "Component descriptor set"
+
+#define BT_ASSERT_PRE_COMP_DESCR_SET_NON_NULL(_comp_descr_set)         \
+       BT_ASSERT_PRE_NON_NULL(_comp_descr_set, _BT_ASSERT_PRE_COMP_DESCR_SET_NAME)
+
+#define BT_ASSERT_PRE_DEV_COMP_DESCR_SET_NON_NULL(_comp_descr_set)     \
+       BT_ASSERT_PRE_DEV_NON_NULL(_comp_descr_set, _BT_ASSERT_PRE_COMP_DESCR_SET_NAME)
+
+#define _BT_ASSERT_PRE_COMP_NAME       "Component"
+
+#define BT_ASSERT_PRE_COMP_NON_NULL(_comp)                             \
+       BT_ASSERT_PRE_NON_NULL(_comp, _BT_ASSERT_PRE_COMP_NAME)
+
+#define BT_ASSERT_PRE_DEV_COMP_NON_NULL(_comp)                         \
+       BT_ASSERT_PRE_DEV_NON_NULL(_comp, _BT_ASSERT_PRE_COMP_NAME)
+
+#define _BT_ASSERT_PRE_CONN_NAME       "Connection"
+
+#define BT_ASSERT_PRE_CONN_NON_NULL(_conn)                             \
+       BT_ASSERT_PRE_NON_NULL(_conn, _BT_ASSERT_PRE_CONN_NAME)
+
+#define BT_ASSERT_PRE_DEV_CONN_NON_NULL(_conn)                         \
+       BT_ASSERT_PRE_DEV_NON_NULL(_conn, _BT_ASSERT_PRE_CONN_NAME)
+
+#define _BT_ASSERT_PRE_GRAPH_NAME      "Graph"
+
+#define BT_ASSERT_PRE_GRAPH_NON_NULL(_graph)                           \
+       BT_ASSERT_PRE_NON_NULL(_graph, _BT_ASSERT_PRE_GRAPH_NAME)
+
+#define BT_ASSERT_PRE_DEV_GRAPH_NON_NULL(_graph)                       \
+       BT_ASSERT_PRE_DEV_NON_NULL(_graph, _BT_ASSERT_PRE_GRAPH_NAME)
+
+#define _BT_ASSERT_PRE_INTR_NAME       "Interrupter"
+
+#define BT_ASSERT_PRE_INTR_NON_NULL(_intr)                             \
+       BT_ASSERT_PRE_NON_NULL(_intr, _BT_ASSERT_PRE_INTR_NAME)
+
+#define BT_ASSERT_PRE_DEV_INTR_NON_NULL(_intr)                         \
+       BT_ASSERT_PRE_DEV_NON_NULL(_intr, _BT_ASSERT_PRE_INTR_NAME)
+
+#define _BT_ASSERT_PRE_PORT_NAME       "Port"
+
+#define BT_ASSERT_PRE_PORT_NON_NULL(_port)                             \
+       BT_ASSERT_PRE_NON_NULL(_port, _BT_ASSERT_PRE_PORT_NAME)
+
+#define BT_ASSERT_PRE_DEV_PORT_NON_NULL(_port)                         \
+       BT_ASSERT_PRE_DEV_NON_NULL(_port, _BT_ASSERT_PRE_PORT_NAME)
+
+#define _BT_ASSERT_PRE_QUERY_EXEC_NAME "Query executor"
+
+#define BT_ASSERT_PRE_QUERY_EXEC_NON_NULL(_query_exec)                 \
+       BT_ASSERT_PRE_NON_NULL(_query_exec, _BT_ASSERT_PRE_QUERY_EXEC_NAME)
+
+#define BT_ASSERT_PRE_DEV_QUERY_EXEC_NON_NULL(_query_exec)             \
+       BT_ASSERT_PRE_DEV_NON_NULL(_query_exec, _BT_ASSERT_PRE_QUERY_EXEC_NAME)
+
+#define _BT_ASSERT_PRE_PLUGIN_SET_NAME "Plugin set"
+
+#define BT_ASSERT_PRE_PLUGIN_SET_NON_NULL(_plugin_set)                 \
+       BT_ASSERT_PRE_NON_NULL(_plugin_set, _BT_ASSERT_PRE_PLUGIN_SET_NAME)
+
+#define BT_ASSERT_PRE_DEV_PLUGIN_SET_NON_NULL(_plugin_set)             \
+       BT_ASSERT_PRE_DEV_NON_NULL(_plugin_set, _BT_ASSERT_PRE_PLUGIN_SET_NAME)
+
+#define _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME                             \
+       _BT_ASSERT_PRE_PLUGIN_SET_NAME " (output)"
+
+#define BT_ASSERT_PRE_PLUGIN_SET_OUT_NON_NULL(_plugin_set)             \
+       BT_ASSERT_PRE_NON_NULL(_plugin_set, _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME)
+
+#define BT_ASSERT_PRE_DEV_PLUGIN_SET_OUT_NON_NULL(_plugin_set)         \
+       BT_ASSERT_PRE_DEV_NON_NULL(_plugin_set, _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME)
+
+#define _BT_ASSERT_PRE_PLUGIN_NAME     "Plugin"
+
+#define BT_ASSERT_PRE_PLUGIN_NON_NULL(_plugin)                         \
+       BT_ASSERT_PRE_NON_NULL(_plugin, _BT_ASSERT_PRE_PLUGIN_NAME)
+
+#define BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(_plugin)                     \
+       BT_ASSERT_PRE_DEV_NON_NULL(_plugin, _BT_ASSERT_PRE_PLUGIN_NAME)
+
+#define _BT_ASSERT_PRE_PLUGIN_OUT_NAME                                 \
+       _BT_ASSERT_PRE_PLUGIN_NAME " (output)"
+
+#define BT_ASSERT_PRE_PLUGIN_OUT_NON_NULL(_plugin)                     \
+       BT_ASSERT_PRE_NON_NULL(_plugin, _BT_ASSERT_PRE_PLUGIN_OUT_NAME)
+
+#define BT_ASSERT_PRE_DEV_PLUGIN_OUT_NON_NULL(_plugin)                 \
+       BT_ASSERT_PRE_DEV_NON_NULL(_plugin, _BT_ASSERT_PRE_PLUGIN_OUT_NAME)
+
+#define _BT_ASSERT_PRE_ERROR_NAME      "Error"
+
+#define BT_ASSERT_PRE_ERROR_NON_NULL(_error)                           \
+       BT_ASSERT_PRE_NON_NULL(_error, _BT_ASSERT_PRE_ERROR_NAME)
+
+#define BT_ASSERT_PRE_DEV_ERROR_NON_NULL(_error)                       \
+       BT_ASSERT_PRE_DEV_NON_NULL(_error, _BT_ASSERT_PRE_ERROR_NAME)
+
+#define _BT_ASSERT_PRE_ERROR_CAUSE_NAME        "Error cause"
+
+#define BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(_error_cause)               \
+       BT_ASSERT_PRE_NON_NULL(_error_cause, _BT_ASSERT_PRE_ERROR_CAUSE_NAME)
+
+#define BT_ASSERT_PRE_DEV_ERROR_CAUSE_NON_NULL(_error_cause)           \
+       BT_ASSERT_PRE_DEV_NON_NULL(_error_cause, _BT_ASSERT_PRE_ERROR_CAUSE_NAME)
+
+#define _BT_ASSERT_PRE_INT_RANGE_NAME  "Integer range"
+
+#define BT_ASSERT_PRE_INT_RANGE_NON_NULL(_int_range)                   \
+       BT_ASSERT_PRE_NON_NULL(_int_range, _BT_ASSERT_PRE_INT_RANGE_NAME)
+
+#define BT_ASSERT_PRE_DEV_INT_RANGE_NON_NULL(_int_range)               \
+       BT_ASSERT_PRE_DEV_NON_NULL(_int_range, _BT_ASSERT_PRE_INT_RANGE_NAME)
+
+#define _BT_ASSERT_PRE_INT_RANGE_SET_NAME      "Integer range set"
+
+#define BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL(_int_range_set)           \
+       BT_ASSERT_PRE_NON_NULL(_int_range_set, _BT_ASSERT_PRE_INT_RANGE_SET_NAME)
+
+#define BT_ASSERT_PRE_DEV_INT_RANGE_SET_NON_NULL(_int_range_set)       \
+       BT_ASSERT_PRE_DEV_NON_NULL(_int_range_set, _BT_ASSERT_PRE_INT_RANGE_SET_NAME)
+
+#define _BT_ASSERT_PRE_VALUE_IS_TYPE_COND(_value, _type)               \
+       (((struct bt_value *) (_value))->type == (_type))
+
+#define _BT_ASSERT_PRE_VALUE_IS_TYPE_FMT                               \
+       "Value has the wrong type: expected-type=%s, %![value-]+v"
+
+#define BT_ASSERT_PRE_VALUE_IS_TYPE(_value, _type)                     \
+       BT_ASSERT_PRE(                                                  \
+               _BT_ASSERT_PRE_VALUE_IS_TYPE_COND((_value), (_type)),   \
+               _BT_ASSERT_PRE_VALUE_IS_TYPE_FMT,                       \
+               bt_common_value_type_string(_type), (_value))
+
+#define BT_ASSERT_PRE_DEV_VALUE_IS_TYPE(_value, _type)                 \
+       BT_ASSERT_PRE_DEV(                                              \
+               _BT_ASSERT_PRE_VALUE_IS_TYPE_COND((_value), (_type)),   \
+               _BT_ASSERT_PRE_VALUE_IS_TYPE_FMT,                       \
+               bt_common_value_type_string(_type), (_value))
+
+#define _BT_ASSERT_PRE_VALUE_NAME      "Value object"
+
+#define BT_ASSERT_PRE_VALUE_NON_NULL(_value)                           \
+       BT_ASSERT_PRE_NON_NULL(_value, _BT_ASSERT_PRE_VALUE_NAME)
+
+#define BT_ASSERT_PRE_DEV_VALUE_NON_NULL(_value)                       \
+       BT_ASSERT_PRE_DEV_NON_NULL(_value, _BT_ASSERT_PRE_VALUE_NAME)
+
+#define BT_ASSERT_PRE_PARAM_VALUE_IS_MAP(_value)                       \
+       BT_ASSERT_PRE(!(_value) || bt_value_is_map(_value),             \
+               "Parameter value is not a map value: %!+v", (_value));
+
+#define _BT_ASSERT_PRE_RES_OUT_NAME    "Result (output)"
+
+#define BT_ASSERT_PRE_RES_OUT_NON_NULL(_res)                           \
+       BT_ASSERT_PRE_NON_NULL(_res, _BT_ASSERT_PRE_RES_OUT_NAME)
+
+#define BT_ASSERT_PRE_DEV_RES_OUT_NON_NULL(_res)                       \
+       BT_ASSERT_PRE_DEV_NON_NULL(_res, _BT_ASSERT_PRE_RES_OUT_NAME)
+
+#define BT_ASSERT_PRE_METHOD_NON_NULL(_method)                         \
+       BT_ASSERT_PRE_NON_NULL(_method, "Method");
+
+#define _BT_ASSERT_PRE_NAME_NAME       "Name"
+
+#define BT_ASSERT_PRE_NAME_NON_NULL(_name)                             \
+       BT_ASSERT_PRE_NON_NULL(_name, _BT_ASSERT_PRE_NAME_NAME)
+
+#define BT_ASSERT_PRE_DEV_NAME_NON_NULL(_name)                         \
+       BT_ASSERT_PRE_DEV_NON_NULL(_name, _BT_ASSERT_PRE_NAME_NAME)
+
+#define _BT_ASSERT_PRE_DESCR_NAME      "Description"
+
+#define BT_ASSERT_PRE_DESCR_NON_NULL(_descr)                           \
+       BT_ASSERT_PRE_NON_NULL(_descr, _BT_ASSERT_PRE_DESCR_NAME)
+
+#define BT_ASSERT_PRE_DEV_DESCR_NON_NULL(_descr)                       \
+       BT_ASSERT_PRE_DEV_NON_NULL(_descr, _BT_ASSERT_PRE_DESCR_NAME)
+
+#define _BT_ASSERT_PRE_UUID_NAME       "UUID"
+
+#define BT_ASSERT_PRE_UUID_NON_NULL(_uuid)                             \
+       BT_ASSERT_PRE_NON_NULL(_uuid, _BT_ASSERT_PRE_UUID_NAME)
+
+#define BT_ASSERT_PRE_DEV_UUID_NON_NULL(_uuid)                         \
+       BT_ASSERT_PRE_DEV_NON_NULL(_uuid, _BT_ASSERT_PRE_UUID_NAME)
+
+#define _BT_ASSERT_PRE_KEY_NAME        "Key"
+
+#define BT_ASSERT_PRE_KEY_NON_NULL(_key)                               \
+       BT_ASSERT_PRE_NON_NULL(_key, _BT_ASSERT_PRE_KEY_NAME)
+
+#define BT_ASSERT_PRE_DEV_KEY_NON_NULL(_key)                           \
+       BT_ASSERT_PRE_DEV_NON_NULL(_key, _BT_ASSERT_PRE_KEY_NAME)
 
 #endif /* BABELTRACE_ASSERT_COND_INTERNAL_H */
index efd211296f5098357c1c5e97319bf9dfc89ae3f2..8a707170c3fb02b2e54849ead00b03d7e2b9a235 100644 (file)
@@ -39,33 +39,6 @@ struct bt_message {
        struct bt_graph *graph;
 };
 
-#define _BT_ASSERT_PRE_MSG_IS_TYPE_COND(_msg, _type)                   \
-       (((struct bt_message *) (_msg))->type == (_type))
-
-#define _BT_ASSERT_PRE_MSG_IS_TYPE_FMT                                 \
-       "Message has the wrong type: expected-type=%s, %![msg-]+n"
-
-#define BT_ASSERT_PRE_MSG_IS_TYPE(_msg, _type)                         \
-       BT_ASSERT_PRE(                                                  \
-               _BT_ASSERT_PRE_MSG_IS_TYPE_COND((_msg), (_type)),       \
-               _BT_ASSERT_PRE_MSG_IS_TYPE_FMT,                         \
-               bt_message_type_string(_type), (_msg))
-
-#define BT_ASSERT_PRE_DEV_MSG_IS_TYPE(_msg, _type)                     \
-       BT_ASSERT_PRE_DEV(                                              \
-               _BT_ASSERT_PRE_MSG_IS_TYPE_COND((_msg), (_type)),       \
-               _BT_ASSERT_PRE_MSG_IS_TYPE_FMT,                         \
-               bt_message_type_string(_type), (_msg))
-
-#define BT_ASSERT_PRE_BEGIN_LE_END(_msg_iter, _begin, _end)            \
-       BT_ASSERT_PRE(                                                  \
-               _begin <= _end,                                         \
-               "Beginning default clock snapshot value is greater "    \
-               "than end default clock snapshot value: "               \
-               "cs-begin-val=%" PRIu64 ", cs-end-val=%" PRIu64 ", "    \
-               "%![msg-iter-]i",                                       \
-               _begin, _end, _msg_iter);
-
 BT_HIDDEN
 void bt_message_init(struct bt_message *message,
                enum bt_message_type type,
index 1cd14e39aa247d1c023b4fa75d0863bc85be224d..464dd286c98e23e2a4dba8f80ff0a629e26ca560 100644 (file)
 #include <stdint.h>
 #include <glib.h>
 
-#define _BT_ASSERT_PRE_FC_IS_INT_COND(_fc)                             \
-       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION)
-
-#define _BT_ASSERT_PRE_FC_IS_INT_FMT(_name)                            \
-       _name " is not an integer field class: %![fc-]+F"
-
-#define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc)                    \
-       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION)
-
-#define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name)                   \
-       _name " is not an unsigned integer field class: %![fc-]+F"
-
-
-#define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc)                      \
-       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION)
-
-#define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name)                     \
-       _name " is not a signed integer field class: %![fc-]+F"
-
-#define _BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc)                            \
-       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION)
-
-#define _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name)                           \
-       _name " is not an enumeration field class: %![fc-]+F"
-
-#define _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc)                           \
-       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD)
-
-#define _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name)                          \
-       _name " is not an array field class: %![fc-]+F"
-
-#define _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc)                          \
-       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
-
-#define _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name)                         \
-       _name " is not an option field class: %![fc-]+F"
-
-#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc)                 \
-       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
-
-#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name)                \
-       _name " is not an option field class with a selector: %![fc-]+F"
-
-#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc)             \
-       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
-
-#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name)            \
-       _name " is not an option field class with an integer selector: %![fc-]+F"
-
-#define _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc)                         \
-       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
-
-#define _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name)                                \
-       _name " is not a variant field class: %![fc-]+F"
-
-#define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc)                        \
-       (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
-       ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
-
-#define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name)               \
-       _name " is not a variant field class with a selector: %![fc-]+F"
-
-#define _BT_ASSERT_PRE_FC_HAS_ID_COND(_fc, _type)                      \
-       (((const struct bt_field_class *) (_fc))->type == (_type))
-
-#define _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name)                            \
-       _name " has the wrong type: expected-type=%s, %![fc-]+F"
-
-#define BT_ASSERT_PRE_FC_IS_INT(_fc, _name)                            \
-       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_INT_COND(_fc),               \
-               _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(_fc, _name)                   \
-       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc),      \
-               _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_FC_IS_SIGNED_INT(_fc, _name)                     \
-       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc),        \
-               _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_FC_IS_ENUM(_fc, _name)                           \
-       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc),              \
-               _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_FC_IS_ARRAY(_fc, _name)                          \
-       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc),             \
-               _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_FC_IS_OPTION(_fc, _name)                         \
-       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc),            \
-               _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL(_fc, _name)                        \
-       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc),   \
-               _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL(_fc, _name)            \
-       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \
-               _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_FC_IS_VARIANT(_fc, _name)                                \
-       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc),           \
-               _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL(_fc, _name)               \
-       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc),  \
-               _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_FC_HAS_ID(_fc, _type, _name)                     \
-       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_HAS_ID_COND((_fc), (_type)),    \
-               _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name),                    \
-               bt_common_field_class_type_string(_type), (_fc))
-
-#define BT_ASSERT_PRE_DEV_FC_IS_INT(_fc, _name)                                \
-       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_INT_COND(_fc),           \
-               _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_DEV_FC_IS_UNSIGNED_INT(_fc, _name)               \
-       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc),  \
-               _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_DEV_FC_IS_SIGNED_INT(_fc, _name)                 \
-       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc),    \
-               _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_DEV_FC_IS_ENUM(_fc, _name)                       \
-       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc),          \
-               _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_DEV_FC_IS_ARRAY(_fc, _name)                      \
-       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc),         \
-               _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_DEV_FC_IS_OPTION(_fc, _name)                     \
-       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc),        \
-               _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_SEL(_fc, _name)            \
-       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \
-               _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_INT_SEL(_fc, _name)                \
-       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \
-               _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_DEV_FC_IS_VARIANT(_fc, _name)                    \
-       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc),       \
-               _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_DEV_FC_IS_VARIANT_WITH_SEL(_fc, _name)           \
-       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc), \
-               _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc))
-
-#define BT_ASSERT_PRE_DEV_FC_HAS_ID(_fc, _type, _name)                 \
-       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_HAS_ID_COND((_fc), (_type)), \
-               _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name),                    \
-               bt_common_field_class_type_string(_type), (_fc))
-
-#define BT_ASSERT_PRE_DEV_FC_HOT(_fc, _name)                           \
-       BT_ASSERT_PRE_DEV_HOT((const struct bt_field_class *) (_fc),    \
-               (_name), ": %!+F", (_fc))
-
 #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)))
index 37e6731ecd4b35d31bde09beb073118bb7683472..6e513d4158d7756b413fc7f1582e2e1608816c88 100644 (file)
 #include "field-class.h"
 #include "lib/func-status.h"
 
+#define BT_ASSERT_PRE_DEV_FIELD_HOT(_field, _name)                     \
+       BT_ASSERT_PRE_DEV_HOT((const struct bt_field *) (_field), (_name), \
+               ": %!+f", (_field))
+
 static
 void reset_single_field(struct bt_field *field);
 
index 7262f827b576254c329cc5a66e07a7a586cf41dc..df303b662e379993eec73b6c923c49d4fa5a5acc 100644 (file)
 #include "field-class.h"
 #include "utils.h"
 
-#define BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(_field, _cls_type, _name) \
-       BT_ASSERT_PRE_DEV(((const struct bt_field *) (_field))->class->type == (_cls_type), \
-               _name " has the wrong class type: expected-class-type=%s, " \
-               "%![field-]+f",                                         \
-               bt_common_field_class_type_string(_cls_type), (_field))
-
-#define BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(_field, _name)         \
-       BT_ASSERT_PRE_DEV(                                              \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, \
-               _name " is not an unsigned integer field: %![field-]+f", \
-               (_field))
-
-#define BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(_field, _name)           \
-       BT_ASSERT_PRE_DEV(                                              \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, \
-               _name " is not a signed integer field: %![field-]+f",   \
-               (_field))
-
-#define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(_field, _name)                        \
-       BT_ASSERT_PRE_DEV(                                              \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \
-               _name " is not an array field: %![field-]+f", (_field))
-
-#define BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(_field, _name)                        \
-       BT_ASSERT_PRE_DEV(                                              \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \
-               _name " is not a dynamic array field: %![field-]+f", (_field))
-
-#define BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(_field, _name)               \
-       BT_ASSERT_PRE_DEV(                                              \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD, \
-               _name " is not an option field: %![field-]+f", (_field))
-
-#define BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(_field, _name)              \
-       BT_ASSERT_PRE_DEV(                                              \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
-               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD, \
-               _name " is not a variant field: %![field-]+f", (_field))
-
-#define BT_ASSERT_PRE_DEV_FIELD_IS_SET(_field, _name)                  \
-       BT_ASSERT_PRE_DEV(bt_field_is_set(_field),                      \
-               _name " is not set: %!+f", (_field))
-
-#define BT_ASSERT_PRE_DEV_FIELD_HOT(_field, _name)                     \
-       BT_ASSERT_PRE_DEV_HOT((const struct bt_field *) (_field), (_name), \
-               ": %!+f", (_field))
-
 struct bt_field;
 
 typedef struct bt_field *(* bt_field_create_func)(struct bt_field_class *);
index f533aba35d6710139a8b5e80d7dc235d91f60683..fbdb9f5a2b439caf54f82c052d89b61076cdcd99 100644 (file)
 #include "common/assert.h"
 #include "func-status.h"
 
+#define BT_ASSERT_PRE_DEV_VALUE_HOT(_value, _name)                     \
+       BT_ASSERT_PRE_DEV_HOT(((struct bt_value *) (_value)), (_name),  \
+               ": %!+v", (_value))
+
 #define BT_VALUE_TO_BOOL(_base) ((struct bt_value_bool *) (_base))
 #define BT_VALUE_TO_INTEGER(_base) ((struct bt_value_integer *) (_base))
 #define BT_VALUE_TO_REAL(_base) ((struct bt_value_real *) (_base))
 #define BT_VALUE_TO_ARRAY(_base) ((struct bt_value_array *) (_base))
 #define BT_VALUE_TO_MAP(_base) ((struct bt_value_map *) (_base))
 
-#define _BT_ASSERT_PRE_VALUE_IS_TYPE_COND(_value, _type)               \
-       (((struct bt_value *) (_value))->type == (_type))
-
-#define _BT_ASSERT_PRE_VALUE_IS_TYPE_FMT                               \
-       "Value has the wrong type ID: expected-type=%s, %![value-]+v"
-
-#define BT_ASSERT_PRE_VALUE_IS_TYPE(_value, _type)                     \
-       BT_ASSERT_PRE(                                                  \
-               _BT_ASSERT_PRE_VALUE_IS_TYPE_COND((_value), (_type)),   \
-               _BT_ASSERT_PRE_VALUE_IS_TYPE_FMT,                       \
-               bt_common_value_type_string(_type), (_value))
-
-#define BT_ASSERT_PRE_DEV_VALUE_IS_TYPE(_value, _type)                 \
-       BT_ASSERT_PRE_DEV(                                              \
-               _BT_ASSERT_PRE_VALUE_IS_TYPE_COND((_value), (_type)),   \
-               _BT_ASSERT_PRE_VALUE_IS_TYPE_FMT,                       \
-               bt_common_value_type_string(_type), (_value))
-
-#define BT_ASSERT_PRE_DEV_VALUE_HOT(_value, _name)                     \
-       BT_ASSERT_PRE_DEV_HOT(((struct bt_value *) (_value)), (_name),  \
-               ": %!+v", (_value))
-
 static
 void bt_value_null_instance_release_func(struct bt_object *obj)
 {
This page took 0.039026 seconds and 4 git commands to generate.