Fix: lib: pass down API function name to some helpers
Let's say I change bt_field_structure_borrow_member_field_by_index to
pass an invalid index (e.g. 99999) to
borrow_structure_field_member_field_by_index, to exercise the "valid
index" precondition assertion, I get:
(╯°□°)╯︵ ┻━┻ /home/simark/src/babeltrace/src/lib/assert-cond.c:33: format_cond_id(): Assertion `strstr(func, func_prefix) == func` failed.
This is because `format_cond_id` expects to receive the name of the API
function called by the user, starting with `bt_`. But it's the name of
the `borrow_structure_field_member_field_by_index` helper that is passed
down to `format_cond_id`, instead.
Change some helpers in lib/trace-ir/field.c to pass down the API
function name to their helper, to avoid this. Add some necessary
"FROM_FUNC" version of assertions used by these helpers.
Introducing the same "bug", I get the expected precondition assertion
failure message:
05-07 21:54:06.709
2194353 2194353 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:65 Babeltrace 2 library precondition not satisfied.
05-07 21:54:06.709
2194353 2194353 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:66 ------------------------------------------------------------------------
05-07 21:54:06.709
2194353 2194353 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:67 Condition ID: `pre:field-structure-borrow-member-field-by-index:valid-index`.
05-07 21:54:06.709
2194353 2194353 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:69 Function: bt_field_structure_borrow_member_field_by_index().
05-07 21:54:06.709
2194353 2194353 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:70 ------------------------------------------------------------------------
05-07 21:54:06.709
2194353 2194353 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:71 Error is:
05-07 21:54:06.709
2194353 2194353 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:73 Index is out of bounds: index=99999, count=1
05-07 21:54:06.709
2194353 2194353 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:76 Aborting...
Change-Id: Id3c310a3c5c46358532657d38d867c5ed802df78
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8002
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
CI-Build: Simon Marchi <simon.marchi@efficios.com>