#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>
-#include <assert.h>
+#include <babeltrace/assert-internal.h>
#include <string.h>
#include <babeltrace/bitfield-internal.h>
+#include <babeltrace/common-internal.h>
#include <babeltrace/babeltrace.h>
-#include <babeltrace/ctf-ir/field-types-internal.h>
#include <babeltrace/ref.h>
#include <babeltrace/align-internal.h>
#include <glib.h>
BT_LOGW("Cannot get field type's field count: btr-addr=%p, "
"ft-addr=%p, ft-id=%s",
btr, field_type,
- bt_field_type_id_string(
+ bt_common_field_type_id_string(
bt_field_type_get_type_id(field_type)));
length = BT_BTR_STATUS_ERROR;
}
int ret = 0;
struct stack_entry *entry;
- assert(stack);
- assert(base_type);
+ BT_ASSERT(stack);
+ BT_ASSERT(base_type);
BT_LOGV("Pushing field type on stack: stack-addr=%p, "
"ft-addr=%p, ft-id=%s, base-length=%zu, "
"stack-size-before=%u, stack-size-after=%u",
- stack, base_type, bt_field_type_id_string(
+ stack, base_type, bt_common_field_type_id_string(
bt_field_type_get_type_id(base_type)),
base_len, stack->entries->len, stack->entries->len + 1);
entry = g_new0(struct stack_entry, 1);
if (base_len < 0) {
BT_LOGW("Cannot get compound field type's field count: "
"btr-addr=%p, ft-addr=%p, ft-id=%s",
- btr, base_type, bt_field_type_id_string(
+ btr, base_type, bt_common_field_type_id_string(
bt_field_type_get_type_id(base_type)));
ret = BT_BTR_STATUS_ERROR;
goto end;
static inline
unsigned int stack_size(struct stack *stack)
{
- assert(stack);
+ BT_ASSERT(stack);
return stack->entries->len;
}
static
void stack_pop(struct stack *stack)
{
- assert(stack);
- assert(stack_size(stack));
+ BT_ASSERT(stack);
+ BT_ASSERT(stack_size(stack));
BT_LOGV("Popping from stack: "
"stack-addr=%p, stack-size-before=%u, stack-size-after=%u",
stack, stack->entries->len, stack->entries->len - 1);
static
void stack_clear(struct stack *stack)
{
- assert(stack);
+ BT_ASSERT(stack);
if (!stack_empty(stack)) {
g_ptr_array_remove_range(stack->entries, 0, stack_size(stack));
}
- assert(stack_empty(stack));
+ BT_ASSERT(stack_empty(stack));
}
static inline
struct stack_entry *stack_top(struct stack *stack)
{
- assert(stack);
- assert(stack_size(stack));
+ BT_ASSERT(stack);
+ BT_ASSERT(stack_size(stack));
return g_ptr_array_index(stack->entries, stack->entries->len - 1);
}
mant_dig =
bt_field_type_floating_point_get_mantissa_digits(
field_type);
- assert(exp_dig >= 0);
- assert(mant_dig >= 0);
+ BT_ASSERT(exp_dig >= 0);
+ BT_ASSERT(mant_dig >= 0);
size = exp_dig + mant_dig;
break;
}
{
struct bt_field_type *int_type;
- int_type = bt_field_type_enumeration_get_container_type(
+ int_type = bt_field_type_enumeration_get_container_field_type(
field_type);
- assert(int_type);
+ BT_ASSERT(int_type);
size = get_basic_field_type_size(btr, int_type);
BT_PUT(int_type);
break;
BITS_TO_BYTES_FLOOR(stitch_at_from_addr(btr));
buf_byte_at = BITS_TO_BYTES_FLOOR(buf_at_from_addr(btr));
nb_bytes = BITS_TO_BYTES_CEIL(sz);
- assert(nb_bytes > 0);
- assert(btr->buf.addr);
+ BT_ASSERT(nb_bytes > 0);
+ BT_ASSERT(btr->buf.addr);
memcpy(&btr->stitch.buf[stitch_byte_at], &btr->buf.addr[buf_byte_at],
nb_bytes);
btr->stitch.at += sz;
BT_LOGV("Read unsigned bit array: cur=%zu, size=%" PRId64 ", "
"bo=%s, val=%" PRIu64, at, field_size,
- bt_byte_order_string(bo), *v);
+ bt_common_byte_order_string(bo), *v);
return status;
}
BT_LOGV("Read signed bit array: cur=%zu, size=%" PRId64 ", "
"bo=%s, val=%" PRId64, at, field_size,
- bt_byte_order_string(bo), *v);
+ bt_common_byte_order_string(bo), *v);
return status;
}
if (status < 0) {
BT_LOGW("Cannot read bit array: two different byte orders not at a byte boundary: "
"btr-addr=%p, last-bo=%s, next-bo=%s",
- btr, bt_byte_order_string(btr->last_bo),
- bt_byte_order_string(next_bo));
+ btr, bt_common_byte_order_string(btr->last_bo),
+ bt_common_byte_order_string(next_bo));
}
return status;
ret = bt_field_type_floating_point_get_mantissa_digits(
btr->cur_basic_field_type);
- assert(ret == 24);
+ BT_ASSERT(ret == 24);
ret = bt_field_type_floating_point_get_exponent_digits(
btr->cur_basic_field_type);
- assert(ret == 8);
+ BT_ASSERT(ret == 8);
status = read_unsigned_bitfield(buf, at, field_size, bo, &v);
if (status != BT_BTR_STATUS_OK) {
BT_LOGW("Cannot read unsigned 32-bit bit array for floating point number field: "
ret = bt_field_type_floating_point_get_mantissa_digits(
btr->cur_basic_field_type);
- assert(ret == 53);
+ BT_ASSERT(ret == 53);
ret = bt_field_type_floating_point_get_exponent_digits(
btr->cur_basic_field_type);
- assert(ret == 11);
+ BT_ASSERT(ret == 11);
status = read_unsigned_bitfield(buf, at, field_size, bo,
&f64.u);
if (status != BT_BTR_STATUS_OK) {
struct bt_field_type *int_field_type;
enum bt_btr_status status = BT_BTR_STATUS_OK;
- int_field_type = bt_field_type_enumeration_get_container_type(
+ int_field_type = bt_field_type_enumeration_get_container_field_type(
btr->cur_basic_field_type);
- assert(int_field_type);
+ BT_ASSERT(int_field_type);
status = read_basic_int_and_call(btr, buf, at,
int_field_type, btr->cur_basic_field_type);
bt_put(int_field_type);
if (field_size <= available) {
/* We have all the bits; decode and set now */
- assert(btr->buf.addr);
+ BT_ASSERT(btr->buf.addr);
status = read_basic_and_call_cb(btr, btr->buf.addr,
buf_at_from_addr(btr));
if (status != BT_BTR_STATUS_OK) {
goto end;
}
- assert(buf_at_from_addr(btr) % 8 == 0);
+ BT_ASSERT(buf_at_from_addr(btr) % 8 == 0);
available_bytes = BITS_TO_BYTES_FLOOR(available_bits(btr));
buf_at_bytes = BITS_TO_BYTES_FLOOR(buf_at_from_addr(btr));
- assert(btr->buf.addr);
+ BT_ASSERT(btr->buf.addr);
first_chr = &btr->buf.addr[buf_at_bytes];
result = memchr(first_chr, '\0', available_bytes);
{
enum bt_btr_status status;
- assert(btr->cur_basic_field_type);
+ BT_ASSERT(btr->cur_basic_field_type);
switch (bt_field_type_get_type_id(btr->cur_basic_field_type)) {
case BT_FIELD_TYPE_ID_INTEGER:
BT_LOGF("Unknown basic field type ID: "
"btr-addr=%p, ft-addr=%p, ft-id=%s",
btr, btr->cur_basic_field_type,
- bt_field_type_id_string(
+ bt_common_field_type_id_string(
bt_field_type_get_type_id(
btr->cur_basic_field_type)));
abort();
{
enum bt_btr_status status;
- assert(btr->cur_basic_field_type);
+ BT_ASSERT(btr->cur_basic_field_type);
switch (bt_field_type_get_type_id(btr->cur_basic_field_type)) {
case BT_FIELD_TYPE_ID_INTEGER:
BT_LOGF("Unknown basic field type ID: "
"btr-addr=%p, ft-addr=%p, ft-id=%s",
btr, btr->cur_basic_field_type,
- bt_field_type_id_string(
+ bt_common_field_type_id_string(
bt_field_type_get_type_id(
btr->cur_basic_field_type)));
abort();
BT_LOGW("Cannot get field type's alignment: "
"btr-addr=%p, ft-addr=%p, ft-id=%s",
btr, field_type,
- bt_field_type_id_string(
+ bt_common_field_type_id_string(
bt_field_type_get_type_id(field_type)));
status = BT_BTR_STATUS_ERROR;
goto end;
break;
case BT_FIELD_TYPE_ID_ARRAY:
next_field_type =
- bt_field_type_array_get_element_type(
+ bt_field_type_array_get_element_field_type(
top->base_type);
break;
case BT_FIELD_TYPE_ID_SEQUENCE:
next_field_type =
- bt_field_type_sequence_get_element_type(
+ bt_field_type_sequence_get_element_field_type(
top->base_type);
break;
case BT_FIELD_TYPE_ID_VARIANT:
"btr-addr=%p, base-ft-addr=%p, base-ft-id=%s, "
"index=%" PRId64,
btr, top->base_type,
- bt_field_type_id_string(
+ bt_common_field_type_id_string(
bt_field_type_get_type_id(top->base_type)),
top->index);
status = BT_BTR_STATUS_ERROR;
size_t offset, size_t packet_offset, size_t sz,
enum bt_btr_status *status)
{
- assert(btr);
- assert(BYTES_TO_BITS(sz) >= offset);
+ BT_ASSERT(btr);
+ BT_ASSERT(BYTES_TO_BITS(sz) >= offset);
reset(btr);
btr->buf.addr = buf;
btr->buf.offset = offset;
const uint8_t *buf, size_t sz,
enum bt_btr_status *status)
{
- assert(btr);
- assert(buf);
- assert(sz > 0);
+ BT_ASSERT(btr);
+ BT_ASSERT(buf);
+ BT_ASSERT(sz > 0);
btr->buf.addr = buf;
btr->buf.offset = 0;
btr->buf.at = 0;