From d98421f2abfc5adab28ab7ee9b63537a6c7261cc Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 15 Apr 2020 16:47:18 -0400 Subject: [PATCH] lib: merge `assert-pre.h` and `assert-post.h` into `assert-cond.h` Merge both files into a single one to make it possible to reuse code. Specific `BT_ASSERT_PRE*` and `BT_ASSERT_POST*` macros which were identical are merged into a single one with the `BT_ASSERT_COND*` prefix now. No functional changes intended. Signed-off-by: Philippe Proulx Change-Id: I019bcc73d5c644012238775c16b6498d07931a9a Reviewed-on: https://review.lttng.org/c/babeltrace/+/3428 --- src/lib/Makefile.am | 3 +- src/lib/assert-cond.h | 248 ++++++++++++++++++ src/lib/assert-post.h | 142 ---------- src/lib/assert-pre.h | 171 ------------ src/lib/current-thread.c | 2 +- src/lib/error.c | 2 +- src/lib/graph/component-class-sink-simple.c | 2 +- src/lib/graph/component-class.c | 2 +- src/lib/graph/component-descriptor-set.c | 2 +- src/lib/graph/component-filter.c | 2 +- src/lib/graph/component-sink.c | 3 +- src/lib/graph/component-source.c | 2 +- src/lib/graph/component.c | 3 +- src/lib/graph/connection.c | 3 +- src/lib/graph/graph.c | 5 +- src/lib/graph/graph.h | 14 +- src/lib/graph/interrupter.c | 2 +- src/lib/graph/iterator.c | 31 ++- src/lib/graph/message-iterator-class.c | 12 +- src/lib/graph/message/discarded-items.c | 2 +- src/lib/graph/message/event.c | 3 +- .../message/message-iterator-inactivity.c | 2 +- src/lib/graph/message/message.c | 3 +- src/lib/graph/message/packet.c | 3 +- src/lib/graph/message/stream.c | 2 +- src/lib/graph/mip.c | 3 +- src/lib/graph/port.c | 2 +- src/lib/graph/query-executor.c | 3 +- src/lib/integer-range-set.c | 2 +- src/lib/lib-logging.c | 4 +- src/lib/object-pool.c | 2 +- src/lib/plugin/plugin-so.c | 2 +- src/lib/plugin/plugin.c | 2 +- src/lib/trace-ir/attributes.c | 2 +- src/lib/trace-ir/clock-class.c | 2 +- src/lib/trace-ir/clock-snapshot.c | 2 +- src/lib/trace-ir/event-class.c | 2 +- src/lib/trace-ir/event-class.h | 2 +- src/lib/trace-ir/event.c | 2 +- src/lib/trace-ir/event.h | 2 +- src/lib/trace-ir/field-class.c | 2 +- src/lib/trace-ir/field-class.h | 2 +- src/lib/trace-ir/field-path.c | 2 +- src/lib/trace-ir/field.c | 2 +- src/lib/trace-ir/field.h | 2 +- src/lib/trace-ir/packet.c | 2 +- src/lib/trace-ir/resolve-field-path.c | 28 +- src/lib/trace-ir/stream-class.c | 2 +- src/lib/trace-ir/stream.c | 2 +- src/lib/trace-ir/trace-class.c | 3 +- src/lib/trace-ir/trace-class.h | 2 +- src/lib/trace-ir/trace.c | 3 +- src/lib/trace-ir/trace.h | 2 +- src/lib/util.c | 2 +- src/lib/value.c | 3 +- 55 files changed, 338 insertions(+), 421 deletions(-) create mode 100644 src/lib/assert-cond.h delete mode 100644 src/lib/assert-post.h delete mode 100644 src/lib/assert-pre.h diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 3c43a684..ce6ba4a4 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -5,8 +5,7 @@ SUBDIRS = trace-ir prio-heap plugin graph lib_LTLIBRARIES = libbabeltrace2.la libbabeltrace2_la_SOURCES = \ - assert-post.h \ - assert-pre.h \ + assert-cond.h \ babeltrace2.c \ current-thread.c \ error.c \ diff --git a/src/lib/assert-cond.h b/src/lib/assert-cond.h new file mode 100644 index 00000000..6fe6bed1 --- /dev/null +++ b/src/lib/assert-cond.h @@ -0,0 +1,248 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation + * Copyright (c) 2018-2020 Philippe Proulx + */ + +#ifndef BABELTRACE_ASSERT_COND_INTERNAL_H +#define BABELTRACE_ASSERT_COND_INTERNAL_H + +/* + * The macros in this header use macros defined in "lib/logging.h". We + * don't want this header to automatically include "lib/logging.h" + * because you need to manually define BT_LOG_TAG before including + * "lib/logging.h" and it is unexpected that you also need to define it + * before including this header. + * + * This is a reminder that in order to use "lib/assert-cond.h", you also + * need to use logging explicitly. + */ + +#ifndef BT_LIB_LOG_SUPPORTED +# error Include "lib/logging.h" before this header. +#endif + +#include +#include +#include +#include "common/common.h" +#include "common/macros.h" + +/* + * Prints the details of an unsatisfied precondition or postcondition + * without immediately aborting. You should use this within a function + * which checks preconditions or postconditions, but which is called + * from a BT_ASSERT_PRE() or BT_ASSERT_POST() context, so that the + * function can still return its result for + * BT_ASSERT_PRE()/BT_ASSERT_POST() to evaluate it. + * + * Example: + * + * static inline bool check_complex_precond(...) + * { + * ... + * + * if (...) { + * BT_ASSERT_COND_MSG("Invalid object: ...", ...); + * return false; + * } + * + * ... + * } + * + * ... + * + * BT_ASSERT_PRE(check_complex_precond(...), + * "Precondition is not satisfied: ...", ...); + */ +#define BT_ASSERT_COND_MSG(_fmt, ...) \ + do { \ + bt_lib_log(_BT_LOG_SRCLOC_FUNCTION, __FILE__, \ + __LINE__, BT_LOG_FATAL, BT_LOG_TAG, \ + (_fmt), ##__VA_ARGS__); \ + } while (0) + +/* + * Internal to this file: asserts that the library condition `_cond` of + * type `_cond_type` (`pre` or `post`) is satisfied. + * + * If `_cond` is false, this macro logs a fatal message using `_fmt` and + * the optional arguments (same usage as BT_LIB_LOGF()), and abort. + * + * To assert that an internal precondition or postcondition is + * satisfied, use BT_ASSERT() or BT_ASSERT_DBG(). + */ +#define _BT_ASSERT_COND(_cond_type, _cond, _fmt, ...) \ + do { \ + if (!(_cond)) { \ + BT_ASSERT_COND_MSG("Babeltrace 2 library " _cond_type "condition not satisfied. Error is:"); \ + BT_ASSERT_COND_MSG(_fmt, ##__VA_ARGS__); \ + BT_ASSERT_COND_MSG("Aborting..."); \ + bt_common_abort(); \ + } \ + } while (0) + +/* + * Asserts that the library precondition `_cond` is satisfied. + * + * If `_cond` is false, log a fatal message using `_fmt` and the + * optional arguments (same usage as BT_LIB_LOGF()), and abort. + * + * To assert that a library postcondition is satisfied (return from user + * code), use BT_ASSERT_POST(). + * + * To assert that an internal precondition or postcondition is + * satisfied, use BT_ASSERT() or BT_ASSERT_DBG(). + */ +#define BT_ASSERT_PRE(_cond, _fmt, ...) \ + _BT_ASSERT_COND("pre", _cond, _fmt, ##__VA_ARGS__) + +/* + * Asserts that the library postcondition `_cond` is satisfied. + * + * If `_cond` is false, log a fatal message using `_fmt` and the + * optional arguments (same usage as BT_LIB_LOGF()), and abort. + * + * To assert that a library precondition is satisfied (return from user + * code), use BT_ASSERT_PRE(). + * + * To assert that an internal precondition or postcondition is + * satisfied, use BT_ASSERT() or BT_ASSERT_DBG(). + */ +#define BT_ASSERT_POST(_cond, _fmt, ...) \ + _BT_ASSERT_COND("post", _cond, _fmt, ##__VA_ARGS__) + +/* + * Asserts that a given variable `_obj` named `_obj_name` (capitalized) + * is not `NULL`. + */ +#define BT_ASSERT_PRE_NON_NULL(_obj, _obj_name) \ + BT_ASSERT_PRE((_obj), "%s is NULL: ", _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), \ + "Index is out of bounds: index=%" PRIu64 ", " \ + "count=%" PRIu64, (uint64_t) (_index), (uint64_t) (_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__); \ + } while (0) + +/* + * Asserts that, if the current thread has an error, `_status` is an + * error status code. + * + * 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) \ + do { \ + const struct bt_error *err = bt_current_thread_take_error(); \ + if (err) { \ + bt_current_thread_move_error(err); \ + } \ + BT_ASSERT_POST(_status < 0 || !err, \ + "Current thread has an error, but user function " \ + "returned a non-error status: status=%s", \ + bt_common_func_status_string(_status)); \ + } while (0) + +/* + * Asserts that the current thread has no error. + */ +#define BT_ASSERT_POST_NO_ERROR() \ + BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(0) + +#ifdef BT_DEV_MODE +/* Developer mode version of BT_ASSERT_PRE(). */ +# define BT_ASSERT_PRE_DEV(_cond, _fmt, ...) \ + BT_ASSERT_PRE((_cond), _fmt, ##__VA_ARGS__) + +/* Developer mode version of BT_ASSERT_PRE_NON_NULL() */ +# define BT_ASSERT_PRE_DEV_NON_NULL(_obj, _obj_name) \ + BT_ASSERT_PRE_NON_NULL((_obj), (_obj_name)) + +/* + * Developer mode: asserts that a given object `_obj` named `_obj_name` + * (capitalized) 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__) + +/* Developer mode version of BT_ASSERT_PRE_VALID_INDEX() */ +# 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(). */ +# define BT_ASSERT_PRE_DEV_NO_ERROR() \ + BT_ASSERT_PRE_NO_ERROR() + +/* Developer mode version of BT_ASSERT_POST(). */ +# define BT_ASSERT_POST_DEV(_cond, _fmt, ...) \ + BT_ASSERT_POST((_cond), _fmt, ##__VA_ARGS__) + +/* + * Developer mode version of + * BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(). + */ +# define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_status) \ + BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_status) + +/* Developer mode version of BT_ASSERT_POST_NO_ERROR(). */ +# define BT_ASSERT_POST_DEV_NO_ERROR() \ + BT_ASSERT_POST_NO_ERROR() + +/* Developer mode version of BT_ASSERT_COND_MSG(). */ +# define BT_ASSERT_COND_DEV_MSG(_fmt, ...) \ + BT_ASSERT_COND_MSG(_fmt, ##__VA_ARGS__) + +/* + * Marks a function as being only used within a BT_ASSERT_PRE_DEV() or + * BT_ASSERT_POST_DEV() context. + */ +# define BT_ASSERT_COND_DEV_FUNC +#else +# define BT_ASSERT_COND_DEV_MSG(_fmt, ...) +# define BT_ASSERT_PRE_DEV(_cond, _fmt, ...) ((void) sizeof((void) (_cond), 0)) +# define BT_ASSERT_PRE_DEV_NON_NULL(_obj, _obj_name) \ + ((void) sizeof((void) (_obj), (void) (_obj_name), 0)) +# define BT_ASSERT_PRE_DEV_HOT(_obj, _obj_name, _fmt, ...) \ + ((void) sizeof((void) (_obj), (void) (_obj_name), 0)) +# define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \ + ((void) sizeof((void) (_index), (void) (_length), 0)) +# define BT_ASSERT_PRE_DEV_NO_ERROR() +# define BT_ASSERT_POST_DEV(_cond, _fmt, ...) ((void) sizeof((void) (_cond), 0)) +# define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_status) \ + ((void) sizeof((void) (_status), 0)) +# define BT_ASSERT_POST_DEV_NO_ERROR() +# define BT_ASSERT_COND_DEV_FUNC __attribute__((unused)) +#endif /* BT_DEV_MODE */ + +/* + * Mark anything that includes this file as supporting precondition and + * postcondition assertion macros. + */ +#define BT_ASSERT_COND_SUPPORTED + +#endif /* BABELTRACE_ASSERT_COND_INTERNAL_H */ diff --git a/src/lib/assert-post.h b/src/lib/assert-post.h deleted file mode 100644 index 5a63f099..00000000 --- a/src/lib/assert-post.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * SPDX-License-Identifier: MIT - * - * Copyright (c) 2019 EfficiOS Inc. and Linux Foundation - * Copyright (c) 2019 Philippe Proulx - */ - -#ifndef BABELTRACE_ASSERT_POST_INTERNAL_H -#define BABELTRACE_ASSERT_POST_INTERNAL_H - -/* - * The macros in this header use macros defined in "lib/logging.h". - * We don't want this header to automatically include - * "lib/logging.h" because you need to manually define BT_LOG_TAG - * before including "lib/logging.h" and it is unexpected that you - * also need to define it before including this header. - * - * This is a reminder that in order to use "lib/assert-post.h", you also - * need to use logging explicitly. - */ - -#ifndef BT_LIB_LOG_SUPPORTED -# error Include "lib/logging.h" before this header. -#endif - -#include -#include -#include -#include "common/macros.h" -#include "common/common.h" - -/* - * Prints the details of an unsatisfied postcondition without - * immediately aborting. You should use this within a function which - * checks postconditions, but which is called from a - * BT_ASSERT_POST() context, so that the function can still return - * its result for BT_ASSERT_POST() to evaluate it. - * - * Example: - * - * BT_ASSERT_POST_FUNC - * static inline bool check_complex_postcond(...) - * { - * ... - * - * if (...) { - * BT_ASSERT_POST_MSG("Unexpected status: ...", ...); - * return false; - * } - * - * ... - * } - * - * ... - * - * BT_ASSERT_POST(check_complex_postcond(...), - * "Postcondition is not satisfied: ...", ...); - */ -#define BT_ASSERT_POST_MSG(_fmt, ...) \ - do { \ - bt_lib_log(_BT_LOG_SRCLOC_FUNCTION, __FILE__, \ - __LINE__, BT_LOG_FATAL, BT_LOG_TAG, \ - (_fmt), ##__VA_ARGS__); \ - } while (0) - -/* - * Asserts that the library postcondition `_cond` is satisfied. - * - * If `_cond` is false, log a fatal statement using `_fmt` and the - * optional arguments (same usage as BT_LIB_LOGF()), and abort. - * - * To assert that a library precondition is satisfied (parameters from - * the user), use BT_ASSERT_PRE(). - * - * To assert that an internal postcondition is satisfied, use - * BT_ASSERT() or BT_ASSERT_DBG(). - */ -#define BT_ASSERT_POST(_cond, _fmt, ...) \ - do { \ - if (!(_cond)) { \ - BT_ASSERT_POST_MSG("Babeltrace 2 library postcondition not satisfied; error is:"); \ - BT_ASSERT_POST_MSG(_fmt, ##__VA_ARGS__); \ - BT_ASSERT_POST_MSG("Aborting..."); \ - bt_common_abort(); \ - } \ - } while (0) - -/* - * Asserts that if there's an error on the current thread, an error status code - * was returned. Puts back the error in place (if there is one) such that if - * the assertion hits, it will be possible to inspect it with a debugger. - */ -#define BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_status) \ - do { \ - const struct bt_error *err = bt_current_thread_take_error(); \ - if (err) { \ - bt_current_thread_move_error(err); \ - } \ - BT_ASSERT_POST(_status < 0 || !err, \ - "Current thread has an error, but user function " \ - "returned a non-error status: status=%s", \ - bt_common_func_status_string(_status)); \ - } while (0) - -/* - * Asserts that the current thread has no error. - */ -#define BT_ASSERT_POST_NO_ERROR() \ - BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(0) - -/* - * Marks a function as being only used within a BT_ASSERT_POST() - * context. - */ -#define BT_ASSERT_POST_FUNC - -#ifdef BT_DEV_MODE -/* Developer mode version of BT_ASSERT_POST_MSG(). */ -# define BT_ASSERT_POST_DEV_MSG(_fmt, ...) \ - BT_ASSERT_POST_MSG(_fmt, ##__VA_ARGS__) - -/* Developer mode version of BT_ASSERT_POST(). */ -# define BT_ASSERT_POST_DEV(_cond, _fmt, ...) \ - BT_ASSERT_POST((_cond), _fmt, ##__VA_ARGS__) - -/* Developer mode version of BT_ASSERT_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) - -/* Developer mode version of `BT_ASSERT_POST_FUNC`. */ -# define BT_ASSERT_POST_DEV_FUNC BT_ASSERT_POST_FUNC -#else -# define BT_ASSERT_POST_DEV_MSG(_fmt, ...) -# define BT_ASSERT_POST_DEV(_cond, _fmt, ...) ((void) sizeof((void) (_cond), 0)) -# define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_status) \ - ((void) sizeof((void) (_status), 0)) -# define BT_ASSERT_POST_DEV_FUNC __attribute__((unused)) -#endif /* BT_DEV_MODE */ - -#define BT_ASSERT_POST_SUPPORTED - -#endif /* BABELTRACE_ASSERT_POST_INTERNAL_H */ diff --git a/src/lib/assert-pre.h b/src/lib/assert-pre.h deleted file mode 100644 index d361d354..00000000 --- a/src/lib/assert-pre.h +++ /dev/null @@ -1,171 +0,0 @@ -/* - * SPDX-License-Identifier: MIT - * - * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation - * Copyright (c) 2018 Philippe Proulx - */ - -#ifndef BABELTRACE_ASSERT_PRE_INTERNAL_H -#define BABELTRACE_ASSERT_PRE_INTERNAL_H - -/* - * The macros in this header use macros defined in "lib/logging.h". - * We don't want this header to automatically include - * "lib/logging.h" because you need to manually define BT_LOG_TAG - * before including "lib/logging.h" and it is unexpected that you - * also need to define it before including this header. - * - * This is a reminder that in order to use "lib/assert-pre.h", you also - * need to use logging explicitly. - */ - -#ifndef BT_LIB_LOG_SUPPORTED -# error Include "lib/logging.h" before this header. -#endif - -#include -#include -#include -#include "common/common.h" -#include "common/macros.h" - -/* - * Prints the details of an unsatisfied precondition without immediately - * aborting. You should use this within a function which checks - * preconditions, but which is called from a BT_ASSERT_PRE() context, so - * that the function can still return its result for BT_ASSERT_PRE() to - * evaluate it. - * - * Example: - * - * static inline bool check_complex_precond(...) - * { - * ... - * - * if (...) { - * BT_ASSERT_PRE_MSG("Invalid object: ...", ...); - * return false; - * } - * - * ... - * } - * - * ... - * - * BT_ASSERT_PRE(check_complex_precond(...), - * "Precondition is not satisfied: ...", ...); - */ -#define BT_ASSERT_PRE_MSG(_fmt, ...) \ - do { \ - bt_lib_log(_BT_LOG_SRCLOC_FUNCTION, __FILE__, \ - __LINE__, BT_LOG_FATAL, BT_LOG_TAG, \ - (_fmt), ##__VA_ARGS__); \ - } while (0) - -/* - * Asserts that the library precondition `_cond` is satisfied. - * - * If `_cond` is false, log a fatal statement 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 postcondition is satisfied, use - * BT_ASSERT() or BT_ASSERT_DBG(). - */ -#define BT_ASSERT_PRE(_cond, _fmt, ...) \ - do { \ - if (!(_cond)) { \ - BT_ASSERT_PRE_MSG("Babeltrace 2 library precondition not satisfied; error is:"); \ - BT_ASSERT_PRE_MSG(_fmt, ##__VA_ARGS__); \ - BT_ASSERT_PRE_MSG("Aborting..."); \ - bt_common_abort(); \ - } \ - } while (0) - -/* - * Asserts that a given variable `_obj` named `_obj_name` (capitalized) - * is not `NULL`. - */ -#define BT_ASSERT_PRE_NON_NULL(_obj, _obj_name) \ - BT_ASSERT_PRE((_obj), "%s is NULL: ", _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), \ - "Index is out of bounds: index=%" PRIu64 ", " \ - "count=%" PRIu64, (uint64_t) (_index), (uint64_t) (_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__); \ - } while (0) - -#ifdef BT_DEV_MODE -/* Developer mode version of BT_ASSERT_PRE_MSG(). */ -# define BT_ASSERT_PRE_DEV_MSG(_fmt, ...) \ - BT_ASSERT_PRE_MSG(_fmt, ##__VA_ARGS__) - -/* Developer mode version of BT_ASSERT_PRE(). */ -# define BT_ASSERT_PRE_DEV(_cond, _fmt, ...) \ - BT_ASSERT_PRE((_cond), _fmt, ##__VA_ARGS__) - -/* Developer mode version of BT_ASSERT_PRE_NON_NULL() */ -# define BT_ASSERT_PRE_DEV_NON_NULL(_obj, _obj_name) \ - BT_ASSERT_PRE_NON_NULL((_obj), (_obj_name)) - -/* - * Developer mode: asserts that a given object `_obj` named `_obj_name` - * (capitalized) 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__) - -/* Developer mode version of BT_ASSERT_PRE_VALID_INDEX() */ -# 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(). */ -# define BT_ASSERT_PRE_DEV_NO_ERROR() \ - BT_ASSERT_PRE_NO_ERROR() - -/* - * Marks a function as being only used within a BT_ASSERT_PRE_DEV() - * context. - */ -# define BT_ASSERT_PRE_DEV_FUNC -#else -# define BT_ASSERT_PRE_DEV_MSG(_fmt, ...) -# define BT_ASSERT_PRE_DEV(_cond, _fmt, ...) ((void) sizeof((void) (_cond), 0)) -# define BT_ASSERT_PRE_DEV_NON_NULL(_obj, _obj_name) \ - ((void) sizeof((void) (_obj), (void) (_obj_name), 0)) -# define BT_ASSERT_PRE_DEV_HOT(_obj, _obj_name, _fmt, ...) \ - ((void) sizeof((void) (_obj), (void) (_obj_name), 0)) -# define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \ - ((void) sizeof((void) (_index), (void) (_length), 0)) -# define BT_ASSERT_PRE_DEV_NO_ERROR() -# define BT_ASSERT_PRE_DEV_FUNC __attribute__((unused)) -#endif /* BT_DEV_MODE */ - -#define BT_ASSERT_PRE_SUPPORTED - -#endif /* BABELTRACE_ASSERT_PRE_INTERNAL_H */ diff --git a/src/lib/current-thread.c b/src/lib/current-thread.c index fed1a213..457ca6f1 100644 --- a/src/lib/current-thread.c +++ b/src/lib/current-thread.c @@ -13,7 +13,7 @@ #include "error.h" #include "common/assert.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "lib/func-status.h" /* diff --git a/src/lib/error.c b/src/lib/error.c index 21e92c4c..1429af06 100644 --- a/src/lib/error.c +++ b/src/lib/error.c @@ -16,7 +16,7 @@ #include "graph/component.h" #include "graph/component-class.h" #include "common/assert.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "lib/func-status.h" #define BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(_cause, _exp_type) \ diff --git a/src/lib/graph/component-class-sink-simple.c b/src/lib/graph/component-class-sink-simple.c index bf55a69c..69b40c1d 100644 --- a/src/lib/graph/component-class-sink-simple.c +++ b/src/lib/graph/component-class-sink-simple.c @@ -9,7 +9,7 @@ #include "common/assert.h" #include "common/common.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "lib/object.h" #include #include diff --git a/src/lib/graph/component-class.c b/src/lib/graph/component-class.c index 6415c39f..79de19fb 100644 --- a/src/lib/graph/component-class.c +++ b/src/lib/graph/component-class.c @@ -9,7 +9,7 @@ #include "lib/logging.h" #include "common/assert.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "compat/compiler.h" #include #include diff --git a/src/lib/graph/component-descriptor-set.c b/src/lib/graph/component-descriptor-set.c index 631157d3..23ed60ce 100644 --- a/src/lib/graph/component-descriptor-set.c +++ b/src/lib/graph/component-descriptor-set.c @@ -9,7 +9,7 @@ #include "lib/logging.h" #include "common/assert.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "compat/compiler.h" #include "common/common.h" #include diff --git a/src/lib/graph/component-filter.c b/src/lib/graph/component-filter.c index 3541514f..24be2277 100644 --- a/src/lib/graph/component-filter.c +++ b/src/lib/graph/component-filter.c @@ -9,7 +9,7 @@ #include "lib/logging.h" #include "common/assert.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "compat/compiler.h" #include #include diff --git a/src/lib/graph/component-sink.c b/src/lib/graph/component-sink.c index 1f4a5a66..d89b7283 100644 --- a/src/lib/graph/component-sink.c +++ b/src/lib/graph/component-sink.c @@ -9,8 +9,7 @@ #include "lib/logging.h" #include "common/assert.h" -#include "lib/assert-pre.h" -#include "lib/assert-post.h" +#include "lib/assert-cond.h" #include "compat/compiler.h" #include #include diff --git a/src/lib/graph/component-source.c b/src/lib/graph/component-source.c index 879af724..9e2211e1 100644 --- a/src/lib/graph/component-source.c +++ b/src/lib/graph/component-source.c @@ -9,7 +9,7 @@ #include "lib/logging.h" #include "common/assert.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "compat/compiler.h" #include #include diff --git a/src/lib/graph/component.c b/src/lib/graph/component.c index d42dba7f..7660425c 100644 --- a/src/lib/graph/component.c +++ b/src/lib/graph/component.c @@ -10,8 +10,7 @@ #include "common/common.h" #include "common/assert.h" -#include "lib/assert-pre.h" -#include "lib/assert-post.h" +#include "lib/assert-cond.h" #include #include #include diff --git a/src/lib/graph/connection.c b/src/lib/graph/connection.c index af480f25..c470994e 100644 --- a/src/lib/graph/connection.c +++ b/src/lib/graph/connection.c @@ -9,8 +9,7 @@ #include "lib/logging.h" #include "common/assert.h" -#include "lib/assert-pre.h" -#include "lib/assert-post.h" +#include "lib/assert-cond.h" #include #include "lib/object.h" #include "compat/compiler.h" diff --git a/src/lib/graph/graph.c b/src/lib/graph/graph.c index 11c7c29d..4645e0f5 100644 --- a/src/lib/graph/graph.c +++ b/src/lib/graph/graph.c @@ -9,8 +9,7 @@ #include "lib/logging.h" #include "common/assert.h" -#include "lib/assert-pre.h" -#include "lib/assert-post.h" +#include "lib/assert-cond.h" #include #include #include @@ -865,7 +864,7 @@ bool component_name_exists(struct bt_graph *graph, const char *name) struct bt_component *other_comp = graph->components->pdata[i]; if (strcmp(name, bt_component_get_name(other_comp)) == 0) { - BT_ASSERT_PRE_MSG("Another component with the same name already exists in the graph: " + BT_ASSERT_COND_MSG("Another component with the same name already exists in the graph: " "%![other-comp-]+c, name=\"%s\"", other_comp, name); exists = true; diff --git a/src/lib/graph/graph.h b/src/lib/graph/graph.h index 61c2e29e..66654939 100644 --- a/src/lib/graph/graph.h +++ b/src/lib/graph/graph.h @@ -34,14 +34,12 @@ # error Please include "lib/logging.h" before including this file. #endif -/* Protection: this file uses BT_ASSERT_PRE*() macros directly */ -#ifndef BT_ASSERT_PRE_SUPPORTED -# error Please include "lib/assert-pre.h" before including this file. -#endif - -/* Protection: this file uses BT_ASSERT_POST*() macros directly */ -#ifndef BT_ASSERT_POST_SUPPORTED -# error Please include "lib/assert-post.h" before including this file. +/* + * Protection: this file uses precondition and postcondition assertion + * macros directly. + */ +#ifndef BT_ASSERT_COND_SUPPORTED +# error Please include "lib/assert-cond.h" before including this file. #endif struct bt_component; diff --git a/src/lib/graph/interrupter.c b/src/lib/graph/interrupter.c index 6e382264..a7e2c0d1 100644 --- a/src/lib/graph/interrupter.c +++ b/src/lib/graph/interrupter.c @@ -12,7 +12,7 @@ #include #include "interrupter.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" static void destroy_interrupter(struct bt_object *obj) diff --git a/src/lib/graph/iterator.c b/src/lib/graph/iterator.c index fad7967a..d8478553 100644 --- a/src/lib/graph/iterator.c +++ b/src/lib/graph/iterator.c @@ -30,8 +30,7 @@ #include #include #include "common/assert.h" -#include "lib/assert-pre.h" -#include "lib/assert-post.h" +#include "lib/assert-cond.h" #include #include #include @@ -510,7 +509,7 @@ void bt_self_message_iterator_configuration_set_can_seek_forward( * time. */ -BT_ASSERT_POST_DEV_FUNC +BT_ASSERT_COND_DEV_FUNC static bool clock_snapshots_are_monotonic_one( struct bt_message_iterator *iterator, @@ -592,7 +591,7 @@ end: return result; } -BT_ASSERT_POST_DEV_FUNC +BT_ASSERT_COND_DEV_FUNC static bool clock_snapshots_are_monotonic( struct bt_message_iterator *iterator, @@ -619,7 +618,7 @@ end: * stream is compatible with what we've seen before. */ -BT_ASSERT_POST_DEV_FUNC +BT_ASSERT_COND_DEV_FUNC static bool clock_classes_are_compatible_one(struct bt_message_iterator *iterator, const struct bt_message *msg) @@ -659,7 +658,7 @@ bool clock_classes_are_compatible_one(struct bt_message_iterator *iterator, case CLOCK_EXPECTATION_NONE: if (clock_class) { - BT_ASSERT_POST_DEV_MSG( + BT_ASSERT_COND_DEV_MSG( "Expecting no clock class, got one: %![cc-]+K", clock_class); result = false; @@ -670,14 +669,14 @@ bool clock_classes_are_compatible_one(struct bt_message_iterator *iterator, case CLOCK_EXPECTATION_ORIGIN_UNIX: if (!clock_class) { - BT_ASSERT_POST_DEV_MSG( + BT_ASSERT_COND_DEV_MSG( "Expecting a clock class, got none."); result = false; goto end; } if (!bt_clock_class_origin_is_unix_epoch(clock_class)) { - BT_ASSERT_POST_DEV_MSG( + BT_ASSERT_COND_DEV_MSG( "Expecting a clock class with Unix epoch origin: %![cc-]+K", clock_class); result = false; @@ -687,14 +686,14 @@ bool clock_classes_are_compatible_one(struct bt_message_iterator *iterator, case CLOCK_EXPECTATION_ORIGIN_OTHER_UUID: if (!clock_class) { - BT_ASSERT_POST_DEV_MSG( + BT_ASSERT_COND_DEV_MSG( "Expecting a clock class, got none."); result = false; goto end; } if (bt_clock_class_origin_is_unix_epoch(clock_class)) { - BT_ASSERT_POST_DEV_MSG( + BT_ASSERT_COND_DEV_MSG( "Expecting a clock class without Unix epoch origin: %![cc-]+K", clock_class); result = false; @@ -702,7 +701,7 @@ bool clock_classes_are_compatible_one(struct bt_message_iterator *iterator, } if (!clock_class_uuid) { - BT_ASSERT_POST_DEV_MSG( + BT_ASSERT_COND_DEV_MSG( "Expecting a clock class with UUID: %![cc-]+K", clock_class); result = false; @@ -710,7 +709,7 @@ bool clock_classes_are_compatible_one(struct bt_message_iterator *iterator, } if (bt_uuid_compare(iterator->clock_expectation.uuid, clock_class_uuid)) { - BT_ASSERT_POST_DEV_MSG( + BT_ASSERT_COND_DEV_MSG( "Expecting a clock class with UUID, got one " "with a different UUID: %![cc-]+K, expected-uuid=%!u", clock_class, iterator->clock_expectation.uuid); @@ -721,14 +720,14 @@ bool clock_classes_are_compatible_one(struct bt_message_iterator *iterator, case CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID: if (!clock_class) { - BT_ASSERT_POST_DEV_MSG( + BT_ASSERT_COND_DEV_MSG( "Expecting a clock class, got none."); result = false; goto end; } if (bt_clock_class_origin_is_unix_epoch(clock_class)) { - BT_ASSERT_POST_DEV_MSG( + BT_ASSERT_COND_DEV_MSG( "Expecting a clock class without Unix epoch origin: %![cc-]+K", clock_class); result = false; @@ -736,7 +735,7 @@ bool clock_classes_are_compatible_one(struct bt_message_iterator *iterator, } if (clock_class_uuid) { - BT_ASSERT_POST_DEV_MSG( + BT_ASSERT_COND_DEV_MSG( "Expecting a clock class without UUID: %![cc-]+K", clock_class); result = false; @@ -752,7 +751,7 @@ end: return result; } -BT_ASSERT_POST_DEV_FUNC +BT_ASSERT_COND_DEV_FUNC static bool clock_classes_are_compatible( struct bt_message_iterator *iterator, diff --git a/src/lib/graph/message-iterator-class.c b/src/lib/graph/message-iterator-class.c index c059862b..6ef9e72a 100644 --- a/src/lib/graph/message-iterator-class.c +++ b/src/lib/graph/message-iterator-class.c @@ -10,10 +10,10 @@ #include "message-iterator-class.h" #include "compat/compiler.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "lib/func-status.h" -#define BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(_msg_iter_cls) \ +#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)) @@ -84,7 +84,7 @@ bt_message_iterator_class_set_initialize_method( BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(message_iterator_class); + BT_ASSERT_COND_DEV_MSG_ITER_CLS_HOT(message_iterator_class); message_iterator_class->methods.initialize = method; BT_LIB_LOGD("Set message iterator class's iterator initialization method" ": %!+I", message_iterator_class); @@ -99,7 +99,7 @@ bt_message_iterator_class_set_finalize_method( BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(message_iterator_class); + BT_ASSERT_COND_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); @@ -115,7 +115,7 @@ bt_message_iterator_class_set_seek_ns_from_origin_methods( BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class"); BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method"); - BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(message_iterator_class); + BT_ASSERT_COND_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" @@ -132,7 +132,7 @@ bt_message_iterator_class_set_seek_beginning_methods( BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class"); BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method"); - BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(message_iterator_class); + BT_ASSERT_COND_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" diff --git a/src/lib/graph/message/discarded-items.c b/src/lib/graph/message/discarded-items.c index 10c02160..b0b51727 100644 --- a/src/lib/graph/message/discarded-items.c +++ b/src/lib/graph/message/discarded-items.c @@ -9,7 +9,7 @@ #include -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "lib/object.h" #include "compat/compiler.h" #include diff --git a/src/lib/graph/message/event.c b/src/lib/graph/message/event.c index 302d4b5a..e194fce0 100644 --- a/src/lib/graph/message/event.c +++ b/src/lib/graph/message/event.c @@ -9,8 +9,7 @@ #include "lib/logging.h" #include "common/assert.h" -#include "lib/assert-pre.h" -#include "lib/assert-post.h" +#include "lib/assert-cond.h" #include "compat/compiler.h" #include "lib/object.h" #include diff --git a/src/lib/graph/message/message-iterator-inactivity.c b/src/lib/graph/message/message-iterator-inactivity.c index 9303c650..6ead8bd5 100644 --- a/src/lib/graph/message/message-iterator-inactivity.c +++ b/src/lib/graph/message/message-iterator-inactivity.c @@ -7,7 +7,7 @@ #define BT_LOG_TAG "LIB/MSG-MSG-ITER-INACTIVITY" #include "lib/logging.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "lib/object.h" #include "compat/compiler.h" #include diff --git a/src/lib/graph/message/message.c b/src/lib/graph/message/message.c index 0f1c807a..734281bd 100644 --- a/src/lib/graph/message/message.c +++ b/src/lib/graph/message/message.c @@ -9,8 +9,7 @@ #include "lib/logging.h" #include "common/assert.h" -#include "lib/assert-pre.h" -#include "lib/assert-post.h" +#include "lib/assert-cond.h" #include #include "lib/graph/message/message.h" #include "lib/graph/graph.h" diff --git a/src/lib/graph/message/packet.c b/src/lib/graph/message/packet.c index 9afbb9f1..84dd8c4c 100644 --- a/src/lib/graph/message/packet.c +++ b/src/lib/graph/message/packet.c @@ -10,8 +10,7 @@ #include -#include "lib/assert-pre.h" -#include "lib/assert-post.h" +#include "lib/assert-cond.h" #include "compat/compiler.h" #include #include "lib/trace-ir/packet.h" diff --git a/src/lib/graph/message/stream.c b/src/lib/graph/message/stream.c index afbabfea..b4b045cf 100644 --- a/src/lib/graph/message/stream.c +++ b/src/lib/graph/message/stream.c @@ -8,7 +8,7 @@ #define BT_LOG_TAG "LIB/MSG-STREAM" #include "lib/logging.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "compat/compiler.h" #include #include "lib/trace-ir/stream.h" diff --git a/src/lib/graph/mip.c b/src/lib/graph/mip.c index 7c2bb698..d32e8054 100644 --- a/src/lib/graph/mip.c +++ b/src/lib/graph/mip.c @@ -7,8 +7,7 @@ #define BT_LOG_TAG "LIB/MIP" #include "lib/logging.h" -#include "lib/assert-pre.h" -#include "lib/assert-post.h" +#include "lib/assert-cond.h" #include #include #include diff --git a/src/lib/graph/port.c b/src/lib/graph/port.c index 65e57196..52ebc7f8 100644 --- a/src/lib/graph/port.c +++ b/src/lib/graph/port.c @@ -9,7 +9,7 @@ #include "lib/logging.h" #include "common/assert.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include #include #include "lib/object.h" diff --git a/src/lib/graph/query-executor.c b/src/lib/graph/query-executor.c index 78ba1f2c..e375979b 100644 --- a/src/lib/graph/query-executor.c +++ b/src/lib/graph/query-executor.c @@ -9,8 +9,7 @@ #include "common/assert.h" #include "common/common.h" -#include "lib/assert-pre.h" -#include "lib/assert-post.h" +#include "lib/assert-cond.h" #include #include #include diff --git a/src/lib/integer-range-set.c b/src/lib/integer-range-set.c index 9a5e817d..8853d702 100644 --- a/src/lib/integer-range-set.c +++ b/src/lib/integer-range-set.c @@ -11,7 +11,7 @@ #include -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "common/assert.h" #include "func-status.h" #include "integer-range-set.h" diff --git a/src/lib/lib-logging.c b/src/lib/lib-logging.c index e4d3ac20..1730f6d0 100644 --- a/src/lib/lib-logging.c +++ b/src/lib/lib-logging.c @@ -21,8 +21,7 @@ #include #include "logging.h" -#include "assert-pre.h" -#include "assert-post.h" +#include "assert-cond.h" #include "value.h" #include "integer-range-set.h" #include "object-pool.h" @@ -58,7 +57,6 @@ #include "trace-ir/trace.h" #include "trace-ir/utils.h" #include "error.h" -#include "assert-pre.h" #define LIB_LOGGING_BUF_SIZE (4096 * 4) diff --git a/src/lib/object-pool.c b/src/lib/object-pool.c index c354d9a5..3b48dee9 100644 --- a/src/lib/object-pool.c +++ b/src/lib/object-pool.c @@ -9,7 +9,7 @@ #include #include "common/assert.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "lib/object-pool.h" int bt_object_pool_initialize(struct bt_object_pool *pool, diff --git a/src/lib/plugin/plugin-so.c b/src/lib/plugin/plugin-so.c index 6025bdec..02428c2a 100644 --- a/src/lib/plugin/plugin-so.c +++ b/src/lib/plugin/plugin-so.c @@ -9,7 +9,7 @@ #include "lib/logging.h" #include "common/assert.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "compat/compiler.h" #include #include "lib/graph/component-class.h" diff --git a/src/lib/plugin/plugin.c b/src/lib/plugin/plugin.c index f9800af7..af8dc092 100644 --- a/src/lib/plugin/plugin.c +++ b/src/lib/plugin/plugin.c @@ -9,7 +9,7 @@ #include "lib/logging.h" #include "common/assert.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "common/macros.h" #include "compat/compiler.h" #include "common/common.h" diff --git a/src/lib/trace-ir/attributes.c b/src/lib/trace-ir/attributes.c index 924c71c4..68f54b86 100644 --- a/src/lib/trace-ir/attributes.c +++ b/src/lib/trace-ir/attributes.c @@ -10,7 +10,7 @@ #include "common/macros.h" #include -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "lib/object.h" #include #include "lib/value.h" diff --git a/src/lib/trace-ir/clock-class.c b/src/lib/trace-ir/clock-class.c index b9a66c02..8d100247 100644 --- a/src/lib/trace-ir/clock-class.c +++ b/src/lib/trace-ir/clock-class.c @@ -8,7 +8,7 @@ #define BT_LOG_TAG "LIB/CLOCK-CLASS" #include "lib/logging.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "common/uuid.h" #include #include "clock-class.h" diff --git a/src/lib/trace-ir/clock-snapshot.c b/src/lib/trace-ir/clock-snapshot.c index 9f8d85ae..65d152f9 100644 --- a/src/lib/trace-ir/clock-snapshot.c +++ b/src/lib/trace-ir/clock-snapshot.c @@ -7,7 +7,7 @@ #define BT_LOG_TAG "LIB/CLOCK-SNAPSHOT" #include "lib/logging.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "common/uuid.h" #include "clock-class.h" #include "clock-snapshot.h" diff --git a/src/lib/trace-ir/event-class.c b/src/lib/trace-ir/event-class.c index 67e4f3a5..49c78fde 100644 --- a/src/lib/trace-ir/event-class.c +++ b/src/lib/trace-ir/event-class.c @@ -8,7 +8,7 @@ #define BT_LOG_TAG "LIB/EVENT-CLASS" #include "lib/logging.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include #include #include diff --git a/src/lib/trace-ir/event-class.h b/src/lib/trace-ir/event-class.h index 61ff918e..00b2e23c 100644 --- a/src/lib/trace-ir/event-class.h +++ b/src/lib/trace-ir/event-class.h @@ -8,7 +8,7 @@ #ifndef BABELTRACE_TRACE_IR_EVENT_CLASS_INTERNAL_H #define BABELTRACE_TRACE_IR_EVENT_CLASS_INTERNAL_H -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include #include #include "common/macros.h" diff --git a/src/lib/trace-ir/event.c b/src/lib/trace-ir/event.c index cb6b6ada..b973798a 100644 --- a/src/lib/trace-ir/event.c +++ b/src/lib/trace-ir/event.c @@ -8,7 +8,7 @@ #define BT_LOG_TAG "LIB/EVENT" #include "lib/logging.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include #include #include diff --git a/src/lib/trace-ir/event.h b/src/lib/trace-ir/event.h index b783c111..2899f271 100644 --- a/src/lib/trace-ir/event.h +++ b/src/lib/trace-ir/event.h @@ -13,7 +13,7 @@ # error Please include "lib/logging.h" before including this file. #endif -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "common/macros.h" #include #include diff --git a/src/lib/trace-ir/field-class.c b/src/lib/trace-ir/field-class.c index 00a7cd3c..97c8523c 100644 --- a/src/lib/trace-ir/field-class.c +++ b/src/lib/trace-ir/field-class.c @@ -8,7 +8,7 @@ #define BT_LOG_TAG "LIB/FIELD-CLASS" #include "lib/logging.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include #include #include diff --git a/src/lib/trace-ir/field-class.h b/src/lib/trace-ir/field-class.h index af9254f2..1cd14e39 100644 --- a/src/lib/trace-ir/field-class.h +++ b/src/lib/trace-ir/field-class.h @@ -8,7 +8,7 @@ #ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H #define BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include #include #include "common/macros.h" diff --git a/src/lib/trace-ir/field-path.c b/src/lib/trace-ir/field-path.c index 781aefcf..e1a76019 100644 --- a/src/lib/trace-ir/field-path.c +++ b/src/lib/trace-ir/field-path.c @@ -8,7 +8,7 @@ #define BT_LOG_TAG "LIB/FIELD-PATH" #include "lib/logging.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include #include #include diff --git a/src/lib/trace-ir/field.c b/src/lib/trace-ir/field.c index 922b9abb..37e6731e 100644 --- a/src/lib/trace-ir/field.c +++ b/src/lib/trace-ir/field.c @@ -8,7 +8,7 @@ #define BT_LOG_TAG "LIB/FIELD" #include "lib/logging.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include #include "lib/object.h" #include "compat/compiler.h" diff --git a/src/lib/trace-ir/field.h b/src/lib/trace-ir/field.h index c94ae318..7262f827 100644 --- a/src/lib/trace-ir/field.h +++ b/src/lib/trace-ir/field.h @@ -8,7 +8,7 @@ #ifndef BABELTRACE_TRACE_IR_FIELDS_INTERNAL_H #define BABELTRACE_TRACE_IR_FIELDS_INTERNAL_H -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "common/common.h" #include "lib/object.h" #include "common/macros.h" diff --git a/src/lib/trace-ir/packet.c b/src/lib/trace-ir/packet.c index 1c9268e8..2b33bb80 100644 --- a/src/lib/trace-ir/packet.c +++ b/src/lib/trace-ir/packet.c @@ -7,7 +7,7 @@ #define BT_LOG_TAG "LIB/PACKET" #include "lib/logging.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include #include #include diff --git a/src/lib/trace-ir/resolve-field-path.c b/src/lib/trace-ir/resolve-field-path.c index 25a5fb68..ac8aed7e 100644 --- a/src/lib/trace-ir/resolve-field-path.c +++ b/src/lib/trace-ir/resolve-field-path.c @@ -7,7 +7,7 @@ #define BT_LOG_TAG "LIB/RESOLVE-FIELD-PATH" #include "lib/logging.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include "common/assert.h" #include #include @@ -155,7 +155,7 @@ end: return field_path; } -BT_ASSERT_PRE_DEV_FUNC +BT_ASSERT_COND_DEV_FUNC static inline bool target_is_before_source(struct bt_field_path *src_field_path, struct bt_field_path *tgt_field_path) @@ -199,7 +199,7 @@ end: return is_valid; } -BT_ASSERT_PRE_DEV_FUNC +BT_ASSERT_COND_DEV_FUNC static inline struct bt_field_class *borrow_root_field_class( struct bt_resolve_field_path_context *ctx, enum bt_field_path_scope scope) @@ -220,7 +220,7 @@ struct bt_field_class *borrow_root_field_class( return NULL; } -BT_ASSERT_PRE_DEV_FUNC +BT_ASSERT_COND_DEV_FUNC static inline struct bt_field_class *borrow_child_field_class( struct bt_field_class *parent_fc, @@ -257,7 +257,7 @@ struct bt_field_class *borrow_child_field_class( return child_fc; } -BT_ASSERT_PRE_DEV_FUNC +BT_ASSERT_COND_DEV_FUNC static inline bool target_field_path_in_different_scope_has_struct_fc_only( struct bt_field_path *src_field_path, @@ -297,7 +297,7 @@ end: return is_valid; } -BT_ASSERT_PRE_DEV_FUNC +BT_ASSERT_COND_DEV_FUNC static inline bool lca_is_structure_field_class(struct bt_field_path *src_field_path, struct bt_field_path *tgt_field_path, @@ -353,7 +353,7 @@ end: return is_valid; } -BT_ASSERT_PRE_DEV_FUNC +BT_ASSERT_COND_DEV_FUNC static inline bool lca_to_target_has_struct_fc_only(struct bt_field_path *src_field_path, struct bt_field_path *tgt_field_path, @@ -416,7 +416,7 @@ end: return is_valid; } -BT_ASSERT_PRE_DEV_FUNC +BT_ASSERT_COND_DEV_FUNC static inline bool field_path_is_valid(struct bt_field_class *src_fc, struct bt_field_class *tgt_fc, @@ -429,14 +429,14 @@ bool field_path_is_valid(struct bt_field_class *src_fc, tgt_fc, ctx); if (!src_field_path) { - BT_ASSERT_PRE_DEV_MSG("Cannot find requesting field class in " + BT_ASSERT_COND_DEV_MSG("Cannot find requesting field class in " "resolving context: %!+F", src_fc); is_valid = false; goto end; } if (!tgt_field_path) { - BT_ASSERT_PRE_DEV_MSG("Cannot find target field class in " + BT_ASSERT_COND_DEV_MSG("Cannot find target field class in " "resolving context: %!+F", tgt_fc); is_valid = false; goto end; @@ -444,7 +444,7 @@ bool field_path_is_valid(struct bt_field_class *src_fc, /* Target must be before source */ if (!target_is_before_source(src_field_path, tgt_field_path)) { - BT_ASSERT_PRE_DEV_MSG("Target field class is located after " + BT_ASSERT_COND_DEV_MSG("Target field class is located after " "requesting field class: %![req-fc-]+F, %![tgt-fc-]+F", src_fc, tgt_fc); is_valid = false; @@ -457,7 +457,7 @@ bool field_path_is_valid(struct bt_field_class *src_fc, */ if (!target_field_path_in_different_scope_has_struct_fc_only( src_field_path, tgt_field_path, ctx)) { - BT_ASSERT_PRE_DEV_MSG("Target field class is located in a " + BT_ASSERT_COND_DEV_MSG("Target field class is located in a " "different scope than requesting field class, " "but within an array or a variant field class: " "%![req-fc-]+F, %![tgt-fc-]+F", @@ -468,7 +468,7 @@ bool field_path_is_valid(struct bt_field_class *src_fc, /* Same scope: LCA must be a structure field class */ if (!lca_is_structure_field_class(src_field_path, tgt_field_path, ctx)) { - BT_ASSERT_PRE_DEV_MSG("Lowest common ancestor of target and " + BT_ASSERT_COND_DEV_MSG("Lowest common ancestor of target and " "requesting field classes is not a structure field class: " "%![req-fc-]+F, %![tgt-fc-]+F", src_fc, tgt_fc); @@ -479,7 +479,7 @@ bool field_path_is_valid(struct bt_field_class *src_fc, /* Same scope: path from LCA to target has no array/variant FTs */ if (!lca_to_target_has_struct_fc_only(src_field_path, tgt_field_path, ctx)) { - BT_ASSERT_PRE_DEV_MSG("Path from lowest common ancestor of target " + BT_ASSERT_COND_DEV_MSG("Path from lowest common ancestor of target " "and requesting field classes to target field class " "contains an array or a variant field class: " "%![req-fc-]+F, %![tgt-fc-]+F", src_fc, tgt_fc); diff --git a/src/lib/trace-ir/stream-class.c b/src/lib/trace-ir/stream-class.c index e6c2c8f6..f32d7bc2 100644 --- a/src/lib/trace-ir/stream-class.c +++ b/src/lib/trace-ir/stream-class.c @@ -8,7 +8,7 @@ #define BT_LOG_TAG "LIB/STREAM-CLASS" #include "lib/logging.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include #include "compat/compiler.h" #include "common/align.h" diff --git a/src/lib/trace-ir/stream.c b/src/lib/trace-ir/stream.c index daabe96f..07bdcc89 100644 --- a/src/lib/trace-ir/stream.c +++ b/src/lib/trace-ir/stream.c @@ -8,7 +8,7 @@ #define BT_LOG_TAG "LIB/STREAM" #include "lib/logging.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include #include #include diff --git a/src/lib/trace-ir/trace-class.c b/src/lib/trace-ir/trace-class.c index 90ae4de7..025698d2 100644 --- a/src/lib/trace-ir/trace-class.c +++ b/src/lib/trace-ir/trace-class.c @@ -8,8 +8,7 @@ #define BT_LOG_TAG "LIB/TRACE-CLASS" #include "lib/logging.h" -#include "lib/assert-pre.h" -#include "lib/assert-post.h" +#include "lib/assert-cond.h" #include #include #include "ctf-writer/functor.h" diff --git a/src/lib/trace-ir/trace-class.h b/src/lib/trace-ir/trace-class.h index 27a81b76..0a09dfbe 100644 --- a/src/lib/trace-ir/trace-class.h +++ b/src/lib/trace-ir/trace-class.h @@ -8,7 +8,7 @@ #ifndef BABELTRACE_TRACE_IR_TRACE_CLASS_INTERNAL_H #define BABELTRACE_TRACE_IR_TRACE_CLASS_INTERNAL_H -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include #include #include diff --git a/src/lib/trace-ir/trace.c b/src/lib/trace-ir/trace.c index 30e1f241..1be8992b 100644 --- a/src/lib/trace-ir/trace.c +++ b/src/lib/trace-ir/trace.c @@ -8,8 +8,7 @@ #define BT_LOG_TAG "LIB/TRACE" #include "lib/logging.h" -#include "lib/assert-pre.h" -#include "lib/assert-post.h" +#include "lib/assert-cond.h" #include #include #include "ctf-writer/functor.h" diff --git a/src/lib/trace-ir/trace.h b/src/lib/trace-ir/trace.h index 81bcbd7f..c6208778 100644 --- a/src/lib/trace-ir/trace.h +++ b/src/lib/trace-ir/trace.h @@ -8,7 +8,7 @@ #ifndef BABELTRACE_TRACE_IR_TRACE_INTERNAL_H #define BABELTRACE_TRACE_IR_TRACE_INTERNAL_H -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include #include #include diff --git a/src/lib/util.c b/src/lib/util.c index e52a956c..d5cc0a0e 100644 --- a/src/lib/util.c +++ b/src/lib/util.c @@ -7,7 +7,7 @@ #define BT_LOG_TAG "LIB/UTIL" #include "lib/logging.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include #include #include diff --git a/src/lib/value.c b/src/lib/value.c index 3d73636e..f533aba3 100644 --- a/src/lib/value.c +++ b/src/lib/value.c @@ -16,8 +16,7 @@ #include "compat/compiler.h" #include "common/common.h" #include "compat/glib.h" -#include "lib/assert-pre.h" -#include "lib/assert-post.h" +#include "lib/assert-cond.h" #include "lib/value.h" #include "common/assert.h" #include "func-status.h" -- 2.34.1