f73cfb97ebd5592a4506d287607ba014e9feebd4
2 * SPDX-License-Identifier: MIT
4 * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
5 * Copyright (c) 2018-2020 Philippe Proulx <pproulx@efficios.com>
8 #ifndef BABELTRACE_LIB_ASSERT_COND_H
9 #define BABELTRACE_LIB_ASSERT_COND_H
11 #include "assert-cond-base.h"
12 #include "trace-ir/trace-class.h" /* IWYU pragma: keep */
17 * Asserts that a given variable `_obj` named `_obj_name` (capitalized)
18 * and having the ID `_obj_id` (within the function's context) is not
21 #define BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _obj_id, _obj, _obj_name) \
22 BT_ASSERT_PRE_FROM_FUNC(_func, "not-null:" _obj_id, (_obj), \
23 "%s is NULL.", _obj_name)
25 #define BT_ASSERT_PRE_NON_NULL(_obj_id, _obj, _obj_name) \
26 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(__func__, _obj_id, (_obj), _obj_name)
29 * Asserts that a given index `_index` is less than a given length
32 #define BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(_func, _index, _length) \
33 BT_ASSERT_PRE_FROM_FUNC(_func, "valid-index", (_index) < (_length), \
34 "Index is out of bounds: index=%" PRIu64 ", " \
35 "count=%" PRIu64, (uint64_t) (_index), (uint64_t) (_length))
37 #define BT_ASSERT_PRE_VALID_INDEX(_index, _length) \
38 BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(__func__, (_index), (_length))
41 * Asserts that the current thread has no error set.
43 #define BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(_func) \
45 const struct bt_error *err = bt_current_thread_take_error(); \
47 bt_current_thread_move_error(err); \
49 BT_ASSERT_PRE_FROM_FUNC(_func, "no-error", !err, \
50 "API function called while current thread has an " \
51 "error: function=%s", _func); \
54 #define BT_ASSERT_PRE_NO_ERROR() \
55 BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(__func__)
58 * Asserts that, if the current thread has an error, `_status` is an
61 * See _BT_ASSERT_COND() for details about the `_func` parameter.
63 * Puts back the error in place (if there is one) such that if this
64 * macro aborts, it will be possible to inspect it with a debugger.
66 #define BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \
68 const struct bt_error *_err = bt_current_thread_take_error(); \
70 bt_current_thread_move_error(_err); \
72 BT_ASSERT_POST(_func, "no-error-if-no-error-status", \
73 (_status) < 0 || !_err, \
74 "Current thread has an error, but user function " \
75 "returned a non-error status: status=%s", \
76 bt_common_func_status_string(_status)); \
80 * Asserts that the current thread has no error.
82 * See _BT_ASSERT_COND() for details about the `_func` parameter.
84 #define BT_ASSERT_POST_NO_ERROR(_func) \
86 const struct bt_error *_err = bt_current_thread_take_error(); \
88 bt_current_thread_move_error(_err); \
90 BT_ASSERT_POST(_func, "no-error", !_err, \
91 "Current thread has an error"); \
95 /* Developer mode version of BT_ASSERT_PRE_NON_NULL_FROM_FUNC() */
96 # define BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, _obj_id, _obj, _obj_name) \
97 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _obj_id, (_obj), (_obj_name))
99 /* Developer mode version of BT_ASSERT_PRE_NON_NULL() */
100 # define BT_ASSERT_PRE_DEV_NON_NULL(_obj_id, _obj, _obj_name) \
101 BT_ASSERT_PRE_NON_NULL(_obj_id, (_obj), (_obj_name))
104 * Developer mode: asserts that a given object `_obj` named `_obj_name`
105 * (capitalized) and having the ID `_obj_id` (within the function's
106 * context) is NOT frozen.
108 * This macro checks the `frozen` field of `_obj`.
110 * This currently only exists in developer mode because some freezing
111 * functions can be called on the fast path, so they too are only
112 * enabled in developer mode.
114 # define BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(_func, _obj_id, _obj, _obj_name, _fmt, ...) \
115 BT_ASSERT_PRE_FROM_FUNC(_func, "not-frozen:" _obj_id, \
116 !(_obj)->frozen, "%s is frozen" _fmt, _obj_name, ##__VA_ARGS__)
118 # define BT_ASSERT_PRE_DEV_HOT(_obj_id, _obj, _obj_name, _fmt, ...) \
119 BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(__func__, _obj_id, (_obj), \
120 _obj_name, _fmt, ##__VA_ARGS__)
122 /* Developer mode version of BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC() */
123 # define BT_ASSERT_PRE_DEV_VALID_INDEX_FROM_FUNC(_func, _index, _length) \
124 BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(_func, (_index), (_length))
126 /* Developer mode version of BT_ASSERT_PRE_VALID_INDEX() */
127 # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \
128 BT_ASSERT_PRE_VALID_INDEX((_index), (_length))
130 /* Developer mode version of BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(). */
131 # define BT_ASSERT_PRE_DEV_NO_ERROR_FROM_FUNC(_func) \
132 BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(_func)
134 /* Developer mode version of BT_ASSERT_PRE_NO_ERROR(). */
135 # define BT_ASSERT_PRE_DEV_NO_ERROR() BT_ASSERT_PRE_NO_ERROR()
138 * Developer mode version of
139 * BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS().
141 # define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \
142 BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_func, (_status))
144 /* Developer mode version of BT_ASSERT_POST_NO_ERROR(). */
145 # define BT_ASSERT_POST_DEV_NO_ERROR(_func) \
146 BT_ASSERT_POST_NO_ERROR(_func)
149 * Marks a function as being only used within a BT_ASSERT_PRE_DEV() or
150 * BT_ASSERT_POST_DEV() context.
152 # define BT_ASSERT_COND_DEV_FUNC
154 # define BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, _obj_id, _obj, _obj_name) \
155 BT_USE_EXPR4(_func, _obj_id, (_obj), _obj_name)
157 # define BT_ASSERT_PRE_DEV_NON_NULL(_obj_id, _obj, _obj_name) \
158 BT_USE_EXPR3(_obj_id, (_obj), _obj_name)
160 # define BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(_func, _obj_id, _obj, _obj_name, _fmt, ...) \
161 BT_USE_EXPR5(_func, _obj_id, (_obj), _obj_name, _fmt)
163 # define BT_ASSERT_PRE_DEV_HOT(_obj_id, _obj, _obj_name, _fmt, ...) \
164 BT_USE_EXPR4(_obj_id, (_obj), _obj_name, _fmt)
166 # define BT_ASSERT_PRE_DEV_VALID_INDEX_FROM_FUNC(_func, _index, _length) \
167 BT_USE_EXPR3(_func, (_index), (_length))
169 # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \
170 BT_USE_EXPR2((_index), (_length))
172 # define BT_ASSERT_PRE_DEV_NO_ERROR_FROM_FUNC(_func) \
175 # define BT_ASSERT_PRE_DEV_NO_ERROR()
177 # define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \
178 BT_USE_EXPR2(_func, _status)
180 # define BT_ASSERT_POST_DEV_NO_ERROR(_func) \
182 #endif /* BT_DEV_MODE */
184 #define _BT_ASSERT_PRE_CLK_CLS_NAME "Clock class"
185 #define _BT_ASSERT_PRE_CLK_CLS_ID "clock-class"
187 #define BT_ASSERT_PRE_CLK_CLS_NON_NULL(_cc) \
188 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CLK_CLS_ID, (_cc), \
189 _BT_ASSERT_PRE_CLK_CLS_NAME)
191 #define BT_ASSERT_PRE_DEV_CLK_CLS_NON_NULL(_cc) \
192 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CLK_CLS_ID, (_cc), \
193 _BT_ASSERT_PRE_CLK_CLS_NAME)
195 #define _BT_ASSERT_PRE_DEF_CLK_CLS_NAME "Default clock class"
196 #define _BT_ASSERT_PRE_DEF_CLK_CLS_ID "default-clock-class"
198 #define BT_ASSERT_PRE_DEF_CLK_CLS_NON_NULL(_cc) \
199 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_DEF_CLK_CLS_ID, (_cc), \
200 _BT_ASSERT_PRE_DEF_CLK_CLS_NAME)
202 #define BT_ASSERT_PRE_DEV_DEF_CLK_CLS_NON_NULL(_cc) \
203 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_DEF_CLK_CLS_ID, \
204 (_cc), _BT_ASSERT_PRE_DEF_CLK_CLS_NAME)
206 #define _BT_ASSERT_PRE_CS_NAME "Clock snapshot"
207 #define _BT_ASSERT_PRE_CS_ID "clock-snapshot"
209 #define BT_ASSERT_PRE_CS_NON_NULL(_cs) \
210 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CS_ID, (_cs), \
211 _BT_ASSERT_PRE_CS_NAME)
213 #define BT_ASSERT_PRE_DEV_CS_NON_NULL(_cs) \
214 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CS_ID, (_cs), \
215 _BT_ASSERT_PRE_CS_NAME)
217 #define _BT_ASSERT_PRE_EVENT_NAME "Event"
218 #define _BT_ASSERT_PRE_EVENT_ID "event"
220 #define BT_ASSERT_PRE_EVENT_NON_NULL(_event) \
221 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_EVENT_ID, (_event), \
222 _BT_ASSERT_PRE_EVENT_NAME)
224 #define BT_ASSERT_PRE_DEV_EVENT_NON_NULL(_event) \
225 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_EVENT_ID, (_event), \
226 _BT_ASSERT_PRE_EVENT_NAME)
228 #define _BT_ASSERT_PRE_EC_NAME "Event class"
229 #define _BT_ASSERT_PRE_EC_ID "event-class"
231 #define BT_ASSERT_PRE_EC_NON_NULL_FROM_FUNC(_func, _ec) \
232 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_EC_ID, \
233 (_ec), _BT_ASSERT_PRE_EC_NAME)
235 #define BT_ASSERT_PRE_EC_NON_NULL(_ec) \
236 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_EC_ID, (_ec), \
237 _BT_ASSERT_PRE_EC_NAME)
239 #define BT_ASSERT_PRE_DEV_EC_NON_NULL_FROM_FUNC(_func, _ec) \
240 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
241 _BT_ASSERT_PRE_EC_ID, (_ec), _BT_ASSERT_PRE_EC_NAME)
243 #define BT_ASSERT_PRE_DEV_EC_NON_NULL(_ec) \
244 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_EC_ID, (_ec), \
245 _BT_ASSERT_PRE_EC_NAME)
247 #define _BT_ASSERT_PRE_FC_IS_INT_COND(_fc) \
248 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
249 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
250 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \
251 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION)
253 #define _BT_ASSERT_PRE_FC_IS_INT_FMT(_name) \
254 _name " is not an integer field class: %![fc-]+F"
256 #define _BT_ASSERT_PRE_FC_IS_INT_ID(_fc_id) "is-int-field-class:" _fc_id
258 #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc) \
259 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
260 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION)
262 #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name) \
263 _name " is not an unsigned integer field class: %![fc-]+F"
265 #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_ID(_fc_id) \
266 "is-unsigned-integer-field-class:" _fc_id
268 #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc) \
269 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
270 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION)
272 #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name) \
273 _name " is not a signed integer field class: %![fc-]+F"
275 #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_ID(_fc_id) \
276 "is-signed-integer-field-class:" _fc_id
278 #define _BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc) \
279 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \
280 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION)
282 #define _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name) \
283 _name " is not an enumeration field class: %![fc-]+F"
285 #define _BT_ASSERT_PRE_FC_IS_ENUM_ID(_fc_id) \
286 "is-enumeration-field-class:" _fc_id
288 #define _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc) \
289 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
290 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
291 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD)
293 #define _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name) \
294 _name " is not an array field class: %![fc-]+F"
296 #define _BT_ASSERT_PRE_FC_IS_ARRAY_ID(_fc_id) \
297 "is-array-field-class:" _fc_id
299 #define _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc) \
300 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \
301 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
302 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
303 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
305 #define _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name) \
306 _name " is not an option field class: %![fc-]+F"
308 #define _BT_ASSERT_PRE_FC_IS_OPTION_ID(_fc_id) \
309 "is-option-field-class:" _fc_id
311 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc) \
312 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
313 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
314 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
316 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name) \
317 _name " is not an option field class with a selector: %![fc-]+F"
319 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_ID(_fc_id) \
320 "is-option-field-class-with-selector:" _fc_id
322 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc) \
323 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
324 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
326 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name) \
327 _name " is not an option field class with an integer selector: %![fc-]+F"
329 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_ID(_fc_id) \
330 "is-option-field-class-with-integer-selector:" _fc_id
332 #define _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name) \
333 _name " is not a structure field class: %![fc-]+F"
335 #define _BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc) \
336 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STRUCTURE)
338 #define _BT_ASSERT_PRE_FC_IS_STRUCT_ID(_fc_id) \
339 "is-structure-field-class:" _fc_id
341 #define _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc) \
342 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \
343 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
344 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
346 #define _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name) \
347 _name " is not a variant field class: %![fc-]+F"
349 #define _BT_ASSERT_PRE_FC_IS_VARIANT_ID(_fc_id) \
350 "is-variant-field-class:" _fc_id
352 #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc) \
353 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
354 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
356 #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name) \
357 _name " is not a variant field class with a selector: %![fc-]+F"
359 #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_ID(_fc_id) \
360 "is-variant-field-class-with-selector:" _fc_id
362 #define _BT_ASSERT_PRE_FC_IS_BLOB_ID(_fc_id) \
363 "is-blob-field-class:" _fc_id
365 #define _BT_ASSERT_PRE_FC_IS_BLOB_COND(_fc) \
366 bt_field_class_type_is((_fc)->type, BT_FIELD_CLASS_TYPE_BLOB)
368 #define _BT_ASSERT_PRE_FC_IS_BLOB_FMT(_name) \
369 _name " is not a BLOB field class: %![fc-]+F"
371 #define _BT_ASSERT_PRE_FC_HAS_TYPE_COND(_fc, _type) \
372 (((const struct bt_field_class *) (_fc))->type == (_type))
374 #define _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name) \
375 _name " has the wrong type: expected-type=%s, %![fc-]+F"
377 #define _BT_ASSERT_PRE_FC_HAS_TYPE_ID(_fc_id, _type_id) \
378 "is-" _type_id ":" _fc_id
380 #define BT_ASSERT_PRE_FC_IS_INT_FROM_FUNC(_func, _fc_id, _fc, _name) \
381 BT_ASSERT_PRE_FROM_FUNC(_func, \
382 _BT_ASSERT_PRE_FC_IS_INT_ID(_fc_id), \
383 _BT_ASSERT_PRE_FC_IS_INT_COND(_fc), \
384 _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc))
386 #define BT_ASSERT_PRE_FC_IS_INT(_fc_id, _fc, _name) \
387 BT_ASSERT_PRE_FC_IS_INT_FROM_FUNC(__func__, _fc_id, (_fc), _name)
389 #define BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(_fc_id, _fc, _name) \
391 _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_ID(_fc_id), \
392 _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc), \
393 _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc))
395 #define BT_ASSERT_PRE_FC_IS_SIGNED_INT(_fc_id, _fc, _name) \
397 _BT_ASSERT_PRE_FC_IS_SIGNED_INT_ID(_fc_id), \
398 _BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc), \
399 _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc))
401 #define BT_ASSERT_PRE_FC_IS_ENUM(_fc_id, _fc, _name) \
403 _BT_ASSERT_PRE_FC_IS_ENUM_ID(_fc_id), \
404 _BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc), \
405 _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc))
407 #define BT_ASSERT_PRE_FC_IS_ARRAY(_fc_id, _fc, _name) \
409 _BT_ASSERT_PRE_FC_IS_ARRAY_ID(_fc_id), \
410 _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc), \
411 _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc))
413 #define BT_ASSERT_PRE_FC_IS_STRUCT(_fc_id, _fc, _name) \
415 _BT_ASSERT_PRE_FC_IS_STRUCT_ID(_fc_id), \
416 _BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc), \
417 _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name), (_fc))
419 #define BT_ASSERT_PRE_FC_IS_OPTION(_fc_id, _fc, _name) \
421 _BT_ASSERT_PRE_FC_IS_OPTION_ID(_fc_id), \
422 _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc), \
423 _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc))
425 #define BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL(_fc_id, _fc, _name) \
427 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_ID(_fc_id), \
428 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \
429 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc))
431 #define BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL(_fc_id, _fc, _name) \
433 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_ID(_fc_id), \
434 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \
435 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc))
437 #define BT_ASSERT_PRE_FC_IS_VARIANT(_fc_id, _fc, _name) \
439 _BT_ASSERT_PRE_FC_IS_VARIANT_ID(_fc_id), \
440 _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc), \
441 _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc))
443 #define BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL(_fc_id, _fc, _name) \
445 _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_ID(_fc_id), \
446 _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc), \
447 _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc))
449 #define BT_ASSERT_PRE_FC_IS_BLOB(_fc_id, _fc, _name) \
451 _BT_ASSERT_PRE_FC_IS_BLOB_ID(_fc_id), \
452 _BT_ASSERT_PRE_FC_IS_BLOB_COND(_fc), \
453 _BT_ASSERT_PRE_FC_IS_BLOB_FMT(_name), (_fc))
455 #define BT_ASSERT_PRE_FC_HAS_TYPE_FROM_FUNC(_func, _fc_id, _fc, _type_id, _type, _name) \
456 BT_ASSERT_PRE_FROM_FUNC(_func, \
457 _BT_ASSERT_PRE_FC_HAS_TYPE_ID(_fc_id, _type_id), \
458 _BT_ASSERT_PRE_FC_HAS_TYPE_COND((_fc), (_type)), \
459 _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name), \
460 bt_common_field_class_type_string(_type), (_fc))
462 #define BT_ASSERT_PRE_FC_HAS_TYPE(_fc_id, _fc, _type_id, _type, _name) \
463 BT_ASSERT_PRE_FC_HAS_TYPE_FROM_FUNC(__func__, _fc_id, (_fc), \
464 _type_id, (_type), _name)
466 #define BT_ASSERT_PRE_DEV_FC_IS_INT(_fc_id, _fc, _name) \
468 _BT_ASSERT_PRE_FC_IS_INT_ID(_fc_id), \
469 _BT_ASSERT_PRE_FC_IS_INT_COND(_fc), \
470 _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc))
472 #define BT_ASSERT_PRE_DEV_FC_IS_UNSIGNED_INT(_fc_id, _fc, _name) \
474 _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_ID(_fc_id), \
475 _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc), \
476 _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc))
478 #define BT_ASSERT_PRE_DEV_FC_IS_SIGNED_INT(_fc_id, _fc, _name) \
480 _BT_ASSERT_PRE_FC_IS_SIGNED_INT_ID(_fc_id), \
481 _BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc), \
482 _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc))
484 #define BT_ASSERT_PRE_DEV_FC_IS_ENUM(_fc_id, _fc, _name) \
486 _BT_ASSERT_PRE_FC_IS_ENUM_ID(_fc_id), \
487 _BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc), \
488 _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc))
490 #define BT_ASSERT_PRE_DEV_FC_IS_ARRAY(_fc_id, _fc, _name) \
492 _BT_ASSERT_PRE_FC_IS_ARRAY_ID(_fc_id), \
493 _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc), \
494 _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc))
496 #define BT_ASSERT_PRE_DEV_FC_IS_STRUCT(_fc_id, _fc, _name) \
498 _BT_ASSERT_PRE_FC_IS_STRUCT_ID(_fc_id), \
499 _BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc), \
500 _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name), (_fc))
502 #define BT_ASSERT_PRE_DEV_FC_IS_OPTION(_fc_id, _fc, _name) \
504 _BT_ASSERT_PRE_FC_IS_OPTION_ID(_fc_id), \
505 _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc), \
506 _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc))
508 #define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_SEL(_fc_id, _fc, _name) \
510 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \
511 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc))
513 #define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_INT_SEL(_fc_id, _fc, _name) \
515 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_ID(_fc_id), \
516 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \
517 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc))
519 #define BT_ASSERT_PRE_DEV_FC_IS_VARIANT(_fc_id, _fc, _name) \
521 _BT_ASSERT_PRE_FC_IS_VARIANT_ID(_fc_id), \
522 _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc), \
523 _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc))
525 #define BT_ASSERT_PRE_DEV_FC_IS_VARIANT_WITH_SEL(_fc_id, _fc, _name) \
527 _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_ID(_fc_id), \
528 _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc), \
529 _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc))
531 #define BT_ASSERT_PRE_DEV_FC_HAS_TYPE(_fc_id, _fc, _type_id, _type, _name) \
533 _BT_ASSERT_PRE_FC_HAS_TYPE_ID(_fc_id, _type_id), \
534 _BT_ASSERT_PRE_FC_HAS_TYPE_COND((_fc), (_type)), \
535 _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name), \
536 bt_common_field_class_type_string(_type), (_fc))
538 #define BT_ASSERT_PRE_DEV_FC_HOT_FROM_FUNC(_func, _fc) \
539 BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(_func, "field-class", \
540 (const struct bt_field_class *) (_fc), \
541 "Field class", ": %!+F", (_fc))
543 #define BT_ASSERT_PRE_DEV_FC_HOT(_fc) \
544 BT_ASSERT_PRE_DEV_FC_HOT_FROM_FUNC(__func__, (_fc))
546 #define _BT_ASSERT_PRE_FC_NAME "Field class"
547 #define _BT_ASSERT_PRE_FC_ID "field-class"
549 #define BT_ASSERT_PRE_FC_NON_NULL(_fc) \
550 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FC_ID, (_fc), \
551 _BT_ASSERT_PRE_FC_NAME)
553 #define _BT_ASSERT_PRE_SELECTOR_FC_NAME "Selector field class"
554 #define _BT_ASSERT_PRE_SELECTOR_FC_ID "selector-field-class"
556 #define BT_ASSERT_PRE_SELECTOR_FC_NON_NULL(_fc) \
557 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_SELECTOR_FC_ID, (_fc), \
558 _BT_ASSERT_PRE_SELECTOR_FC_NAME)
560 #define BT_ASSERT_PRE_DEV_FC_NON_NULL(_fc) \
561 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FC_ID, (_fc), \
562 _BT_ASSERT_PRE_FC_NAME)
564 #define _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME "Structure field class member"
565 #define _BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID "structure-field-class-member"
567 #define BT_ASSERT_PRE_STRUCT_FC_MEMBER_NON_NULL(_fc) \
568 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID, \
569 (_fc), _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME)
571 #define BT_ASSERT_PRE_DEV_STRUCT_FC_MEMBER_NON_NULL(_fc) \
572 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID, \
573 (_fc), _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME)
575 #define _BT_ASSERT_PRE_VAR_FC_OPT_NAME "Variant field class option"
576 #define _BT_ASSERT_PRE_VAR_FC_OPT_ID "variant-field-class-option-id"
578 #define BT_ASSERT_PRE_VAR_FC_OPT_NON_NULL(_fc) \
579 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_VAR_FC_OPT_ID, (_fc), \
580 _BT_ASSERT_PRE_VAR_FC_OPT_NAME)
582 #define BT_ASSERT_PRE_DEV_VAR_FC_OPT_NON_NULL(_fc) \
583 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_VAR_FC_OPT_ID, (_fc), \
584 _BT_ASSERT_PRE_VAR_FC_OPT_NAME)
587 #define _BT_ASSERT_PRE_FL_NAME "Field location"
588 #define _BT_ASSERT_PRE_FL_ID "field-location"
590 /* Asserts that `_fl` is non-NULL */
591 #define BT_ASSERT_PRE_FL_NON_NULL(_fl) \
592 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FL_ID, (_fl), \
593 _BT_ASSERT_PRE_FL_NAME)
595 #define _BT_ASSERT_PRE_SELECTOR_FL_NAME "Selector field location"
596 #define _BT_ASSERT_PRE_SELECTOR_FL_ID "selector-field-location"
598 /* Asserts that `_fl` is non-NULL */
599 #define BT_ASSERT_PRE_SELECTOR_FL_NON_NULL(_fl) \
600 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_SELECTOR_FL_ID, (_fl), \
601 _BT_ASSERT_PRE_SELECTOR_FL_NAME)
603 #define _BT_ASSERT_PRE_LENGTH_FL_NAME "Length field location"
604 #define _BT_ASSERT_PRE_LENGTH_FL_ID "length-field-location"
606 /* Asserts that `_fl` is non-NULL */
607 #define BT_ASSERT_PRE_LENGTH_FL_NON_NULL(_fl) \
608 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_LENGTH_FL_ID, (_fl), \
609 _BT_ASSERT_PRE_LENGTH_FL_NAME)
611 #define _BT_ASSERT_PRE_FP_NAME "Field path"
612 #define _BT_ASSERT_PRE_FP_ID "field-path"
614 #define BT_ASSERT_PRE_FP_NON_NULL(_fp) \
615 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FP_ID, (_fp), \
616 _BT_ASSERT_PRE_FP_NAME)
618 #define BT_ASSERT_PRE_DEV_FP_NON_NULL(_fp) \
619 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FP_ID, (_fp), \
620 _BT_ASSERT_PRE_FP_NAME)
622 #define BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE_FROM_FUNC(_func, _field_id, _field, _cls_type_id, _cls_type, _name) \
623 BT_ASSERT_PRE_DEV_FROM_FUNC(_func, "is-" _cls_type_id ":" _field_id, \
624 ((const struct bt_field *) (_field))->class->type == (_cls_type), \
625 _name " has the wrong class type: expected-class-type=%s, " \
627 bt_common_field_class_type_string(_cls_type), (_field))
629 #define BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(_field_id, _field, _cls_type_id, _cls_type, _name) \
630 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE_FROM_FUNC(__func__, \
631 _field_id, (_field), _cls_type_id, _cls_type, _name)
633 #define BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(_field_id, _field, _name) \
635 "is-unsigned-integer-field:" _field_id, \
636 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
637 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, \
638 _name " is not an unsigned integer field: %![field-]+f", \
641 #define BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(_field_id, _field, _name) \
643 "is-signed-integer-field:" _field_id, \
644 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
645 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, \
646 _name " is not a signed integer field: %![field-]+f", \
649 #define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY_FROM_FUNC(_func, _field_id, _field, _name) \
650 BT_ASSERT_PRE_DEV_FROM_FUNC(_func, \
651 "is-array-field:" _field_id, \
652 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
653 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
654 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \
655 _name " is not an array field: %![field-]+f", (_field))
657 #define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(_field_id, _field, _name) \
658 BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY_FROM_FUNC(__func__, _field_id, \
661 #define BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(_field_id, _field, _name) \
663 "is-dynamic-array-field:" _field_id, \
664 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
665 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \
666 _name " is not a dynamic array field: %![field-]+f", (_field))
668 #define BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(_field_id, _field, _name) \
670 "is-option-field:" _field_id, \
671 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \
672 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
673 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
674 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD, \
675 _name " is not an option field: %![field-]+f", (_field))
677 #define BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(_field_id, _field, _name) \
679 "is-variant-field:" _field_id, \
680 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \
681 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
682 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD, \
683 _name " is not a variant field: %![field-]+f", (_field))
685 #define BT_ASSERT_PRE_DEV_FIELD_IS_BLOB(_field_id, _field, _name) \
687 "is-blob-field:" _field_id, \
688 bt_field_class_type_is(_field->class->type, BT_FIELD_CLASS_TYPE_BLOB), \
689 _name "is not a BLOB field: %![field-]+f", (_field))
691 #define BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_BLOB(_field_id, _field, _name) \
693 "is-dynamic-blob-field:" _field_id, \
694 bt_field_class_type_is(_field->class->type, BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB), \
695 _name "is not a dynamic BLOB field: %![field-]+f", (_field))
697 #define BT_ASSERT_PRE_DEV_FIELD_IS_SET(_field_id, _field) \
698 BT_ASSERT_PRE_DEV("is-field-set:" _field_id, \
699 bt_field_is_set(_field), \
700 "Field is not set: %!+f", (_field))
702 #define _BT_ASSERT_PRE_FIELD_NAME "Field"
703 #define _BT_ASSERT_PRE_FIELD_ID "field"
705 #define BT_ASSERT_PRE_FIELD_NON_NULL(_field) \
706 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FIELD_ID, (_field), \
707 _BT_ASSERT_PRE_FIELD_NAME)
709 #define BT_ASSERT_PRE_DEV_FIELD_NON_NULL_FROM_FUNC(_func, _field) \
710 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
711 _BT_ASSERT_PRE_FIELD_ID, (_field), \
712 _BT_ASSERT_PRE_FIELD_NAME)
714 #define BT_ASSERT_PRE_DEV_FIELD_NON_NULL(_field) \
715 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FIELD_ID, (_field), \
716 _BT_ASSERT_PRE_FIELD_NAME)
718 #define _BT_ASSERT_PRE_PACKET_NAME "Packet"
719 #define _BT_ASSERT_PRE_PACKET_ID "packet"
721 #define BT_ASSERT_PRE_PACKET_NON_NULL_FROM_FUNC(_func, _packet) \
722 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
723 _BT_ASSERT_PRE_PACKET_ID, (_packet), _BT_ASSERT_PRE_PACKET_NAME)
725 #define BT_ASSERT_PRE_PACKET_NON_NULL(_packet) \
726 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PACKET_ID, (_packet), \
727 _BT_ASSERT_PRE_PACKET_NAME)
729 #define BT_ASSERT_PRE_DEV_PACKET_NON_NULL_FROM_FUNC(_func, _packet) \
730 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
731 _BT_ASSERT_PRE_PACKET_ID, (_packet), _BT_ASSERT_PRE_PACKET_NAME)
733 #define BT_ASSERT_PRE_DEV_PACKET_NON_NULL(_packet) \
734 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PACKET_ID, (_packet), \
735 _BT_ASSERT_PRE_PACKET_NAME)
737 #define _BT_ASSERT_PRE_SC_NAME "Stream class"
738 #define _BT_ASSERT_PRE_SC_ID "stream-class"
740 #define BT_ASSERT_PRE_SC_NON_NULL(_sc) \
741 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_SC_ID, (_sc), \
742 _BT_ASSERT_PRE_SC_NAME)
744 #define BT_ASSERT_PRE_DEV_SC_NON_NULL(_sc) \
745 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_SC_ID, (_sc), \
746 _BT_ASSERT_PRE_SC_NAME)
748 #define _BT_ASSERT_PRE_STREAM_NAME "Stream"
749 #define _BT_ASSERT_PRE_STREAM_ID "stream"
751 #define BT_ASSERT_PRE_STREAM_NON_NULL_FROM_FUNC(_func, _stream) \
752 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
753 _BT_ASSERT_PRE_STREAM_ID, (_stream), \
754 _BT_ASSERT_PRE_STREAM_NAME)
756 #define BT_ASSERT_PRE_STREAM_NON_NULL(_stream) \
757 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_STREAM_ID, (_stream), \
758 _BT_ASSERT_PRE_STREAM_NAME)
760 #define BT_ASSERT_PRE_DEV_STREAM_NON_NULL_FROM_FUNC(_func, _stream) \
761 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
762 _BT_ASSERT_PRE_STREAM_ID, (_stream), \
763 _BT_ASSERT_PRE_STREAM_NAME)
765 #define BT_ASSERT_PRE_DEV_STREAM_NON_NULL(_stream) \
766 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_STREAM_ID, (_stream), \
767 _BT_ASSERT_PRE_STREAM_NAME)
769 #define _BT_ASSERT_PRE_TC_NAME "Trace class"
770 #define _BT_ASSERT_PRE_TC_ID "trace-class"
772 #define BT_ASSERT_PRE_TC_NON_NULL_FROM_FUNC(_func, _tc) \
773 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_TC_ID, \
774 (_tc), _BT_ASSERT_PRE_TC_NAME)
776 #define BT_ASSERT_PRE_TC_NON_NULL(_tc) \
777 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_TC_ID, (_tc), \
778 _BT_ASSERT_PRE_TC_NAME)
780 #define BT_ASSERT_PRE_DEV_TC_NON_NULL(_tc) \
781 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_TC_ID, (_tc), \
782 _BT_ASSERT_PRE_TC_NAME)
784 #define _BT_ASSERT_PRE_TRACE_NAME "Trace"
785 #define _BT_ASSERT_PRE_TRACE_ID "trace"
787 #define BT_ASSERT_PRE_TRACE_NON_NULL(_trace) \
788 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_TRACE_ID, (_trace), \
789 _BT_ASSERT_PRE_TRACE_NAME)
791 #define BT_ASSERT_PRE_DEV_TRACE_NON_NULL(_trace) \
792 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_TRACE_ID, (_trace), \
793 _BT_ASSERT_PRE_TRACE_NAME)
795 #define _BT_ASSERT_PRE_USER_ATTRS_NAME "User attributes value object"
796 #define _BT_ASSERT_PRE_USER_ATTRS_ID "user-attributes-value-object"
798 #define BT_ASSERT_PRE_USER_ATTRS_NON_NULL_FROM_FUNC(_func, _ua) \
799 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
800 _BT_ASSERT_PRE_USER_ATTRS_ID, (_ua), \
801 _BT_ASSERT_PRE_USER_ATTRS_NAME)
803 #define BT_ASSERT_PRE_USER_ATTRS_NON_NULL(_ua) \
804 BT_ASSERT_PRE_USER_ATTRS_NON_NULL_FROM_FUNC(__func__, (_ua))
806 #define BT_ASSERT_PRE_DEV_USER_ATTRS_NON_NULL(_ua) \
807 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_USER_ATTRS_ID, (_ua), \
808 _BT_ASSERT_PRE_USER_ATTRS_NAME)
810 #define BT_ASSERT_PRE_USER_ATTRS_IS_MAP_FROM_FUNC(_func, _ua) \
811 BT_ASSERT_PRE_FROM_FUNC(_func, "is-map-value:user-attributes", \
812 (_ua)->type == BT_VALUE_TYPE_MAP, \
813 _BT_ASSERT_PRE_USER_ATTRS_NAME \
814 " object is not a map value object.")
816 #define BT_ASSERT_PRE_USER_ATTRS_IS_MAP(_ua) \
817 BT_ASSERT_PRE_USER_ATTRS_IS_MAP_FROM_FUNC(__func__, (_ua))
819 #define BT_ASSERT_COND_LISTENER_FUNC_NAME "Listener function"
820 #define BT_ASSERT_COND_LISTENER_FUNC_ID "listener-function"
822 #define BT_ASSERT_PRE_LISTENER_FUNC_NON_NULL(_listener_func) \
823 BT_ASSERT_PRE_NON_NULL(BT_ASSERT_COND_LISTENER_FUNC_ID, \
824 (_listener_func), BT_ASSERT_COND_LISTENER_FUNC_NAME)
826 #define BT_ASSERT_PRE_DEV_LISTENER_FUNC_NON_NULL(_listener_func) \
827 BT_ASSERT_PRE_DEV_NON_NULL(BT_ASSERT_COND_LISTENER_FUNC_ID, \
828 (_listener_func), BT_ASSERT_COND_LISTENER_FUNC_NAME)
830 #define _BT_ASSERT_PRE_MSG_ITER_NAME "Message iterator"
831 #define _BT_ASSERT_PRE_MSG_ITER_ID "message-iterator"
833 #define BT_ASSERT_PRE_MSG_ITER_NON_NULL_FROM_FUNC(_func, _msg_iter) \
834 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
835 _BT_ASSERT_PRE_MSG_ITER_ID, (_msg_iter), \
836 _BT_ASSERT_PRE_MSG_ITER_NAME)
838 #define BT_ASSERT_PRE_MSG_ITER_NON_NULL(_msg_iter) \
839 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_ID, (_msg_iter), \
840 _BT_ASSERT_PRE_MSG_ITER_NAME)
842 #define BT_ASSERT_PRE_DEV_MSG_ITER_NON_NULL_FROM_FUNC(_func, _msg_iter) \
843 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
844 _BT_ASSERT_PRE_MSG_ITER_ID, \
845 (_msg_iter), _BT_ASSERT_PRE_MSG_ITER_NAME)
847 #define BT_ASSERT_PRE_DEV_MSG_ITER_NON_NULL(_msg_iter) \
848 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_ID, \
849 (_msg_iter), _BT_ASSERT_PRE_MSG_ITER_NAME)
851 #define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc) \
852 ((_sc)->default_clock_class)
854 #define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FMT \
855 "Message's stream's class has no default clock class: " \
856 "%![msg-]+n, %![sc-]+S"
858 #define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID \
859 "message-stream-class-has-default-clock-class"
861 #define BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FROM_FUNC(_func, _msg, _sc) \
862 BT_ASSERT_PRE_FROM_FUNC(_func, \
863 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID, \
864 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc), \
865 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FMT, \
868 #define BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS(_msg, _sc) \
869 BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FROM_FUNC(__func__, (_msg), (_sc))
871 #define BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS_FROM_FUNC(_func, _msg, _sc) \
872 BT_ASSERT_PRE_DEV_FROM_FUNC(_func, \
873 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID, \
874 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc), \
875 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FMT, \
878 #define BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS(_msg, _sc) \
879 BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS_FROM_FUNC(__func__, (_msg), (_sc))
881 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_COND(_msg, _type) \
882 (((struct bt_message *) (_msg))->type == (_type))
884 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT \
885 "Message has the wrong type: expected-type=%s, %![msg-]+n"
887 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id) \
888 "is-" _type_id "-message:" _msg_id
890 #define BT_ASSERT_PRE_MSG_HAS_TYPE(_msg_id, _msg, _type_id, _type) \
892 _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id), \
893 _BT_ASSERT_PRE_MSG_HAS_TYPE_COND((_msg), (_type)), \
894 _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT, \
895 bt_common_message_type_string(_type), (_msg))
897 #define BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(_msg_id, _msg, _type_id, _type) \
899 _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id), \
900 _BT_ASSERT_PRE_MSG_HAS_TYPE_COND((_msg), (_type)), \
901 _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT, \
902 bt_common_message_type_string(_type), (_msg))
904 #define _BT_ASSERT_PRE_MSG_NAME "Message"
905 #define _BT_ASSERT_PRE_MSG_ID "message"
907 #define BT_ASSERT_PRE_MSG_NON_NULL(_msg_iter) \
908 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ID, (_msg_iter), \
909 _BT_ASSERT_PRE_MSG_NAME)
911 #define BT_ASSERT_PRE_DEV_MSG_NON_NULL(_msg_iter) \
912 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ID, (_msg_iter), \
913 _BT_ASSERT_PRE_MSG_NAME)
915 #define BT_ASSERT_PRE_MSG_CS_BEGIN_LE_END(_msg_iter, _begin, _end) \
916 BT_ASSERT_PRE("beginning-default-clock-snapshot-lteq-end", \
917 (_begin) <= (_end), \
918 "Beginning default clock snapshot value is greater " \
919 "than end default clock snapshot value: " \
920 "cs-begin-val=%" PRIu64 ", cs-end-val=%" PRIu64 ", " \
921 "%![msg-iter-]+i", (_begin), (_end), _msg_iter);
923 #define BT_ASSERT_PRE_DEV_MSG_HOT(_msg) \
924 BT_ASSERT_PRE_DEV_HOT("message", (_msg), "Message", ": %!+n", (_msg));
926 #define _BT_ASSERT_PRE_MSG_ITER_CLS_NAME "Message iterator class"
927 #define _BT_ASSERT_PRE_MSG_ITER_CLS_ID "message-iterator-class"
929 #define BT_ASSERT_PRE_MSG_ITER_CLS_NON_NULL(_msg_iter_cls) \
930 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_CLS_ID, \
931 (_msg_iter_cls), _BT_ASSERT_PRE_MSG_ITER_CLS_NAME)
933 #define BT_ASSERT_PRE_DEV_MSG_ITER_CLS_NON_NULL(_msg_iter_cls) \
934 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_CLS_ID, \
935 (_msg_iter_cls), _BT_ASSERT_PRE_MSG_ITER_CLS_NAME)
937 #define _BT_ASSERT_PRE_COMP_CLS_NAME "Component class"
938 #define _BT_ASSERT_PRE_COMP_CLS_ID "component-class"
940 #define BT_ASSERT_PRE_COMP_CLS_NON_NULL_FROM_FUNC(_func, _comp_cls) \
941 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
942 _BT_ASSERT_PRE_COMP_CLS_ID, (_comp_cls), \
943 _BT_ASSERT_PRE_COMP_CLS_NAME)
945 #define BT_ASSERT_PRE_COMP_CLS_NON_NULL(_comp_cls) \
946 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_CLS_ID, (_comp_cls), \
947 _BT_ASSERT_PRE_COMP_CLS_NAME)
949 #define BT_ASSERT_PRE_DEV_COMP_CLS_NON_NULL(_comp_cls) \
950 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_CLS_ID, \
951 (_comp_cls), _BT_ASSERT_PRE_COMP_CLS_NAME)
953 #define _BT_ASSERT_PRE_COMP_DESCR_SET_NAME "Component descriptor set"
954 #define _BT_ASSERT_PRE_COMP_DESCR_SET_ID "component-descriptor-set"
956 #define BT_ASSERT_PRE_COMP_DESCR_SET_NON_NULL(_comp_descr_set) \
957 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_DESCR_SET_ID, \
958 (_comp_descr_set), _BT_ASSERT_PRE_COMP_DESCR_SET_NAME)
960 #define BT_ASSERT_PRE_DEV_COMP_DESCR_SET_NON_NULL(_comp_descr_set) \
961 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_DESCR_SET_ID, \
962 (_comp_descr_set), _BT_ASSERT_PRE_COMP_DESCR_SET_NAME)
964 #define _BT_ASSERT_PRE_COMP_NAME "Component"
965 #define _BT_ASSERT_PRE_COMP_ID "component"
967 #define BT_ASSERT_PRE_COMP_NON_NULL_FROM_FUNC(_func, _comp) \
968 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_COMP_ID, \
969 (_comp), _BT_ASSERT_PRE_COMP_NAME)
971 #define BT_ASSERT_PRE_COMP_NON_NULL(_comp) \
972 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_ID, (_comp), \
973 _BT_ASSERT_PRE_COMP_NAME)
975 #define BT_ASSERT_PRE_DEV_COMP_NON_NULL_FROM_FUNC(_func, _comp) \
976 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
977 _BT_ASSERT_PRE_COMP_ID, (_comp), _BT_ASSERT_PRE_COMP_NAME)
979 #define BT_ASSERT_PRE_DEV_COMP_NON_NULL(_comp) \
980 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_ID, (_comp), \
981 _BT_ASSERT_PRE_COMP_NAME)
983 #define _BT_ASSERT_PRE_CONN_NAME "Connection"
984 #define _BT_ASSERT_PRE_CONN_ID "connection"
986 #define BT_ASSERT_PRE_CONN_NON_NULL(_conn) \
987 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CONN_ID, (_conn), \
988 _BT_ASSERT_PRE_CONN_NAME)
990 #define BT_ASSERT_PRE_DEV_CONN_NON_NULL(_conn) \
991 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CONN_ID, (_conn), \
992 _BT_ASSERT_PRE_CONN_NAME)
994 #define _BT_ASSERT_PRE_GRAPH_NAME "Graph"
995 #define _BT_ASSERT_PRE_GRAPH_ID "graph"
997 #define BT_ASSERT_PRE_GRAPH_NON_NULL_FROM_FUNC(_func, _graph) \
998 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
999 _BT_ASSERT_PRE_GRAPH_ID, (_graph), _BT_ASSERT_PRE_GRAPH_NAME)
1001 #define BT_ASSERT_PRE_GRAPH_NON_NULL(_graph) \
1002 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_GRAPH_ID, (_graph), \
1003 _BT_ASSERT_PRE_GRAPH_NAME)
1005 #define BT_ASSERT_PRE_DEV_GRAPH_NON_NULL(_graph) \
1006 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_GRAPH_ID, (_graph), \
1007 _BT_ASSERT_PRE_GRAPH_NAME)
1009 #define _BT_ASSERT_PRE_MIP_VERSION_VALID_ID "mip-version-is-valid"
1011 /* Asserts that the MIP version `_mip_version` is equal to `_val`. */
1012 #define BT_ASSERT_PRE_MIP_VERSION_EQ(_mip_version, _val) \
1013 BT_ASSERT_PRE(_BT_ASSERT_PRE_MIP_VERSION_VALID_ID, \
1014 _mip_version == _val, \
1015 "MIP version is not equal to %" PRIu64, _val)
1017 /* Asserts that the MIP version `_mip_version` is equal to `_val`. */
1018 #define BT_ASSERT_PRE_DEV_MIP_VERSION_EQ(_mip_version, _val) \
1019 BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_MIP_VERSION_VALID_ID, \
1020 _mip_version == _val, \
1021 "MIP version is not equal to %" PRIu64, _val)
1024 * Asserts that the given MIP version `_mip_version` is greater than or equal
1027 #define BT_ASSERT_PRE_MIP_VERSION_GE(_mip_version, _val) \
1028 BT_ASSERT_PRE(_BT_ASSERT_PRE_MIP_VERSION_VALID_ID, \
1029 _mip_version >= _val, \
1030 "MIP version is less than %" PRIu64, _val)
1033 * Asserts that the given MIP version `_mip_version` is greater than or equal
1036 #define BT_ASSERT_PRE_DEV_MIP_VERSION_GE(_mip_version, _val) \
1037 BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_MIP_VERSION_VALID_ID, \
1038 _mip_version >= _val, \
1039 "MIP version is less than %" PRIu64, _val)
1042 * Asserts that the effective MIP version for `_clock_class` is equal to `_val`.
1044 #define BT_ASSERT_PRE_CC_MIP_VERSION_EQ(_clock_class, _val) \
1045 BT_ASSERT_PRE_MIP_VERSION_EQ((_clock_class)->mip_version, _val)
1048 * Asserts that the effective MIP version for `_clock_class` is greater than or
1051 #define BT_ASSERT_PRE_CC_MIP_VERSION_GE(_clock_class, _val) \
1052 BT_ASSERT_PRE_MIP_VERSION_GE((_clock_class)->mip_version, _val)
1055 * Asserts that the effective MIP version for `_trace_class` is equal to `_val`.
1057 #define BT_ASSERT_PRE_TC_MIP_VERSION_EQ(_trace_class, _val) \
1058 BT_ASSERT_PRE_MIP_VERSION_EQ((_trace_class)->mip_version, _val)
1061 * Asserts that the effective MIP version for `_trace_class` is greater than or
1064 #define BT_ASSERT_PRE_TC_MIP_VERSION_GE(_trace_class, _val) \
1065 BT_ASSERT_PRE_MIP_VERSION_GE((_trace_class)->mip_version, _val)
1068 * Asserts that the effective MIP version for `_trace` is greater than or
1071 #define BT_ASSERT_PRE_TRACE_MIP_VERSION_GE(_trace, _val) \
1072 BT_ASSERT_PRE_MIP_VERSION_GE((_trace)->class->mip_version, _val)
1075 * Asserts that the effective MIP version for `_stream_class` is greater than or
1078 #define BT_ASSERT_PRE_SC_MIP_VERSION_GE(_stream_class, _val) \
1079 BT_ASSERT_PRE_TC_MIP_VERSION_GE( \
1080 bt_stream_class_borrow_trace_class_inline(_stream_class), \
1084 * Asserts that the effective MIP version for `_event_class` is greater than or
1087 #define BT_ASSERT_PRE_EC_MIP_VERSION_GE(_event_class, _val) \
1088 BT_ASSERT_PRE_SC_MIP_VERSION_GE( \
1089 bt_event_class_borrow_stream_class_inline(_event_class), \
1093 * Asserts that the effective MIP version for `_field_class` is equal to `_val`.
1095 #define BT_ASSERT_PRE_FC_MIP_VERSION_EQ(_field_class, _val) \
1096 BT_ASSERT_PRE_MIP_VERSION_EQ((_field_class)->mip_version, _val)
1099 * Asserts that the effective MIP version for `_field_class` is equal to `_val`.
1101 #define BT_ASSERT_PRE_DEV_FC_MIP_VERSION_EQ(_field_class, _val) \
1102 BT_ASSERT_PRE_DEV_MIP_VERSION_EQ((_field_class)->mip_version, _val)
1105 * Asserts that the effective MIP version for `_field_class` is greator than or
1108 #define BT_ASSERT_PRE_FC_MIP_VERSION_GE(_field_class, _val) \
1109 BT_ASSERT_PRE_MIP_VERSION_GE((_field_class)->mip_version, _val)
1112 * Asserts that the effective MIP version for `_field_class` is greator than or
1115 #define BT_ASSERT_PRE_DEV_FC_MIP_VERSION_GE(_field_class, _val) \
1116 BT_ASSERT_PRE_DEV_MIP_VERSION_GE((_field_class)->mip_version, _val)
1118 #define _BT_ASSERT_PRE_INTR_NAME "Interrupter"
1119 #define _BT_ASSERT_PRE_INTR_ID "interrupter"
1121 #define BT_ASSERT_PRE_INTR_NON_NULL(_intr) \
1122 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INTR_ID, (_intr), \
1123 _BT_ASSERT_PRE_INTR_NAME)
1125 #define BT_ASSERT_PRE_DEV_INTR_NON_NULL(_intr) \
1126 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INTR_ID, (_intr), \
1127 _BT_ASSERT_PRE_INTR_NAME)
1129 #define _BT_ASSERT_PRE_PORT_NAME "Port"
1130 #define _BT_ASSERT_PRE_PORT_ID "port"
1132 #define BT_ASSERT_PRE_PORT_NON_NULL(_port) \
1133 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PORT_ID, (_port), \
1134 _BT_ASSERT_PRE_PORT_NAME)
1136 #define BT_ASSERT_PRE_DEV_PORT_NON_NULL(_port) \
1137 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PORT_ID, (_port), \
1138 _BT_ASSERT_PRE_PORT_NAME)
1140 #define _BT_ASSERT_PRE_QUERY_EXEC_NAME "Query executor"
1141 #define _BT_ASSERT_PRE_QUERY_EXEC_ID "query-executor"
1143 #define BT_ASSERT_PRE_QUERY_EXEC_NON_NULL(_query_exec) \
1144 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_QUERY_EXEC_ID, \
1145 (_query_exec), _BT_ASSERT_PRE_QUERY_EXEC_NAME)
1147 #define BT_ASSERT_PRE_DEV_QUERY_EXEC_NON_NULL(_query_exec) \
1148 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_QUERY_EXEC_ID, \
1149 (_query_exec), _BT_ASSERT_PRE_QUERY_EXEC_NAME)
1151 #define _BT_ASSERT_PRE_PLUGIN_SET_NAME "Plugin set"
1152 #define _BT_ASSERT_PRE_PLUGIN_SET_ID "plugin-set"
1154 #define BT_ASSERT_PRE_PLUGIN_SET_NON_NULL(_plugin_set) \
1155 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_ID, \
1156 (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_NAME)
1158 #define BT_ASSERT_PRE_DEV_PLUGIN_SET_NON_NULL(_plugin_set) \
1159 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_ID, \
1160 (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_NAME)
1162 #define _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME \
1163 _BT_ASSERT_PRE_PLUGIN_SET_NAME " (output)"
1164 #define _BT_ASSERT_PRE_PLUGIN_SET_OUT_ID \
1165 _BT_ASSERT_PRE_PLUGIN_SET_ID "-output"
1167 #define BT_ASSERT_PRE_PLUGIN_SET_OUT_NON_NULL(_plugin_set) \
1168 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_OUT_ID, \
1169 (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME)
1171 #define BT_ASSERT_PRE_DEV_PLUGIN_SET_OUT_NON_NULL(_plugin_set) \
1172 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_OUT_ID, \
1173 (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME)
1175 #define _BT_ASSERT_PRE_PLUGIN_NAME "Plugin"
1176 #define _BT_ASSERT_PRE_PLUGIN_ID "plugin"
1178 #define BT_ASSERT_PRE_PLUGIN_NON_NULL(_plugin) \
1179 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_ID, (_plugin), \
1180 _BT_ASSERT_PRE_PLUGIN_NAME)
1182 #define BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(_plugin) \
1183 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_ID, (_plugin), \
1184 _BT_ASSERT_PRE_PLUGIN_NAME)
1186 #define _BT_ASSERT_PRE_PLUGIN_OUT_NAME \
1187 _BT_ASSERT_PRE_PLUGIN_NAME " (output)"
1188 #define _BT_ASSERT_PRE_PLUGIN_OUT_ID \
1189 _BT_ASSERT_PRE_PLUGIN_ID "-output"
1191 #define BT_ASSERT_PRE_PLUGIN_OUT_NON_NULL(_plugin) \
1192 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_OUT_ID, (_plugin), \
1193 _BT_ASSERT_PRE_PLUGIN_OUT_NAME)
1195 #define BT_ASSERT_PRE_DEV_PLUGIN_OUT_NON_NULL(_plugin) \
1196 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_OUT_ID, \
1197 (_plugin), _BT_ASSERT_PRE_PLUGIN_OUT_NAME)
1199 #define _BT_ASSERT_PRE_ERROR_NAME "Error"
1200 #define _BT_ASSERT_PRE_ERROR_ID "error"
1202 #define BT_ASSERT_PRE_ERROR_NON_NULL(_error) \
1203 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_ERROR_ID, (_error), \
1204 _BT_ASSERT_PRE_ERROR_NAME)
1206 #define BT_ASSERT_PRE_DEV_ERROR_NON_NULL(_error) \
1207 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_ERROR_ID, (_error), \
1208 _BT_ASSERT_PRE_ERROR_NAME)
1210 #define _BT_ASSERT_PRE_ERROR_CAUSE_NAME "Error cause"
1211 #define _BT_ASSERT_PRE_ERROR_CAUSE_ID "error-cause"
1213 #define BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(_error_cause) \
1214 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_ERROR_CAUSE_ID, \
1215 (_error_cause), _BT_ASSERT_PRE_ERROR_CAUSE_NAME)
1217 #define BT_ASSERT_PRE_DEV_ERROR_CAUSE_NON_NULL(_error_cause) \
1218 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_ERROR_CAUSE_ID, \
1219 (_error_cause), _BT_ASSERT_PRE_ERROR_CAUSE_NAME)
1221 #define _BT_ASSERT_PRE_INT_RANGE_NAME "Integer range"
1222 #define _BT_ASSERT_PRE_INT_RANGE_ID "integer-range"
1224 #define BT_ASSERT_PRE_INT_RANGE_NON_NULL(_int_range) \
1225 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_ID, \
1226 (_int_range), _BT_ASSERT_PRE_INT_RANGE_NAME)
1228 #define BT_ASSERT_PRE_DEV_INT_RANGE_NON_NULL(_int_range) \
1229 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_ID, \
1230 (_int_range), _BT_ASSERT_PRE_INT_RANGE_NAME)
1232 #define BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY_FROM_FUNC(_func, _range_set) \
1233 BT_ASSERT_PRE_FROM_FUNC(_func, "integer-range-set-is-not-empty", \
1234 (_range_set)->ranges->len > 0, \
1235 "Integer range set is empty: %!+R", (_range_set))
1237 #define BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY(_range_set) \
1238 BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY_FROM_FUNC(__func__, \
1241 #define _BT_ASSERT_PRE_INT_RANGE_SET_NAME "Integer range set"
1242 #define _BT_ASSERT_PRE_INT_RANGE_SET_ID "integer-range-set"
1244 #define BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL_FROM_FUNC(_func, _range_set) \
1245 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
1246 _BT_ASSERT_PRE_INT_RANGE_SET_ID, (_range_set), \
1247 _BT_ASSERT_PRE_INT_RANGE_SET_NAME)
1249 #define BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL(_range_set) \
1250 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_SET_ID, \
1251 (_range_set), _BT_ASSERT_PRE_INT_RANGE_SET_NAME)
1253 #define BT_ASSERT_PRE_DEV_INT_RANGE_SET_NON_NULL(_range_set) \
1254 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_SET_ID, \
1255 (_range_set), _BT_ASSERT_PRE_INT_RANGE_SET_NAME)
1257 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND(_value, _type) \
1258 (((struct bt_value *) (_value))->type == (_type))
1260 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT \
1261 "Value has the wrong type: expected-type=%s, %![value-]+v"
1263 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id) \
1264 "is-" _type_id "-value:" _value_id
1266 #define BT_ASSERT_PRE_VALUE_HAS_TYPE_FROM_FUNC(_func, _value_id, _value, _type_id, _type) \
1267 BT_ASSERT_PRE_FROM_FUNC(_func, \
1268 _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id), \
1269 _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND((_value), (_type)), \
1270 _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT, \
1271 bt_common_value_type_string(_type), (_value))
1273 #define BT_ASSERT_PRE_VALUE_HAS_TYPE(_value_id, _value, _type_id, _type) \
1274 BT_ASSERT_PRE_VALUE_HAS_TYPE_FROM_FUNC(__func__, _value_id, \
1275 (_value), _type_id, (_type));
1277 #define BT_ASSERT_PRE_VALUE_IS_BOOL(_value) \
1278 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1279 "boolean", BT_VALUE_TYPE_BOOL);
1281 #define BT_ASSERT_PRE_VALUE_IS_UNSIGNED_INT(_value) \
1282 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1283 "unsigned-int", BT_VALUE_TYPE_UNSIGNED_INTEGER);
1285 #define BT_ASSERT_PRE_VALUE_IS_SIGNED_INT(_value) \
1286 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1287 "signed-int", BT_VALUE_TYPE_SIGNED_INTEGER);
1289 #define BT_ASSERT_PRE_VALUE_IS_REAL(_value) \
1290 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1291 "real", BT_VALUE_TYPE_REAL);
1293 #define BT_ASSERT_PRE_VALUE_IS_STRING(_value) \
1294 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1295 "string", BT_VALUE_TYPE_STRING);
1297 #define BT_ASSERT_PRE_VALUE_IS_ARRAY(_value) \
1298 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1299 "array", BT_VALUE_TYPE_ARRAY);
1301 #define BT_ASSERT_PRE_VALUE_IS_MAP_FROM_FUNC(_func, _value) \
1302 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1303 "map", BT_VALUE_TYPE_MAP);
1305 #define BT_ASSERT_PRE_VALUE_IS_MAP(_value) \
1306 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1307 "map", BT_VALUE_TYPE_MAP);
1309 #define BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(_value_id, _value, _type_id, _type) \
1310 BT_ASSERT_PRE_DEV( \
1311 _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id), \
1312 _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND((_value), (_type)), \
1313 _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT, \
1314 bt_common_value_type_string(_type), (_value))
1316 #define BT_ASSERT_PRE_DEV_VALUE_IS_BOOL(_value) \
1317 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1318 "boolean", BT_VALUE_TYPE_BOOL);
1320 #define BT_ASSERT_PRE_DEV_VALUE_IS_UNSIGNED_INT(_value) \
1321 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1322 "unsigned-int", BT_VALUE_TYPE_UNSIGNED_INTEGER);
1324 #define BT_ASSERT_PRE_DEV_VALUE_IS_SIGNED_INT(_value) \
1325 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1326 "signed-int", BT_VALUE_TYPE_SIGNED_INTEGER);
1328 #define BT_ASSERT_PRE_DEV_VALUE_IS_REAL(_value) \
1329 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1330 "real", BT_VALUE_TYPE_REAL);
1332 #define BT_ASSERT_PRE_DEV_VALUE_IS_STRING(_value) \
1333 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1334 "string", BT_VALUE_TYPE_STRING);
1336 #define BT_ASSERT_PRE_DEV_VALUE_IS_ARRAY(_value) \
1337 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1338 "array", BT_VALUE_TYPE_ARRAY);
1340 #define BT_ASSERT_PRE_DEV_VALUE_IS_MAP(_value) \
1341 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1342 "map", BT_VALUE_TYPE_MAP);
1344 #define _BT_ASSERT_PRE_VALUE_NAME "Value object"
1345 #define _BT_ASSERT_PRE_VALUE_ID "value-object"
1347 #define BT_ASSERT_PRE_VALUE_NON_NULL_FROM_FUNC(_func, _value) \
1348 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
1349 _BT_ASSERT_PRE_VALUE_ID, (_value), _BT_ASSERT_PRE_VALUE_NAME)
1351 #define BT_ASSERT_PRE_VALUE_NON_NULL(_value) \
1352 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_VALUE_ID, (_value), \
1353 _BT_ASSERT_PRE_VALUE_NAME)
1355 #define BT_ASSERT_PRE_DEV_VALUE_NON_NULL_FROM_FUNC(_func, _value) \
1356 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
1357 _BT_ASSERT_PRE_VALUE_ID, (_value), _BT_ASSERT_PRE_VALUE_NAME)
1359 #define BT_ASSERT_PRE_DEV_VALUE_NON_NULL(_value) \
1360 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_VALUE_ID, (_value), \
1361 _BT_ASSERT_PRE_VALUE_NAME)
1363 #define BT_ASSERT_PRE_PARAM_VALUE_IS_MAP_FROM_FUNC(_func, _value) \
1364 BT_ASSERT_PRE_FROM_FUNC(_func, \
1365 "is-map-value:parameters-value-object", \
1366 !(_value) || bt_value_is_map(_value), \
1367 "Parameters value object is not a map value: %!+v", (_value));
1369 #define BT_ASSERT_PRE_PARAM_VALUE_IS_MAP(_value) \
1370 BT_ASSERT_PRE_PARAM_VALUE_IS_MAP_FROM_FUNC(__func__, (_value))
1372 #define _BT_ASSERT_PRE_RES_OUT_NAME "Result (output)"
1373 #define _BT_ASSERT_PRE_RES_OUT_ID "result-output"
1375 #define BT_ASSERT_PRE_RES_OUT_NON_NULL(_res) \
1376 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_RES_OUT_ID, (_res), \
1377 _BT_ASSERT_PRE_RES_OUT_NAME)
1379 #define BT_ASSERT_PRE_DEV_RES_OUT_NON_NULL(_res) \
1380 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_RES_OUT_ID, (_res), \
1381 _BT_ASSERT_PRE_RES_OUT_NAME)
1383 #define BT_ASSERT_PRE_METHOD_NON_NULL(_method) \
1384 BT_ASSERT_PRE_NON_NULL("method", (_method), "Method");
1386 #define _BT_ASSERT_PRE_NAME_NAME "Name"
1387 #define _BT_ASSERT_PRE_NAME_ID "name"
1389 #define BT_ASSERT_PRE_NAME_NON_NULL_FROM_FUNC(_func, _name) \
1390 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_NAME_ID, \
1391 (_name), _BT_ASSERT_PRE_NAME_NAME)
1393 #define BT_ASSERT_PRE_NAME_NON_NULL(_name) \
1394 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_NAME_ID, (_name), \
1395 _BT_ASSERT_PRE_NAME_NAME)
1397 #define BT_ASSERT_PRE_DEV_NAME_NON_NULL_FROM_FUNC(_func, _name) \
1398 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
1399 _BT_ASSERT_PRE_NAME_ID, (_name), _BT_ASSERT_PRE_NAME_NAME)
1401 #define BT_ASSERT_PRE_DEV_NAME_NON_NULL(_name) \
1402 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_NAME_ID, (_name), \
1403 _BT_ASSERT_PRE_NAME_NAME)
1405 #define _BT_ASSERT_PRE_NAMESPACE_NAME "Namespace"
1406 #define _BT_ASSERT_PRE_NAMESPACE_ID "namespace"
1408 #define BT_ASSERT_PRE_NAMESPACE_NON_NULL(_namespace) \
1409 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_NAMESPACE_ID, (_namespace), \
1410 _BT_ASSERT_PRE_NAMESPACE_NAME)
1412 #define _BT_ASSERT_PRE_DESCR_NAME "Description"
1413 #define _BT_ASSERT_PRE_DESCR_ID "description"
1415 #define BT_ASSERT_PRE_DESCR_NON_NULL(_descr) \
1416 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_DESCR_ID, (_descr), \
1417 _BT_ASSERT_PRE_DESCR_NAME)
1419 #define BT_ASSERT_PRE_DEV_DESCR_NON_NULL(_descr) \
1420 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_DESCR_ID, (_descr), \
1421 _BT_ASSERT_PRE_DESCR_NAME)
1423 #define _BT_ASSERT_PRE_UUID_NAME "UUID"
1424 #define _BT_ASSERT_PRE_UUID_ID "uuid"
1426 #define BT_ASSERT_PRE_UUID_NON_NULL(_uuid) \
1427 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_UUID_ID, (_uuid), \
1428 _BT_ASSERT_PRE_UUID_NAME)
1430 #define BT_ASSERT_PRE_DEV_UUID_NON_NULL(_uuid) \
1431 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_UUID_ID, (_uuid), \
1432 _BT_ASSERT_PRE_UUID_NAME)
1434 #define _BT_ASSERT_PRE_UID_NAME "Unique identifier"
1435 #define _BT_ASSERT_PRE_UID_ID "uid"
1437 #define BT_ASSERT_PRE_UID_NON_NULL(_uid) \
1438 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_UID_ID, (_uid), \
1439 _BT_ASSERT_PRE_UID_NAME)
1441 #define _BT_ASSERT_PRE_KEY_NAME "Key"
1442 #define _BT_ASSERT_PRE_KEY_ID "key"
1444 #define BT_ASSERT_PRE_KEY_NON_NULL_FROM_FUNC(_func, _key) \
1445 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_KEY_ID, \
1446 (_key), _BT_ASSERT_PRE_KEY_NAME)
1448 #define BT_ASSERT_PRE_KEY_NON_NULL(_key) \
1449 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_KEY_ID, (_key), \
1450 _BT_ASSERT_PRE_KEY_NAME)
1452 #define BT_ASSERT_PRE_DEV_KEY_NON_NULL(_key) \
1453 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_KEY_ID, (_key), \
1454 _BT_ASSERT_PRE_KEY_NAME)
1456 #endif /* BABELTRACE_LIB_ASSERT_COND_H */
This page took 0.055437 seconds and 5 git commands to generate.