- 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
#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 */
_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
libbabeltrace2_la_SOURCES = \
assert-cond-base.h \
assert-cond.h \
+ assert-cond.c \
babeltrace2.c \
current-thread.c \
error.c \
(_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 */
--- /dev/null
+/*
+ * 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();
+}
/*
* 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 */
#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.
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;
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;
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;
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;
#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))
(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;
}
(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;
}
(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;
}
(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;
(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;
}
(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;
}
(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;
(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;
}
(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;
}
(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;
}
(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;
}
(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;
#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
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);
{
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);
{
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(
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(
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;
}
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(
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;
}
{
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(
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(
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;
}
{
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(
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(
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;
}
void finalize_component(struct bt_component *comp)
{
typedef void (*method_t)(void *);
+ const char *method_name;
method_t method = NULL;
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:
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:
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:
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);
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);
}
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;
}
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);
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
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);
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();
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();
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();
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;
#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)(
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);
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());
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;
return status;
}
+#define CONSUME_METHOD_NAME "bt_component_class_sink_consume_method"
+
static inline
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(
}
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);
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;
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++) {
(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(
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:
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;
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
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);
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();
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();
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();
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;
}
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;
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: "
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(
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(
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(
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(
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
/*
* 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) {
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;
#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,
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 =
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 ==
(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: "
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
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(
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;
}
* messages.
*/
+#define NEXT_METHOD_NAME "bt_message_iterator_class_next_method"
+
static
enum bt_message_iterator_class_next_method_status
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;
}
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",
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);
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,
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",
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(
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);
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,
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",
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;
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);
/*
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: "
(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;
(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;
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(
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);
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,
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);
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: "
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,
#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(
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);
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);
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);
{
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"
{
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"
#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)
{
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);
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: "
"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: "
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);
}
{
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;
}
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;
}
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)
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(
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);
}
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);
}
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 *
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 *
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);
}
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(
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);
}
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);
}
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 *
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 *
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);
}
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);
}
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);
}
#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(
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;
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);
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;
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, "
"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: "
{
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(
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(
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 *
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
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;
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);
}
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);
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);
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;
}
#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)
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;
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);
* `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: "
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(
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(
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(
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
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;
}
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;
}
(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(
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;
}
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);
}
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);
}
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);
}
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);
}
#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)
{
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: "
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(
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
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);
}
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);
}
}
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;
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;
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;
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
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
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);
}
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);
}
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) {
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:
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:
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:
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: "
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);
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);
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);
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:
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:
query_exec->comp_cls;
method = (method_t) sink_cc->methods.query;
+ method_name = "bt_component_class_sink_query_method";
break;
}
default:
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) {
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);
}
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);
}
};
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 ", "
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);
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,
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);
}
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);
}
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);
#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)
{
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;
{
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;
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;
}
{
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;
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 "
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;
}
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(
#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
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,
{
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,
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);
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;
{
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;
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
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;
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
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.");
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;
}
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;
}
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),
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;
}
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);
}
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;
}
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);
}
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 =
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 *
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;
}
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;
}
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;
}
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++) {
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++) {
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;
{
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
{
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
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);
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 */
}
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;
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;
}
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];
}
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 *
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;
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 *
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(
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),
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);
}
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(
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 *
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;
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;
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;
}
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;
}
(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;
}
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;
}
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;
}
(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;
}
(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;
}
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",
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)
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 */
}
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;
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);
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);
}
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;
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
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)
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;
}
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 *
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 *
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 *
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 *
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 *
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 *
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 *
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(
(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;
}
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) {
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;
}
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;
}
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;
}
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) {
}
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);
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;
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 ||
{
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);
}
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);
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(
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)
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));
#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);
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;
}
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);
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;
}
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;
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;
}
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;
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;
}
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;
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;
}
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;
}
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);
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);
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(
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(
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;
}
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;
}
{
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)) {
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);
}
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;
}
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)) {
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];
}
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];
}
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,
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) {
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;
}
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)
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];
}
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);
}
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);
}
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);
}
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];
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;
}
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);
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);
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;
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;
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;
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;
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)) {
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;
}
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:
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 */
#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)
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);
{
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,
{
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);
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
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
{
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;
{
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;
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;
#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)
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);
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,
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)
};
#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)
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;
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,
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)
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;
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,
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) {
{
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);
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,
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);
#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))
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);
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);
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);
}
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);
}
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",
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;
}
{
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",
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;
}
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);
}
(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, "
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)
{
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;
}
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;
}
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;
}
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;
}
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;
}
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;
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;
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));
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);
}
{
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)));
}
{
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);
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)
{
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;
}
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;
}
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;
}
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;
}
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;
}
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;
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;
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(
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 {
};
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);
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) {
{
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: "