struct ctf_node *node);
BT_HIDDEN
-int ctf_visitor_semantic_check(int depth, struct ctf_node *node);
+int ctf_visitor_semantic_check(int depth, struct ctf_node *node,
+ bt_logging_level log_level);
BT_HIDDEN
-int ctf_visitor_parent_links(int depth, struct ctf_node *node);
+int ctf_visitor_parent_links(int depth, struct ctf_node *node,
+ bt_logging_level log_level);
#endif /* _CTF_AST_H */
* all copies or substantial portions of the Software.
*/
+#define BT_LOG_OUTPUT_LEVEL (ctx->log_level)
#define BT_LOG_TAG "PLUGIN/CTF/META/RESOLVE"
-#include "logging.h"
+#include "logging/log.h"
#include <babeltrace2/babeltrace.h>
#include "common/macros.h"
* The current context of the resolving engine.
*/
struct resolve_context {
+ bt_logging_level log_level;
struct ctf_trace_class *tc;
struct ctf_stream_class *sc;
struct ctf_event_class *ec;
* Pushes a field class onto a class stack.
*/
static
-int field_class_stack_push(field_class_stack *stack, struct ctf_field_class *fc)
+int field_class_stack_push(field_class_stack *stack, struct ctf_field_class *fc,
+ struct resolve_context *ctx)
{
int ret = 0;
struct field_class_stack_frame *frame = NULL;
* Removes the top frame of `stack`.
*/
static
-void field_class_stack_pop(field_class_stack *stack)
+void field_class_stack_pop(field_class_stack *stack,
+ struct resolve_context *ctx)
{
if (!field_class_stack_empty(stack)) {
/*
* is found to be relative.
*/
static
-enum ctf_scope get_root_scope_from_absolute_pathstr(const char *pathstr)
+enum ctf_scope get_root_scope_from_absolute_pathstr(const char *pathstr,
+ struct resolve_context *ctx)
{
enum ctf_scope scope;
enum ctf_scope ret = -1;
* strings.
*/
static
-GList *pathstr_to_ptokens(const char *pathstr)
+GList *pathstr_to_ptokens(const char *pathstr, struct resolve_context *ctx)
{
const char *at = pathstr;
const char *last = at;
*/
static
int ptokens_to_field_path(GList *ptokens, struct ctf_field_path *field_path,
- struct ctf_field_class *fc, int64_t src_index)
+ struct ctf_field_class *fc, int64_t src_index,
+ struct resolve_context *ctx)
{
int ret = 0;
GList *cur_ptoken = ptokens;
}
/* Locate target */
- ret = ptokens_to_field_path(cur_ptoken, field_path, fc, INT64_MAX);
+ ret = ptokens_to_field_path(cur_ptoken, field_path, fc, INT64_MAX, ctx);
end:
return ret;
/* Locate target from current parent class */
ret = ptokens_to_field_path(ptokens, &tail_field_path,
- parent_class, cur_index);
+ parent_class, cur_index, ctx);
if (ret) {
/* Not found... yet */
BT_LOGD_STR("Not found at this point.");
GList *ptokens = NULL;
/* Convert path string to path tokens */
- ptokens = pathstr_to_ptokens(pathstr);
+ ptokens = pathstr_to_ptokens(pathstr, ctx);
if (!ptokens) {
BT_LOGE("Cannot convert path string to path tokens: "
"path=\"%s\"", pathstr);
}
/* Absolute or relative path? */
- root_scope = get_root_scope_from_absolute_pathstr(pathstr);
+ root_scope = get_root_scope_from_absolute_pathstr(pathstr, ctx);
if (root_scope == -1) {
/* Relative path: start with current root scope */
* objects having the same root scope.
*/
int64_t get_field_paths_lca_index(struct ctf_field_path *field_path1,
- struct ctf_field_path *field_path2)
+ struct ctf_field_path *field_path2,
+ struct resolve_context *ctx)
{
int64_t lca_index = 0;
uint64_t field_path1_len, field_path2_len;
* paths.
*/
lca_index = get_field_paths_lca_index(target_field_path,
- &ctx_field_path);
+ &ctx_field_path, ctx);
if (lca_index < 0) {
BT_LOGE_STR("Cannot get least common ancestor.");
ret = -1;
uint64_t field_count =
ctf_field_class_compound_get_field_class_count(fc);
- ret = field_class_stack_push(ctx->field_class_stack, fc);
+ ret = field_class_stack_push(ctx->field_class_stack, fc, ctx);
if (ret) {
BT_LOGE("Cannot push field class on context's stack: "
"fc-addr=%p", fc);
}
}
- field_class_stack_pop(ctx->field_class_stack);
+ field_class_stack_pop(ctx->field_class_stack, ctx);
break;
}
default:
}
BT_HIDDEN
-int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc)
+int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc,
+ bt_logging_level log_level)
{
int ret = 0;
uint64_t i;
- struct resolve_context ctx = {
+ struct resolve_context local_ctx = {
+ .log_level = log_level,
.tc = tc,
.sc = NULL,
.ec = NULL,
.root_scope = CTF_SCOPE_PACKET_HEADER,
.cur_fc = NULL,
};
+ struct resolve_context *ctx = &local_ctx;
/* Initialize class stack */
- ctx.field_class_stack = field_class_stack_create();
- if (!ctx.field_class_stack) {
+ ctx->field_class_stack = field_class_stack_create();
+ if (!ctx->field_class_stack) {
BT_LOGE_STR("Cannot create field class stack.");
ret = -1;
goto end;
}
if (!tc->is_translated) {
- ctx.scopes.packet_header = tc->packet_header_fc;
- ret = resolve_root_class(CTF_SCOPE_PACKET_HEADER, &ctx);
+ ctx->scopes.packet_header = tc->packet_header_fc;
+ ret = resolve_root_class(CTF_SCOPE_PACKET_HEADER, ctx);
if (ret) {
BT_LOGE("Cannot resolve packet header field class: "
"ret=%d", ret);
}
}
- ctx.scopes.packet_header = tc->packet_header_fc;
+ ctx->scopes.packet_header = tc->packet_header_fc;
for (i = 0; i < tc->stream_classes->len; i++) {
struct ctf_stream_class *sc = tc->stream_classes->pdata[i];
- ret = resolve_stream_class_field_classes(&ctx, sc);
+ ret = resolve_stream_class_field_classes(ctx, sc);
if (ret) {
BT_LOGE("Cannot resolve stream class's field classes: "
"sc-id=%" PRIu64, sc->id);
}
end:
- field_class_stack_destroy(ctx.field_class_stack);
+ field_class_stack_destroy(ctx->field_class_stack);
return ret;
}
* all copies or substantial portions of the Software.
*/
-#define BT_LOG_TAG "PLUGIN/CTF/META/TRANSLATE"
-#include "logging.h"
-
#include <babeltrace2/babeltrace.h>
#include "common/macros.h"
#include "common/assert.h"
* all copies or substantial portions of the Software.
*/
+#define BT_LOG_OUTPUT_LEVEL log_level
#define BT_LOG_TAG "PLUGIN/CTF/META/UPDATE-DEF-CC"
-#include "logging.h"
+#include "logging/log.h"
#include <babeltrace2/babeltrace.h>
#include "common/macros.h"
static inline
int find_mapped_clock_class(struct ctf_field_class *fc,
- struct ctf_clock_class **clock_class)
+ struct ctf_clock_class **clock_class,
+ bt_logging_level log_level)
{
int ret = 0;
uint64_t i;
struct_fc, i);
ret = find_mapped_clock_class(named_fc->fc,
- clock_class);
+ clock_class, log_level);
if (ret) {
goto end;
}
var_fc, i);
ret = find_mapped_clock_class(named_fc->fc,
- clock_class);
+ clock_class, log_level);
if (ret) {
goto end;
}
{
struct ctf_field_class_array_base *array_fc = (void *) fc;
- ret = find_mapped_clock_class(array_fc->elem_fc, clock_class);
+ ret = find_mapped_clock_class(array_fc->elem_fc, clock_class,
+ log_level);
if (ret) {
goto end;
}
static inline
int update_stream_class_default_clock_class(
- struct ctf_stream_class *stream_class)
+ struct ctf_stream_class *stream_class,
+ bt_logging_level log_level)
{
int ret = 0;
struct ctf_clock_class *clock_class =
uint64_t i;
ret = find_mapped_clock_class(stream_class->packet_context_fc,
- &clock_class);
+ &clock_class, log_level);
if (ret) {
goto end;
}
ret = find_mapped_clock_class(stream_class->event_header_fc,
- &clock_class);
+ &clock_class, log_level);
if (ret) {
goto end;
}
ret = find_mapped_clock_class(stream_class->event_common_context_fc,
- &clock_class);
+ &clock_class, log_level);
if (ret) {
goto end;
}
stream_class->event_classes->pdata[i];
ret = find_mapped_clock_class(event_class->spec_context_fc,
- &clock_class);
+ &clock_class, log_level);
if (ret) {
goto end;
}
ret = find_mapped_clock_class(event_class->payload_fc,
- &clock_class);
+ &clock_class, log_level);
if (ret) {
goto end;
}
}
BT_HIDDEN
-int ctf_trace_class_update_default_clock_classes(struct ctf_trace_class *ctf_tc)
+int ctf_trace_class_update_default_clock_classes(struct ctf_trace_class *ctf_tc,
+ bt_logging_level log_level)
{
uint64_t i;
int ret = 0;
struct ctf_clock_class *clock_class = NULL;
- ret = find_mapped_clock_class(ctf_tc->packet_header_fc, &clock_class);
+ ret = find_mapped_clock_class(ctf_tc->packet_header_fc, &clock_class,
+ log_level);
if (ret) {
goto end;
}
ctf_tc->stream_classes->pdata[i];
ret = update_stream_class_default_clock_class(
- ctf_tc->stream_classes->pdata[i]);
+ ctf_tc->stream_classes->pdata[i], log_level);
if (ret) {
BT_LOGE("Stream class contains more than one "
"clock class: stream-class-id=%" PRIu64,
* all copies or substantial portions of the Software.
*/
-#define BT_LOG_TAG "PLUGIN/CTF/META/UPDATE-IN-IR"
-#include "logging.h"
-
#include <babeltrace2/babeltrace.h>
#include "common/macros.h"
#include "common/assert.h"
* all copies or substantial portions of the Software.
*/
-#define BT_LOG_TAG "PLUGIN/CTF/META/UPDATE-MEANINGS"
-#include "logging.h"
-
#include <babeltrace2/babeltrace.h>
#include "common/macros.h"
#include "common/assert.h"
* all copies or substantial portions of the Software.
*/
-#define BT_LOG_TAG "PLUGIN/CTF/META/UPDATE-SC-CONFIG"
-#include "logging.h"
-
#include <babeltrace2/babeltrace.h>
#include "common/macros.h"
#include "common/assert.h"
* all copies or substantial portions of the Software.
*/
-#define BT_LOG_TAG "PLUGIN/CTF/META/UPDATE-TEXT-ARRAY-SEQ"
-#include "logging.h"
-
#include <babeltrace2/babeltrace.h>
#include "common/macros.h"
#include "common/assert.h"
* all copies or substantial portions of the Software.
*/
-#define BT_LOG_TAG "PLUGIN/CTF/META/UPDATE-VALUE-STORING-INDEXES"
-#include "logging.h"
-
#include <babeltrace2/babeltrace.h>
#include "common/macros.h"
#include "common/assert.h"
* all copies or substantial portions of the Software.
*/
+#define BT_LOG_OUTPUT_LEVEL log_level
#define BT_LOG_TAG "PLUGIN/CTF/META/VALIDATE"
-#include "logging.h"
+#include "logging/log.h"
#include <babeltrace2/babeltrace.h>
#include "common/macros.h"
#include "ctf-meta-visitors.h"
static
-int validate_stream_class(struct ctf_stream_class *sc)
+int validate_stream_class(struct ctf_stream_class *sc,
+ bt_logging_level log_level)
{
int ret = 0;
struct ctf_field_class_int *int_fc;
}
BT_HIDDEN
-int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc)
+int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
+ bt_logging_level log_level)
{
int ret = 0;
struct ctf_field_class_int *int_fc;
struct ctf_stream_class *sc =
ctf_tc->stream_classes->pdata[i];
- ret = validate_stream_class(sc);
+ ret = validate_stream_class(sc, log_level);
if (ret) {
BT_LOGE("Invalid stream class: sc-id=%" PRIu64, sc->id);
goto invalid;
#include "ctf-meta.h"
BT_HIDDEN
-int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc);
+int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc,
+ bt_logging_level log_level);
BT_HIDDEN
int ctf_trace_class_translate(bt_self_component_source *self_comp,
BT_HIDDEN
int ctf_trace_class_update_default_clock_classes(
- struct ctf_trace_class *ctf_tc);
+ struct ctf_trace_class *ctf_tc,
+ bt_logging_level log_level);
BT_HIDDEN
int ctf_trace_class_update_in_ir(struct ctf_trace_class *ctf_tc);
int ctf_trace_class_update_stream_class_config(struct ctf_trace_class *ctf_tc);
BT_HIDDEN
-int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc);
+int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
+ bt_logging_level log_level);
BT_HIDDEN
void ctf_trace_class_warn_meaningless_header_fields(
- struct ctf_trace_class *ctf_tc);
+ struct ctf_trace_class *ctf_tc, bt_logging_level log_level);
#endif /* _CTF_META_VISITORS_H */
* all copies or substantial portions of the Software.
*/
+#define BT_LOG_OUTPUT_LEVEL log_level
#define BT_LOG_TAG "PLUGIN/CTF/META/WARN-MEANINGLESS-HEADER-FIELDS"
-#include "logging.h"
+#include "logging/log.h"
#include <babeltrace2/babeltrace.h>
#include "common/macros.h"
#include "ctf-meta-visitors.h"
static inline
-void warn_meaningless_field(const char *name, const char *scope_name)
+void warn_meaningless_field(const char *name, const char *scope_name,
+ bt_logging_level log_level)
{
BT_LOGW("User field found in %s: ignoring: name=\"%s\"",
scope_name, name);
static inline
void warn_meaningless_fields(struct ctf_field_class *fc, const char *name,
- const char *scope_name)
+ const char *scope_name, bt_logging_level log_level)
{
uint64_t i;
switch (fc->type) {
case CTF_FIELD_CLASS_TYPE_FLOAT:
case CTF_FIELD_CLASS_TYPE_STRING:
- warn_meaningless_field(name, scope_name);
+ warn_meaningless_field(name, scope_name, log_level);
break;
case CTF_FIELD_CLASS_TYPE_INT:
case CTF_FIELD_CLASS_TYPE_ENUM:
if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE &&
!int_fc->mapped_clock_class) {
- warn_meaningless_field(name, scope_name);
+ warn_meaningless_field(name, scope_name, log_level);
}
break;
struct_fc, i);
warn_meaningless_fields(named_fc->fc,
- named_fc->name->str, scope_name);
+ named_fc->name->str, scope_name, log_level);
}
break;
var_fc, i);
warn_meaningless_fields(named_fc->fc,
- named_fc->name->str, scope_name);
+ named_fc->name->str, scope_name, log_level);
}
break;
{
struct ctf_field_class_array_base *array_fc = (void *) fc;
- warn_meaningless_fields(array_fc->elem_fc, name, scope_name);
+ warn_meaningless_fields(array_fc->elem_fc, name, scope_name,
+ log_level);
break;
}
default:
BT_HIDDEN
void ctf_trace_class_warn_meaningless_header_fields(
- struct ctf_trace_class *ctf_tc)
+ struct ctf_trace_class *ctf_tc,
+ bt_logging_level log_level)
{
uint64_t i;
if (!ctf_tc->is_translated) {
warn_meaningless_fields(
- ctf_tc->packet_header_fc, NULL, "packet header");
+ ctf_tc->packet_header_fc, NULL, "packet header",
+ log_level);
}
for (i = 0; i < ctf_tc->stream_classes->len; i++) {
if (!sc->is_translated) {
warn_meaningless_fields(sc->event_header_fc, NULL,
- "event header");
+ "event header", log_level);
}
}
}
* all copies or substantial portions of the Software.
*/
+#define BT_LOG_OUTPUT_LEVEL (mdec->config.log_level)
#define BT_LOG_TAG "PLUGIN/CTF/META/DECODER"
-#include "logging.h"
+#include "logging/log.h"
#include <stdio.h>
#include <stdbool.h>
} __attribute__((__packed__));
BT_HIDDEN
-bool ctf_metadata_decoder_is_packetized(FILE *fp, int *byte_order)
+bool ctf_metadata_decoder_is_packetized(FILE *fp, int *byte_order,
+ bt_logging_level log_level)
{
uint32_t magic;
size_t len;
len = fread(&magic, sizeof(magic), 1, fp);
if (len != 1) {
- BT_LOGI_STR("Cannot read first metadata packet header: assuming the stream is not packetized.");
+ BT_LOG_WRITE_CUR_LVL(BT_LOG_INFO, log_level, BT_LOG_TAG,
+ "Cannot read first metadata packet header: assuming the stream is not packetized.");
goto end;
}
static
int ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec(
struct ctf_metadata_decoder *mdec, FILE *fp,
- char **buf, int byte_order)
+ char **buf, int byte_order, bt_logging_level log_level)
{
FILE *out_fp;
size_t size;
out_fp = bt_open_memstream(buf, &size);
if (out_fp == NULL) {
- BT_LOGE("Cannot open memory stream: %s: mdec-addr=%p",
+ BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+ "Cannot open memory stream: %s: mdec-addr=%p",
strerror(errno), mdec);
goto error;
}
tret = decode_packet(mdec, fp, out_fp, byte_order);
if (tret) {
- BT_LOGE("Cannot decode packet: index=%zu, mdec-addr=%p",
+ BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+ "Cannot decode packet: index=%zu, mdec-addr=%p",
packet_index, mdec);
goto error;
}
/* Make sure the whole string ends with a null character */
tret = fputc('\0', out_fp);
if (tret == EOF) {
- BT_LOGE("Cannot append '\\0' to the decoded metadata buffer: "
+ BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+ "Cannot append '\\0' to the decoded metadata buffer: "
"mdec-addr=%p", mdec);
goto error;
}
*/
out_fp = NULL;
if (ret < 0) {
- BT_LOGE("Cannot close memory stream: %s: mdec-addr=%p",
- strerror(errno), mdec);
+ BT_LOG_WRITE_ERRNO_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+ "Cannot close memory stream", ": mdec-addr=%p", mdec);
goto error;
}
if (out_fp) {
if (bt_close_memstream(buf, &size, out_fp)) {
- BT_LOGE("Cannot close memory stream: %s: mdec-addr=%p",
+ BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+ "Cannot close memory stream: %s: mdec-addr=%p",
strerror(errno), mdec);
}
}
BT_HIDDEN
int ctf_metadata_decoder_packetized_file_stream_to_buf(
- FILE *fp, char **buf, int byte_order)
+ FILE *fp, char **buf, int byte_order,
+ bt_logging_level log_level)
{
return ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec(
- NULL, fp, buf, byte_order);
+ NULL, fp, buf, byte_order, log_level);
}
BT_HIDDEN
BT_ASSERT(mdec);
- if (ctf_metadata_decoder_is_packetized(fp, &mdec->bo)) {
+ if (ctf_metadata_decoder_is_packetized(fp, &mdec->bo,
+ BT_LOG_OUTPUT_LEVEL)) {
BT_LOGI("Metadata stream is packetized: mdec-addr=%p", mdec);
ret = ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec(
- mdec, fp, &buf, mdec->bo);
+ mdec, fp, &buf, mdec->bo, BT_LOG_OUTPUT_LEVEL);
if (ret) {
BT_LOGE("Cannot decode packetized metadata packets to metadata text: "
"mdec-addr=%p, ret=%d", mdec, ret);
goto end;
}
- ret = ctf_visitor_semantic_check(0, &scanner->ast->root);
+ ret = ctf_visitor_semantic_check(0, &scanner->ast->root,
+ mdec->config.log_level);
if (ret) {
BT_LOGE("Validation of the metadata semantics failed: "
"mdec-addr=%p", mdec);
/* Decoding configuration */
struct ctf_metadata_decoder_config {
+ bt_logging_level log_level;
int64_t clock_class_offset_s;
int64_t clock_class_offset_ns;
};
* if so, sets `*byte_order` to the byte order of the first packet.
*/
BT_HIDDEN
-bool ctf_metadata_decoder_is_packetized(FILE *fp, int *byte_order);
+bool ctf_metadata_decoder_is_packetized(FILE *fp, int *byte_order,
+ bt_logging_level log_level);
/*
* Decodes a packetized metadata file stream to a NULL-terminated
*/
BT_HIDDEN
int ctf_metadata_decoder_packetized_file_stream_to_buf(
- FILE *fp, char **buf, int byte_order);
+ FILE *fp, char **buf, int byte_order,
+ bt_logging_level log_level);
#endif /* _METADATA_DECODER_H */
* SOFTWARE.
*/
+#define BT_LOG_OUTPUT_LEVEL ctf_plugin_metadata_log_level
#define BT_LOG_TAG "PLUGIN-CTF-METADATA-LEXER"
#include "logging.h"
* SOFTWARE.
*/
-#define BT_LOG_OUTPUT_LEVEL metadata_log_level
+#define BT_LOG_OUTPUT_LEVEL ctf_plugin_metadata_log_level
#include "logging/log.h"
-BT_LOG_INIT_LOG_LEVEL(metadata_log_level, "BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL");
+BT_LOG_INIT_LOG_LEVEL(ctf_plugin_metadata_log_level, "BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL");
* SOFTWARE.
*/
-#define BT_LOG_OUTPUT_LEVEL metadata_log_level
#include "logging/log.h"
-BT_LOG_LEVEL_EXTERN_SYMBOL(metadata_log_level);
+/*
+ * This global log level is for the generated lexer and parser: we can't
+ * use a contextual log level for their "tracing", so they rely on this.
+ */
+BT_LOG_LEVEL_EXTERN_SYMBOL(ctf_plugin_metadata_log_level);
#define _BT_LOGV_LINENO(_lineno, _msg, args...) \
BT_LOGV("At line %u in metadata stream: " _msg, _lineno, ## args)
* SOFTWARE.
*/
+#define BT_LOG_OUTPUT_LEVEL ctf_plugin_metadata_log_level
#define BT_LOG_TAG "PLUGIN/CTF/META/OBJSTACK"
#include "logging.h"
* SOFTWARE.
*/
+#define BT_LOG_OUTPUT_LEVEL ctf_plugin_metadata_log_level
#define BT_LOG_TAG "PLUGIN/CTF/META/PARSER"
#include "logging.h"
* SOFTWARE.
*/
+#define BT_LOG_OUTPUT_LEVEL (ctx->log_level)
#define BT_LOG_TAG "PLUGIN/CTF/META/IR-VISITOR"
-#include "logging.h"
+#include "logging/log.h"
#include <stdio.h>
#include <unistd.h>
#include "compat/endian.h"
#include <babeltrace2/babeltrace.h>
+#include "logging.h"
#include "scanner.h"
#include "parser.h"
#include "ast.h"
* Visitor context (private).
*/
struct ctx {
+ bt_logging_level log_level;
bt_self_component_source *self_comp;
/* Trace IR trace class being filled (owned by this) */
bt_trace_class *trace_class;
* @returns New declaration scope, or NULL on error
*/
static
-struct ctx_decl_scope *ctx_decl_scope_create(struct ctx_decl_scope *par_scope)
+struct ctx_decl_scope *ctx_decl_scope_create(struct ctx *ctx,
+ struct ctx_decl_scope *par_scope)
{
struct ctx_decl_scope *scope;
* @returns Associated GQuark, or 0 on error
*/
static
-GQuark get_prefixed_named_quark(char prefix, const char *name)
+GQuark get_prefixed_named_quark(struct ctx *ctx, char prefix, const char *name)
{
GQuark qname = 0;
*/
static
struct ctf_field_class *ctx_decl_scope_lookup_prefix_alias(
- struct ctx_decl_scope *scope, char prefix, const char *name,
- int levels, bool copy)
+ struct ctx *ctx, struct ctx_decl_scope *scope, char prefix,
+ const char *name, int levels, bool copy)
{
GQuark qname = 0;
int cur_levels = 0;
BT_ASSERT(scope);
BT_ASSERT(name);
- qname = get_prefixed_named_quark(prefix, name);
+ qname = get_prefixed_named_quark(ctx, prefix, name);
if (!qname) {
goto end;
}
* or NULL if not found
*/
static
-struct ctf_field_class *ctx_decl_scope_lookup_alias(
+struct ctf_field_class *ctx_decl_scope_lookup_alias(struct ctx *ctx,
struct ctx_decl_scope *scope, const char *name, int levels,
bool copy)
{
- return ctx_decl_scope_lookup_prefix_alias(scope, _PREFIX_ALIAS,
+ return ctx_decl_scope_lookup_prefix_alias(ctx, scope, _PREFIX_ALIAS,
name, levels, copy);
}
* or NULL if not found
*/
static
-struct ctf_field_class_enum *ctx_decl_scope_lookup_enum(
+struct ctf_field_class_enum *ctx_decl_scope_lookup_enum(struct ctx *ctx,
struct ctx_decl_scope *scope, const char *name, int levels,
bool copy)
{
- return (void *) ctx_decl_scope_lookup_prefix_alias(scope, _PREFIX_ENUM,
- name, levels, copy);
+ return (void *) ctx_decl_scope_lookup_prefix_alias(ctx, scope,
+ _PREFIX_ENUM, name, levels, copy);
}
/**
* or NULL if not found
*/
static
-struct ctf_field_class_struct *ctx_decl_scope_lookup_struct(
+struct ctf_field_class_struct *ctx_decl_scope_lookup_struct(struct ctx *ctx,
struct ctx_decl_scope *scope, const char *name, int levels,
bool copy)
{
- return (void *) ctx_decl_scope_lookup_prefix_alias(scope,
+ return (void *) ctx_decl_scope_lookup_prefix_alias(ctx, scope,
_PREFIX_STRUCT, name, levels, copy);
}
* or NULL if not found
*/
static
-struct ctf_field_class_variant *ctx_decl_scope_lookup_variant(
+struct ctf_field_class_variant *ctx_decl_scope_lookup_variant(struct ctx *ctx,
struct ctx_decl_scope *scope, const char *name, int levels,
bool copy)
{
- return (void *) ctx_decl_scope_lookup_prefix_alias(scope,
+ return (void *) ctx_decl_scope_lookup_prefix_alias(ctx, scope,
_PREFIX_VARIANT, name, levels, copy);
}
* @returns 0 if registration went okay, negative value otherwise
*/
static
-int ctx_decl_scope_register_prefix_alias(struct ctx_decl_scope *scope,
- char prefix, const char *name, struct ctf_field_class *decl)
+int ctx_decl_scope_register_prefix_alias(struct ctx *ctx,
+ struct ctx_decl_scope *scope, char prefix, const char *name,
+ struct ctf_field_class *decl)
{
int ret = 0;
GQuark qname = 0;
BT_ASSERT(scope);
BT_ASSERT(name);
BT_ASSERT(decl);
- qname = get_prefixed_named_quark(prefix, name);
+ qname = get_prefixed_named_quark(ctx, prefix, name);
if (!qname) {
ret = -ENOMEM;
goto end;
}
/* Make sure alias does not exist in local scope */
- if (ctx_decl_scope_lookup_prefix_alias(scope, prefix, name, 1,
+ if (ctx_decl_scope_lookup_prefix_alias(ctx, scope, prefix, name, 1,
false)) {
ret = -EEXIST;
goto end;
* @returns 0 if registration went okay, negative value otherwise
*/
static
-int ctx_decl_scope_register_alias(struct ctx_decl_scope *scope,
+int ctx_decl_scope_register_alias(struct ctx *ctx, struct ctx_decl_scope *scope,
const char *name, struct ctf_field_class *decl)
{
- return ctx_decl_scope_register_prefix_alias(scope, _PREFIX_ALIAS,
+ return ctx_decl_scope_register_prefix_alias(ctx, scope, _PREFIX_ALIAS,
name, (void *) decl);
}
* @returns 0 if registration went okay, negative value otherwise
*/
static
-int ctx_decl_scope_register_enum(struct ctx_decl_scope *scope,
+int ctx_decl_scope_register_enum(struct ctx *ctx, struct ctx_decl_scope *scope,
const char *name, struct ctf_field_class_enum *decl)
{
- return ctx_decl_scope_register_prefix_alias(scope, _PREFIX_ENUM,
+ return ctx_decl_scope_register_prefix_alias(ctx, scope, _PREFIX_ENUM,
name, (void *) decl);
}
* @returns 0 if registration went okay, negative value otherwise
*/
static
-int ctx_decl_scope_register_struct(struct ctx_decl_scope *scope,
- const char *name, struct ctf_field_class_struct *decl)
+int ctx_decl_scope_register_struct(struct ctx *ctx,
+ struct ctx_decl_scope *scope, const char *name,
+ struct ctf_field_class_struct *decl)
{
- return ctx_decl_scope_register_prefix_alias(scope, _PREFIX_STRUCT,
+ return ctx_decl_scope_register_prefix_alias(ctx, scope, _PREFIX_STRUCT,
name, (void *) decl);
}
* @returns 0 if registration went okay, negative value otherwise
*/
static
-int ctx_decl_scope_register_variant(struct ctx_decl_scope *scope,
- const char *name, struct ctf_field_class_variant *decl)
+int ctx_decl_scope_register_variant(struct ctx *ctx,
+ struct ctx_decl_scope *scope, const char *name,
+ struct ctf_field_class_variant *decl)
{
- return ctx_decl_scope_register_prefix_alias(scope, _PREFIX_VARIANT,
+ return ctx_decl_scope_register_prefix_alias(ctx, scope, _PREFIX_VARIANT,
name, (void *) decl);
}
ctx = g_new0(struct ctx, 1);
if (!ctx) {
- BT_LOGE_STR("Failed to allocate one visitor context.");
+ BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, decoder_config->log_level,
+ BT_LOG_TAG,
+ "Failed to allocate one visitor context.");
goto error;
}
+ ctx->log_level = decoder_config->log_level;
+
if (self_comp) {
ctx->trace_class = bt_trace_class_create(
bt_self_component_source_as_self_component(self_comp));
}
/* Root declaration scope */
- ctx->current_scope = ctx_decl_scope_create(NULL);
+ ctx->current_scope = ctx_decl_scope_create(ctx, NULL);
if (!ctx->current_scope) {
BT_LOGE_STR("Cannot create declaration scope.");
goto error;
struct ctx_decl_scope *new_scope;
BT_ASSERT(ctx);
- new_scope = ctx_decl_scope_create(ctx->current_scope);
+ new_scope = ctx_decl_scope_create(ctx, ctx->current_scope);
if (!new_scope) {
BT_LOGE_STR("Cannot create declaration scope.");
ret = -ENOMEM;
struct ctf_field_class **decl);
static
-char *remove_underscores_from_field_ref(const char *field_ref)
+char *remove_underscores_from_field_ref(struct ctx *ctx, const char *field_ref)
{
const char *in_ch;
char *out_ch;
}
static
-int get_unary_unsigned(struct bt_list_head *head, uint64_t *value)
+int get_unary_unsigned(struct ctx *ctx, struct bt_list_head *head,
+ uint64_t *value)
{
int i = 0;
int ret = 0;
}
static
-int get_unary_uuid(struct bt_list_head *head, unsigned char *uuid)
+int get_unary_uuid(struct ctx *ctx, struct bt_list_head *head,
+ unsigned char *uuid)
{
int i = 0;
int ret = 0;
}
static
-int get_boolean(struct ctf_node *unary_expr)
+int get_boolean(struct ctx *ctx, struct ctf_node *unary_expr)
{
int ret = 0;
}
static
-enum ctf_byte_order byte_order_from_unary_expr(struct ctf_node *unary_expr)
+enum ctf_byte_order byte_order_from_unary_expr(struct ctx *ctx,
+ struct ctf_node *unary_expr)
{
const char *str;
enum ctf_byte_order bo = -1;
enum ctf_byte_order get_real_byte_order(struct ctx *ctx,
struct ctf_node *uexpr)
{
- enum ctf_byte_order bo = byte_order_from_unary_expr(uexpr);
+ enum ctf_byte_order bo = byte_order_from_unary_expr(ctx, uexpr);
if (bo == CTF_BYTE_ORDER_DEFAULT) {
bo = ctx->ctf_tc->default_byte_order;
qalias = create_class_alias_identifier(ctx,
cls_specifier_list, node_field_class_declarator);
nested_decl =
- ctx_decl_scope_lookup_alias(ctx->current_scope,
+ ctx_decl_scope_lookup_alias(ctx,
+ ctx->current_scope,
g_quark_to_string(qalias), -1, true);
if (!nested_decl) {
_BT_LOGE_NODE(node_field_class_declarator,
decl = (void *) array_decl;
} else {
char *length_name_no_underscore =
- remove_underscores_from_field_ref(
+ remove_underscores_from_field_ref(ctx,
length_name);
if (!length_name_no_underscore) {
/*
}
}
- ret = ctx_decl_scope_register_alias(ctx->current_scope,
+ ret = ctx_decl_scope_register_alias(ctx, ctx->current_scope,
g_quark_to_string(qidentifier), class_decl);
if (ret) {
_BT_LOGE_NODE(iter,
struct ctf_node, siblings);
qalias = create_class_alias_identifier(ctx,
alias->u.field_class_alias_name.field_class_specifier_list, node);
- ret = ctx_decl_scope_register_alias(ctx->current_scope,
+ ret = ctx_decl_scope_register_alias(ctx, ctx->current_scope,
g_quark_to_string(qalias), class_decl);
if (ret) {
_BT_LOGE_NODE(node,
goto error;
}
- *struct_decl = ctx_decl_scope_lookup_struct(ctx->current_scope,
+ *struct_decl = ctx_decl_scope_lookup_struct(ctx, ctx->current_scope,
name, -1, true);
if (!*struct_decl) {
BT_LOGE("Cannot find structure field class: name=\"struct %s\"",
uint64_t min_align_value = 0;
if (name) {
- if (ctx_decl_scope_lookup_struct(
+ if (ctx_decl_scope_lookup_struct(ctx,
ctx->current_scope, name, 1, false)) {
BT_LOGE("Structure field class already declared in local scope: "
"name=\"struct %s\"", name);
}
if (!bt_list_empty(min_align)) {
- ret = get_unary_unsigned(min_align, &min_align_value);
+ ret = get_unary_unsigned(ctx, min_align,
+ &min_align_value);
if (ret) {
BT_LOGE("Unexpected unary expression for structure field class's `align` attribute: "
"ret=%d", ret);
ctx_pop_scope(ctx);
if (name) {
- ret = ctx_decl_scope_register_struct(ctx->current_scope,
- name, *struct_decl);
+ ret = ctx_decl_scope_register_struct(ctx,
+ ctx->current_scope, name, *struct_decl);
if (ret) {
BT_LOGE("Cannot register structure field class in declaration scope: "
"name=\"struct %s\", ret=%d", name, ret);
}
untagged_variant_decl =
- ctx_decl_scope_lookup_variant(ctx->current_scope,
+ ctx_decl_scope_lookup_variant(ctx, ctx->current_scope,
name, -1, true);
if (!untagged_variant_decl) {
BT_LOGE("Cannot find variant field class: name=\"variant %s\"",
struct ctf_node *entry_node;
if (name) {
- if (ctx_decl_scope_lookup_variant(ctx->current_scope,
- name, 1, false)) {
+ if (ctx_decl_scope_lookup_variant(ctx,
+ ctx->current_scope, name, 1, false)) {
BT_LOGE("Variant field class already declared in local scope: "
"name=\"variant %s\"", name);
ret = -EINVAL;
ctx_pop_scope(ctx);
if (name) {
- ret = ctx_decl_scope_register_variant(
+ ret = ctx_decl_scope_register_variant(ctx,
ctx->current_scope, name,
untagged_variant_decl);
if (ret) {
* else owns it. Set its tag now.
*/
char *tag_no_underscore =
- remove_underscores_from_field_ref(tag);
+ remove_underscores_from_field_ref(ctx, tag);
if (!tag_no_underscore) {
/* remove_underscores_from_field_ref() logs errors */
goto error;
}
- *enum_decl = ctx_decl_scope_lookup_enum(ctx->current_scope,
+ *enum_decl = ctx_decl_scope_lookup_enum(ctx, ctx->current_scope,
name, -1, true);
if (!*enum_decl) {
BT_LOGE("Cannot find enumeration field class: "
};
if (name) {
- if (ctx_decl_scope_lookup_enum(ctx->current_scope,
+ if (ctx_decl_scope_lookup_enum(ctx, ctx->current_scope,
name, 1, false)) {
BT_LOGE("Enumeration field class already declared in local scope: "
"name=\"enum %s\"", name);
}
if (!container_cls) {
- integer_decl = (void *) ctx_decl_scope_lookup_alias(
+ integer_decl = (void *) ctx_decl_scope_lookup_alias(ctx,
ctx->current_scope, "int", -1, true);
if (!integer_decl) {
BT_LOGE_STR("Cannot find implicit `int` field class alias for enumeration field class.");
}
if (name) {
- ret = ctx_decl_scope_register_enum(ctx->current_scope,
- name, *enum_decl);
+ ret = ctx_decl_scope_register_enum(ctx,
+ ctx->current_scope, name, *enum_decl);
if (ret) {
BT_LOGE("Cannot register enumeration field class in declaration scope: "
"ret=%d", ret);
goto error;
}
- *decl = ctx_decl_scope_lookup_alias(ctx->current_scope, str->str, -1,
- true);
+ *decl = ctx_decl_scope_lookup_alias(ctx, ctx->current_scope, str->str,
+ -1, true);
if (!*decl) {
_BT_LOGE_NODE(cls_specifier_list,
"Cannot find field class alias: name=\"%s\"", str->str);
goto error;
}
- signedness = get_boolean(right);
+ signedness = get_boolean(ctx, right);
if (signedness < 0) {
_BT_LOGE_NODE(right,
"Invalid boolean value for integer field class's `signed` attribute: "
goto error;
}
- ret = get_unary_unsigned(&node->u.ctf_expression.right,
+ ret = get_unary_unsigned(ctx,
+ &node->u.ctf_expression.right,
(uint64_t *) &id);
/* Only read "id" if get_unary_unsigned() succeeded. */
if (ret || (!ret && id < 0)) {
goto error;
}
- ret = get_unary_unsigned(&node->u.ctf_expression.right,
- stream_id);
+ ret = get_unary_unsigned(ctx,
+ &node->u.ctf_expression.right, stream_id);
/*
* Only read "stream_id" if get_unary_unsigned()
goto error;
}
- ret = get_unary_unsigned(&node->u.ctf_expression.right,
- &loglevel_value);
+ ret = get_unary_unsigned(ctx,
+ &node->u.ctf_expression.right, &loglevel_value);
if (ret) {
_BT_LOGE_NODE(node,
"Unexpected unary expression for event class's `loglevel` attribute.");
goto error;
}
- ret = get_unary_unsigned(&node->u.ctf_expression.right,
+ ret = get_unary_unsigned(ctx,
+ &node->u.ctf_expression.right,
(uint64_t *) &id);
/* Only read "id" if get_unary_unsigned() succeeded. */
goto error;
}
- ret = get_unary_unsigned(&node->u.ctf_expression.right,
- &val);
+ ret = get_unary_unsigned(ctx,
+ &node->u.ctf_expression.right, &val);
if (ret) {
_BT_LOGE_NODE(node,
"Unexpected unary expression for trace's `major` attribute.");
goto error;
}
- ret = get_unary_unsigned(&node->u.ctf_expression.right,
- &val);
+ ret = get_unary_unsigned(ctx,
+ &node->u.ctf_expression.right, &val);
if (ret) {
_BT_LOGE_NODE(node,
"Unexpected unary expression for trace's `minor` attribute.");
goto error;
}
- ret = get_unary_uuid(&node->u.ctf_expression.right,
+ ret = get_unary_uuid(ctx,
+ &node->u.ctf_expression.right,
ctx->ctf_tc->uuid);
if (ret) {
_BT_LOGE_NODE(node,
int64_t v;
if (is_unary_unsigned(right_head)) {
- ret = get_unary_unsigned(right_head,
+ ret = get_unary_unsigned(ctx, right_head,
(uint64_t *) &v);
} else {
ret = get_unary_signed(right_head, &v);
right_node = _BT_LIST_FIRST_ENTRY(
&node->u.ctf_expression.right,
struct ctf_node, siblings);
- bo = byte_order_from_unary_expr(right_node);
+ bo = byte_order_from_unary_expr(ctx,
+ right_node);
if (bo == -1) {
_BT_LOGE_NODE(node,
"Invalid `byte_order` attribute in trace (`trace` block): "
goto error;
}
- ret = get_unary_uuid(&entry_node->u.ctf_expression.right, uuid);
+ ret = get_unary_uuid(ctx, &entry_node->u.ctf_expression.right,
+ uuid);
if (ret) {
_BT_LOGE_NODE(entry_node,
"Invalid clock class's `uuid` attribute.");
goto error;
}
- ret = get_unary_unsigned(
+ ret = get_unary_unsigned(ctx,
&entry_node->u.ctf_expression.right, &freq);
if (ret) {
_BT_LOGE_NODE(entry_node,
goto error;
}
- ret = get_unary_unsigned(
+ ret = get_unary_unsigned(ctx,
&entry_node->u.ctf_expression.right, &precision);
if (ret) {
_BT_LOGE_NODE(entry_node,
goto error;
}
- ret = get_unary_unsigned(
+ ret = get_unary_unsigned(ctx,
&entry_node->u.ctf_expression.right, offset_cycles);
if (ret) {
_BT_LOGE_NODE(entry_node,
right = _BT_LIST_FIRST_ENTRY(
&entry_node->u.ctf_expression.right,
struct ctf_node, siblings);
- ret = get_boolean(right);
+ ret = get_boolean(ctx, right);
if (ret < 0) {
_BT_LOGE_NODE(entry_node,
"Unexpected unary expression for clock class's `absolute` attribute.");
}
/* Update default clock classes */
- ret = ctf_trace_class_update_default_clock_classes(ctx->ctf_tc);
+ ret = ctf_trace_class_update_default_clock_classes(ctx->ctf_tc,
+ ctx->log_level);
if (ret) {
ret = -EINVAL;
goto end;
}
/* Resolve sequence lengths and variant tags */
- ret = ctf_trace_class_resolve_field_classes(ctx->ctf_tc);
+ ret = ctf_trace_class_resolve_field_classes(ctx->ctf_tc,
+ ctx->log_level);
if (ret) {
ret = -EINVAL;
goto end;
}
/* Validate what we have so far */
- ret = ctf_trace_class_validate(ctx->ctf_tc);
+ ret = ctf_trace_class_validate(ctx->ctf_tc,
+ ctx->log_level);
if (ret) {
ret = -EINVAL;
goto end;
* itself in the packet header and in event header field
* classes, warn about it because they are never translated.
*/
- ctf_trace_class_warn_meaningless_header_fields(ctx->ctf_tc);
+ ctf_trace_class_warn_meaningless_header_fields(ctx->ctf_tc,
+ ctx->log_level);
if (ctx->trace_class) {
/* Copy new CTF metadata -> new IR metadata */
* SOFTWARE.
*/
+#define BT_LOG_OUTPUT_LEVEL log_level
#define BT_LOG_TAG "PLUGIN/CTF/META/PARENT-LINKS-VISITOR"
-#include "logging.h"
+#include "logging/log.h"
#include <stdio.h>
#include <unistd.h>
#include "scanner.h"
#include "parser.h"
#include "ast.h"
+#include "logging.h"
static
-int ctf_visitor_unary_expression(int depth, struct ctf_node *node)
+int ctf_visitor_unary_expression(int depth, struct ctf_node *node,
+ bt_logging_level log_level)
{
int ret = 0;
case UNARY_SBRAC:
node->u.unary_expression.u.sbrac_exp->parent = node;
ret = ctf_visitor_unary_expression(depth + 1,
- node->u.unary_expression.u.sbrac_exp);
+ node->u.unary_expression.u.sbrac_exp,
+ log_level);
if (ret)
return ret;
break;
}
static
-int ctf_visitor_type_specifier(int depth, struct ctf_node *node)
+int ctf_visitor_type_specifier(int depth, struct ctf_node *node,
+ bt_logging_level log_level)
{
int ret;
case TYPESPEC_VARIANT:
case TYPESPEC_ENUM:
node->u.field_class_specifier.node->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_specifier.node);
+ ret = ctf_visitor_parent_links(depth + 1,
+ node->u.field_class_specifier.node,
+ log_level);
if (ret)
return ret;
break;
}
static
-int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node)
+int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node,
+ bt_logging_level log_level)
{
int ret = 0;
struct ctf_node *iter;
bt_list_for_each_entry(iter, &node->u.field_class_declarator.pointers,
siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter, log_level);
if (ret)
return ret;
}
if (node->u.field_class_declarator.u.nested.field_class_declarator) {
node->u.field_class_declarator.u.nested.field_class_declarator->parent = node;
ret = ctf_visitor_parent_links(depth + 1,
- node->u.field_class_declarator.u.nested.field_class_declarator);
+ node->u.field_class_declarator.u.nested.field_class_declarator,
+ log_level);
if (ret)
return ret;
}
bt_list_for_each_entry(iter, &node->u.field_class_declarator.u.nested.length,
siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
if (node->u.field_class_declarator.bitfield_len) {
node->u.field_class_declarator.bitfield_len = node;
ret = ctf_visitor_parent_links(depth + 1,
- node->u.field_class_declarator.bitfield_len);
+ node->u.field_class_declarator.bitfield_len,
+ log_level);
if (ret)
return ret;
}
return 0;
}
-int ctf_visitor_parent_links(int depth, struct ctf_node *node)
+int ctf_visitor_parent_links(int depth, struct ctf_node *node,
+ bt_logging_level log_level)
{
int ret = 0;
struct ctf_node *iter;
case NODE_ROOT:
bt_list_for_each_entry(iter, &node->u.root.declaration_list, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
bt_list_for_each_entry(iter, &node->u.root.trace, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
bt_list_for_each_entry(iter, &node->u.root.stream, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
bt_list_for_each_entry(iter, &node->u.root.event, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
bt_list_for_each_entry(iter, &node->u.root.clock, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
bt_list_for_each_entry(iter, &node->u.root.callsite, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
case NODE_EVENT:
bt_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
case NODE_STREAM:
bt_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
case NODE_ENV:
bt_list_for_each_entry(iter, &node->u.env.declaration_list, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
case NODE_TRACE:
bt_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
case NODE_CLOCK:
bt_list_for_each_entry(iter, &node->u.clock.declaration_list, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
case NODE_CALLSITE:
bt_list_for_each_entry(iter, &node->u.callsite.declaration_list, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
depth++;
bt_list_for_each_entry(iter, &node->u.ctf_expression.left, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
bt_list_for_each_entry(iter, &node->u.ctf_expression.right, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
depth--;
break;
case NODE_UNARY_EXPRESSION:
- return ctf_visitor_unary_expression(depth, node);
+ return ctf_visitor_unary_expression(depth, node, log_level);
case NODE_TYPEDEF:
depth++;
node->u.field_class_def.field_class_specifier_list->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_def.field_class_specifier_list);
+ ret = ctf_visitor_parent_links(depth + 1,
+ node->u.field_class_def.field_class_specifier_list,
+ log_level);
if (ret)
return ret;
bt_list_for_each_entry(iter, &node->u.field_class_def.field_class_declarators, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
case NODE_TYPEALIAS_TARGET:
depth++;
node->u.field_class_alias_target.field_class_specifier_list->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_alias_target.field_class_specifier_list);
+ ret = ctf_visitor_parent_links(depth + 1,
+ node->u.field_class_alias_target.field_class_specifier_list,
+ log_level);
if (ret)
return ret;
bt_list_for_each_entry(iter, &node->u.field_class_alias_target.field_class_declarators, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
case NODE_TYPEALIAS_ALIAS:
depth++;
node->u.field_class_alias_name.field_class_specifier_list->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_alias_name.field_class_specifier_list);
+ ret = ctf_visitor_parent_links(depth + 1,
+ node->u.field_class_alias_name.field_class_specifier_list,
+ log_level);
if (ret)
return ret;
bt_list_for_each_entry(iter, &node->u.field_class_alias_name.field_class_declarators, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
break;
case NODE_TYPEALIAS:
node->u.field_class_alias.target->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_alias.target);
+ ret = ctf_visitor_parent_links(depth + 1,
+ node->u.field_class_alias.target, log_level);
if (ret)
return ret;
node->u.field_class_alias.alias->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_alias.alias);
+ ret = ctf_visitor_parent_links(depth + 1,
+ node->u.field_class_alias.alias, log_level);
if (ret)
return ret;
break;
case NODE_TYPE_SPECIFIER_LIST:
bt_list_for_each_entry(iter, &node->u.field_class_specifier_list.head, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
break;
case NODE_TYPE_SPECIFIER:
- ret = ctf_visitor_type_specifier(depth, node);
+ ret = ctf_visitor_type_specifier(depth, node, log_level);
if (ret)
return ret;
break;
case NODE_POINTER:
break;
case NODE_TYPE_DECLARATOR:
- ret = ctf_visitor_field_class_declarator(depth, node);
+ ret = ctf_visitor_field_class_declarator(depth, node,
+ log_level);
if (ret)
return ret;
break;
case NODE_FLOATING_POINT:
bt_list_for_each_entry(iter, &node->u.floating_point.expressions, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
case NODE_INTEGER:
bt_list_for_each_entry(iter, &node->u.integer.expressions, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
case NODE_STRING:
bt_list_for_each_entry(iter, &node->u.string.expressions, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
case NODE_ENUMERATOR:
bt_list_for_each_entry(iter, &node->u.enumerator.values, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
case NODE_ENUM:
depth++;
if (node->u._enum.container_field_class) {
- ret = ctf_visitor_parent_links(depth + 1, node->u._enum.container_field_class);
+ ret = ctf_visitor_parent_links(depth + 1,
+ node->u._enum.container_field_class, log_level);
if (ret)
return ret;
}
bt_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
case NODE_STRUCT_OR_VARIANT_DECLARATION:
node->u.struct_or_variant_declaration.field_class_specifier_list->parent = node;
ret = ctf_visitor_parent_links(depth + 1,
- node->u.struct_or_variant_declaration.field_class_specifier_list);
+ node->u.struct_or_variant_declaration.field_class_specifier_list,
+ log_level);
if (ret)
return ret;
bt_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.field_class_declarators, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
case NODE_VARIANT:
bt_list_for_each_entry(iter, &node->u.variant.declaration_list, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
case NODE_STRUCT:
bt_list_for_each_entry(iter, &node->u._struct.declaration_list, siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
bt_list_for_each_entry(iter, &node->u._struct.min_align,
siblings) {
iter->parent = node;
- ret = ctf_visitor_parent_links(depth + 1, iter);
+ ret = ctf_visitor_parent_links(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
* SOFTWARE.
*/
+#define BT_LOG_OUTPUT_LEVEL log_level
#define BT_LOG_TAG "PLUGIN/CTF/META/SEMANTIC-VALIDATOR-VISITOR"
-#include "logging.h"
+#include "logging/log.h"
#include <stdio.h>
#include <unistd.h>
#include "scanner.h"
#include "parser.h"
#include "ast.h"
+#include "logging.h"
#define _bt_list_first_entry(ptr, type, member) \
bt_list_entry((ptr)->next, type, member)
static
-int _ctf_visitor_semantic_check(int depth, struct ctf_node *node);
+int _ctf_visitor_semantic_check(int depth, struct ctf_node *node,
+ bt_logging_level log_level);
static
-int ctf_visitor_unary_expression(int depth, struct ctf_node *node)
+int ctf_visitor_unary_expression(int depth, struct ctf_node *node,
+ bt_logging_level log_level)
{
struct ctf_node *iter;
int is_ctf_exp = 0, is_ctf_exp_left = 0;
}
static
-int ctf_visitor_field_class_specifier_list(int depth, struct ctf_node *node)
+int ctf_visitor_field_class_specifier_list(int depth, struct ctf_node *node,
+ bt_logging_level log_level)
{
switch (node->parent->type) {
case NODE_CTF_EXPRESSION:
}
static
-int ctf_visitor_field_class_specifier(int depth, struct ctf_node *node)
+int ctf_visitor_field_class_specifier(int depth, struct ctf_node *node,
+ bt_logging_level log_level)
{
switch (node->parent->type) {
case NODE_TYPE_SPECIFIER_LIST:
}
static
-int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node)
+int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node,
+ bt_logging_level log_level)
{
int ret = 0;
struct ctf_node *iter;
bt_list_for_each_entry(iter, &node->u.field_class_declarator.pointers,
siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter, log_level);
if (ret)
return ret;
}
{
if (node->u.field_class_declarator.u.nested.field_class_declarator) {
ret = _ctf_visitor_semantic_check(depth + 1,
- node->u.field_class_declarator.u.nested.field_class_declarator);
+ node->u.field_class_declarator.u.nested.field_class_declarator,
+ log_level);
if (ret)
return ret;
}
node_type(iter));
return -EINVAL;
}
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1,
+ iter, log_level);
if (ret)
return ret;
}
}
if (node->u.field_class_declarator.bitfield_len) {
ret = _ctf_visitor_semantic_check(depth + 1,
- node->u.field_class_declarator.bitfield_len);
+ node->u.field_class_declarator.bitfield_len,
+ log_level);
if (ret)
return ret;
}
}
static
-int _ctf_visitor_semantic_check(int depth, struct ctf_node *node)
+int _ctf_visitor_semantic_check(int depth, struct ctf_node *node,
+ bt_logging_level log_level)
{
int ret = 0;
struct ctf_node *iter;
switch (node->type) {
case NODE_ROOT:
bt_list_for_each_entry(iter, &node->u.root.declaration_list, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
bt_list_for_each_entry(iter, &node->u.root.trace, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
bt_list_for_each_entry(iter, &node->u.root.stream, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
bt_list_for_each_entry(iter, &node->u.root.event, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
}
bt_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
}
bt_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
}
bt_list_for_each_entry(iter, &node->u.env.declaration_list, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
}
bt_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
}
bt_list_for_each_entry(iter, &node->u.clock.declaration_list, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
}
bt_list_for_each_entry(iter, &node->u.callsite.declaration_list, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
depth++;
bt_list_for_each_entry(iter, &node->u.ctf_expression.left, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
bt_list_for_each_entry(iter, &node->u.ctf_expression.right, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
depth--;
break;
case NODE_UNARY_EXPRESSION:
- return ctf_visitor_unary_expression(depth, node);
+ return ctf_visitor_unary_expression(depth, node, log_level);
case NODE_TYPEDEF:
switch (node->parent->type) {
depth++;
ret = _ctf_visitor_semantic_check(depth + 1,
- node->u.field_class_def.field_class_specifier_list);
+ node->u.field_class_def.field_class_specifier_list,
+ log_level);
if (ret)
return ret;
bt_list_for_each_entry(iter, &node->u.field_class_def.field_class_declarators, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
depth++;
ret = _ctf_visitor_semantic_check(depth + 1,
- node->u.field_class_alias_target.field_class_specifier_list);
+ node->u.field_class_alias_target.field_class_specifier_list,
+ log_level);
if (ret)
return ret;
nr_declarators = 0;
bt_list_for_each_entry(iter, &node->u.field_class_alias_target.field_class_declarators, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
nr_declarators++;
depth++;
ret = _ctf_visitor_semantic_check(depth + 1,
- node->u.field_class_alias_name.field_class_specifier_list);
+ node->u.field_class_alias_name.field_class_specifier_list,
+ log_level);
if (ret)
return ret;
nr_declarators = 0;
bt_list_for_each_entry(iter, &node->u.field_class_alias_name.field_class_declarators, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
nr_declarators++;
goto errinval;
}
- ret = _ctf_visitor_semantic_check(depth + 1, node->u.field_class_alias.target);
+ ret = _ctf_visitor_semantic_check(depth + 1,
+ node->u.field_class_alias.target, log_level);
if (ret)
return ret;
- ret = _ctf_visitor_semantic_check(depth + 1, node->u.field_class_alias.alias);
+ ret = _ctf_visitor_semantic_check(depth + 1,
+ node->u.field_class_alias.alias, log_level);
if (ret)
return ret;
break;
case NODE_TYPE_SPECIFIER_LIST:
- ret = ctf_visitor_field_class_specifier_list(depth, node);
+ ret = ctf_visitor_field_class_specifier_list(depth, node,
+ log_level);
if (ret)
return ret;
break;
case NODE_TYPE_SPECIFIER:
- ret = ctf_visitor_field_class_specifier(depth, node);
+ ret = ctf_visitor_field_class_specifier(depth, node,
+ log_level);
if (ret)
return ret;
break;
}
break;
case NODE_TYPE_DECLARATOR:
- ret = ctf_visitor_field_class_declarator(depth, node);
+ ret = ctf_visitor_field_class_declarator(depth, node,
+ log_level);
if (ret)
return ret;
break;
goto errperm;
}
bt_list_for_each_entry(iter, &node->u.floating_point.expressions, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
}
bt_list_for_each_entry(iter, &node->u.integer.expressions, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
}
bt_list_for_each_entry(iter, &node->u.string.expressions, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
}
bt_list_for_each_entry(iter, &node->u.enumerator.values, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
}
depth++;
- ret = _ctf_visitor_semantic_check(depth + 1, node->u._enum.container_field_class);
+ ret = _ctf_visitor_semantic_check(depth + 1,
+ node->u._enum.container_field_class, log_level);
if (ret)
return ret;
bt_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
goto errinval;
}
ret = _ctf_visitor_semantic_check(depth + 1,
- node->u.struct_or_variant_declaration.field_class_specifier_list);
+ node->u.struct_or_variant_declaration.field_class_specifier_list,
+ log_level);
if (ret)
return ret;
bt_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.field_class_declarators, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
goto errperm;
}
bt_list_for_each_entry(iter, &node->u.variant.declaration_list, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
goto errperm;
}
bt_list_for_each_entry(iter, &node->u._struct.declaration_list, siblings) {
- ret = _ctf_visitor_semantic_check(depth + 1, iter);
+ ret = _ctf_visitor_semantic_check(depth + 1, iter,
+ log_level);
if (ret)
return ret;
}
return -EPERM; /* Structure not allowed */
}
-int ctf_visitor_semantic_check(int depth, struct ctf_node *node)
+int ctf_visitor_semantic_check(int depth, struct ctf_node *node,
+ bt_logging_level log_level)
{
int ret = 0;
* take the safe route and recreate them at each validation, just in
* case the structure has changed.
*/
- ret = ctf_visitor_parent_links(depth, node);
+ ret = ctf_visitor_parent_links(depth, node, log_level);
if (ret) {
_BT_LOGE_LINENO(node->lineno,
"Cannot create parent links in metadata's AST: "
goto end;
}
- ret = _ctf_visitor_semantic_check(depth, node);
+ ret = _ctf_visitor_semantic_check(depth, node, log_level);
if (ret) {
_BT_LOGE_LINENO(node->lineno,
"Cannot check metadata's AST semantics: "
int ret = 0;
struct ctf_fs_file *file = NULL;
struct ctf_metadata_decoder_config decoder_config = {
+ .log_level = BT_LOG_OUTPUT_LEVEL,
.clock_class_offset_s = config ? config->clock_class_offset_s : 0,
.clock_class_offset_ns = config ? config->clock_class_offset_ns : 0,
};
}
is_packetized = ctf_metadata_decoder_is_packetized(metadata_fp,
- &bo);
+ &bo, BT_LOG_OUTPUT_LEVEL);
if (is_packetized) {
ret = ctf_metadata_decoder_packetized_file_stream_to_buf(
- metadata_fp, &metadata_text, bo);
+ metadata_fp, &metadata_text, bo,
+ BT_LOG_OUTPUT_LEVEL);
if (ret) {
BT_LOGE("Cannot decode packetized metadata file: path=\"%s\"",
path);
struct lttng_live_metadata *metadata = NULL;
struct lttng_live_trace *trace;
const char *match;
+ struct ctf_metadata_decoder_config cfg = {
+ .log_level = BT_LOG_OUTPUT_LEVEL,
+ .clock_class_offset_s = 0,
+ .clock_class_offset_ns = 0,
+ };
metadata = g_new0(struct lttng_live_metadata, 1);
if (!metadata) {
}
metadata->decoder = ctf_metadata_decoder_create(
- lttng_live->self_comp, NULL);
+ lttng_live->self_comp, &cfg);
if (!metadata->decoder) {
goto error;
}