* SOFTWARE.
*/
+#define BT_LOG_OUTPUT_LEVEL (bfcr->log_level)
#define BT_LOG_TAG "PLUGIN/CTF/BFCR"
-#include "logging.h"
+#include "logging/log.h"
#include <stdlib.h>
#include <stdint.h>
int64_t index;
};
+struct bt_bfcr;
+
/* Visit stack */
struct stack {
+ struct bt_bfcr *bfcr;
+
/* Entries (struct stack_entry) */
GArray *entries;
/* Binary class reader */
struct bt_bfcr {
- /* Bisit stack */
+ bt_logging_level log_level;
+
+ /* BFCR stack */
struct stack *stack;
/* Current basic field class */
}
static
-struct stack *stack_new(void)
+struct stack *stack_new(struct bt_bfcr *bfcr)
{
struct stack *stack = NULL;
goto error;
}
+ stack->bfcr = bfcr;
stack->entries = g_array_new(FALSE, TRUE, sizeof(struct stack_entry));
if (!stack->entries) {
BT_LOGE_STR("Failed to allocate a GArray.");
static
void stack_destroy(struct stack *stack)
{
+ struct bt_bfcr *bfcr;
+
if (!stack) {
return;
}
+ bfcr = stack->bfcr;
BT_LOGD("Destroying stack: addr=%p", stack);
if (stack->entries) {
size_t base_len)
{
struct stack_entry *entry;
+ struct bt_bfcr *bfcr;
BT_ASSERT(stack);
BT_ASSERT(base_class);
+ bfcr = stack->bfcr;
BT_LOGV("Pushing field class on stack: stack-addr=%p, "
"fc-addr=%p, fc-type=%d, base-length=%zu, "
"stack-size-before=%zu, stack-size-after=%zu",
static
void stack_pop(struct stack *stack)
{
+ struct bt_bfcr *bfcr;
+
BT_ASSERT(stack);
BT_ASSERT(stack_size(stack));
+ bfcr = stack->bfcr;
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 inline
-void read_unsigned_bitfield(const uint8_t *buf, size_t at,
+void read_unsigned_bitfield(struct bt_bfcr *bfcr, const uint8_t *buf, size_t at,
unsigned int field_size, enum ctf_byte_order bo,
uint64_t *v)
{
}
static inline
-void read_signed_bitfield(const uint8_t *buf, size_t at,
+void read_signed_bitfield(struct bt_bfcr *bfcr, const uint8_t *buf, size_t at,
unsigned int field_size, enum ctf_byte_order bo, int64_t *v)
{
switch (bo) {
float f;
} f32;
- read_unsigned_bitfield(buf, at, field_size, bo, &v);
+ read_unsigned_bitfield(bfcr, buf, at, field_size, bo, &v);
f32.u = (uint32_t) v;
dblval = (double) f32.f;
break;
double d;
} f64;
- read_unsigned_bitfield(buf, at, field_size, bo, &f64.u);
+ read_unsigned_bitfield(bfcr, buf, at, field_size, bo, &f64.u);
dblval = f64.d;
break;
}
if (fc->is_signed) {
int64_t v;
- read_signed_bitfield(buf, at, field_size, bo, &v);
+ read_signed_bitfield(bfcr, buf, at, field_size, bo, &v);
if (bfcr->user.cbs.classes.signed_int) {
BT_LOGV("Calling user function (signed integer).");
} else {
uint64_t v;
- read_unsigned_bitfield(buf, at, field_size, bo, &v);
+ read_unsigned_bitfield(bfcr, buf, at, field_size, bo, &v);
if (bfcr->user.cbs.classes.unsigned_int) {
BT_LOGV("Calling user function (unsigned integer).");
}
BT_HIDDEN
-struct bt_bfcr *bt_bfcr_create(struct bt_bfcr_cbs cbs, void *data)
+struct bt_bfcr *bt_bfcr_create(struct bt_bfcr_cbs cbs, void *data,
+ bt_logging_level log_level)
{
struct bt_bfcr *bfcr;
- BT_LOGD_STR("Creating binary field class reader (BFCR).");
+ BT_LOG_WRITE_CUR_LVL(BT_LOG_DEBUG, log_level, BT_LOG_TAG,
+ "Creating binary field class reader (BFCR).");
bfcr = g_new0(struct bt_bfcr, 1);
if (!bfcr) {
- BT_LOGE_STR("Failed to allocate one binary class reader.");
+ BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+ "Failed to allocate one binary class reader.");
goto end;
}
- bfcr->stack = stack_new();
+ bfcr->log_level = log_level;
+ bfcr->stack = stack_new(bfcr);
if (!bfcr->stack) {
BT_LOGE_STR("Cannot create BFCR's stack.");
bt_bfcr_destroy(bfcr);