/*
- * ctf-visitor-generate-ir.c
+ * SPDX-License-Identifier: MIT
*
- * Common Trace Format metadata visitor (generates CTF IR objects).
- *
- * Based on older ctf-visitor-generate-io-struct.c.
- *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright 2015-2018 - Philippe Proulx <philippe.proulx@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.
+ * Copyright 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2015-2018 Philippe Proulx <philippe.proulx@efficios.com>
*
- * 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.
+ * Common Trace Format metadata visitor (generates CTF IR objects).
*/
#define BT_COMP_LOG_SELF_COMP (ctx->log_cfg.self_comp)
+#define BT_COMP_LOG_SELF_COMP_CLASS (ctx->log_cfg.self_comp_class)
#define BT_LOG_OUTPUT_LEVEL (ctx->log_cfg.log_level)
#define BT_LOG_TAG "PLUGIN/CTF/META/IR-VISITOR"
-#include "plugins/comp-logging.h"
+#include "logging/comp-logging.h"
#include <stdio.h>
#include <unistd.h>
#include <inttypes.h>
#include <errno.h>
#include "common/common.h"
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include "compat/endian.h"
#include <babeltrace2/babeltrace.h>
#include "logging.h"
#include "scanner.h"
-#include "parser.h"
#include "ast.h"
#include "decoder.h"
#include "ctf-meta.h"
do { \
ret = ctx_push_scope(ctx); \
if (ret) { \
- BT_COMP_LOGE_STR("Cannot push scope."); \
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot push scope."); \
goto error; \
} \
} while (0)
#define _BT_LIST_FIRST_ENTRY(_ptr, _class, _member) \
bt_list_entry((_ptr)->next, _class, _member)
-#define _BT_COMP_LOGE_DUP_ATTR(_node, _attr, _entity) \
- _BT_COMP_LOGE_LINENO((_node)->lineno, \
+#define _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(_node, _attr, _entity) \
+ _BT_COMP_LOGE_APPEND_CAUSE_LINENO((_node)->lineno, \
"Duplicate attribute in %s: attr-name=\"%s\"", \
_entity, _attr)
#define _BT_COMP_LOGE_NODE(_node, _msg, args...) \
_BT_COMP_LOGE_LINENO((_node)->lineno, _msg, ## args)
+#define _BT_COMP_LOGE_APPEND_CAUSE_NODE(_node, _msg, args...) \
+ _BT_COMP_LOGE_APPEND_CAUSE_LINENO((_node)->lineno, _msg, ## args)
+
#define _BT_COMP_LOGW_NODE(_node, _msg, args...) \
_BT_COMP_LOGW_LINENO((_node)->lineno, _msg, ## args)
-#define _BT_COMP_LOGV_NODE(_node, _msg, args...) \
- _BT_COMP_LOGV_LINENO((_node)->lineno, _msg, ## args)
+#define _BT_COMP_LOGT_NODE(_node, _msg, args...) \
+ _BT_COMP_LOGT_LINENO((_node)->lineno, _msg, ## args)
/*
* Declaration scope of a visitor context. This represents a TSDL
scope = g_new(struct ctx_decl_scope, 1);
if (!scope) {
- BT_COMP_LOGE_STR("Failed to allocate one declaration scope.");
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Failed to allocate one declaration scope.");
goto end;
}
/* Prefix character + original string + '\0' */
char *prname = g_new(char, strlen(name) + 2);
if (!prname) {
- BT_COMP_LOGE_STR("Failed to allocate a string.");
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Failed to allocate a string.");
goto end;
}
ctx->log_cfg.log_level = decoder_config->log_level;
ctx->log_cfg.self_comp = decoder_config->self_comp;
+ ctx->log_cfg.self_comp_class = decoder_config->self_comp_class;
if (decoder_config->self_comp) {
ctx->trace_class = bt_trace_class_create(
decoder_config->self_comp);
if (!ctx->trace_class) {
- BT_COMP_LOGE_STR("Cannot create empty trace class.");
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot create empty trace class.");
goto error;
}
}
ctx->ctf_tc = ctf_trace_class_create();
if (!ctx->ctf_tc) {
- BT_COMP_LOGE_STR("Cannot create CTF trace class.");
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot create CTF trace class.");
goto error;
}
/* Root declaration scope */
ctx->current_scope = ctx_decl_scope_create(ctx, NULL);
if (!ctx->current_scope) {
- BT_COMP_LOGE_STR("Cannot create declaration scope.");
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot create declaration scope.");
goto error;
}
BT_ASSERT(ctx);
new_scope = ctx_decl_scope_create(ctx, ctx->current_scope);
if (!new_scope) {
- BT_COMP_LOGE_STR("Cannot create declaration scope.");
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot create declaration scope.");
ret = -ENOMEM;
goto end;
}
int visit_field_class_specifier_list(struct ctx *ctx, struct ctf_node *ts_list,
struct ctf_field_class **decl);
-static
-char *remove_underscores_from_field_ref(struct ctx *ctx, const char *field_ref)
-{
- const char *in_ch;
- char *out_ch;
- char *ret;
- enum {
- UNDERSCORE_REMOVE_STATE_REMOVE_NEXT_UNDERSCORE,
- UNDERSCORE_REMOVE_STATE_DO_NOT_REMOVE_NEXT_UNDERSCORE,
- } state = UNDERSCORE_REMOVE_STATE_REMOVE_NEXT_UNDERSCORE;
-
- BT_ASSERT(field_ref);
- ret = calloc(strlen(field_ref) + 1, 1);
- if (!ret) {
- BT_COMP_LOGE("Failed to allocate a string: size=%zu",
- strlen(field_ref) + 1);
- goto end;
- }
-
- in_ch = field_ref;
- out_ch = ret;
-
- while (*in_ch != '\0') {
- switch (*in_ch) {
- case ' ':
- case '\t':
- /* Remove whitespace */
- in_ch++;
- continue;
- case '_':
- if (state == UNDERSCORE_REMOVE_STATE_REMOVE_NEXT_UNDERSCORE) {
- in_ch++;
- state = UNDERSCORE_REMOVE_STATE_DO_NOT_REMOVE_NEXT_UNDERSCORE;
- continue;
- }
-
- goto copy;
- case '.':
- state = UNDERSCORE_REMOVE_STATE_REMOVE_NEXT_UNDERSCORE;
- goto copy;
- default:
- state = UNDERSCORE_REMOVE_STATE_DO_NOT_REMOVE_NEXT_UNDERSCORE;
- goto copy;
- }
-
-copy:
- *out_ch = *in_ch;
- in_ch++;
- out_ch++;
- }
-
-end:
- return ret;
-}
-
static
int is_unary_string(struct bt_list_head *head)
{
return ret;
}
-static
-char *concatenate_unary_strings(struct bt_list_head *head)
-{
- int i = 0;
- GString *str;
- struct ctf_node *node;
-
- str = g_string_new(NULL);
- BT_ASSERT(str);
-
- bt_list_for_each_entry(node, head, siblings) {
- char *src_string;
-
- if (
- node->type != NODE_UNARY_EXPRESSION ||
- node->u.unary_expression.type != UNARY_STRING ||
- !(
- (
- node->u.unary_expression.link !=
- UNARY_LINK_UNKNOWN
- ) ^ (i == 0)
- )
- ) {
- goto error;
- }
-
- switch (node->u.unary_expression.link) {
- case UNARY_DOTLINK:
- g_string_append(str, ".");
- break;
- case UNARY_ARROWLINK:
- g_string_append(str, "->");
- break;
- case UNARY_DOTDOTDOT:
- g_string_append(str, "...");
- break;
- default:
- break;
- }
-
- src_string = node->u.unary_expression.u.string;
- g_string_append(str, src_string);
- i++;
- }
-
- /* Destroys the container, returns the underlying string */
- return g_string_free(str, FALSE);
-
-error:
- /* This always returns NULL */
- return g_string_free(str, TRUE);
-}
-
static
const char *get_map_clock_name_value(struct bt_list_head *head)
{
uexpr_type != UNARY_UNSIGNED_CONSTANT ||
uexpr_link != UNARY_LINK_UNKNOWN || i != 0;
if (cond) {
- _BT_COMP_LOGE_NODE(node, "Invalid constant unsigned integer.");
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Invalid constant unsigned integer.");
ret = -EINVAL;
goto end;
}
static
int get_unary_uuid(struct ctx *ctx, struct bt_list_head *head,
- unsigned char *uuid)
+ bt_uuid_t uuid)
{
- int i = 0;
- int ret = 0;
- struct ctf_node *node;
-
- bt_list_for_each_entry(node, head, siblings) {
- int uexpr_type = node->u.unary_expression.type;
- int uexpr_link = node->u.unary_expression.link;
- const char *src_string;
-
- if (node->type != NODE_UNARY_EXPRESSION ||
- uexpr_type != UNARY_STRING ||
- uexpr_link != UNARY_LINK_UNKNOWN ||
- i != 0) {
- ret = -EINVAL;
- goto end;
- }
-
- src_string = node->u.unary_expression.u.string;
- ret = bt_uuid_parse(src_string, uuid);
- if (ret) {
- _BT_COMP_LOGE_NODE(node,
- "Cannot parse UUID: uuid=\"%s\"", src_string);
- goto end;
- }
- }
-
-end:
- return ret;
+ return ctf_ast_get_unary_uuid(head, uuid, ctx->log_cfg.log_level,
+ ctx->log_cfg.self_comp);
}
static
int ret = 0;
if (unary_expr->type != NODE_UNARY_EXPRESSION) {
- _BT_COMP_LOGE_NODE(unary_expr,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(unary_expr,
"Expecting unary expression: node-type=%d",
unary_expr->type);
ret = -EINVAL;
{
const char *str = unary_expr->u.unary_expression.u.string;
- if (!strcmp(str, "true") || !strcmp(str, "TRUE")) {
+ if (strcmp(str, "true") == 0 || strcmp(str, "TRUE") == 0) {
ret = TRUE;
- } else if (!strcmp(str, "false") || !strcmp(str, "FALSE")) {
+ } else if (strcmp(str, "false") == 0 || strcmp(str, "FALSE") == 0) {
ret = FALSE;
} else {
- _BT_COMP_LOGE_NODE(unary_expr,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(unary_expr,
"Unexpected boolean value: value=\"%s\"", str);
ret = -EINVAL;
goto end;
break;
}
default:
- _BT_COMP_LOGE_NODE(unary_expr,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(unary_expr,
"Unexpected unary expression type: node-type=%d",
unary_expr->u.unary_expression.type);
ret = -EINVAL;
struct ctf_node *unary_expr)
{
const char *str;
- enum ctf_byte_order bo = -1;
+ enum ctf_byte_order bo = CTF_BYTE_ORDER_UNKNOWN;
if (unary_expr->u.unary_expression.type != UNARY_STRING) {
- _BT_COMP_LOGE_NODE(unary_expr,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(unary_expr,
"\"byte_order\" attribute: expecting `be`, `le`, `network`, or `native`.");
goto end;
}
str = unary_expr->u.unary_expression.u.string;
- if (!strcmp(str, "be") || !strcmp(str, "network")) {
+ if (strcmp(str, "be") == 0 || strcmp(str, "network") == 0) {
bo = CTF_BYTE_ORDER_BIG;
- } else if (!strcmp(str, "le")) {
+ } else if (strcmp(str, "le") == 0) {
bo = CTF_BYTE_ORDER_LITTLE;
- } else if (!strcmp(str, "native")) {
+ } else if (strcmp(str, "native") == 0) {
bo = CTF_BYTE_ORDER_DEFAULT;
} else {
- _BT_COMP_LOGE_NODE(unary_expr,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(unary_expr,
"Unexpected \"byte_order\" attribute value: "
"expecting `be`, `le`, `network`, or `native`: value=\"%s\"",
str);
int ret = 0;
if (cls_specifier->type != NODE_TYPE_SPECIFIER) {
- _BT_COMP_LOGE_NODE(cls_specifier,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(cls_specifier,
"Unexpected node type: node-type=%d",
cls_specifier->type);
ret = -EINVAL;
struct ctf_node *node = cls_specifier->u.field_class_specifier.node;
if (!node->u._struct.name) {
- _BT_COMP_LOGE_NODE(node, "Unexpected empty structure field class name.");
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Unexpected empty structure field class name.");
ret = -EINVAL;
goto end;
}
struct ctf_node *node = cls_specifier->u.field_class_specifier.node;
if (!node->u.variant.name) {
- _BT_COMP_LOGE_NODE(node, "Unexpected empty variant field class name.");
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Unexpected empty variant field class name.");
ret = -EINVAL;
goto end;
}
struct ctf_node *node = cls_specifier->u.field_class_specifier.node;
if (!node->u._enum.enum_id) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Unexpected empty enumeration field class (`enum`) name.");
ret = -EINVAL;
goto end;
case TYPESPEC_INTEGER:
case TYPESPEC_STRING:
default:
- _BT_COMP_LOGE_NODE(cls_specifier->u.field_class_specifier.node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(cls_specifier->u.field_class_specifier.node,
"Unexpected field class specifier type: %d",
cls_specifier->u.field_class_specifier.type);
ret = -EINVAL;
if (node_field_class_declarator) {
if (node_field_class_declarator->u.field_class_declarator.type ==
TYPEDEC_UNKNOWN) {
- _BT_COMP_LOGE_NODE(node_field_class_declarator,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node_field_class_declarator,
"Unexpected field class declarator type: type=%d",
node_field_class_declarator->u.field_class_declarator.type);
ret = -EINVAL;
/* TODO: GCC bitfields not supported yet */
if (node_field_class_declarator->u.field_class_declarator.bitfield_len !=
NULL) {
- _BT_COMP_LOGE_NODE(node_field_class_declarator,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node_field_class_declarator,
"GCC bitfields are not supported as of this version.");
ret = -EPERM;
goto error;
ctx->current_scope,
g_quark_to_string(qalias), -1, true);
if (!nested_decl) {
- _BT_COMP_LOGE_NODE(node_field_class_declarator,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node_field_class_declarator,
"Cannot find class alias: name=\"%s\"",
g_quark_to_string(qalias));
ret = -EINVAL;
const char *id =
node_field_class_declarator->u.field_class_declarator.u.id;
- if (id[0] == '_') {
- id++;
- }
-
*field_name = g_quark_from_string(id);
} else {
*field_name = 0;
/* Create array/sequence, pass nested_decl as child */
if (bt_list_empty(length)) {
- _BT_COMP_LOGE_NODE(node_field_class_declarator,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node_field_class_declarator,
"Expecting length field reference or value.");
ret = -EINVAL;
goto error;
first = _BT_LIST_FIRST_ENTRY(length, struct ctf_node, siblings);
if (first->type != NODE_UNARY_EXPRESSION) {
- _BT_COMP_LOGE_NODE(first,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(first,
"Unexpected node type: node-type=%d",
first->type);
ret = -EINVAL;
{
/* Lookup unsigned integer definition, create seq. */
struct ctf_field_class_sequence *seq_decl = NULL;
- char *length_name = concatenate_unary_strings(length);
+ char *length_name = ctf_ast_concatenate_unary_strings(length);
if (!length_name) {
- _BT_COMP_LOGE_NODE(node_field_class_declarator,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node_field_class_declarator,
"Cannot concatenate unary strings.");
ret = -EINVAL;
goto error;
struct ctf_field_class_array *array_decl;
if (!env_entry) {
- _BT_COMP_LOGE_NODE(node_field_class_declarator,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node_field_class_declarator,
"Cannot find environment entry: "
"name=\"%s\"", env_entry_name);
ret = -EINVAL;
}
if (env_entry->type != CTF_TRACE_CLASS_ENV_ENTRY_TYPE_INT) {
- _BT_COMP_LOGE_NODE(node_field_class_declarator,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node_field_class_declarator,
"Wrong environment entry type "
"(expecting integer): "
"name=\"%s\"", env_entry_name);
}
if (env_entry->value.i < 0) {
- _BT_COMP_LOGE_NODE(node_field_class_declarator,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node_field_class_declarator,
"Invalid, negative array length: "
"env-entry-name=\"%s\", "
"value=%" PRId64,
nested_decl = NULL;
decl = (void *) array_decl;
} else {
- char *length_name_no_underscore =
- remove_underscores_from_field_ref(ctx,
- length_name);
- if (!length_name_no_underscore) {
- /*
- * remove_underscores_from_field_ref()
- * logs errors
- */
- ret = -EINVAL;
- goto error;
- }
seq_decl = ctf_field_class_sequence_create();
BT_ASSERT(seq_decl);
seq_decl->base.elem_fc = nested_decl;
nested_decl = NULL;
g_string_assign(seq_decl->length_ref,
- length_name_no_underscore);
- free(length_name_no_underscore);
+ length_name);
decl = (void *) seq_decl;
}
&qfield_name, iter, &field_decl, NULL);
if (ret) {
BT_ASSERT(!field_decl);
- _BT_COMP_LOGE_NODE(cls_specifier_list,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(cls_specifier_list,
"Cannot visit field class declarator: ret=%d", ret);
goto error;
}
/* Check if field with same name already exists */
if (ctf_field_class_struct_borrow_member_by_name(
struct_decl, field_name)) {
- _BT_COMP_LOGE_NODE(cls_specifier_list,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(cls_specifier_list,
"Duplicate field in structure field class: "
"field-name=\"%s\"", field_name);
ret = -EINVAL;
&qfield_name, iter, &field_decl, NULL);
if (ret) {
BT_ASSERT(!field_decl);
- _BT_COMP_LOGE_NODE(cls_specifier_list,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(cls_specifier_list,
"Cannot visit field class declarator: ret=%d", ret);
goto error;
}
/* Check if field with same name already exists */
if (ctf_field_class_variant_borrow_option_by_name(
variant_decl, field_name)) {
- _BT_COMP_LOGE_NODE(cls_specifier_list,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(cls_specifier_list,
"Duplicate field in variant field class: "
"field-name=\"%s\"", field_name);
ret = -EINVAL;
ret = visit_field_class_declarator(ctx, cls_specifier_list,
&qidentifier, iter, &class_decl, NULL);
if (ret) {
- _BT_COMP_LOGE_NODE(iter,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
"Cannot visit field class declarator: ret=%d", ret);
ret = -EINVAL;
goto end;
(void *) class_decl;
if (var_fc->tag_path.path->len == 0) {
- _BT_COMP_LOGE_NODE(iter,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
"Type definition of untagged variant field class is not allowed.");
ret = -EPERM;
goto end;
ret = ctx_decl_scope_register_alias(ctx, ctx->current_scope,
g_quark_to_string(qidentifier), class_decl);
if (ret) {
- _BT_COMP_LOGE_NODE(iter,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
"Cannot register field class alias: name=\"%s\"",
g_quark_to_string(qidentifier));
goto end;
&qdummy_field_name, node, &class_decl, NULL);
if (ret) {
BT_ASSERT(!class_decl);
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot visit field class declarator: ret=%d", ret);
goto end;
}
struct ctf_field_class_variant *var_fc = (void *) class_decl;
if (var_fc->tag_path.path->len == 0) {
- _BT_COMP_LOGE_NODE(target,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(target,
"Type definition of untagged variant field class is not allowed.");
ret = -EPERM;
goto end;
* abstract or not (if it has an identifier). Check it here.
*/
if (qdummy_field_name != 0) {
- _BT_COMP_LOGE_NODE(target,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(target,
"Expecting empty identifier: id=\"%s\"",
g_quark_to_string(qdummy_field_name));
ret = -EINVAL;
ret = ctx_decl_scope_register_alias(ctx, ctx->current_scope,
g_quark_to_string(qalias), class_decl);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot register class alias: name=\"%s\"",
g_quark_to_string(qalias));
goto end;
entry_node->u.field_class_def.field_class_specifier_list,
&entry_node->u.field_class_def.field_class_declarators);
if (ret) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Cannot add field class found in structure field class: ret=%d",
ret);
goto end;
ret = visit_field_class_alias(ctx, entry_node->u.field_class_alias.target,
entry_node->u.field_class_alias.alias);
if (ret) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Cannot add field class alias found in structure field class: ret=%d",
ret);
goto end;
}
break;
default:
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Unexpected node type: node-type=%d", entry_node->type);
ret = -EINVAL;
goto end;
entry_node->u.field_class_def.field_class_specifier_list,
&entry_node->u.field_class_def.field_class_declarators);
if (ret) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Cannot add field class found in variant field class: ret=%d",
ret);
goto end;
ret = visit_field_class_alias(ctx, entry_node->u.field_class_alias.target,
entry_node->u.field_class_alias.alias);
if (ret) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Cannot add field class alias found in variant field class: ret=%d",
ret);
goto end;
}
break;
default:
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Unexpected node type: node-type=%d",
entry_node->type);
ret = -EINVAL;
/* For named struct (without body), lookup in declaration scope */
if (!has_body) {
if (!name) {
- BT_COMP_LOGE_STR("Bodyless structure field class: missing name.");
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Bodyless structure field class: missing name.");
ret = -EPERM;
goto error;
}
*struct_decl = ctx_decl_scope_lookup_struct(ctx, ctx->current_scope,
name, -1, true);
if (!*struct_decl) {
- BT_COMP_LOGE("Cannot find structure field class: name=\"struct %s\"",
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot find structure field class: name=\"struct %s\"",
name);
ret = -EINVAL;
goto error;
if (name) {
if (ctx_decl_scope_lookup_struct(ctx,
ctx->current_scope, name, 1, false)) {
- BT_COMP_LOGE("Structure field class already declared in local scope: "
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Structure field class already declared in local scope: "
"name=\"struct %s\"", name);
ret = -EINVAL;
goto error;
ret = get_unary_unsigned(ctx, min_align,
&min_align_value);
if (ret) {
- BT_COMP_LOGE("Unexpected unary expression for structure field class's `align` attribute: "
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Unexpected unary expression for structure field class's `align` attribute: "
"ret=%d", ret);
goto error;
}
ret = visit_struct_decl_entry(ctx, entry_node,
*struct_decl);
if (ret) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Cannot visit structure field class entry: "
"ret=%d", ret);
ctx_pop_scope(ctx);
ret = ctx_decl_scope_register_struct(ctx,
ctx->current_scope, name, *struct_decl);
if (ret) {
- BT_COMP_LOGE("Cannot register structure field class in declaration scope: "
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot register structure field class in declaration scope: "
"name=\"struct %s\", ret=%d", name, ret);
goto error;
}
/* For named variant (without body), lookup in declaration scope */
if (!has_body) {
if (!name) {
- BT_COMP_LOGE_STR("Bodyless variant field class: missing name.");
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Bodyless variant field class: missing name.");
ret = -EPERM;
goto error;
}
ctx_decl_scope_lookup_variant(ctx, ctx->current_scope,
name, -1, true);
if (!untagged_variant_decl) {
- BT_COMP_LOGE("Cannot find variant field class: name=\"variant %s\"",
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot find variant field class: name=\"variant %s\"",
name);
ret = -EINVAL;
goto error;
if (name) {
if (ctx_decl_scope_lookup_variant(ctx,
ctx->current_scope, name, 1, false)) {
- BT_COMP_LOGE("Variant field class already declared in local scope: "
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Variant field class already declared in local scope: "
"name=\"variant %s\"", name);
ret = -EINVAL;
goto error;
ret = visit_variant_decl_entry(ctx, entry_node,
untagged_variant_decl);
if (ret) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Cannot visit variant field class entry: "
"ret=%d", ret);
ctx_pop_scope(ctx);
ctx->current_scope, name,
untagged_variant_decl);
if (ret) {
- BT_COMP_LOGE("Cannot register variant field class in declaration scope: "
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot register variant field class in declaration scope: "
"name=\"variant %s\", ret=%d", name, ret);
goto error;
}
* At this point, we have a fresh untagged variant; nobody
* else owns it. Set its tag now.
*/
- char *tag_no_underscore =
- remove_underscores_from_field_ref(ctx, tag);
-
- if (!tag_no_underscore) {
- /* remove_underscores_from_field_ref() logs errors */
- goto error;
- }
-
- g_string_assign(untagged_variant_decl->tag_ref,
- tag_no_underscore);
- free(tag_no_underscore);
+ g_string_assign(untagged_variant_decl->tag_ref, tag);
*variant_decl = untagged_variant_decl;
untagged_variant_decl = NULL;
}
.value.u = 0,
};
const char *label = enumerator->u.enumerator.id;
- const char *effective_label = label;
struct bt_list_head *values = &enumerator->u.enumerator.values;
bt_list_for_each_entry(iter, values, siblings) {
struct uori *target;
if (iter->type != NODE_UNARY_EXPRESSION) {
- _BT_COMP_LOGE_NODE(iter,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
"Wrong expression for enumeration field class label: "
"node-type=%d, label=\"%s\"", iter->type,
label);
iter->u.unary_expression.u.unsigned_constant;
break;
default:
- _BT_COMP_LOGE_NODE(iter,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
"Invalid enumeration field class entry: "
"expecting constant signed or unsigned integer: "
"node-type=%d, label=\"%s\"",
}
if (nr_vals > 1) {
- _BT_COMP_LOGE_NODE(iter,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
"Invalid enumeration field class entry: label=\"%s\"",
label);
ret = -EINVAL;
last->value.u = end.value.u + 1;
}
- if (label[0] == '_') {
- /*
- * Strip the first underscore of any enumeration field
- * class's label in case this enumeration FC is used as
- * a variant FC tag later. The variant FC choice names
- * could also start with `_`, in which case the prefix
- * is removed, and it the resulting choice name needs to
- * match tag labels.
- */
- effective_label = &label[1];
- }
-
- ctf_field_class_enum_append_mapping(enum_decl, effective_label,
+ ctf_field_class_enum_map_range(enum_decl, label,
start.value.u, end.value.u);
return 0;
/* For named enum (without body), lookup in declaration scope */
if (!has_body) {
if (!name) {
- BT_COMP_LOGE_STR("Bodyless enumeration field class: missing name.");
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Bodyless enumeration field class: missing name.");
ret = -EPERM;
goto error;
}
*enum_decl = ctx_decl_scope_lookup_enum(ctx, ctx->current_scope,
name, -1, true);
if (!*enum_decl) {
- BT_COMP_LOGE("Cannot find enumeration field class: "
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot find enumeration field class: "
"name=\"enum %s\"", name);
ret = -EINVAL;
goto error;
if (name) {
if (ctx_decl_scope_lookup_enum(ctx, ctx->current_scope,
name, 1, false)) {
- BT_COMP_LOGE("Enumeration field class already declared in local scope: "
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Enumeration field class already declared in local scope: "
"name=\"enum %s\"", name);
ret = -EINVAL;
goto error;
integer_decl = (void *) ctx_decl_scope_lookup_alias(ctx,
ctx->current_scope, "int", -1, true);
if (!integer_decl) {
- BT_COMP_LOGE_STR("Cannot find implicit `int` field class alias for enumeration field class.");
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot find implicit `int` field class alias for enumeration field class.");
ret = -EINVAL;
goto error;
}
BT_ASSERT(integer_decl);
if (integer_decl->base.base.type != CTF_FIELD_CLASS_TYPE_INT) {
- BT_COMP_LOGE("Container field class for enumeration field class is not an integer field class: "
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Container field class for enumeration field class is not an integer field class: "
"fc-type=%d", integer_decl->base.base.type);
ret = -EINVAL;
goto error;
ret = visit_enum_decl_entry(ctx, iter, *enum_decl,
&last_value);
if (ret) {
- _BT_COMP_LOGE_NODE(iter,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
"Cannot visit enumeration field class entry: "
"ret=%d", ret);
goto error;
ret = ctx_decl_scope_register_enum(ctx,
ctx->current_scope, name, *enum_decl);
if (ret) {
- BT_COMP_LOGE("Cannot register enumeration field class in declaration scope: "
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot register enumeration field class in declaration scope: "
"ret=%d", ret);
goto error;
}
str = g_string_new("");
ret = get_class_specifier_list_name(ctx, cls_specifier_list, str);
if (ret) {
- _BT_COMP_LOGE_NODE(cls_specifier_list,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(cls_specifier_list,
"Cannot get field class specifier list's name: ret=%d", ret);
goto error;
}
*decl = ctx_decl_scope_lookup_alias(ctx, ctx->current_scope, str->str,
-1, true);
if (!*decl) {
- _BT_COMP_LOGE_NODE(cls_specifier_list,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(cls_specifier_list,
"Cannot find field class alias: name=\"%s\"", str->str);
ret = -EINVAL;
goto error;
siblings);
if (left->u.unary_expression.type != UNARY_STRING) {
- _BT_COMP_LOGE_NODE(left,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(left,
"Unexpected unary expression type: type=%d",
left->u.unary_expression.type);
ret = -EINVAL;
goto error;
}
- if (!strcmp(left->u.unary_expression.u.string, "signed")) {
+ if (strcmp(left->u.unary_expression.u.string, "signed") == 0) {
if (_IS_SET(&set, _INTEGER_SIGNED_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(left, "signed",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "signed",
"integer field class");
ret = -EPERM;
goto error;
signedness = get_boolean(ctx, right);
if (signedness < 0) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid boolean value for integer field class's `signed` attribute: "
"ret=%d", ret);
ret = -EINVAL;
}
_SET(&set, _INTEGER_SIGNED_SET);
- } else if (!strcmp(left->u.unary_expression.u.string,
- "byte_order")) {
+ } else if (strcmp(left->u.unary_expression.u.string, "byte_order") == 0) {
if (_IS_SET(&set, _INTEGER_BYTE_ORDER_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(left, "byte_order",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "byte_order",
"integer field class");
ret = -EPERM;
goto error;
}
byte_order = get_real_byte_order(ctx, right);
- if (byte_order == -1) {
- _BT_COMP_LOGE_NODE(right,
+ if (byte_order == CTF_BYTE_ORDER_UNKNOWN) {
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `byte_order` attribute in integer field class: "
"ret=%d", ret);
ret = -EINVAL;
}
_SET(&set, _INTEGER_BYTE_ORDER_SET);
- } else if (!strcmp(left->u.unary_expression.u.string, "size")) {
+ } else if (strcmp(left->u.unary_expression.u.string, "size") == 0) {
if (_IS_SET(&set, _INTEGER_SIZE_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(left, "size",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "size",
"integer field class");
ret = -EPERM;
goto error;
if (right->u.unary_expression.type !=
UNARY_UNSIGNED_CONSTANT) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `size` attribute in integer field class: "
"expecting unsigned constant integer: "
"node-type=%d",
size = right->u.unary_expression.u.unsigned_constant;
if (size == 0) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `size` attribute in integer field class: "
"expecting positive constant integer: "
"size=%" PRIu64, size);
ret = -EINVAL;
goto error;
} else if (size > 64) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `size` attribute in integer field class: "
"integer fields over 64 bits are not supported as of this version: "
"size=%" PRIu64, size);
}
_SET(&set, _INTEGER_SIZE_SET);
- } else if (!strcmp(left->u.unary_expression.u.string,
- "align")) {
+ } else if (strcmp(left->u.unary_expression.u.string, "align") == 0) {
if (_IS_SET(&set, _INTEGER_ALIGN_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(left, "align",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "align",
"integer field class");
ret = -EPERM;
goto error;
if (right->u.unary_expression.type !=
UNARY_UNSIGNED_CONSTANT) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `align` attribute in integer field class: "
"expecting unsigned constant integer: "
"node-type=%d",
alignment =
right->u.unary_expression.u.unsigned_constant;
if (!is_align_valid(alignment)) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `align` attribute in integer field class: "
"expecting power of two: "
"align=%" PRIu64, alignment);
}
_SET(&set, _INTEGER_ALIGN_SET);
- } else if (!strcmp(left->u.unary_expression.u.string, "base")) {
+ } else if (strcmp(left->u.unary_expression.u.string, "base") == 0) {
if (_IS_SET(&set, _INTEGER_BASE_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(left, "base",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "base",
"integer field class");
ret = -EPERM;
goto error;
base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL;
break;
default:
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `base` attribute in integer field class: "
"base=%" PRIu64,
right->u.unary_expression.u.unsigned_constant);
}
case UNARY_STRING:
{
- char *s_right = concatenate_unary_strings(
+ char *s_right = ctf_ast_concatenate_unary_strings(
&expression->u.ctf_expression.right);
if (!s_right) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Unexpected unary expression for integer field class's `base` attribute.");
ret = -EINVAL;
goto error;
}
- if (!strcmp(s_right, "decimal") ||
- !strcmp(s_right, "dec") ||
- !strcmp(s_right, "d") ||
- !strcmp(s_right, "i") ||
- !strcmp(s_right, "u")) {
+ if (strcmp(s_right, "decimal") == 0 ||
+ strcmp(s_right, "dec") == 0 ||
+ strcmp(s_right, "d") == 0 ||
+ strcmp(s_right, "i") == 0 ||
+ strcmp(s_right, "u") == 0) {
base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL;
- } else if (!strcmp(s_right, "hexadecimal") ||
- !strcmp(s_right, "hex") ||
- !strcmp(s_right, "x") ||
- !strcmp(s_right, "X") ||
- !strcmp(s_right, "p")) {
+ } else if (strcmp(s_right, "hexadecimal") == 0 ||
+ strcmp(s_right, "hex") == 0 ||
+ strcmp(s_right, "x") == 0 ||
+ strcmp(s_right, "X") == 0 ||
+ strcmp(s_right, "p") == 0) {
base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL;
- } else if (!strcmp(s_right, "octal") ||
- !strcmp(s_right, "oct") ||
- !strcmp(s_right, "o")) {
+ } else if (strcmp(s_right, "octal") == 0 ||
+ strcmp(s_right, "oct") == 0 ||
+ strcmp(s_right, "o") == 0) {
base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL;
- } else if (!strcmp(s_right, "binary") ||
- !strcmp(s_right, "b")) {
+ } else if (strcmp(s_right, "binary") == 0 ||
+ strcmp(s_right, "b") == 0) {
base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY;
} else {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Unexpected unary expression for integer field class's `base` attribute: "
"base=\"%s\"", s_right);
g_free(s_right);
break;
}
default:
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `base` attribute in integer field class: "
"expecting unsigned constant integer or unary string.");
ret = -EINVAL;
}
_SET(&set, _INTEGER_BASE_SET);
- } else if (!strcmp(left->u.unary_expression.u.string,
- "encoding")) {
+ } else if (strcmp(left->u.unary_expression.u.string, "encoding") == 0) {
char *s_right;
if (_IS_SET(&set, _INTEGER_ENCODING_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(left, "encoding",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "encoding",
"integer field class");
ret = -EPERM;
goto error;
}
if (right->u.unary_expression.type != UNARY_STRING) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `encoding` attribute in integer field class: "
"expecting unary string.");
ret = -EINVAL;
goto error;
}
- s_right = concatenate_unary_strings(
+ s_right = ctf_ast_concatenate_unary_strings(
&expression->u.ctf_expression.right);
if (!s_right) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Unexpected unary expression for integer field class's `encoding` attribute.");
ret = -EINVAL;
goto error;
}
- if (!strcmp(s_right, "UTF8") ||
- !strcmp(s_right, "utf8") ||
- !strcmp(s_right, "utf-8") ||
- !strcmp(s_right, "UTF-8") ||
- !strcmp(s_right, "ASCII") ||
- !strcmp(s_right, "ascii")) {
+ if (strcmp(s_right, "UTF8") == 0 ||
+ strcmp(s_right, "utf8") == 0 ||
+ strcmp(s_right, "utf-8") == 0 ||
+ strcmp(s_right, "UTF-8") == 0 ||
+ strcmp(s_right, "ASCII") == 0 ||
+ strcmp(s_right, "ascii") == 0) {
encoding = CTF_ENCODING_UTF8;
- } else if (!strcmp(s_right, "none")) {
+ } else if (strcmp(s_right, "none") == 0) {
encoding = CTF_ENCODING_NONE;
} else {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `encoding` attribute in integer field class: "
"unknown encoding: encoding=\"%s\"",
s_right);
g_free(s_right);
_SET(&set, _INTEGER_ENCODING_SET);
- } else if (!strcmp(left->u.unary_expression.u.string, "map")) {
+ } else if (strcmp(left->u.unary_expression.u.string, "map") == 0) {
const char *clock_name;
if (_IS_SET(&set, _INTEGER_MAP_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(left, "map",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "map",
"integer field class");
ret = -EPERM;
goto error;
}
if (right->u.unary_expression.type != UNARY_STRING) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `map` attribute in integer field class: "
"expecting unary string.");
ret = -EINVAL;
get_map_clock_name_value(
&expression->u.ctf_expression.right);
if (!clock_name) {
- char *s_right = concatenate_unary_strings(
+ char *s_right = ctf_ast_concatenate_unary_strings(
&expression->u.ctf_expression.right);
if (!s_right) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Unexpected unary expression for integer field class's `map` attribute.");
ret = -EINVAL;
goto error;
ctf_trace_class_borrow_clock_class_by_name(
ctx->ctf_tc, clock_name);
if (!mapped_clock_class) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `map` attribute in integer field class: "
"cannot find clock class at this point: name=\"%s\"",
clock_name);
}
if (!_IS_SET(&set, _INTEGER_SIZE_SET)) {
- BT_COMP_LOGE_STR("Missing `size` attribute in integer field class.");
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Missing `size` attribute in integer field class.");
ret = -EPERM;
goto error;
}
siblings);
if (left->u.unary_expression.type != UNARY_STRING) {
- _BT_COMP_LOGE_NODE(left,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(left,
"Unexpected unary expression type: type=%d",
left->u.unary_expression.type);
ret = -EINVAL;
goto error;
}
- if (!strcmp(left->u.unary_expression.u.string, "byte_order")) {
+ if (strcmp(left->u.unary_expression.u.string, "byte_order") == 0) {
if (_IS_SET(&set, _FLOAT_BYTE_ORDER_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(left, "byte_order",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "byte_order",
"floating point number field class");
ret = -EPERM;
goto error;
}
byte_order = get_real_byte_order(ctx, right);
- if (byte_order == -1) {
- _BT_COMP_LOGE_NODE(right,
+ if (byte_order == CTF_BYTE_ORDER_UNKNOWN) {
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `byte_order` attribute in floating point number field class: "
"ret=%d", ret);
ret = -EINVAL;
}
_SET(&set, _FLOAT_BYTE_ORDER_SET);
- } else if (!strcmp(left->u.unary_expression.u.string,
- "exp_dig")) {
+ } else if (strcmp(left->u.unary_expression.u.string, "exp_dig") == 0) {
if (_IS_SET(&set, _FLOAT_EXP_DIG_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(left, "exp_dig",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "exp_dig",
"floating point number field class");
ret = -EPERM;
goto error;
if (right->u.unary_expression.type !=
UNARY_UNSIGNED_CONSTANT) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `exp_dig` attribute in floating point number field class: "
"expecting unsigned constant integer: "
"node-type=%d",
exp_dig = right->u.unary_expression.u.unsigned_constant;
_SET(&set, _FLOAT_EXP_DIG_SET);
- } else if (!strcmp(left->u.unary_expression.u.string,
- "mant_dig")) {
+ } else if (strcmp(left->u.unary_expression.u.string, "mant_dig") == 0) {
if (_IS_SET(&set, _FLOAT_MANT_DIG_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(left, "mant_dig",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "mant_dig",
"floating point number field class");
ret = -EPERM;
goto error;
if (right->u.unary_expression.type !=
UNARY_UNSIGNED_CONSTANT) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `mant_dig` attribute in floating point number field class: "
"expecting unsigned constant integer: "
"node-type=%d",
mant_dig = right->u.unary_expression.u.
unsigned_constant;
_SET(&set, _FLOAT_MANT_DIG_SET);
- } else if (!strcmp(left->u.unary_expression.u.string,
- "align")) {
+ } else if (strcmp(left->u.unary_expression.u.string, "align") == 0) {
if (_IS_SET(&set, _FLOAT_ALIGN_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(left, "align",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "align",
"floating point number field class");
ret = -EPERM;
goto error;
if (right->u.unary_expression.type !=
UNARY_UNSIGNED_CONSTANT) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `align` attribute in floating point number field class: "
"expecting unsigned constant integer: "
"node-type=%d",
unsigned_constant;
if (!is_align_valid(alignment)) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `align` attribute in floating point number field class: "
"expecting power of two: "
"align=%" PRIu64, alignment);
}
if (!_IS_SET(&set, _FLOAT_MANT_DIG_SET)) {
- BT_COMP_LOGE_STR("Missing `mant_dig` attribute in floating point number field class.");
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Missing `mant_dig` attribute in floating point number field class.");
ret = -EPERM;
goto error;
}
if (!_IS_SET(&set, _FLOAT_EXP_DIG_SET)) {
- BT_COMP_LOGE_STR("Missing `exp_dig` attribute in floating point number field class.");
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Missing `exp_dig` attribute in floating point number field class.");
ret = -EPERM;
goto error;
}
if (mant_dig != 24 && mant_dig != 53) {
- BT_COMP_LOGE_STR("`mant_dig` attribute: expecting 24 or 53.");
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("`mant_dig` attribute: expecting 24 or 53.");
ret = -EPERM;
goto error;
}
if (mant_dig == 24 && exp_dig != 8) {
- BT_COMP_LOGE_STR("`exp_dig` attribute: expecting 8 because `mant_dig` is 24.");
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("`exp_dig` attribute: expecting 8 because `mant_dig` is 24.");
ret = -EPERM;
goto error;
}
if (mant_dig == 53 && exp_dig != 11) {
- BT_COMP_LOGE_STR("`exp_dig` attribute: expecting 11 because `mant_dig` is 53.");
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("`exp_dig` attribute: expecting 11 because `mant_dig` is 53.");
ret = -EPERM;
goto error;
}
siblings);
if (left->u.unary_expression.type != UNARY_STRING) {
- _BT_COMP_LOGE_NODE(left,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(left,
"Unexpected unary expression type: type=%d",
left->u.unary_expression.type);
ret = -EINVAL;
goto error;
}
- if (!strcmp(left->u.unary_expression.u.string, "encoding")) {
+ if (strcmp(left->u.unary_expression.u.string, "encoding") == 0) {
char *s_right;
if (_IS_SET(&set, _STRING_ENCODING_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(left, "encoding",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(left, "encoding",
"string field class");
ret = -EPERM;
goto error;
}
if (right->u.unary_expression.type != UNARY_STRING) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `encoding` attribute in string field class: "
"expecting unary string.");
ret = -EINVAL;
goto error;
}
- s_right = concatenate_unary_strings(
+ s_right = ctf_ast_concatenate_unary_strings(
&expression->u.ctf_expression.right);
if (!s_right) {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Unexpected unary expression for string field class's `encoding` attribute.");
ret = -EINVAL;
goto error;
}
- if (!strcmp(s_right, "UTF8") ||
- !strcmp(s_right, "utf8") ||
- !strcmp(s_right, "utf-8") ||
- !strcmp(s_right, "UTF-8") ||
- !strcmp(s_right, "ASCII") ||
- !strcmp(s_right, "ascii")) {
+ if (strcmp(s_right, "UTF8") == 0 ||
+ strcmp(s_right, "utf8") == 0 ||
+ strcmp(s_right, "utf-8") == 0 ||
+ strcmp(s_right, "UTF-8") == 0 ||
+ strcmp(s_right, "ASCII") == 0 ||
+ strcmp(s_right, "ascii") == 0) {
encoding = CTF_ENCODING_UTF8;
- } else if (!strcmp(s_right, "none")) {
+ } else if (strcmp(s_right, "none") == 0) {
encoding = CTF_ENCODING_NONE;
} else {
- _BT_COMP_LOGE_NODE(right,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(right,
"Invalid `encoding` attribute in string field class: "
"unknown encoding: encoding=\"%s\"",
s_right);
*decl = NULL;
if (ts_list->type != NODE_TYPE_SPECIFIER_LIST) {
- _BT_COMP_LOGE_NODE(ts_list,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(ts_list,
"Unexpected node type: node-type=%d", ts_list->type);
ret = -EINVAL;
goto error;
first = _BT_LIST_FIRST_ENTRY(&ts_list->u.field_class_specifier_list.head,
struct ctf_node, siblings);
if (first->type != NODE_TYPE_SPECIFIER) {
- _BT_COMP_LOGE_NODE(first,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(first,
"Unexpected node type: node-type=%d", first->type);
ret = -EINVAL;
goto error;
case TYPESPEC_ID_TYPE:
ret = visit_field_class_specifier(ctx, ts_list, decl);
if (ret) {
- _BT_COMP_LOGE_NODE(first,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(first,
"Cannot visit field class specifier: ret=%d",
ret);
BT_ASSERT(!*decl);
}
break;
default:
- _BT_COMP_LOGE_NODE(first,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(first,
"Unexpected field class specifier type: node-type=%d",
first->u.field_class_specifier.type);
ret = -EINVAL;
ret = visit_field_class_def(ctx, node->u.field_class_def.field_class_specifier_list,
&node->u.field_class_def.field_class_declarators);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot add field class found in event class.");
goto error;
}
ret = visit_field_class_alias(ctx, node->u.field_class_alias.target,
node->u.field_class_alias.alias);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot add field class alias found in event class.");
goto error;
}
break;
case NODE_CTF_EXPRESSION:
{
- left = concatenate_unary_strings(&node->u.ctf_expression.left);
+ left = ctf_ast_concatenate_unary_strings(&node->u.ctf_expression.left);
if (!left) {
- _BT_COMP_LOGE_NODE(node, "Cannot concatenate unary strings.");
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Cannot concatenate unary strings.");
ret = -EINVAL;
goto error;
}
- if (!strcmp(left, "name")) {
+ if (strcmp(left, "name") == 0) {
/* This is already known at this stage */
if (_IS_SET(set, _EVENT_NAME_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(node, "name", "event class");
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "name", "event class");
ret = -EPERM;
goto error;
}
_SET(set, _EVENT_NAME_SET);
- } else if (!strcmp(left, "id")) {
+ } else if (strcmp(left, "id") == 0) {
int64_t id = -1;
if (_IS_SET(set, _EVENT_ID_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(node, "id", "event class");
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "id", "event class");
ret = -EPERM;
goto error;
}
(uint64_t *) &id);
/* Only read "id" if get_unary_unsigned() succeeded. */
if (ret || (!ret && id < 0)) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Unexpected unary expression for event class's `id` attribute.");
ret = -EINVAL;
goto error;
event_class->id = id;
_SET(set, _EVENT_ID_SET);
- } else if (!strcmp(left, "stream_id")) {
+ } else if (strcmp(left, "stream_id") == 0) {
if (_IS_SET(set, _EVENT_STREAM_ID_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(node, "stream_id",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "stream_id",
"event class");
ret = -EPERM;
goto error;
* succeeded.
*/
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Unexpected unary expression for event class's `stream_id` attribute.");
ret = -EINVAL;
goto error;
}
_SET(set, _EVENT_STREAM_ID_SET);
- } else if (!strcmp(left, "context")) {
+ } else if (strcmp(left, "context") == 0) {
if (_IS_SET(set, _EVENT_CONTEXT_SET)) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Duplicate `context` entry in event class.");
ret = -EPERM;
goto error;
struct ctf_node, siblings),
&event_class->spec_context_fc);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot create event class's context field class.");
goto error;
}
BT_ASSERT(event_class->spec_context_fc);
_SET(set, _EVENT_CONTEXT_SET);
- } else if (!strcmp(left, "fields")) {
+ } else if (strcmp(left, "fields") == 0) {
if (_IS_SET(set, _EVENT_FIELDS_SET)) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Duplicate `fields` entry in event class.");
ret = -EPERM;
goto error;
struct ctf_node, siblings),
&event_class->payload_fc);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot create event class's payload field class.");
goto error;
}
BT_ASSERT(event_class->payload_fc);
_SET(set, _EVENT_FIELDS_SET);
- } else if (!strcmp(left, "loglevel")) {
+ } else if (strcmp(left, "loglevel") == 0) {
uint64_t loglevel_value;
+ bool is_log_level_known = true;
bt_event_class_log_level log_level = -1;
if (_IS_SET(set, _EVENT_LOG_LEVEL_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(node, "loglevel",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "loglevel",
"event class");
ret = -EPERM;
goto error;
ret = get_unary_unsigned(ctx,
&node->u.ctf_expression.right, &loglevel_value);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Unexpected unary expression for event class's `loglevel` attribute.");
ret = -EINVAL;
goto error;
log_level = BT_EVENT_CLASS_LOG_LEVEL_DEBUG;
break;
default:
+ is_log_level_known = false;
_BT_COMP_LOGW_NODE(node, "Not setting event class's log level because its value is unknown: "
"log-level=%" PRIu64, loglevel_value);
}
- if (log_level != -1) {
- event_class->log_level = log_level;
+ if (is_log_level_known) {
+ ctf_event_class_set_log_level(event_class, log_level);
}
_SET(set, _EVENT_LOG_LEVEL_SET);
- } else if (!strcmp(left, "model.emf.uri")) {
+ } else if (strcmp(left, "model.emf.uri") == 0) {
char *right;
if (_IS_SET(set, _EVENT_MODEL_EMF_URI_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(node, "model.emf.uri",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "model.emf.uri",
"event class");
ret = -EPERM;
goto error;
}
- right = concatenate_unary_strings(
+ right = ctf_ast_concatenate_unary_strings(
&node->u.ctf_expression.right);
if (!right) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Unexpected unary expression for event class's `model.emf.uri` attribute.");
ret = -EINVAL;
goto error;
goto end;
error:
- if (left) {
- g_free(left);
- }
+ g_free(left);
end:
return ret;
continue;
}
- left = concatenate_unary_strings(&iter->u.ctf_expression.left);
+ left = ctf_ast_concatenate_unary_strings(&iter->u.ctf_expression.left);
if (!left) {
- _BT_COMP_LOGE_NODE(iter,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
"Cannot concatenate unary strings.");
goto error;
}
- if (!strcmp(left, "name")) {
- name = concatenate_unary_strings(
+ if (strcmp(left, "name") == 0) {
+ name = ctf_ast_concatenate_unary_strings(
&iter->u.ctf_expression.right);
if (!name) {
- _BT_COMP_LOGE_NODE(iter,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
"Unexpected unary expression for event class's `name` attribute.");
goto error;
}
node->visited = TRUE;
event_name = get_event_decl_name(ctx, node);
if (!event_name) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Missing `name` attribute in event class.");
ret = -EPERM;
goto error;
ret = visit_event_decl_entry(ctx, iter, event_class,
&stream_id, &set);
if (ret) {
- _BT_COMP_LOGE_NODE(iter, "Cannot visit event class's entry: "
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter, "Cannot visit event class's entry: "
"ret=%d", ret);
goto error;
}
stream_id = stream_class->id;
break;
default:
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Missing `stream_id` attribute in event class.");
ret = -EPERM;
goto error;
stream_class = ctf_trace_class_borrow_stream_class_by_id(
ctx->ctf_tc, stream_id);
if (!stream_class) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot find stream class at this point: "
"id=%" PRId64, stream_id);
ret = -EINVAL;
if (!_IS_SET(&set, _EVENT_ID_SET)) {
/* Allow only one event without ID per stream */
if (stream_class->event_classes->len != 0) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Missing `id` attribute in event class.");
ret = -EPERM;
goto error;
if (ctf_stream_class_borrow_event_class_by_id(stream_class,
event_class->id)) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Duplicate event class (same ID) in the same stream class: "
"id=%" PRId64, event_class->id);
ret = -EEXIST;
ctx_pop_scope(ctx);
}
- if (event_name) {
- g_free(event_name);
- }
+ g_free(event_name);
return ret;
}
* Timestamp field not mapped to a clock class and there's more
* than one clock class in the trace: this is an error.
*/
- BT_COMP_LOGE_STR("Timestamp field found with no mapped clock class, "
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Timestamp field found with no mapped clock class, "
"but there's more than one clock class in the trace at this point.");
ret = -1;
goto end;
} else if (root_fc->type == CTF_FIELD_CLASS_TYPE_VARIANT) {
named_fc = ctf_field_class_variant_borrow_option_by_index(
var_fc, i);
+ } else {
+ bt_common_abort();
}
if (strcmp(named_fc->name->str, field_name) == 0) {
ret = auto_map_field_to_trace_clock_class(ctx,
named_fc->fc);
if (ret) {
- BT_COMP_LOGE("Cannot automatically map field to trace's clock class: "
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot automatically map field to trace's clock class: "
"field-name=\"%s\"", field_name);
goto end;
}
ret = auto_map_fields_to_trace_clock_class(ctx, named_fc->fc,
field_name);
if (ret) {
- BT_COMP_LOGE("Cannot automatically map structure or variant field class's fields to trace's clock class: "
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot automatically map structure or variant field class's fields to trace's clock class: "
"field-name=\"%s\", root-field-name=\"%s\"",
field_name, named_fc->name->str);
goto end;
ret = visit_field_class_def(ctx, node->u.field_class_def.field_class_specifier_list,
&node->u.field_class_def.field_class_declarators);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot add field class found in stream class.");
goto error;
}
ret = visit_field_class_alias(ctx, node->u.field_class_alias.target,
node->u.field_class_alias.alias);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot add field class alias found in stream class.");
goto error;
}
break;
case NODE_CTF_EXPRESSION:
{
- left = concatenate_unary_strings(&node->u.ctf_expression.left);
+ left = ctf_ast_concatenate_unary_strings(&node->u.ctf_expression.left);
if (!left) {
- _BT_COMP_LOGE_NODE(node, "Cannot concatenate unary strings.");
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Cannot concatenate unary strings.");
ret = -EINVAL;
goto error;
}
- if (!strcmp(left, "id")) {
+ if (strcmp(left, "id") == 0) {
int64_t id;
if (_IS_SET(set, _STREAM_ID_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(node, "id",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "id",
"stream declaration");
ret = -EPERM;
goto error;
/* Only read "id" if get_unary_unsigned() succeeded. */
if (ret || (!ret && id < 0)) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Unexpected unary expression for stream class's `id` attribute.");
ret = -EINVAL;
goto error;
if (ctf_trace_class_borrow_stream_class_by_id(
ctx->ctf_tc, id)) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Duplicate stream class (same ID): id=%" PRId64,
id);
ret = -EEXIST;
stream_class->id = id;
_SET(set, _STREAM_ID_SET);
- } else if (!strcmp(left, "event.header")) {
+ } else if (strcmp(left, "event.header") == 0) {
if (_IS_SET(set, _STREAM_EVENT_HEADER_SET)) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Duplicate `event.header` entry in stream class.");
ret = -EPERM;
goto error;
struct ctf_node, siblings),
&stream_class->event_header_fc);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot create stream class's event header field class.");
goto error;
}
ret = auto_map_fields_to_trace_clock_class(ctx,
stream_class->event_header_fc, "timestamp");
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot automatically map specific event header field class fields named `timestamp` to trace's clock class.");
goto error;
}
_SET(set, _STREAM_EVENT_HEADER_SET);
- } else if (!strcmp(left, "event.context")) {
+ } else if (strcmp(left, "event.context") == 0) {
if (_IS_SET(set, _STREAM_EVENT_CONTEXT_SET)) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Duplicate `event.context` entry in stream class.");
ret = -EPERM;
goto error;
struct ctf_node, siblings),
&stream_class->event_common_context_fc);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot create stream class's event context field class.");
goto error;
}
BT_ASSERT(stream_class->event_common_context_fc);
_SET(set, _STREAM_EVENT_CONTEXT_SET);
- } else if (!strcmp(left, "packet.context")) {
+ } else if (strcmp(left, "packet.context") == 0) {
if (_IS_SET(set, _STREAM_PACKET_CONTEXT_SET)) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Duplicate `packet.context` entry in stream class.");
ret = -EPERM;
goto error;
struct ctf_node, siblings),
&stream_class->packet_context_fc);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot create stream class's packet context field class.");
goto error;
}
stream_class->packet_context_fc,
"timestamp_begin");
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot automatically map specific packet context field class fields named `timestamp_begin` to trace's clock class.");
goto error;
}
stream_class->packet_context_fc,
"timestamp_end");
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot automatically map specific packet context field class fields named `timestamp_end` to trace's clock class.");
goto error;
}
bt_list_for_each_entry(iter, decl_list, siblings) {
ret = visit_stream_decl_entry(ctx, iter, stream_class, &set);
if (ret) {
- _BT_COMP_LOGE_NODE(iter,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
"Cannot visit stream class's entry: "
"ret=%d", ret);
ctx_pop_scope(ctx);
struct ctf_named_field_class *named_fc = NULL;
if (!ctx->ctf_tc->packet_header_fc) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Stream class has a `id` attribute, "
"but trace has no packet header field class.");
+ ret = -EINVAL;
goto error;
}
named_fc = ctf_field_class_struct_borrow_member_by_name(
(void *) ctx->ctf_tc->packet_header_fc, "stream_id");
if (!named_fc) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Stream class has a `id` attribute, "
"but trace's packet header field class has no `stream_id` field.");
+ ret = -EINVAL;
goto error;
}
if (named_fc->fc->type != CTF_FIELD_CLASS_TYPE_INT &&
named_fc->fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Stream class has a `id` attribute, "
"but trace's packet header field class's `stream_id` field is not an integer field class.");
+ ret = -EINVAL;
goto error;
}
} else {
/* Allow only _one_ ID-less stream */
if (ctx->ctf_tc->stream_classes->len != 0) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Missing `id` attribute in stream class as there's more than one stream class in the trace.");
ret = -EPERM;
goto error;
*/
if (ctf_trace_class_borrow_stream_class_by_id(ctx->ctf_tc,
stream_class->id)) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Duplicate stream class (same ID): id=%" PRId64,
stream_class->id);
ret = -EINVAL;
ret = visit_field_class_def(ctx, node->u.field_class_def.field_class_specifier_list,
&node->u.field_class_def.field_class_declarators);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot add field class found in trace (`trace` block).");
goto error;
}
ret = visit_field_class_alias(ctx, node->u.field_class_alias.target,
node->u.field_class_alias.alias);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot add field class alias found in trace (`trace` block).");
goto error;
}
break;
case NODE_CTF_EXPRESSION:
{
- left = concatenate_unary_strings(&node->u.ctf_expression.left);
+ left = ctf_ast_concatenate_unary_strings(&node->u.ctf_expression.left);
if (!left) {
- _BT_COMP_LOGE_NODE(node, "Cannot concatenate unary strings.");
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Cannot concatenate unary strings.");
ret = -EINVAL;
goto error;
}
- if (!strcmp(left, "major")) {
+ if (strcmp(left, "major") == 0) {
if (_IS_SET(set, _TRACE_MAJOR_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(node, "major", "trace");
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "major", "trace");
ret = -EPERM;
goto error;
}
ret = get_unary_unsigned(ctx,
&node->u.ctf_expression.right, &val);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Unexpected unary expression for trace's `major` attribute.");
ret = -EINVAL;
goto error;
}
if (val != 1) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Invalid trace's `minor` attribute: expecting 1.");
+ ret = -EINVAL;
goto error;
}
ctx->ctf_tc->major = val;
_SET(set, _TRACE_MAJOR_SET);
- } else if (!strcmp(left, "minor")) {
+ } else if (strcmp(left, "minor") == 0) {
if (_IS_SET(set, _TRACE_MINOR_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(node, "minor", "trace");
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "minor", "trace");
ret = -EPERM;
goto error;
}
ret = get_unary_unsigned(ctx,
&node->u.ctf_expression.right, &val);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Unexpected unary expression for trace's `minor` attribute.");
ret = -EINVAL;
goto error;
}
if (val != 8) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Invalid trace's `minor` attribute: expecting 8.");
+ ret = -EINVAL;
goto error;
}
ctx->ctf_tc->minor = val;
_SET(set, _TRACE_MINOR_SET);
- } else if (!strcmp(left, "uuid")) {
+ } else if (strcmp(left, "uuid") == 0) {
if (_IS_SET(set, _TRACE_UUID_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(node, "uuid", "trace");
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "uuid", "trace");
ret = -EPERM;
goto error;
}
&node->u.ctf_expression.right,
ctx->ctf_tc->uuid);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Invalid trace's `uuid` attribute.");
goto error;
}
ctx->ctf_tc->is_uuid_set = true;
_SET(set, _TRACE_UUID_SET);
- } else if (!strcmp(left, "byte_order")) {
+ } else if (strcmp(left, "byte_order") == 0) {
/* Default byte order is already known at this stage */
if (_IS_SET(set, _TRACE_BYTE_ORDER_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(node, "byte_order",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "byte_order",
"trace");
ret = -EPERM;
goto error;
}
- BT_ASSERT(ctx->ctf_tc->default_byte_order != -1);
+ BT_ASSERT(ctx->ctf_tc->default_byte_order != CTF_BYTE_ORDER_UNKNOWN);
_SET(set, _TRACE_BYTE_ORDER_SET);
- } else if (!strcmp(left, "packet.header")) {
+ } else if (strcmp(left, "packet.header") == 0) {
if (_IS_SET(set, _TRACE_PACKET_HEADER_SET)) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Duplicate `packet.header` entry in trace.");
ret = -EPERM;
goto error;
struct ctf_node, siblings),
&ctx->ctf_tc->packet_header_fc);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot create trace's packet header field class.");
goto error;
}
break;
}
default:
- _BT_COMP_LOGE_NODE(node, "Unknown expression in trace.");
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Unknown expression in trace.");
ret = -EINVAL;
goto error;
}
node->visited = TRUE;
if (ctx->is_trace_visited) {
- _BT_COMP_LOGE_NODE(node, "Duplicate trace (`trace` block).");
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node, "Duplicate trace (`trace` block).");
ret = -EEXIST;
goto error;
}
bt_list_for_each_entry(iter, decl_list, siblings) {
ret = visit_trace_decl_entry(ctx, iter, &set);
if (ret) {
- _BT_COMP_LOGE_NODE(iter, "Cannot visit trace's entry (`trace` block): "
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter, "Cannot visit trace's entry (`trace` block): "
"ret=%d", ret);
ctx_pop_scope(ctx);
goto error;
ctx_pop_scope(ctx);
if (!_IS_SET(&set, _TRACE_MAJOR_SET)) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Missing `major` attribute in trace (`trace` block).");
ret = -EPERM;
goto error;
}
if (!_IS_SET(&set, _TRACE_MINOR_SET)) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Missing `minor` attribute in trace (`trace` block).");
ret = -EPERM;
goto error;
}
if (!_IS_SET(&set, _TRACE_BYTE_ORDER_SET)) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Missing `byte_order` attribute in trace (`trace` block).");
ret = -EPERM;
goto error;
&entry_node->u.ctf_expression.right;
if (entry_node->type != NODE_CTF_EXPRESSION) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Wrong expression in environment entry: "
"node-type=%d", entry_node->type);
ret = -EPERM;
goto error;
}
- left = concatenate_unary_strings(
+ left = ctf_ast_concatenate_unary_strings(
&entry_node->u.ctf_expression.left);
if (!left) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Cannot get environment entry's name.");
ret = -EINVAL;
goto error;
}
if (is_unary_string(right_head)) {
- char *right = concatenate_unary_strings(right_head);
+ char *right = ctf_ast_concatenate_unary_strings(right_head);
if (!right) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Unexpected unary expression for environment entry's value: "
"name=\"%s\"", left);
ret = -EINVAL;
ret = get_unary_signed(right_head, &v);
}
if (ret) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Unexpected unary expression for environment entry's value: "
"name=\"%s\"", left);
ret = -EINVAL;
if (node->type == NODE_CTF_EXPRESSION) {
struct ctf_node *right_node;
- left = concatenate_unary_strings(
+ left = ctf_ast_concatenate_unary_strings(
&node->u.ctf_expression.left);
if (!left) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot concatenate unary strings.");
ret = -EINVAL;
goto error;
}
- if (!strcmp(left, "byte_order")) {
+ if (strcmp(left, "byte_order") == 0) {
enum ctf_byte_order bo;
if (_IS_SET(&set, _TRACE_BYTE_ORDER_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(node, "byte_order",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(node, "byte_order",
"trace");
ret = -EPERM;
goto error;
struct ctf_node, siblings);
bo = byte_order_from_unary_expr(ctx,
right_node);
- if (bo == -1) {
- _BT_COMP_LOGE_NODE(node,
+ if (bo == CTF_BYTE_ORDER_UNKNOWN) {
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Invalid `byte_order` attribute in trace (`trace` block): "
"expecting `le`, `be`, or `network`.");
ret = -EINVAL;
goto error;
} else if (bo == CTF_BYTE_ORDER_DEFAULT) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Invalid `byte_order` attribute in trace (`trace` block): "
"cannot be set to `native` here.");
ret = -EPERM;
}
if (!_IS_SET(&set, _TRACE_BYTE_ORDER_SET)) {
- _BT_COMP_LOGE_NODE(trace_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(trace_node,
"Missing `byte_order` attribute in trace (`trace` block).");
ret = -EINVAL;
goto error;
char *left = NULL;
if (entry_node->type != NODE_CTF_EXPRESSION) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Unexpected node type: node-type=%d",
entry_node->type);
ret = -EPERM;
goto error;
}
- left = concatenate_unary_strings(&entry_node->u.ctf_expression.left);
+ left = ctf_ast_concatenate_unary_strings(&entry_node->u.ctf_expression.left);
if (!left) {
- _BT_COMP_LOGE_NODE(entry_node, "Cannot concatenate unary strings.");
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node, "Cannot concatenate unary strings.");
ret = -EINVAL;
goto error;
}
- if (!strcmp(left, "name")) {
+ if (strcmp(left, "name") == 0) {
char *right;
if (_IS_SET(set, _CLOCK_NAME_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(entry_node, "name", "clock class");
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(entry_node, "name", "clock class");
ret = -EPERM;
goto error;
}
- right = concatenate_unary_strings(
+ right = ctf_ast_concatenate_unary_strings(
&entry_node->u.ctf_expression.right);
if (!right) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Unexpected unary expression for clock class's `name` attribute.");
ret = -EINVAL;
goto error;
g_string_assign(clock->name, right);
g_free(right);
_SET(set, _CLOCK_NAME_SET);
- } else if (!strcmp(left, "uuid")) {
- uint8_t uuid[BABELTRACE_UUID_LEN];
+ } else if (strcmp(left, "uuid") == 0) {
+ bt_uuid_t uuid;
if (_IS_SET(set, _CLOCK_UUID_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(entry_node, "uuid", "clock class");
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(entry_node, "uuid", "clock class");
ret = -EPERM;
goto error;
}
ret = get_unary_uuid(ctx, &entry_node->u.ctf_expression.right,
uuid);
if (ret) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Invalid clock class's `uuid` attribute.");
goto error;
}
clock->has_uuid = true;
- memcpy(&clock->uuid[0], uuid, 16);
+ bt_uuid_copy(clock->uuid, uuid);
_SET(set, _CLOCK_UUID_SET);
- } else if (!strcmp(left, "description")) {
+ } else if (strcmp(left, "description") == 0) {
char *right;
if (_IS_SET(set, _CLOCK_DESCRIPTION_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(entry_node, "description",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(entry_node, "description",
"clock class");
ret = -EPERM;
goto error;
}
- right = concatenate_unary_strings(
+ right = ctf_ast_concatenate_unary_strings(
&entry_node->u.ctf_expression.right);
if (!right) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Unexpected unary expression for clock class's `description` attribute.");
ret = -EINVAL;
goto error;
g_string_assign(clock->description, right);
g_free(right);
_SET(set, _CLOCK_DESCRIPTION_SET);
- } else if (!strcmp(left, "freq")) {
+ } else if (strcmp(left, "freq") == 0) {
uint64_t freq = UINT64_C(-1);
if (_IS_SET(set, _CLOCK_FREQ_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(entry_node, "freq", "clock class");
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(entry_node, "freq", "clock class");
ret = -EPERM;
goto error;
}
ret = get_unary_unsigned(ctx,
&entry_node->u.ctf_expression.right, &freq);
if (ret) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Unexpected unary expression for clock class's `freq` attribute.");
ret = -EINVAL;
goto error;
}
if (freq == UINT64_C(-1) || freq == 0) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Invalid clock class frequency: freq=%" PRIu64,
freq);
ret = -EINVAL;
clock->frequency = freq;
_SET(set, _CLOCK_FREQ_SET);
- } else if (!strcmp(left, "precision")) {
+ } else if (strcmp(left, "precision") == 0) {
uint64_t precision;
if (_IS_SET(set, _CLOCK_PRECISION_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(entry_node, "precision",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(entry_node, "precision",
"clock class");
ret = -EPERM;
goto error;
ret = get_unary_unsigned(ctx,
&entry_node->u.ctf_expression.right, &precision);
if (ret) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Unexpected unary expression for clock class's `precision` attribute.");
ret = -EINVAL;
goto error;
clock->precision = precision;
_SET(set, _CLOCK_PRECISION_SET);
- } else if (!strcmp(left, "offset_s")) {
+ } else if (strcmp(left, "offset_s") == 0) {
if (_IS_SET(set, _CLOCK_OFFSET_S_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(entry_node, "offset_s",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(entry_node, "offset_s",
"clock class");
ret = -EPERM;
goto error;
ret = get_unary_signed(
&entry_node->u.ctf_expression.right, offset_seconds);
if (ret) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Unexpected unary expression for clock class's `offset_s` attribute.");
ret = -EINVAL;
goto error;
}
_SET(set, _CLOCK_OFFSET_S_SET);
- } else if (!strcmp(left, "offset")) {
+ } else if (strcmp(left, "offset") == 0) {
if (_IS_SET(set, _CLOCK_OFFSET_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(entry_node, "offset", "clock class");
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(entry_node, "offset", "clock class");
ret = -EPERM;
goto error;
}
ret = get_unary_unsigned(ctx,
&entry_node->u.ctf_expression.right, offset_cycles);
if (ret) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Unexpected unary expression for clock class's `offset` attribute.");
ret = -EINVAL;
goto error;
}
_SET(set, _CLOCK_OFFSET_SET);
- } else if (!strcmp(left, "absolute")) {
+ } else if (strcmp(left, "absolute") == 0) {
struct ctf_node *right;
if (_IS_SET(set, _CLOCK_ABSOLUTE_SET)) {
- _BT_COMP_LOGE_DUP_ATTR(entry_node, "absolute",
+ _BT_COMP_LOGE_APPEND_CAUSE_DUP_ATTR(entry_node, "absolute",
"clock class");
ret = -EPERM;
goto error;
struct ctf_node, siblings);
ret = get_boolean(ctx, right);
if (ret < 0) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Unexpected unary expression for clock class's `absolute` attribute.");
ret = -EINVAL;
goto error;
}
}
+static
+void apply_clock_class_is_absolute(struct ctx *ctx,
+ struct ctf_clock_class *clock)
+{
+ if (ctx->decoder_config.force_clock_class_origin_unix_epoch) {
+ clock->is_absolute = true;
+ }
+
+ return;
+}
+
static
void apply_clock_class_offset(struct ctx *ctx,
struct ctf_clock_class *clock)
/* CTF 1.8's default frequency for a clock class is 1 GHz */
clock = ctf_clock_class_create();
if (!clock) {
- _BT_COMP_LOGE_NODE(clock_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(clock_node,
"Cannot create default clock class.");
ret = -ENOMEM;
goto end;
ret = visit_clock_decl_entry(ctx, entry_node, clock, &set,
&offset_seconds, &offset_cycles);
if (ret) {
- _BT_COMP_LOGE_NODE(entry_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(entry_node,
"Cannot visit clock class's entry: ret=%d",
ret);
goto end;
}
if (!_IS_SET(&set, _CLOCK_NAME_SET)) {
- _BT_COMP_LOGE_NODE(clock_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(clock_node,
"Missing `name` attribute in clock class.");
ret = -EPERM;
goto end;
clock->offset_seconds = offset_seconds;
clock->offset_cycles = offset_cycles;
apply_clock_class_offset(ctx, clock);
+ apply_clock_class_is_absolute(ctx, clock);
g_ptr_array_add(ctx->ctf_tc->clock_classes, clock);
clock = NULL;
root_decl_node->u.field_class_def.field_class_specifier_list,
&root_decl_node->u.field_class_def.field_class_declarators);
if (ret) {
- _BT_COMP_LOGE_NODE(root_decl_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(root_decl_node,
"Cannot add field class found in root scope.");
goto end;
}
ret = visit_field_class_alias(ctx, root_decl_node->u.field_class_alias.target,
root_decl_node->u.field_class_alias.alias);
if (ret) {
- _BT_COMP_LOGE_NODE(root_decl_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(root_decl_node,
"Cannot add field class alias found in root scope.");
goto end;
}
*/
ret = visit_field_class_specifier_list(ctx, root_decl_node, &decl);
if (ret) {
- _BT_COMP_LOGE_NODE(root_decl_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(root_decl_node,
"Cannot visit root scope's field class: "
"ret=%d", ret);
BT_ASSERT(!decl);
break;
}
default:
- _BT_COMP_LOGE_NODE(root_decl_node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(root_decl_node,
"Unexpected node type: node-type=%d",
root_decl_node->type);
ret = -EPERM;
/* Create visitor's context */
ctx = ctx_create(decoder_config);
if (!ctx) {
- BT_COMP_LOGE_STR("Cannot create visitor's context.");
+ BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, decoder_config->log_level,
+ decoder_config->self_comp,
+ "Cannot create visitor's context.");
goto error;
}
{
struct ctx *ctx = (void *) visitor;
- BT_ASSERT(ctx);
+ BT_ASSERT_DBG(ctx);
if (ctx->trace_class) {
bt_trace_class_get_ref(ctx->trace_class);
{
struct ctx *ctx = (void *) visitor;
- BT_ASSERT(ctx);
- BT_ASSERT(ctx->ctf_tc);
+ BT_ASSERT_DBG(ctx);
+ BT_ASSERT_DBG(ctx->ctf_tc);
return ctx->ctf_tc;
}
* have the native byte order yet, and we don't have any
* trace block yet, then fail with EINCOMPLETE.
*/
- if (ctx->ctf_tc->default_byte_order == -1) {
+ if (ctx->ctf_tc->default_byte_order == CTF_BYTE_ORDER_UNKNOWN) {
bt_list_for_each_entry(iter, &node->u.root.trace, siblings) {
if (got_trace_decl) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Duplicate trace (`trace` block).");
ret = -1;
goto end;
ret = set_trace_byte_order(ctx, iter);
if (ret) {
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Cannot set trace's native byte order: "
"ret=%d", ret);
goto end;
BT_ASSERT(ctx->ctf_tc->default_byte_order == CTF_BYTE_ORDER_LITTLE ||
ctx->ctf_tc->default_byte_order == CTF_BYTE_ORDER_BIG);
BT_ASSERT(ctx->current_scope &&
- ctx->current_scope->parent_scope == NULL);
+ !ctx->current_scope->parent_scope);
/* Environment */
bt_list_for_each_entry(iter, &node->u.root.env, siblings) {
ret = visit_env(ctx, iter);
if (ret) {
- _BT_COMP_LOGE_NODE(iter,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
"Cannot visit trace's environment (`env` block) entry: "
"ret=%d", ret);
goto end;
}
BT_ASSERT(ctx->current_scope &&
- ctx->current_scope->parent_scope == NULL);
+ !ctx->current_scope->parent_scope);
/*
* Visit clock blocks.
bt_list_for_each_entry(iter, &node->u.root.clock, siblings) {
ret = visit_clock_decl(ctx, iter);
if (ret) {
- _BT_COMP_LOGE_NODE(iter,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
"Cannot visit clock class: ret=%d",
ret);
goto end;
}
BT_ASSERT(ctx->current_scope &&
- ctx->current_scope->parent_scope == NULL);
+ !ctx->current_scope->parent_scope);
/*
* Visit root declarations next, as they can be used by any
siblings) {
ret = visit_root_decl(ctx, iter);
if (ret) {
- _BT_COMP_LOGE_NODE(iter,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
"Cannot visit root entry: ret=%d",
ret);
goto end;
}
BT_ASSERT(ctx->current_scope &&
- ctx->current_scope->parent_scope == NULL);
+ !ctx->current_scope->parent_scope);
/* Callsite blocks are not supported */
bt_list_for_each_entry(iter, &node->u.root.callsite, siblings) {
}
BT_ASSERT(ctx->current_scope &&
- ctx->current_scope->parent_scope == NULL);
+ !ctx->current_scope->parent_scope);
/* Trace */
bt_list_for_each_entry(iter, &node->u.root.trace, siblings) {
ret = visit_trace_decl(ctx, iter);
if (ret) {
- _BT_COMP_LOGE_NODE(iter,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
"Cannot visit trace (`trace` block): "
"ret=%d", ret);
goto end;
}
BT_ASSERT(ctx->current_scope &&
- ctx->current_scope->parent_scope == NULL);
+ !ctx->current_scope->parent_scope);
/* Streams */
bt_list_for_each_entry(iter, &node->u.root.stream, siblings) {
ret = visit_stream_decl(ctx, iter);
if (ret) {
- _BT_COMP_LOGE_NODE(iter,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
"Cannot visit stream class: ret=%d",
ret);
goto end;
}
BT_ASSERT(ctx->current_scope &&
- ctx->current_scope->parent_scope == NULL);
+ !ctx->current_scope->parent_scope);
/* Events */
bt_list_for_each_entry(iter, &node->u.root.event, siblings) {
ret = visit_event_decl(ctx, iter);
if (ret) {
- _BT_COMP_LOGE_NODE(iter,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(iter,
"Cannot visit event class: ret=%d",
ret);
goto end;
}
BT_ASSERT(ctx->current_scope &&
- ctx->current_scope->parent_scope == NULL);
+ !ctx->current_scope->parent_scope);
break;
}
default:
- _BT_COMP_LOGE_NODE(node,
+ _BT_COMP_LOGE_APPEND_CAUSE_NODE(node,
"Unexpected node type: node-type=%d",
node->type);
ret = -EINVAL;
goto end;
}
+ /* Update structure/array/sequence alignments */
+ ret = ctf_trace_class_update_alignments(ctx->ctf_tc);
+ if (ret) {
+ ret = -EINVAL;
+ goto end;
+ }
+
/* Resolve sequence lengths and variant tags */
ret = ctf_trace_class_resolve_field_classes(ctx->ctf_tc, &ctx->log_cfg);
if (ret) {