* 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);
+++ /dev/null
-/*
- * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define BT_LOG_OUTPUT_LEVEL bfcr_log_level
-#include "logging/log.h"
-
-BT_LOG_INIT_LOG_LEVEL(bfcr_log_level, "BABELTRACE_PLUGIN_CTF_BFCR_LOG_LEVEL");
+++ /dev/null
-#ifndef CTF_BFCR_LOGGING_H
-#define CTF_BFCR_LOGGING_H
-
-/*
- * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define BT_LOG_OUTPUT_LEVEL bfcr_log_level
-#include "logging/log.h"
-
-BT_LOG_LEVEL_EXTERN_SYMBOL(bfcr_log_level);
-
-#endif /* CTF_BFCR_LOGGING_H */