lib: assign a unique ID to each pre/postcond. and report it on failure
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 21 Apr 2020 15:15:42 +0000 (11:15 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 23 Apr 2020 03:45:20 +0000 (23:45 -0400)
This patch changes the libbabeltrace2 pre/postcondition assertion macros
so that each precondition and postcondion has a unique ID within the
library.

The macros report (log with a FATAL level) the condition ID on assertion
failure as such (logging prefixes removed):

    Babeltrace 2 library precondition not satisfied.
    ------------------------------------------------------------------------
    Condition ID: `pre:field-class-integer-set-field-value-range:valid-n`.
    Function: bt_field_class_integer_set_field_value_range().
    ------------------------------------------------------------------------
    Error is:
    Unsupported size for integer field class's field value range
    (minimum is 1, maximum is 64): size=65
    Aborting...

The main goal of this change is to make it easier to test library
precondition and postcondition assertions: now you only need to confirm
that the log indicates the expected condition ID, making the details
("Unsupported size for [...]" in the example above) unimportant.

The condition IDs could also exist in the documentation so as to make it
easier to search for libbabeltrace2 pre/postcondition documentation when
failing to satisfy one.

The general condition ID format is:

    TYPE:FUNC:SUFFIX

with

`TYPE`:
    `pre` or `post`.

`FUNC`:
    Name of the API function (precondition) or user function type
    (postcondition) without the `bt_` prefix and with `_` replaced with
    `-`.

`SUFFIX`:
    With the scope of the function: unique, specific precondition or
    postcondition ID.

The BT_ASSERT_PRE_FROM_FUNC() macro (and its developer mode counterpart)
accepts a function name and an ID suffix.

The BT_ASSERT_PRE() macro (and its developer mode counterpart) only
accepts an ID suffix: it uses BT_ASSERT_PRE_FROM_FUNC() with `__func__`
as the function name.

All the other precondition assertion macros follow the same scheme:
`_FROM_FUNC` suffix for a specific function, no suffix for the current
function.

Many precondition assertion macros in `assert-cond.h` build a complete
ID suffix based on a part of it. For example, BT_ASSERT_PRE_NON_NULL()
accepts an object ID, so that

    BT_ASSERT_PRE_NON_NULL("description", descr, "Description");

has the condition ID, when used from the hypothetical public function
bt_do_xyz(), `pre:do-xyz:not-null:description`.

It is imperative that the used API function name is always the one the
user called. Knowing this, internal, static functions _cannot_ use
BT_ASSERT_PRE() because the reported function name would be the internal
one. Not only is this confusing for the library user, it could also
change in the future.

This patch uses two strategies to deal with this constraint depending
on the intended execution path of the public function:

Slow path:
    The common (internal) function accepts an `api_func` parameter which
    is the ultimate public API function name.

    The common function only uses precondition assertion macros which
    end with `_FROM_FUNC`.

    A public function which calls this common function passes `__func__`
    as its `api_func` parameter.

Fast path:
    We define (locally) a new macro which uses the required precondition
    assertion macros (the variants without `_FROM_FUNC`).

    A public function which calls the common function uses the custom
    macro.

Postconditions are checked when a user function returns. Therefore, the
function name in that case is the user function type name.
BT_ASSERT_POST() accepts a function name and an ID suffix.

_BT_ASSERT_COND() calls the internal bt_lib_assert_cond_failed() which
formats the condition ID, prints it and the function name, prints the
details, and aborts.

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

42 files changed:
doc/api/libbabeltrace2/dox/api-fund.dox
src/common/assert.h
src/common/macros.h
src/lib/Makefile.am
src/lib/assert-cond-base.h
src/lib/assert-cond.c [new file with mode: 0644]
src/lib/assert-cond.h
src/lib/current-thread.c
src/lib/error.c
src/lib/graph/component-class.c
src/lib/graph/component-filter.c
src/lib/graph/component-sink.c
src/lib/graph/component-source.c
src/lib/graph/component.c
src/lib/graph/component.h
src/lib/graph/graph.c
src/lib/graph/iterator.c
src/lib/graph/message-iterator-class.c
src/lib/graph/message/discarded-items.c
src/lib/graph/message/event.c
src/lib/graph/message/message-iterator-inactivity.c
src/lib/graph/message/packet.c
src/lib/graph/message/stream.c
src/lib/graph/mip.c
src/lib/graph/query-executor.c
src/lib/integer-range-set.c
src/lib/plugin/plugin.c
src/lib/trace-ir/clock-class.c
src/lib/trace-ir/clock-snapshot.c
src/lib/trace-ir/event-class.c
src/lib/trace-ir/field-class.c
src/lib/trace-ir/field-path.c
src/lib/trace-ir/field.c
src/lib/trace-ir/packet.c
src/lib/trace-ir/resolve-field-path.c
src/lib/trace-ir/resolve-field-path.h
src/lib/trace-ir/stream-class.c
src/lib/trace-ir/stream.c
src/lib/trace-ir/trace-class.c
src/lib/trace-ir/trace.c
src/lib/util.c
src/lib/value.c

index 8c60e539f614c5d138fe095776e7ef8d6eef0d73..5b24faf4e3c2b76fdf3d3fe0f5a1a57dbf304484 100644 (file)
@@ -24,34 +24,51 @@ directory: the compiler prints an error when you try to.
 - All libbabeltrace2 definitions, macros, and enumerators start
   with \c BT_.
 
-@section api-fund-pre-post Function precondition and postcondition checking
+@section api-fund-pre-post Function contract checking
 
-All the functions of libbabeltrace2 which have parameters check that
-the caller meets their
+All the functions of libbabeltrace2 check that the caller meets their
 <a href="https://en.wikipedia.org/wiki/Precondition">preconditions</a>.
 
-All the functions of libbabeltrace2 which call a user function which
-returns something check that the returned value meets their
-<a href="https://en.wikipedia.org/wiki/Postcondition">postconditions</a>.
+All the functions of libbabeltrace2 which call a user function check
+that it meets its
+<a href="https://en.wikipedia.org/wiki/Postcondition">postconditions</a>
+when it returns.
 
 The function descriptions in the
 <a class="el" href="modules.html">API reference modules</a>
 list all their preconditions and postconditions, if any.
 
-libbabeltrace2 is very strict regarding function preconditions and
-postconditions: when you break any of them, the library prints how the
-precondition or postcondition was not satisfied, with details, and then
-calls <code>abort()</code>.
+The libbabeltrace2 public functions offer a
+<strong>narrow contract</strong>: when you break it, the library
+prints how the precondition or postcondition was not satisfied, with
+details, and then calls <code>abort()</code>.
 
 Here's an example of what the library prints to the standard error
-before aborting when you break a precondition:
+before aborting when you break a precondition (call
+bt_value_bool_set() with a \c NULL value);
+\ref api-fund-logging "logging" prefixes are removed for clarity:
 
 @code{.unparsed}
-10-06 09:12:20.228 62362 62362 F LIB/VALUE bt_value_array_get_length@value.c:887 Babeltrace 2 library precondition not satisfied; error is:
-10-06 09:12:20.228 62362 62362 F LIB/VALUE bt_value_array_get_length@value.c:887 Value object is NULL:
-10-06 09:12:20.228 62362 62362 F LIB/VALUE bt_value_array_get_length@value.c:887 Aborting...
+Babeltrace 2 library precondition not satisfied.
+------------------------------------------------------------------------
+Condition ID: `pre:value-bool-set:not-null:value-object`.
+Function: bt_value_bool_set().
+------------------------------------------------------------------------
+Error is:
+Value object is NULL.
+Aborting...
 @endcode
 
+In the output above:
+
+- <code>pre:value-bool-set:not-null:value-object</code> is the unique,
+  permanent ID of this precondition.
+
+  We use this ID for internal libbabeltrace2 testing.
+
+- The <code>Function:</code> line shows which function's contract was
+  broken.
+
 Because precondition and postcondition checks detect programming errors,
 libbabeltrace2's approach is to abort as soon as possible so that you
 fix the error. Therefore, the libbabeltrace2 functions never return a
index 1767e32337c73415cb364695b9c6d1c47fff80a1..77c35e2e14700547de416270a8d37f43739d9a58 100644 (file)
@@ -52,21 +52,8 @@ extern void bt_common_assert_failed(const char *file, int line,
 #define BT_ASSERT_DBG_FUNC
 
 #else /* BT_DEBUG_MODE */
-
-/*
- * When `BT_DEBUG_MODE` is _not_ defined, define BT_ASSERT_DBG() macro
- * to the following to trick the compiler into thinking that the
- * variable passed as condition to the assertion is used. This is to
- * prevent set-but-not-used warnings from the compiler when assertions
- * are disabled. The sizeof() operator also makes sure that the `_cond`
- * expression is not evaluated, thus preventing unwanted side effects.
- *
- * In-depth explanation:
- * https://stackoverflow.com/questions/37411809/how-to-elegantly-fix-this-unused-variable-warning/37412551#37412551
- */
-# define BT_ASSERT_DBG(_cond)  ((void) sizeof((void) (_cond), 0))
+# define BT_ASSERT_DBG(_cond)  BT_USE_EXPR(_cond)
 # define BT_ASSERT_DBG_FUNC    __attribute__((unused))
-
 #endif /* BT_DEBUG_MODE */
 
 #endif /* BABELTRACE_ASSERT_INTERNAL_H */
index a49e30e662aa32047576ba4a076d7c343d137053..718a3050ccb1b4b96b9a00cf84adeb35185bdae0 100644 (file)
                _ref;                   \
        })
 
+/*
+ * Copied from:
+ * <https://stackoverflow.com/questions/37411809/how-to-elegantly-fix-this-unused-variable-warning/37412551#37412551>:
+ *
+ * * sizeof() ensures that the expression is not evaluated at all, so
+ *   its side-effects don't happen. That is to be consistent with the
+ *   usual behaviour of debug-only constructs, such as assert().
+ *
+ * * `((_expr), 0)` uses the comma operator to swallow the actual type
+ *   of `(_expr)`. This is to prevent VLAs from triggering evaluation.
+ *
+ * * `(void)` explicitly ignores the result of `(_expr)` and sizeof() so
+ *   no "unused value" warning appears.
+ */
+
+#define BT_USE_EXPR(_expr)             ((void) sizeof((void) (_expr), 0))
+#define BT_USE_EXPR2(_expr1, _expr2)                                   \
+       ((void) sizeof((void) (_expr1), (void) (_expr2), 0))
+#define BT_USE_EXPR3(_expr1, _expr2, _expr3)                           \
+       ((void) sizeof((void) (_expr1), (void) (_expr2), (void) (_expr3), 0))
+#define BT_USE_EXPR4(_expr1, _expr2, _expr3, _expr4)                   \
+       ((void) sizeof((void) (_expr1), (void) (_expr2),                \
+               (void) (_expr3), (void) (_expr4), 0))
+#define BT_USE_EXPR5(_expr1, _expr2, _expr3, _expr4, _expr5)           \
+       ((void) sizeof((void) (_expr1), (void) (_expr2),                \
+               (void) (_expr3), (void) (_expr4), (void) (_expr5), 0))
+
 #endif
index d36a4436c013920156e934d98a6ca1357b27bedd..c636762612bd34f0eec09a8724eb40cef4b2b18e 100644 (file)
@@ -7,6 +7,7 @@ lib_LTLIBRARIES = libbabeltrace2.la
 libbabeltrace2_la_SOURCES = \
        assert-cond-base.h \
        assert-cond.h \
+       assert-cond.c \
        babeltrace2.c \
        current-thread.c \
        error.c \
index 269107ff2de5afc2b68384668bdfee5e4e653b1f..271ed02efd37b959d27cf3ab5981498ab21bd6f1 100644 (file)
                        (_fmt), ##__VA_ARGS__);                         \
        } while (0)
 
+/*
+ * This function:
+ *
+ * 1. Generates a condition ID based on `cond_type`, `func`, and
+ *    `id_suffix`.
+ *
+ * 2. Logs (FATAL level) the generated condition ID and function name
+ *    (`func`).
+ *
+ * 3. Logs (FATAL level) a message using `fmt` and the optional
+ *    arguments (same usage as BT_LIB_LOGF()).
+ *
+ * 4. Aborts.
+ */
+BT_HIDDEN
+__attribute__((noreturn))
+void bt_lib_assert_cond_failed(const char *cond_type, const char *func,
+               const char *id_suffix, const char *fmt, ...);
+
 /*
  * Internal to this file: asserts that the library condition `_cond` of
- * type `_cond_type` (`pre` or `post`) is satisfied.
+ * type `_cond_type` (`pre` or `post`), related to function `_func`,
+ * and having the ID suffix `_id_suffix` 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.
+ * If `_cond` is false, then this macro calls
+ * bt_lib_assert_cond_failed().
  *
- * To assert that an internal precondition or postcondition is
+ * 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, ...)                  \
+#define _BT_ASSERT_COND(_cond_type, _func, _id_suffix, _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();                              \
+                       bt_lib_assert_cond_failed(_cond_type, _func,    \
+                               _id_suffix, _fmt, ##__VA_ARGS__);       \
                }                                                       \
        } 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().
+ * See _BT_ASSERT_COND() for details about the `_func` and `_id_suffix`
+ * parameters.
  */
-#define BT_ASSERT_PRE(_cond, _fmt, ...)                                        \
-       _BT_ASSERT_COND("pre", _cond, _fmt, ##__VA_ARGS__)
+#define BT_ASSERT_PRE_FROM_FUNC(_func, _id_suffix, _cond, _fmt, ...)   \
+       _BT_ASSERT_COND("pre", _func, _id_suffix, (_cond), _fmt, ##__VA_ARGS__)
+
+/*
+ * Like BT_ASSERT_PRE_FROM_FUNC(), but uses `__func__` (current function
+ * name) as the `_func` parameter.
+ */
+#define BT_ASSERT_PRE(_id_suffix, _cond, _fmt, ...)                    \
+       BT_ASSERT_PRE_FROM_FUNC(__func__, _id_suffix, (_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().
+ * See _BT_ASSERT_COND() for details about the `_func` and `_id_suffix`
+ * parameters.
  */
-#define BT_ASSERT_POST(_cond, _fmt, ...)                                       \
-       _BT_ASSERT_COND("post", _cond, _fmt, ##__VA_ARGS__)
+#define BT_ASSERT_POST(_func, _id_suffix, _cond, _fmt, ...)                            \
+       _BT_ASSERT_COND("post", _func, _id_suffix, (_cond), _fmt, ##__VA_ARGS__);
 
 #ifdef BT_DEV_MODE
+/* Developer mode version of BT_ASSERT_PRE_FROM_FUNC(). */
+# define BT_ASSERT_PRE_DEV_FROM_FUNC(_func, _id_suffix, _cond, _fmt, ...) \
+       BT_ASSERT_PRE_FROM_FUNC(_func, _id_suffix, (_cond), _fmt, ##__VA_ARGS__)
+
 /* Developer mode version of BT_ASSERT_PRE(). */
-# define BT_ASSERT_PRE_DEV(_cond, _fmt, ...)                           \
-       BT_ASSERT_PRE((_cond), _fmt, ##__VA_ARGS__)
+# define BT_ASSERT_PRE_DEV(_id_suffix, _cond, _fmt, ...)               \
+       BT_ASSERT_PRE(_id_suffix, (_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__)
+# define BT_ASSERT_POST_DEV(_func, _id_suffix, _cond, _fmt, ...)       \
+       BT_ASSERT_POST(_func, _id_suffix, (_cond), _fmt, ##__VA_ARGS__)
 
 /* Developer mode version of BT_ASSERT_COND_MSG(). */
 # define BT_ASSERT_COND_DEV_MSG(_fmt, ...)                             \
 #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_FROM_FUNC(_func, _id_suffix, _cond, _fmt, ...) \
+       BT_USE_EXPR4(_func, _id_suffix, _cond, _fmt)
+
+# define BT_ASSERT_PRE_DEV(_id_suffix, _cond, _fmt, ...)               \
+       BT_USE_EXPR3(_id_suffix, _cond, _fmt)
 
-# define BT_ASSERT_POST_DEV(_cond, _fmt, ...)  ((void) sizeof((void) (_cond), 0))
+# define BT_ASSERT_POST_DEV(_func, _id_suffix, _cond, _fmt, ...)       \
+       BT_USE_EXPR4(_func, _id_suffix, _cond, _fmt)
 
 # define BT_ASSERT_COND_DEV_FUNC       __attribute__((unused))
 #endif /* BT_DEV_MODE */
diff --git a/src/lib/assert-cond.c b/src/lib/assert-cond.c
new file mode 100644 (file)
index 0000000..c2d23c9
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright 2020 Philippe Proulx <pproulx@efficios.com>
+ */
+
+#define BT_LOG_TAG "LIB/ASSERT-COND"
+#include "lib/logging.h"
+
+#include <string.h>
+#include <stdarg.h>
+#include <glib.h>
+#include "common/assert.h"
+#include "common/macros.h"
+#include "assert-cond-base.h"
+
+static
+GString *format_cond_id(const char *cond_type, const char *func,
+               const char *id_suffix)
+{
+       static const char func_prefix[] = "bt_";
+       GString *id = g_string_new(NULL);
+       const char *src_ch;
+
+       BT_ASSERT(id);
+
+       /* Condition type */
+       BT_ASSERT(cond_type);
+       g_string_append_printf(id, "%s:", cond_type);
+
+       /* Function name: no prefix */
+       BT_ASSERT(func);
+       BT_ASSERT(strstr(func, func_prefix) == func);
+       src_ch = &func[strlen(func_prefix)];
+
+       /* Function name: `_` replaced with `-` */
+       for (; *src_ch; src_ch++) {
+               char dst_ch;
+
+               if (*src_ch == '_') {
+                       dst_ch = '-';
+               } else {
+                       dst_ch = *src_ch;
+               }
+
+               g_string_append_c(id, dst_ch);
+       }
+
+       /* Suffix */
+       BT_ASSERT(id_suffix);
+       g_string_append_printf(id, ":%s", id_suffix);
+
+       return id;
+}
+
+BT_HIDDEN
+void bt_lib_assert_cond_failed(const char *cond_type, const char *func,
+               const char *id_suffix, const char *fmt, ...)
+{
+       va_list args;
+       GString *cond_id = format_cond_id(cond_type, func, id_suffix);
+
+       BT_ASSERT(cond_id);
+       BT_ASSERT_COND_MSG("Babeltrace 2 library %scondition not satisfied.",
+               cond_type);
+       BT_ASSERT_COND_MSG("------------------------------------------------------------------------");
+       BT_ASSERT_COND_MSG("Condition ID: `%s`.", cond_id->str);
+       g_string_free(cond_id, TRUE);
+       BT_ASSERT_COND_MSG("Function: %s().", func);
+       BT_ASSERT_COND_MSG("------------------------------------------------------------------------");
+       BT_ASSERT_COND_MSG("Error is:");
+       va_start(args, fmt);
+       bt_lib_log_v(_BT_LOG_SRCLOC_FUNCTION, __FILE__, __LINE__, BT_LOG_FATAL,
+               BT_LOG_TAG, fmt, &args);
+       va_end(args);
+       BT_ASSERT_COND_MSG("Aborting...");
+       bt_common_abort();
+}
index 4de066b3cda2837745fdb8217c596b41198e7e2e..411f1364b786deb14805bd2c7a542164597b8bce 100644 (file)
 
 /*
  * Asserts that a given variable `_obj` named `_obj_name` (capitalized)
- * is not `NULL`.
+ * and having the ID `_obj_id` (within the function's context) is not
+ * `NULL`.
  */
-#define BT_ASSERT_PRE_NON_NULL(_obj, _obj_name)                                \
-       BT_ASSERT_PRE((_obj), "%s is NULL: ", _obj_name)
+#define BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _obj_id, _obj, _obj_name) \
+       BT_ASSERT_PRE_FROM_FUNC(_func, "not-null:" _obj_id, (_obj),     \
+               "%s is NULL: ", _obj_name)
+
+#define BT_ASSERT_PRE_NON_NULL(_obj_id, _obj, _obj_name)               \
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(__func__, _obj_id, (_obj), _obj_name)
 
 /*
  * Asserts that a given index `_index` is less than a given length
  * `_length`.
  */
-#define BT_ASSERT_PRE_VALID_INDEX(_index, _length)                     \
-       BT_ASSERT_PRE((_index) < (_length),                             \
+#define BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(_func, _index, _length)    \
+       BT_ASSERT_PRE_FROM_FUNC(_func, "valid-index", (_index) < (_length), \
                "Index is out of bounds: index=%" PRIu64 ", "           \
                "count=%" PRIu64, (uint64_t) (_index), (uint64_t) (_length))
 
+#define BT_ASSERT_PRE_VALID_INDEX(_index, _length)                     \
+       BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(__func__, (_index), (_length))
+
 /*
  * Asserts that the current thread has no error set.
  */
-#define BT_ASSERT_PRE_NO_ERROR() \
-       do {                                                                    \
-               const struct bt_error *err = bt_current_thread_take_error();    \
-               if (err) {                                                      \
-                       bt_current_thread_move_error(err);                      \
-               }                                                               \
-               BT_ASSERT_PRE(!err,                                             \
-                       "API function called while current thread has an "      \
-                       "error: function=%s", __func__);                        \
+#define BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(_func)                                \
+       do {                                                            \
+               const struct bt_error *err = bt_current_thread_take_error(); \
+               if (err) {                                              \
+                       bt_current_thread_move_error(err);              \
+               }                                                       \
+               BT_ASSERT_PRE_FROM_FUNC(_func, "no-error", !err,        \
+                       "API function called while current thread has an " \
+                       "error: function=%s", _func);                   \
        } while (0)
 
+#define BT_ASSERT_PRE_NO_ERROR()                                       \
+       BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(__func__)
+
 /*
  * Asserts that, if the current thread has an error, `_status` is an
  * error status code.
  *
+ * See _BT_ASSERT_COND() for details about the `_func` parameter.
+ *
  * Puts back the error in place (if there is one) such that if this
  * macro aborts, it will be possible to inspect it with a debugger.
  */
-#define BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_status)                    \
+#define BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status)             \
        do {                                                                    \
-               const struct bt_error *err = bt_current_thread_take_error();    \
-               if (err) {                                                      \
-                       bt_current_thread_move_error(err);                      \
+               const struct bt_error *_err = bt_current_thread_take_error();   \
+               if (_err) {                                                     \
+                       bt_current_thread_move_error(_err);                     \
                }                                                               \
-               BT_ASSERT_POST(_status < 0 || !err,                             \
+               BT_ASSERT_POST(_func, "no-error-if-no-error-status",            \
+                       (_status) < 0 || !_err,                                 \
                        "Current thread has an error, but user function "       \
                        "returned a non-error status: status=%s",               \
                        bt_common_func_status_string(_status));                 \
 
 /*
  * Asserts that the current thread has no error.
+ *
+ * See _BT_ASSERT_COND() for details about the `_func` parameter.
  */
-#define BT_ASSERT_POST_NO_ERROR() \
-       BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(0)
+#define BT_ASSERT_POST_NO_ERROR(_func)                                 \
+       do {                                                            \
+               const struct bt_error *_err = bt_current_thread_take_error(); \
+               if (_err) {                                             \
+                       bt_current_thread_move_error(_err);             \
+               }                                                       \
+               BT_ASSERT_POST(_func, "no-error", !_err,                \
+                       "Current thread has an error");                 \
+       } while (0)
 
 #ifdef BT_DEV_MODE
+/* Developer mode version of BT_ASSERT_PRE_NON_NULL_FROM_FUNC() */
+# define BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, _obj_id, _obj, _obj_name) \
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _obj_id, (_obj), (_obj_name))
+
 /* 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))
+# define BT_ASSERT_PRE_DEV_NON_NULL(_obj_id, _obj, _obj_name)          \
+       BT_ASSERT_PRE_NON_NULL(_obj_id, (_obj), (_obj_name))
 
 /*
  * Developer mode: asserts that a given object `_obj` named `_obj_name`
- * (capitalized) is NOT frozen. This macro checks the `frozen` field of
- * `_obj`.
+ * (capitalized) and having the ID `_obj_id` (within the function's
+ * context) is NOT frozen.
+ *
+ * This macro checks the `frozen` field of `_obj`.
  *
  * This currently only exists in developer mode because some freezing
  * functions can be called on the fast path, so they too are only
  * enabled in developer mode.
  */
-# define BT_ASSERT_PRE_DEV_HOT(_obj, _obj_name, _fmt, ...)             \
-       BT_ASSERT_PRE(!(_obj)->frozen, "%s is frozen" _fmt, _obj_name,  \
-               ##__VA_ARGS__)
+# define BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(_func, _obj_id, _obj, _obj_name, _fmt, ...) \
+       BT_ASSERT_PRE_FROM_FUNC(_func, "not-frozen:" _obj_id,           \
+               !(_obj)->frozen, "%s is frozen" _fmt, _obj_name, ##__VA_ARGS__)
+
+# define BT_ASSERT_PRE_DEV_HOT(_obj_id, _obj, _obj_name, _fmt, ...)    \
+       BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(__func__, _obj_id, (_obj),      \
+               _obj_name, _fmt, ##__VA_ARGS__)
+
+/* Developer mode version of BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC() */
+# define BT_ASSERT_PRE_DEV_VALID_INDEX_FROM_FUNC(_func, _index, _length) \
+       BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(_func, (_index), (_length))
 
 /* Developer mode version of BT_ASSERT_PRE_VALID_INDEX() */
-# define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length)                        \
+# define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length)        \
        BT_ASSERT_PRE_VALID_INDEX((_index), (_length))
 
+/* Developer mode version of BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(). */
+# define BT_ASSERT_PRE_DEV_NO_ERROR_FROM_FUNC(_func)                   \
+       BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(_func)
+
 /* Developer mode version of BT_ASSERT_PRE_NO_ERROR(). */
-# define BT_ASSERT_PRE_DEV_NO_ERROR()                                  \
-       BT_ASSERT_PRE_NO_ERROR()
+# define BT_ASSERT_PRE_DEV_NO_ERROR()  BT_ASSERT_PRE_NO_ERROR()
 
 /*
  * 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)       \
-       BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_status)
+# define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status)        \
+       BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_func, (_status))
 
 /* Developer mode version of BT_ASSERT_POST_NO_ERROR(). */
-# define BT_ASSERT_POST_DEV_NO_ERROR()                                 \
-       BT_ASSERT_POST_NO_ERROR()
+# define BT_ASSERT_POST_DEV_NO_ERROR(_func)                            \
+       BT_ASSERT_POST_NO_ERROR(_func)
 
 /*
  * Marks a function as being only used within a BT_ASSERT_PRE_DEV() or
  */
 # define BT_ASSERT_COND_DEV_FUNC
 #else
-# define BT_ASSERT_PRE_DEV_NON_NULL(_obj, _obj_name)                   \
-       ((void) sizeof((void) (_obj), (void) (_obj_name), 0))
+# define BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, _obj_id, _obj, _obj_name) \
+       BT_USE_EXPR4(_func, _obj_id, (_obj), _obj_name)
+
+# define BT_ASSERT_PRE_DEV_NON_NULL(_obj_id, _obj, _obj_name)          \
+       BT_USE_EXPR3(_obj_id, (_obj), _obj_name)
+
+# define BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(_func, _obj_id, _obj, _obj_name, _fmt, ...) \
+       BT_USE_EXPR5(_func, _obj_id, (_obj), _obj_name, _fmt)
 
-# define BT_ASSERT_PRE_DEV_HOT(_obj, _obj_name, _fmt, ...)             \
-       ((void) sizeof((void) (_obj), (void) (_obj_name), 0))
+# define BT_ASSERT_PRE_DEV_HOT(_obj_id, _obj, _obj_name, _fmt, ...) \
+       BT_USE_EXPR4(_obj_id, (_obj), _obj_name, _fmt)
+
+# define BT_ASSERT_PRE_DEV_VALID_INDEX_FROM_FUNC(_func, _index, _length) \
+       BT_USE_EXPR3(_func, (_index), (_length))
 
 # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length)                        \
-       ((void) sizeof((void) (_index), (void) (_length), 0))
+       BT_USE_EXPR2((_index), (_length))
+
+# define BT_ASSERT_PRE_DEV_NO_ERROR_FROM_FUNC(_func)                   \
+       BT_USE_EXPR(_func)
 
 # define BT_ASSERT_PRE_DEV_NO_ERROR()
 
-# define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_status)       \
-       ((void) sizeof((void) (_status), 0))
+# define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status)        \
+       BT_USE_EXPR2(_func, _status)
 
-# define BT_ASSERT_POST_DEV_NO_ERROR()
+# define BT_ASSERT_POST_DEV_NO_ERROR(_func)                            \
+       BT_USE_EXPR(_func)
 #endif /* BT_DEV_MODE */
 
 #define _BT_ASSERT_PRE_CLK_CLS_NAME    "Clock class"
+#define _BT_ASSERT_PRE_CLK_CLS_ID      "clock-class"
 
 #define BT_ASSERT_PRE_CLK_CLS_NON_NULL(_cc)                            \
-       BT_ASSERT_PRE_NON_NULL(clock_class, _BT_ASSERT_PRE_CLK_CLS_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CLK_CLS_ID, (_cc),        \
+               _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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CLK_CLS_ID, (_cc),    \
+               _BT_ASSERT_PRE_CLK_CLS_NAME)
 
 #define _BT_ASSERT_PRE_DEF_CLK_CLS_NAME        "Default clock class"
+#define _BT_ASSERT_PRE_DEF_CLK_CLS_ID  "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)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_DEF_CLK_CLS_ID, (_cc),    \
+               _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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_DEF_CLK_CLS_ID,       \
+               (_cc), _BT_ASSERT_PRE_DEF_CLK_CLS_NAME)
 
 #define _BT_ASSERT_PRE_CS_NAME "Clock snapshot"
+#define _BT_ASSERT_PRE_CS_ID   "clock-snapshot"
 
 #define BT_ASSERT_PRE_CS_NON_NULL(_cs)                                 \
-       BT_ASSERT_PRE_NON_NULL(_cs, _BT_ASSERT_PRE_CS_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CS_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CS_ID, (_cs),         \
+               _BT_ASSERT_PRE_CS_NAME)
 
 #define _BT_ASSERT_PRE_EVENT_NAME      "Event"
+#define _BT_ASSERT_PRE_EVENT_ID                "event"
 
-#define BT_ASSERT_PRE_EVENT_NON_NULL(_ec)                              \
-       BT_ASSERT_PRE_NON_NULL(_ec, _BT_ASSERT_PRE_EVENT_NAME)
+#define BT_ASSERT_PRE_EVENT_NON_NULL(_event)                           \
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_EVENT_ID, (_event),       \
+               _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_DEV_EVENT_NON_NULL(_event)                       \
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_EVENT_ID, (_event),   \
+               _BT_ASSERT_PRE_EVENT_NAME)
 
 #define _BT_ASSERT_PRE_EC_NAME "Event class"
+#define _BT_ASSERT_PRE_EC_ID   "event-class"
+
+#define BT_ASSERT_PRE_EC_NON_NULL_FROM_FUNC(_func, _ec)                        \
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_EC_ID,   \
+               (_ec), _BT_ASSERT_PRE_EC_NAME)
 
 #define BT_ASSERT_PRE_EC_NON_NULL(_ec)                                 \
-       BT_ASSERT_PRE_NON_NULL(_ec, _BT_ASSERT_PRE_EC_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_EC_ID, (_ec),             \
+               _BT_ASSERT_PRE_EC_NAME)
+
+#define BT_ASSERT_PRE_DEV_EC_NON_NULL_FROM_FUNC(_func, _ec)            \
+       BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func,                     \
+               _BT_ASSERT_PRE_EC_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_EC_ID, (_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 || \
 #define _BT_ASSERT_PRE_FC_IS_INT_FMT(_name)                            \
        _name " is not an integer field class: %![fc-]+F"
 
+#define _BT_ASSERT_PRE_FC_IS_INT_ID(_fc_id)    "is-int-field-class:" _fc_id
+
 #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_UNSIGNED_INT_ID(_fc_id)                   \
+       "is-unsigned-integer-field-class:" _fc_id
 
 #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc)                      \
        (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
 #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_SIGNED_INT_ID(_fc_id)                     \
+       "is-signed-integer-field-class:" _fc_id
+
 #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_ENUM_ID(_fc_id)                           \
+       "is-enumeration-field-class:" _fc_id
+
 #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 || \
 #define _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name)                          \
        _name " is not an array field class: %![fc-]+F"
 
+#define _BT_ASSERT_PRE_FC_IS_ARRAY_ID(_fc_id)                          \
+       "is-array-field-class:" _fc_id
+
 #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 || \
 #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_ID(_fc_id)                         \
+       "is-option-field-class:" _fc_id
+
 #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 || \
 #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_SEL_ID(_fc_id)                        \
+       "is-option-field-class-with-selector:" _fc_id
+
 #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_OPTION_WITH_INT_SEL_ID(_fc_id)            \
+       "is-option-field-class-with-integer-selector:" _fc_id
+
 #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_STRUCT_ID(_fc_id)                         \
+       "is-structure-field-class:" _fc_id
+
 #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 || \
 #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_ID(_fc_id)                                \
+       "is-variant-field-class:" _fc_id
+
 #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_IS_VARIANT_WITH_SEL_ID(_fc_id)               \
+       "is-variant-field-class-with-selector:" _fc_id
+
 #define _BT_ASSERT_PRE_FC_HAS_TYPE_COND(_fc, _type)                    \
        (((const struct bt_field_class *) (_fc))->type == (_type))
 
 #define _BT_ASSERT_PRE_FC_HAS_TYPE_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),               \
+#define _BT_ASSERT_PRE_FC_HAS_TYPE_ID(_fc_id, _type_id)                        \
+       "is-" _type_id ":" _fc_id
+
+#define BT_ASSERT_PRE_FC_IS_INT_FROM_FUNC(_func, _fc_id, _fc, _name)   \
+       BT_ASSERT_PRE_FROM_FUNC(_func,                                  \
+               _BT_ASSERT_PRE_FC_IS_INT_ID(_fc_id),                    \
+               _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),      \
+#define BT_ASSERT_PRE_FC_IS_INT(_fc_id, _fc, _name)                    \
+       BT_ASSERT_PRE_FC_IS_INT_FROM_FUNC(__func__, _fc_id, (_fc), _name)
+
+#define BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(_fc_id, _fc, _name)           \
+       BT_ASSERT_PRE(                                                  \
+               _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_ID(_fc_id),           \
+               _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),        \
+#define BT_ASSERT_PRE_FC_IS_SIGNED_INT(_fc_id, _fc, _name)             \
+       BT_ASSERT_PRE(                                                  \
+               _BT_ASSERT_PRE_FC_IS_SIGNED_INT_ID(_fc_id),             \
+               _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),              \
+#define BT_ASSERT_PRE_FC_IS_ENUM(_fc_id, _fc, _name)                   \
+       BT_ASSERT_PRE(                                                  \
+               _BT_ASSERT_PRE_FC_IS_ENUM_ID(_fc_id),                   \
+               _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),             \
+#define BT_ASSERT_PRE_FC_IS_ARRAY(_fc_id, _fc, _name)                  \
+       BT_ASSERT_PRE(                                                  \
+               _BT_ASSERT_PRE_FC_IS_ARRAY_ID(_fc_id),                  \
+               _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),            \
+#define BT_ASSERT_PRE_FC_IS_STRUCT(_fc_id, _fc, _name)                 \
+       BT_ASSERT_PRE(                                                  \
+               _BT_ASSERT_PRE_FC_IS_STRUCT_ID(_fc_id),                 \
+               _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),            \
+#define BT_ASSERT_PRE_FC_IS_OPTION(_fc_id, _fc, _name)                 \
+       BT_ASSERT_PRE(                                                  \
+               _BT_ASSERT_PRE_FC_IS_OPTION_ID(_fc_id),                 \
+               _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),   \
+#define BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL(_fc_id, _fc, _name)                \
+       BT_ASSERT_PRE(                                                  \
+               _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_ID(_fc_id),        \
+               _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), \
+#define BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL(_fc_id, _fc, _name)    \
+       BT_ASSERT_PRE(                                                  \
+               _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_ID(_fc_id),    \
+               _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),           \
+#define BT_ASSERT_PRE_FC_IS_VARIANT(_fc_id, _fc, _name)                        \
+       BT_ASSERT_PRE(                                                  \
+               _BT_ASSERT_PRE_FC_IS_VARIANT_ID(_fc_id),                \
+               _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),  \
+#define BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL(_fc_id, _fc, _name)       \
+       BT_ASSERT_PRE(                                                  \
+               _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_ID(_fc_id),       \
+               _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_TYPE(_fc, _type, _name)                   \
-       BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_HAS_TYPE_COND((_fc), (_type)),  \
+#define BT_ASSERT_PRE_FC_HAS_TYPE_FROM_FUNC(_func, _fc_id, _fc, _type_id, _type, _name) \
+       BT_ASSERT_PRE_FROM_FUNC(_func,                                  \
+               _BT_ASSERT_PRE_FC_HAS_TYPE_ID(_fc_id, _type_id),                \
+               _BT_ASSERT_PRE_FC_HAS_TYPE_COND((_fc), (_type)),                \
                _BT_ASSERT_PRE_FC_HAS_TYPE_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),           \
+#define BT_ASSERT_PRE_FC_HAS_TYPE(_fc_id, _fc, _type_id, _type, _name) \
+       BT_ASSERT_PRE_FC_HAS_TYPE_FROM_FUNC(__func__, _fc_id, (_fc),    \
+               _type_id, (_type), _name)
+
+#define BT_ASSERT_PRE_DEV_FC_IS_INT(_fc_id, _fc, _name)                        \
+       BT_ASSERT_PRE_DEV(                                              \
+               _BT_ASSERT_PRE_FC_IS_INT_ID(_fc_id),                    \
+               _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),  \
+#define BT_ASSERT_PRE_DEV_FC_IS_UNSIGNED_INT(_fc_id, _fc, _name)       \
+       BT_ASSERT_PRE_DEV(                                              \
+               _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_ID(_fc_id),           \
+               _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),    \
+#define BT_ASSERT_PRE_DEV_FC_IS_SIGNED_INT(_fc_id, _fc, _name)         \
+       BT_ASSERT_PRE_DEV(                                              \
+               _BT_ASSERT_PRE_FC_IS_SIGNED_INT_ID(_fc_id),             \
+               _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),          \
+#define BT_ASSERT_PRE_DEV_FC_IS_ENUM(_fc_id, _fc, _name)               \
+       BT_ASSERT_PRE_DEV(                                              \
+               _BT_ASSERT_PRE_FC_IS_ENUM_ID(_fc_id),                   \
+               _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),         \
+#define BT_ASSERT_PRE_DEV_FC_IS_ARRAY(_fc_id, _fc, _name)              \
+       BT_ASSERT_PRE_DEV(                                              \
+               _BT_ASSERT_PRE_FC_IS_ARRAY_ID(_fc_id),                  \
+               _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),        \
+#define BT_ASSERT_PRE_DEV_FC_IS_STRUCT(_fc_id, _fc, _name)             \
+       BT_ASSERT_PRE_DEV(                                              \
+               _BT_ASSERT_PRE_FC_IS_STRUCT_ID(_fc_id),                 \
+               _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),        \
+#define BT_ASSERT_PRE_DEV_FC_IS_OPTION(_fc_id, _fc, _name)             \
+       BT_ASSERT_PRE_DEV(                                              \
+               _BT_ASSERT_PRE_FC_IS_OPTION_ID(_fc_id),                 \
+               _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), \
+#define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_SEL(_fc_id, _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), \
+#define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_INT_SEL(_fc_id, _fc, _name)        \
+       BT_ASSERT_PRE_DEV(                                              \
+               _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_ID(_fc_id),    \
+               _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),       \
+#define BT_ASSERT_PRE_DEV_FC_IS_VARIANT(_fc_id, _fc, _name)            \
+       BT_ASSERT_PRE_DEV(                                              \
+               _BT_ASSERT_PRE_FC_IS_VARIANT_ID(_fc_id),                \
+               _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), \
+#define BT_ASSERT_PRE_DEV_FC_IS_VARIANT_WITH_SEL(_fc_id, _fc, _name)   \
+       BT_ASSERT_PRE_DEV(                                              \
+               _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_ID(_fc_id),       \
+               _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_TYPE(_fc, _type, _name)               \
-       BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_HAS_TYPE_COND((_fc), (_type)), \
+#define BT_ASSERT_PRE_DEV_FC_HAS_TYPE(_fc_id, _fc, _type_id, _type, _name) \
+       BT_ASSERT_PRE_DEV(                                              \
+               _BT_ASSERT_PRE_FC_HAS_TYPE_ID(_fc_id, _type_id),                \
+               _BT_ASSERT_PRE_FC_HAS_TYPE_COND((_fc), (_type)),                \
                _BT_ASSERT_PRE_FC_HAS_TYPE_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_DEV_FC_HOT_FROM_FUNC(_func, _fc)                 \
+       BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(_func, "field-class",           \
+               (const struct bt_field_class *) (_fc),                  \
+               "Field class", ": %!+F", (_fc))
+
+#define BT_ASSERT_PRE_DEV_FC_HOT(_fc)                                  \
+       BT_ASSERT_PRE_DEV_FC_HOT_FROM_FUNC(__func__, (_fc))
 
 #define _BT_ASSERT_PRE_FC_NAME "Field class"
+#define _BT_ASSERT_PRE_FC_ID   "field-class"
 
 #define BT_ASSERT_PRE_FC_NON_NULL(_fc)                                 \
-       BT_ASSERT_PRE_NON_NULL(_fc, _BT_ASSERT_PRE_FC_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FC_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FC_ID, (_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_ID     "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)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID,      \
+               (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID,  \
+               (_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_ID   "variant-field-class-option-id"
 
 #define BT_ASSERT_PRE_VAR_FC_OPT_NON_NULL(_fc)                         \
-       BT_ASSERT_PRE_NON_NULL(_fc, _BT_ASSERT_PRE_VAR_FC_OPT_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_VAR_FC_OPT_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_VAR_FC_OPT_ID, (_fc), \
+               _BT_ASSERT_PRE_VAR_FC_OPT_NAME)
 
 #define _BT_ASSERT_PRE_FP_NAME "Field path"
+#define _BT_ASSERT_PRE_FP_ID   "field-path"
 
 #define BT_ASSERT_PRE_FP_NON_NULL(_fp)                                 \
-       BT_ASSERT_PRE_NON_NULL(_fp, _BT_ASSERT_PRE_FP_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FP_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FP_ID, (_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), \
+#define BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(_field_id, _field, _cls_type_id, _cls_type, _name) \
+       BT_ASSERT_PRE_DEV("is-" _cls_type_id ":" _field_id,             \
+               ((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)         \
+#define BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(_field_id, _field, _name) \
        BT_ASSERT_PRE_DEV(                                              \
+               "is-unsigned-integer-field:" _field_id,                 \
                ((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)           \
+#define BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(_field_id, _field, _name)        \
        BT_ASSERT_PRE_DEV(                                              \
+               "is-signed-integer-field:" _field_id,                   \
                ((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)                        \
+#define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(_field_id, _field, _name)     \
        BT_ASSERT_PRE_DEV(                                              \
+               "is-array-field:" _field_id,                            \
                ((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)                \
+#define BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(_field_id, _field, _name) \
        BT_ASSERT_PRE_DEV(                                              \
+               "is-dynamic-array-field:" _field_id,                    \
                ((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)               \
+#define BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(_field_id, _field, _name)    \
        BT_ASSERT_PRE_DEV(                                              \
+               "is-option-field:" _field_id,                           \
                ((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)              \
+#define BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(_field_id, _field, _name)   \
        BT_ASSERT_PRE_DEV(                                              \
+               "is-variant-field:" _field_id,                          \
                ((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)                         \
-       BT_ASSERT_PRE_DEV(bt_field_is_set(_field),                      \
+#define BT_ASSERT_PRE_DEV_FIELD_IS_SET(_field_id, _field)              \
+       BT_ASSERT_PRE_DEV("is-field-set:" _field_id,                    \
+               bt_field_is_set(_field),                                \
                "Field is not set: %!+f", (_field))
 
 #define _BT_ASSERT_PRE_FIELD_NAME      "Field"
+#define _BT_ASSERT_PRE_FIELD_ID                "field"
 
 #define BT_ASSERT_PRE_FIELD_NON_NULL(_field)                           \
-       BT_ASSERT_PRE_NON_NULL(_field, _BT_ASSERT_PRE_FIELD_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FIELD_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FIELD_ID, (_field),   \
+               _BT_ASSERT_PRE_FIELD_NAME)
 
 #define _BT_ASSERT_PRE_PACKET_NAME     "Packet"
+#define _BT_ASSERT_PRE_PACKET_ID       "packet"
+
+#define BT_ASSERT_PRE_PACKET_NON_NULL_FROM_FUNC(_func, _packet)                \
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func,                         \
+               _BT_ASSERT_PRE_PACKET_ID, (_packet), _BT_ASSERT_PRE_PACKET_NAME)
 
 #define BT_ASSERT_PRE_PACKET_NON_NULL(_packet)                         \
-       BT_ASSERT_PRE_NON_NULL(_packet, _BT_ASSERT_PRE_PACKET_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PACKET_ID, (_packet),     \
+               _BT_ASSERT_PRE_PACKET_NAME)
+
+#define BT_ASSERT_PRE_DEV_PACKET_NON_NULL_FROM_FUNC(_func, _packet)    \
+       BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func,                     \
+               _BT_ASSERT_PRE_PACKET_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PACKET_ID, (_packet), \
+               _BT_ASSERT_PRE_PACKET_NAME)
 
 #define _BT_ASSERT_PRE_SC_NAME "Stream class"
+#define _BT_ASSERT_PRE_SC_ID   "stream-class"
 
 #define BT_ASSERT_PRE_SC_NON_NULL(_sc)                                 \
-       BT_ASSERT_PRE_NON_NULL(_sc, _BT_ASSERT_PRE_SC_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_SC_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_SC_ID, (_sc),         \
+               _BT_ASSERT_PRE_SC_NAME)
 
 #define _BT_ASSERT_PRE_STREAM_NAME     "Stream"
+#define _BT_ASSERT_PRE_STREAM_ID       "stream"
+
+#define BT_ASSERT_PRE_STREAM_NON_NULL_FROM_FUNC(_func, _stream)                \
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func,                         \
+               _BT_ASSERT_PRE_STREAM_ID, (_stream),                    \
+               _BT_ASSERT_PRE_STREAM_NAME)
 
 #define BT_ASSERT_PRE_STREAM_NON_NULL(_stream)                         \
-       BT_ASSERT_PRE_NON_NULL(_stream, _BT_ASSERT_PRE_STREAM_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_STREAM_ID, (_stream),     \
+               _BT_ASSERT_PRE_STREAM_NAME)
+
+#define BT_ASSERT_PRE_DEV_STREAM_NON_NULL_FROM_FUNC(_func, _stream)    \
+       BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func,                     \
+               _BT_ASSERT_PRE_STREAM_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_STREAM_ID, (_stream), \
+               _BT_ASSERT_PRE_STREAM_NAME)
 
 #define _BT_ASSERT_PRE_TC_NAME "Trace class"
+#define _BT_ASSERT_PRE_TC_ID   "trace-class"
+
+#define BT_ASSERT_PRE_TC_NON_NULL_FROM_FUNC(_func, _tc)                        \
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_TC_ID,   \
+               (_tc), _BT_ASSERT_PRE_TC_NAME)
 
 #define BT_ASSERT_PRE_TC_NON_NULL(_tc)                                 \
-       BT_ASSERT_PRE_NON_NULL(_tc, _BT_ASSERT_PRE_TC_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_TC_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_TC_ID, (_tc),         \
+               _BT_ASSERT_PRE_TC_NAME)
 
 #define _BT_ASSERT_PRE_TRACE_NAME      "Trace"
+#define _BT_ASSERT_PRE_TRACE_ID                "trace"
 
 #define BT_ASSERT_PRE_TRACE_NON_NULL(_trace)                           \
-       BT_ASSERT_PRE_NON_NULL(_trace, _BT_ASSERT_PRE_TRACE_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_TRACE_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_TRACE_ID, (_trace),   \
+               _BT_ASSERT_PRE_TRACE_NAME)
 
-#define _BT_ASSERT_PRE_USER_ATTRS_NAME "User attributes"
+#define _BT_ASSERT_PRE_USER_ATTRS_NAME "User attributes value object"
+#define _BT_ASSERT_PRE_USER_ATTRS_ID   "user-attributes-value-object"
+
+#define BT_ASSERT_PRE_USER_ATTRS_NON_NULL_FROM_FUNC(_func, _ua)                \
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func,                         \
+               _BT_ASSERT_PRE_USER_ATTRS_ID, (_ua),                    \
+               _BT_ASSERT_PRE_USER_ATTRS_NAME)
 
 #define BT_ASSERT_PRE_USER_ATTRS_NON_NULL(_ua)                         \
-       BT_ASSERT_PRE_NON_NULL(_ua, _BT_ASSERT_PRE_USER_ATTRS_NAME)
+       BT_ASSERT_PRE_USER_ATTRS_NON_NULL_FROM_FUNC(__func__, (_ua))
 
 #define BT_ASSERT_PRE_DEV_USER_ATTRS_NON_NULL(_ua)                     \
-       BT_ASSERT_PRE_DEV_NON_NULL(_ua, _BT_ASSERT_PRE_USER_ATTRS_NAME)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_USER_ATTRS_ID, (_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,                 \
+#define BT_ASSERT_PRE_USER_ATTRS_IS_MAP_FROM_FUNC(_func, _ua)          \
+       BT_ASSERT_PRE_FROM_FUNC(_func, "is-map-value:user-attributes",  \
+               (_ua)->type == BT_VALUE_TYPE_MAP,                       \
                _BT_ASSERT_PRE_USER_ATTRS_NAME                          \
                " object is not a map value object.")
 
+#define BT_ASSERT_PRE_USER_ATTRS_IS_MAP(_ua)                           \
+       BT_ASSERT_PRE_USER_ATTRS_IS_MAP_FROM_FUNC(__func__, (_ua))
+
 #define BT_ASSERT_COND_LISTENER_FUNC_NAME      "Listener function"
+#define BT_ASSERT_COND_LISTENER_FUNC_ID                "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_LISTENER_FUNC_NON_NULL(_listener_func)           \
+       BT_ASSERT_PRE_NON_NULL(BT_ASSERT_COND_LISTENER_FUNC_ID,         \
+               (_listener_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_DEV_LISTENER_FUNC_NON_NULL(_listener_func)                       \
+       BT_ASSERT_PRE_DEV_NON_NULL(BT_ASSERT_COND_LISTENER_FUNC_ID,     \
+               (_listener_func), BT_ASSERT_COND_LISTENER_FUNC_NAME)
 
 #define _BT_ASSERT_PRE_MSG_ITER_NAME   "Message iterator"
+#define _BT_ASSERT_PRE_MSG_ITER_ID     "message-iterator"
+
+#define BT_ASSERT_PRE_MSG_ITER_NON_NULL_FROM_FUNC(_func, _msg_iter)    \
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func,                         \
+               _BT_ASSERT_PRE_MSG_ITER_ID, (_msg_iter),                \
+               _BT_ASSERT_PRE_MSG_ITER_NAME)
 
 #define BT_ASSERT_PRE_MSG_ITER_NON_NULL(_msg_iter)                     \
-       BT_ASSERT_PRE_NON_NULL(_msg_iter, _BT_ASSERT_PRE_MSG_ITER_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_ID, (_msg_iter), \
+               _BT_ASSERT_PRE_MSG_ITER_NAME)
+
+#define BT_ASSERT_PRE_DEV_MSG_ITER_NON_NULL_FROM_FUNC(_func, _msg_iter)        \
+       BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func,                     \
+               _BT_ASSERT_PRE_MSG_ITER_ID,                             \
+               (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_ID,          \
+               (_msg_iter), _BT_ASSERT_PRE_MSG_ITER_NAME)
+
+#define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc)                    \
+       ((_sc)->default_clock_class)
+
+#define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FMT                          \
+       "Message's stream's class has no default clock class: "         \
+       "%![msg-]+n, %![sc-]+S"
+
+#define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID                           \
+       "message-stream-class-has-default-clock-class"
+
+#define BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FROM_FUNC(_func, _msg, _sc)   \
+       BT_ASSERT_PRE_FROM_FUNC(_func,                                  \
+               _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID,                   \
+               _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc),            \
+               _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FMT,                  \
+               (_msg), (_sc));
+
+#define BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS(_msg, _sc)                    \
+       BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FROM_FUNC(__func__, (_msg), (_sc))
+
+#define BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS_FROM_FUNC(_func, _msg, _sc) \
+       BT_ASSERT_PRE_DEV_FROM_FUNC(_func,                              \
+               _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID,                   \
+               _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc),            \
+               _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FMT,                  \
+               (_msg), (_sc));
 
 #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));
+       BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS_FROM_FUNC(__func__, (_msg), (_sc))
 
 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_COND(_msg, _type)                  \
        (((struct bt_message *) (_msg))->type == (_type))
 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT                                        \
        "Message has the wrong type: expected-type=%s, %![msg-]+n"
 
-#define BT_ASSERT_PRE_MSG_HAS_TYPE(_msg, _type)                                \
+#define _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id)              \
+       "is-" _type_id "-message:" _msg_id
+
+#define BT_ASSERT_PRE_MSG_HAS_TYPE(_msg_id, _msg, _type_id, _type)     \
        BT_ASSERT_PRE(                                                  \
+               _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id),      \
                _BT_ASSERT_PRE_MSG_HAS_TYPE_COND((_msg), (_type)),      \
                _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT,                        \
                bt_message_type_string(_type), (_msg))
 
-#define BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(_msg, _type)                    \
+#define BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(_msg_id, _msg, _type_id, _type) \
        BT_ASSERT_PRE_DEV(                                              \
+               _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id),      \
                _BT_ASSERT_PRE_MSG_HAS_TYPE_COND((_msg), (_type)),      \
                _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT,                        \
                bt_message_type_string(_type), (_msg))
 
 #define _BT_ASSERT_PRE_MSG_NAME        "Message"
+#define _BT_ASSERT_PRE_MSG_ID  "message"
 
 #define BT_ASSERT_PRE_MSG_NON_NULL(_msg_iter)                          \
-       BT_ASSERT_PRE_NON_NULL(_msg_iter, _BT_ASSERT_PRE_MSG_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ID, (_msg_iter),  \
+               _BT_ASSERT_PRE_MSG_NAME)
 
 #define BT_ASSERT_PRE_MSG_CS_BEGIN_LE_END(_msg_iter, _begin, _end)     \
-       BT_ASSERT_PRE(                                                  \
-               _begin <= _end,                                         \
+       BT_ASSERT_PRE("beginning-default-clock-snapshot-lteq-end",      \
+               (_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);
+               "%![msg-iter-]+i", (_begin), (_end), _msg_iter);
 
 #define BT_ASSERT_PRE_DEV_MSG_HOT(_msg)                                        \
-       BT_ASSERT_PRE_DEV_HOT((_msg), "Message", ": %!+n", (_msg));
+       BT_ASSERT_PRE_DEV_HOT("message", (_msg), "Message", ": %!+n", (_msg));
 
 #define _BT_ASSERT_PRE_MSG_ITER_CLS_NAME       "Message iterator class"
+#define _BT_ASSERT_PRE_MSG_ITER_CLS_ID         "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)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_CLS_ID,          \
+               (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_CLS_ID,      \
+               (_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_ID     "component-class"
+
+#define BT_ASSERT_PRE_COMP_CLS_NON_NULL_FROM_FUNC(_func, _comp_cls)    \
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func,                         \
+               _BT_ASSERT_PRE_COMP_CLS_ID, (_comp_cls),                \
+               _BT_ASSERT_PRE_COMP_CLS_NAME)
 
 #define BT_ASSERT_PRE_COMP_CLS_NON_NULL(_comp_cls)                     \
-       BT_ASSERT_PRE_NON_NULL(_comp_cls, _BT_ASSERT_PRE_COMP_CLS_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_CLS_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_CLS_ID,          \
+               (_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_ID       "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)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_DESCR_SET_ID,        \
+               (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_DESCR_SET_ID,    \
+               (_comp_descr_set), _BT_ASSERT_PRE_COMP_DESCR_SET_NAME)
 
 #define _BT_ASSERT_PRE_COMP_NAME       "Component"
+#define _BT_ASSERT_PRE_COMP_ID         "component"
+
+#define BT_ASSERT_PRE_COMP_NON_NULL_FROM_FUNC(_func, _comp)            \
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_COMP_ID, \
+               (_comp), _BT_ASSERT_PRE_COMP_NAME)
 
 #define BT_ASSERT_PRE_COMP_NON_NULL(_comp)                             \
-       BT_ASSERT_PRE_NON_NULL(_comp, _BT_ASSERT_PRE_COMP_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_ID, (_comp),         \
+               _BT_ASSERT_PRE_COMP_NAME)
+
+#define BT_ASSERT_PRE_DEV_COMP_NON_NULL_FROM_FUNC(_func, _comp)                \
+       BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func,                     \
+               _BT_ASSERT_PRE_COMP_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_ID, (_comp),     \
+               _BT_ASSERT_PRE_COMP_NAME)
 
 #define _BT_ASSERT_PRE_CONN_NAME       "Connection"
+#define _BT_ASSERT_PRE_CONN_ID         "connection"
 
 #define BT_ASSERT_PRE_CONN_NON_NULL(_conn)                             \
-       BT_ASSERT_PRE_NON_NULL(_conn, _BT_ASSERT_PRE_CONN_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CONN_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CONN_ID, (_conn),     \
+               _BT_ASSERT_PRE_CONN_NAME)
 
 #define _BT_ASSERT_PRE_GRAPH_NAME      "Graph"
+#define _BT_ASSERT_PRE_GRAPH_ID                "graph"
+
+#define BT_ASSERT_PRE_GRAPH_NON_NULL_FROM_FUNC(_func, _graph)          \
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func,                         \
+               _BT_ASSERT_PRE_GRAPH_ID, (_graph), _BT_ASSERT_PRE_GRAPH_NAME)
 
 #define BT_ASSERT_PRE_GRAPH_NON_NULL(_graph)                           \
-       BT_ASSERT_PRE_NON_NULL(_graph, _BT_ASSERT_PRE_GRAPH_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_GRAPH_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_GRAPH_ID, (_graph),   \
+               _BT_ASSERT_PRE_GRAPH_NAME)
 
 #define _BT_ASSERT_PRE_INTR_NAME       "Interrupter"
+#define _BT_ASSERT_PRE_INTR_ID         "interrupter"
 
 #define BT_ASSERT_PRE_INTR_NON_NULL(_intr)                             \
-       BT_ASSERT_PRE_NON_NULL(_intr, _BT_ASSERT_PRE_INTR_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INTR_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INTR_ID, (_intr),     \
+               _BT_ASSERT_PRE_INTR_NAME)
 
 #define _BT_ASSERT_PRE_PORT_NAME       "Port"
+#define _BT_ASSERT_PRE_PORT_ID         "port"
 
 #define BT_ASSERT_PRE_PORT_NON_NULL(_port)                             \
-       BT_ASSERT_PRE_NON_NULL(_port, _BT_ASSERT_PRE_PORT_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PORT_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PORT_ID, (_port),     \
+               _BT_ASSERT_PRE_PORT_NAME)
 
 #define _BT_ASSERT_PRE_QUERY_EXEC_NAME "Query executor"
+#define _BT_ASSERT_PRE_QUERY_EXEC_ID   "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)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_QUERY_EXEC_ID,            \
+               (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_QUERY_EXEC_ID,        \
+               (_query_exec), _BT_ASSERT_PRE_QUERY_EXEC_NAME)
 
 #define _BT_ASSERT_PRE_PLUGIN_SET_NAME "Plugin set"
+#define _BT_ASSERT_PRE_PLUGIN_SET_ID   "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)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_ID,            \
+               (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_ID,        \
+               (_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_ID                               \
+       _BT_ASSERT_PRE_PLUGIN_SET_ID "-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)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_OUT_ID,        \
+               (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_OUT_ID,    \
+               (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME)
 
 #define _BT_ASSERT_PRE_PLUGIN_NAME     "Plugin"
+#define _BT_ASSERT_PRE_PLUGIN_ID       "plugin"
 
 #define BT_ASSERT_PRE_PLUGIN_NON_NULL(_plugin)                         \
-       BT_ASSERT_PRE_NON_NULL(_plugin, _BT_ASSERT_PRE_PLUGIN_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_ID, (_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_ID                                   \
+       _BT_ASSERT_PRE_PLUGIN_ID "-output"
 
 #define BT_ASSERT_PRE_PLUGIN_OUT_NON_NULL(_plugin)                     \
-       BT_ASSERT_PRE_NON_NULL(_plugin, _BT_ASSERT_PRE_PLUGIN_OUT_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_OUT_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_OUT_ID,        \
+               (_plugin), _BT_ASSERT_PRE_PLUGIN_OUT_NAME)
 
 #define _BT_ASSERT_PRE_ERROR_NAME      "Error"
+#define _BT_ASSERT_PRE_ERROR_ID                "error"
 
 #define BT_ASSERT_PRE_ERROR_NON_NULL(_error)                           \
-       BT_ASSERT_PRE_NON_NULL(_error, _BT_ASSERT_PRE_ERROR_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_ERROR_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_ERROR_ID, (_error),   \
+               _BT_ASSERT_PRE_ERROR_NAME)
 
 #define _BT_ASSERT_PRE_ERROR_CAUSE_NAME        "Error cause"
+#define _BT_ASSERT_PRE_ERROR_CAUSE_ID  "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)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_ERROR_CAUSE_ID,           \
+               (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_ERROR_CAUSE_ID,       \
+               (_error_cause), _BT_ASSERT_PRE_ERROR_CAUSE_NAME)
 
 #define _BT_ASSERT_PRE_INT_RANGE_NAME  "Integer range"
+#define _BT_ASSERT_PRE_INT_RANGE_ID    "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)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_ID,             \
+               (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_ID,         \
+               (_int_range), _BT_ASSERT_PRE_INT_RANGE_NAME)
+
+#define BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY_FROM_FUNC(_func, _range_set) \
+       BT_ASSERT_PRE_FROM_FUNC(_func, "integer-range-set-is-not-empty", \
+               (_range_set)->ranges->len > 0,                          \
+               "Integer range set is empty: %!+R", (_range_set))
+
+#define BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY(_range_set)              \
+       BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY_FROM_FUNC(__func__,       \
+               (_range_set))
 
 #define _BT_ASSERT_PRE_INT_RANGE_SET_NAME      "Integer range set"
+#define _BT_ASSERT_PRE_INT_RANGE_SET_ID                "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_INT_RANGE_SET_NON_NULL_FROM_FUNC(_func, _range_set) \
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func,                         \
+               _BT_ASSERT_PRE_INT_RANGE_SET_ID, (_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_INT_RANGE_SET_NON_NULL(_range_set)               \
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_SET_ID,         \
+               (_range_set), _BT_ASSERT_PRE_INT_RANGE_SET_NAME)
+
+#define BT_ASSERT_PRE_DEV_INT_RANGE_SET_NON_NULL(_range_set)           \
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_SET_ID,     \
+               (_range_set), _BT_ASSERT_PRE_INT_RANGE_SET_NAME)
 
 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND(_value, _type)              \
        (((struct bt_value *) (_value))->type == (_type))
 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT                              \
        "Value has the wrong type: expected-type=%s, %![value-]+v"
 
-#define BT_ASSERT_PRE_VALUE_HAS_TYPE(_value, _type)                    \
-       BT_ASSERT_PRE(                                                  \
+#define _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id)          \
+       "is-" _type_id "-value:" _value_id
+
+#define BT_ASSERT_PRE_VALUE_HAS_TYPE_FROM_FUNC(_func, _value_id, _value, _type_id, _type) \
+       BT_ASSERT_PRE_FROM_FUNC(_func,                                  \
+               _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id),  \
                _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND((_value), (_type)),  \
                _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT,                      \
                bt_common_value_type_string(_type), (_value))
 
-#define BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(_value, _type)                        \
+#define BT_ASSERT_PRE_VALUE_HAS_TYPE(_value_id, _value, _type_id, _type) \
+       BT_ASSERT_PRE_VALUE_HAS_TYPE_FROM_FUNC(__func__, _value_id,     \
+               (_value), _type_id, (_type));
+
+#define BT_ASSERT_PRE_VALUE_IS_BOOL(_value)                            \
+       BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value),          \
+               "boolean", BT_VALUE_TYPE_BOOL);
+
+#define BT_ASSERT_PRE_VALUE_IS_UNSIGNED_INT(_value)                    \
+       BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value),          \
+               "unsigned-int", BT_VALUE_TYPE_UNSIGNED_INTEGER);
+
+#define BT_ASSERT_PRE_VALUE_IS_SIGNED_INT(_value)                      \
+       BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value),          \
+               "signed-int", BT_VALUE_TYPE_SIGNED_INTEGER);
+
+#define BT_ASSERT_PRE_VALUE_IS_REAL(_value)                            \
+       BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value),          \
+               "real", BT_VALUE_TYPE_REAL);
+
+#define BT_ASSERT_PRE_VALUE_IS_STRING(_value)                          \
+       BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value),          \
+               "string", BT_VALUE_TYPE_STRING);
+
+#define BT_ASSERT_PRE_VALUE_IS_ARRAY(_value)                           \
+       BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value),          \
+               "array", BT_VALUE_TYPE_ARRAY);
+
+#define BT_ASSERT_PRE_VALUE_IS_MAP_FROM_FUNC(_func, _value)            \
+       BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value),          \
+               "map", BT_VALUE_TYPE_MAP);
+
+#define BT_ASSERT_PRE_VALUE_IS_MAP(_value)                             \
+       BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value),          \
+               "map", BT_VALUE_TYPE_MAP);
+
+#define BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(_value_id, _value, _type_id, _type) \
        BT_ASSERT_PRE_DEV(                                              \
+               _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id),  \
                _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND((_value), (_type)),  \
                _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT,                      \
                bt_common_value_type_string(_type), (_value))
 
+#define BT_ASSERT_PRE_DEV_VALUE_IS_BOOL(_value)                        \
+       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value),      \
+               "boolean", BT_VALUE_TYPE_BOOL);
+
+#define BT_ASSERT_PRE_DEV_VALUE_IS_UNSIGNED_INT(_value)                \
+       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value),      \
+               "unsigned-int", BT_VALUE_TYPE_UNSIGNED_INTEGER);
+
+#define BT_ASSERT_PRE_DEV_VALUE_IS_SIGNED_INT(_value)                  \
+       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value),      \
+               "signed-int", BT_VALUE_TYPE_SIGNED_INTEGER);
+
+#define BT_ASSERT_PRE_DEV_VALUE_IS_REAL(_value)                                \
+       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value),      \
+               "real", BT_VALUE_TYPE_REAL);
+
+#define BT_ASSERT_PRE_DEV_VALUE_IS_STRING(_value)                      \
+       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value),      \
+               "string", BT_VALUE_TYPE_STRING);
+
+#define BT_ASSERT_PRE_DEV_VALUE_IS_ARRAY(_value)                       \
+       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value),      \
+               "array", BT_VALUE_TYPE_ARRAY);
+
+#define BT_ASSERT_PRE_DEV_VALUE_IS_MAP(_value)                                 \
+       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value),      \
+               "map", BT_VALUE_TYPE_MAP);
+
 #define _BT_ASSERT_PRE_VALUE_NAME      "Value object"
+#define _BT_ASSERT_PRE_VALUE_ID                "value-object"
+
+#define BT_ASSERT_PRE_VALUE_NON_NULL_FROM_FUNC(_func, _value)          \
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func,                         \
+               _BT_ASSERT_PRE_VALUE_ID, (_value), _BT_ASSERT_PRE_VALUE_NAME)
 
 #define BT_ASSERT_PRE_VALUE_NON_NULL(_value)                           \
-       BT_ASSERT_PRE_NON_NULL(_value, _BT_ASSERT_PRE_VALUE_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_VALUE_ID, (_value),       \
+               _BT_ASSERT_PRE_VALUE_NAME)
+
+#define BT_ASSERT_PRE_DEV_VALUE_NON_NULL_FROM_FUNC(_func, _value)      \
+       BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func,                     \
+               _BT_ASSERT_PRE_VALUE_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_VALUE_ID, (_value),   \
+               _BT_ASSERT_PRE_VALUE_NAME)
+
+#define BT_ASSERT_PRE_PARAM_VALUE_IS_MAP_FROM_FUNC(_func, _value)      \
+       BT_ASSERT_PRE_FROM_FUNC(_func,                                  \
+               "is-map-value:parameters-value-object",                 \
+               !(_value) || bt_value_is_map(_value),                   \
+               "Parameters value object is not a map value: %!+v", (_value));
 
 #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));
+       BT_ASSERT_PRE_PARAM_VALUE_IS_MAP_FROM_FUNC(__func__, (_value))
 
 #define _BT_ASSERT_PRE_RES_OUT_NAME    "Result (output)"
+#define _BT_ASSERT_PRE_RES_OUT_ID      "result-output"
 
 #define BT_ASSERT_PRE_RES_OUT_NON_NULL(_res)                           \
-       BT_ASSERT_PRE_NON_NULL(_res, _BT_ASSERT_PRE_RES_OUT_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_RES_OUT_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_RES_OUT_ID, (_res),   \
+               _BT_ASSERT_PRE_RES_OUT_NAME)
 
 #define BT_ASSERT_PRE_METHOD_NON_NULL(_method)                         \
-       BT_ASSERT_PRE_NON_NULL(_method, "Method");
+       BT_ASSERT_PRE_NON_NULL("method", (_method), "Method");
 
 #define _BT_ASSERT_PRE_NAME_NAME       "Name"
+#define _BT_ASSERT_PRE_NAME_ID         "name"
+
+#define BT_ASSERT_PRE_NAME_NON_NULL_FROM_FUNC(_func, _name)            \
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_NAME_ID, \
+               (_name), _BT_ASSERT_PRE_NAME_NAME)
 
 #define BT_ASSERT_PRE_NAME_NON_NULL(_name)                             \
-       BT_ASSERT_PRE_NON_NULL(_name, _BT_ASSERT_PRE_NAME_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_NAME_ID, (_name),         \
+               _BT_ASSERT_PRE_NAME_NAME)
+
+#define BT_ASSERT_PRE_DEV_NAME_NON_NULL_FROM_FUNC(_func, _name)                \
+       BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func,                     \
+               _BT_ASSERT_PRE_NAME_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_NAME_ID, (_name),     \
+               _BT_ASSERT_PRE_NAME_NAME)
 
 #define _BT_ASSERT_PRE_DESCR_NAME      "Description"
+#define _BT_ASSERT_PRE_DESCR_ID                "description"
 
 #define BT_ASSERT_PRE_DESCR_NON_NULL(_descr)                           \
-       BT_ASSERT_PRE_NON_NULL(_descr, _BT_ASSERT_PRE_DESCR_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_DESCR_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_DESCR_ID, (_descr),   \
+               _BT_ASSERT_PRE_DESCR_NAME)
 
 #define _BT_ASSERT_PRE_UUID_NAME       "UUID"
+#define _BT_ASSERT_PRE_UUID_ID         "uuid"
 
 #define BT_ASSERT_PRE_UUID_NON_NULL(_uuid)                             \
-       BT_ASSERT_PRE_NON_NULL(_uuid, _BT_ASSERT_PRE_UUID_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_UUID_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_UUID_ID, (_uuid),     \
+               _BT_ASSERT_PRE_UUID_NAME)
 
 #define _BT_ASSERT_PRE_KEY_NAME        "Key"
+#define _BT_ASSERT_PRE_KEY_ID  "key"
+
+#define BT_ASSERT_PRE_KEY_NON_NULL_FROM_FUNC(_func, _key)              \
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_KEY_ID,  \
+               (_key), _BT_ASSERT_PRE_KEY_NAME)
 
 #define BT_ASSERT_PRE_KEY_NON_NULL(_key)                               \
-       BT_ASSERT_PRE_NON_NULL(_key, _BT_ASSERT_PRE_KEY_NAME)
+       BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_KEY_ID, (_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)
+       BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_KEY_ID, (_key),       \
+               _BT_ASSERT_PRE_KEY_NAME)
 
 #endif /* BABELTRACE_ASSERT_COND_INTERNAL_H */
index f99eb93c82ae8cde999113e6d2a000acb8979ab7..9e14e4e70e895920a852707ca98d5464e12cfece 100644 (file)
 #include "lib/assert-cond.h"
 #include "lib/func-status.h"
 
+#define BT_ASSERT_PRE_FILE_NAME_NON_NULL(_file_name)                   \
+       BT_ASSERT_PRE_NON_NULL("file-name", (_file_name), "File name");
+
+#define BT_ASSERT_PRE_MSG_FMT_NON_NULL(_msg_fmt)                       \
+       BT_ASSERT_PRE_NON_NULL("message-format", (_msg_fmt), "Message format");
+
 /*
  * This points to the thread's error object, or it's `NULL` if there's
  * no current error object.
@@ -85,9 +91,9 @@ bt_current_thread_error_append_cause_from_unknown(
                try_create_thread_error();
        va_list args;
 
-       BT_ASSERT_PRE_NON_NULL(module_name, "Module name");
-       BT_ASSERT_PRE_NON_NULL(file_name, "File name");
-       BT_ASSERT_PRE_NON_NULL(msg_fmt, "Message format string");
+       BT_ASSERT_PRE_NON_NULL("module-name", module_name, "Module name");
+       BT_ASSERT_PRE_FILE_NAME_NON_NULL(file_name);
+       BT_ASSERT_PRE_MSG_FMT_NON_NULL(msg_fmt);
 
        if (status) {
                goto end;
@@ -114,8 +120,8 @@ bt_current_thread_error_append_cause_from_component(
        va_list args;
 
        BT_ASSERT_PRE_COMP_NON_NULL(self_comp);
-       BT_ASSERT_PRE_NON_NULL(file_name, "File name");
-       BT_ASSERT_PRE_NON_NULL(msg_fmt, "Message format string");
+       BT_ASSERT_PRE_FILE_NAME_NON_NULL(file_name);
+       BT_ASSERT_PRE_MSG_FMT_NON_NULL(msg_fmt);
 
        if (status) {
                goto end;
@@ -142,8 +148,8 @@ bt_current_thread_error_append_cause_from_component_class(
        va_list args;
 
        BT_ASSERT_PRE_COMP_CLS_NON_NULL(self_comp_class);
-       BT_ASSERT_PRE_NON_NULL(file_name, "File name");
-       BT_ASSERT_PRE_NON_NULL(msg_fmt, "Message format string");
+       BT_ASSERT_PRE_FILE_NAME_NON_NULL(file_name);
+       BT_ASSERT_PRE_MSG_FMT_NON_NULL(msg_fmt);
 
        if (status) {
                goto end;
@@ -170,8 +176,8 @@ bt_current_thread_error_append_cause_from_message_iterator(
        va_list args;
 
        BT_ASSERT_PRE_MSG_ITER_NON_NULL(self_iter);
-       BT_ASSERT_PRE_NON_NULL(file_name, "File name");
-       BT_ASSERT_PRE_NON_NULL(msg_fmt, "Message format string");
+       BT_ASSERT_PRE_FILE_NAME_NON_NULL(file_name);
+       BT_ASSERT_PRE_MSG_FMT_NON_NULL(msg_fmt);
 
        if (status) {
                goto end;
index 58a3749816b8f34efffb2ca3934a208171063350..9144bd96ddc528c9f52e47afe88d0c195bd678ed 100644 (file)
@@ -19,8 +19,9 @@
 #include "lib/assert-cond.h"
 #include "lib/func-status.h"
 
-#define BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(_cause, _exp_type)          \
-       BT_ASSERT_PRE(((const struct bt_error_cause *) (_cause))->actor_type == _exp_type, \
+#define BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(_cause, _exp_type_name, _exp_type) \
+       BT_ASSERT_PRE("error-cause-has-" _exp_type_name "-actor",       \
+               ((const struct bt_error_cause *) (_cause))->actor_type == _exp_type, \
                "Unexpected error cause's actor type: type=%s, exp-type=%s", \
                bt_error_cause_actor_type_string(((const struct bt_error_cause *) (_cause))->actor_type), \
                bt_error_cause_actor_type_string(_exp_type))
@@ -657,7 +658,7 @@ const char *bt_error_cause_component_actor_get_component_name(
                (const void *) cause;
 
        BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
-       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause,
+       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "component",
                BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT);
        return spec_cause->comp_name->str;
 }
@@ -669,7 +670,7 @@ bt_component_class_type bt_error_cause_component_actor_get_component_class_type(
                (const void *) cause;
 
        BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
-       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause,
+       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "component",
                BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT);
        return spec_cause->comp_class_id.type;
 }
@@ -681,7 +682,7 @@ const char *bt_error_cause_component_actor_get_component_class_name(
                (const void *) cause;
 
        BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
-       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause,
+       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "component",
                BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT);
        return spec_cause->comp_class_id.name->str;
 }
@@ -693,7 +694,7 @@ const char *bt_error_cause_component_actor_get_plugin_name(
                (const void *) cause;
 
        BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
-       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause,
+       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "component",
                BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT);
        return spec_cause->comp_class_id.plugin_name->len > 0 ?
                spec_cause->comp_class_id.plugin_name->str : NULL;
@@ -707,7 +708,7 @@ bt_error_cause_component_class_actor_get_component_class_type(
                (const void *) cause;
 
        BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
-       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause,
+       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "component-class",
                BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS);
        return spec_cause->comp_class_id.type;
 }
@@ -719,7 +720,7 @@ const char *bt_error_cause_component_class_actor_get_component_class_name(
                (const void *) cause;
 
        BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
-       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause,
+       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "component-class",
                BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS);
        return spec_cause->comp_class_id.name->str;
 }
@@ -731,7 +732,7 @@ const char *bt_error_cause_component_class_actor_get_plugin_name(
                (const void *) cause;
 
        BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
-       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause,
+       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "component-class",
                BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS);
        return spec_cause->comp_class_id.plugin_name->len > 0 ?
                spec_cause->comp_class_id.plugin_name->str : NULL;
@@ -744,7 +745,7 @@ const char *bt_error_cause_message_iterator_actor_get_component_name(
                (const void *) cause;
 
        BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
-       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause,
+       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "message-iterator",
                BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR);
        return spec_cause->comp_name->str;
 }
@@ -757,7 +758,7 @@ bt_error_cause_message_iterator_actor_get_component_output_port_name(
                (const void *) cause;
 
        BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
-       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause,
+       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "message-iterator",
                BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR);
        return spec_cause->output_port_name->str;
 }
@@ -770,7 +771,7 @@ bt_error_cause_message_iterator_actor_get_component_class_type(
                (const void *) cause;
 
        BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
-       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause,
+       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "message-iterator",
                BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR);
        return spec_cause->comp_class_id.type;
 }
@@ -782,7 +783,7 @@ const char *bt_error_cause_message_iterator_actor_get_component_class_name(
                (const void *) cause;
 
        BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
-       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause,
+       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "message-iterator",
                BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR);
        return spec_cause->comp_class_id.name->str;
 }
@@ -794,7 +795,7 @@ const char *bt_error_cause_message_iterator_actor_get_plugin_name(
                (const void *) cause;
 
        BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(cause);
-       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause,
+       BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause, "message-iterator",
                BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR);
        return spec_cause->comp_class_id.plugin_name->len > 0 ?
                spec_cause->comp_class_id.plugin_name->str : NULL;
index 7f31aa3022850ebef7e2aba6ba9a344003c4d6e5..dcdd8e7dd8b4aa46c4c4fa6dbcc186dabd20136b 100644 (file)
@@ -20,7 +20,8 @@
 #include "lib/graph/message-iterator-class.h"
 
 #define BT_ASSERT_PRE_DEV_COMP_CLS_HOT(_cc)                            \
-       BT_ASSERT_PRE_DEV_HOT(((const struct bt_component_class *) (_cc)), \
+       BT_ASSERT_PRE_DEV_HOT("component-class",                        \
+               ((const struct bt_component_class *) (_cc)), \
                "Component class", ": %!+C", (_cc))
 
 static
@@ -239,7 +240,7 @@ struct bt_component_class_sink *bt_component_class_sink_create(
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_NAME_NON_NULL(name);
-       BT_ASSERT_PRE_NON_NULL(method, "Consume next method");
+       BT_ASSERT_PRE_NON_NULL("consume-method", method, "Consume next method");
        BT_LOGI("Creating sink component class: "
                "name=\"%s\", consume-method-addr=%p",
                name, method);
@@ -549,7 +550,7 @@ enum bt_component_class_set_help_status bt_component_class_set_help(
 {
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
-       BT_ASSERT_PRE_NON_NULL(help, "Help");
+       BT_ASSERT_PRE_NON_NULL("help-text", help, "Help text");
        BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
        g_string_assign(comp_cls->help, help);
        BT_LIB_LOGD("Set component class's help text: %!+C", comp_cls);
index 6582b8deaac79908ce15389577b25a8128bfaa95..44bf484343c2d8cbc0ff54e3abcaa1a9f39daaec 100644 (file)
@@ -32,8 +32,6 @@ struct bt_component *bt_component_filter_create(
 {
        struct bt_component_filter *filter = NULL;
 
-       BT_ASSERT_PRE_NO_ERROR();
-
        filter = g_new0(struct bt_component_filter, 1);
        if (!filter) {
                BT_LIB_LOGE_APPEND_CAUSE(
@@ -64,39 +62,56 @@ bt_component_filter_borrow_class_const(
 uint64_t bt_component_filter_get_output_port_count(
                const struct bt_component_filter *comp)
 {
-       return bt_component_get_output_port_count((void *) comp);
+       /* bt_component_get_output_port_count() checks preconditions */
+       return bt_component_get_output_port_count((void *) comp, __func__);
 }
 
 const struct bt_port_output *
 bt_component_filter_borrow_output_port_by_name_const(
                const struct bt_component_filter *comp, const char *name)
 {
+       /*
+        * bt_component_borrow_output_port_by_name() logs details/errors
+        * and checks preconditions.
+        */
        return bt_component_borrow_output_port_by_name(
-               (void *) comp, name);
+               (void *) comp, name, __func__);
 }
 
 struct bt_self_component_port_output *
 bt_self_component_filter_borrow_output_port_by_name(
                struct bt_self_component_filter *comp, const char *name)
 {
+       /*
+        * bt_component_borrow_output_port_by_name() logs details/errors
+        * and checks preconditions.
+        */
        return (void *) bt_component_borrow_output_port_by_name(
-               (void *) comp, name);
+               (void *) comp, name, __func__);
 }
 
 const struct bt_port_output *
 bt_component_filter_borrow_output_port_by_index_const(
                const struct bt_component_filter *comp, uint64_t index)
 {
+       /*
+        * bt_component_borrow_output_port_by_index() logs
+        * details/errors and checks preconditions.
+        */
        return bt_component_borrow_output_port_by_index(
-               (void *) comp, index);
+               (void *) comp, index, __func__);
 }
 
 struct bt_self_component_port_output *
 bt_self_component_filter_borrow_output_port_by_index(
                struct bt_self_component_filter *comp, uint64_t index)
 {
+       /*
+        * bt_component_borrow_output_port_by_index() logs
+        * details/errors and checks preconditions.
+        */
        return (void *) bt_component_borrow_output_port_by_index(
-               (void *) comp, index);
+               (void *) comp, index, __func__);
 }
 
 enum bt_self_component_add_port_status bt_self_component_filter_add_output_port(
@@ -109,10 +124,13 @@ enum bt_self_component_add_port_status bt_self_component_filter_add_output_port(
        struct bt_port *port = NULL;
 
        BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_OUTPUT_PORT_NAME_UNIQUE(comp, name);
 
-       /* bt_component_add_output_port() logs details and errors */
-       status = bt_component_add_output_port(comp, name, user_data, &port);
+       /*
+        * bt_component_add_output_port() logs details/errors and checks
+        * preconditions.
+        */
+       status = bt_component_add_output_port(comp, name, user_data, &port,
+               __func__);
        if (status != BT_FUNC_STATUS_OK) {
                goto end;
        }
@@ -130,43 +148,55 @@ end:
 uint64_t bt_component_filter_get_input_port_count(
                const struct bt_component_filter *component)
 {
-       /* bt_component_get_input_port_count() logs details/errors */
-       return bt_component_get_input_port_count((void *) component);
+       /* bt_component_get_input_port_count() checks preconditions */
+       return bt_component_get_input_port_count((void *) component, __func__);
 }
 
 const struct bt_port_input *bt_component_filter_borrow_input_port_by_name_const(
                const struct bt_component_filter *component, const char *name)
 {
-       /* bt_component_borrow_input_port_by_name() logs details/errors */
+       /*
+        * bt_component_borrow_input_port_by_name() logs details/errors
+        * and checks preconditions.
+        */
        return bt_component_borrow_input_port_by_name(
-               (void *) component, name);
+               (void *) component, name, __func__);
 }
 
 struct bt_self_component_port_input *
 bt_self_component_filter_borrow_input_port_by_name(
                struct bt_self_component_filter *component, const char *name)
 {
-       /* bt_component_borrow_input_port_by_name() logs details/errors */
+       /*
+        * bt_component_borrow_input_port_by_name() logs details/errors
+        * and checks preconditions.
+        */
        return (void *) bt_component_borrow_input_port_by_name(
-               (void *) component, name);
+               (void *) component, name, __func__);
 }
 
 const struct bt_port_input *
 bt_component_filter_borrow_input_port_by_index_const(
                const struct bt_component_filter *component, uint64_t index)
 {
-       /* bt_component_borrow_input_port_by_index() logs details/errors */
+       /*
+        * bt_component_borrow_input_port_by_index() logs details/errors
+        * and checks preconditions.
+        */
        return bt_component_borrow_input_port_by_index(
-               (void *) component, index);
+               (void *) component, index, __func__);
 }
 
 struct bt_self_component_port_input *
 bt_self_component_filter_borrow_input_port_by_index(
                struct bt_self_component_filter *component, uint64_t index)
 {
-       /* bt_component_borrow_input_port_by_index() logs details/errors */
+       /*
+        * bt_component_borrow_input_port_by_index() logs details/errors
+        * and checks preconditions.
+        */
        return (void *) bt_component_borrow_input_port_by_index(
-               (void *) component, index);
+               (void *) component, index, __func__);
 }
 
 enum bt_self_component_add_port_status bt_self_component_filter_add_input_port(
@@ -179,10 +209,13 @@ enum bt_self_component_add_port_status bt_self_component_filter_add_input_port(
        struct bt_component *comp = (void *) self_comp;
 
        BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_INPUT_PORT_NAME_UNIQUE(comp, name);
 
-       /* bt_component_add_input_port() logs details/errors */
-       status = bt_component_add_input_port(comp, name, user_data, &port);
+       /*
+        * bt_component_add_input_port() logs details/errors and checks
+        * preconditions.
+        */
+       status = bt_component_add_input_port(comp, name, user_data, &port,
+               __func__);
        if (status != BT_FUNC_STATUS_OK) {
                goto end;
        }
index d9d33cc9ab205c6a5de9e7722c10f25e1c8e7e16..d45532b455c8e89c1740d0b1711e5ab8cd8bb43a 100644 (file)
@@ -32,8 +32,6 @@ struct bt_component *bt_component_sink_create(
 {
        struct bt_component_sink *sink = NULL;
 
-       BT_ASSERT_PRE_NO_ERROR();
-
        sink = g_new0(struct bt_component_sink, 1);
        if (!sink) {
                BT_LIB_LOGE_APPEND_CAUSE(
@@ -64,42 +62,55 @@ bt_component_sink_borrow_class_const(
 uint64_t bt_component_sink_get_input_port_count(
                const struct bt_component_sink *component)
 {
-       /* bt_component_get_input_port_count() logs details/errors */
-       return bt_component_get_input_port_count((void *) component);
+       /* bt_component_get_input_port_count() checks preconditions */
+       return bt_component_get_input_port_count((void *) component, __func__);
 }
 
 const struct bt_port_input *
 bt_component_sink_borrow_input_port_by_name_const(
                const struct bt_component_sink *component, const char *name)
 {
-       /* bt_component_borrow_input_port_by_name() logs details/errors */
-       return bt_component_borrow_input_port_by_name((void *) component, name);
+       /*
+        * bt_component_borrow_input_port_by_name() logs details/errors
+        * and checks preconditions.
+        */
+       return bt_component_borrow_input_port_by_name((void *) component, name,
+               __func__);
 }
 
 struct bt_self_component_port_input *
 bt_self_component_sink_borrow_input_port_by_name(
                struct bt_self_component_sink *component, const char *name)
 {
-       /* bt_component_borrow_input_port_by_name() logs details/errors */
+       /*
+        * bt_component_borrow_input_port_by_name() logs details/errors
+        * and checks preconditions.
+        */
        return (void *) bt_component_borrow_input_port_by_name(
-               (void *) component, name);
+               (void *) component, name, __func__);
 }
 
 const struct bt_port_input *bt_component_sink_borrow_input_port_by_index_const(
                const struct bt_component_sink *component, uint64_t index)
 {
-       /* bt_component_borrow_input_port_by_index() logs details/errors */
+       /*
+        * bt_component_borrow_input_port_by_index() logs details/errors
+        * and checks preconditions.
+        */
        return bt_component_borrow_input_port_by_index(
-               (void *) component, index);
+               (void *) component, index, __func__);
 }
 
 struct bt_self_component_port_input *
 bt_self_component_sink_borrow_input_port_by_index(
                struct bt_self_component_sink *component, uint64_t index)
 {
-       /* bt_component_borrow_input_port_by_index() logs details/errors */
+       /*
+        * bt_component_borrow_input_port_by_index() logs details/errors
+        * and checks preconditions.
+        */
        return (void *) bt_component_borrow_input_port_by_index(
-               (void *) component, index);
+               (void *) component, index, __func__);
 }
 
 enum bt_self_component_add_port_status bt_self_component_sink_add_input_port(
@@ -112,10 +123,13 @@ enum bt_self_component_add_port_status bt_self_component_sink_add_input_port(
        struct bt_component *comp = (void *) self_comp;
 
        BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_INPUT_PORT_NAME_UNIQUE(comp, name);
 
-       /* bt_component_add_input_port() logs details/errors */
-       status = bt_component_add_input_port(comp, name, user_data, &port);
+       /*
+        * bt_component_add_input_port() logs details/errors and checks
+        * preconditions.
+        */
+       status = bt_component_add_input_port(comp, name, user_data, &port,
+               __func__);
        if (status != BT_FUNC_STATUS_OK) {
                goto end;
        }
index c1638fd3d4bd041a050f87e53d31d5cb5c8d6c42..71d28b2884e1858954c454e88e0baac70ea3abf4 100644 (file)
@@ -32,8 +32,6 @@ struct bt_component *bt_component_source_create(
 {
        struct bt_component_source *source = NULL;
 
-       BT_ASSERT_PRE_NO_ERROR();
-
        source = g_new0(struct bt_component_source, 1);
        if (!source) {
                BT_LIB_LOGE_APPEND_CAUSE(
@@ -64,37 +62,56 @@ bt_component_source_borrow_class_const(
 uint64_t bt_component_source_get_output_port_count(
                const struct bt_component_source *comp)
 {
-       return bt_component_get_output_port_count((void *) comp);
+       /* bt_component_get_output_port_count() checks preconditions */
+       return bt_component_get_output_port_count((void *) comp, __func__);
 }
 
 const struct bt_port_output *
 bt_component_source_borrow_output_port_by_name_const(
                const struct bt_component_source *comp, const char *name)
 {
-       return bt_component_borrow_output_port_by_name((void *) comp, name);
+       /*
+        * bt_component_borrow_output_port_by_name() logs details/errors
+        * and checks preconditions.
+        */
+       return bt_component_borrow_output_port_by_name((void *) comp, name,
+               __func__);
 }
 
 struct bt_self_component_port_output *
 bt_self_component_source_borrow_output_port_by_name(
                struct bt_self_component_source *comp, const char *name)
 {
+       /*
+        * bt_component_borrow_output_port_by_name() logs details/errors
+        * and checks preconditions.
+        */
        return (void *) bt_component_borrow_output_port_by_name(
-               (void *) comp, name);
+               (void *) comp, name, __func__);
 }
 
 const struct bt_port_output *
 bt_component_source_borrow_output_port_by_index_const(
                const struct bt_component_source *comp, uint64_t index)
 {
-       return bt_component_borrow_output_port_by_index((void *) comp, index);
+       /*
+        * bt_component_borrow_output_port_by_index() logs
+        * details/errors and checks preconditions.
+        */
+       return bt_component_borrow_output_port_by_index((void *) comp, index,
+               __func__);
 }
 
 struct bt_self_component_port_output *
 bt_self_component_source_borrow_output_port_by_index(
                struct bt_self_component_source *comp, uint64_t index)
 {
+       /*
+        * bt_component_borrow_output_port_by_index() logs
+        * details/errors and checks preconditions.
+        */
        return (void *) bt_component_borrow_output_port_by_index(
-               (void *) comp, index);
+               (void *) comp, index, __func__);
 }
 
 enum bt_self_component_add_port_status bt_self_component_source_add_output_port(
@@ -109,8 +126,12 @@ enum bt_self_component_add_port_status bt_self_component_source_add_output_port(
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_OUTPUT_PORT_NAME_UNIQUE(comp, name);
 
-       /* bt_component_add_output_port() logs details and errors */
-       status = bt_component_add_output_port(comp, name, user_data, &port);
+       /*
+        * bt_component_add_output_port() logs details/errors and checks
+        * preconditions.
+        */
+       status = bt_component_add_output_port(comp, name, user_data, &port,
+               __func__);
        if (status != BT_FUNC_STATUS_OK) {
                goto end;
        }
index d4d01f08d16e623fe27bebd3071263750c4c99dd..fcfdb8b9cba6f403d290a4689adbeb2b31766598 100644 (file)
@@ -52,6 +52,7 @@ static
 void finalize_component(struct bt_component *comp)
 {
        typedef void (*method_t)(void *);
+       const char *method_name;
 
        method_t method = NULL;
 
@@ -63,6 +64,7 @@ void finalize_component(struct bt_component *comp)
                struct bt_component_class_source *src_cc = (void *) comp->class;
 
                method = (method_t) src_cc->methods.finalize;
+               method_name = "bt_component_class_source_finalize_method";
                break;
        }
        case BT_COMPONENT_CLASS_TYPE_FILTER:
@@ -70,6 +72,7 @@ void finalize_component(struct bt_component *comp)
                struct bt_component_class_filter *flt_cc = (void *) comp->class;
 
                method = (method_t) flt_cc->methods.finalize;
+               method_name = "bt_component_class_filter_finalize_method";
                break;
        }
        case BT_COMPONENT_CLASS_TYPE_SINK:
@@ -77,6 +80,7 @@ void finalize_component(struct bt_component *comp)
                struct bt_component_class_sink *sink_cc = (void *) comp->class;
 
                method = (method_t) sink_cc->methods.finalize;
+               method_name = "bt_component_class_sink_finalize_method";
                break;
        }
        default:
@@ -91,7 +95,7 @@ void finalize_component(struct bt_component *comp)
                BT_LIB_LOGI("Calling user's component finalization method: "
                        "%![comp-]+c", comp);
                method(comp);
-               BT_ASSERT_POST_NO_ERROR();
+               BT_ASSERT_POST_NO_ERROR(method_name);
 
                if (saved_error) {
                        BT_CURRENT_THREAD_MOVE_ERROR_AND_RESET(saved_error);
@@ -187,17 +191,18 @@ static
 enum bt_self_component_add_port_status add_port(
                struct bt_component *component, GPtrArray *ports,
                enum bt_port_type port_type, const char *name, void *user_data,
-               struct bt_port **port)
+               struct bt_port **port, const char *api_func)
 {
        struct bt_port *new_port = NULL;
        struct bt_graph *graph = NULL;
        enum bt_self_component_add_port_status status;
 
-       BT_ASSERT_PRE_COMP_NON_NULL(component);
-       BT_ASSERT_PRE_NAME_NON_NULL(name);
-       BT_ASSERT_PRE(strlen(name) > 0, "Name is empty");
+       BT_ASSERT(component);
+       BT_ASSERT(name);
+       BT_ASSERT_PRE_FROM_FUNC(api_func, "name-is-not-empty",
+               strlen(name) > 0, "Name is empty");
        graph = bt_component_borrow_graph(component);
-       BT_ASSERT_PRE(
+       BT_ASSERT_PRE_FROM_FUNC(api_func, "graph-is-not-configured",
                graph->config_state == BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
                "Component's graph is already configured: "
                "%![comp-]+c, %![graph-]+g", component, graph);
@@ -257,16 +262,18 @@ end:
 }
 
 BT_HIDDEN
-uint64_t bt_component_get_input_port_count(const struct bt_component *comp)
+uint64_t bt_component_get_input_port_count(const struct bt_component *comp,
+               const char *api_func)
 {
-       BT_ASSERT_PRE_DEV_COMP_NON_NULL(comp);
+       BT_ASSERT_PRE_DEV_COMP_NON_NULL_FROM_FUNC(api_func, comp);
        return (uint64_t) comp->input_ports->len;
 }
 
 BT_HIDDEN
-uint64_t bt_component_get_output_port_count(const struct bt_component *comp)
+uint64_t bt_component_get_output_port_count(const struct bt_component *comp,
+               const char *api_func)
 {
-       BT_ASSERT_PRE_DEV_COMP_NON_NULL(comp);
+       BT_ASSERT_PRE_DEV_COMP_NON_NULL_FROM_FUNC(api_func, comp);
        return (uint64_t) comp->output_ports->len;
 }
 
@@ -380,12 +387,12 @@ void bt_component_set_graph(struct bt_component *component,
 
 static
 struct bt_port *borrow_port_by_name(GPtrArray *ports,
-               const char *name)
+               const char *name, const char *api_func)
 {
        uint64_t i;
        struct bt_port *ret_port = NULL;
 
-       BT_ASSERT(name);
+       BT_ASSERT_PRE_DEV_NAME_NON_NULL_FROM_FUNC(api_func, name);
 
        for (i = 0; i < ports->len; i++) {
                struct bt_port *port = g_ptr_array_index(ports, i);
@@ -401,66 +408,84 @@ struct bt_port *borrow_port_by_name(GPtrArray *ports,
 
 BT_HIDDEN
 struct bt_port_input *bt_component_borrow_input_port_by_name(
-               struct bt_component *comp, const char *name)
+               struct bt_component *comp, const char *name,
+               const char *api_func)
 {
-       BT_ASSERT(comp);
-       return (void *) borrow_port_by_name(comp->input_ports, name);
+       BT_ASSERT_PRE_DEV_COMP_NON_NULL_FROM_FUNC(api_func, comp);
+       return (void *) borrow_port_by_name(comp->input_ports, name, api_func);
 }
 
 BT_HIDDEN
 struct bt_port_output *bt_component_borrow_output_port_by_name(
-               struct bt_component *comp, const char *name)
+               struct bt_component *comp, const char *name,
+               const char *api_func)
 {
-       BT_ASSERT_PRE_DEV_COMP_NON_NULL(comp);
+       BT_ASSERT_PRE_DEV_COMP_NON_NULL_FROM_FUNC(api_func, comp);
        return (void *)
-               borrow_port_by_name(comp->output_ports, name);
+               borrow_port_by_name(comp->output_ports, name, api_func);
 }
 
 static
-struct bt_port *borrow_port_by_index(GPtrArray *ports, uint64_t index)
+struct bt_port *borrow_port_by_index(GPtrArray *ports, uint64_t index,
+               const char *api_func)
 {
-       BT_ASSERT(index < ports->len);
+       BT_ASSERT_PRE_DEV_VALID_INDEX_FROM_FUNC(api_func, index, ports->len);
        return g_ptr_array_index(ports, index);
 }
 
 BT_HIDDEN
 struct bt_port_input *bt_component_borrow_input_port_by_index(
-               struct bt_component *comp, uint64_t index)
+               struct bt_component *comp, uint64_t index,
+               const char *api_func)
 {
-       BT_ASSERT_PRE_DEV_COMP_NON_NULL(comp);
-       BT_ASSERT_PRE_DEV_VALID_INDEX(index, comp->input_ports->len);
+       BT_ASSERT_PRE_DEV_COMP_NON_NULL_FROM_FUNC(api_func, comp);
        return (void *)
-               borrow_port_by_index(comp->input_ports, index);
+               borrow_port_by_index(comp->input_ports, index, api_func);
 }
 
 BT_HIDDEN
 struct bt_port_output *bt_component_borrow_output_port_by_index(
-               struct bt_component *comp, uint64_t index)
+               struct bt_component *comp, uint64_t index,
+               const char *api_func)
 {
-       BT_ASSERT_PRE_DEV_COMP_NON_NULL(comp);
-       BT_ASSERT_PRE_DEV_VALID_INDEX(index, comp->output_ports->len);
+       BT_ASSERT_PRE_DEV_COMP_NON_NULL_FROM_FUNC(api_func, comp);
        return (void *)
-               borrow_port_by_index(comp->output_ports, index);
+               borrow_port_by_index(comp->output_ports, index, api_func);
 }
 
 BT_HIDDEN
 enum bt_self_component_add_port_status bt_component_add_input_port(
                struct bt_component *component, const char *name,
-               void *user_data, struct bt_port **port)
+               void *user_data, struct bt_port **port, const char *api_func)
 {
-       /* add_port() logs details */
+       BT_ASSERT_PRE_COMP_NON_NULL_FROM_FUNC(api_func, component);
+       BT_ASSERT_PRE_NAME_NON_NULL_FROM_FUNC(api_func, name);
+       BT_ASSERT_PRE_FROM_FUNC(api_func, "input-port-name-is-unique",
+               bt_component_port_name_is_unique(component->input_ports, name),
+               "Input port name is not unique: name=\"%s\", %![comp-]c",
+               name, component);
+
+       /* add_port() logs details and checks preconditions */
        return add_port(component, component->input_ports,
-               BT_PORT_TYPE_INPUT, name, user_data, port);
+               BT_PORT_TYPE_INPUT, name, user_data, port, api_func);
 }
 
 BT_HIDDEN
 enum bt_self_component_add_port_status bt_component_add_output_port(
                struct bt_component *component, const char *name,
-               void *user_data, struct bt_port **port)
+               void *user_data, struct bt_port **port,
+               const char *api_func)
 {
-       /* add_port() logs details */
+       BT_ASSERT_PRE_COMP_NON_NULL_FROM_FUNC(api_func, component);
+       BT_ASSERT_PRE_NAME_NON_NULL_FROM_FUNC(api_func, name);
+       BT_ASSERT_PRE_FROM_FUNC(api_func, "output-port-name-is-unique",
+               bt_component_port_name_is_unique(component->output_ports, name),
+               "Output port name is not unique: name=\"%s\", %![comp-]c",
+               name, component);
+
+       /* add_port() logs details and checks preconditions */
        return add_port(component, component->output_ports,
-               BT_PORT_TYPE_OUTPUT, name, user_data, port);
+               BT_PORT_TYPE_OUTPUT, name, user_data, port, api_func);
 }
 
 BT_HIDDEN
@@ -496,6 +521,7 @@ bt_component_port_connected(
        enum bt_component_class_port_connected_method_status status =
                BT_FUNC_STATUS_OK;
        method_t method = NULL;
+       const char *method_name = NULL;
 
        BT_ASSERT(comp);
        BT_ASSERT(self_port);
@@ -509,6 +535,7 @@ bt_component_port_connected(
                switch (self_port->type) {
                case BT_PORT_TYPE_OUTPUT:
                        method = (method_t) src_cc->methods.output_port_connected;
+                       method_name = "bt_component_class_source_output_port_connected_method";
                        break;
                default:
                        bt_common_abort();
@@ -523,9 +550,11 @@ bt_component_port_connected(
                switch (self_port->type) {
                case BT_PORT_TYPE_INPUT:
                        method = (method_t) flt_cc->methods.input_port_connected;
+                       method_name = "bt_component_class_filter_input_port_connected_method";
                        break;
                case BT_PORT_TYPE_OUTPUT:
                        method = (method_t) flt_cc->methods.output_port_connected;
+                       method_name = "bt_component_class_filter_output_port_connected_method";
                        break;
                default:
                        bt_common_abort();
@@ -540,6 +569,7 @@ bt_component_port_connected(
                switch (self_port->type) {
                case BT_PORT_TYPE_INPUT:
                        method = (method_t) sink_cc->methods.input_port_connected;
+                       method_name = "bt_component_class_sink_input_port_connected_method";
                        break;
                default:
                        bt_common_abort();
@@ -558,12 +588,13 @@ bt_component_port_connected(
                status = (int) method(comp, self_port, (void *) other_port);
                BT_LOGD("User method returned: status=%s",
                        bt_common_func_status_string(status));
-               BT_ASSERT_POST(status == BT_FUNC_STATUS_OK ||
+               BT_ASSERT_POST(method_name, "valid-status",
+                       status == BT_FUNC_STATUS_OK ||
                        status == BT_FUNC_STATUS_ERROR ||
                        status == BT_FUNC_STATUS_MEMORY_ERROR,
                        "Unexpected returned component status: status=%s",
                        bt_common_func_status_string(status));
-               BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(status);
+               BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(method_name, status);
        }
 
        return status;
index 387996aac4ad5e592a8a35a3ebdbc57101898f2c..f12ca3b1aff173de1b623108a56ad31ad7af311f 100644 (file)
 #include "component-class.h"
 #include "port.h"
 
-#define BT_ASSERT_PRE_INPUT_PORT_NAME_UNIQUE(comp, name) \
-       BT_ASSERT_PRE(bt_component_port_name_is_unique(comp->input_ports, name), \
-               "Input port name is not unique: name=\"%s\", %![comp-]c", name, comp);
-
-#define BT_ASSERT_PRE_OUTPUT_PORT_NAME_UNIQUE(comp, name) \
-       BT_ASSERT_PRE(bt_component_port_name_is_unique(comp->output_ports, name), \
+#define BT_ASSERT_PRE_OUTPUT_PORT_NAME_UNIQUE(comp, name)              \
+       BT_ASSERT_PRE("output-port-is-unique",                          \
+               bt_component_port_name_is_unique(comp->output_ports, name), \
                "Output port name is not unique: name=\"%s\", %![comp-]c", name, comp);
 
 typedef void (*bt_component_destroy_listener_func)(
@@ -88,36 +85,44 @@ void bt_component_set_graph(struct bt_component *component,
                struct bt_graph *graph);
 
 BT_HIDDEN
-uint64_t bt_component_get_input_port_count(const struct bt_component *comp);
+uint64_t bt_component_get_input_port_count(const struct bt_component *comp,
+               const char *api_func);
 
 BT_HIDDEN
-uint64_t bt_component_get_output_port_count(const struct bt_component *comp);
+uint64_t bt_component_get_output_port_count(const struct bt_component *comp,
+               const char *api_func);
 
 BT_HIDDEN
 struct bt_port_input *bt_component_borrow_input_port_by_index(
-               struct bt_component *comp, uint64_t index);
+               struct bt_component *comp, uint64_t index,
+               const char *api_func);
 
 BT_HIDDEN
 struct bt_port_output *bt_component_borrow_output_port_by_index(
-               struct bt_component *comp, uint64_t index);
+               struct bt_component *comp, uint64_t index,
+               const char *api_func);
 
 BT_HIDDEN
 struct bt_port_input *bt_component_borrow_input_port_by_name(
-               struct bt_component *comp, const char *name);
+               struct bt_component *comp, const char *name,
+               const char *api_func);
 
 BT_HIDDEN
 struct bt_port_output *bt_component_borrow_output_port_by_name(
-               struct bt_component *comp, const char *name);
+               struct bt_component *comp, const char *name,
+               const char *api_func);
 
 BT_HIDDEN
 enum bt_self_component_add_port_status bt_component_add_input_port(
                struct bt_component *component, const char *name,
-               void *user_data, struct bt_port **port);
+               void *user_data, struct bt_port **port,
+               const char *api_func);
 
 BT_HIDDEN
 enum bt_self_component_add_port_status bt_component_add_output_port(
                struct bt_component *component, const char *name,
-               void *user_data, struct bt_port **port);
+               void *user_data, struct bt_port **port,
+               const char *api_func);
 
 BT_HIDDEN
 bool bt_component_port_name_is_unique(GPtrArray *ports, const char *name);
index f40c61047078efdc8abcf4ad573dd44bc4e7cd6a..37c239946cdeb6d17735b8a5a74d97ba1fbda42f 100644 (file)
@@ -176,7 +176,8 @@ struct bt_graph *bt_graph_create(uint64_t mip_version)
        int ret;
 
        BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE(mip_version <= bt_get_maximal_mip_version(),
+       BT_ASSERT_PRE("valid-mip-version",
+               mip_version <= bt_get_maximal_mip_version(),
                "Unknown MIP version: mip-version=%" PRIu64 ", "
                "max-mip-version=%" PRIu64,
                mip_version, bt_get_maximal_mip_version());
@@ -313,19 +314,24 @@ enum bt_graph_connect_ports_status bt_graph_connect_ports(
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_GRAPH_NON_NULL(graph);
-       BT_ASSERT_PRE_NON_NULL(upstream_port, "Upstream port");
-       BT_ASSERT_PRE_NON_NULL(downstream_port, "Downstream port port");
-       BT_ASSERT_PRE(
+       BT_ASSERT_PRE_NON_NULL("upstream-port", upstream_port, "Upstream port");
+       BT_ASSERT_PRE_NON_NULL("downstream-port", downstream_port,
+               "Downstream port port");
+       BT_ASSERT_PRE("graph-is-not-configured",
                graph->config_state == BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
                "Graph is not in the \"configuring\" state: %!+g", graph);
-       BT_ASSERT_PRE(!bt_port_is_connected(upstream_port),
+       BT_ASSERT_PRE("upstream-port-is-not-connected",
+               !bt_port_is_connected(upstream_port),
                "Upstream port is already connected: %!+p", upstream_port);
-       BT_ASSERT_PRE(!bt_port_is_connected(downstream_port),
+       BT_ASSERT_PRE("downstream-port-is-not-connected",
+               !bt_port_is_connected(downstream_port),
                "Downstream port is already connected: %!+p", downstream_port);
-       BT_ASSERT_PRE(bt_port_borrow_component_inline((void *) upstream_port),
+       BT_ASSERT_PRE("upstream-port-has-component",
+               bt_port_borrow_component_inline((void *) upstream_port),
                "Upstream port does not belong to a component: %!+p",
                upstream_port);
-       BT_ASSERT_PRE(bt_port_borrow_component_inline((void *) downstream_port),
+       BT_ASSERT_PRE("downstream-port-has-component",
+               bt_port_borrow_component_inline((void *) downstream_port),
                "Downstream port does not belong to a component: %!+p",
                downstream_port);
        init_can_consume = graph->can_consume;
@@ -426,6 +432,8 @@ end:
        return status;
 }
 
+#define CONSUME_METHOD_NAME    "bt_component_class_sink_consume_method"
+
 static inline
 int consume_graph_sink(struct bt_component_sink *comp)
 {
@@ -439,14 +447,16 @@ int consume_graph_sink(struct bt_component_sink *comp)
        consume_status = sink_class->methods.consume((void *) comp);
        BT_LOGD("User method returned: status=%s",
                bt_common_func_status_string(consume_status));
-       BT_ASSERT_POST_DEV(consume_status == BT_FUNC_STATUS_OK ||
+       BT_ASSERT_POST_DEV(CONSUME_METHOD_NAME, "valid-status",
+               consume_status == BT_FUNC_STATUS_OK ||
                consume_status == BT_FUNC_STATUS_END ||
                consume_status == BT_FUNC_STATUS_AGAIN ||
                consume_status == BT_FUNC_STATUS_ERROR ||
                consume_status == BT_FUNC_STATUS_MEMORY_ERROR,
                "Invalid component status returned by consuming method: "
                "status=%s", bt_common_func_status_string(consume_status));
-       BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(consume_status);
+       BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(CONSUME_METHOD_NAME,
+               consume_status);
        if (consume_status) {
                if (consume_status < 0) {
                        BT_LIB_LOGW_APPEND_CAUSE(
@@ -533,13 +543,14 @@ end:
 }
 
 static inline
-int consume_no_check(struct bt_graph *graph)
+int consume_no_check(struct bt_graph *graph, const char *api_func)
 {
        int status = BT_FUNC_STATUS_OK;
        struct bt_component *sink;
        GList *current_node;
 
-       BT_ASSERT_PRE_DEV(graph->has_sink,
+       BT_ASSERT_PRE_DEV_FROM_FUNC(api_func,
+               "graph-has-at-least-one-sink-component", graph->has_sink,
                "Graph has no sink component: %!+g", graph);
        BT_LIB_LOGD("Making next sink component consume: %![graph-]+g", graph);
 
@@ -558,8 +569,11 @@ end:
        return status;
 }
 
+#define GRAPH_IS_CONFIGURED_METHOD_NAME                                        \
+       "bt_component_class_sink_graph_is_configured_method"
+
 static
-int configure_graph(struct bt_graph *graph)
+int configure_graph(struct bt_graph *graph, const char *api_func)
 {
        int status = BT_FUNC_STATUS_OK;
        uint64_t i;
@@ -572,7 +586,9 @@ int configure_graph(struct bt_graph *graph)
                goto end;
        }
 
-       BT_ASSERT_PRE(graph->has_sink, "Graph has no sink component: %!+g", graph);
+       BT_ASSERT_PRE_FROM_FUNC(api_func,
+               "graph-has-at-least-one-sink-component",
+               graph->has_sink, "Graph has no sink component: %!+g", graph);
        graph->config_state = BT_GRAPH_CONFIGURATION_STATE_PARTIALLY_CONFIGURED;
 
        for (i = 0; i < graph->components->len; i++) {
@@ -599,12 +615,15 @@ int configure_graph(struct bt_graph *graph)
                                (void *) comp_sink);
                        BT_LIB_LOGD("User method returned: status=%s",
                                bt_common_func_status_string(comp_status));
-                       BT_ASSERT_POST(comp_status == BT_FUNC_STATUS_OK ||
+                       BT_ASSERT_POST(GRAPH_IS_CONFIGURED_METHOD_NAME,
+                               "valid-status",
+                               comp_status == BT_FUNC_STATUS_OK ||
                                comp_status == BT_FUNC_STATUS_ERROR ||
                                comp_status == BT_FUNC_STATUS_MEMORY_ERROR,
                                "Unexpected returned status: status=%s",
                                bt_common_func_status_string(comp_status));
-                       BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(comp_status);
+                       BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(
+                               GRAPH_IS_CONFIGURED_METHOD_NAME, comp_status);
                        if (comp_status != BT_FUNC_STATUS_OK) {
                                if (comp_status < 0) {
                                        BT_LIB_LOGW_APPEND_CAUSE(
@@ -635,19 +654,19 @@ enum bt_graph_run_once_status bt_graph_run_once(struct bt_graph *graph)
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_DEV_GRAPH_NON_NULL(graph);
-       BT_ASSERT_PRE_DEV(graph->can_consume,
+       BT_ASSERT_PRE_DEV("graph-can-consume", graph->can_consume,
                "Cannot consume graph in its current state: %!+g", graph);
-       BT_ASSERT_PRE_DEV(graph->config_state !=
-               BT_GRAPH_CONFIGURATION_STATE_FAULTY,
+       BT_ASSERT_PRE_DEV("graph-is-not-faulty",
+               graph->config_state != BT_GRAPH_CONFIGURATION_STATE_FAULTY,
                "Graph is in a faulty state: %!+g", graph);
        bt_graph_set_can_consume(graph, false);
-       status = configure_graph(graph);
+       status = configure_graph(graph, __func__);
        if (G_UNLIKELY(status)) {
                /* configure_graph() logs errors */
                goto end;
        }
 
-       status = consume_no_check(graph);
+       status = consume_no_check(graph, __func__);
        bt_graph_set_can_consume(graph, true);
 
 end:
@@ -660,12 +679,13 @@ enum bt_graph_run_status bt_graph_run(struct bt_graph *graph)
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_GRAPH_NON_NULL(graph);
-       BT_ASSERT_PRE(graph->can_consume,
+       BT_ASSERT_PRE("graph-can-consume", graph->can_consume,
                "Cannot consume graph in its current state: %!+g", graph);
-       BT_ASSERT_PRE(graph->config_state != BT_GRAPH_CONFIGURATION_STATE_FAULTY,
+       BT_ASSERT_PRE("graph-is-not-faulty",
+               graph->config_state != BT_GRAPH_CONFIGURATION_STATE_FAULTY,
                "Graph is in a faulty state: %!+g", graph);
        bt_graph_set_can_consume(graph, false);
-       status = configure_graph(graph);
+       status = configure_graph(graph, __func__);
        if (G_UNLIKELY(status)) {
                /* configure_graph() logs errors */
                goto end;
@@ -687,7 +707,7 @@ enum bt_graph_run_status bt_graph_run(struct bt_graph *graph)
                        goto end;
                }
 
-               status = consume_no_check(graph);
+               status = consume_no_check(graph, __func__);
                if (G_UNLIKELY(status == BT_FUNC_STATUS_AGAIN)) {
                        /*
                         * If AGAIN is received and there are multiple
@@ -844,6 +864,7 @@ enum bt_graph_listener_func_status bt_graph_notify_port_added(
        GArray *listeners;
        struct bt_component *comp;
        enum bt_graph_listener_func_status status = BT_FUNC_STATUS_OK;
+       const char *func_name;
 
        BT_ASSERT(graph);
        BT_ASSERT(port);
@@ -858,6 +879,7 @@ enum bt_graph_listener_func_status bt_graph_notify_port_added(
                switch (port->type) {
                case BT_PORT_TYPE_OUTPUT:
                        listeners = graph->listeners.source_output_port_added;
+                       func_name = "bt_graph_source_component_output_port_added_listener_func";
                        break;
                default:
                        bt_common_abort();
@@ -870,9 +892,11 @@ enum bt_graph_listener_func_status bt_graph_notify_port_added(
                switch (port->type) {
                case BT_PORT_TYPE_INPUT:
                        listeners = graph->listeners.filter_input_port_added;
+                       func_name = "bt_graph_filter_component_input_port_added_listener_func";
                        break;
                case BT_PORT_TYPE_OUTPUT:
                        listeners = graph->listeners.filter_output_port_added;
+                       func_name = "bt_graph_filter_component_output_port_added_listener_func";
                        break;
                default:
                        bt_common_abort();
@@ -885,6 +909,7 @@ enum bt_graph_listener_func_status bt_graph_notify_port_added(
                switch (port->type) {
                case BT_PORT_TYPE_INPUT:
                        listeners = graph->listeners.sink_input_port_added;
+                       func_name = "bt_graph_sink_component_input_port_added_listener_func";
                        break;
                default:
                        bt_common_abort();
@@ -904,7 +929,7 @@ enum bt_graph_listener_func_status bt_graph_notify_port_added(
 
                BT_ASSERT(listener->func);
                status = listener->func(comp, port, listener->data);
-               BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(status);
+               BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(func_name, status);
                if (status != BT_FUNC_STATUS_OK) {
                        goto end;
                }
@@ -954,7 +979,9 @@ int add_component_with_init_method_data(
                comp_init_method_t init_method,
                const char *name, const struct bt_value *params,
                void *init_method_data, bt_logging_level log_level,
-               const struct bt_component **user_component)
+               const struct bt_component **user_component,
+               const char *api_func,
+               const char *init_method_name)
 {
        int status = BT_FUNC_STATUS_OK;
        enum bt_component_class_initialize_method_status init_status;
@@ -964,14 +991,15 @@ int add_component_with_init_method_data(
        struct bt_value *new_params = NULL;
 
        BT_ASSERT(comp_cls);
-       BT_ASSERT_PRE_GRAPH_NON_NULL(graph);
-       BT_ASSERT_PRE_NAME_NON_NULL(name);
-       BT_ASSERT_PRE(
+       BT_ASSERT_PRE_GRAPH_NON_NULL_FROM_FUNC(api_func, graph);
+       BT_ASSERT_PRE_NAME_NON_NULL_FROM_FUNC(api_func, name);
+       BT_ASSERT_PRE_FROM_FUNC(api_func, "graph-is-not-configured",
                graph->config_state == BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
                "Graph is not in the \"configuring\" state: %!+g", graph);
-       BT_ASSERT_PRE(!component_name_exists(graph, name),
+       BT_ASSERT_PRE_FROM_FUNC(api_func, "component-name-is-unique",
+               !component_name_exists(graph, name),
                "Duplicate component name: %!+g, name=\"%s\"", graph, name);
-       BT_ASSERT_PRE_PARAM_VALUE_IS_MAP(params);
+       BT_ASSERT_PRE_PARAM_VALUE_IS_MAP_FROM_FUNC(api_func, params);
        init_can_consume = graph->can_consume;
        bt_graph_set_can_consume(graph, false);
        BT_LIB_LOGI("Adding component to graph: "
@@ -1020,7 +1048,8 @@ int add_component_with_init_method_data(
                init_status = init_method(component, NULL, params, init_method_data);
                BT_LOGD("User method returned: status=%s",
                        bt_common_func_status_string(init_status));
-               BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(init_status);
+               BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(init_method_name,
+                       init_status);
                if (init_status != BT_FUNC_STATUS_OK) {
                        if (init_status < 0) {
                                BT_LIB_LOGW_APPEND_CAUSE(
@@ -1083,19 +1112,34 @@ end:
        return status;
 }
 
+static
 enum bt_graph_add_component_status
-bt_graph_add_source_component_with_initialize_method_data(
+add_source_component_with_initialize_method_data(
                struct bt_graph *graph,
                const struct bt_component_class_source *comp_cls,
                const char *name, const struct bt_value *params,
                void *init_method_data, bt_logging_level log_level,
-               const struct bt_component_source **component)
+               const struct bt_component_source **component,
+               const char *api_func)
 {
-       BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
+       BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(api_func);
+       BT_ASSERT_PRE_COMP_CLS_NON_NULL_FROM_FUNC(api_func, comp_cls);
        return add_component_with_init_method_data(graph,
                (void *) comp_cls, (comp_init_method_t) comp_cls->methods.init,
-               name, params, init_method_data, log_level, (void *) component);
+               name, params, init_method_data, log_level, (void *) component,
+               api_func, "bt_component_class_source_initialize_method");
+}
+
+enum bt_graph_add_component_status
+bt_graph_add_source_component_with_initialize_method_data(
+               struct bt_graph *graph,
+               const struct bt_component_class_source *comp_cls,
+               const char *name, const struct bt_value *params,
+               void *init_method_data, bt_logging_level log_level,
+               const struct bt_component_source **component)
+{
+       return add_source_component_with_initialize_method_data(graph, comp_cls,
+               name, params, init_method_data, log_level, component, __func__);
 }
 
 enum bt_graph_add_component_status bt_graph_add_source_component(
@@ -1105,24 +1149,38 @@ enum bt_graph_add_component_status bt_graph_add_source_component(
                enum bt_logging_level log_level,
                const struct bt_component_source **component)
 {
-       BT_ASSERT_PRE_NO_ERROR();
-       return bt_graph_add_source_component_with_initialize_method_data(
-               graph, comp_cls, name, params, NULL, log_level, component);
+       return add_source_component_with_initialize_method_data(graph, comp_cls,
+               name, params, NULL, log_level, component, __func__);
 }
 
+static
 enum bt_graph_add_component_status
-bt_graph_add_filter_component_with_initialize_method_data(
+add_filter_component_with_initialize_method_data(
                struct bt_graph *graph,
                const struct bt_component_class_filter *comp_cls,
                const char *name, const struct bt_value *params,
-               void *init_method_data, enum bt_logging_level log_level,
-               const struct bt_component_filter **component)
+               void *init_method_data, bt_logging_level log_level,
+               const struct bt_component_filter **component,
+               const char *api_func)
 {
-       BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
+       BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(api_func);
+       BT_ASSERT_PRE_COMP_CLS_NON_NULL_FROM_FUNC(api_func, comp_cls);
        return add_component_with_init_method_data(graph,
                (void *) comp_cls, (comp_init_method_t) comp_cls->methods.init,
-               name, params, init_method_data, log_level, (void *) component);
+               name, params, init_method_data, log_level, (void *) component,
+               api_func, "bt_component_class_filter_initialize_method");
+}
+
+enum bt_graph_add_component_status
+bt_graph_add_filter_component_with_initialize_method_data(
+               struct bt_graph *graph,
+               const struct bt_component_class_filter *comp_cls,
+               const char *name, const struct bt_value *params,
+               void *init_method_data, bt_logging_level log_level,
+               const struct bt_component_filter **component)
+{
+       return add_filter_component_with_initialize_method_data(graph, comp_cls,
+               name, params, init_method_data, log_level, component, __func__);
 }
 
 enum bt_graph_add_component_status bt_graph_add_filter_component(
@@ -1132,24 +1190,39 @@ enum bt_graph_add_component_status bt_graph_add_filter_component(
                enum bt_logging_level log_level,
                const struct bt_component_filter **component)
 {
-       BT_ASSERT_PRE_NO_ERROR();
-       return bt_graph_add_filter_component_with_initialize_method_data(
-               graph, comp_cls, name, params, NULL, log_level, component);
+       return add_filter_component_with_initialize_method_data(graph, comp_cls,
+               name, params, NULL, log_level, component, __func__);
 }
 
+static
 enum bt_graph_add_component_status
-bt_graph_add_sink_component_with_initialize_method_data(
+add_sink_component_with_initialize_method_data(
                struct bt_graph *graph,
                const struct bt_component_class_sink *comp_cls,
                const char *name, const struct bt_value *params,
-               void *init_method_data, enum bt_logging_level log_level,
-               const struct bt_component_sink **component)
+               void *init_method_data, bt_logging_level log_level,
+               const struct bt_component_sink **component,
+               const char *api_func)
 {
-       BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
+       BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(api_func);
+       BT_ASSERT_PRE_COMP_CLS_NON_NULL_FROM_FUNC(api_func, comp_cls);
        return add_component_with_init_method_data(graph,
                (void *) comp_cls, (comp_init_method_t) comp_cls->methods.init,
-               name, params, init_method_data, log_level, (void *) component);
+               name, params, init_method_data, log_level, (void *) component,
+               api_func, "bt_component_class_sink_initialize_method");
+}
+
+enum bt_graph_add_component_status
+bt_graph_add_sink_component_with_initialize_method_data(
+               struct bt_graph *graph,
+               const struct bt_component_class_sink *comp_cls,
+               const char *name, const struct bt_value *params,
+               void *init_method_data, bt_logging_level log_level,
+               const struct bt_component_sink **component)
+{
+       return add_sink_component_with_initialize_method_data(graph, comp_cls,
+               name, params, init_method_data, log_level, component,
+               __func__);
 }
 
 enum bt_graph_add_component_status bt_graph_add_sink_component(
@@ -1159,9 +1232,8 @@ enum bt_graph_add_component_status bt_graph_add_sink_component(
                enum bt_logging_level log_level,
                const struct bt_component_sink **component)
 {
-       BT_ASSERT_PRE_NO_ERROR();
-       return bt_graph_add_sink_component_with_initialize_method_data(
-               graph, comp_cls, name, params, NULL, log_level, component);
+       return add_sink_component_with_initialize_method_data(graph, comp_cls,
+               name, params, NULL, log_level, component, __func__);
 }
 
 enum bt_graph_add_component_status
@@ -1184,9 +1256,10 @@ bt_graph_add_simple_sink_component(struct bt_graph *graph, const char *name,
 
        /*
         * Other preconditions are checked by
-        * bt_graph_add_sink_component_with_init_method_data().
+        * add_sink_component_with_initialize_method_data().
         */
-       BT_ASSERT_PRE_NON_NULL(consume_func, "Consume function");
+       BT_ASSERT_PRE_NON_NULL("consume-function", consume_func,
+               "Consume function");
 
        comp_cls = bt_component_class_sink_simple_borrow();
        if (!comp_cls) {
@@ -1196,9 +1269,9 @@ bt_graph_add_simple_sink_component(struct bt_graph *graph, const char *name,
                goto end;
        }
 
-       status = bt_graph_add_sink_component_with_initialize_method_data(graph,
+       status = add_sink_component_with_initialize_method_data(graph,
                comp_cls, name, NULL, &init_method_data,
-               BT_LOGGING_LEVEL_NONE, component);
+               BT_LOGGING_LEVEL_NONE, component, __func__);
 
 end:
        return status;
index ff5073adaa33a167cbf960b9a0fde39c6438be77..ccc12d615f9c203d5002580702c8f07317c08e16 100644 (file)
 #define MSG_BATCH_SIZE 15
 
 #define BT_ASSERT_PRE_ITER_HAS_STATE_TO_SEEK(_iter)                    \
-       BT_ASSERT_PRE((_iter)->state == BT_MESSAGE_ITERATOR_STATE_ACTIVE || \
+       BT_ASSERT_PRE("has-state-to-seek",                              \
+               (_iter)->state == BT_MESSAGE_ITERATOR_STATE_ACTIVE ||   \
                (_iter)->state == BT_MESSAGE_ITERATOR_STATE_ENDED ||    \
                (_iter)->state == BT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN || \
                (_iter)->state == BT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR, \
-               "Message iterator is in the wrong state: %!+i", _iter)
+               "Message iterator is in the wrong state: %!+i", (_iter))
 
 static inline
 void set_msg_iterator_state(struct bt_message_iterator *iterator,
@@ -273,7 +274,8 @@ static
 int create_self_component_input_port_message_iterator(
                struct bt_self_message_iterator *self_downstream_msg_iter,
                struct bt_self_component_port_input *self_port,
-               struct bt_message_iterator **message_iterator)
+               struct bt_message_iterator **message_iterator,
+               const char *api_func)
 {
        bt_message_iterator_class_initialize_method init_method = NULL;
        struct bt_message_iterator *iterator =
@@ -288,20 +290,23 @@ int create_self_component_input_port_message_iterator(
        struct bt_component_class_with_iterator_class *upstream_comp_cls_with_iter_cls;
        int status;
 
-       BT_ASSERT_PRE_NON_NULL(message_iterator,
-               "Created message iterator (output)");
-       BT_ASSERT_PRE_NON_NULL(port, "Input port");
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(api_func, "message-iterator-output",
+               message_iterator, "Created message iterator (output)");
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(api_func, "input-port", port,
+               "Input port");
        comp = bt_port_borrow_component_inline(port);
-       BT_ASSERT_PRE(bt_port_is_connected(port),
+       BT_ASSERT_PRE_FROM_FUNC(api_func, "input-port-is-connected",
+               bt_port_is_connected(port),
                "Input port is not connected: %![port-]+p", port);
-       BT_ASSERT_PRE(comp, "Input port is not part of a component: %![port-]+p",
+       BT_ASSERT_PRE_FROM_FUNC(api_func, "input-port-has-component",
+               comp, "Input port is not part of a component: %![port-]+p",
                port);
        BT_ASSERT(port->connection);
        upstream_port = port->connection->upstream_port;
        BT_ASSERT(upstream_port);
        upstream_comp = bt_port_borrow_component_inline(upstream_port);
        BT_ASSERT(upstream_comp);
-       BT_ASSERT_PRE(
+       BT_ASSERT_PRE_FROM_FUNC(api_func, "graph-is-configured",
                bt_component_borrow_graph(upstream_comp)->config_state ==
                        BT_GRAPH_CONFIGURATION_STATE_PARTIALLY_CONFIGURED ||
                bt_component_borrow_graph(upstream_comp)->config_state ==
@@ -405,7 +410,9 @@ int create_self_component_input_port_message_iterator(
                        (struct bt_self_component_port_output *) upstream_port);
                BT_LOGD("User method returned: status=%s",
                        bt_common_func_status_string(iter_status));
-               BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(iter_status);
+               BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(
+                       "bt_message_iterator_class_initialize_method",
+                       iter_status);
                if (iter_status != BT_FUNC_STATUS_OK) {
                        BT_LIB_LOGW_APPEND_CAUSE(
                                "Component input port message iterator initialization method failed: "
@@ -458,7 +465,7 @@ bt_message_iterator_create_from_message_iterator(
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_MSG_ITER_NON_NULL(self_msg_iter);
        return create_self_component_input_port_message_iterator(self_msg_iter,
-               input_port, message_iterator);
+               input_port, message_iterator, __func__);
 }
 
 bt_message_iterator_create_from_sink_component_status
@@ -468,9 +475,9 @@ bt_message_iterator_create_from_sink_component(
                struct bt_message_iterator **message_iterator)
 {
        BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_NON_NULL(self_comp, "Sink component");
+       BT_ASSERT_PRE_NON_NULL("sink-component", self_comp, "Sink component");
        return create_self_component_input_port_message_iterator(NULL,
-               input_port, message_iterator);
+               input_port, message_iterator, __func__);
 }
 
 void *bt_self_message_iterator_get_data(
@@ -499,8 +506,10 @@ void bt_self_message_iterator_configuration_set_can_seek_forward(
                bt_self_message_iterator_configuration *config,
                bt_bool can_seek_forward)
 {
-       BT_ASSERT_PRE_NON_NULL(config, "Message iterator configuration");
-       BT_ASSERT_PRE_DEV_HOT(config, "Message iterator configuration", "");
+       BT_ASSERT_PRE_NON_NULL("message-iterator-configuration", config,
+               "Message iterator configuration");
+       BT_ASSERT_PRE_DEV_HOT("message-iterator-configuration", config,
+               "Message iterator configuration", "");
 
        config->can_seek_forward = can_seek_forward;
 }
@@ -779,6 +788,8 @@ end:
  * messages.
  */
 
+#define NEXT_METHOD_NAME       "bt_message_iterator_class_next_method"
+
 static
 enum bt_message_iterator_class_next_method_status
 call_iterator_next_method(
@@ -794,13 +805,20 @@ call_iterator_next_method(
                bt_common_func_status_string(status), *user_count);
 
        if (status == BT_FUNC_STATUS_OK) {
-               BT_ASSERT_POST_DEV(clock_classes_are_compatible(iterator, msgs, *user_count),
+               BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+                       "message-clock-classes-are-compatible",
+                       clock_classes_are_compatible(iterator, msgs,
+                               *user_count),
                        "Clocks are not compatible");
-               BT_ASSERT_POST_DEV(clock_snapshots_are_monotonic(iterator, msgs, *user_count),
+               BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+                       "message-clock-snapshots-are-monotonic",
+                       clock_snapshots_are_monotonic(iterator, msgs,
+                               *user_count),
                        "Clock snapshots are not monotonic");
        }
 
-       BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(status);
+       BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(NEXT_METHOD_NAME,
+               status);
 
        return status;
 }
@@ -814,15 +832,17 @@ bt_message_iterator_next(
 
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_DEV_MSG_ITER_NON_NULL(iterator);
-       BT_ASSERT_PRE_DEV_NON_NULL(msgs, "Message array (output)");
-       BT_ASSERT_PRE_DEV_NON_NULL(user_count, "Message count (output)");
-       BT_ASSERT_PRE_DEV(iterator->state ==
-               BT_MESSAGE_ITERATOR_STATE_ACTIVE,
+       BT_ASSERT_PRE_DEV_NON_NULL("message-array-output", msgs,
+               "Message array (output)");
+       BT_ASSERT_PRE_DEV_NON_NULL("user-count-output", user_count,
+               "Message count (output)");
+       BT_ASSERT_PRE_DEV("message-iterator-is-active",
+               iterator->state == BT_MESSAGE_ITERATOR_STATE_ACTIVE,
                "Message iterator's \"next\" called, but "
                "message iterator is in the wrong state: %!+i", iterator);
        BT_ASSERT_DBG(iterator->upstream_component);
        BT_ASSERT_DBG(iterator->upstream_component->class);
-       BT_ASSERT_PRE_DEV(
+       BT_ASSERT_PRE_DEV("graph-is-configured",
                bt_component_borrow_graph(iterator->upstream_component)->config_state !=
                        BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
                "Graph is not configured: %!+g",
@@ -863,7 +883,8 @@ bt_message_iterator_next(
 
        switch (status) {
        case BT_FUNC_STATUS_OK:
-               BT_ASSERT_POST_DEV(*user_count <= MSG_BATCH_SIZE,
+               BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, "count-lteq-capacity",
+                       *user_count <= MSG_BATCH_SIZE,
                        "Invalid returned message count: greater than "
                        "batch size: count=%" PRIu64 ", batch-size=%u",
                        *user_count, MSG_BATCH_SIZE);
@@ -912,6 +933,9 @@ struct bt_self_component_port_output *bt_self_message_iterator_borrow_port(
        return (void *) iterator->upstream_port;
 }
 
+#define CAN_SEEK_NS_FROM_ORIGIN_METHOD_NAME                            \
+       "bt_message_iterator_class_can_seek_ns_from_origin_method"
+
 enum bt_message_iterator_can_seek_ns_from_origin_status
 bt_message_iterator_can_seek_ns_from_origin(
                struct bt_message_iterator *iterator,
@@ -923,7 +947,7 @@ bt_message_iterator_can_seek_ns_from_origin(
        BT_ASSERT_PRE_MSG_ITER_NON_NULL(iterator);
        BT_ASSERT_PRE_RES_OUT_NON_NULL(can_seek);
        BT_ASSERT_PRE_ITER_HAS_STATE_TO_SEEK(iterator);
-       BT_ASSERT_PRE(
+       BT_ASSERT_PRE("graph-is-configured",
                bt_component_borrow_graph(iterator->upstream_component)->config_state !=
                        BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
                "Graph is not configured: %!+g",
@@ -942,7 +966,8 @@ bt_message_iterator_can_seek_ns_from_origin(
                status = (int) iterator->methods.can_seek_ns_from_origin(iterator,
                        ns_from_origin, can_seek);
 
-               BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(status);
+               BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(
+                       CAN_SEEK_NS_FROM_ORIGIN_METHOD_NAME, status);
 
                if (status != BT_FUNC_STATUS_OK) {
                        BT_LIB_LOGW_APPEND_CAUSE(
@@ -952,7 +977,9 @@ bt_message_iterator_can_seek_ns_from_origin(
                        goto end;
                }
 
-               BT_ASSERT_POST(*can_seek == BT_TRUE || *can_seek == BT_FALSE,
+               BT_ASSERT_POST(CAN_SEEK_NS_FROM_ORIGIN_METHOD_NAME,
+                       "valid-return-value",
+                       *can_seek == BT_TRUE || *can_seek == BT_FALSE,
                        "Unexpected boolean value returned from user's \"can seek ns from origin\" method: val=%d, %![iter-]+i",
                        *can_seek, iterator);
 
@@ -983,6 +1010,9 @@ end:
        return status;
 }
 
+#define CAN_SEEK_BEGINNING_METHOD_NAME                                 \
+       "bt_message_iterator_class_can_seek_beginning"
+
 enum bt_message_iterator_can_seek_beginning_status
 bt_message_iterator_can_seek_beginning(
                struct bt_message_iterator *iterator,
@@ -994,7 +1024,7 @@ bt_message_iterator_can_seek_beginning(
        BT_ASSERT_PRE_MSG_ITER_NON_NULL(iterator);
        BT_ASSERT_PRE_RES_OUT_NON_NULL(can_seek);
        BT_ASSERT_PRE_ITER_HAS_STATE_TO_SEEK(iterator);
-       BT_ASSERT_PRE(
+       BT_ASSERT_PRE("graph-is-configured",
                bt_component_borrow_graph(iterator->upstream_component)->config_state !=
                        BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
                "Graph is not configured: %!+g",
@@ -1009,13 +1039,15 @@ bt_message_iterator_can_seek_beginning(
 
                status = (int) iterator->methods.can_seek_beginning(iterator, can_seek);
 
-               BT_ASSERT_POST(
+               BT_ASSERT_POST(CAN_SEEK_BEGINNING_METHOD_NAME,
+                       "valid-return-value",
                        status != BT_FUNC_STATUS_OK ||
                                *can_seek == BT_TRUE ||
                                *can_seek == BT_FALSE,
                        "Unexpected boolean value returned from user's \"can seek beginning\" method: val=%d, %![iter-]+i",
                        *can_seek, iterator);
-               BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(status);
+               BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(
+                       CAN_SEEK_BEGINNING_METHOD_NAME, status);
        } else {
                *can_seek = BT_FALSE;
                status = BT_FUNC_STATUS_OK;
@@ -1077,21 +1109,24 @@ bool message_iterator_can_seek_beginning(
        return can_seek;
 }
 
+#define SEEK_BEGINNING_METHOD_NAME                                     \
+       "bt_message_iterator_class_seek_beginning_method"
+
 enum bt_message_iterator_seek_beginning_status
-bt_message_iterator_seek_beginning(
-               struct bt_message_iterator *iterator)
+bt_message_iterator_seek_beginning(struct bt_message_iterator *iterator)
 {
        int status;
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_MSG_ITER_NON_NULL(iterator);
        BT_ASSERT_PRE_ITER_HAS_STATE_TO_SEEK(iterator);
-       BT_ASSERT_PRE(
+       BT_ASSERT_PRE("graph-is-configured",
                bt_component_borrow_graph(iterator->upstream_component)->config_state !=
                        BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
                "Graph is not configured: %!+g",
                bt_component_borrow_graph(iterator->upstream_component));
-       BT_ASSERT_PRE(message_iterator_can_seek_beginning(iterator),
+       BT_ASSERT_PRE("can-seek-beginning",
+               message_iterator_can_seek_beginning(iterator),
                "Message iterator cannot seek beginning: %!+i", iterator);
 
        /*
@@ -1106,13 +1141,15 @@ bt_message_iterator_seek_beginning(
        status = iterator->methods.seek_beginning(iterator);
        BT_LOGD("User method returned: status=%s",
                bt_common_func_status_string(status));
-       BT_ASSERT_POST(status == BT_FUNC_STATUS_OK ||
+       BT_ASSERT_POST(SEEK_BEGINNING_METHOD_NAME, "valid-status",
+               status == BT_FUNC_STATUS_OK ||
                status == BT_FUNC_STATUS_ERROR ||
                status == BT_FUNC_STATUS_MEMORY_ERROR ||
                status == BT_FUNC_STATUS_AGAIN,
                "Unexpected status: %![iter-]+i, status=%s",
                iterator, bt_common_func_status_string(status));
-       BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(status);
+       BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(SEEK_BEGINNING_METHOD_NAME,
+               status);
        if (status < 0) {
                BT_LIB_LOGW_APPEND_CAUSE(
                        "Component input port message iterator's \"seek beginning\" method failed: "
@@ -1226,7 +1263,9 @@ int auto_seek_handle_message(
                        (const void *) msg;
 
                clk_snapshot = event_msg->default_cs;
-               BT_ASSERT_POST_DEV(clk_snapshot,
+               BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+                       "event-message-has-default-clock-snapshot",
+                       clk_snapshot,
                        "Event message has no default clock snapshot: %!+n",
                        event_msg);
                break;
@@ -1247,7 +1286,9 @@ int auto_seek_handle_message(
                        (const void *) msg;
 
                clk_snapshot = packet_msg->default_cs;
-               BT_ASSERT_POST_DEV(clk_snapshot,
+               BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+                       "packet-message-has-default-clock-snapshot",
+                       clk_snapshot,
                        "Packet message has no default clock snapshot: %!+n",
                        packet_msg);
                break;
@@ -1258,8 +1299,10 @@ int auto_seek_handle_message(
                struct bt_message_discarded_items *msg_disc_items =
                        (void *) msg;
 
-               BT_ASSERT_POST_DEV(msg_disc_items->default_begin_cs &&
-                       msg_disc_items->default_end_cs,
+               BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+                       "discarded-events-packets-message-has-default-clock-snapshot",
+                       msg_disc_items->default_begin_cs &&
+                               msg_disc_items->default_end_cs,
                        "Discarded events/packets message has no default clock snapshots: %!+n",
                        msg_disc_items);
                ret = bt_clock_snapshot_get_ns_from_origin(
@@ -1526,7 +1569,9 @@ int find_message_ge_ns_from_origin(
 
                switch (status) {
                case BT_FUNC_STATUS_OK:
-                       BT_ASSERT_POST_DEV(user_count <= MSG_BATCH_SIZE,
+                       BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+                               "count-lteq-capacity",
+                               user_count <= MSG_BATCH_SIZE,
                                "Invalid returned message count: greater than "
                                "batch size: count=%" PRIu64 ", batch-size=%u",
                                user_count, MSG_BATCH_SIZE);
@@ -1639,6 +1684,10 @@ bool message_iterator_can_seek_ns_from_origin(
        return can_seek;
 }
 
+#define SEEK_NS_FROM_ORIGIN_METHOD_NAME                                        \
+       "bt_message_iterator_class_seek_ns_from_origin_method"
+
+
 enum bt_message_iterator_seek_ns_from_origin_status
 bt_message_iterator_seek_ns_from_origin(
                struct bt_message_iterator *iterator,
@@ -1651,13 +1700,13 @@ bt_message_iterator_seek_ns_from_origin(
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_MSG_ITER_NON_NULL(iterator);
        BT_ASSERT_PRE_ITER_HAS_STATE_TO_SEEK(iterator);
-       BT_ASSERT_PRE(
+       BT_ASSERT_PRE("graph-is-configured",
                bt_component_borrow_graph(iterator->upstream_component)->config_state !=
                        BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
                "Graph is not configured: %!+g",
                bt_component_borrow_graph(iterator->upstream_component));
        /* The iterator must be able to seek ns from origin one way or another. */
-       BT_ASSERT_PRE(
+       BT_ASSERT_PRE("can-seek-ns-from-origin",
                message_iterator_can_seek_ns_from_origin(iterator, ns_from_origin),
                "Message iterator cannot seek nanoseconds from origin: %!+i, "
                "ns-from-origin=%" PRId64, iterator, ns_from_origin);
@@ -1695,13 +1744,15 @@ bt_message_iterator_seek_ns_from_origin(
                        ns_from_origin);
                BT_LOGD("User method returned: status=%s",
                        bt_common_func_status_string(status));
-               BT_ASSERT_POST(status == BT_FUNC_STATUS_OK ||
+               BT_ASSERT_POST(SEEK_NS_FROM_ORIGIN_METHOD_NAME, "valid-status",
+                       status == BT_FUNC_STATUS_OK ||
                        status == BT_FUNC_STATUS_ERROR ||
                        status == BT_FUNC_STATUS_MEMORY_ERROR ||
                        status == BT_FUNC_STATUS_AGAIN,
                        "Unexpected status: %![iter-]+i, status=%s",
                        iterator, bt_common_func_status_string(status));
-               BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(status);
+               BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(
+                       SEEK_NS_FROM_ORIGIN_METHOD_NAME, status);
                if (status < 0) {
                        BT_LIB_LOGW_APPEND_CAUSE(
                                "Component input port message iterator's \"seek nanoseconds from origin\" method failed: "
@@ -1727,7 +1778,8 @@ bt_message_iterator_seek_ns_from_origin(
                status = iterator->methods.seek_beginning(iterator);
                BT_LOGD("User method returned: status=%s",
                        bt_common_func_status_string(status));
-               BT_ASSERT_POST(status == BT_FUNC_STATUS_OK ||
+               BT_ASSERT_POST(SEEK_BEGINNING_METHOD_NAME, "valid-status",
+                       status == BT_FUNC_STATUS_OK ||
                        status == BT_FUNC_STATUS_ERROR ||
                        status == BT_FUNC_STATUS_MEMORY_ERROR ||
                        status == BT_FUNC_STATUS_AGAIN,
index ad4bdb56809a42ffab98a20b695e6b0e5c91790e..7bb9a871c65afc5ebff3698bc8e786b175868c4d 100644 (file)
 #include "lib/assert-cond.h"
 #include "lib/func-status.h"
 
-#define BT_ASSERT_COND_DEV_MSG_ITER_CLS_HOT(_msg_iter_cls) \
-       BT_ASSERT_PRE_DEV_HOT((_msg_iter_cls), \
-               "Message iterator class", ": %!+I", (_msg_iter_cls))
+#define BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(_msg_iter_cls)              \
+       BT_ASSERT_PRE_DEV_HOT("message-iterator-class",                 \
+               (_msg_iter_cls), "Message iterator class",              \
+               ": %!+I", (_msg_iter_cls))
 
 BT_HIDDEN
 void _bt_message_iterator_class_freeze(
@@ -57,7 +58,7 @@ struct bt_message_iterator_class *bt_message_iterator_class_create(
        struct bt_message_iterator_class *message_iterator_class;
 
        BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_NON_NULL(next_method, "Next method");
+       BT_ASSERT_PRE_NON_NULL("next-method", next_method, "Next method");
        BT_LOGI("Creating message iterator class: next-method-addr=%p",
                next_method);
 
@@ -84,7 +85,7 @@ bt_message_iterator_class_set_initialize_method(
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_MSG_ITER_CLS_NON_NULL(message_iterator_class);
        BT_ASSERT_PRE_METHOD_NON_NULL(method);
-       BT_ASSERT_COND_DEV_MSG_ITER_CLS_HOT(message_iterator_class);
+       BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(message_iterator_class);
        message_iterator_class->methods.initialize = method;
        BT_LIB_LOGD("Set message iterator class's iterator initialization method"
                ": %!+I", message_iterator_class);
@@ -99,7 +100,7 @@ bt_message_iterator_class_set_finalize_method(
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_MSG_ITER_CLS_NON_NULL(message_iterator_class);
        BT_ASSERT_PRE_METHOD_NON_NULL(method);
-       BT_ASSERT_COND_DEV_MSG_ITER_CLS_HOT(message_iterator_class);
+       BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(message_iterator_class);
        message_iterator_class->methods.finalize = method;
        BT_LIB_LOGD("Set message iterator class's finalization method"
                ": %!+I", message_iterator_class);
@@ -114,8 +115,8 @@ bt_message_iterator_class_set_seek_ns_from_origin_methods(
 {
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_MSG_ITER_CLS_NON_NULL(message_iterator_class);
-       BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method");
-       BT_ASSERT_COND_DEV_MSG_ITER_CLS_HOT(message_iterator_class);
+       BT_ASSERT_PRE_NON_NULL("seek-method", seek_method, "Seek method");
+       BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(message_iterator_class);
        message_iterator_class->methods.seek_ns_from_origin = seek_method;
        message_iterator_class->methods.can_seek_ns_from_origin = can_seek_method;
        BT_LIB_LOGD("Set message iterator class's \"seek nanoseconds from origin\" method"
@@ -131,8 +132,8 @@ bt_message_iterator_class_set_seek_beginning_methods(
 {
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_MSG_ITER_CLS_NON_NULL(message_iterator_class);
-       BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method");
-       BT_ASSERT_COND_DEV_MSG_ITER_CLS_HOT(message_iterator_class);
+       BT_ASSERT_PRE_NON_NULL("seek-method", seek_method, "Seek method");
+       BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(message_iterator_class);
        message_iterator_class->methods.seek_beginning = seek_method;
        message_iterator_class->methods.can_seek_beginning = can_seek_method;
        BT_LIB_LOGD("Set message iterator class's \"seek beginning\" methods"
index 53420e9384ddea161cfb19340d5e404ff52eb7ab..b20e1abf98331b2e39a2a29447b4d5f8213ac6b3 100644 (file)
 
 #include "discarded-items.h"
 
+#define BT_ASSERT_PRE_MSG_IS_DISC_EVENTS(_msg)                         \
+       BT_ASSERT_PRE_MSG_HAS_TYPE("message", (_msg),                   \
+               "discarded-events", BT_MESSAGE_TYPE_DISCARDED_EVENTS);
+
+#define BT_ASSERT_PRE_DEV_MSG_IS_DISC_EVENTS(_msg)                     \
+       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE("message", (_msg),               \
+               "discarded-events", BT_MESSAGE_TYPE_DISCARDED_EVENTS);
+
+#define BT_ASSERT_PRE_MSG_IS_DISC_PACKETS(_msg)                                \
+       BT_ASSERT_PRE_MSG_HAS_TYPE("message", (_msg),                   \
+               "discarded-packets", BT_MESSAGE_TYPE_DISCARDED_PACKETS);
+
+#define BT_ASSERT_PRE_DEV_MSG_IS_DISC_PACKETS(_msg)                    \
+       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE("message", (_msg),               \
+               "discarded-packets", BT_MESSAGE_TYPE_DISCARDED_PACKETS);
+
+#define BT_ASSERT_PRE_DEV_COUNT_OUTPUT_NON_NULL(_count)                        \
+       BT_ASSERT_PRE_DEV_NON_NULL("count-output", count,               \
+               "Count (output)");
+
 static
 void destroy_discarded_items_message(struct bt_object *obj)
 {
@@ -48,15 +68,17 @@ struct bt_message *create_discarded_items_message(
                struct bt_self_message_iterator *self_msg_iter,
                enum bt_message_type type, struct bt_stream *stream,
                bool with_cs,
-               uint64_t beginning_raw_value, uint64_t end_raw_value)
+               uint64_t beginning_raw_value, uint64_t end_raw_value,
+               const char *api_func,
+               const char *sc_supports_disc_precond_id)
 {
        struct bt_message_discarded_items *message;
        struct bt_stream_class *stream_class;
        bool has_support;
        bool need_cs;
 
-       BT_ASSERT_PRE_MSG_ITER_NON_NULL(self_msg_iter);
-       BT_ASSERT_PRE_STREAM_NON_NULL(stream);
+       BT_ASSERT_PRE_MSG_ITER_NON_NULL_FROM_FUNC(api_func, self_msg_iter);
+       BT_ASSERT_PRE_STREAM_NON_NULL_FROM_FUNC(api_func, stream);
        stream_class = bt_stream_borrow_class(stream);
        BT_ASSERT(stream_class);
 
@@ -68,11 +90,13 @@ struct bt_message *create_discarded_items_message(
                need_cs = stream_class->discarded_packets_have_default_clock_snapshots;
        }
 
-       BT_ASSERT_PRE(has_support,
+       BT_ASSERT_PRE_FROM_FUNC(api_func, sc_supports_disc_precond_id,
+               has_support,
                "Stream class does not support discarded events or packets: "
                "type=%s, %![stream-]+s, %![sc-]+S",
                bt_message_type_string(type), stream, stream_class);
-       BT_ASSERT_PRE(need_cs ? with_cs : true,
+       BT_ASSERT_PRE_FROM_FUNC(api_func, "with-default-clock-snapshots",
+               need_cs ? with_cs : true,
                "Unexpected stream class configuration when creating "
                "a discarded events or discarded packets message: "
                "default clock snapshots are needed, but none was provided: "
@@ -80,7 +104,8 @@ struct bt_message *create_discarded_items_message(
                "cs-begin-val=%" PRIu64 ", cs-end-val=%" PRIu64,
                bt_message_type_string(type), stream, stream_class,
                with_cs, beginning_raw_value, end_raw_value);
-       BT_ASSERT_PRE(!need_cs ? !with_cs : true,
+       BT_ASSERT_PRE_FROM_FUNC(api_func, "without-default-clock-snapshots",
+               !need_cs ? !with_cs : true,
                "Unexpected stream class configuration when creating "
                "a discarded events or discarded packets message: "
                "no default clock snapshots are needed, but two were provided: "
@@ -155,7 +180,6 @@ void set_discarded_items_message_count(struct bt_message *message,
        struct bt_message_discarded_items *disc_items_msg = (void *) message;
 
        BT_ASSERT(message);
-       BT_ASSERT_PRE_DEV_MSG_HOT(message);
        bt_property_uint_set(&disc_items_msg->count, count);
 }
 
@@ -165,8 +189,8 @@ enum bt_property_availability get_discarded_items_message_count(
 {
        struct bt_message_discarded_items *disc_items_msg = (void *) message;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(count, "Count (output)");
        BT_ASSERT_DBG(message);
+       BT_ASSERT_DBG(count);
        *count = disc_items_msg->count.value;
        return disc_items_msg->count.base.avail;
 }
@@ -174,12 +198,12 @@ enum bt_property_availability get_discarded_items_message_count(
 static inline
 const struct bt_clock_snapshot *
 borrow_discarded_items_message_beginning_default_clock_snapshot_const(
-               const struct bt_message *message)
+               const struct bt_message *message, const char *api_func)
 {
        struct bt_message_discarded_items *disc_items_msg = (void *) message;
 
        BT_ASSERT_DBG(message);
-       BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS(message,
+       BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS_FROM_FUNC(api_func, message,
                disc_items_msg->stream->class);
        return disc_items_msg->default_begin_cs;
 }
@@ -187,16 +211,19 @@ borrow_discarded_items_message_beginning_default_clock_snapshot_const(
 static inline
 const struct bt_clock_snapshot *
 borrow_discarded_items_message_end_default_clock_snapshot_const(
-               const struct bt_message *message)
+               const struct bt_message *message, const char *api_func)
 {
        struct bt_message_discarded_items *disc_items_msg = (void *) message;
 
        BT_ASSERT_DBG(message);
-       BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS(message,
+       BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS_FROM_FUNC(api_func, message,
                disc_items_msg->stream->class);
        return disc_items_msg->default_end_cs;
 }
 
+#define SC_SUPPORTS_DISC_PRECOND_ID(_item_type)                                \
+       "stream-class-supports-discarded-" _item_type
+
 struct bt_message *bt_message_discarded_events_create(
                struct bt_self_message_iterator *message_iterator,
                const struct bt_stream *stream)
@@ -205,7 +232,8 @@ struct bt_message *bt_message_discarded_events_create(
 
        return create_discarded_items_message(message_iterator,
                BT_MESSAGE_TYPE_DISCARDED_EVENTS, (void *) stream,
-               false, 0, 0);
+               false, 0, 0, __func__,
+               SC_SUPPORTS_DISC_PRECOND_ID("events"));
 }
 
 struct bt_message *bt_message_discarded_events_create_with_default_clock_snapshots(
@@ -219,15 +247,15 @@ struct bt_message *bt_message_discarded_events_create_with_default_clock_snapsho
 
        return create_discarded_items_message(message_iterator,
                BT_MESSAGE_TYPE_DISCARDED_EVENTS, (void *) stream,
-               true, beginning_raw_value, end_raw_value);
+               true, beginning_raw_value, end_raw_value, __func__,
+               SC_SUPPORTS_DISC_PRECOND_ID("events"));
 }
 
 struct bt_stream *bt_message_discarded_events_borrow_stream(
                struct bt_message *message)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(message);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(message,
-               BT_MESSAGE_TYPE_DISCARDED_EVENTS);
+       BT_ASSERT_PRE_DEV_MSG_IS_DISC_EVENTS(message);
        return borrow_discarded_items_message_stream(message);
 }
 
@@ -235,8 +263,9 @@ void bt_message_discarded_events_set_count(struct bt_message *message,
                uint64_t count)
 {
        BT_ASSERT_PRE_MSG_NON_NULL(message);
-       BT_ASSERT_PRE_MSG_HAS_TYPE(message, BT_MESSAGE_TYPE_DISCARDED_EVENTS);
-       BT_ASSERT_PRE(count > 0, "Discarded event count is 0.");
+       BT_ASSERT_PRE_MSG_IS_DISC_EVENTS(message);
+       BT_ASSERT_PRE_DEV_MSG_HOT(message);
+       BT_ASSERT_PRE("count-gt-0", count > 0, "Discarded event count is 0.");
        set_discarded_items_message_count(message, count);
 }
 
@@ -245,9 +274,9 @@ bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const(
                const struct bt_message *msg)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_DISCARDED_EVENTS);
+       BT_ASSERT_PRE_DEV_MSG_IS_DISC_EVENTS(msg);
        return borrow_discarded_items_message_beginning_default_clock_snapshot_const(
-               msg);
+               msg, __func__);
 }
 
 const struct bt_clock_snapshot *
@@ -255,9 +284,9 @@ bt_message_discarded_events_borrow_end_default_clock_snapshot_const(
                const struct bt_message *msg)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_DISCARDED_EVENTS);
+       BT_ASSERT_PRE_DEV_MSG_IS_DISC_EVENTS(msg);
        return borrow_discarded_items_message_end_default_clock_snapshot_const(
-               msg);
+               msg, __func__);
 }
 
 const struct bt_stream *
@@ -271,8 +300,8 @@ enum bt_property_availability bt_message_discarded_events_get_count(
                const struct bt_message *message, uint64_t *count)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(message);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(message,
-               BT_MESSAGE_TYPE_DISCARDED_EVENTS);
+       BT_ASSERT_PRE_DEV_MSG_IS_DISC_EVENTS(message);
+       BT_ASSERT_PRE_DEV_COUNT_OUTPUT_NON_NULL(count);
        return get_discarded_items_message_count(message, count);
 }
 
@@ -284,7 +313,7 @@ struct bt_message *bt_message_discarded_packets_create(
 
        return create_discarded_items_message(message_iterator,
                BT_MESSAGE_TYPE_DISCARDED_PACKETS, (void *) stream,
-               false, 0, 0);
+               false, 0, 0, __func__, SC_SUPPORTS_DISC_PRECOND_ID("packets"));
 }
 
 struct bt_message *bt_message_discarded_packets_create_with_default_clock_snapshots(
@@ -298,15 +327,15 @@ struct bt_message *bt_message_discarded_packets_create_with_default_clock_snapsh
 
        return create_discarded_items_message(message_iterator,
                BT_MESSAGE_TYPE_DISCARDED_PACKETS, (void *) stream,
-               true, beginning_raw_value, end_raw_value);
+               true, beginning_raw_value, end_raw_value, __func__,
+               SC_SUPPORTS_DISC_PRECOND_ID("packets"));
 }
 
 struct bt_stream *bt_message_discarded_packets_borrow_stream(
                struct bt_message *message)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(message);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(message,
-               BT_MESSAGE_TYPE_DISCARDED_PACKETS);
+       BT_ASSERT_PRE_DEV_MSG_IS_DISC_PACKETS(message);
        return borrow_discarded_items_message_stream(message);
 }
 
@@ -314,8 +343,9 @@ void bt_message_discarded_packets_set_count(struct bt_message *message,
                uint64_t count)
 {
        BT_ASSERT_PRE_MSG_NON_NULL(message);
-       BT_ASSERT_PRE_MSG_HAS_TYPE(message, BT_MESSAGE_TYPE_DISCARDED_PACKETS);
-       BT_ASSERT_PRE(count > 0, "Discarded packet count is 0.");
+       BT_ASSERT_PRE_MSG_IS_DISC_PACKETS(message);
+       BT_ASSERT_PRE_DEV_MSG_HOT(message);
+       BT_ASSERT_PRE("count-gt-0", count > 0, "Discarded packet count is 0.");
        set_discarded_items_message_count(message, count);
 }
 
@@ -324,9 +354,9 @@ bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const(
                const struct bt_message *msg)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_DISCARDED_PACKETS);
+       BT_ASSERT_PRE_DEV_MSG_IS_DISC_PACKETS(msg);
        return borrow_discarded_items_message_beginning_default_clock_snapshot_const(
-               msg);
+               msg, __func__);
 }
 
 const struct bt_clock_snapshot *
@@ -334,9 +364,9 @@ bt_message_discarded_packets_borrow_end_default_clock_snapshot_const(
                const struct bt_message *msg)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_DISCARDED_PACKETS);
+       BT_ASSERT_PRE_DEV_MSG_IS_DISC_PACKETS(msg);
        return borrow_discarded_items_message_end_default_clock_snapshot_const(
-               msg);
+               msg, __func__);
 }
 
 const struct bt_stream *
@@ -350,8 +380,8 @@ enum bt_property_availability bt_message_discarded_packets_get_count(
                const struct bt_message *message, uint64_t *count)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(message);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(message,
-               BT_MESSAGE_TYPE_DISCARDED_PACKETS);
+       BT_ASSERT_PRE_DEV_MSG_IS_DISC_PACKETS(message);
+       BT_ASSERT_PRE_DEV_COUNT_OUTPUT_NON_NULL(count);
        return get_discarded_items_message_count(message, count);
 }
 
@@ -371,7 +401,7 @@ bt_message_discarded_events_borrow_stream_class_default_clock_class_const(
                const struct bt_message *msg)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_DISCARDED_EVENTS);
+       BT_ASSERT_PRE_DEV_MSG_IS_DISC_EVENTS(msg);
        return borrow_discarded_items_message_stream_class_default_clock_class(
                msg);
 }
@@ -381,7 +411,7 @@ bt_message_discarded_packets_borrow_stream_class_default_clock_class_const(
                const struct bt_message *msg)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_DISCARDED_PACKETS);
+       BT_ASSERT_PRE_DEV_MSG_IS_DISC_PACKETS(msg);
        return borrow_discarded_items_message_stream_class_default_clock_class(
                msg);
 }
index ac567bfa4a954b49bb771bcb11aa2efefb40120e..932a598ebf2216daa3496e30d1061822e340b2a0 100644 (file)
 
 #include "event.h"
 
-static inline bool event_class_has_trace(struct bt_event_class *event_class)
-{
-       struct bt_stream_class *stream_class;
-
-       stream_class = bt_event_class_borrow_stream_class_inline(event_class);
-       BT_ASSERT_DBG(stream_class);
-       return bt_stream_class_borrow_trace_class(stream_class);
-}
+#define BT_ASSERT_PRE_DEV_MSG_IS_EVENT(_msg)                           \
+       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE("message", (_msg), "event",      \
+               BT_MESSAGE_TYPE_EVENT)
 
 BT_HIDDEN
 struct bt_message *bt_message_event_new(
@@ -61,7 +56,8 @@ end:
 
 static
 struct bt_event *create_event(struct bt_event_class *event_class,
-               struct bt_packet *packet, struct bt_stream *stream)
+               struct bt_packet *packet, struct bt_stream *stream,
+               const char *api_func)
 {
        struct bt_event *event = NULL;
 
@@ -87,8 +83,10 @@ struct bt_event *create_event(struct bt_event_class *event_class,
                event, stream);
 
        if (packet) {
-               BT_ASSERT_PRE_DEV(bt_event_class_borrow_stream_class(
-                       event_class) == packet->stream->class,
+               BT_ASSERT_PRE_DEV_FROM_FUNC(api_func,
+                       "packet-stream-class-is-event-class-stream-class",
+                       bt_event_class_borrow_stream_class(
+                               event_class) == packet->stream->class,
                        "Packet's stream class and event class's stream class differ: "
                        "%![ec-]+E, %![packet-]+a", event, packet);
                BT_ASSERT_DBG(event->stream->class->supports_packets);
@@ -109,7 +107,7 @@ struct bt_message *create_event_message(
                const struct bt_event_class *c_event_class,
                const struct bt_packet *c_packet,
                const struct bt_stream *c_stream, bool with_cs,
-               uint64_t raw_value)
+               uint64_t raw_value, const char *api_func)
 {
        struct bt_message_iterator *msg_iter =
                (void *) self_msg_iter;
@@ -121,17 +119,19 @@ struct bt_message *create_event_message(
        struct bt_event *event;
 
        BT_ASSERT_DBG(stream);
-       BT_ASSERT_PRE_MSG_ITER_NON_NULL(msg_iter);
-       BT_ASSERT_PRE_EC_NON_NULL(event_class);
-       BT_ASSERT_PRE(event_class_has_trace(event_class),
-               "Event class is not part of a trace: %!+E", event_class);
-       BT_ASSERT_PRE_DEV(bt_event_class_borrow_stream_class(event_class) ==
-               stream->class,
+       BT_ASSERT_PRE_MSG_ITER_NON_NULL_FROM_FUNC(api_func, msg_iter);
+       BT_ASSERT_PRE_EC_NON_NULL_FROM_FUNC(api_func, event_class);
+       stream_class = bt_event_class_borrow_stream_class_inline(event_class);
+       BT_ASSERT_PRE_FROM_FUNC(api_func,
+               "stream-class-is-event-class-stream-class",
+               bt_event_class_borrow_stream_class(event_class) ==
+                       stream->class,
                "Stream's class and event's stream class differ: "
                "%![ec-]+E, %![stream-]+s", event_class, stream);
-       stream_class = bt_event_class_borrow_stream_class_inline(event_class);
        BT_ASSERT_DBG(stream_class);
-       BT_ASSERT_PRE((with_cs && stream_class->default_clock_class) ||
+       BT_ASSERT_PRE_FROM_FUNC(api_func,
+               "with-default-clock-snapshot-if-stream-class-has-default-clock-class",
+               (with_cs && stream_class->default_clock_class) ||
                (!with_cs && !stream_class->default_clock_class),
                "Creating an event message with a default clock snapshot, but without "
                "a default clock class, or without a default clock snapshot, "
@@ -140,7 +140,7 @@ struct bt_message *create_event_message(
                "cs-val=%" PRIu64,
                event_class, stream_class, with_cs, raw_value);
        BT_LIB_LOGD("Creating event message object: %![ec-]+E", event_class);
-       event = create_event(event_class, packet, stream);
+       event = create_event(event_class, packet, stream, api_func);
        if (G_UNLIKELY(!event)) {
                BT_LIB_LOGE_APPEND_CAUSE(
                        "Cannot create event from event class: "
@@ -209,7 +209,8 @@ struct bt_message *bt_message_event_create(
 {
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_STREAM_NON_NULL(stream);
-       return create_event_message(msg_iter, event_class, NULL, stream, false, 0);
+       return create_event_message(msg_iter, event_class, NULL, stream,
+               false, 0, __func__);
 }
 
 struct bt_message *bt_message_event_create_with_packet(
@@ -220,7 +221,7 @@ struct bt_message *bt_message_event_create_with_packet(
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_PACKET_NON_NULL(packet);
        return create_event_message(msg_iter, event_class, packet,
-               packet->stream, false, 0);
+               packet->stream, false, 0, __func__);
 }
 
 struct bt_message *bt_message_event_create_with_default_clock_snapshot(
@@ -232,7 +233,7 @@ struct bt_message *bt_message_event_create_with_default_clock_snapshot(
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_STREAM_NON_NULL(stream);
        return create_event_message(msg_iter, event_class, NULL, stream,
-               true, raw_value);
+               true, raw_value, __func__);
 }
 
 struct bt_message *
@@ -245,7 +246,7 @@ bt_message_event_create_with_packet_and_default_clock_snapshot(
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_PACKET_NON_NULL(packet);
        return create_event_message(msg_iter, event_class, packet,
-               packet->stream, true, raw_value);
+               packet->stream, true, raw_value, __func__);
 }
 
 BT_HIDDEN
@@ -299,13 +300,17 @@ void bt_message_event_recycle(struct bt_message *msg)
        bt_object_pool_recycle_object(&graph->event_msg_pool, msg);
 }
 
+#define BT_ASSERT_PRE_DEV_FOR_BORROW_EVENTS(_msg)                      \
+       do {                                                            \
+               BT_ASSERT_PRE_DEV_MSG_NON_NULL(_msg);                   \
+               BT_ASSERT_PRE_DEV_MSG_IS_EVENT(_msg);                   \
+       } while (0)
+
 static inline
 struct bt_event *borrow_event(struct bt_message *message)
 {
        struct bt_message_event *event_message;
 
-       BT_ASSERT_PRE_DEV_MSG_NON_NULL(message);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(message, BT_MESSAGE_TYPE_EVENT);
        event_message = container_of(message,
                        struct bt_message_event, parent);
        return event_message->event;
@@ -314,12 +319,14 @@ struct bt_event *borrow_event(struct bt_message *message)
 struct bt_event *bt_message_event_borrow_event(
                struct bt_message *message)
 {
+       BT_ASSERT_PRE_DEV_FOR_BORROW_EVENTS(message);
        return borrow_event(message);
 }
 
 const struct bt_event *bt_message_event_borrow_event_const(
                const struct bt_message *message)
 {
+       BT_ASSERT_PRE_DEV_FOR_BORROW_EVENTS(message);
        return borrow_event((void *) message);
 }
 
@@ -331,7 +338,7 @@ bt_message_event_borrow_default_clock_snapshot_const(
        struct bt_stream_class *stream_class;
 
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_EVENT);
+       BT_ASSERT_PRE_DEV_MSG_IS_EVENT(msg);
        stream_class = bt_event_class_borrow_stream_class_inline(
                event_msg->event->class);
        BT_ASSERT_DBG(stream_class);
@@ -347,7 +354,7 @@ bt_message_event_borrow_stream_class_default_clock_class_const(
        struct bt_stream_class *stream_class;
 
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_EVENT);
+       BT_ASSERT_PRE_DEV_MSG_IS_EVENT(msg);
        stream_class = bt_event_class_borrow_stream_class_inline(
                event_msg->event->class);
        BT_ASSERT_DBG(stream_class);
index f6769aff52edba063d0ecaecf6b6e83f8f7512ac..89302ff23cf7fd65adabcb0be18c8a5e67f954a8 100644 (file)
@@ -86,7 +86,8 @@ bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(
        struct bt_message_message_iterator_inactivity *inactivity = (void *) msg;
 
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg,
+       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE("message", msg,
+               "message-iterator-inactivity",
                BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY);
        return inactivity->cs;
 }
index 8baa25fc2b575ee80baf9e671136753f5e1cc9f5..86452b0c6a7df2ad759ad8ad154ae4d762b64b74 100644 (file)
 
 #include "packet.h"
 
+#define BT_ASSERT_PRE_DEV_MSG_IS_PACKET_BEGINNING(_msg)                        \
+       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE("message", (_msg),               \
+               "packet-beginning", BT_MESSAGE_TYPE_PACKET_BEGINNING)
+
+#define BT_ASSERT_PRE_DEV_MSG_IS_PACKET_END(_msg)                      \
+       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE("message", (_msg),               \
+               "packet-end", BT_MESSAGE_TYPE_PACKET_END)
+
 static inline
 struct bt_message *new_packet_message(struct bt_graph *graph,
                enum bt_message_type type, bt_object_release_func recycle_func)
@@ -67,7 +75,7 @@ static inline
 struct bt_message *create_packet_message(
                struct bt_message_iterator *msg_iter,
                struct bt_packet *packet, struct bt_object_pool *pool,
-               bool with_cs, uint64_t raw_value)
+               bool with_cs, uint64_t raw_value, const char *api_func)
 {
        struct bt_message_packet *message = NULL;
        struct bt_stream *stream;
@@ -75,7 +83,7 @@ struct bt_message *create_packet_message(
        bool need_cs;
 
        BT_ASSERT(msg_iter);
-       BT_ASSERT_PRE_PACKET_NON_NULL(packet);
+       BT_ASSERT_PRE_PACKET_NON_NULL_FROM_FUNC(api_func, packet);
        stream = bt_packet_borrow_stream(packet);
        BT_ASSERT(stream);
        stream_class = bt_stream_borrow_class(stream);
@@ -97,14 +105,16 @@ struct bt_message *create_packet_message(
         * `packet_has_default_clock_snapshot` implies that the stream
         * class has a default clock class (precondition).
         */
-       BT_ASSERT_PRE(need_cs ? with_cs : true,
+       BT_ASSERT_PRE_FROM_FUNC(api_func, "with-default-clock-snapshot",
+               need_cs ? with_cs : true,
                "Unexpected stream class configuration when creating "
                "a packet beginning or end message: "
                "a default clock snapshot is needed, but none was provided: "
                "%![stream-]+s, %![sc-]+S, with-cs=%d, "
                "cs-val=%" PRIu64,
                stream, stream_class, with_cs, raw_value);
-       BT_ASSERT_PRE(!need_cs ? !with_cs : true,
+       BT_ASSERT_PRE_FROM_FUNC(api_func, "without-default-clock-snapshot",
+               !need_cs ? !with_cs : true,
                "Unexpected stream class configuration when creating "
                "a packet beginning or end message: "
                "no default clock snapshot is needed, but one was provided: "
@@ -157,7 +167,7 @@ struct bt_message *bt_message_packet_beginning_create(
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_MSG_ITER_NON_NULL(msg_iter);
        return create_packet_message(msg_iter, (void *) packet,
-               &msg_iter->graph->packet_begin_msg_pool, false, 0);
+               &msg_iter->graph->packet_begin_msg_pool, false, 0, __func__);
 }
 
 struct bt_message *bt_message_packet_beginning_create_with_default_clock_snapshot(
@@ -170,7 +180,8 @@ struct bt_message *bt_message_packet_beginning_create_with_default_clock_snapsho
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_MSG_ITER_NON_NULL(msg_iter);
        return create_packet_message(msg_iter, (void *) packet,
-               &msg_iter->graph->packet_begin_msg_pool, true, raw_value);
+               &msg_iter->graph->packet_begin_msg_pool, true, raw_value,
+               __func__);
 }
 
 struct bt_message *bt_message_packet_end_create(
@@ -183,7 +194,7 @@ struct bt_message *bt_message_packet_end_create(
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_MSG_ITER_NON_NULL(msg_iter);
        return create_packet_message(msg_iter, (void *) packet,
-               &msg_iter->graph->packet_end_msg_pool, false, 0);
+               &msg_iter->graph->packet_end_msg_pool, false, 0, __func__);
 }
 
 struct bt_message *bt_message_packet_end_create_with_default_clock_snapshot(
@@ -196,7 +207,8 @@ struct bt_message *bt_message_packet_end_create_with_default_clock_snapshot(
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_MSG_ITER_NON_NULL(msg_iter);
        return create_packet_message(msg_iter, (void *) packet,
-               &msg_iter->graph->packet_end_msg_pool, true, raw_value);
+               &msg_iter->graph->packet_end_msg_pool, true, raw_value,
+               __func__);
 }
 
 BT_HIDDEN
@@ -267,8 +279,7 @@ struct bt_packet *bt_message_packet_beginning_borrow_packet(
        struct bt_message_packet *packet_msg = (void *) message;
 
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(message);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(message,
-               BT_MESSAGE_TYPE_PACKET_BEGINNING);
+       BT_ASSERT_PRE_DEV_MSG_IS_PACKET_BEGINNING(message);
        return packet_msg->packet;
 }
 
@@ -285,8 +296,7 @@ struct bt_packet *bt_message_packet_end_borrow_packet(
        struct bt_message_packet *packet_msg = (void *) message;
 
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(message);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(message,
-               BT_MESSAGE_TYPE_PACKET_END);
+       BT_ASSERT_PRE_DEV_MSG_IS_PACKET_END(message);
        return packet_msg->packet;
 }
 
@@ -297,6 +307,10 @@ const struct bt_packet *bt_message_packet_end_borrow_packet_const(
                (void *) message);
 }
 
+#define BT_ASSERT_PRE_DEV_FOR_BORROW_DEF_CS(_msg)                      \
+       BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS((_msg),                    \
+               ((struct bt_message_packet *) _msg)->packet->stream->class)
+
 static inline
 const struct bt_clock_snapshot *
 borrow_packet_message_default_clock_snapshot_const(
@@ -305,8 +319,6 @@ borrow_packet_message_default_clock_snapshot_const(
        struct bt_message_packet *packet_msg = (void *) message;
 
        BT_ASSERT_DBG(message);
-       BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS(message,
-               packet_msg->packet->stream->class);
        return packet_msg->default_cs;
 }
 
@@ -315,7 +327,8 @@ bt_message_packet_beginning_borrow_default_clock_snapshot_const(
                const struct bt_message *msg)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_BEGINNING);
+       BT_ASSERT_PRE_DEV_MSG_IS_PACKET_BEGINNING(msg);
+       BT_ASSERT_PRE_DEV_FOR_BORROW_DEF_CS(msg);
        return borrow_packet_message_default_clock_snapshot_const(msg);
 }
 
@@ -324,7 +337,8 @@ bt_message_packet_end_borrow_default_clock_snapshot_const(
                const struct bt_message *msg)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_END);
+       BT_ASSERT_PRE_DEV_MSG_IS_PACKET_END(msg);
+       BT_ASSERT_PRE_DEV_FOR_BORROW_DEF_CS(msg);
        return borrow_packet_message_default_clock_snapshot_const(msg);
 }
 
@@ -344,7 +358,7 @@ bt_message_packet_beginning_borrow_stream_class_default_clock_class_const(
                const struct bt_message *msg)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_BEGINNING);
+       BT_ASSERT_PRE_DEV_MSG_IS_PACKET_BEGINNING(msg);
        return borrow_packet_message_stream_class_default_clock_class(msg);
 }
 
@@ -353,6 +367,6 @@ bt_message_packet_end_borrow_stream_class_default_clock_class_const(
                const struct bt_message *msg)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_END);
+       BT_ASSERT_PRE_DEV_MSG_IS_PACKET_END(msg);
        return borrow_packet_message_stream_class_default_clock_class(msg);
 }
index f92fc3d068e1b8da5cd91517816f67bcf98a1165..cd88d25baceb14f40a363f808896ac5cdc8a00fe 100644 (file)
 
 #include "stream.h"
 
+#define BT_ASSERT_PRE_DEV_MSG_IS_STREAM_BEGINNING(_msg)                        \
+       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE("message", (_msg),               \
+               "stream-beginning", BT_MESSAGE_TYPE_STREAM_BEGINNING)
+
+#define BT_ASSERT_PRE_DEV_MSG_IS_STREAM_END(_msg)                      \
+       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE("message", (_msg),               \
+               "stream-end", BT_MESSAGE_TYPE_STREAM_END)
+
 static
 void destroy_stream_message(struct bt_object *obj)
 {
@@ -42,13 +50,14 @@ void destroy_stream_message(struct bt_object *obj)
 static inline
 struct bt_message *create_stream_message(
                struct bt_self_message_iterator *self_msg_iter,
-               struct bt_stream *stream, enum bt_message_type type)
+               struct bt_stream *stream, enum bt_message_type type,
+               const char *api_func)
 {
        struct bt_message_stream *message;
        struct bt_stream_class *stream_class;
 
-       BT_ASSERT_PRE_MSG_ITER_NON_NULL(self_msg_iter);
-       BT_ASSERT_PRE_STREAM_NON_NULL(stream);
+       BT_ASSERT_PRE_MSG_ITER_NON_NULL_FROM_FUNC(api_func, self_msg_iter);
+       BT_ASSERT_PRE_STREAM_NON_NULL_FROM_FUNC(api_func, stream);
        stream_class = bt_stream_borrow_class(stream);
        BT_ASSERT(stream_class);
        BT_LIB_LOGD("Creating stream message object: "
@@ -97,7 +106,7 @@ struct bt_message *bt_message_stream_beginning_create(
        BT_ASSERT_PRE_DEV_NO_ERROR();
 
        return create_stream_message(self_msg_iter, (void *) stream,
-               BT_MESSAGE_TYPE_STREAM_BEGINNING);
+               BT_MESSAGE_TYPE_STREAM_BEGINNING, __func__);
 }
 
 struct bt_message *bt_message_stream_end_create(
@@ -107,7 +116,7 @@ struct bt_message *bt_message_stream_end_create(
        BT_ASSERT_PRE_DEV_NO_ERROR();
 
        return create_stream_message(self_msg_iter, (void *) stream,
-               BT_MESSAGE_TYPE_STREAM_END);
+               BT_MESSAGE_TYPE_STREAM_END, __func__);
 }
 
 static inline
@@ -124,8 +133,7 @@ struct bt_stream *bt_message_stream_beginning_borrow_stream(
                struct bt_message *message)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(message);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(message,
-               BT_MESSAGE_TYPE_STREAM_BEGINNING);
+       BT_ASSERT_PRE_DEV_MSG_IS_STREAM_BEGINNING(message);
        return borrow_stream_message_stream(message);
 }
 
@@ -133,8 +141,7 @@ struct bt_stream *bt_message_stream_end_borrow_stream(
                struct bt_message *message)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(message);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(message,
-               BT_MESSAGE_TYPE_STREAM_END);
+       BT_ASSERT_PRE_DEV_MSG_IS_STREAM_END(message);
        return borrow_stream_message_stream(message);
 }
 
@@ -153,17 +160,19 @@ const struct bt_stream *bt_message_stream_end_borrow_stream_const(
 }
 
 static
-void bt_message_stream_set_default_clock_snapshot(
-               struct bt_message *msg, uint64_t raw_value)
+void set_stream_default_clock_snapshot(
+               struct bt_message *msg, uint64_t raw_value,
+               const char *api_func)
 {
        struct bt_message_stream *stream_msg = (void *) msg;
        struct bt_stream_class *sc;
 
        BT_ASSERT(msg);
-       BT_ASSERT_PRE_DEV_HOT(msg, "Message", ": %!+n", msg);
+       BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(api_func, "message", msg,
+               "Message", ": %!+n", msg);
        sc = stream_msg->stream->class;
        BT_ASSERT(sc);
-       BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS(msg, sc);
+       BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FROM_FUNC(api_func, msg, sc);
        BT_ASSERT(stream_msg->default_cs);
        bt_clock_snapshot_set_raw_value(stream_msg->default_cs, raw_value);
        stream_msg->default_cs_state = BT_MESSAGE_STREAM_CLOCK_SNAPSHOT_STATE_KNOWN;
@@ -175,23 +184,22 @@ void bt_message_stream_beginning_set_default_clock_snapshot(
                struct bt_message *message, uint64_t raw_value)
 {
        BT_ASSERT_PRE_MSG_NON_NULL(message);
-       BT_ASSERT_PRE_MSG_HAS_TYPE(message, BT_MESSAGE_TYPE_STREAM_BEGINNING);
-
-       bt_message_stream_set_default_clock_snapshot(message, raw_value);
+       BT_ASSERT_PRE_DEV_MSG_IS_STREAM_BEGINNING(message);
+       set_stream_default_clock_snapshot(message, raw_value, __func__);
 }
 
 void bt_message_stream_end_set_default_clock_snapshot(
                struct bt_message *message, uint64_t raw_value)
 {
        BT_ASSERT_PRE_MSG_NON_NULL(message);
-       BT_ASSERT_PRE_MSG_HAS_TYPE(message, BT_MESSAGE_TYPE_STREAM_END);
-
-       return bt_message_stream_set_default_clock_snapshot(message, raw_value);
+       BT_ASSERT_PRE_DEV_MSG_IS_STREAM_END(message);
+       return set_stream_default_clock_snapshot(message, raw_value, __func__);
 }
 
 static enum bt_message_stream_clock_snapshot_state
-bt_message_stream_borrow_default_clock_snapshot_const(
-               const bt_message *msg, const bt_clock_snapshot **snapshot)
+borrow_stream_message_default_clock_snapshot_const(
+               const bt_message *msg, const bt_clock_snapshot **snapshot,
+               const char *api_func)
 {
        struct bt_message_stream *stream_msg = (void *) msg;
        struct bt_stream_class *sc;
@@ -199,7 +207,7 @@ bt_message_stream_borrow_default_clock_snapshot_const(
        BT_ASSERT_DBG(msg);
        sc = stream_msg->stream->class;
        BT_ASSERT_DBG(sc);
-       BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS(msg, sc);
+       BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS_FROM_FUNC(api_func, msg, sc);
        BT_ASSERT_DBG(stream_msg->default_cs);
 
        *snapshot = stream_msg->default_cs;
@@ -212,10 +220,9 @@ bt_message_stream_beginning_borrow_default_clock_snapshot_const(
                const bt_message *message, const bt_clock_snapshot **snapshot)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(message);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(message,
-               BT_MESSAGE_TYPE_STREAM_BEGINNING);
-       return bt_message_stream_borrow_default_clock_snapshot_const(
-               message, snapshot);
+       BT_ASSERT_PRE_DEV_MSG_IS_STREAM_BEGINNING(message);
+       return borrow_stream_message_default_clock_snapshot_const(
+               message, snapshot, __func__);
 }
 
 enum bt_message_stream_clock_snapshot_state
@@ -223,9 +230,9 @@ bt_message_stream_end_borrow_default_clock_snapshot_const(
                const bt_message *message, const bt_clock_snapshot **snapshot)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(message);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(message, BT_MESSAGE_TYPE_STREAM_END);
-       return bt_message_stream_borrow_default_clock_snapshot_const(
-               message, snapshot);
+       BT_ASSERT_PRE_DEV_MSG_IS_STREAM_END(message);
+       return borrow_stream_message_default_clock_snapshot_const(
+               message, snapshot, __func__);
 }
 
 static inline
@@ -244,8 +251,7 @@ bt_message_stream_beginning_borrow_stream_class_default_clock_class_const(
                const struct bt_message *msg)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg,
-               BT_MESSAGE_TYPE_STREAM_BEGINNING);
+       BT_ASSERT_PRE_DEV_MSG_IS_STREAM_BEGINNING(msg);
        return borrow_stream_message_stream_class_default_clock_class(msg);
 }
 
@@ -254,6 +260,6 @@ bt_message_stream_end_borrow_stream_class_default_clock_class_const(
                const struct bt_message *msg)
 {
        BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg);
-       BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_STREAM_END);
+       BT_ASSERT_PRE_DEV_MSG_IS_STREAM_END(msg);
        return borrow_stream_message_stream_class_default_clock_class(msg);
 }
index 0252e5ead540350550fc6d725fe5135e71fc61b9..19635a6acbbdb6245dcdec15829af14f225a6f6a 100644 (file)
@@ -71,6 +71,7 @@ int validate_operative_mip_version_in_array(GPtrArray *descriptors,
                struct bt_component_descriptor_set_entry *descr =
                        descriptors->pdata[i];
                method_t method = NULL;
+               const char *method_name = NULL;
                bt_component_class_get_supported_mip_versions_method_status method_status;
 
                switch (descr->comp_cls->type) {
@@ -80,6 +81,7 @@ int validate_operative_mip_version_in_array(GPtrArray *descriptors,
                                descr->comp_cls;
 
                        method = (method_t) src_cc->methods.get_supported_mip_versions;
+                       method_name = "bt_component_class_source_get_supported_mip_versions_method";
                        break;
                }
                case BT_COMPONENT_CLASS_TYPE_FILTER:
@@ -88,6 +90,7 @@ int validate_operative_mip_version_in_array(GPtrArray *descriptors,
                                descr->comp_cls;
 
                        method = (method_t) flt_cc->methods.get_supported_mip_versions;
+                       method_name = "bt_component_class_filter_get_supported_mip_versions_method";
                        break;
                }
                case BT_COMPONENT_CLASS_TYPE_SINK:
@@ -96,6 +99,7 @@ int validate_operative_mip_version_in_array(GPtrArray *descriptors,
                                descr->comp_cls;
 
                        method = (method_t) sink_cc->methods.get_supported_mip_versions;
+                       method_name = "bt_component_class_sink_get_supported_mip_versions_method";
                        break;
                }
                default:
@@ -125,11 +129,13 @@ int validate_operative_mip_version_in_array(GPtrArray *descriptors,
                        range_set);
                BT_LIB_LOGD("User method returned: status=%s",
                        bt_common_func_status_string(method_status));
-               BT_ASSERT_POST(method_status != BT_FUNC_STATUS_OK ||
+               BT_ASSERT_POST(method_name, "status-ok-with-at-least-one-range",
+                       method_status != BT_FUNC_STATUS_OK ||
                        range_set->ranges->len > 0,
                        "User method returned `BT_FUNC_STATUS_OK` without "
                        "adding a range to the supported MIP version range set.");
-               BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(method_status);
+               BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(method_name,
+                       method_status);
                if (method_status < 0) {
                        BT_LIB_LOGW_APPEND_CAUSE(
                                "Component class's \"get supported MIP versions\" method failed: "
@@ -180,9 +186,11 @@ bt_get_greatest_operative_mip_version(
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_COMP_DESCR_SET_NON_NULL(comp_descr_set);
-       BT_ASSERT_PRE_NON_NULL(operative_mip_version,
+       BT_ASSERT_PRE_NON_NULL("operative-mip-version-output",
+               operative_mip_version,
                "Operative MIP version (output)");
-       BT_ASSERT_PRE(comp_descr_set->sources->len +
+       BT_ASSERT_PRE("component-descriptor-set-is-not-empty",
+               comp_descr_set->sources->len +
                comp_descr_set->filters->len +
                comp_descr_set->sinks->len > 0,
                "Component descriptor set is empty: addr=%p", comp_descr_set);
index be5bbba19ab16e53d89566ad7c47dec93b14bf12..e68d1e978470cb7c535546e8fe7549d373d91e4d 100644 (file)
@@ -58,7 +58,7 @@ struct bt_query_executor *bt_query_executor_create_with_method_data(
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
-       BT_ASSERT_PRE_NON_NULL(object, "Object");
+       BT_ASSERT_PRE_NON_NULL("object", object, "Object");
        BT_LIB_LOGD("Creating query executor: "
                "%![comp-cls-]+C, object=\"%s\", %![params-]+v",
                comp_cls, object, params);
@@ -140,6 +140,7 @@ enum bt_query_executor_query_status bt_query_executor_query(
        enum bt_query_executor_query_status status;
        enum bt_component_class_query_method_status query_status;
        method_t method = NULL;
+       const char *method_name = NULL;
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_QUERY_EXEC_NON_NULL(query_exec);
@@ -175,6 +176,7 @@ enum bt_query_executor_query_status bt_query_executor_query(
                        query_exec->comp_cls;
 
                method = (method_t) src_cc->methods.query;
+               method_name = "bt_component_class_source_query_method";
                break;
        }
        case BT_COMPONENT_CLASS_TYPE_FILTER:
@@ -183,6 +185,7 @@ enum bt_query_executor_query_status bt_query_executor_query(
                        query_exec->comp_cls;
 
                method = (method_t) flt_cc->methods.query;
+               method_name = "bt_component_class_filter_query_method";
                break;
        }
        case BT_COMPONENT_CLASS_TYPE_SINK:
@@ -191,6 +194,7 @@ enum bt_query_executor_query_status bt_query_executor_query(
                        query_exec->comp_cls;
 
                method = (method_t) sink_cc->methods.query;
+               method_name = "bt_component_class_sink_query_method";
                break;
        }
        default:
@@ -217,9 +221,10 @@ enum bt_query_executor_query_status bt_query_executor_query(
                query_exec->params, query_exec->method_data, user_result);
        BT_LIB_LOGD("User method returned: status=%s, %![res-]+v",
                bt_common_func_status_string(query_status), *user_result);
-       BT_ASSERT_POST(query_status != BT_FUNC_STATUS_OK || *user_result,
+       BT_ASSERT_POST(method_name, "status-ok-with-result",
+               query_status != BT_FUNC_STATUS_OK || *user_result,
                "User method returned `BT_FUNC_STATUS_OK` without a result.");
-       BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(query_status);
+       BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(method_name, query_status);
        status = (int) query_status;
 
        if (status < 0) {
index 2fe13ec5d10666f7278fc1302c75b04ee3ad1686..2f2fea7e93db1e8a600eebffee5b0cc02055c2c2 100644 (file)
@@ -64,8 +64,10 @@ bt_bool bt_integer_range_unsigned_is_equal(
                const struct bt_integer_range_unsigned *range_a,
                const struct bt_integer_range_unsigned *range_b)
 {
-       BT_ASSERT_PRE_DEV_NON_NULL(range_a, "Integer range A");
-       BT_ASSERT_PRE_DEV_NON_NULL(range_b, "Integer range B");
+       BT_ASSERT_PRE_DEV_NON_NULL("integer-range-a", range_a,
+               "Integer range A");
+       BT_ASSERT_PRE_DEV_NON_NULL("integer-range-b", range_b,
+               "Integer range B");
        return (bt_bool) compare_ranges((const void *) range_a,
                (const void *) range_b);
 }
@@ -74,8 +76,10 @@ bt_bool bt_integer_range_signed_is_equal(
                const struct bt_integer_range_signed *range_a,
                const struct bt_integer_range_signed *range_b)
 {
-       BT_ASSERT_PRE_DEV_NON_NULL(range_a, "Integer range A");
-       BT_ASSERT_PRE_DEV_NON_NULL(range_b, "Integer range B");
+       BT_ASSERT_PRE_DEV_NON_NULL("integer-range-a", range_a,
+               "Integer range A");
+       BT_ASSERT_PRE_DEV_NON_NULL("integer-range-b", range_b,
+               "Integer range B");
        return (bt_bool) compare_ranges((const void *) range_a,
                (const void *) range_b);
 }
@@ -186,8 +190,8 @@ void add_range_to_range_set(struct bt_integer_range_set *range_set,
        };
 
        BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL(range_set);
-       BT_ASSERT_PRE_DEV_HOT(range_set, "Integer range set", ": %!+R",
-               range_set);
+       BT_ASSERT_PRE_DEV_HOT("integer-range-set", range_set,
+               "Integer range set", ": %!+R", range_set);
        g_array_append_val(range_set->ranges, range);
        BT_LIB_LOGD("Added integer range to integer range set: "
                "%![range-set-]+R, lower-unsigned=%" PRIu64 ", "
@@ -200,7 +204,7 @@ bt_integer_range_set_unsigned_add_range(
                uint64_t lower, uint64_t upper)
 {
        BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE(lower <= upper,
+       BT_ASSERT_PRE("lower-lteq-upper", lower <= upper,
                "Range's upper bound is less than lower bound: "
                "upper=%" PRIu64 ", lower=%" PRIu64, lower, upper);
        add_range_to_range_set((void *) range_set, lower, upper);
@@ -213,7 +217,7 @@ bt_integer_range_set_signed_add_range(
                int64_t lower, int64_t upper)
 {
        BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE(lower <= upper,
+       BT_ASSERT_PRE("lower-lteq-upper", lower <= upper,
                "Range's upper bound is less than lower bound: "
                "upper=%" PRId64 ", lower=%" PRId64, lower, upper);
        add_range_to_range_set((void *) range_set,
@@ -351,8 +355,10 @@ bt_bool bt_integer_range_set_unsigned_is_equal(
                const struct bt_integer_range_set_unsigned *range_set_a,
                const struct bt_integer_range_set_unsigned *range_set_b)
 {
-       BT_ASSERT_PRE_DEV_NON_NULL(range_set_a, "Range set A");
-       BT_ASSERT_PRE_DEV_NON_NULL(range_set_b, "Range set B");
+       BT_ASSERT_PRE_DEV_NON_NULL("integer-range-set-a", range_set_a,
+               "Range set A");
+       BT_ASSERT_PRE_DEV_NON_NULL("integer-range-set-b", range_set_b,
+               "Range set B");
        return (bt_bool) compare_range_sets((const void *) range_set_a,
                (const void *) range_set_b);
 }
@@ -361,8 +367,10 @@ bt_bool bt_integer_range_set_signed_is_equal(
                const struct bt_integer_range_set_signed *range_set_a,
                const struct bt_integer_range_set_signed *range_set_b)
 {
-       BT_ASSERT_PRE_DEV_NON_NULL(range_set_a, "Range set A");
-       BT_ASSERT_PRE_DEV_NON_NULL(range_set_b, "Range set B");
+       BT_ASSERT_PRE_DEV_NON_NULL("integer-range-set-a", range_set_a,
+               "Range set A");
+       BT_ASSERT_PRE_DEV_NON_NULL("integer-range-set-b", range_set_b,
+               "Range set B");
        return (bt_bool) compare_range_sets((const void *) range_set_a,
                (const void *) range_set_b);
 }
index c95fe83070e20dbb4790d7e903d34b8999b3b697..93a56c27eec835fd1798d56686fca200e169d0bb 100644 (file)
@@ -184,7 +184,7 @@ enum bt_plugin_find_all_from_file_status bt_plugin_find_all_from_file(
        enum bt_plugin_find_all_from_file_status status;
 
        BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_NON_NULL(path, "Path");
+       BT_ASSERT_PRE_NON_NULL("path", path, "Path");
        BT_ASSERT_PRE_PLUGIN_SET_OUT_NON_NULL(path);
        BT_LOGI("Creating plugins from file: path=\"%s\"", path);
 
index d2c7ab54be3cf944efef9265362101edafbb9ca4..bb50730609b5036985b94cc0644bb87e78ec51ba 100644 (file)
@@ -25,7 +25,8 @@
 #include "lib/value.h"
 
 #define BT_ASSERT_PRE_DEV_CLOCK_CLASS_HOT(_cc)                         \
-       BT_ASSERT_PRE_DEV_HOT((_cc), "Clock class", ": %!+K", (_cc))
+       BT_ASSERT_PRE_DEV_HOT("clock-class", (_cc), "Clock class",      \
+               ": %!+K", (_cc))
 
 static
 void destroy_clock_class(struct bt_object *obj)
@@ -178,10 +179,12 @@ void bt_clock_class_set_frequency(struct bt_clock_class *clock_class,
 {
        BT_ASSERT_PRE_CLK_CLS_NON_NULL(clock_class);
        BT_ASSERT_PRE_DEV_CLOCK_CLASS_HOT(clock_class);
-       BT_ASSERT_PRE(frequency != UINT64_C(-1) && frequency != 0,
+       BT_ASSERT_PRE("valid-frequency",
+               frequency != UINT64_C(-1) && frequency != 0,
                "Invalid frequency: %![cc-]+K, new-freq=%" PRIu64,
                clock_class, frequency);
-       BT_ASSERT_PRE(clock_class->offset_cycles < frequency,
+       BT_ASSERT_PRE("offset-cycles-lt-frequency",
+               clock_class->offset_cycles < frequency,
                "Offset (cycles) is greater than clock class's frequency: "
                "%![cc-]+K, new-freq=%" PRIu64, clock_class, frequency);
        clock_class->frequency = frequency;
@@ -200,7 +203,7 @@ void bt_clock_class_set_precision(struct bt_clock_class *clock_class,
 {
        BT_ASSERT_PRE_CLK_CLS_NON_NULL(clock_class);
        BT_ASSERT_PRE_DEV_CLOCK_CLASS_HOT(clock_class);
-       BT_ASSERT_PRE(precision != UINT64_C(-1),
+       BT_ASSERT_PRE("valid-precision", precision != UINT64_C(-1),
                "Invalid precision: %![cc-]+K, new-precision=%" PRIu64,
                clock_class, precision);
        clock_class->precision = precision;
@@ -211,8 +214,9 @@ void bt_clock_class_get_offset(const struct bt_clock_class *clock_class,
                int64_t *seconds, uint64_t *cycles)
 {
        BT_ASSERT_PRE_DEV_CLK_CLS_NON_NULL(clock_class);
-       BT_ASSERT_PRE_DEV_NON_NULL(seconds, "Seconds (output)");
-       BT_ASSERT_PRE_DEV_NON_NULL(cycles, "Cycles (output)");
+       BT_ASSERT_PRE_DEV_NON_NULL("seconds-output", seconds,
+               "Seconds (output)");
+       BT_ASSERT_PRE_DEV_NON_NULL("cycles-output", cycles, "Cycles (output)");
        *seconds = clock_class->offset_seconds;
        *cycles = clock_class->offset_cycles;
 }
@@ -222,7 +226,8 @@ void bt_clock_class_set_offset(struct bt_clock_class *clock_class,
 {
        BT_ASSERT_PRE_CLK_CLS_NON_NULL(clock_class);
        BT_ASSERT_PRE_DEV_CLOCK_CLASS_HOT(clock_class);
-       BT_ASSERT_PRE(cycles < clock_class->frequency,
+       BT_ASSERT_PRE("offset-cycles-lt-frequency",
+               cycles < clock_class->frequency,
                "Offset (cycles) is greater than clock class's frequency: "
                "%![cc-]+K, new-offset-cycles=%" PRIu64, clock_class, cycles);
        clock_class->offset_seconds = seconds;
@@ -289,7 +294,8 @@ bt_clock_class_cycles_to_ns_from_origin(
 
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_DEV_CLK_CLS_NON_NULL(clock_class);
-       BT_ASSERT_PRE_DEV_NON_NULL(ns, "Nanoseconds (output)");
+       BT_ASSERT_PRE_DEV_NON_NULL("nanoseconds-output", ns,
+               "Nanoseconds (output)");
        ret = bt_util_ns_from_origin_clock_class(clock_class, cycles, ns);
        if (ret) {
                BT_LIB_LOGE_APPEND_CAUSE("Cannot convert cycles to nanoseconds "
index 3006ff573acfe44a73fa78a5d13a9f5a608b22dd..55e3777b2f098ae123eaedf069959820fca14994 100644 (file)
@@ -121,8 +121,7 @@ uint64_t bt_clock_snapshot_get_value(
                const struct bt_clock_snapshot *clock_snapshot)
 {
        BT_ASSERT_PRE_DEV_CS_NON_NULL(clock_snapshot);
-       BT_ASSERT_PRE_DEV(clock_snapshot->is_set,
-               "Clock snapshot is not set: %!+k", clock_snapshot);
+       BT_ASSERT_DBG(clock_snapshot->is_set);
        return clock_snapshot->value_cycles;
 }
 
@@ -135,9 +134,9 @@ bt_clock_snapshot_get_ns_from_origin(
 
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_DEV_CS_NON_NULL(clock_snapshot);
-       BT_ASSERT_PRE_DEV_NON_NULL(ret_value_ns, "Value (ns) (output)");
-       BT_ASSERT_PRE_DEV(clock_snapshot->is_set,
-               "Clock snapshot is not set: %!+k", clock_snapshot);
+       BT_ASSERT_PRE_DEV_NON_NULL("value-ns-output", ret_value_ns,
+               "Value (ns) (output)");
+       BT_ASSERT_DBG(clock_snapshot->is_set);
 
        if (clock_snapshot->ns_from_origin_overflows) {
                BT_LIB_LOGE_APPEND_CAUSE(
index c520a83749bf869607ac0eebf3dea1a9180a1006..871f40cbb13eeaa15fdc00183954142870c52d14 100644 (file)
@@ -34,7 +34,8 @@
 #include "lib/func-status.h"
 
 #define BT_ASSERT_PRE_DEV_EVENT_CLASS_HOT(_ec)                         \
-       BT_ASSERT_PRE_DEV_HOT(((const struct bt_event_class *) (_ec)),  \
+       BT_ASSERT_PRE_DEV_HOT("event-class",                            \
+               ((const struct bt_event_class *) (_ec)),                \
                "Event class", ": %!+E", (_ec))
 
 static
@@ -99,7 +100,8 @@ struct bt_event_class *create_event_class_with_id(
        struct bt_event_class *event_class;
 
        BT_ASSERT(stream_class);
-       BT_ASSERT_PRE(event_class_id_is_unique(stream_class, id),
+       BT_ASSERT_PRE("event-class-id-is-unique",
+               event_class_id_is_unique(stream_class, id),
                "Duplicate event class ID: %![sc-]+S, id=%" PRIu64,
                stream_class, id);
        BT_LIB_LOGD("Creating event class object: %![sc-]+S, id=%" PRIu64,
@@ -163,7 +165,9 @@ struct bt_event_class *bt_event_class_create(
 {
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_SC_NON_NULL(stream_class);
-       BT_ASSERT_PRE(stream_class->assigns_automatic_event_class_id,
+       BT_ASSERT_PRE(
+               "stream-class-automatically-assigns-event-class-ids",
+               stream_class->assigns_automatic_event_class_id,
                "Stream class does not automatically assigns event class IDs: "
                "%![sc-]+S", stream_class);
        return create_event_class_with_id(stream_class,
@@ -174,7 +178,9 @@ struct bt_event_class *bt_event_class_create_with_id(
                struct bt_stream_class *stream_class, uint64_t id)
 {
        BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE(!stream_class->assigns_automatic_event_class_id,
+       BT_ASSERT_PRE(
+               "stream-class-does-not-automatically-assigns-event-class-ids",
+               !stream_class->assigns_automatic_event_class_id,
                "Stream class automatically assigns event class IDs: "
                "%![sc-]+S", stream_class);
        return create_event_class_with_id(stream_class, id);
@@ -210,7 +216,8 @@ enum bt_property_availability bt_event_class_get_log_level(
                enum bt_event_class_log_level *log_level)
 {
        BT_ASSERT_PRE_DEV_EC_NON_NULL(event_class);
-       BT_ASSERT_PRE_DEV_NON_NULL(log_level, "Log level (output)");
+       BT_ASSERT_PRE_DEV_NON_NULL("log-level-output", log_level,
+               "Log level (output)");
        *log_level = (enum bt_event_class_log_level)
                event_class->log_level.value;
        return event_class->log_level.base.avail;
@@ -239,7 +246,7 @@ enum bt_event_class_set_emf_uri_status bt_event_class_set_emf_uri(
 {
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_EC_NON_NULL(event_class);
-       BT_ASSERT_PRE_NON_NULL(emf_uri, "EMF URI");
+       BT_ASSERT_PRE_NON_NULL("emf-uri", emf_uri, "EMF URI");
        BT_ASSERT_PRE_DEV_EVENT_CLASS_HOT(event_class);
        g_string_assign(event_class->emf_uri.str, emf_uri);
        event_class->emf_uri.value = event_class->emf_uri.str->str;
@@ -295,14 +302,15 @@ bt_event_class_set_specific_context_field_class(
        BT_ASSERT_PRE_EC_NON_NULL(event_class);
        BT_ASSERT_PRE_FC_NON_NULL(field_class);
        BT_ASSERT_PRE_DEV_EVENT_CLASS_HOT(event_class);
-       BT_ASSERT_PRE_FC_IS_STRUCT(field_class, "Specific context field class");
+       BT_ASSERT_PRE_FC_IS_STRUCT("specific-context", field_class,
+               "Specific context field class");
        stream_class = bt_event_class_borrow_stream_class_inline(
                event_class);
        resolve_ctx.packet_context = stream_class->packet_context_fc;
        resolve_ctx.event_common_context =
                stream_class->event_common_context_fc;
 
-       ret = bt_resolve_field_paths(field_class, &resolve_ctx);
+       ret = bt_resolve_field_paths(field_class, &resolve_ctx, __func__);
        if (ret) {
                /*
                 * This is the only reason for which
@@ -357,7 +365,7 @@ bt_event_class_set_payload_field_class(
        BT_ASSERT_PRE_EC_NON_NULL(event_class);
        BT_ASSERT_PRE_FC_NON_NULL(field_class);
        BT_ASSERT_PRE_DEV_EVENT_CLASS_HOT(event_class);
-       BT_ASSERT_PRE_FC_IS_STRUCT(field_class, "Payload field class");
+       BT_ASSERT_PRE_FC_IS_STRUCT("payload", field_class, "Payload field class");
        stream_class = bt_event_class_borrow_stream_class_inline(
                event_class);
        resolve_ctx.packet_context = stream_class->packet_context_fc;
@@ -365,7 +373,7 @@ bt_event_class_set_payload_field_class(
                stream_class->event_common_context_fc;
        resolve_ctx.event_specific_context = event_class->specific_context_fc;
 
-       ret = bt_resolve_field_paths(field_class, &resolve_ctx);
+       ret = bt_resolve_field_paths(field_class, &resolve_ctx, __func__);
        if (ret) {
                /*
                 * This is the only reason for which
index 5eb08146356534a71b92284ed3ae95f536ef4b77..2a9230252243ba1aec674cf23078ceea8f99b055 100644 (file)
@@ -82,7 +82,7 @@ struct bt_field_class *bt_field_class_bit_array_create(
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_TC_NON_NULL(trace_class);
-       BT_ASSERT_PRE(length > 0 && length <= 64,
+       BT_ASSERT_PRE("valid-length", length > 0 && length <= 64,
                "Unsupported length for bit array field class "
                "(minimum is 1, maximum is 64): length=%" PRIu64, length);
        BT_LOGD("Creating default bit array field class object.");
@@ -114,8 +114,8 @@ uint64_t bt_field_class_bit_array_get_length(const struct bt_field_class *fc)
        const struct bt_field_class_bit_array *ba_fc = (const void *) fc;
 
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc, BT_FIELD_CLASS_TYPE_BIT_ARRAY,
-               "Field class");
+       BT_ASSERT_PRE_DEV_FC_HAS_TYPE("field-class", fc, "bit-array",
+               BT_FIELD_CLASS_TYPE_BIT_ARRAY, "Field class");
        return ba_fc->length;
 }
 
@@ -241,7 +241,7 @@ uint64_t bt_field_class_integer_get_field_value_range(
        const struct bt_field_class_integer *int_fc = (const void *) fc;
 
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_IS_INT(fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_IS_INT("field-class", fc, "Field class");
        return int_fc->range;
 }
 
@@ -259,12 +259,13 @@ void bt_field_class_integer_set_field_value_range(
        struct bt_field_class_integer *int_fc = (void *) fc;
 
        BT_ASSERT_PRE_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_IS_INT(fc, "Field class");
-       BT_ASSERT_PRE_DEV_FC_HOT(fc, "Field class");
-       BT_ASSERT_PRE(size >= 1 && size <= 64,
+       BT_ASSERT_PRE_FC_IS_INT("field-class", fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_HOT(fc);
+       BT_ASSERT_PRE("valid-n",
+               size >= 1 && size <= 64,
                "Unsupported size for integer field class's field value range "
                "(minimum is 1, maximum is 64): size=%" PRIu64, size);
-       BT_ASSERT_PRE(
+       BT_ASSERT_PRE("valid-n-for-enumeration-field-class",
                int_fc->common.type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER ||
                int_fc->common.type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER ||
                size_is_valid_for_enumeration_field_class(fc, size),
@@ -281,7 +282,7 @@ bt_field_class_integer_get_preferred_display_base(const struct bt_field_class *f
        const struct bt_field_class_integer *int_fc = (const void *) fc;
 
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_IS_INT(fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_IS_INT("field-class", fc, "Field class");
        return int_fc->base;
 }
 
@@ -292,8 +293,8 @@ void bt_field_class_integer_set_preferred_display_base(
        struct bt_field_class_integer *int_fc = (void *) fc;
 
        BT_ASSERT_PRE_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_IS_INT(fc, "Field class");
-       BT_ASSERT_PRE_DEV_FC_HOT(fc, "Field class");
+       BT_ASSERT_PRE_FC_IS_INT("field-class", fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_HOT(fc);
        int_fc->base = base;
        BT_LIB_LOGD("Set integer field class's preferred display base: %!+F", fc);
 }
@@ -409,7 +410,7 @@ uint64_t bt_field_class_enumeration_get_mapping_count(
        const struct bt_field_class_enumeration *enum_fc = (const void *) fc;
 
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_IS_ENUM(fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_IS_ENUM("field-class", fc, "Field class");
        return (uint64_t) enum_fc->mappings->len;
 }
 
@@ -421,8 +422,8 @@ bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const(
 
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
        BT_ASSERT_PRE_DEV_VALID_INDEX(index, enum_fc->mappings->len);
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc, BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION,
-               "Field class");
+       BT_ASSERT_PRE_DEV_FC_HAS_TYPE("field-class", fc, "unsigned-enumeration",
+               BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, "Field class");
        return (const void *) BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(fc, index);
 }
 
@@ -434,21 +435,23 @@ bt_field_class_enumeration_signed_borrow_mapping_by_index_const(
 
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
        BT_ASSERT_PRE_DEV_VALID_INDEX(index, enum_fc->mappings->len);
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc, BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION,
-               "Field class");
+       BT_ASSERT_PRE_DEV_FC_HAS_TYPE("field-class", fc, "signed-enumeration",
+               BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, "Field class");
        return (const void *) BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(fc, index);
 }
 
 static
 const struct bt_field_class_enumeration_mapping *
 borrow_enumeration_field_class_mapping_by_label(
-               const struct bt_field_class_enumeration *fc, const char *label)
+               const struct bt_field_class_enumeration *fc, const char *label,
+               const char *api_func)
 {
        struct bt_field_class_enumeration_mapping *mapping = NULL;
        uint64_t i;
 
        BT_ASSERT_DBG(fc);
-       BT_ASSERT_PRE_DEV_NON_NULL(label, "Label");
+       BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(api_func, "label", label,
+               "Label");
 
        for (i = 0; i < fc->mappings->len; i++) {
                struct bt_field_class_enumeration_mapping *this_mapping =
@@ -469,10 +472,10 @@ bt_field_class_enumeration_signed_borrow_mapping_by_label_const(
                const struct bt_field_class *fc, const char *label)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc, BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION,
-               "Field class");
+       BT_ASSERT_PRE_DEV_FC_HAS_TYPE("field-class", fc, "signed-enumeration",
+               BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, "Field class");
        return (const void *) borrow_enumeration_field_class_mapping_by_label(
-               (const void *) fc, label);
+               (const void *) fc, label, __func__);
 }
 
 const struct bt_field_class_enumeration_unsigned_mapping *
@@ -480,16 +483,17 @@ bt_field_class_enumeration_unsigned_borrow_mapping_by_label_const(
                const struct bt_field_class *fc, const char *label)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc,
+       BT_ASSERT_PRE_DEV_FC_HAS_TYPE("field-class", fc, "unsigned-enumeration",
                BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, "Field class");
        return (const void *) borrow_enumeration_field_class_mapping_by_label(
-               (const void *) fc, label);
+               (const void *) fc, label, __func__);
 }
 
 const char *bt_field_class_enumeration_mapping_get_label(
                const struct bt_field_class_enumeration_mapping *mapping)
 {
-       BT_ASSERT_PRE_DEV_NON_NULL(mapping, "Enumeration field class mapping");
+       BT_ASSERT_PRE_DEV_NON_NULL("enumeration-field-class-mapping",
+               mapping, "Enumeration field class mapping");
        return mapping->label->str;
 }
 
@@ -500,7 +504,8 @@ bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const(
        const struct bt_field_class_enumeration_mapping *mapping =
                (const void *) u_mapping;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(mapping, "Enumeration field class mapping");
+       BT_ASSERT_PRE_DEV_NON_NULL("enumeration-field-class-mapping",
+               mapping, "Enumeration field class mapping");
        return (const void *) mapping->range_set;
 }
 
@@ -511,7 +516,8 @@ bt_field_class_enumeration_signed_mapping_borrow_ranges_const(
        const struct bt_field_class_enumeration_mapping *mapping =
                (const void *) s_mapping;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(mapping, "Enumeration field class mapping");
+       BT_ASSERT_PRE_DEV_NON_NULL("enumeration-field-class-mapping",
+               mapping, "Enumeration field class mapping");
        return (const void *) mapping->range_set;
 }
 
@@ -526,10 +532,11 @@ bt_field_class_enumeration_unsigned_get_mapping_labels_for_value(
 
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Label array (output)");
-       BT_ASSERT_PRE_DEV_NON_NULL(count, "Count (output)");
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc, BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION,
-               "Field class");
+       BT_ASSERT_PRE_DEV_NON_NULL("label-array-output", label_array,
+               "Label array (output)");
+       BT_ASSERT_PRE_DEV_NON_NULL("count-output", count, "Count (output)");
+       BT_ASSERT_PRE_DEV_FC_HAS_TYPE("field-class", fc, "unsigned-enumeration",
+               BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, "Field class");
        g_ptr_array_set_size(enum_fc->label_buf, 0);
 
        for (i = 0; i < enum_fc->mappings->len; i++) {
@@ -567,10 +574,11 @@ bt_field_class_enumeration_signed_get_mapping_labels_for_value(
 
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Label array (output)");
-       BT_ASSERT_PRE_DEV_NON_NULL(count, "Count (output)");
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc, BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION,
-               "Field class");
+       BT_ASSERT_PRE_DEV_NON_NULL("label-array-output", label_array,
+               "Label array (output)");
+       BT_ASSERT_PRE_DEV_NON_NULL("count-output", count, "Count (output)");
+       BT_ASSERT_PRE_DEV_FC_HAS_TYPE("field-class", fc, "signed-enumeration",
+               BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, "Field class");
        g_ptr_array_set_size(enum_fc->label_buf, 0);
 
        for (i = 0; i < enum_fc->mappings->len; i++) {
@@ -625,19 +633,22 @@ end:
 static inline
 enum bt_field_class_enumeration_add_mapping_status
 add_mapping_to_enumeration_field_class(struct bt_field_class *fc,
-               const char *label, const struct bt_integer_range_set *range_set)
+               const char *label, const struct bt_integer_range_set *range_set,
+               const char *api_func)
 {
        enum bt_field_class_enumeration_add_mapping_status status =
                BT_FUNC_STATUS_OK;
        struct bt_field_class_enumeration *enum_fc = (void *) fc;
        struct bt_field_class_enumeration_mapping mapping = { 0 };
 
-       BT_ASSERT_PRE_NO_ERROR();
+       BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(api_func);
        BT_ASSERT(fc);
-       BT_ASSERT_PRE_NON_NULL(label, "Label");
-       BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL(range_set);
-       BT_ASSERT_PRE(!enumeration_field_class_has_mapping_with_label(
-               enum_fc, label),
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(api_func, "label", label, "Label");
+       BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL_FROM_FUNC(api_func, range_set);
+       BT_ASSERT_PRE_FROM_FUNC(api_func,
+               "enumeration-field-class-mapping-label-is-unique",
+               !enumeration_field_class_has_mapping_with_label(
+                       enum_fc, label),
                "Duplicate mapping name in enumeration field class: "
                "%![enum-fc-]+F, label=\"%s\"", fc, label);
        mapping.range_set = range_set;
@@ -664,10 +675,11 @@ bt_field_class_enumeration_unsigned_add_mapping(
 {
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_HAS_TYPE(fc, BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION,
-               "Field class");
+       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+               "unsigned-enumeration-field-class",
+               BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, "Field class");
        return add_mapping_to_enumeration_field_class(fc, label,
-               (const void *) range_set);
+               (const void *) range_set, __func__);
 }
 
 enum bt_field_class_enumeration_add_mapping_status
@@ -677,10 +689,11 @@ bt_field_class_enumeration_signed_add_mapping(
 {
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_HAS_TYPE(fc, BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION,
-               "Field class");
+       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+               "signed-enumeration-field-class",
+               BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, "Field class");
        return add_mapping_to_enumeration_field_class(fc, label,
-               (const void *) range_set);
+               (const void *) range_set, __func__);
 }
 
 static
@@ -972,13 +985,15 @@ end:
 static
 int append_named_field_class_to_container_field_class(
                struct bt_field_class_named_field_class_container *container_fc,
-               struct bt_named_field_class *named_fc)
+               struct bt_named_field_class *named_fc, const char *api_func,
+               const char *unique_entry_precond_id)
 {
        BT_ASSERT(container_fc);
        BT_ASSERT(named_fc);
-       BT_ASSERT_PRE_DEV_FC_HOT(container_fc, "Field class");
-       BT_ASSERT_PRE(!bt_g_hash_table_contains(container_fc->name_to_index,
-               named_fc->name->str),
+       BT_ASSERT_PRE_DEV_FC_HOT_FROM_FUNC(api_func, container_fc);
+       BT_ASSERT_PRE_FROM_FUNC(api_func, unique_entry_precond_id,
+               !bt_g_hash_table_contains(container_fc->name_to_index,
+                       named_fc->name->str),
                "Duplicate member/option name in structure/variant field class: "
                "%![container-fc-]+F, name=\"%s\"", container_fc,
                named_fc->name->str);
@@ -1005,8 +1020,7 @@ bt_field_class_structure_append_member(
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_HAS_TYPE(fc, BT_FIELD_CLASS_TYPE_STRUCTURE,
-               "Field class");
+       BT_ASSERT_PRE_FC_IS_STRUCT("field-class", fc, "Field class");
        named_fc = create_named_field_class(name, member_fc);
        if (!named_fc) {
                /* create_named_field_class() logs errors */
@@ -1015,7 +1029,8 @@ bt_field_class_structure_append_member(
        }
 
        status = append_named_field_class_to_container_field_class((void *) fc,
-               named_fc);
+               named_fc, __func__,
+               "structure-field-class-member-name-is-unique");
        if (status == BT_FUNC_STATUS_OK) {
                /* Moved to the container */
                named_fc = NULL;
@@ -1031,8 +1046,7 @@ uint64_t bt_field_class_structure_get_member_count(
        struct bt_field_class_structure *struct_fc = (void *) fc;
 
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc, BT_FIELD_CLASS_TYPE_STRUCTURE,
-               "Field class");
+       BT_ASSERT_PRE_FC_IS_STRUCT("field-class", fc, "Field class");
        return (uint64_t) struct_fc->common.named_fcs->len;
 }
 
@@ -1040,10 +1054,11 @@ static
 struct bt_named_field_class *
 borrow_named_field_class_from_container_field_class_at_index(
                struct bt_field_class_named_field_class_container *fc,
-               uint64_t index)
+               uint64_t index, const char *api_func)
 {
        BT_ASSERT_DBG(fc);
-       BT_ASSERT_PRE_DEV_VALID_INDEX(index, fc->named_fcs->len);
+       BT_ASSERT_PRE_DEV_VALID_INDEX_FROM_FUNC(api_func, index,
+               fc->named_fcs->len);
        return fc->named_fcs->pdata[index];
 }
 
@@ -1052,11 +1067,10 @@ bt_field_class_structure_borrow_member_by_index_const(
                const struct bt_field_class *fc, uint64_t index)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc, BT_FIELD_CLASS_TYPE_STRUCTURE,
-               "Field class");
+       BT_ASSERT_PRE_FC_IS_STRUCT("field-class", fc, "Field class");
        return (const void *)
                borrow_named_field_class_from_container_field_class_at_index(
-                       (void *) fc, index);
+                       (void *) fc, index, __func__);
 }
 
 struct bt_field_class_structure_member *
@@ -1064,25 +1078,24 @@ bt_field_class_structure_borrow_member_by_index(
                struct bt_field_class *fc, uint64_t index)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc, BT_FIELD_CLASS_TYPE_STRUCTURE,
-               "Field class");
+       BT_ASSERT_PRE_FC_IS_STRUCT("field-class", fc, "Field class");
        return (void *)
                borrow_named_field_class_from_container_field_class_at_index(
-                       (void *) fc, index);
+                       (void *) fc, index, __func__);
 }
 
 static
 struct bt_named_field_class *
 borrow_named_field_class_from_container_field_class_by_name(
                struct bt_field_class_named_field_class_container *fc,
-               const char *name)
+               const char *name, const char *api_func)
 {
        struct bt_named_field_class *named_fc = NULL;
        gpointer orig_key;
        gpointer value;
 
        BT_ASSERT_DBG(fc);
-       BT_ASSERT_PRE_DEV_NAME_NON_NULL(name);
+       BT_ASSERT_PRE_DEV_NAME_NON_NULL_FROM_FUNC(api_func, name);
        if (!g_hash_table_lookup_extended(fc->name_to_index, name, &orig_key,
                        &value)) {
                goto end;
@@ -1099,11 +1112,10 @@ bt_field_class_structure_borrow_member_by_name_const(
                const struct bt_field_class *fc, const char *name)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc, BT_FIELD_CLASS_TYPE_STRUCTURE,
-               "Field class");
+       BT_ASSERT_PRE_FC_IS_STRUCT("field-class", fc, "Field class");
        return (const void *)
                borrow_named_field_class_from_container_field_class_by_name(
-                       (void *) fc, name);
+                       (void *) fc, name, __func__);
 }
 
 struct bt_field_class_structure_member *
@@ -1111,11 +1123,10 @@ bt_field_class_structure_borrow_member_by_name(
                struct bt_field_class *fc, const char *name)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc, BT_FIELD_CLASS_TYPE_STRUCTURE,
-               "Field class");
+       BT_ASSERT_PRE_FC_IS_STRUCT("field-class", fc, "Field class");
        return (void *)
                borrow_named_field_class_from_container_field_class_by_name(
-                       (void *) fc, name);
+                       (void *) fc, name, __func__);
 }
 
 const char *bt_field_class_structure_member_get_name(
@@ -1184,12 +1195,15 @@ struct bt_field_class *create_option_field_class(
                struct bt_trace_class *trace_class,
                enum bt_field_class_type fc_type,
                struct bt_field_class *content_fc,
-               struct bt_field_class *selector_fc)
+               struct bt_field_class *selector_fc,
+               const char *api_func)
 {
        struct bt_field_class_option *opt_fc = NULL;
 
-       BT_ASSERT_PRE_TC_NON_NULL(trace_class);
-       BT_ASSERT_PRE_NON_NULL(content_fc, "Content field class");
+       BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(api_func);
+       BT_ASSERT_PRE_TC_NON_NULL_FROM_FUNC(api_func, trace_class);
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(api_func, "content-field-class",
+               content_fc, "Content field class");
        BT_LIB_LOGD("Creating option field class: "
                "type=%s, %![content-fc-]+F, %![sel-fc-]+F",
                bt_common_field_class_type_string(fc_type),
@@ -1198,17 +1212,21 @@ struct bt_field_class *create_option_field_class(
        if (fc_type != BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD) {
                struct bt_field_class_option_with_selector_field *opt_with_sel_fc = NULL;
 
-               BT_ASSERT_PRE_NON_NULL(selector_fc, "Selector field class");
+               BT_ASSERT_PRE_NON_NULL_FROM_FUNC(api_func,
+                       "selector-field-class", selector_fc,
+                       "Selector field class");
 
                if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD) {
-                       BT_ASSERT_PRE_FC_HAS_TYPE(selector_fc,
-                               BT_FIELD_CLASS_TYPE_BOOL,
+                       BT_ASSERT_PRE_FC_HAS_TYPE_FROM_FUNC(api_func,
+                               "selector-field-class", selector_fc,
+                               "boolean-field-class", BT_FIELD_CLASS_TYPE_BOOL,
                                "Selector field class");
                        opt_with_sel_fc = (void *) g_new0(
                                struct bt_field_class_option_with_selector_field_bool, 1);
                } else {
-                       BT_ASSERT_PRE_FC_IS_INT(selector_fc,
-                               "Selector field class");
+                       BT_ASSERT_PRE_FC_IS_INT_FROM_FUNC(api_func,
+                               "selector-field-class",
+                               selector_fc, "Selector field class");
                        opt_with_sel_fc = (void *) g_new0(
                                struct bt_field_class_option_with_selector_field_integer, 1);
                }
@@ -1261,11 +1279,9 @@ struct bt_field_class *bt_field_class_option_without_selector_create(
                struct bt_trace_class *trace_class,
                struct bt_field_class *content_fc)
 {
-       BT_ASSERT_PRE_NO_ERROR();
-
        return create_option_field_class(trace_class,
                BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD,
-               content_fc, NULL);
+               content_fc, NULL, __func__);
 }
 
 struct bt_field_class *bt_field_class_option_with_selector_field_bool_create(
@@ -1277,7 +1293,7 @@ struct bt_field_class *bt_field_class_option_with_selector_field_bool_create(
 
        return create_option_field_class(trace_class,
                BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD,
-               content_fc, selector_fc);
+               content_fc, selector_fc, __func__);
 }
 
 struct bt_field_class *
@@ -1293,11 +1309,10 @@ bt_field_class_option_with_selector_field_integer_unsigned_create(
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL(range_set);
-       BT_ASSERT_PRE(range_set->ranges->len > 0,
-               "Integer range set is empty: %!+R", range_set);
+       BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY(range_set);
        fc = (void *) create_option_field_class(trace_class,
                BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
-               content_fc, selector_fc);
+               content_fc, selector_fc, __func__);
 
        if (!fc) {
                goto end;
@@ -1324,11 +1339,10 @@ bt_field_class_option_with_selector_field_integer_signed_create(
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL(range_set);
-       BT_ASSERT_PRE(range_set->ranges->len > 0,
-               "Integer range set is empty: %!+R", range_set);
+       BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY(range_set);
        fc = (void *) create_option_field_class(trace_class,
                BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
-               content_fc, selector_fc);
+               content_fc, selector_fc, __func__);
 
        if (!fc) {
                goto end;
@@ -1348,7 +1362,7 @@ const struct bt_field_class *bt_field_class_option_borrow_field_class_const(
        struct bt_field_class_option *opt_fc = (void *) fc;
 
        BT_ASSERT_PRE_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_IS_OPTION(fc, "Field class");
+       BT_ASSERT_PRE_FC_IS_OPTION("field-class", fc, "Field class");
        return opt_fc->content_fc;
 }
 
@@ -1358,7 +1372,7 @@ struct bt_field_class *bt_field_class_option_borrow_field_class(
        struct bt_field_class_option *opt_fc = (void *) fc;
 
        BT_ASSERT_PRE_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_IS_OPTION(fc, "Field class");
+       BT_ASSERT_PRE_FC_IS_OPTION("field-class", fc, "Field class");
        return opt_fc->content_fc;
 }
 
@@ -1370,7 +1384,7 @@ bt_field_class_option_with_selector_field_borrow_selector_field_path_const(
                (const void *) fc;
 
        BT_ASSERT_PRE_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL(fc, "Field class");
+       BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL("field-class", fc, "Field class");
        return opt_fc->selector_field_path;
 }
 
@@ -1380,9 +1394,11 @@ void bt_field_class_option_with_selector_field_bool_set_selector_is_reversed(
        struct bt_field_class_option_with_selector_field_bool *opt_fc = (void *) fc;
 
        BT_ASSERT_PRE_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_HAS_TYPE(fc,
-               BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD, "Field class");
-       BT_ASSERT_PRE_DEV_FC_HOT(fc, "Field class");
+       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+               "option-field-class-with-boolean-selector-field",
+               BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD,
+               "Field class");
+       BT_ASSERT_PRE_DEV_FC_HOT(fc);
        opt_fc->sel_is_reversed = sel_is_reversed;
 }
 
@@ -1392,8 +1408,10 @@ bt_bool bt_field_class_option_with_selector_field_bool_selector_is_reversed(
        struct bt_field_class_option_with_selector_field_bool *opt_fc = (void *) fc;
 
        BT_ASSERT_PRE_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_HAS_TYPE(fc,
-               BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD, "Field class");
+       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+               "option-field-class-with-boolean-selector-field",
+               BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD,
+               "Field class");
        return opt_fc->sel_is_reversed;
 }
 
@@ -1405,7 +1423,8 @@ bt_field_class_option_with_selector_field_integer_unsigned_borrow_selector_range
                (void *) fc;
 
        BT_ASSERT_PRE_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL(fc, "Field class");
+       BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL("field-class", fc,
+               "Field class");
        return (const void *) opt_fc->range_set;
 }
 
@@ -1417,7 +1436,8 @@ bt_field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_
                (void *) fc;
 
        BT_ASSERT_PRE_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL(fc, "Field class");
+       BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL("field-class", fc,
+               "Field class");
        return (const void *) opt_fc->range_set;
 }
 
@@ -1466,7 +1486,8 @@ struct bt_field_class *bt_field_class_variant_create(
        BT_ASSERT_PRE_TC_NON_NULL(trace_class);
 
        if (selector_fc) {
-               BT_ASSERT_PRE_FC_IS_INT(selector_fc, "Selector field class");
+               BT_ASSERT_PRE_FC_IS_INT("selector-field-class", selector_fc,
+                       "Selector field class");
        }
 
        BT_LIB_LOGD("Creating default variant field class: %![sel-fc-]+F",
@@ -1533,6 +1554,9 @@ end:
        return (void *) var_fc;
 }
 
+#define VAR_FC_OPT_NAME_IS_UNIQUE_ID                                   \
+       "variant-field-class-option-name-is-unique"
+
 enum bt_field_class_variant_without_selector_append_option_status
 bt_field_class_variant_without_selector_append_option(struct bt_field_class *fc,
                const char *name, struct bt_field_class *option_fc)
@@ -1543,9 +1567,12 @@ bt_field_class_variant_without_selector_append_option(struct bt_field_class *fc,
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_FC_NON_NULL(fc);
        BT_ASSERT_PRE_NAME_NON_NULL(name);
-       BT_ASSERT_PRE_NON_NULL(option_fc, "Option field class");
-       BT_ASSERT_PRE_FC_HAS_TYPE(fc,
-               BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD, "Field class");
+       BT_ASSERT_PRE_NON_NULL("option-field-class", option_fc,
+               "Option field class");
+       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+               "variant-field-class-without-selector-field",
+               BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD,
+               "Field class");
        named_fc = create_named_field_class(name, option_fc);
        if (!named_fc) {
                /* create_named_field_class() logs errors */
@@ -1554,7 +1581,7 @@ bt_field_class_variant_without_selector_append_option(struct bt_field_class *fc,
        }
 
        status = append_named_field_class_to_container_field_class((void *) fc,
-               named_fc);
+               named_fc, __func__, VAR_FC_OPT_NAME_IS_UNIQUE_ID);
        if (status == BT_FUNC_STATUS_OK) {
                /* Moved to the container */
                named_fc = NULL;
@@ -1658,20 +1685,20 @@ int append_option_to_variant_with_selector_field_field_class(
                struct bt_field_class *fc, const char *name,
                struct bt_field_class *option_fc,
                const struct bt_integer_range_set *range_set,
-               enum bt_field_class_type expected_type)
+               enum bt_field_class_type expected_type,
+               const char *api_func)
 {
        int status;
        struct bt_field_class_variant_with_selector_field *var_fc = (void *) fc;
        struct bt_field_class_variant_with_selector_field_option *opt = NULL;
        bool has_overlap;
 
-       BT_ASSERT_PRE_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_NAME_NON_NULL(name);
-       BT_ASSERT_PRE_NON_NULL(option_fc, "Option field class");
-       BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL(range_set);
-       BT_ASSERT_PRE_FC_HAS_TYPE(fc, expected_type, "Field class");
-       BT_ASSERT_PRE(range_set->ranges->len > 0,
-               "Integer range set is empty: %!+R", range_set);
+       BT_ASSERT(fc);
+       BT_ASSERT_PRE_NAME_NON_NULL_FROM_FUNC(api_func, name);
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(api_func, "option-field-class",
+               option_fc, "Option field class");
+       BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL_FROM_FUNC(api_func, range_set);
+       BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY_FROM_FUNC(api_func, range_set);
        status = ranges_overlap(var_fc->common.common.named_fcs, range_set,
                expected_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
                &has_overlap);
@@ -1680,7 +1707,8 @@ int append_option_to_variant_with_selector_field_field_class(
                goto end;
        }
 
-       BT_ASSERT_PRE(!has_overlap,
+       BT_ASSERT_PRE_FROM_FUNC(api_func, "ranges-do-not-overlap",
+               !has_overlap,
                "Integer range set's ranges and existing ranges have an overlap: "
                "%!+R", range_set);
        opt = create_variant_with_selector_field_option(name, option_fc, range_set);
@@ -1691,7 +1719,7 @@ int append_option_to_variant_with_selector_field_field_class(
        }
 
        status = append_named_field_class_to_container_field_class((void *) fc,
-               &opt->common);
+               &opt->common, __func__, VAR_FC_OPT_NAME_IS_UNIQUE_ID);
        if (status == BT_FUNC_STATUS_OK) {
                /* Moved to the container */
                opt = NULL;
@@ -1712,10 +1740,15 @@ bt_field_class_variant_with_selector_field_integer_unsigned_append_option(
                const struct bt_integer_range_set_unsigned *range_set)
 {
        BT_ASSERT_PRE_NO_ERROR();
-
+       BT_ASSERT_PRE_FC_NON_NULL(fc);
+       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+               "variant-field-class-with-unsigned-integer-selector-field",
+               BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
+               "Field class");
        return append_option_to_variant_with_selector_field_field_class(fc,
                name, option_fc, (const void *) range_set,
-               BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD);
+               BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
+               __func__);
 }
 
 enum bt_field_class_variant_with_selector_field_integer_append_option_status
@@ -1725,10 +1758,15 @@ bt_field_class_variant_with_selector_field_integer_signed_append_option(
                const struct bt_integer_range_set_signed *range_set)
 {
        BT_ASSERT_PRE_NO_ERROR();
-
+       BT_ASSERT_PRE_FC_NON_NULL(fc);
+       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+               "variant-field-class-with-signed-integer-selector-field",
+               BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
+               "Field class");
        return append_option_to_variant_with_selector_field_field_class(fc,
                name, option_fc, (const void *) range_set,
-               BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD);
+               BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
+               __func__);
 }
 
 uint64_t bt_field_class_variant_get_option_count(const struct bt_field_class *fc)
@@ -1736,7 +1774,7 @@ uint64_t bt_field_class_variant_get_option_count(const struct bt_field_class *fc
        const struct bt_field_class_variant *var_fc = (const void *) fc;
 
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_IS_VARIANT(fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_IS_VARIANT("field-class", fc, "Field class");
        return (uint64_t) var_fc->common.named_fcs->len;
 }
 
@@ -1745,10 +1783,10 @@ bt_field_class_variant_borrow_option_by_name_const(
                const struct bt_field_class *fc, const char *name)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_IS_VARIANT(fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_IS_VARIANT("field-class", fc, "Field class");
        return (const void *)
                borrow_named_field_class_from_container_field_class_by_name(
-                       (void *) fc, name);
+                       (void *) fc, name, __func__);
 }
 
 const struct bt_field_class_variant_option *
@@ -1756,10 +1794,10 @@ bt_field_class_variant_borrow_option_by_index_const(
                const struct bt_field_class *fc, uint64_t index)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_IS_VARIANT(fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_IS_VARIANT("field-class", fc, "Field class");
        return (const void *)
                borrow_named_field_class_from_container_field_class_at_index(
-                       (void *) fc, index);
+                       (void *) fc, index, __func__);
 }
 
 struct bt_field_class_variant_option *
@@ -1767,10 +1805,10 @@ bt_field_class_variant_borrow_option_by_name(
                struct bt_field_class *fc, const char *name)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_IS_VARIANT(fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_IS_VARIANT("field-class", fc, "Field class");
        return (void *)
                borrow_named_field_class_from_container_field_class_by_name(
-                       (void *) fc, name);
+                       (void *) fc, name, __func__);
 }
 
 struct bt_field_class_variant_option *
@@ -1778,10 +1816,10 @@ bt_field_class_variant_borrow_option_by_index(
                struct bt_field_class *fc, uint64_t index)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_IS_VARIANT(fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_IS_VARIANT("field-class", fc, "Field class");
        return (void *)
                borrow_named_field_class_from_container_field_class_at_index(
-                       (void *) fc, index);
+                       (void *) fc, index, __func__);
 }
 
 const struct bt_field_class_variant_with_selector_field_integer_unsigned_option *
@@ -1789,12 +1827,13 @@ bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_nam
                const struct bt_field_class *fc, const char *name)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc,
+       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+               "variant-field-class-with-unsigned-integer-selector-field",
                BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
                "Field class");
        return (const void *)
                borrow_named_field_class_from_container_field_class_by_name(
-                       (void *) fc, name);
+                       (void *) fc, name, __func__);
 }
 
 const struct bt_field_class_variant_with_selector_field_integer_unsigned_option *
@@ -1802,12 +1841,13 @@ bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_ind
                const struct bt_field_class *fc, uint64_t index)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc,
+       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+               "variant-field-class-with-unsigned-integer-selector-field",
                BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
                "Field class");
        return (const void *)
                borrow_named_field_class_from_container_field_class_at_index(
-                       (void *) fc, index);
+                       (void *) fc, index, __func__);
 }
 
 const struct bt_field_class_variant_with_selector_field_integer_signed_option *
@@ -1815,12 +1855,13 @@ bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_
                const struct bt_field_class *fc, const char *name)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc,
+       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+               "variant-field-class-with-signed-integer-selector-field",
                BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
                "Field class");
        return (const void *)
                borrow_named_field_class_from_container_field_class_by_name(
-                       (void *) fc, name);
+                       (void *) fc, name, __func__);
 }
 
 const struct bt_field_class_variant_with_selector_field_integer_signed_option *
@@ -1828,12 +1869,13 @@ bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index
                const struct bt_field_class *fc, uint64_t index)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc,
+       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+               "variant-field-class-with-signed-integer-selector-field",
                BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
                "Field class");
        return (const void *)
                borrow_named_field_class_from_container_field_class_at_index(
-                       (void *) fc, index);
+                       (void *) fc, index, __func__);
 }
 
 const char *bt_field_class_variant_option_get_name(
@@ -1895,7 +1937,8 @@ bt_field_class_variant_with_selector_field_borrow_selector_field_path_const(
                (const void *) fc;
 
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_IS_VARIANT_WITH_SEL(fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_IS_VARIANT_WITH_SEL("field-class", fc,
+               "Field class");
        return var_fc->selector_field_path;
 }
 
@@ -1946,7 +1989,8 @@ bt_field_class_array_static_create(bt_trace_class *trace_class,
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_TC_NON_NULL(trace_class);
-       BT_ASSERT_PRE_NON_NULL(element_fc, "Element field class");
+       BT_ASSERT_PRE_NON_NULL("element-field-class", element_fc,
+               "Element field class");
        BT_LOGD_STR("Creating default static array field class object.");
        array_fc = g_new0(struct bt_field_class_array_static, 1);
        if (!array_fc) {
@@ -1979,7 +2023,7 @@ bt_field_class_array_borrow_element_field_class_const(
        const struct bt_field_class_array *array_fc = (const void *) fc;
 
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_IS_ARRAY(fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_IS_ARRAY("field-class", fc, "Field class");
        return array_fc->element_fc;
 }
 
@@ -1989,7 +2033,7 @@ 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_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_IS_ARRAY(fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_IS_ARRAY("field-class", fc, "Field class");
        return array_fc->element_fc;
 }
 
@@ -1998,7 +2042,8 @@ uint64_t bt_field_class_array_static_get_length(const struct bt_field_class *fc)
        const struct bt_field_class_array_static *array_fc = (const void *) fc;
 
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc, BT_FIELD_CLASS_TYPE_STATIC_ARRAY,
+       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+               "static-array-field-class", BT_FIELD_CLASS_TYPE_STATIC_ARRAY,
                "Field class");
        return (uint64_t) array_fc->length;
 }
@@ -2027,7 +2072,8 @@ struct bt_field_class *bt_field_class_array_dynamic_create(
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_TC_NON_NULL(trace_class);
-       BT_ASSERT_PRE_NON_NULL(element_fc, "Element field class");
+       BT_ASSERT_PRE_NON_NULL("element-field-class", element_fc,
+               "Element field class");
        BT_LOGD_STR("Creating default dynamic array field class object.");
        array_fc = g_new0(struct bt_field_class_array_dynamic, 1);
        if (!array_fc) {
@@ -2045,8 +2091,8 @@ struct bt_field_class *bt_field_class_array_dynamic_create(
        }
 
        if (length_fc) {
-               BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(length_fc,
-                       "Length field class");
+               BT_ASSERT_PRE_FC_IS_UNSIGNED_INT("length-field-class",
+                       length_fc, "Length field class");
                array_fc->length_fc = length_fc;
                bt_object_get_ref_no_null_check(array_fc->length_fc);
                bt_field_class_freeze(length_fc);
@@ -2070,7 +2116,8 @@ bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_DEV_FC_HAS_TYPE(fc,
+       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+               "dynamic-array-field-class-with-length-field",
                BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD,
                "Field class");
        return seq_fc->length_field_path;
@@ -2158,8 +2205,9 @@ void bt_field_class_make_part_of_trace_class(const struct bt_field_class *c_fc)
        struct bt_field_class *fc = (void *) c_fc;
 
        BT_ASSERT(fc);
-       BT_ASSERT_PRE(!fc->part_of_trace_class,
-               "Field class is already part of a trace: %!+F", fc);
+       BT_ASSERT_PRE("field-class-is-not-part-of-trace-class",
+               !fc->part_of_trace_class,
+               "Field class is already part of a trace class: %!+F", fc);
        fc->part_of_trace_class = true;
 
        if (fc->type == BT_FIELD_CLASS_TYPE_STRUCTURE ||
@@ -2204,9 +2252,8 @@ void bt_field_class_set_user_attributes(
 {
        BT_ASSERT_PRE_FC_NON_NULL(fc);
        BT_ASSERT_PRE_USER_ATTRS_NON_NULL(user_attributes);
-       BT_ASSERT_PRE(user_attributes->type == BT_VALUE_TYPE_MAP,
-               "User attributes object is not a map value object.");
-       BT_ASSERT_PRE_DEV_FC_HOT(fc, "Field class");
+       BT_ASSERT_PRE_USER_ATTRS_IS_MAP(user_attributes);
+       BT_ASSERT_PRE_DEV_FC_HOT(fc);
        bt_object_put_ref_no_null_check(fc->user_attributes);
        fc->user_attributes = (void *) user_attributes;
        bt_object_get_ref_no_null_check(fc->user_attributes);
@@ -2220,15 +2267,12 @@ const struct bt_value *bt_named_field_class_borrow_user_attributes_const(
 }
 
 static
-void bt_named_field_class_set_user_attributes(
+void set_named_field_class_user_attributes(
                struct bt_named_field_class *named_fc,
-               const struct bt_value *user_attributes)
+               const struct bt_value *user_attributes, const char *api_func)
 {
-       BT_ASSERT_PRE_USER_ATTRS_NON_NULL(user_attributes);
-       BT_ASSERT_PRE_USER_ATTRS_IS_MAP(user_attributes);
-       BT_ASSERT_PRE_DEV_HOT(named_fc,
-               "Structure field class member or variant field class option",
-               ".");
+       BT_ASSERT_PRE_USER_ATTRS_NON_NULL_FROM_FUNC(api_func, user_attributes);
+       BT_ASSERT_PRE_USER_ATTRS_NON_NULL_FROM_FUNC(api_func, user_attributes);
        bt_object_put_ref_no_null_check(named_fc->user_attributes);
        named_fc->user_attributes = (void *) user_attributes;
        bt_object_get_ref_no_null_check(named_fc->user_attributes);
@@ -2257,8 +2301,11 @@ void bt_field_class_structure_member_set_user_attributes(
                const struct bt_value *user_attributes)
 {
        BT_ASSERT_PRE_STRUCT_FC_MEMBER_NON_NULL(member);
-       bt_named_field_class_set_user_attributes((void *) member,
-               user_attributes);
+       BT_ASSERT_PRE_DEV_HOT("structure-field-class-member",
+               (struct bt_named_field_class *) member,
+               "Structure field class member", ".");
+       set_named_field_class_user_attributes((void *) member,
+               user_attributes, __func__);
 }
 
 const struct bt_value *bt_field_class_variant_option_borrow_user_attributes_const(
@@ -2282,8 +2329,11 @@ void bt_field_class_variant_option_set_user_attributes(
                const struct bt_value *user_attributes)
 {
        BT_ASSERT_PRE_VAR_FC_OPT_NON_NULL(option);
-       bt_named_field_class_set_user_attributes((void *) option,
-               user_attributes);
+       BT_ASSERT_PRE_DEV_HOT("variant-field-class-option",
+               (struct bt_named_field_class *) option,
+               "Variant field class option", ".");
+       set_named_field_class_user_attributes((void *) option,
+               user_attributes, __func__);
 }
 
 void bt_field_class_get_ref(const struct bt_field_class *field_class)
index 60e0aca992f945481715c04db88f146b5af82cbf..f7d7551b0e052f34d5ce8ca408d8853d031eb0fa 100644 (file)
@@ -87,15 +87,18 @@ const struct bt_field_path_item *bt_field_path_borrow_item_by_index_const(
 enum bt_field_path_item_type bt_field_path_item_get_type(
                const struct bt_field_path_item *field_path_item)
 {
-       BT_ASSERT_PRE_DEV_NON_NULL(field_path_item, "Field path item");
+       BT_ASSERT_PRE_DEV_NON_NULL("field-path-item", field_path_item,
+               "Field path item");
        return field_path_item->type;
 }
 
 uint64_t bt_field_path_item_index_get_index(
                const struct bt_field_path_item *field_path_item)
 {
-       BT_ASSERT_PRE_DEV_NON_NULL(field_path_item, "Field path item");
-       BT_ASSERT_PRE_DEV(field_path_item->type == BT_FIELD_PATH_ITEM_TYPE_INDEX,
+       BT_ASSERT_PRE_DEV_NON_NULL("field-path-item", field_path_item,
+               "Field path item");
+       BT_ASSERT_PRE_DEV("is-index-field-path-item",
+               field_path_item->type == BT_FIELD_PATH_ITEM_TYPE_INDEX,
                "Field path item is not an index field path item: "
                "addr=%p, type=%s", field_path_item,
                bt_field_path_item_type_string(field_path_item->type));
index b1d8486761c10fa690a9724ea97e6e07cd74f128..cbba4a5345d5e7a1b2b9bf8f0437df9f0d699e1f 100644 (file)
@@ -23,8 +23,8 @@
 #include "lib/func-status.h"
 
 #define BT_ASSERT_PRE_DEV_FIELD_HOT(_field)                            \
-       BT_ASSERT_PRE_DEV_HOT((const struct bt_field *) (_field),       \
-               "Field", ": %!+f", (_field))
+       BT_ASSERT_PRE_DEV_HOT("field",                                  \
+               (const struct bt_field *) (_field), "Field", ": %!+f", (_field))
 
 static
 void reset_single_field(struct bt_field *field);
@@ -625,9 +625,9 @@ bt_bool bt_field_bool_get_value(const struct bt_field *field)
        const struct bt_field_bool *bool_field = (const void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_BOOL,
-               "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET("field", field);
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field,
+               "boolean-field", BT_FIELD_CLASS_TYPE_BOOL, "Field");
        return (bt_bool) bool_field->value;
 }
 
@@ -636,8 +636,8 @@ void bt_field_bool_set_value(struct bt_field *field, bt_bool value)
        struct bt_field_bool *bool_field = (void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_BOOL,
-               "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field,
+               "boolean-field", BT_FIELD_CLASS_TYPE_BOOL, "Field");
        BT_ASSERT_PRE_DEV_FIELD_HOT(field);
        bool_field->value = (bool) value;
        bt_field_set_single(field, true);
@@ -648,9 +648,9 @@ uint64_t bt_field_bit_array_get_value_as_integer(const struct bt_field *field)
        const struct bt_field_bit_array *ba_field = (const void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
-               BT_FIELD_CLASS_TYPE_BIT_ARRAY, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET("field", field);
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field,
+               "bit-array-field", BT_FIELD_CLASS_TYPE_BIT_ARRAY, "Field");
        return ba_field->value_as_int;
 }
 
@@ -661,8 +661,8 @@ void bt_field_bit_array_set_value_as_integer(struct bt_field *field,
        struct bt_field_class_bit_array *ba_fc;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
-               BT_FIELD_CLASS_TYPE_BIT_ARRAY, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field,
+               "bit-array-field", BT_FIELD_CLASS_TYPE_BIT_ARRAY, "Field");
        BT_ASSERT_PRE_DEV_FIELD_HOT(field);
        ba_fc = (void *) field->class;
        ba_field->value_as_int = value;
@@ -680,8 +680,8 @@ int64_t bt_field_integer_signed_get_value(const struct bt_field *field)
        const struct bt_field_integer *int_field = (const void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET("field", field);
+       BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT("field", field, "Field");
        return int_field->value.i;
 }
 
@@ -690,10 +690,12 @@ void bt_field_integer_signed_set_value(struct bt_field *field, int64_t value)
        struct bt_field_integer *int_field = (void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT("field", field, "Field");
        BT_ASSERT_PRE_DEV_FIELD_HOT(field);
-       BT_ASSERT_PRE_DEV(bt_util_value_is_in_range_signed(
-               ((struct bt_field_class_integer *) field->class)->range, value),
+       BT_ASSERT_PRE_DEV("valid-value-for-field-class-field-value-range",
+               bt_util_value_is_in_range_signed(
+                       ((struct bt_field_class_integer *) field->class)->range,
+                       value),
                "Value is out of bounds: value=%" PRId64 ", %![field-]+f, "
                "%![fc-]+F", value, field, field->class);
        int_field->value.i = value;
@@ -705,8 +707,8 @@ uint64_t bt_field_integer_unsigned_get_value(const struct bt_field *field)
        const struct bt_field_integer *int_field = (const void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET("field", field);
+       BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT("field", field, "Field");
        return int_field->value.u;
 }
 
@@ -715,10 +717,12 @@ void bt_field_integer_unsigned_set_value(struct bt_field *field, uint64_t value)
        struct bt_field_integer *int_field = (void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT("field", field, "Field");
        BT_ASSERT_PRE_DEV_FIELD_HOT(field);
-       BT_ASSERT_PRE_DEV(bt_util_value_is_in_range_unsigned(
-               ((struct bt_field_class_integer *) field->class)->range, value),
+       BT_ASSERT_PRE_DEV("valid-value-for-field-class-field-value-range",
+               bt_util_value_is_in_range_unsigned(
+                       ((struct bt_field_class_integer *) field->class)->range,
+                       value),
                "Value is out of bounds: value=%" PRIu64 ", %![field-]+f, "
                "%![fc-]+F", value, field, field->class);
        int_field->value.u = value;
@@ -730,8 +734,9 @@ float bt_field_real_single_precision_get_value(const struct bt_field *field)
        const struct bt_field_real *real_field = (const void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET("field", field);
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field,
+               "single-precision-real-field",
                BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL, "Field");
        return (float) real_field->value;
 }
@@ -741,10 +746,10 @@ double bt_field_real_double_precision_get_value(const struct bt_field *field)
        const struct bt_field_real *real_field = (const void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET("field", field);
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field,
+               "double-precision-real-field",
                BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL, "Field");
-
        return real_field->value;
 }
 
@@ -754,7 +759,8 @@ void bt_field_real_single_precision_set_value(struct bt_field *field,
        struct bt_field_real *real_field = (void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field,
+               "single-precision-real-field",
                BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL, "Field");
        BT_ASSERT_PRE_DEV_FIELD_HOT(field);
 
@@ -768,7 +774,8 @@ void bt_field_real_double_precision_set_value(struct bt_field *field,
        struct bt_field_real *real_field = (void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field,
+               "double-precision-real-field",
                BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL, "Field");
        BT_ASSERT_PRE_DEV_FIELD_HOT(field);
 
@@ -786,10 +793,12 @@ bt_field_enumeration_unsigned_get_mapping_labels(
 
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Label array (output)");
-       BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Count (output)");
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
+       BT_ASSERT_PRE_DEV_NON_NULL("label-array-output", label_array,
+               "Label array (output)");
+       BT_ASSERT_PRE_DEV_NON_NULL("count-output", count, "Count (output)");
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET("field", field);
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field,
+               "unsigned-enumeration-field",
                BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, "Field");
        return (int)
                bt_field_class_enumeration_unsigned_get_mapping_labels_for_value(
@@ -806,10 +815,12 @@ bt_field_enumeration_signed_get_mapping_labels(
 
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Label array (output)");
-       BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Count (output)");
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
+       BT_ASSERT_PRE_DEV_NON_NULL("label-array-output", label_array,
+               "Label array (output)");
+       BT_ASSERT_PRE_DEV_NON_NULL("count-output", count, "Count (output)");
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET("field", field);
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field,
+               "signed-enumeration-field",
                BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, "Field");
        return (int)
                bt_field_class_enumeration_signed_get_mapping_labels_for_value(
@@ -821,9 +832,9 @@ const char *bt_field_string_get_value(const struct bt_field *field)
        const struct bt_field_string *string_field = (const void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_STRING,
-               "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET("field", field);
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field, "string-field",
+               BT_FIELD_CLASS_TYPE_STRING, "Field");
        return (const char *) string_field->buf->data;
 }
 
@@ -832,9 +843,9 @@ uint64_t bt_field_string_get_length(const struct bt_field *field)
        const struct bt_field_string *string_field = (const void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_STRING,
-               "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET("field", field);
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field, "string-field",
+               BT_FIELD_CLASS_TYPE_STRING, "Field");
        return string_field->length;
 }
 
@@ -853,43 +864,41 @@ enum bt_field_string_set_value_status bt_field_string_set_value(
 {
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_NON_NULL(value, "Value");
+       BT_ASSERT_PRE_DEV_NON_NULL("value", value, "Value");
        BT_ASSERT_PRE_DEV_FIELD_HOT(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_STRING,
-               "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field, "string-field",
+               BT_FIELD_CLASS_TYPE_STRING, "Field");
        clear_string_field(field);
        return (int) bt_field_string_append_with_length(field, value,
                (uint64_t) strlen(value));
 }
 
-enum bt_field_string_append_status bt_field_string_append(
-               struct bt_field *field, const char *value)
-{
-       BT_ASSERT_PRE_DEV_NO_ERROR();
-
-       return bt_field_string_append_with_length(field,
-               value, (uint64_t) strlen(value));
-}
-
-enum bt_field_string_append_status bt_field_string_append_with_length(
+#define BT_ASSERT_PRE_DEV_FOR_APPEND_TO_STRING_FIELD_WITH_LENGTH(_field, _value, _length) \
+       do {                                                            \
+               BT_ASSERT_PRE_DEV_NO_ERROR();                           \
+               BT_ASSERT_PRE_DEV_FIELD_NON_NULL(_field);               \
+               BT_ASSERT_PRE_DEV_NON_NULL("value", (_value), "Value"); \
+               BT_ASSERT_PRE_DEV_FIELD_HOT(_field);                    \
+               BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field",         \
+                       (_field), "string-field",                       \
+                       BT_FIELD_CLASS_TYPE_STRING, "Field");           \
+               BT_ASSERT_PRE_DEV("value-has-no-null-byte",             \
+                       !memchr((_value), '\0', (_length)),             \
+                       "String value to append contains a null character: " \
+                       "partial-value=\"%.32s\", length=%" PRIu64,     \
+                       (_value), (_length));                                   \
+       } while (0)
+
+static
+enum bt_field_string_append_status append_to_string_field_with_length(
                struct bt_field *field, const char *value, uint64_t length)
 {
        struct bt_field_string *string_field = (void *) field;
        char *data;
        uint64_t new_length;
 
-       BT_ASSERT_PRE_DEV_NO_ERROR();
-       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_NON_NULL(value, "Value");
-       BT_ASSERT_PRE_DEV_FIELD_HOT(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
-               BT_FIELD_CLASS_TYPE_STRING, "Field");
-
-       /* Make sure no null bytes are appended */
-       BT_ASSERT_PRE_DEV(!memchr(value, '\0', length),
-               "String value to append contains a null character: "
-               "partial-value=\"%.32s\", length=%" PRIu64, value, length);
-
+       BT_ASSERT_DBG(field);
+       BT_ASSERT_DBG(value);
        new_length = length + string_field->length;
 
        if (G_UNLIKELY(new_length + 1 > string_field->buf->len)) {
@@ -904,11 +913,29 @@ enum bt_field_string_append_status bt_field_string_append_with_length(
        return BT_FUNC_STATUS_OK;
 }
 
+enum bt_field_string_append_status bt_field_string_append_with_length(
+               struct bt_field *field, const char *value, uint64_t length)
+{
+       BT_ASSERT_PRE_DEV_FOR_APPEND_TO_STRING_FIELD_WITH_LENGTH(field, value,
+               length);
+       return append_to_string_field_with_length(field, value, length);
+}
+
+enum bt_field_string_append_status bt_field_string_append(
+               struct bt_field *field, const char *value)
+{
+       uint64_t length = (uint64_t) strlen(value);
+
+       BT_ASSERT_PRE_DEV_FOR_APPEND_TO_STRING_FIELD_WITH_LENGTH(field, value,
+               length);
+       return append_to_string_field_with_length(field, value, length);
+}
+
 void bt_field_string_clear(struct bt_field *field)
 {
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_HOT(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field, "string-field",
                BT_FIELD_CLASS_TYPE_STRING, "Field");
        clear_string_field(field);
 }
@@ -918,7 +945,7 @@ uint64_t bt_field_array_get_length(const struct bt_field *field)
        const struct bt_field_array *array_field = (const void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY("field", field, "Field");
        return array_field->length;
 }
 
@@ -930,7 +957,7 @@ enum bt_field_array_dynamic_set_length_status bt_field_array_dynamic_set_length(
 
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY("field", field, "Field");
        BT_ASSERT_PRE_DEV_FIELD_HOT(field);
 
        if (G_UNLIKELY(length > array_field->fields->len)) {
@@ -974,7 +1001,7 @@ struct bt_field *borrow_array_field_element_field_by_index(
        struct bt_field_array *array_field = (void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY("field", field, "Field");
        BT_ASSERT_PRE_DEV_VALID_INDEX(index, array_field->length);
        return array_field->fields->pdata[index];
 }
@@ -999,8 +1026,8 @@ struct bt_field *borrow_structure_field_member_field_by_index(
        struct bt_field_structure *struct_field = (void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
-               BT_FIELD_CLASS_TYPE_STRUCTURE, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field,
+               "structure-field", BT_FIELD_CLASS_TYPE_STRUCTURE, "Field");
        BT_ASSERT_PRE_DEV_VALID_INDEX(index, struct_field->fields->len);
        return struct_field->fields->pdata[index];
 }
@@ -1031,9 +1058,9 @@ struct bt_field *borrow_structure_field_member_field_by_name(
        gpointer index;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_NON_NULL(name, "Field name");
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
-               BT_FIELD_CLASS_TYPE_STRUCTURE, "Field");
+       BT_ASSERT_PRE_DEV_NON_NULL("member-name", name, "Member name");
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field,
+               "structure-field", BT_FIELD_CLASS_TYPE_STRUCTURE, "Field");
        struct_fc = (void *) field->class;
 
        if (!g_hash_table_lookup_extended(struct_fc->common.name_to_index, name,
@@ -1066,7 +1093,7 @@ void bt_field_option_set_has_field(struct bt_field *field, bt_bool has_field)
        struct bt_field_option *opt_field = (void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_OPTION("field", field, "Field");
        BT_ASSERT_PRE_DEV_FIELD_HOT(field);
 
        if (has_field) {
@@ -1081,7 +1108,7 @@ struct bt_field *bt_field_option_borrow_field(struct bt_field *field)
        struct bt_field_option *opt_field = (void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_OPTION("field", field, "Field");
        return opt_field->selected_field;
 }
 
@@ -1091,31 +1118,51 @@ const struct bt_field *bt_field_option_borrow_field_const(
        return (const void *) bt_field_option_borrow_field((void *) field);
 }
 
+#define BT_ASSERT_PRE_DEV_FOR_BORROW_VAR_FIELD_SEL_OPT_FIELD(_field)   \
+       do {                                                            \
+               struct bt_field_variant *_var_field = (void *) field;   \
+               BT_ASSERT_PRE_DEV_FIELD_NON_NULL(_field);               \
+               BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT("field", (_field),   \
+                       "Field");                                       \
+               BT_ASSERT_PRE_DEV("has-selected-field",                 \
+                       _var_field->selected_field,                     \
+                       "Variant field has no selected field: %!+f",    \
+                       field);                                         \
+       } while (0)
+
 static inline
 struct bt_field *borrow_variant_field_selected_option_field(
                struct bt_field *field)
 {
        struct bt_field_variant *var_field = (void *) field;
 
-       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field");
-       BT_ASSERT_PRE_DEV(var_field->selected_field,
-               "Variant field has no selected field: %!+f", field);
+       BT_ASSERT_DBG(field);
        return var_field->selected_field;
 }
 
 struct bt_field *bt_field_variant_borrow_selected_option_field(
                struct bt_field *field)
 {
+       BT_ASSERT_PRE_DEV_FOR_BORROW_VAR_FIELD_SEL_OPT_FIELD(field);
        return borrow_variant_field_selected_option_field(field);
 }
 
 const struct bt_field *bt_field_variant_borrow_selected_option_field_const(
                const struct bt_field *field)
 {
+       BT_ASSERT_PRE_DEV_FOR_BORROW_VAR_FIELD_SEL_OPT_FIELD(field);
        return borrow_variant_field_selected_option_field((void *) field);
 }
 
+#define BT_ASSERT_PRE_DEV_FOR_BORROW_VAR_FIELD_SEL_CLASS_OPT(_field)   \
+       do {                                                            \
+               struct bt_field_variant *_var_field = (void *) field;   \
+               BT_ASSERT_PRE_DEV("has-selected-field",                 \
+                       _var_field->selected_field,                     \
+                       "Variant field has no selected field: %!+f",    \
+                       (_field));                                      \
+       } while (0)
+
 static
 const struct bt_field_class_variant_option *
 borrow_variant_field_selected_class_option(const struct bt_field *field)
@@ -1124,8 +1171,6 @@ borrow_variant_field_selected_class_option(const struct bt_field *field)
        const struct bt_field_variant *var_field = (const void *) field;
 
        BT_ASSERT_DBG(field);
-       BT_ASSERT_PRE_DEV(var_field->selected_field,
-               "Variant field has no selected field: %!+f", field);
        container_fc = (const void *) field->class;
        return container_fc->named_fcs->pdata[var_field->selected_index];
 }
@@ -1135,7 +1180,8 @@ bt_field_variant_borrow_selected_option_class_const(
                const struct bt_field *field)
 {
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT("field", field, "Field");
+       BT_ASSERT_PRE_DEV_FOR_BORROW_VAR_FIELD_SEL_CLASS_OPT(field);
        return borrow_variant_field_selected_class_option(field);
 }
 
@@ -1144,8 +1190,11 @@ bt_field_variant_with_selector_field_integer_unsigned_borrow_selected_option_cla
                const struct bt_field *field)
 {
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
-               BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field,
+               "variant-field-with-unsigned-selector-field",
+               BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
+               "Field");
+       BT_ASSERT_PRE_DEV_FOR_BORROW_VAR_FIELD_SEL_CLASS_OPT(field);
        return (const void *) borrow_variant_field_selected_class_option(field);
 }
 
@@ -1154,8 +1203,11 @@ bt_field_variant_with_selector_field_integer_signed_borrow_selected_option_class
                const struct bt_field *field)
 {
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
-               BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field,
+               "variant-field-with-signed-selector-field",
+               BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
+               "Field");
+       BT_ASSERT_PRE_DEV_FOR_BORROW_VAR_FIELD_SEL_CLASS_OPT(field);
        return (const void *) borrow_variant_field_selected_class_option(field);
 }
 
@@ -1167,7 +1219,7 @@ bt_field_variant_select_option_by_index(
 
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT("field", field, "Field");
        BT_ASSERT_PRE_DEV_FIELD_HOT(field);
        BT_ASSERT_PRE_DEV_VALID_INDEX(index, var_field->fields->len);
        var_field->selected_field = var_field->fields->pdata[index];
@@ -1181,8 +1233,8 @@ uint64_t bt_field_variant_get_selected_option_index(
        const struct bt_field_variant *var_field = (const void *) field;
 
        BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
-       BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field");
-       BT_ASSERT_PRE_DEV(var_field->selected_field,
+       BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT("field", field, "Field");
+       BT_ASSERT_PRE_DEV("has-selected-field", var_field->selected_field,
                "Variant field has no selected field: %!+f", field);
        return var_field->selected_index;
 }
index 18ed8fede87d3552217424b8e42af893c14b7370..96cbae019e54d11dda7dd80c427d560b7538fa49 100644 (file)
@@ -204,7 +204,8 @@ struct bt_packet *bt_packet_create(const struct bt_stream *c_stream)
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_STREAM_NON_NULL(stream);
-       BT_ASSERT_PRE(stream->class->supports_packets,
+       BT_ASSERT_PRE("stream-class-supports-packets",
+               stream->class->supports_packets,
                "Stream class does not support packets: %![sc-]+S",
                stream->class);
        packet = bt_object_pool_create_object(&stream->packet_pool);
index ac8aed7e7153c72d330fbdee1084de0836b867f4..51719387e97624cc3d0af638254653d87243b5be 100644 (file)
@@ -496,9 +496,11 @@ end:
 static
 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)
+               struct bt_resolve_field_path_context *ctx,
+               const char *api_func)
 {
-       BT_ASSERT_PRE_DEV(field_path_is_valid(src_fc, tgt_fc, ctx),
+       BT_ASSERT_PRE_DEV_FROM_FUNC(api_func, "valid-field-class",
+               field_path_is_valid(src_fc, tgt_fc, ctx),
                "Invalid target field class: %![req-fc-]+F, %![tgt-fc-]+F",
                src_fc, tgt_fc);
        return find_field_class_in_ctx(tgt_fc, ctx);
@@ -506,7 +508,8 @@ struct bt_field_path *resolve_field_path(struct bt_field_class *src_fc,
 
 BT_HIDDEN
 int bt_resolve_field_paths(struct bt_field_class *fc,
-               struct bt_resolve_field_path_context *ctx)
+               struct bt_resolve_field_path_context *ctx,
+               const char *api_func)
 {
        int ret = 0;
 
@@ -520,7 +523,7 @@ int bt_resolve_field_paths(struct bt_field_class *fc,
                BT_ASSERT(opt_fc->selector_fc);
                BT_ASSERT(!opt_fc->selector_field_path);
                opt_fc->selector_field_path = resolve_field_path(
-                       fc, opt_fc->selector_fc, ctx);
+                       fc, opt_fc->selector_fc, ctx, __func__);
                if (!opt_fc->selector_field_path) {
                        ret = -1;
                        goto end;
@@ -531,7 +534,7 @@ int bt_resolve_field_paths(struct bt_field_class *fc,
                BT_ASSERT(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);
+                       fc, dyn_array_fc->length_fc, ctx, __func__);
                if (!dyn_array_fc->length_field_path) {
                        ret = -1;
                        goto end;
@@ -545,7 +548,8 @@ int bt_resolve_field_paths(struct bt_field_class *fc,
                        BT_ASSERT(!var_fc->selector_field_path);
                        var_fc->selector_field_path =
                                resolve_field_path(fc,
-                                       (void *) var_fc->selector_fc, ctx);
+                                       (void *) var_fc->selector_fc, ctx,
+                                       __func__);
                        if (!var_fc->selector_field_path) {
                                ret = -1;
                                goto end;
@@ -557,7 +561,7 @@ int bt_resolve_field_paths(struct bt_field_class *fc,
        if (bt_field_class_type_is(fc->type, BT_FIELD_CLASS_TYPE_OPTION)) {
                struct bt_field_class_option *opt_fc = (void *) fc;
 
-               ret = bt_resolve_field_paths(opt_fc->content_fc, ctx);
+               ret = bt_resolve_field_paths(opt_fc->content_fc, ctx, api_func);
        } else if (fc->type == BT_FIELD_CLASS_TYPE_STRUCTURE ||
                        bt_field_class_type_is(fc->type,
                                BT_FIELD_CLASS_TYPE_VARIANT)) {
@@ -569,7 +573,8 @@ int bt_resolve_field_paths(struct bt_field_class *fc,
                        struct bt_named_field_class *named_fc =
                                container_fc->named_fcs->pdata[i];
 
-                       ret = bt_resolve_field_paths(named_fc->fc, ctx);
+                       ret = bt_resolve_field_paths(named_fc->fc, ctx,
+                               api_func);
                        if (ret) {
                                goto end;
                        }
@@ -578,7 +583,8 @@ int bt_resolve_field_paths(struct bt_field_class *fc,
                        BT_FIELD_CLASS_TYPE_ARRAY)) {
                struct bt_field_class_array *array_fc = (void *) fc;
 
-               ret = bt_resolve_field_paths(array_fc->element_fc, ctx);
+               ret = bt_resolve_field_paths(array_fc->element_fc, ctx,
+                       api_func);
        }
 
 end:
index 408b50752d5bc36e1055163bc1df585ca32ab82d..4cd436a326ced1dda982b897b23811ecb912ee1a 100644 (file)
@@ -25,6 +25,7 @@ struct bt_resolve_field_path_context {
 
 BT_HIDDEN
 int bt_resolve_field_paths(struct bt_field_class *field_class,
-               struct bt_resolve_field_path_context *ctx);
+               struct bt_resolve_field_path_context *ctx,
+               const char *api_func);
 
 #endif /* BABELTRACE_TRACE_IR_RESOLVE_FIELD_PATH_INTERNAL */
index 2fe47615ad340e54c1b2def294359efd4f0553eb..73d96f0e8a67e9b4284072caaea7080abfbc4d4f 100644 (file)
@@ -32,7 +32,8 @@
 #include "lib/func-status.h"
 
 #define BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(_sc)                                \
-       BT_ASSERT_PRE_DEV_HOT((_sc), "Stream class", ": %!+S", (_sc))
+       BT_ASSERT_PRE_DEV_HOT("stream-class", (_sc), "Stream class",    \
+               ": %!+S", (_sc))
 
 static
 void destroy_stream_class(struct bt_object *obj)
@@ -99,7 +100,8 @@ struct bt_stream_class *create_stream_class_with_id(
        int ret;
 
        BT_ASSERT(tc);
-       BT_ASSERT_PRE(stream_class_id_is_unique(tc, id),
+       BT_ASSERT_PRE("stream-class-id-is-unique",
+               stream_class_id_is_unique(tc, id),
                "Duplicate stream class ID: %![tc-]+T, id=%" PRIu64, tc, id);
        BT_LIB_LOGD("Creating stream class object: %![tc-]+T, id=%" PRIu64,
                tc, id);
@@ -163,7 +165,8 @@ struct bt_stream_class *bt_stream_class_create(struct bt_trace_class *tc)
 {
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_TC_NON_NULL(tc);
-       BT_ASSERT_PRE(tc->assigns_automatic_stream_class_id,
+       BT_ASSERT_PRE("trace-class-automatically-assigns-stream-class-ids",
+               tc->assigns_automatic_stream_class_id,
                "Trace class does not automatically assigns stream class IDs: "
                "%![sc-]+T", tc);
        return create_stream_class_with_id(tc,
@@ -175,7 +178,9 @@ struct bt_stream_class *bt_stream_class_create_with_id(
 {
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_TC_NON_NULL(tc);
-       BT_ASSERT_PRE(!tc->assigns_automatic_stream_class_id,
+       BT_ASSERT_PRE(
+               "trace-class-does-not-automatically-assigns-stream-class-ids",
+               !tc->assigns_automatic_stream_class_id,
                "Trace class automatically assigns stream class IDs: "
                "%![sc-]+T", tc);
        return create_stream_class_with_id(tc, id);
@@ -304,13 +309,15 @@ bt_stream_class_set_packet_context_field_class(
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_SC_NON_NULL(stream_class);
-       BT_ASSERT_PRE(stream_class->supports_packets,
+       BT_ASSERT_PRE("supports-packets",
+               stream_class->supports_packets,
                "Stream class does not support packets: %![sc-]+S",
                stream_class);
        BT_ASSERT_PRE_FC_NON_NULL(field_class);
        BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
-       BT_ASSERT_PRE_FC_IS_STRUCT(field_class, "Packet context field class");
-       ret = bt_resolve_field_paths(field_class, &resolve_ctx);
+       BT_ASSERT_PRE_FC_IS_STRUCT("field-class", field_class,
+               "Packet context field class");
+       ret = bt_resolve_field_paths(field_class, &resolve_ctx, __func__);
        if (ret) {
                /*
                 * This is the only reason for which
@@ -366,10 +373,10 @@ bt_stream_class_set_event_common_context_field_class(
        BT_ASSERT_PRE_SC_NON_NULL(stream_class);
        BT_ASSERT_PRE_FC_NON_NULL(field_class);
        BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
-       BT_ASSERT_PRE_FC_IS_STRUCT(field_class,
+       BT_ASSERT_PRE_FC_IS_STRUCT("field-class", field_class,
                "Event common context field class");
        resolve_ctx.packet_context = stream_class->packet_context_fc;
-       ret = bt_resolve_field_paths(field_class, &resolve_ctx);
+       ret = bt_resolve_field_paths(field_class, &resolve_ctx, __func__);
        if (ret) {
                /*
                 * This is the only reason for which
@@ -468,12 +475,14 @@ void bt_stream_class_set_supports_discarded_events(
 {
        BT_ASSERT_PRE_SC_NON_NULL(stream_class);
        BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
-       BT_ASSERT_PRE(supports_discarded_events ||
-               !with_default_clock_snapshots,
+       BT_ASSERT_PRE("supports-discarded-events-for-default-clock-snapshots",
+               supports_discarded_events ||
+                       !with_default_clock_snapshots,
                "Discarded events cannot have default clock snapshots when "
                "not supported: %!+S", stream_class);
-       BT_ASSERT_PRE(!with_default_clock_snapshots ||
-               stream_class->default_clock_class,
+       BT_ASSERT_PRE("has-default-clock-class-for-default-clock-snapshots",
+               !with_default_clock_snapshots ||
+                       stream_class->default_clock_class,
                "Stream class has no default clock class: %!+S", stream_class);
        stream_class->supports_discarded_events =
                (bool) supports_discarded_events;
@@ -504,16 +513,19 @@ void bt_stream_class_set_supports_discarded_packets(
 {
        BT_ASSERT_PRE_SC_NON_NULL(stream_class);
        BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
-       BT_ASSERT_PRE(!supports_discarded_packets ||
-               stream_class->supports_packets,
+       BT_ASSERT_PRE("supports-packets-for-discarded-packets-support",
+               !supports_discarded_packets ||
+                       stream_class->supports_packets,
                "Stream class does not support packets: %!+S",
                stream_class);
-       BT_ASSERT_PRE(supports_discarded_packets ||
-               !with_default_clock_snapshots,
+       BT_ASSERT_PRE("supports-discarded-packets-for-default-clock-snapshots",
+               supports_discarded_packets ||
+                       !with_default_clock_snapshots,
                "Discarded packets cannot have default clock snapshots when "
                "not supported: %!+S", stream_class);
-       BT_ASSERT_PRE(!with_default_clock_snapshots ||
-               stream_class->default_clock_class,
+       BT_ASSERT_PRE("has-default-clock-class-for-default-clock-snapshots",
+               !with_default_clock_snapshots ||
+                       stream_class->default_clock_class,
                "Stream class has no default clock class: %!+S", stream_class);
        stream_class->supports_discarded_packets =
                (bool) supports_discarded_packets;
@@ -548,18 +560,21 @@ void bt_stream_class_set_supports_packets(
                with_end_default_clock_snapshot;
        BT_ASSERT_PRE_SC_NON_NULL(stream_class);
        BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
-       BT_ASSERT_PRE(supports_packets ||
-               !with_default_clock_snapshot,
+       BT_ASSERT_PRE("supports-packets-for-default-clock-snapshot",
+               supports_packets ||
+                       !with_default_clock_snapshot,
                "Packets cannot have default clock snapshots when "
                "not supported: %!+S", stream_class);
-       BT_ASSERT_PRE(!with_default_clock_snapshot ||
-               stream_class->default_clock_class,
+       BT_ASSERT_PRE("has-default-clock-class-for-default-clock-snapshot",
+               !with_default_clock_snapshot ||
+                       stream_class->default_clock_class,
                "Stream class has no default clock class: %!+S", stream_class);
-       BT_ASSERT_PRE(supports_packets || !stream_class->packet_context_fc,
+       BT_ASSERT_PRE("supports-packets-for-packet-context-field-class",
+               supports_packets || !stream_class->packet_context_fc,
                "Stream class already has a packet context field class: %!+S",
                stream_class);
-       BT_ASSERT_PRE(supports_packets ||
-               !stream_class->supports_discarded_packets,
+       BT_ASSERT_PRE("supports-packets-for-discarded-packets-support",
+               supports_packets || !stream_class->supports_discarded_packets,
                "Stream class already supports discarded packets: %!+S",
                stream_class);
        stream_class->supports_packets = (bool) supports_packets;
index fe36b89277e6103d0596294ff13b92e25a8f32b5..fcfe3d4b7ec58bdac76c0e38da9a6dfb5136832f 100644 (file)
@@ -28,7 +28,8 @@
 #include "lib/func-status.h"
 
 #define BT_ASSERT_PRE_DEV_STREAM_HOT(_stream)                          \
-       BT_ASSERT_PRE_DEV_HOT((_stream), "Stream", ": %!+s", (_stream))
+       BT_ASSERT_PRE_DEV_HOT("stream", (_stream), "Stream",            \
+               ": %!+s", (_stream))
 
 static
 void destroy_stream(struct bt_object *obj)
@@ -82,18 +83,21 @@ end:
 
 static
 struct bt_stream *create_stream_with_id(struct bt_stream_class *stream_class,
-               struct bt_trace *trace, uint64_t id)
+               struct bt_trace *trace, uint64_t id, const char *api_func)
 {
        int ret;
        struct bt_stream *stream;
 
        BT_ASSERT(stream_class);
        BT_ASSERT(trace);
-       BT_ASSERT_PRE(trace->class ==
-               bt_stream_class_borrow_trace_class_inline(stream_class),
+       BT_ASSERT_PRE_FROM_FUNC(api_func,
+               "trace-class-is-stream-class-trace-class",
+               trace->class ==
+                       bt_stream_class_borrow_trace_class_inline(stream_class),
                "Trace's class is different from stream class's parent trace class: "
                "%![sc-]+S, %![trace-]+t", stream_class, trace);
-       BT_ASSERT_PRE(stream_id_is_unique(trace, stream_class, id),
+       BT_ASSERT_PRE_FROM_FUNC(api_func, "stream-id-is-unique",
+               stream_id_is_unique(trace, stream_class, id),
                "Duplicate stream ID: %![trace-]+t, id=%" PRIu64, trace, id);
        BT_LIB_LOGD("Creating stream object: %![trace-]+t, id=%" PRIu64,
                trace, id);
@@ -153,11 +157,12 @@ struct bt_stream *bt_stream_create(struct bt_stream_class *stream_class,
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_SC_NON_NULL(stream_class);
        BT_ASSERT_PRE_TRACE_NON_NULL(trace);
-       BT_ASSERT_PRE(stream_class->assigns_automatic_stream_id,
+       BT_ASSERT_PRE("stream-class-automatically-assigns-stream-ids",
+               stream_class->assigns_automatic_stream_id,
                "Stream class does not automatically assigns stream IDs: "
                "%![sc-]+S", stream_class);
        id = bt_trace_get_automatic_stream_id(trace, stream_class);
-       return create_stream_with_id(stream_class, trace, id);
+       return create_stream_with_id(stream_class, trace, id, __func__);
 }
 
 struct bt_stream *bt_stream_create_with_id(struct bt_stream_class *stream_class,
@@ -166,10 +171,11 @@ struct bt_stream *bt_stream_create_with_id(struct bt_stream_class *stream_class,
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_SC_NON_NULL(stream_class);
        BT_ASSERT_PRE_TRACE_NON_NULL(trace);
-       BT_ASSERT_PRE(!stream_class->assigns_automatic_stream_id,
+       BT_ASSERT_PRE("stream-class-does-not-automatically-assigns-stream-ids",
+               !stream_class->assigns_automatic_stream_id,
                "Stream class automatically assigns stream IDs: "
                "%![sc-]+S", stream_class);
-       return create_stream_with_id(stream_class, trace, id);
+       return create_stream_with_id(stream_class, trace, id, __func__);
 }
 
 struct bt_stream_class *bt_stream_borrow_class(struct bt_stream *stream)
index ac66803b5bb028c99923dd34b2c1bfcde34a3c27..642fa9060086618f790e177f21c9ed1330a49ec1 100644 (file)
@@ -45,7 +45,10 @@ struct bt_trace_class_destruction_listener_elem {
 };
 
 #define BT_ASSERT_PRE_DEV_TRACE_CLASS_HOT(_tc)                         \
-       BT_ASSERT_PRE_DEV_HOT((_tc), "Trace class", ": %!+T", (_tc))
+       BT_ASSERT_PRE_DEV_HOT("trace-class", (_tc), "Trace class",      \
+               ": %!+T", (_tc))
+
+#define DESTRUCTION_LISTENER_FUNC_NAME "bt_trace_destruction_listener_func"
 
 static
 void destroy_trace_class(struct bt_object *obj)
@@ -87,14 +90,19 @@ void destroy_trace_class(struct bt_object *obj)
 
                        if (elem.func) {
                                elem.func(tc, elem.data);
-                               BT_ASSERT_POST_NO_ERROR();
+                               BT_ASSERT_POST_NO_ERROR(
+                                       DESTRUCTION_LISTENER_FUNC_NAME);
                        }
 
                        /*
                         * The destruction listener should not have kept a
                         * reference to the trace class.
                         */
-                       BT_ASSERT_POST(tc->base.ref_count == 1, "Destruction listener kept a reference to the trace class being destroyed: %![tc-]+T", tc);
+                       BT_ASSERT_POST(DESTRUCTION_LISTENER_FUNC_NAME,
+                               "trace-class-reference-count-not-changed",
+                               tc->base.ref_count == 1,
+                               "Destruction listener kept a reference to the trace class being destroyed: %![tc-]+T",
+                               tc);
                }
                g_array_free(tc->destruction_listeners, TRUE);
                tc->destruction_listeners = NULL;
@@ -218,7 +226,8 @@ enum bt_trace_class_remove_listener_status bt_trace_class_remove_destruction_lis
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_TC_NON_NULL(tc);
-       BT_ASSERT_PRE(has_listener_id(tc, listener_id),
+       BT_ASSERT_PRE("listener-id-exists",
+               has_listener_id(tc, listener_id),
                "Trace class has no such trace class destruction listener ID: "
                "%![tc-]+T, %" PRIu64, tc, listener_id);
        elem = &g_array_index(tc->destruction_listeners,
index 897812e7ef64b8ec6104f3db9bd72b0f6b69c0a4..bd20f9fbda343e48689edf140573574d02eaa8da 100644 (file)
@@ -46,8 +46,11 @@ struct bt_trace_destruction_listener_elem {
        void *data;
 };
 
-#define BT_ASSERT_PRE_DEV_TRACE_HOT(_trace) \
-       BT_ASSERT_PRE_DEV_HOT((_trace), "Trace", ": %!+t", (_trace))
+#define BT_ASSERT_PRE_DEV_TRACE_HOT(_trace)                            \
+       BT_ASSERT_PRE_DEV_HOT("trace", (_trace), "Trace", ": %!+t", (_trace))
+
+#define DESTRUCTION_LISTENER_FUNC_NAME                                 \
+       "bt_trace_class_destruction_listener_func"
 
 static
 void destroy_trace(struct bt_object *obj)
@@ -85,18 +88,23 @@ void destroy_trace(struct bt_object *obj)
                for (i = 0; i < trace->destruction_listeners->len; i++) {
                        struct bt_trace_destruction_listener_elem elem =
                                g_array_index(trace->destruction_listeners,
-                                               struct bt_trace_destruction_listener_elem, i);
+                                       struct bt_trace_destruction_listener_elem, i);
 
                        if (elem.func) {
                                elem.func(trace, elem.data);
-                               BT_ASSERT_POST_NO_ERROR();
+                               BT_ASSERT_POST_NO_ERROR(
+                                       DESTRUCTION_LISTENER_FUNC_NAME);
                        }
 
                        /*
                         * The destruction listener should not have kept a
                         * reference to the trace.
                         */
-                       BT_ASSERT_POST(trace->base.ref_count == 1, "Destruction listener kept a reference to the trace being destroyed: %![trace-]+t", trace);
+                       BT_ASSERT_POST(DESTRUCTION_LISTENER_FUNC_NAME,
+                               "trace-reference-count-not-changed",
+                               trace->base.ref_count == 1,
+                               "Destruction listener kept a reference to the trace being destroyed: %![trace-]+t",
+                               trace);
                }
                g_array_free(trace->destruction_listeners, TRUE);
                trace->destruction_listeners = NULL;
@@ -255,8 +263,9 @@ enum bt_trace_set_environment_entry_status set_environment_entry(
        BT_ASSERT(trace);
        BT_ASSERT(name);
        BT_ASSERT(value);
-       BT_ASSERT_PRE(!trace->frozen ||
-               !trace_has_environment_entry(trace, name),
+       BT_ASSERT_PRE("not-frozen:trace",
+               !trace->frozen ||
+                       !trace_has_environment_entry(trace, name),
                "Trace is frozen: cannot replace environment entry: "
                "%![trace-]+t, entry-name=\"%s\"", trace, name);
        ret = bt_attributes_set_field_value(trace->environment, name,
@@ -285,7 +294,7 @@ bt_trace_set_environment_entry_string(
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_TRACE_NON_NULL(trace);
        BT_ASSERT_PRE_NAME_NON_NULL(name);
-       BT_ASSERT_PRE_NON_NULL(value, "Value");
+       BT_ASSERT_PRE_NON_NULL("value", value, "Value");
 
        value_obj = bt_value_string_create_init(value);
        if (!value_obj) {
@@ -342,7 +351,8 @@ void bt_trace_borrow_environment_entry_by_index_const(
 {
        BT_ASSERT_PRE_DEV_TRACE_NON_NULL(trace);
        BT_ASSERT_PRE_DEV_NAME_NON_NULL(name);
-       BT_ASSERT_PRE_DEV_NON_NULL(value, "Value");
+       BT_ASSERT_PRE_DEV_NON_NULL("value-object-output", value,
+               "Value object (output)");
        BT_ASSERT_PRE_DEV_VALID_INDEX(index,
                bt_attributes_get_count(trace->environment));
        *value = bt_attributes_borrow_field_value(trace->environment, index);
@@ -467,7 +477,8 @@ enum bt_trace_remove_listener_status bt_trace_remove_destruction_listener(
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_TRACE_NON_NULL(trace);
-       BT_ASSERT_PRE(has_listener_id(trace, listener_id),
+       BT_ASSERT_PRE("listener-id-exists",
+               has_listener_id(trace, listener_id),
                "Trace has no such trace destruction listener ID: "
                "%![trace-]+t, %" PRIu64, trace, listener_id);
        elem = &g_array_index(trace->destruction_listeners,
index d5cc0a0ea9510c87736f361e96e387c9686bb097..49d39f0b183a2352899f7f838d3befac1ac3ddbf 100644 (file)
@@ -27,10 +27,13 @@ bt_util_clock_cycles_to_ns_from_origin(uint64_t cycles,
        int ret;
 
        BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_NON_NULL(ns, "Nanoseconds (output)");
-       BT_ASSERT_PRE(frequency != UINT64_C(-1) && frequency != 0,
+       BT_ASSERT_PRE_NON_NULL("nanoseconds-output", ns,
+               "Nanoseconds (output)");
+       BT_ASSERT_PRE("valid-frequency",
+               frequency != UINT64_C(-1) && frequency != 0,
                "Invalid frequency: freq=%" PRIu64, frequency);
-       BT_ASSERT_PRE(offset_cycles < frequency,
+       BT_ASSERT_PRE("offset-cycles-lt-frequency",
+               offset_cycles < frequency,
                "Offset (cycles) is greater than frequency: "
                "offset-cycles=%" PRIu64 ", freq=%" PRIu64,
                offset_cycles, frequency);
index 701143fd3e470cc7f0877187722e51e5e97eb151..e570b005b4168448712f9bd34797ad56b800cf6c 100644 (file)
 #include "common/assert.h"
 #include "func-status.h"
 
+#define BT_ASSERT_PRE_DEV_VALUE_HOT_FROM_FUNC(_func, _value)           \
+       BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(_func, "value-object",          \
+               ((struct bt_value *) (_value)), "Value object",         \
+               ": %!+v", (_value))
+
 #define BT_ASSERT_PRE_DEV_VALUE_HOT(_value)                            \
-       BT_ASSERT_PRE_DEV_HOT(((struct bt_value *) (_value)),           \
-               "Value object", ": %!+v", (_value))
+       BT_ASSERT_PRE_DEV_VALUE_HOT_FROM_FUNC(__func__, (_value))
 
 #define BT_VALUE_TO_BOOL(_base) ((struct bt_value_bool *) (_base))
 #define BT_VALUE_TO_INTEGER(_base) ((struct bt_value_integer *) (_base))
@@ -680,7 +684,7 @@ struct bt_value *bt_value_string_create_init(const char *val)
        struct bt_value_string *string_obj = NULL;
 
        BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_NON_NULL(val, "Raw value");
+       BT_ASSERT_PRE_NON_NULL("raw-value", val, "Raw value");
 
        BT_LOGD("Creating string value object: val-len=%zu", strlen(val));
        string_obj = g_new0(struct bt_value_string, 1);
@@ -778,15 +782,14 @@ end:
 bt_bool bt_value_bool_get(const struct bt_value *bool_obj)
 {
        BT_ASSERT_PRE_DEV_VALUE_NON_NULL(bool_obj);
-       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(bool_obj, BT_VALUE_TYPE_BOOL);
+       BT_ASSERT_PRE_DEV_VALUE_IS_BOOL(bool_obj);
        return BT_VALUE_TO_BOOL(bool_obj)->value;
 }
 
 void bt_value_bool_set(struct bt_value *bool_obj, bt_bool val)
 {
        BT_ASSERT_PRE_VALUE_NON_NULL(bool_obj);
-       BT_ASSERT_PRE_VALUE_HAS_TYPE(bool_obj, BT_VALUE_TYPE_BOOL);
-       BT_ASSERT_PRE_DEV_VALUE_HOT(bool_obj);
+       BT_ASSERT_PRE_VALUE_IS_BOOL(bool_obj);
        BT_VALUE_TO_BOOL(bool_obj)->value = val;
        BT_LOGT("Set boolean value's raw value: value-addr=%p, value=%d",
                bool_obj, val);
@@ -795,33 +798,33 @@ void bt_value_bool_set(struct bt_value *bool_obj, bt_bool val)
 uint64_t bt_value_integer_unsigned_get(const struct bt_value *integer_obj)
 {
        BT_ASSERT_PRE_DEV_VALUE_NON_NULL(integer_obj);
-       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(integer_obj,
-               BT_VALUE_TYPE_UNSIGNED_INTEGER);
+       BT_ASSERT_PRE_DEV_VALUE_IS_UNSIGNED_INT(integer_obj);
        return BT_VALUE_TO_INTEGER(integer_obj)->value.u;
 }
 
 int64_t bt_value_integer_signed_get(const struct bt_value *integer_obj)
 {
        BT_ASSERT_PRE_DEV_VALUE_NON_NULL(integer_obj);
-       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(integer_obj,
-               BT_VALUE_TYPE_SIGNED_INTEGER);
+       BT_ASSERT_PRE_DEV_VALUE_IS_SIGNED_INT(integer_obj);
        return BT_VALUE_TO_INTEGER(integer_obj)->value.i;
 }
 
 static inline
-void bt_value_integer_set(struct bt_value *integer_obj,
-               enum bt_value_type expected_type, uint64_t uval)
+void set_integer_value(struct bt_value *integer_obj,
+               enum bt_value_type expected_type, uint64_t uval,
+               const char *api_func)
 {
-       BT_ASSERT_PRE_VALUE_NON_NULL(integer_obj);
-       BT_ASSERT_PRE_VALUE_HAS_TYPE(integer_obj, expected_type);
-       BT_ASSERT_PRE_DEV_VALUE_HOT(integer_obj);
+       BT_ASSERT_PRE_DEV_VALUE_HOT_FROM_FUNC(api_func, integer_obj);
        BT_VALUE_TO_INTEGER(integer_obj)->value.u = uval;
 }
 
 void bt_value_integer_unsigned_set(struct bt_value *integer_obj,
                uint64_t val)
 {
-       bt_value_integer_set(integer_obj, BT_VALUE_TYPE_UNSIGNED_INTEGER, val);
+       BT_ASSERT_PRE_VALUE_NON_NULL(integer_obj);
+       BT_ASSERT_PRE_VALUE_IS_UNSIGNED_INT(integer_obj);
+       set_integer_value(integer_obj, BT_VALUE_TYPE_UNSIGNED_INTEGER, val,
+               __func__);
        BT_LOGT("Set unsigned integer value's raw value: "
                "value-addr=%p, value=%" PRIu64, integer_obj, val);
 }
@@ -829,8 +832,10 @@ void bt_value_integer_unsigned_set(struct bt_value *integer_obj,
 void bt_value_integer_signed_set(struct bt_value *integer_obj,
                int64_t val)
 {
-       bt_value_integer_set(integer_obj, BT_VALUE_TYPE_SIGNED_INTEGER,
-               (uint64_t) val);
+       BT_ASSERT_PRE_VALUE_NON_NULL(integer_obj);
+       BT_ASSERT_PRE_VALUE_IS_SIGNED_INT(integer_obj);
+       set_integer_value(integer_obj, BT_VALUE_TYPE_SIGNED_INTEGER,
+               (uint64_t) val, __func__);
        BT_LOGT("Set signed integer value's raw value: "
                "value-addr=%p, value=%" PRId64, integer_obj, val);
 }
@@ -838,14 +843,14 @@ void bt_value_integer_signed_set(struct bt_value *integer_obj,
 double bt_value_real_get(const struct bt_value *real_obj)
 {
        BT_ASSERT_PRE_DEV_VALUE_NON_NULL(real_obj);
-       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(real_obj, BT_VALUE_TYPE_REAL);
+       BT_ASSERT_PRE_DEV_VALUE_IS_REAL(real_obj);
        return BT_VALUE_TO_REAL(real_obj)->value;
 }
 
 void bt_value_real_set(struct bt_value *real_obj, double val)
 {
        BT_ASSERT_PRE_VALUE_NON_NULL(real_obj);
-       BT_ASSERT_PRE_VALUE_HAS_TYPE(real_obj, BT_VALUE_TYPE_REAL);
+       BT_ASSERT_PRE_VALUE_IS_REAL(real_obj);
        BT_ASSERT_PRE_DEV_VALUE_HOT(real_obj);
        BT_VALUE_TO_REAL(real_obj)->value = val;
        BT_LOGT("Set real number value's raw value: value-addr=%p, value=%f",
@@ -855,7 +860,7 @@ void bt_value_real_set(struct bt_value *real_obj, double val)
 const char *bt_value_string_get(const struct bt_value *string_obj)
 {
        BT_ASSERT_PRE_DEV_VALUE_NON_NULL(string_obj);
-       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(string_obj, BT_VALUE_TYPE_STRING);
+       BT_ASSERT_PRE_DEV_VALUE_IS_STRING(string_obj);
        return BT_VALUE_TO_STRING(string_obj)->gstr->str;
 }
 
@@ -864,7 +869,7 @@ enum bt_value_string_set_status bt_value_string_set(
 {
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_VALUE_NON_NULL(string_obj);
-       BT_ASSERT_PRE_VALUE_HAS_TYPE(string_obj, BT_VALUE_TYPE_STRING);
+       BT_ASSERT_PRE_VALUE_IS_STRING(string_obj);
        BT_ASSERT_PRE_DEV_VALUE_HOT(string_obj);
        g_string_assign(BT_VALUE_TO_STRING(string_obj)->gstr, val);
        BT_LOGT("Set string value's raw value: value-addr=%p, raw-value-addr=%p",
@@ -875,7 +880,7 @@ enum bt_value_string_set_status bt_value_string_set(
 uint64_t bt_value_array_get_length(const struct bt_value *array_obj)
 {
        BT_ASSERT_PRE_DEV_VALUE_NON_NULL(array_obj);
-       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(array_obj, BT_VALUE_TYPE_ARRAY);
+       BT_ASSERT_PRE_DEV_VALUE_IS_ARRAY(array_obj);
        return (uint64_t) BT_VALUE_TO_ARRAY(array_obj)->garray->len;
 }
 
@@ -886,7 +891,7 @@ struct bt_value *bt_value_array_borrow_element_by_index(
                BT_VALUE_TO_ARRAY(array_obj);
 
        BT_ASSERT_PRE_DEV_VALUE_NON_NULL(array_obj);
-       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(array_obj, BT_VALUE_TYPE_ARRAY);
+       BT_ASSERT_PRE_DEV_VALUE_IS_ARRAY(array_obj);
        BT_ASSERT_PRE_DEV_VALID_INDEX(index, typed_array_obj->garray->len);
        return g_ptr_array_index(typed_array_obj->garray, index);
 }
@@ -899,18 +904,22 @@ const struct bt_value *bt_value_array_borrow_element_by_index_const(
                (void *) array_obj, index);
 }
 
-enum bt_value_array_append_element_status bt_value_array_append_element(
+static
+enum bt_value_array_append_element_status append_array_element(
                struct bt_value *array_obj,
-               struct bt_value *element_obj)
+               struct bt_value *element_obj, const char *api_func)
 {
        struct bt_value_array *typed_array_obj =
                BT_VALUE_TO_ARRAY(array_obj);
 
-       BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_NON_NULL(array_obj, "Array value object");
-       BT_ASSERT_PRE_NON_NULL(element_obj, "Element value object");
-       BT_ASSERT_PRE_VALUE_HAS_TYPE(array_obj, BT_VALUE_TYPE_ARRAY);
-       BT_ASSERT_PRE_DEV_VALUE_HOT(array_obj);
+       BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(api_func);
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(api_func, "array-value-object",
+               array_obj, "Array value object");
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(api_func, "element-value-object",
+               element_obj, "Element value object");
+       BT_ASSERT_PRE_VALUE_HAS_TYPE_FROM_FUNC(api_func, "value-object",
+               array_obj, "array", BT_VALUE_TYPE_ARRAY);
+       BT_ASSERT_PRE_DEV_VALUE_HOT_FROM_FUNC(api_func, array_obj);
        g_ptr_array_add(typed_array_obj->garray, element_obj);
        bt_object_get_ref(element_obj);
        BT_LOGT("Appended element to array value: array-value-addr=%p, "
@@ -919,6 +928,13 @@ enum bt_value_array_append_element_status bt_value_array_append_element(
        return BT_FUNC_STATUS_OK;
 }
 
+enum bt_value_array_append_element_status bt_value_array_append_element(
+               struct bt_value *array_obj,
+               struct bt_value *element_obj)
+{
+       return append_array_element(array_obj, element_obj, __func__);
+}
+
 enum bt_value_array_append_element_status
 bt_value_array_append_bool_element(struct bt_value *array_obj, bt_bool val)
 {
@@ -928,8 +944,8 @@ bt_value_array_append_bool_element(struct bt_value *array_obj, bt_bool val)
        BT_ASSERT_PRE_NO_ERROR();
 
        bool_obj = bt_value_bool_create_init(val);
-       ret = bt_value_array_append_element(array_obj,
-               (void *) bool_obj);
+       ret = append_array_element(array_obj,
+               (void *) bool_obj, __func__);
        bt_object_put_ref(bool_obj);
        return ret;
 }
@@ -944,8 +960,8 @@ bt_value_array_append_unsigned_integer_element(struct bt_value *array_obj,
        BT_ASSERT_PRE_NO_ERROR();
 
        integer_obj = bt_value_integer_unsigned_create_init(val);
-       ret = bt_value_array_append_element(array_obj,
-               (void *) integer_obj);
+       ret = append_array_element(array_obj,
+               (void *) integer_obj, __func__);
        bt_object_put_ref(integer_obj);
        return ret;
 }
@@ -960,8 +976,8 @@ bt_value_array_append_signed_integer_element(struct bt_value *array_obj,
        BT_ASSERT_PRE_NO_ERROR();
 
        integer_obj = bt_value_integer_signed_create_init(val);
-       ret = bt_value_array_append_element(array_obj,
-               (void *) integer_obj);
+       ret = append_array_element(array_obj,
+               (void *) integer_obj, __func__);
        bt_object_put_ref(integer_obj);
        return ret;
 }
@@ -975,8 +991,8 @@ bt_value_array_append_real_element(struct bt_value *array_obj, double val)
        BT_ASSERT_PRE_NO_ERROR();
 
        real_obj = bt_value_real_create_init(val);
-       ret = bt_value_array_append_element(array_obj,
-               (void *) real_obj);
+       ret = append_array_element(array_obj,
+               (void *) real_obj, __func__);
        bt_object_put_ref(real_obj);
        return ret;
 }
@@ -991,8 +1007,8 @@ bt_value_array_append_string_element(struct bt_value *array_obj,
        BT_ASSERT_PRE_NO_ERROR();
 
        string_obj = bt_value_string_create_init(val);
-       ret = bt_value_array_append_element(array_obj,
-               (void *) string_obj);
+       ret = append_array_element(array_obj,
+               (void *) string_obj, __func__);
        bt_object_put_ref(string_obj);
        return ret;
 }
@@ -1007,8 +1023,8 @@ bt_value_array_append_empty_array_element(struct bt_value *array_obj,
        BT_ASSERT_PRE_NO_ERROR();
 
        empty_array_obj = bt_value_array_create();
-       ret = bt_value_array_append_element(array_obj,
-               (void *) empty_array_obj);
+       ret = append_array_element(array_obj,
+               (void *) empty_array_obj, __func__);
 
        if (element_obj) {
                *element_obj = empty_array_obj;
@@ -1028,8 +1044,8 @@ bt_value_array_append_empty_map_element(struct bt_value *array_obj,
        BT_ASSERT_PRE_NO_ERROR();
 
        map_obj = bt_value_map_create();
-       ret = bt_value_array_append_element(array_obj,
-               (void *) map_obj);
+       ret = append_array_element(array_obj,
+               (void *) map_obj, __func__);
 
        if (element_obj) {
                *element_obj = map_obj;
@@ -1047,9 +1063,11 @@ bt_value_array_set_element_by_index(struct bt_value *array_obj, uint64_t index,
                BT_VALUE_TO_ARRAY(array_obj);
 
        BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_NON_NULL(array_obj, "Array value object");
-       BT_ASSERT_PRE_NON_NULL(element_obj, "Element value object");
-       BT_ASSERT_PRE_VALUE_HAS_TYPE(array_obj, BT_VALUE_TYPE_ARRAY);
+       BT_ASSERT_PRE_NON_NULL("array-value-object", array_obj,
+               "Array value object");
+       BT_ASSERT_PRE_NON_NULL("element-value-object", element_obj,
+               "Element value object");
+       BT_ASSERT_PRE_VALUE_IS_ARRAY(array_obj);
        BT_ASSERT_PRE_DEV_VALUE_HOT(array_obj);
        BT_ASSERT_PRE_VALID_INDEX(index, typed_array_obj->garray->len);
        bt_object_put_ref(g_ptr_array_index(typed_array_obj->garray, index));
@@ -1064,7 +1082,7 @@ bt_value_array_set_element_by_index(struct bt_value *array_obj, uint64_t index,
 uint64_t bt_value_map_get_size(const struct bt_value *map_obj)
 {
        BT_ASSERT_PRE_DEV_VALUE_NON_NULL(map_obj);
-       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(map_obj, BT_VALUE_TYPE_MAP);
+       BT_ASSERT_PRE_DEV_VALUE_IS_MAP(map_obj);
        return (uint64_t) g_hash_table_size(BT_VALUE_TO_MAP(map_obj)->ght);
 }
 
@@ -1073,7 +1091,7 @@ struct bt_value *bt_value_map_borrow_entry_value(struct bt_value *map_obj,
 {
        BT_ASSERT_PRE_DEV_VALUE_NON_NULL(map_obj);
        BT_ASSERT_PRE_DEV_KEY_NON_NULL(key);
-       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(map_obj, BT_VALUE_TYPE_MAP);
+       BT_ASSERT_PRE_DEV_VALUE_IS_MAP(map_obj);
        return g_hash_table_lookup(BT_VALUE_TO_MAP(map_obj)->ght,
                GUINT_TO_POINTER(g_quark_from_string(key)));
 }
@@ -1088,21 +1106,25 @@ bt_bool bt_value_map_has_entry(const struct bt_value *map_obj, const char *key)
 {
        BT_ASSERT_PRE_DEV_VALUE_NON_NULL(map_obj);
        BT_ASSERT_PRE_DEV_KEY_NON_NULL(key);
-       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(map_obj, BT_VALUE_TYPE_MAP);
+       BT_ASSERT_PRE_DEV_VALUE_IS_MAP(map_obj);
        return bt_g_hash_table_contains(BT_VALUE_TO_MAP(map_obj)->ght,
                GUINT_TO_POINTER(g_quark_from_string(key)));
 }
 
-enum bt_value_map_insert_entry_status bt_value_map_insert_entry(
+static
+enum bt_value_map_insert_entry_status insert_map_value_entry(
                struct bt_value *map_obj, const char *key,
-               struct bt_value *element_obj)
-{
-       BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_NON_NULL(map_obj, "Map value object");
-       BT_ASSERT_PRE_KEY_NON_NULL(key);
-       BT_ASSERT_PRE_NON_NULL(element_obj, "Element value object");
-       BT_ASSERT_PRE_VALUE_HAS_TYPE(map_obj, BT_VALUE_TYPE_MAP);
-       BT_ASSERT_PRE_DEV_VALUE_HOT(map_obj);
+               struct bt_value *element_obj, const char *api_func)
+{
+       BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(api_func);
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(api_func, "map-value-object",
+               map_obj, "Map value object");
+       BT_ASSERT_PRE_KEY_NON_NULL_FROM_FUNC(api_func, key);
+       BT_ASSERT_PRE_NON_NULL_FROM_FUNC(api_func,
+               "element-value-object", element_obj, "Element value object");
+       BT_ASSERT_PRE_VALUE_HAS_TYPE_FROM_FUNC(api_func, "value-object",
+               map_obj, "map", BT_VALUE_TYPE_MAP);
+       BT_ASSERT_PRE_DEV_VALUE_HOT_FROM_FUNC(api_func, map_obj);
        g_hash_table_insert(BT_VALUE_TO_MAP(map_obj)->ght,
                GUINT_TO_POINTER(g_quark_from_string(key)), element_obj);
        bt_object_get_ref(element_obj);
@@ -1112,6 +1134,13 @@ enum bt_value_map_insert_entry_status bt_value_map_insert_entry(
        return BT_FUNC_STATUS_OK;
 }
 
+enum bt_value_map_insert_entry_status bt_value_map_insert_entry(
+               struct bt_value *map_obj, const char *key,
+               struct bt_value *element_obj)
+{
+       return insert_map_value_entry(map_obj, key, element_obj, __func__);
+}
+
 enum bt_value_map_insert_entry_status bt_value_map_insert_bool_entry(
                struct bt_value *map_obj, const char *key, bt_bool val)
 {
@@ -1121,8 +1150,8 @@ enum bt_value_map_insert_entry_status bt_value_map_insert_bool_entry(
        BT_ASSERT_PRE_NO_ERROR();
 
        bool_obj = bt_value_bool_create_init(val);
-       ret = bt_value_map_insert_entry(map_obj, key,
-               (void *) bool_obj);
+       ret = insert_map_value_entry(map_obj, key,
+               (void *) bool_obj, __func__);
        bt_object_put_ref(bool_obj);
        return ret;
 }
@@ -1137,8 +1166,8 @@ bt_value_map_insert_unsigned_integer_entry(struct bt_value *map_obj,
        BT_ASSERT_PRE_NO_ERROR();
 
        integer_obj = bt_value_integer_unsigned_create_init(val);
-       ret = bt_value_map_insert_entry(map_obj, key,
-               (void *) integer_obj);
+       ret = insert_map_value_entry(map_obj, key,
+               (void *) integer_obj, __func__);
        bt_object_put_ref(integer_obj);
        return ret;
 }
@@ -1153,8 +1182,8 @@ bt_value_map_insert_signed_integer_entry(struct bt_value *map_obj,
        BT_ASSERT_PRE_NO_ERROR();
 
        integer_obj = bt_value_integer_signed_create_init(val);
-       ret = bt_value_map_insert_entry(map_obj, key,
-               (void *) integer_obj);
+       ret = insert_map_value_entry(map_obj, key,
+               (void *) integer_obj, __func__);
        bt_object_put_ref(integer_obj);
        return ret;
 }
@@ -1168,8 +1197,8 @@ enum bt_value_map_insert_entry_status bt_value_map_insert_real_entry(
        BT_ASSERT_PRE_NO_ERROR();
 
        real_obj = bt_value_real_create_init(val);
-       ret = bt_value_map_insert_entry(map_obj, key,
-               (void *) real_obj);
+       ret = insert_map_value_entry(map_obj, key,
+               (void *) real_obj, __func__);
        bt_object_put_ref(real_obj);
        return ret;
 }
@@ -1184,8 +1213,8 @@ enum bt_value_map_insert_entry_status bt_value_map_insert_string_entry(
        BT_ASSERT_PRE_NO_ERROR();
 
        string_obj = bt_value_string_create_init(val);
-       ret = bt_value_map_insert_entry(map_obj, key,
-               (void *) string_obj);
+       ret = insert_map_value_entry(map_obj, key,
+               (void *) string_obj, __func__);
        bt_object_put_ref(string_obj);
        return ret;
 }
@@ -1201,8 +1230,8 @@ bt_value_map_insert_empty_array_entry(
        BT_ASSERT_PRE_NO_ERROR();
 
        array_obj = bt_value_array_create();
-       ret = bt_value_map_insert_entry(map_obj, key,
-               (void *) array_obj);
+       ret = insert_map_value_entry(map_obj, key,
+               (void *) array_obj, __func__);
 
        if (entry_obj) {
                *entry_obj = array_obj;
@@ -1222,8 +1251,8 @@ bt_value_map_insert_empty_map_entry(struct bt_value *map_obj, const char *key,
        BT_ASSERT_PRE_NO_ERROR();
 
        empty_map_obj = bt_value_map_create();
-       ret = bt_value_map_insert_entry(map_obj, key,
-               (void *) empty_map_obj);
+       ret = insert_map_value_entry(map_obj, key,
+               (void *) empty_map_obj, __func__);
 
        if (entry_obj) {
                *entry_obj = empty_map_obj;
@@ -1233,27 +1262,31 @@ bt_value_map_insert_empty_map_entry(struct bt_value *map_obj, const char *key,
        return ret;
 }
 
-enum bt_value_map_foreach_entry_status bt_value_map_foreach_entry(
+static
+enum bt_value_map_foreach_entry_status foreach_map_entry(
                struct bt_value *map_obj, bt_value_map_foreach_entry_func func,
-               void *data)
+               void *data, const char *api_func,
+               const char *user_func_name)
 {
        int status = BT_FUNC_STATUS_OK;
        gpointer key, element_obj;
        GHashTableIter iter;
        struct bt_value_map *typed_map_obj = BT_VALUE_TO_MAP(map_obj);
 
-       BT_ASSERT_PRE_NO_ERROR();
-
-       BT_ASSERT_PRE_DEV_VALUE_NON_NULL(map_obj);
-       BT_ASSERT_PRE_DEV_NON_NULL(func, "User function");
-       BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(map_obj, BT_VALUE_TYPE_MAP);
+       BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(api_func);
+       BT_ASSERT_PRE_DEV_VALUE_NON_NULL_FROM_FUNC(api_func, map_obj);
+       BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(api_func, "user-function",
+               func, "User function");
+       BT_ASSERT_PRE_VALUE_HAS_TYPE_FROM_FUNC(api_func, "value-object",
+               map_obj, "map", BT_VALUE_TYPE_MAP);
        g_hash_table_iter_init(&iter, typed_map_obj->ght);
 
        while (g_hash_table_iter_next(&iter, &key, &element_obj)) {
                const char *key_str = g_quark_to_string(GPOINTER_TO_UINT(key));
 
                status = func(key_str, element_obj, data);
-               BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(status);
+               BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(user_func_name,
+                       status);
                if (status != BT_FUNC_STATUS_OK) {
                        if (status < 0) {
                                BT_LIB_LOGE_APPEND_CAUSE(
@@ -1288,14 +1321,21 @@ enum bt_value_map_foreach_entry_status bt_value_map_foreach_entry(
        return status;
 }
 
+enum bt_value_map_foreach_entry_status bt_value_map_foreach_entry(
+               struct bt_value *map_obj, bt_value_map_foreach_entry_func func,
+               void *data)
+{
+       return foreach_map_entry(map_obj, func, data, __func__,
+               "bt_value_map_foreach_entry_func");
+}
+
 enum bt_value_map_foreach_entry_const_status bt_value_map_foreach_entry_const(
                const struct bt_value *map_obj,
                bt_value_map_foreach_entry_const_func func, void *data)
 {
-       BT_ASSERT_PRE_NO_ERROR();
-
-       return (int) bt_value_map_foreach_entry((void *) map_obj,
-               (bt_value_map_foreach_entry_func) func, data);
+       return (int) foreach_map_entry((void *) map_obj,
+               (bt_value_map_foreach_entry_func) func, data, __func__,
+               "bt_value_map_foreach_entry_const_func");
 }
 
 struct extend_map_element_data {
@@ -1354,11 +1394,15 @@ enum bt_value_map_extend_status bt_value_map_extend(
        };
 
        BT_ASSERT_PRE_NO_ERROR();
-       BT_ASSERT_PRE_NON_NULL(base_map_obj, "Base value object");
+       BT_ASSERT_PRE_NON_NULL("base-value-object", base_map_obj,
+               "Base value object");
        BT_ASSERT_PRE_DEV_VALUE_HOT(base_map_obj);
-       BT_ASSERT_PRE_NON_NULL(extension_obj, "Extension value object");
-       BT_ASSERT_PRE_VALUE_HAS_TYPE(base_map_obj, BT_VALUE_TYPE_MAP);
-       BT_ASSERT_PRE_VALUE_HAS_TYPE(extension_obj, BT_VALUE_TYPE_MAP);
+       BT_ASSERT_PRE_NON_NULL("extension-value-object", extension_obj,
+               "Extension value object");
+       BT_ASSERT_PRE_VALUE_HAS_TYPE("base-value-object", base_map_obj,
+               "map", BT_VALUE_TYPE_MAP);
+       BT_ASSERT_PRE_VALUE_HAS_TYPE("extension-value-object", extension_obj,
+               "map", BT_VALUE_TYPE_MAP);
        BT_LOGD("Extending map value: base-value-addr=%p, extension-value-addr=%p",
                base_map_obj, extension_obj);
 
@@ -1386,7 +1430,8 @@ enum bt_value_copy_status bt_value_copy(const struct bt_value *object,
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_VALUE_NON_NULL(object);
-       BT_ASSERT_PRE_NON_NULL(copy_obj, "Value object copy (output)");
+       BT_ASSERT_PRE_NON_NULL("value-object-copy-output", copy_obj,
+               "Value object copy (output)");
        BT_LOGD("Copying value object: addr=%p", object);
        *copy_obj = copy_funcs[object->type](object);
        if (*copy_obj) {
@@ -1406,8 +1451,10 @@ bt_bool bt_value_is_equal(const struct bt_value *object_a,
 {
        bt_bool ret = BT_FALSE;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(object_a, "Value object A");
-       BT_ASSERT_PRE_DEV_NON_NULL(object_b, "Value object B");
+       BT_ASSERT_PRE_DEV_NON_NULL("value-object-a", object_a,
+               "Value object A");
+       BT_ASSERT_PRE_DEV_NON_NULL("value-object-b", object_b,
+               "Value object B");
 
        if (object_a->type != object_b->type) {
                BT_LOGT("Values are different: type mismatch: "
This page took 0.178127 seconds and 4 git commands to generate.