From: Philippe Proulx Date: Wed, 14 Jun 2017 02:07:10 +0000 (-0400) Subject: visitor-generate-ir.c: logging: add stream's line number and other info X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=28973adf293a087eac8541ca647b6f89b50612ba;p=babeltrace.git visitor-generate-ir.c: logging: add stream's line number and other info Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/plugins/ctf/common/metadata/logging.h b/plugins/ctf/common/metadata/logging.h index 78a41a66..8c04b1ca 100644 --- a/plugins/ctf/common/metadata/logging.h +++ b/plugins/ctf/common/metadata/logging.h @@ -28,6 +28,9 @@ BT_LOG_LEVEL_EXTERN_SYMBOL(metadata_log_level); +#define _BT_LOGV_LINENO(_lineno, _msg, args...) \ + BT_LOGV("At line %u in metadata stream: " _msg, _lineno, ## args) + #define _BT_LOGW_LINENO(_lineno, _msg, args...) \ BT_LOGW("At line %u in metadata stream: " _msg, _lineno, ## args) diff --git a/plugins/ctf/common/metadata/visitor-generate-ir.c b/plugins/ctf/common/metadata/visitor-generate-ir.c index b4a084df..19a67896 100644 --- a/plugins/ctf/common/metadata/visitor-generate-ir.c +++ b/plugins/ctf/common/metadata/visitor-generate-ir.c @@ -153,11 +153,19 @@ enum loglevel { #define _BT_CTF_FIELD_TYPE_INIT(_name) struct bt_ctf_field_type *_name = NULL; -#define _BT_LOGE_DUP_ATTR(_attr, _entity) \ - do { \ - BT_LOGE("Duplicate attribute in %s: attr-name=\"%s\"", \ - _entity, _attr); \ - } while (0) +#define _BT_LOGE_DUP_ATTR(_node, _attr, _entity) \ + _BT_LOGE_LINENO((_node)->lineno, \ + "Duplicate attribute in %s: attr-name=\"%s\"", \ + _entity, _attr) + +#define _BT_LOGE_NODE(_node, _msg, args...) \ + _BT_LOGE_LINENO((_node)->lineno, _msg, ## args) + +#define _BT_LOGW_NODE(_node, _msg, args...) \ + _BT_LOGW_LINENO((_node)->lineno, _msg, ## args) + +#define _BT_LOGV_NODE(_node, _msg, args...) \ + _BT_LOGV_LINENO((_node)->lineno, _msg, ## args) /* * Declaration scope of a visitor context. This represents a TSDL @@ -261,6 +269,7 @@ struct ctx_decl_scope *ctx_decl_scope_create(struct ctx_decl_scope *par_scope) scope = g_new(struct ctx_decl_scope, 1); if (!scope) { + BT_LOGE_STR("Failed to allocate one declaration scope."); goto end; } @@ -310,6 +319,7 @@ GQuark get_prefixed_named_quark(char prefix, const char *name) /* Prefix character + original string + '\0' */ char *prname = g_new(char, strlen(name) + 2); if (!prname) { + BT_LOGE_STR("Failed to allocate a string."); goto end; } @@ -598,24 +608,28 @@ struct ctx *ctx_create(struct bt_ctf_trace *trace, ctx = g_new0(struct ctx, 1); if (!ctx) { + BT_LOGE_STR("Failed to allocate one visitor context."); goto error; } /* Root declaration scope */ scope = ctx_decl_scope_create(NULL); if (!scope) { + BT_LOGE_STR("Cannot create declaration scope."); goto error; } ctx->stream_classes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) bt_put); if (!ctx->stream_classes) { + BT_LOGE_STR("Failed to allocate a GHashTable."); goto error; } if (trace_name_suffix) { ctx->trace_name_suffix = strdup(trace_name_suffix); if (!ctx->trace_name_suffix) { + BT_LOGE_STR("Failed to copy string."); goto error; } } @@ -649,6 +663,7 @@ int ctx_push_scope(struct ctx *ctx) assert(ctx); new_scope = ctx_decl_scope_create(ctx->current_scope); if (!new_scope) { + BT_LOGE_STR("Cannot create declaration scope."); ret = -ENOMEM; goto end; } @@ -851,6 +866,7 @@ int get_unary_unsigned(struct bt_list_head *head, uint64_t *value) uexpr_type != UNARY_UNSIGNED_CONSTANT || uexpr_link != UNARY_LINK_UNKNOWN || i != 0; if (cond) { + _BT_LOGE_NODE(node, "Invalid constant unsigned integer."); ret = -EINVAL; goto end; } @@ -945,6 +961,8 @@ int get_unary_uuid(struct bt_list_head *head, unsigned char *uuid) src_string = node->u.unary_expression.u.string; ret = bt_uuid_parse(src_string, uuid); if (ret) { + _BT_LOGE_NODE(node, + "Cannot parse UUID: uuid=\"%s\"", src_string); goto end; } } @@ -959,7 +977,8 @@ int get_boolean(struct ctf_node *unary_expr) int ret = 0; if (unary_expr->type != NODE_UNARY_EXPRESSION) { - BT_LOGE("Expecting unary expression: node-type=%d", + _BT_LOGE_NODE(unary_expr, + "Expecting unary expression: node-type=%d", unary_expr->type); ret = -EINVAL; goto end; @@ -981,14 +1000,16 @@ int get_boolean(struct ctf_node *unary_expr) } else if (!strcmp(str, "false") || !strcmp(str, "FALSE")) { ret = FALSE; } else { - BT_LOGE("Unexpected boolean value: value=\"%s\"", str); + _BT_LOGE_NODE(unary_expr, + "Unexpected boolean value: value=\"%s\"", str); ret = -EINVAL; goto end; } break; } default: - BT_LOGE("Unexpected unary expression type: node-type=%d", + _BT_LOGE_NODE(unary_expr, + "Unexpected unary expression type: node-type=%d", unary_expr->u.unary_expression.type); ret = -EINVAL; goto end; @@ -1005,7 +1026,8 @@ enum bt_ctf_byte_order byte_order_from_unary_expr(struct ctf_node *unary_expr) enum bt_ctf_byte_order bo = BT_CTF_BYTE_ORDER_UNKNOWN; if (unary_expr->u.unary_expression.type != UNARY_STRING) { - BT_LOGE_STR("\"byte_order\" attribute: expecting `be`, `le`, `network`, or `native`."); + _BT_LOGE_NODE(unary_expr, + "\"byte_order\" attribute: expecting `be`, `le`, `network`, or `native`."); goto end; } @@ -1018,7 +1040,8 @@ enum bt_ctf_byte_order byte_order_from_unary_expr(struct ctf_node *unary_expr) } else if (!strcmp(str, "native")) { bo = BT_CTF_BYTE_ORDER_NATIVE; } else { - BT_LOGE("Unexpected \"byte_order\" attribute value: " + _BT_LOGE_NODE(unary_expr, + "Unexpected \"byte_order\" attribute value: " "expecting `be`, `le`, `network`, or `native`: value=\"%s\"", str); goto end; @@ -1054,6 +1077,9 @@ int get_type_specifier_name(struct ctx *ctx, struct ctf_node *type_specifier, int ret = 0; if (type_specifier->type != NODE_TYPE_SPECIFIER) { + _BT_LOGE_NODE(type_specifier, + "Unexpected node type: node-type=%d", + type_specifier->type); ret = -EINVAL; goto end; } @@ -1109,7 +1135,7 @@ int get_type_specifier_name(struct ctx *ctx, struct ctf_node *type_specifier, struct ctf_node *node = type_specifier->u.type_specifier.node; if (!node->u._struct.name) { - BT_LOGE_STR("Unexpected empty structure name."); + _BT_LOGE_NODE(node, "Unexpected empty structure field type name."); ret = -EINVAL; goto end; } @@ -1123,7 +1149,7 @@ int get_type_specifier_name(struct ctx *ctx, struct ctf_node *type_specifier, struct ctf_node *node = type_specifier->u.type_specifier.node; if (!node->u.variant.name) { - BT_LOGE_STR("Unexpected empty variant name."); + _BT_LOGE_NODE(node, "Unexpected empty variant field type name."); ret = -EINVAL; goto end; } @@ -1137,7 +1163,8 @@ int get_type_specifier_name(struct ctx *ctx, struct ctf_node *type_specifier, struct ctf_node *node = type_specifier->u.type_specifier.node; if (!node->u._enum.enum_id) { - BT_LOGE_STR("Unexpected empty enumeration field type (`enum`) name."); + _BT_LOGE_NODE(node, + "Unexpected empty enumeration field type (`enum`) name."); ret = -EINVAL; goto end; } @@ -1150,7 +1177,8 @@ int get_type_specifier_name(struct ctx *ctx, struct ctf_node *type_specifier, case TYPESPEC_INTEGER: case TYPESPEC_STRING: default: - BT_LOGE("Unexpected type specifier type: %d", + _BT_LOGE_NODE(type_specifier->u.type_specifier.node, + "Unexpected type specifier type: %d", type_specifier->u.type_specifier.type); ret = -EINVAL; goto end; @@ -1241,7 +1269,8 @@ int visit_type_declarator(struct ctx *ctx, struct ctf_node *type_specifier_list, if (node_type_declarator) { if (node_type_declarator->u.type_declarator.type == TYPEDEC_UNKNOWN) { - BT_LOGE("Unexpected type declarator type: type=%d", + _BT_LOGE_NODE(node_type_declarator, + "Unexpected type declarator type: type=%d", node_type_declarator->u.type_declarator.type); ret = -EINVAL; goto error; @@ -1250,7 +1279,8 @@ int visit_type_declarator(struct ctx *ctx, struct ctf_node *type_specifier_list, /* TODO: GCC bitfields not supported yet */ if (node_type_declarator->u.type_declarator.bitfield_len != NULL) { - BT_LOGE_STR("GCC bitfields are not supported as of this version."); + _BT_LOGE_NODE(node_type_declarator, + "GCC bitfields are not supported as of this version."); ret = -EPERM; goto error; } @@ -1275,7 +1305,8 @@ int visit_type_declarator(struct ctx *ctx, struct ctf_node *type_specifier_list, ctx_decl_scope_lookup_alias(ctx->current_scope, g_quark_to_string(qalias), -1); if (!nested_decl) { - BT_LOGE("Cannot find type alias: name=\"%s\"", + _BT_LOGE_NODE(node_type_declarator, + "Cannot find type alias: name=\"%s\"", g_quark_to_string(qalias)); ret = -EINVAL; goto error; @@ -1285,7 +1316,8 @@ int visit_type_declarator(struct ctx *ctx, struct ctf_node *type_specifier_list, nested_decl_copy = bt_ctf_field_type_copy(nested_decl); BT_PUT(nested_decl); if (!nested_decl_copy) { - BT_LOGE_STR("Cannot copy nested field type."); + _BT_LOGE_NODE(node_type_declarator, + "Cannot copy nested field type."); ret = -EINVAL; goto error; } @@ -1294,8 +1326,10 @@ int visit_type_declarator(struct ctx *ctx, struct ctf_node *type_specifier_list, /* Force integer's base to 16 since it's a pointer */ if (bt_ctf_field_type_is_integer(nested_decl)) { - bt_ctf_field_type_integer_set_base(nested_decl, + ret = bt_ctf_field_type_integer_set_base( + nested_decl, BT_CTF_INTEGER_BASE_HEXADECIMAL); + assert(ret == 0); } } else { ret = visit_type_specifier_list(ctx, @@ -1336,13 +1370,17 @@ int visit_type_declarator(struct ctx *ctx, struct ctf_node *type_specifier_list, /* Create array/sequence, pass nested_decl as child */ if (bt_list_empty(length)) { - BT_LOGE_STR("Expecting length field reference or value."); + _BT_LOGE_NODE(node_type_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_LOGE_NODE(first, + "Unexpected node type: node-type=%d", + first->type); ret = -EINVAL; goto error; } @@ -1358,7 +1396,8 @@ int visit_type_declarator(struct ctx *ctx, struct ctf_node *type_specifier_list, len); BT_PUT(nested_decl); if (!array_decl) { - BT_LOGE_STR("Cannot create array field type."); + _BT_LOGE_NODE(first, + "Cannot create array field type."); ret = -ENOMEM; goto error; } @@ -1373,6 +1412,8 @@ int visit_type_declarator(struct ctx *ctx, struct ctf_node *type_specifier_list, char *length_name = concatenate_unary_strings(length); if (!length_name) { + _BT_LOGE_NODE(node_type_declarator, + "Cannot concatenate unary strings."); ret = -EINVAL; goto error; } @@ -1382,7 +1423,8 @@ int visit_type_declarator(struct ctx *ctx, struct ctf_node *type_specifier_list, g_free(length_name); BT_PUT(nested_decl); if (!seq_decl) { - BT_LOGE_STR("Cannot create sequence field type."); + _BT_LOGE_NODE(node_type_declarator, + "Cannot create sequence field type."); ret = -ENOMEM; goto error; } @@ -1455,7 +1497,8 @@ int visit_struct_decl_field(struct ctx *ctx, &qfield_name, iter, &field_decl, NULL); if (ret) { assert(!field_decl); - BT_LOGE("Cannot visit type declarator: ret=%d", ret); + _BT_LOGE_NODE(type_specifier_list, + "Cannot visit type declarator: ret=%d", ret); goto error; } @@ -1468,7 +1511,8 @@ int visit_struct_decl_field(struct ctx *ctx, struct_decl, field_name); if (efield_decl) { BT_PUT(efield_decl); - BT_LOGE("Duplicate field in structure field type: " + _BT_LOGE_NODE(type_specifier_list, + "Duplicate field in structure field type: " "field-name=\"%s\"", field_name); ret = -EINVAL; goto error; @@ -1479,7 +1523,8 @@ int visit_struct_decl_field(struct ctx *ctx, field_decl, field_name); BT_PUT(field_decl); if (ret) { - BT_LOGE("Cannot add field to structure field type: " + _BT_LOGE_NODE(type_specifier_list, + "Cannot add field to structure field type: " "field-name=\"%s\", ret=%d", g_quark_to_string(qfield_name), ret); goto error; @@ -1514,7 +1559,8 @@ int visit_variant_decl_field(struct ctx *ctx, &qfield_name, iter, &field_decl, NULL); if (ret) { assert(!field_decl); - BT_LOGE("Cannot visit type declarator: ret=%d", ret); + _BT_LOGE_NODE(type_specifier_list, + "Cannot visit type declarator: ret=%d", ret); goto error; } @@ -1527,7 +1573,8 @@ int visit_variant_decl_field(struct ctx *ctx, variant_decl, field_name); if (efield_decl) { BT_PUT(efield_decl); - BT_LOGE("Duplicate field in variant field type: " + _BT_LOGE_NODE(type_specifier_list, + "Duplicate field in variant field type: " "field-name=\"%s\"", field_name); ret = -EINVAL; goto error; @@ -1538,7 +1585,8 @@ int visit_variant_decl_field(struct ctx *ctx, field_decl, field_name); BT_PUT(field_decl); if (ret) { - BT_LOGE("Cannot add field to variant field type: " + _BT_LOGE_NODE(type_specifier_list, + "Cannot add field to variant field type: " "field-name=\"%s\", ret=%d", g_quark_to_string(qfield_name), ret); goto error; @@ -1566,7 +1614,8 @@ int visit_typedef(struct ctx *ctx, struct ctf_node *type_specifier_list, ret = visit_type_declarator(ctx, type_specifier_list, &qidentifier, iter, &type_decl, NULL); if (ret) { - BT_LOGE("Cannot visit type declarator: ret=%d", ret); + _BT_LOGE_NODE(iter, + "Cannot visit type declarator: ret=%d", ret); ret = -EINVAL; goto end; } @@ -1574,7 +1623,8 @@ int visit_typedef(struct ctx *ctx, struct ctf_node *type_specifier_list, /* Do not allow typedef and typealias of untagged variants */ if (bt_ctf_field_type_is_variant(type_decl)) { if (bt_ctf_field_type_variant_get_tag_name(type_decl)) { - BT_LOGE_STR("Type definition of untagged variant field type is not allowed."); + _BT_LOGE_NODE(iter, + "Type definition of untagged variant field type is not allowed."); ret = -EPERM; goto end; } @@ -1583,7 +1633,8 @@ int visit_typedef(struct ctx *ctx, struct ctf_node *type_specifier_list, ret = ctx_decl_scope_register_alias(ctx->current_scope, g_quark_to_string(qidentifier), type_decl); if (ret) { - BT_LOGE("Cannot register type definition: name=\"%s\"", + _BT_LOGE_NODE(iter, + "Cannot register type definition: name=\"%s\"", g_quark_to_string(qidentifier)); goto end; } @@ -1619,14 +1670,16 @@ int visit_typealias(struct ctx *ctx, struct ctf_node *target, &qdummy_field_name, node, &type_decl, NULL); if (ret) { assert(!type_decl); - BT_LOGE("Cannot visit type declarator: ret=%d", ret); + _BT_LOGE_NODE(node, + "Cannot visit type declarator: ret=%d", ret); goto end; } /* Do not allow typedef and typealias of untagged variants */ if (bt_ctf_field_type_is_variant(type_decl)) { if (bt_ctf_field_type_variant_get_tag_name(type_decl)) { - BT_LOGE_STR("Type definition of untagged variant field type is not allowed."); + _BT_LOGE_NODE(node, + "Type definition of untagged variant field type is not allowed."); ret = -EPERM; goto end; } @@ -1637,7 +1690,8 @@ int visit_typealias(struct ctx *ctx, struct ctf_node *target, * abstract or not (if it has an identifier). Check it here. */ if (qdummy_field_name != 0) { - BT_LOGE("Expecting empty identifier: id=\"%s\"", + _BT_LOGE_NODE(node, + "Expecting empty identifier: id=\"%s\"", g_quark_to_string(qdummy_field_name)); ret = -EINVAL; goto end; @@ -1651,7 +1705,8 @@ int visit_typealias(struct ctx *ctx, struct ctf_node *target, ret = ctx_decl_scope_register_alias(ctx->current_scope, g_quark_to_string(qalias), type_decl); if (ret) { - BT_LOGE("Cannot register type alias: name=\"%s\"", + _BT_LOGE_NODE(node, + "Cannot register type alias: name=\"%s\"", g_quark_to_string(qalias)); goto end; } @@ -1674,7 +1729,8 @@ int visit_struct_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, entry_node->u._typedef.type_specifier_list, &entry_node->u._typedef.type_declarators); if (ret) { - BT_LOGE("Cannot add type definition found in structure field type: ret=%d", + _BT_LOGE_NODE(entry_node, + "Cannot add type definition found in structure field type: ret=%d", ret); goto end; } @@ -1683,7 +1739,8 @@ int visit_struct_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = visit_typealias(ctx, entry_node->u.typealias.target, entry_node->u.typealias.alias); if (ret) { - BT_LOGE("Cannot add type alias found in structure field type: ret=%d", + _BT_LOGE_NODE(entry_node, + "Cannot add type alias found in structure field type: ret=%d", ret); goto end; } @@ -1700,7 +1757,8 @@ int visit_struct_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, } break; default: - BT_LOGE("Unexpected node type: node-type=%d", entry_node->type); + _BT_LOGE_NODE(entry_node, + "Unexpected node type: node-type=%d", entry_node->type); ret = -EINVAL; goto end; } @@ -1721,7 +1779,8 @@ int visit_variant_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, entry_node->u._typedef.type_specifier_list, &entry_node->u._typedef.type_declarators); if (ret) { - BT_LOGE("Cannot add type definition found in variant field type: ret=%d", + _BT_LOGE_NODE(entry_node, + "Cannot add type definition found in variant field type: ret=%d", ret); goto end; } @@ -1730,7 +1789,8 @@ int visit_variant_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = visit_typealias(ctx, entry_node->u.typealias.target, entry_node->u.typealias.alias); if (ret) { - BT_LOGE("Cannot add type alias found in variant field type: ret=%d", + _BT_LOGE_NODE(entry_node, + "Cannot add type alias found in variant field type: ret=%d", ret); goto end; } @@ -1747,7 +1807,8 @@ int visit_variant_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, } break; default: - BT_LOGE("Unexpected node type: node-type=%d", + _BT_LOGE_NODE(entry_node, + "Unexpected node type: node-type=%d", entry_node->type); ret = -EINVAL; goto end; @@ -1772,6 +1833,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name, _BT_CTF_FIELD_TYPE_INIT(struct_decl_copy); if (!name) { + BT_LOGE_STR("Bodyless structure field type: missing name."); ret = -EPERM; goto error; } @@ -1848,6 +1910,9 @@ int visit_struct_decl(struct ctx *ctx, const char *name, ret = visit_struct_decl_entry(ctx, entry_node, *struct_decl); if (ret) { + _BT_LOGE_NODE(entry_node, + "Cannot visit structure field type entry: " + "ret=%d", ret); ctx_pop_scope(ctx); goto error; } @@ -1889,6 +1954,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name, _BT_CTF_FIELD_TYPE_INIT(variant_decl_copy); if (!name) { + BT_LOGE_STR("Bodyless variant field type: missing name."); ret = -EPERM; goto error; } @@ -1948,6 +2014,9 @@ int visit_variant_decl(struct ctx *ctx, const char *name, ret = visit_variant_decl_entry(ctx, entry_node, untagged_variant_decl); if (ret) { + _BT_LOGE_NODE(entry_node, + "Cannot visit variant field type entry: " + "ret=%d", ret); ctx_pop_scope(ctx); goto error; } @@ -1981,6 +2050,8 @@ int visit_variant_decl(struct ctx *ctx, const char *name, ret = bt_ctf_field_type_variant_set_tag_name( untagged_variant_decl, tag); if (ret) { + BT_LOGE("Cannot set variant field type's tag name: " + "tag-name=\"%s\"", tag); goto error; } @@ -2014,7 +2085,8 @@ int visit_enum_decl_entry(struct ctx *ctx, struct ctf_node *enumerator, int64_t *target; if (iter->type != NODE_UNARY_EXPRESSION) { - BT_LOGE("Wrong expression for enumeration field type label: " + _BT_LOGE_NODE(iter, + "Wrong expression for enumeration field type label: " "node-type=%d, label=\"%s\"", iter->type, label); ret = -EINVAL; @@ -2036,7 +2108,8 @@ int visit_enum_decl_entry(struct ctx *ctx, struct ctf_node *enumerator, iter->u.unary_expression.u.unsigned_constant; break; default: - BT_LOGE("Invalid enumeration field type entry: " + _BT_LOGE_NODE(iter, + "Invalid enumeration field type entry: " "expecting constant signed or unsigned integer: " "node-type=%d, label=\"%s\"", iter->u.unary_expression.type, label); @@ -2045,7 +2118,8 @@ int visit_enum_decl_entry(struct ctx *ctx, struct ctf_node *enumerator, } if (nr_vals > 1) { - BT_LOGE("Invalid enumeration field type entry: label=\"%s\"", + _BT_LOGE_NODE(iter, + "Invalid enumeration field type entry: label=\"%s\"", label); ret = -EINVAL; goto error; @@ -2072,7 +2146,8 @@ int visit_enum_decl_entry(struct ctx *ctx, struct ctf_node *enumerator, label, (uint64_t) start, (uint64_t) end); } if (ret) { - BT_LOGE("Cannot add mapping to enumeration field type: " + _BT_LOGE_NODE(enumerator, + "Cannot add mapping to enumeration field type: " "label=\"%s\", ret=%d, " "start-value-unsigned=%" PRIu64 ", " "end-value-unsigned=%" PRIu64, label, ret, @@ -2104,6 +2179,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name, _BT_CTF_FIELD_TYPE_INIT(enum_decl_copy); if (!name) { + BT_LOGE_STR("Bodyless enumeration field type: missing name."); ret = -EPERM; goto error; } @@ -2186,6 +2262,9 @@ int visit_enum_decl(struct ctx *ctx, const char *name, &last_value, bt_ctf_field_type_integer_get_signed(integer_decl)); if (ret) { + _BT_LOGE_NODE(iter, + "Cannot visit enumeration field type entry: " + "ret=%d", ret); goto error; } } @@ -2194,6 +2273,8 @@ int visit_enum_decl(struct ctx *ctx, const char *name, ret = ctx_decl_scope_register_enum(ctx->current_scope, name, *enum_decl); if (ret) { + BT_LOGE("Cannot register enumeration field type in declaration scope: " + "ret=%d", ret); goto error; } } @@ -2223,12 +2304,15 @@ int visit_type_specifier(struct ctx *ctx, str = g_string_new(""); ret = get_type_specifier_list_name(ctx, type_specifier_list, str); if (ret) { + _BT_LOGE_NODE(type_specifier_list, + "Cannot get type specifier list's name: ret=%d", ret); goto error; } *decl = ctx_decl_scope_lookup_alias(ctx->current_scope, str->str, -1); if (!*decl) { - BT_LOGE("Cannot find type alias: name=\"%s\"", str->str); + _BT_LOGE_NODE(type_specifier_list, + "Cannot find type alias: name=\"%s\"", str->str); ret = -EINVAL; goto error; } @@ -2236,7 +2320,8 @@ int visit_type_specifier(struct ctx *ctx, /* Make a copy of the type declaration */ decl_copy = bt_ctf_field_type_copy(*decl); if (!decl_copy) { - BT_LOGE_STR("Cannot create field type copy."); + _BT_LOGE_NODE(type_specifier_list, + "Cannot create field type copy."); ret = -EINVAL; goto error; } @@ -2285,13 +2370,16 @@ int visit_integer_decl(struct ctx *ctx, siblings); if (left->u.unary_expression.type != UNARY_STRING) { + _BT_LOGE_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 (_IS_SET(&set, _INTEGER_SIGNED_SET)) { - _BT_LOGE_DUP_ATTR("signed", + _BT_LOGE_DUP_ATTR(left, "signed", "integer field type"); ret = -EPERM; goto error; @@ -2299,6 +2387,9 @@ int visit_integer_decl(struct ctx *ctx, signedness = get_boolean(right); if (signedness < 0) { + _BT_LOGE_NODE(right, + "Invalid boolean value for integer field type's `signed` attribute: " + "ret=%d", ret); ret = -EINVAL; goto error; } @@ -2307,7 +2398,7 @@ int visit_integer_decl(struct ctx *ctx, } else if (!strcmp(left->u.unary_expression.u.string, "byte_order")) { if (_IS_SET(&set, _INTEGER_BYTE_ORDER_SET)) { - _BT_LOGE_DUP_ATTR("byte_order", + _BT_LOGE_DUP_ATTR(left, "byte_order", "integer field type"); ret = -EPERM; goto error; @@ -2315,7 +2406,8 @@ int visit_integer_decl(struct ctx *ctx, byte_order = get_real_byte_order(ctx, right); if (byte_order == BT_CTF_BYTE_ORDER_UNKNOWN) { - BT_LOGE("Invalid `byte_order` attribute in integer field type: " + _BT_LOGE_NODE(right, + "Invalid `byte_order` attribute in integer field type: " "ret=%d", ret); ret = -EINVAL; goto error; @@ -2324,7 +2416,7 @@ int visit_integer_decl(struct ctx *ctx, _SET(&set, _INTEGER_BYTE_ORDER_SET); } else if (!strcmp(left->u.unary_expression.u.string, "size")) { if (_IS_SET(&set, _INTEGER_SIZE_SET)) { - _BT_LOGE_DUP_ATTR("size", + _BT_LOGE_DUP_ATTR(left, "size", "integer field type"); ret = -EPERM; goto error; @@ -2332,7 +2424,8 @@ int visit_integer_decl(struct ctx *ctx, if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) { - BT_LOGE("Invalid `size` attribute in integer field type: " + _BT_LOGE_NODE(right, + "Invalid `size` attribute in integer field type: " "expecting unsigned constant integer: " "node-type=%d", right->u.unary_expression.type); @@ -2342,13 +2435,15 @@ int visit_integer_decl(struct ctx *ctx, size = right->u.unary_expression.u.unsigned_constant; if (size == 0) { - BT_LOGE("Invalid `size` attribute in integer field type: " + _BT_LOGE_NODE(right, + "Invalid `size` attribute in integer field type: " "expecting positive constant integer: " "size=%" PRIu64, size); ret = -EINVAL; goto error; } else if (size > 64) { - BT_LOGE("Invalid `size` attribute in integer field type: " + _BT_LOGE_NODE(right, + "Invalid `size` attribute in integer field type: " "integer fields over 64 bits are not supported as of this version: " "size=%" PRIu64, size); ret = -EINVAL; @@ -2359,7 +2454,7 @@ int visit_integer_decl(struct ctx *ctx, } else if (!strcmp(left->u.unary_expression.u.string, "align")) { if (_IS_SET(&set, _INTEGER_ALIGN_SET)) { - _BT_LOGE_DUP_ATTR("align", + _BT_LOGE_DUP_ATTR(left, "align", "integer field type"); ret = -EPERM; goto error; @@ -2367,7 +2462,8 @@ int visit_integer_decl(struct ctx *ctx, if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) { - BT_LOGE("Invalid `align` attribute in integer field type: " + _BT_LOGE_NODE(right, + "Invalid `align` attribute in integer field type: " "expecting unsigned constant integer: " "node-type=%d", right->u.unary_expression.type); @@ -2378,7 +2474,8 @@ int visit_integer_decl(struct ctx *ctx, alignment = right->u.unary_expression.u.unsigned_constant; if (!is_align_valid(alignment)) { - BT_LOGE("Invalid `align` attribute in integer field type: " + _BT_LOGE_NODE(right, + "Invalid `align` attribute in integer field type: " "expecting power of two: " "align=%" PRIu64, alignment); ret = -EINVAL; @@ -2388,7 +2485,8 @@ int visit_integer_decl(struct ctx *ctx, _SET(&set, _INTEGER_ALIGN_SET); } else if (!strcmp(left->u.unary_expression.u.string, "base")) { if (_IS_SET(&set, _INTEGER_BASE_SET)) { - _BT_LOGE_DUP_ATTR("base", "integer field type"); + _BT_LOGE_DUP_ATTR(left, "base", + "integer field type"); ret = -EPERM; goto error; } @@ -2413,7 +2511,8 @@ int visit_integer_decl(struct ctx *ctx, base = BT_CTF_INTEGER_BASE_HEXADECIMAL; break; default: - BT_LOGE("Invalid `base` attribute in integer field type: " + _BT_LOGE_NODE(right, + "Invalid `base` attribute in integer field type: " "base=%" PRIu64, right->u.unary_expression.u.unsigned_constant); ret = -EINVAL; @@ -2426,7 +2525,8 @@ int visit_integer_decl(struct ctx *ctx, char *s_right = concatenate_unary_strings( &expression->u.ctf_expression.right); if (!s_right) { - BT_LOGE_STR("Unexpected unary expression for integer field type's `base` attribute."); + _BT_LOGE_NODE(right, + "Unexpected unary expression for integer field type's `base` attribute."); ret = -EINVAL; goto error; } @@ -2451,7 +2551,8 @@ int visit_integer_decl(struct ctx *ctx, !strcmp(s_right, "b")) { base = BT_CTF_INTEGER_BASE_BINARY; } else { - BT_LOGE("Unexpected unary expression for integer field type's `base` attribute: " + _BT_LOGE_NODE(right, + "Unexpected unary expression for integer field type's `base` attribute: " "base=\"%s\"", s_right); g_free(s_right); ret = -EINVAL; @@ -2462,7 +2563,8 @@ int visit_integer_decl(struct ctx *ctx, break; } default: - BT_LOGE_STR("Invalid `base` attribute in integer field type: " + _BT_LOGE_NODE(right, + "Invalid `base` attribute in integer field type: " "expecting unsigned constant integer or unary string."); ret = -EINVAL; goto error; @@ -2474,14 +2576,15 @@ int visit_integer_decl(struct ctx *ctx, char *s_right; if (_IS_SET(&set, _INTEGER_ENCODING_SET)) { - _BT_LOGE_DUP_ATTR("encoding", + _BT_LOGE_DUP_ATTR(left, "encoding", "integer field type"); ret = -EPERM; goto error; } if (right->u.unary_expression.type != UNARY_STRING) { - BT_LOGE_STR("Invalid `encoding` attribute in integer field type: " + _BT_LOGE_NODE(right, + "Invalid `encoding` attribute in integer field type: " "expecting unary string."); ret = -EINVAL; goto error; @@ -2490,7 +2593,8 @@ int visit_integer_decl(struct ctx *ctx, s_right = concatenate_unary_strings( &expression->u.ctf_expression.right); if (!s_right) { - BT_LOGE_STR("Unexpected unary expression for integer field type's `encoding` attribute."); + _BT_LOGE_NODE(right, + "Unexpected unary expression for integer field type's `encoding` attribute."); ret = -EINVAL; goto error; } @@ -2506,7 +2610,8 @@ int visit_integer_decl(struct ctx *ctx, } else if (!strcmp(s_right, "none")) { encoding = BT_CTF_STRING_ENCODING_NONE; } else { - BT_LOGE("Invalid `encoding` attribute in integer field type: " + _BT_LOGE_NODE(right, + "Invalid `encoding` attribute in integer field type: " "unknown encoding: encoding=\"%s\"", s_right); g_free(s_right); @@ -2520,13 +2625,15 @@ int visit_integer_decl(struct ctx *ctx, const char *clock_name; if (_IS_SET(&set, _INTEGER_MAP_SET)) { - _BT_LOGE_DUP_ATTR("map", "integer field type"); + _BT_LOGE_DUP_ATTR(left, "map", + "integer field type"); ret = -EPERM; goto error; } if (right->u.unary_expression.type != UNARY_STRING) { - BT_LOGE_STR("Invalid `map` attribute in integer field type: " + _BT_LOGE_NODE(right, + "Invalid `map` attribute in integer field type: " "expecting unary string."); ret = -EINVAL; goto error; @@ -2540,12 +2647,14 @@ int visit_integer_decl(struct ctx *ctx, &expression->u.ctf_expression.right); if (!s_right) { - BT_LOGE_STR("Unexpected unary expression for integer field type's `map` attribute."); + _BT_LOGE_NODE(right, + "Unexpected unary expression for integer field type's `map` attribute."); ret = -EINVAL; goto error; } - BT_LOGE("Invalid `map` attribute in integer field type: " + _BT_LOGE_NODE(right, + "Invalid `map` attribute in integer field type: " "cannot find clock class at this point: name=\"%s\"", s_right); _SET(&set, _INTEGER_MAP_SET); @@ -2556,7 +2665,8 @@ int visit_integer_decl(struct ctx *ctx, mapped_clock = bt_ctf_trace_get_clock_class_by_name( ctx->trace, clock_name); if (!mapped_clock) { - BT_LOGE("Invalid `map` attribute in integer field type: " + _BT_LOGE_NODE(right, + "Invalid `map` attribute in integer field type: " "cannot find clock class at this point: name=\"%s\"", clock_name); ret = -EINVAL; @@ -2565,7 +2675,8 @@ int visit_integer_decl(struct ctx *ctx, _SET(&set, _INTEGER_MAP_SET); } else { - BT_LOGW("Unknown attribute in integer field type: " + _BT_LOGW_NODE(left, + "Unknown attribute in integer field type: " "attr-name=\"%s\"", left->u.unary_expression.u.string); } @@ -2651,13 +2762,16 @@ int visit_floating_point_number_decl(struct ctx *ctx, siblings); if (left->u.unary_expression.type != UNARY_STRING) { + _BT_LOGE_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 (_IS_SET(&set, _FLOAT_BYTE_ORDER_SET)) { - _BT_LOGE_DUP_ATTR("byte_order", + _BT_LOGE_DUP_ATTR(left, "byte_order", "floating point number field type"); ret = -EPERM; goto error; @@ -2665,7 +2779,8 @@ int visit_floating_point_number_decl(struct ctx *ctx, byte_order = get_real_byte_order(ctx, right); if (byte_order == BT_CTF_BYTE_ORDER_UNKNOWN) { - BT_LOGE("Invalid `byte_order` attribute in floating point number field type: " + _BT_LOGE_NODE(right, + "Invalid `byte_order` attribute in floating point number field type: " "ret=%d", ret); ret = -EINVAL; goto error; @@ -2675,7 +2790,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, } else if (!strcmp(left->u.unary_expression.u.string, "exp_dig")) { if (_IS_SET(&set, _FLOAT_EXP_DIG_SET)) { - _BT_LOGE_DUP_ATTR("exp_dig", + _BT_LOGE_DUP_ATTR(left, "exp_dig", "floating point number field type"); ret = -EPERM; goto error; @@ -2683,7 +2798,8 @@ int visit_floating_point_number_decl(struct ctx *ctx, if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) { - BT_LOGE("Invalid `exp_dig` attribute in floating point number field type: " + _BT_LOGE_NODE(right, + "Invalid `exp_dig` attribute in floating point number field type: " "expecting unsigned constant integer: " "node-type=%d", right->u.unary_expression.type); @@ -2696,7 +2812,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, } else if (!strcmp(left->u.unary_expression.u.string, "mant_dig")) { if (_IS_SET(&set, _FLOAT_MANT_DIG_SET)) { - _BT_LOGE_DUP_ATTR("mant_dig", + _BT_LOGE_DUP_ATTR(left, "mant_dig", "floating point number field type"); ret = -EPERM; goto error; @@ -2704,7 +2820,8 @@ int visit_floating_point_number_decl(struct ctx *ctx, if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) { - BT_LOGE("Invalid `mant_dig` attribute in floating point number field type: " + _BT_LOGE_NODE(right, + "Invalid `mant_dig` attribute in floating point number field type: " "expecting unsigned constant integer: " "node-type=%d", right->u.unary_expression.type); @@ -2718,7 +2835,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, } else if (!strcmp(left->u.unary_expression.u.string, "align")) { if (_IS_SET(&set, _FLOAT_ALIGN_SET)) { - _BT_LOGE_DUP_ATTR("align", + _BT_LOGE_DUP_ATTR(left, "align", "floating point number field type"); ret = -EPERM; goto error; @@ -2726,7 +2843,8 @@ int visit_floating_point_number_decl(struct ctx *ctx, if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) { - BT_LOGE("Invalid `align` attribute in floating point number field type: " + _BT_LOGE_NODE(right, + "Invalid `align` attribute in floating point number field type: " "expecting unsigned constant integer: " "node-type=%d", right->u.unary_expression.type); @@ -2738,7 +2856,8 @@ int visit_floating_point_number_decl(struct ctx *ctx, unsigned_constant; if (!is_align_valid(alignment)) { - BT_LOGE("Invalid `align` attribute in floating point number field type: " + _BT_LOGE_NODE(right, + "Invalid `align` attribute in floating point number field type: " "expecting power of two: " "align=%" PRIu64, alignment); ret = -EINVAL; @@ -2747,7 +2866,8 @@ int visit_floating_point_number_decl(struct ctx *ctx, _SET(&set, _FLOAT_ALIGN_SET); } else { - BT_LOGW("Unknown attribute in floating point number field type: " + _BT_LOGW_NODE(left, + "Unknown attribute in floating point number field type: " "attr-name=\"%s\"", left->u.unary_expression.u.string); } @@ -2824,6 +2944,9 @@ int visit_string_decl(struct ctx *ctx, siblings); if (left->u.unary_expression.type != UNARY_STRING) { + _BT_LOGE_NODE(left, + "Unexpected unary expression type: type=%d", + left->u.unary_expression.type); ret = -EINVAL; goto error; } @@ -2832,14 +2955,15 @@ int visit_string_decl(struct ctx *ctx, char *s_right; if (_IS_SET(&set, _STRING_ENCODING_SET)) { - _BT_LOGE_DUP_ATTR("encoding", + _BT_LOGE_DUP_ATTR(left, "encoding", "string field type"); ret = -EPERM; goto error; } if (right->u.unary_expression.type != UNARY_STRING) { - BT_LOGE_STR("Invalid `encoding` attribute in string field type: " + _BT_LOGE_NODE(right, + "Invalid `encoding` attribute in string field type: " "expecting unary string."); ret = -EINVAL; goto error; @@ -2848,7 +2972,8 @@ int visit_string_decl(struct ctx *ctx, s_right = concatenate_unary_strings( &expression->u.ctf_expression.right); if (!s_right) { - BT_LOGE_STR("Unexpected unary expression for string field type's `encoding` attribute."); + _BT_LOGE_NODE(right, + "Unexpected unary expression for string field type's `encoding` attribute."); ret = -EINVAL; goto error; } @@ -2864,7 +2989,8 @@ int visit_string_decl(struct ctx *ctx, } else if (!strcmp(s_right, "none")) { encoding = BT_CTF_STRING_ENCODING_NONE; } else { - BT_LOGE("Invalid `encoding` attribute in string field type: " + _BT_LOGE_NODE(right, + "Invalid `encoding` attribute in string field type: " "unknown encoding: encoding=\"%s\"", s_right); g_free(s_right); @@ -2875,7 +3001,8 @@ int visit_string_decl(struct ctx *ctx, g_free(s_right); _SET(&set, _STRING_ENCODING_SET); } else { - BT_LOGW("Unknown attribute in string field type: " + _BT_LOGW_NODE(left, + "Unknown attribute in string field type: " "attr-name=\"%s\"", left->u.unary_expression.u.string); } @@ -2914,6 +3041,8 @@ int visit_type_specifier_list(struct ctx *ctx, *decl = NULL; if (ts_list->type != NODE_TYPE_SPECIFIER_LIST) { + _BT_LOGE_NODE(ts_list, + "Unexpected node type: node-type=%d", ts_list->type); ret = -EINVAL; goto error; } @@ -2921,6 +3050,8 @@ int visit_type_specifier_list(struct ctx *ctx, first = _BT_LIST_FIRST_ENTRY(&ts_list->u.type_specifier_list.head, struct ctf_node, siblings); if (first->type != NODE_TYPE_SPECIFIER) { + _BT_LOGE_NODE(first, + "Unexpected node type: node-type=%d", first->type); ret = -EINVAL; goto error; } @@ -2998,12 +3129,16 @@ int visit_type_specifier_list(struct ctx *ctx, case TYPESPEC_ID_TYPE: ret = visit_type_specifier(ctx, ts_list, decl); if (ret) { + _BT_LOGE_NODE(first, + "Cannot visit type specifier: ret=%d", + ret); assert(!*decl); goto error; } break; default: - BT_LOGE("Unexpected node type: node-type=%d", + _BT_LOGE_NODE(first, + "Unexpected type specifier type: node-type=%d", first->u.type_specifier.type); ret = -EINVAL; goto error; @@ -3033,7 +3168,8 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = visit_typedef(ctx, node->u._typedef.type_specifier_list, &node->u._typedef.type_declarators); if (ret) { - BT_LOGE_STR("Cannot add type definition found in event class."); + _BT_LOGE_NODE(node, + "Cannot add type definition found in event class."); goto error; } break; @@ -3041,7 +3177,8 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = visit_typealias(ctx, node->u.typealias.target, node->u.typealias.alias); if (ret) { - BT_LOGE_STR("Cannot add type alias found in event class."); + _BT_LOGE_NODE(node, + "Cannot add type alias found in event class."); goto error; } break; @@ -3049,6 +3186,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, { left = concatenate_unary_strings(&node->u.ctf_expression.left); if (!left) { + _BT_LOGE_NODE(node, "Cannot concatenate unary strings."); ret = -EINVAL; goto error; } @@ -3056,7 +3194,8 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, if (!strcmp(left, "name")) { /* This is already known at this stage */ if (_IS_SET(set, _EVENT_NAME_SET)) { - _BT_LOGE_DUP_ATTR("name", "event declaration"); + _BT_LOGE_DUP_ATTR(node, "name", + "event class"); ret = -EPERM; goto error; } @@ -3066,7 +3205,8 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, int64_t id; if (_IS_SET(set, _EVENT_ID_SET)) { - _BT_LOGE_DUP_ATTR("id", "event declaration"); + _BT_LOGE_DUP_ATTR(node, "id", + "event class"); ret = -EPERM; goto error; } @@ -3075,14 +3215,16 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, (uint64_t *) &id); /* Only read "id" if get_unary_unsigned() succeeded. */ if (ret || (!ret && id < 0)) { - BT_LOGE_STR("Unexpected unary expression for event class's `id` attribute."); + _BT_LOGE_NODE(node, + "Unexpected unary expression for event class's `id` attribute."); ret = -EINVAL; goto error; } ret = bt_ctf_event_class_set_id(event_class, id); if (ret) { - BT_LOGE("Cannot set event class's ID: " + _BT_LOGE_NODE(node, + "Cannot set event class's ID: " "id=%" PRId64, id); goto error; } @@ -3090,7 +3232,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, _SET(set, _EVENT_ID_SET); } else if (!strcmp(left, "stream_id")) { if (_IS_SET(set, _EVENT_STREAM_ID_SET)) { - _BT_LOGE_DUP_ATTR("stream_id", + _BT_LOGE_DUP_ATTR(node, "stream_id", "event class"); ret = -EPERM; goto error; @@ -3103,7 +3245,8 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, * succeeded. */ if (ret || (!ret && *stream_id < 0)) { - BT_LOGE_STR("Unexpected unary expression for event class's `stream_id` attribute."); + _BT_LOGE_NODE(node, + "Unexpected unary expression for event class's `stream_id` attribute."); ret = -EINVAL; goto error; } @@ -3111,7 +3254,8 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, _SET(set, _EVENT_STREAM_ID_SET); } else if (!strcmp(left, "context")) { if (_IS_SET(set, _EVENT_CONTEXT_SET)) { - BT_LOGE_STR("Duplicate `context` entry in event class."); + _BT_LOGE_NODE(node, + "Duplicate `context` entry in event class."); ret = -EPERM; goto error; } @@ -3122,7 +3266,8 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, struct ctf_node, siblings), &decl); if (ret) { - BT_LOGE_STR("Cannot create event class's context field type."); + _BT_LOGE_NODE(node, + "Cannot create event class's context field type."); goto error; } @@ -3131,14 +3276,16 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, event_class, decl); BT_PUT(decl); if (ret) { - BT_LOGE_STR("Cannot set event class's context field type."); + _BT_LOGE_NODE(node, + "Cannot set event class's context field type."); goto error; } _SET(set, _EVENT_CONTEXT_SET); } else if (!strcmp(left, "fields")) { if (_IS_SET(set, _EVENT_FIELDS_SET)) { - BT_LOGE_STR("Duplicate `fields` entry in event class."); + _BT_LOGE_NODE(node, + "Duplicate `fields` entry in event class."); ret = -EPERM; goto error; } @@ -3149,7 +3296,8 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, struct ctf_node, siblings), &decl); if (ret) { - BT_LOGE_STR("Cannot create event class's payload field type."); + _BT_LOGE_NODE(node, + "Cannot create event class's payload field type."); goto error; } @@ -3158,7 +3306,8 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, event_class, decl); BT_PUT(decl); if (ret) { - BT_LOGE_STR("Cannot set event class's payload field type."); + _BT_LOGE_NODE(node, + "Cannot set event class's payload field type."); goto error; } @@ -3169,7 +3318,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, struct bt_value *value_obj, *str_obj; if (_IS_SET(set, _EVENT_LOGLEVEL_SET)) { - _BT_LOGE_DUP_ATTR("loglevel", + _BT_LOGE_DUP_ATTR(node, "loglevel", "event class"); ret = -EPERM; goto error; @@ -3178,19 +3327,22 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = get_unary_unsigned(&node->u.ctf_expression.right, &loglevel_value); if (ret) { - BT_LOGE_STR("Unexpected unary expression for event class's `loglevel` attribute."); + _BT_LOGE_NODE(node, + "Unexpected unary expression for event class's `loglevel` attribute."); ret = -EINVAL; goto error; } value_obj = bt_value_integer_create_init(loglevel_value); if (!value_obj) { - BT_LOGE_STR("Cannot create integer value object."); + _BT_LOGE_NODE(node, + "Cannot create integer value object."); ret = -ENOMEM; goto error; } if (bt_ctf_event_class_set_attribute(event_class, "loglevel", value_obj) != BT_VALUE_STATUS_OK) { - BT_LOGE_STR("Cannot set event class's `loglevel` attribute."); + _BT_LOGE_NODE(node, + "Cannot set event class's `loglevel` attribute."); ret = -EINVAL; bt_put(value_obj); goto error; @@ -3200,7 +3352,8 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, str_obj = bt_value_string_create_init(loglevel_str); if (bt_ctf_event_class_set_attribute(event_class, "loglevel_string", str_obj) != BT_VALUE_STATUS_OK) { - BT_LOGE_STR("Cannot set event class's `loglevel_string` attribute."); + _BT_LOGE_NODE(node, + "Cannot set event class's `loglevel_string` attribute."); ret = -EINVAL; bt_put(str_obj); goto error; @@ -3211,10 +3364,11 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, _SET(set, _EVENT_LOGLEVEL_SET); } else if (!strcmp(left, "model.emf.uri")) { char *right; + struct bt_value *str_obj; if (_IS_SET(set, _EVENT_MODEL_EMF_URI_SET)) { - _BT_LOGE_DUP_ATTR("model.emf.uri", - "event declaration"); + _BT_LOGE_DUP_ATTR(node, "model.emf.uri", + "event class"); ret = -EPERM; goto error; } @@ -3222,17 +3376,27 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, right = concatenate_unary_strings( &node->u.ctf_expression.right); if (!right) { - BT_LOGE_STR("Unexpected unary expression for event class's `model.emf.uri` attribute."); + _BT_LOGE_NODE(node, + "Unexpected unary expression for event class's `model.emf.uri` attribute."); ret = -EINVAL; goto error; } - // TODO: FIXME: set model EMF URI here - + str_obj = bt_value_string_create_init(right); + if (bt_ctf_event_class_set_attribute(event_class, + "model.emf.uri", str_obj) != BT_VALUE_STATUS_OK) { + _BT_LOGE_NODE(node, + "Cannot set event class's `model.emf.uri` attribute."); + ret = -EINVAL; + bt_put(str_obj); + goto error; + } + bt_put(str_obj); g_free(right); _SET(set, _EVENT_MODEL_EMF_URI_SET); } else { - BT_LOGW("Unknown attribute in event class: " + _BT_LOGW_NODE(node, + "Unknown attribute in event class: " "attr-name=\"%s\"", left); } @@ -3272,6 +3436,8 @@ char *get_event_decl_name(struct ctx *ctx, struct ctf_node *node) left = concatenate_unary_strings(&iter->u.ctf_expression.left); if (!left) { + _BT_LOGE_NODE(iter, + "Cannot concatenate unary strings."); goto error; } @@ -3279,7 +3445,8 @@ char *get_event_decl_name(struct ctx *ctx, struct ctf_node *node) name = concatenate_unary_strings( &iter->u.ctf_expression.right); if (!name) { - BT_LOGE_STR("Unexpected unary expression for event class's `name` attribute."); + _BT_LOGE_NODE(iter, + "Unexpected unary expression for event class's `name` attribute."); goto error; } } @@ -3309,14 +3476,18 @@ int reset_event_decl_types(struct ctx *ctx, /* Context type. */ ret = bt_ctf_event_class_set_context_type(event_class, NULL); if (ret) { - BT_LOGE_STR("Cannot reset initial event class's context field type."); + BT_LOGE("Cannot reset initial event class's context field type: " + "event-name=\"%s\"", + bt_ctf_event_class_get_name(event_class)); goto end; } /* Event payload. */ ret = bt_ctf_event_class_set_payload_type(event_class, NULL); if (ret) { - BT_LOGE_STR("Cannot reset initial event class's payload field type."); + BT_LOGE("Cannot reset initial event class's payload field type: " + "event-name=\"%s\"", + bt_ctf_event_class_get_name(event_class)); goto end; } end: @@ -3404,7 +3575,8 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) node->visited = TRUE; event_name = get_event_decl_name(ctx, node); if (!event_name) { - BT_LOGE_STR("Missing `name` attribute in event class."); + _BT_LOGE_NODE(node, + "Missing `name` attribute in event class."); ret = -EPERM; goto error; } @@ -3416,6 +3588,9 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) */ ret = reset_event_decl_types(ctx, event_class); if (ret) { + _BT_LOGE_NODE(node, + "Cannot reset event class's field types: " + "ret=%d", ret); goto error; } @@ -3431,6 +3606,8 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) ret = visit_event_decl_entry(ctx, iter, event_class, &stream_id, &set); if (ret) { + _BT_LOGE_NODE(iter, "Cannot visit event class's entry: " + "ret=%d", ret); goto error; } } @@ -3451,13 +3628,16 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) /* Create implicit stream class if there's none */ new_stream_class = create_reset_stream_class(ctx); if (!new_stream_class) { + _BT_LOGE_NODE(node, + "Cannot create empty stream class."); ret = -EINVAL; goto error; } ret = bt_ctf_stream_class_set_id(new_stream_class, 0); if (ret) { - BT_LOGE("Cannot set stream class's ID: " + _BT_LOGE_NODE(node, + "Cannot set stream class's ID: " "id=0, ret=%d", ret); BT_PUT(new_stream_class); goto error; @@ -3489,7 +3669,8 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) } break; default: - BT_LOGE_STR("Missing `stream_id` attribute in event class."); + _BT_LOGE_NODE(node, + "Missing `stream_id` attribute in event class."); ret = -EPERM; goto error; } @@ -3505,7 +3686,8 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) stream_class = bt_ctf_trace_get_stream_class_by_id(ctx->trace, stream_id); if (!stream_class) { - BT_LOGE("Cannot find stream class at this point: " + _BT_LOGE_NODE(node, + "Cannot find stream class at this point: " "id=%" PRId64, stream_id); ret = -EINVAL; goto error; @@ -3518,7 +3700,8 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) /* Allow only one event without ID per stream */ if (bt_ctf_stream_class_get_event_class_count(stream_class) != 0) { - BT_LOGE_STR("Missing `id` attribute in event class."); + _BT_LOGE_NODE(node, + "Missing `id` attribute in event class."); ret = -EPERM; goto error; } @@ -3526,7 +3709,8 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) /* Automatic ID */ ret = bt_ctf_event_class_set_id(event_class, 0); if (ret) { - BT_LOGE("Cannot set event class's ID: id=0, ret=%d", + _BT_LOGE_NODE(node, + "Cannot set event class's ID: id=0, ret=%d", ret); goto error; } @@ -3534,7 +3718,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) event_id = bt_ctf_event_class_get_id(event_class); if (event_id < 0) { - BT_LOGE_STR("Cannot get event class's ID."); + _BT_LOGE_NODE(node, "Cannot get event class's ID."); ret = -EINVAL; goto error; } @@ -3543,7 +3727,8 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) event_id); if (eevent_class) { BT_PUT(eevent_class); - BT_LOGE("Duplicate event class (same ID) in the same stream class: " + _BT_LOGE_NODE(node, + "Duplicate event class (same ID) in the same stream class: " "id=%" PRId64, event_id); ret = -EEXIST; goto error; @@ -3552,7 +3737,8 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) ret = bt_ctf_stream_class_add_event_class(stream_class, event_class); BT_PUT(event_class); if (ret) { - BT_LOGE("Cannot add event class to stream class: ret=%d", ret); + _BT_LOGE_NODE(node, + "Cannot add event class to stream class: ret=%d", ret); goto error; } @@ -3584,7 +3770,8 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = visit_typedef(ctx, node->u._typedef.type_specifier_list, &node->u._typedef.type_declarators); if (ret) { - BT_LOGE_STR("Cannot add type definition found in stream class."); + _BT_LOGE_NODE(node, + "Cannot add type definition found in stream class."); goto error; } break; @@ -3592,7 +3779,8 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = visit_typealias(ctx, node->u.typealias.target, node->u.typealias.alias); if (ret) { - BT_LOGE_STR("Cannot add type alias found in stream class."); + _BT_LOGE_NODE(node, + "Cannot add type alias found in stream class."); goto error; } break; @@ -3600,6 +3788,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, { left = concatenate_unary_strings(&node->u.ctf_expression.left); if (!left) { + _BT_LOGE_NODE(node, "Cannot concatenate unary strings."); ret = -EINVAL; goto error; } @@ -3609,7 +3798,8 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, gpointer ptr; if (_IS_SET(set, _STREAM_ID_SET)) { - _BT_LOGE_DUP_ATTR("id", "stream declaration"); + _BT_LOGE_DUP_ATTR(node, "id", + "stream declaration"); ret = -EPERM; goto error; } @@ -3618,7 +3808,8 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, (uint64_t *) &id); /* Only read "id" if get_unary_unsigned() succeeded. */ if (ret || (!ret && id < 0)) { - BT_LOGE_STR("Unexpected unary expression for stream class's `id` attribute."); + _BT_LOGE_NODE(node, + "Unexpected unary expression for stream class's `id` attribute."); ret = -EINVAL; goto error; } @@ -3626,7 +3817,8 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, ptr = g_hash_table_lookup(ctx->stream_classes, (gpointer) id); if (ptr) { - BT_LOGE("Duplicate stream class (same ID): id=%" PRId64, + _BT_LOGE_NODE(node, + "Duplicate stream class (same ID): id=%" PRId64, id); ret = -EEXIST; goto error; @@ -3634,7 +3826,8 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = bt_ctf_stream_class_set_id(stream_class, id); if (ret) { - BT_LOGE("Cannot set stream class's ID: " + _BT_LOGE_NODE(node, + "Cannot set stream class's ID: " "id=%" PRId64 ", ret=%d", id, ret); goto error; } @@ -3642,7 +3835,8 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, _SET(set, _STREAM_ID_SET); } else if (!strcmp(left, "event.header")) { if (_IS_SET(set, _STREAM_EVENT_HEADER_SET)) { - BT_LOGE_STR("Duplicate `event.header` entry in stream class."); + _BT_LOGE_NODE(node, + "Duplicate `event.header` entry in stream class."); ret = -EPERM; goto error; } @@ -3653,7 +3847,8 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, struct ctf_node, siblings), &decl); if (ret) { - BT_LOGE_STR("Cannot create stream class's event header field type."); + _BT_LOGE_NODE(node, + "Cannot create stream class's event header field type."); goto error; } @@ -3663,14 +3858,16 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, stream_class, decl); BT_PUT(decl); if (ret) { - BT_LOGE_STR("Cannot set stream class's event header field type."); + _BT_LOGE_NODE(node, + "Cannot set stream class's event header field type."); goto error; } _SET(set, _STREAM_EVENT_HEADER_SET); } else if (!strcmp(left, "event.context")) { if (_IS_SET(set, _STREAM_EVENT_CONTEXT_SET)) { - BT_LOGE_STR("Duplicate `event.context` entry in stream class."); + _BT_LOGE_NODE(node, + "Duplicate `event.context` entry in stream class."); ret = -EPERM; goto error; } @@ -3681,7 +3878,8 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, struct ctf_node, siblings), &decl); if (ret) { - BT_LOGE_STR("Cannot create stream class's event context field type."); + _BT_LOGE_NODE(node, + "Cannot create stream class's event context field type."); goto error; } @@ -3691,14 +3889,16 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, stream_class, decl); BT_PUT(decl); if (ret) { - BT_LOGE_STR("Cannot set stream class's event context field type."); + _BT_LOGE_NODE(node, + "Cannot set stream class's event context field type."); goto error; } _SET(set, _STREAM_EVENT_CONTEXT_SET); } else if (!strcmp(left, "packet.context")) { if (_IS_SET(set, _STREAM_PACKET_CONTEXT_SET)) { - BT_LOGE_STR("Duplicate `packet.context` entry in stream class."); + _BT_LOGE_NODE(node, + "Duplicate `packet.context` entry in stream class."); ret = -EPERM; goto error; } @@ -3709,7 +3909,8 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, struct ctf_node, siblings), &decl); if (ret) { - BT_LOGE_STR("Cannot create stream class's packet context field type."); + _BT_LOGE_NODE(node, + "Cannot create stream class's packet context field type."); goto error; } @@ -3719,13 +3920,15 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, stream_class, decl); BT_PUT(decl); if (ret) { - BT_LOGE_STR("Cannot set stream class's packet context field type."); + _BT_LOGE_NODE(node, + "Cannot set stream class's packet context field type."); goto error; } _SET(set, _STREAM_PACKET_CONTEXT_SET); } else { - BT_LOGW("Unknown attribute in stream class: " + _BT_LOGW_NODE(node, + "Unknown attribute in stream class: " "attr-name=\"%s\"", left); } @@ -3766,6 +3969,7 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) node->visited = TRUE; stream_class = create_reset_stream_class(ctx); if (!stream_class) { + _BT_LOGE_NODE(node, "Cannot create empty stream class."); ret = -EINVAL; goto error; } @@ -3779,6 +3983,9 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) bt_list_for_each_entry(iter, decl_list, siblings) { ret = visit_stream_decl_entry(ctx, iter, stream_class, &set); if (ret) { + _BT_LOGE_NODE(iter, + "Cannot visit stream class's entry: " + "ret=%d", ret); ctx_pop_scope(ctx); goto error; } @@ -3794,7 +4001,8 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) packet_header_decl = bt_ctf_trace_get_packet_header_type(ctx->trace); if (!packet_header_decl) { - BT_LOGE_STR("Stream class has a `id` attribute, " + _BT_LOGE_NODE(node, + "Stream class has a `id` attribute, " "but trace has no packet header field type."); goto error; } @@ -3804,14 +4012,16 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) packet_header_decl, "stream_id"); BT_PUT(packet_header_decl); if (!stream_id_decl) { - BT_LOGE_STR("Stream class has a `id` attribute, " + _BT_LOGE_NODE(node, + "Stream class has a `id` attribute, " "but trace's packet header field type has no `stream_id` field."); goto error; } if (!bt_ctf_field_type_is_integer(stream_id_decl)) { BT_PUT(stream_id_decl); - BT_LOGE_STR("Stream class has a `id` attribute, " + _BT_LOGE_NODE(node, + "Stream class has a `id` attribute, " "but trace's packet header field type's `stream_id` field is not an integer field type."); goto error; } @@ -3820,7 +4030,8 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) } else { /* Allow only _one_ ID-less stream */ if (g_hash_table_size(ctx->stream_classes) != 0) { - BT_LOGE_STR("Missing `id` attribute in stream class as there's more than one stream class in the trace."); + _BT_LOGE_NODE(node, + "Missing `id` attribute in stream class as there's more than one stream class in the trace."); ret = -EPERM; goto error; } @@ -3832,7 +4043,8 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) id = bt_ctf_stream_class_get_id(stream_class); if (id < 0) { - BT_LOGE_STR("Cannot get stream class's ID."); + _BT_LOGE_NODE(node, + "Cannot get stream class's ID."); ret = -EINVAL; goto error; } @@ -3845,7 +4057,8 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) id); if (g_hash_table_lookup(ctx->stream_classes, (gpointer) id) || existing_stream_class) { - BT_LOGE("Duplicate stream class (same ID): id=%" PRId64, + _BT_LOGE_NODE(node, + "Duplicate stream class (same ID): id=%" PRId64, id); ret = -EINVAL; goto error; @@ -3877,7 +4090,8 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) ret = visit_typedef(ctx, node->u._typedef.type_specifier_list, &node->u._typedef.type_declarators); if (ret) { - BT_LOGE_STR("Cannot add type definition found in trace (`trace` block)."); + _BT_LOGE_NODE(node, + "Cannot add type definition found in trace (`trace` block)."); goto error; } break; @@ -3885,7 +4099,8 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) ret = visit_typealias(ctx, node->u.typealias.target, node->u.typealias.alias); if (ret) { - BT_LOGE_STR("Cannot add type alias found in trace (`trace` block)."); + _BT_LOGE_NODE(node, + "Cannot add type alias found in trace (`trace` block)."); goto error; } break; @@ -3893,13 +4108,14 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) { left = concatenate_unary_strings(&node->u.ctf_expression.left); if (!left) { + _BT_LOGE_NODE(node, "Cannot concatenate unary strings."); ret = -EINVAL; goto error; } if (!strcmp(left, "major")) { if (_IS_SET(set, _TRACE_MAJOR_SET)) { - _BT_LOGE_DUP_ATTR("major", "trace"); + _BT_LOGE_DUP_ATTR(node, "major", "trace"); ret = -EPERM; goto error; } @@ -3907,7 +4123,8 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) ret = get_unary_unsigned(&node->u.ctf_expression.right, &ctx->trace_major); if (ret) { - BT_LOGE_STR("Unexpected unary expression for trace's `major` attribute."); + _BT_LOGE_NODE(node, + "Unexpected unary expression for trace's `major` attribute."); ret = -EINVAL; goto error; } @@ -3915,7 +4132,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) _SET(set, _TRACE_MAJOR_SET); } else if (!strcmp(left, "minor")) { if (_IS_SET(set, _TRACE_MINOR_SET)) { - _BT_LOGE_DUP_ATTR("minor", "trace"); + _BT_LOGE_DUP_ATTR(node, "minor", "trace"); ret = -EPERM; goto error; } @@ -3923,7 +4140,8 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) ret = get_unary_unsigned(&node->u.ctf_expression.right, &ctx->trace_minor); if (ret) { - BT_LOGE_STR("Unexpected unary expression for trace's `minor` attribute."); + _BT_LOGE_NODE(node, + "Unexpected unary expression for trace's `minor` attribute."); ret = -EINVAL; goto error; } @@ -3931,7 +4149,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) _SET(set, _TRACE_MINOR_SET); } else if (!strcmp(left, "uuid")) { if (_IS_SET(set, _TRACE_UUID_SET)) { - _BT_LOGE_DUP_ATTR("uuid", "trace"); + _BT_LOGE_DUP_ATTR(node, "uuid", "trace"); ret = -EPERM; goto error; } @@ -3939,13 +4157,14 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) ret = get_unary_uuid(&node->u.ctf_expression.right, ctx->trace_uuid); if (ret) { - BT_LOGE_STR("Invalid trace's `uuid` attribute."); + _BT_LOGE_NODE(node, + "Invalid trace's `uuid` attribute."); goto error; } ret = bt_ctf_trace_set_uuid(ctx->trace, ctx->trace_uuid); if (ret) { - BT_LOGE_STR("Cannot set trace's UUID."); + _BT_LOGE_NODE(node, "Cannot set trace's UUID."); goto error; } @@ -3953,7 +4172,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) } else if (!strcmp(left, "byte_order")) { /* Native byte order is already known at this stage */ if (_IS_SET(set, _TRACE_BYTE_ORDER_SET)) { - _BT_LOGE_DUP_ATTR("byte_order", + _BT_LOGE_DUP_ATTR(node, "byte_order", "trace"); ret = -EPERM; goto error; @@ -3962,7 +4181,8 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) _SET(set, _TRACE_BYTE_ORDER_SET); } else if (!strcmp(left, "packet.header")) { if (_IS_SET(set, _TRACE_PACKET_HEADER_SET)) { - BT_LOGE_STR("Duplicate `packet.header` entry in trace."); + _BT_LOGE_NODE(node, + "Duplicate `packet.header` entry in trace."); ret = -EPERM; goto error; } @@ -3973,7 +4193,8 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) struct ctf_node, siblings), &packet_header_decl); if (ret) { - BT_LOGE_STR("Cannot create trace's packet header field type."); + _BT_LOGE_NODE(node, + "Cannot create trace's packet header field type."); goto error; } @@ -3982,13 +4203,15 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) packet_header_decl); BT_PUT(packet_header_decl); if (ret) { - BT_LOGE_STR("Cannot set trace's packet header field type."); + _BT_LOGE_NODE(node, + "Cannot set trace's packet header field type."); goto error; } _SET(set, _TRACE_PACKET_HEADER_SET); } else { - BT_LOGW("Unknown attribute in stream class: " + _BT_LOGW_NODE(node, + "Unknown attribute in stream class: " "attr-name=\"%s\"", left); } @@ -3997,7 +4220,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) break; } default: - BT_LOGE_STR("Unknown expression in trace."); + _BT_LOGE_NODE(node, "Unknown expression in trace."); ret = -EINVAL; goto error; } @@ -4026,7 +4249,7 @@ int visit_trace_decl(struct ctx *ctx, struct ctf_node *node) node->visited = TRUE; if (ctx->is_trace_visited) { - BT_LOGE_STR("Duplicate trace (`trace` block)."); + _BT_LOGE_NODE(node, "Duplicate trace (`trace` block)."); ret = -EEXIST; goto error; } @@ -4040,6 +4263,8 @@ int visit_trace_decl(struct ctx *ctx, struct ctf_node *node) bt_list_for_each_entry(iter, decl_list, siblings) { ret = visit_trace_decl_entry(ctx, iter, &set); if (ret) { + _BT_LOGE_NODE(iter, "Cannot visit trace's entry (`trace` block): " + "ret=%d", ret); ctx_pop_scope(ctx); goto error; } @@ -4048,19 +4273,22 @@ int visit_trace_decl(struct ctx *ctx, struct ctf_node *node) ctx_pop_scope(ctx); if (!_IS_SET(&set, _TRACE_MAJOR_SET)) { - BT_LOGE_STR("Missing `major` attribute in trace (`trace` block)."); + _BT_LOGE_NODE(node, + "Missing `major` attribute in trace (`trace` block)."); ret = -EPERM; goto error; } if (!_IS_SET(&set, _TRACE_MINOR_SET)) { - BT_LOGE_STR("Missing `minor` attribute in trace (`trace` block)."); + _BT_LOGE_NODE(node, + "Missing `minor` attribute in trace (`trace` block)."); ret = -EPERM; goto error; } if (!_IS_SET(&set, _TRACE_BYTE_ORDER_SET)) { - BT_LOGE_STR("Missing `byte_order` attribute in trace (`trace` block)."); + _BT_LOGE_NODE(node, + "Missing `byte_order` attribute in trace (`trace` block)."); ret = -EPERM; goto error; } @@ -4093,7 +4321,8 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) &entry_node->u.ctf_expression.right; if (entry_node->type != NODE_CTF_EXPRESSION) { - BT_LOGE("Wrong expression in environment entry: " + _BT_LOGE_NODE(entry_node, + "Wrong expression in environment entry: " "node-type=%d", entry_node->type); ret = -EPERM; goto error; @@ -4102,7 +4331,8 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) left = concatenate_unary_strings( &entry_node->u.ctf_expression.left); if (!left) { - BT_LOGE_STR("Cannot get environment entry's name."); + _BT_LOGE_NODE(entry_node, + "Cannot get environment entry's name."); ret = -EINVAL; goto error; } @@ -4111,7 +4341,8 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) char *right = concatenate_unary_strings(right_head); if (!right) { - BT_LOGE("Unexpected unary expression for environment entry's value: " + _BT_LOGE_NODE(entry_node, + "Unexpected unary expression for environment entry's value: " "name=\"%s\"", left); ret = -EINVAL; goto error; @@ -4119,6 +4350,9 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) if (strcmp(left, "tracer_name") == 0) { if (strncmp(right, "lttng", 5) == 0) { + BT_LOGI("Detected LTTng trace from `%s` environment value: " + "tracer-name=\"%s\"", + left, right); ctx->is_lttng = 1; } } @@ -4128,7 +4362,8 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) g_free(right); if (ret) { - BT_LOGE("Cannot add string environment entry to trace: " + _BT_LOGE_NODE(entry_node, + "Cannot add string environment entry to trace: " "name=\"%s\", ret=%d", left, ret); goto error; } @@ -4143,7 +4378,8 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) ret = get_unary_signed(right_head, &v); } if (ret) { - BT_LOGE("Unexpected unary expression for environment entry's value: " + _BT_LOGE_NODE(entry_node, + "Unexpected unary expression for environment entry's value: " "name=\"%s\"", left); ret = -EINVAL; goto error; @@ -4152,12 +4388,14 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) ret = bt_ctf_trace_set_environment_field_integer( ctx->trace, left, v); if (ret) { - BT_LOGE("Cannot add integer environment entry to trace: " + _BT_LOGE_NODE(entry_node, + "Cannot add integer environment entry to trace: " "name=\"%s\", ret=%d", left, ret); goto error; } } else { - BT_LOGW("Environment entry has unknown type: " + _BT_LOGW_NODE(entry_node, + "Environment entry has unknown type: " "name=\"%s\"", left); } @@ -4190,6 +4428,8 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node) left = concatenate_unary_strings( &node->u.ctf_expression.left); if (!left) { + _BT_LOGE_NODE(node, + "Cannot concatenate unary strings."); ret = -EINVAL; goto error; } @@ -4198,7 +4438,7 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node) enum bt_ctf_byte_order bo; if (_IS_SET(&set, _TRACE_BYTE_ORDER_SET)) { - _BT_LOGE_DUP_ATTR("byte_order", + _BT_LOGE_DUP_ATTR(node, "byte_order", "trace"); ret = -EPERM; goto error; @@ -4210,10 +4450,14 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node) struct ctf_node, siblings); bo = byte_order_from_unary_expr(right_node); if (bo == BT_CTF_BYTE_ORDER_UNKNOWN) { + _BT_LOGE_NODE(node, + "Invalid `byte_order` attribute in trace (`trace` block): " + "expecting `le`, `be`, or `network`."); ret = -EINVAL; goto error; } else if (bo == BT_CTF_BYTE_ORDER_NATIVE) { - BT_LOGE_STR("Invalid `byte_order` attribute in trace (`trace` block): " + _BT_LOGE_NODE(node, + "Invalid `byte_order` attribute in trace (`trace` block): " "cannot be set to `native` here."); ret = -EPERM; goto error; @@ -4223,7 +4467,8 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node) ret = bt_ctf_trace_set_native_byte_order( ctx->trace, bo); if (ret) { - BT_LOGE("Cannot set trace's byte order: " + _BT_LOGE_NODE(node, + "Cannot set trace's byte order: " "ret=%d", ret); goto error; } @@ -4235,7 +4480,8 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node) } if (!_IS_SET(&set, _TRACE_BYTE_ORDER_SET)) { - BT_LOGE_STR("Missing `byte_order` attribute in trace (`trace` block)."); + _BT_LOGE_NODE(trace_node, + "Missing `byte_order` attribute in trace (`trace` block)."); ret = -EINVAL; goto error; } @@ -4256,12 +4502,16 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, char *left = NULL; if (entry_node->type != NODE_CTF_EXPRESSION) { + _BT_LOGE_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); if (!left) { + _BT_LOGE_NODE(entry_node, "Cannot concatenate unary strings."); ret = -EINVAL; goto error; } @@ -4270,7 +4520,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, char *right; if (_IS_SET(set, _CLOCK_NAME_SET)) { - _BT_LOGE_DUP_ATTR("name", "clock class"); + _BT_LOGE_DUP_ATTR(entry_node, "name", "clock class"); ret = -EPERM; goto error; } @@ -4278,14 +4528,16 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, right = concatenate_unary_strings( &entry_node->u.ctf_expression.right); if (!right) { - BT_LOGE_STR("Unexpected unary expression for clock class's `name` attribute."); + _BT_LOGE_NODE(entry_node, + "Unexpected unary expression for clock class's `name` attribute."); ret = -EINVAL; goto error; } ret = bt_ctf_clock_class_set_name(clock, right); if (ret) { - BT_LOGE("cannot set clock class's name"); + _BT_LOGE_NODE(entry_node, + "cannot set clock class's name"); g_free(right); goto error; } @@ -4296,20 +4548,22 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, unsigned char uuid[BABELTRACE_UUID_LEN]; if (_IS_SET(set, _CLOCK_UUID_SET)) { - _BT_LOGE_DUP_ATTR("uuid", "clock class"); + _BT_LOGE_DUP_ATTR(entry_node, "uuid", "clock class"); ret = -EPERM; goto error; } ret = get_unary_uuid(&entry_node->u.ctf_expression.right, uuid); if (ret) { - BT_LOGE_STR("Invalid clock class's `uuid` attribute."); + _BT_LOGE_NODE(entry_node, + "Invalid clock class's `uuid` attribute."); goto error; } ret = bt_ctf_clock_class_set_uuid(clock, uuid); if (ret) { - BT_LOGE_STR("Cannot set clock class's UUID."); + _BT_LOGE_NODE(entry_node, + "Cannot set clock class's UUID."); goto error; } @@ -4318,7 +4572,8 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, char *right; if (_IS_SET(set, _CLOCK_DESCRIPTION_SET)) { - _BT_LOGE_DUP_ATTR("description", "clock class"); + _BT_LOGE_DUP_ATTR(entry_node, "description", + "clock class"); ret = -EPERM; goto error; } @@ -4326,14 +4581,16 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, right = concatenate_unary_strings( &entry_node->u.ctf_expression.right); if (!right) { - BT_LOGE_STR("Unexpected unary expression for clock class's `description` attribute."); + _BT_LOGE_NODE(entry_node, + "Unexpected unary expression for clock class's `description` attribute."); ret = -EINVAL; goto error; } ret = bt_ctf_clock_class_set_description(clock, right); if (ret) { - BT_LOGE_STR("Cannot set clock class's description."); + _BT_LOGE_NODE(entry_node, + "Cannot set clock class's description."); g_free(right); goto error; } @@ -4344,7 +4601,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, uint64_t freq; if (_IS_SET(set, _CLOCK_FREQ_SET)) { - _BT_LOGE_DUP_ATTR("freq", "clock class"); + _BT_LOGE_DUP_ATTR(entry_node, "freq", "clock class"); ret = -EPERM; goto error; } @@ -4352,14 +4609,16 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = get_unary_unsigned( &entry_node->u.ctf_expression.right, &freq); if (ret) { - BT_LOGE_STR("Unexpected unary expression for clock class's `freq` attribute."); + _BT_LOGE_NODE(entry_node, + "Unexpected unary expression for clock class's `freq` attribute."); ret = -EINVAL; goto error; } ret = bt_ctf_clock_class_set_frequency(clock, freq); if (ret) { - BT_LOGE_STR("Cannot set clock class's frequency."); + _BT_LOGE_NODE(entry_node, + "Cannot set clock class's frequency."); goto error; } @@ -4368,7 +4627,8 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, uint64_t precision; if (_IS_SET(set, _CLOCK_PRECISION_SET)) { - _BT_LOGE_DUP_ATTR("precision", "clock class"); + _BT_LOGE_DUP_ATTR(entry_node, "precision", + "clock class"); ret = -EPERM; goto error; } @@ -4376,14 +4636,16 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = get_unary_unsigned( &entry_node->u.ctf_expression.right, &precision); if (ret) { - BT_LOGE_STR("Unexpected unary expression for clock class's `precision` attribute."); + _BT_LOGE_NODE(entry_node, + "Unexpected unary expression for clock class's `precision` attribute."); ret = -EINVAL; goto error; } ret = bt_ctf_clock_class_set_precision(clock, precision); if (ret) { - BT_LOGE_STR("Cannot set clock class's precision."); + _BT_LOGE_NODE(entry_node, + "Cannot set clock class's precision."); goto error; } @@ -4392,7 +4654,8 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, uint64_t offset_s; if (_IS_SET(set, _CLOCK_OFFSET_S_SET)) { - _BT_LOGE_DUP_ATTR("offset_s", "clock class"); + _BT_LOGE_DUP_ATTR(entry_node, "offset_s", + "clock class"); ret = -EPERM; goto error; } @@ -4400,14 +4663,16 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = get_unary_unsigned( &entry_node->u.ctf_expression.right, &offset_s); if (ret) { - BT_LOGE_STR("Unexpected unary expression for clock class's `offset_s` attribute."); + _BT_LOGE_NODE(entry_node, + "Unexpected unary expression for clock class's `offset_s` attribute."); ret = -EINVAL; goto error; } ret = bt_ctf_clock_class_set_offset_s(clock, offset_s); if (ret) { - BT_LOGE_STR("Cannot set clock class's offset in seconds."); + _BT_LOGE_NODE(entry_node, + "Cannot set clock class's offset in seconds."); goto error; } @@ -4416,7 +4681,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, uint64_t offset; if (_IS_SET(set, _CLOCK_OFFSET_SET)) { - _BT_LOGE_DUP_ATTR("offset", "clock class"); + _BT_LOGE_DUP_ATTR(entry_node, "offset", "clock class"); ret = -EPERM; goto error; } @@ -4424,14 +4689,16 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = get_unary_unsigned( &entry_node->u.ctf_expression.right, &offset); if (ret) { - BT_LOGE_STR("Unexpected unary expression for clock class's `offset` attribute."); + _BT_LOGE_NODE(entry_node, + "Unexpected unary expression for clock class's `offset` attribute."); ret = -EINVAL; goto error; } ret = bt_ctf_clock_class_set_offset_cycles(clock, offset); if (ret) { - BT_LOGE_STR("Cannot set clock class's offset in cycles."); + _BT_LOGE_NODE(entry_node, + "Cannot set clock class's offset in cycles."); goto error; } @@ -4440,7 +4707,8 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, struct ctf_node *right; if (_IS_SET(set, _CLOCK_ABSOLUTE_SET)) { - _BT_LOGE_DUP_ATTR("absolute", "clock class"); + _BT_LOGE_DUP_ATTR(entry_node, "absolute", + "clock class"); ret = -EPERM; goto error; } @@ -4450,20 +4718,23 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, struct ctf_node, siblings); ret = get_boolean(right); if (ret < 0) { - BT_LOGE_STR("Unexpected unary expression for clock class's `absolute` attribute."); + _BT_LOGE_NODE(entry_node, + "Unexpected unary expression for clock class's `absolute` attribute."); ret = -EINVAL; goto error; } ret = bt_ctf_clock_class_set_is_absolute(clock, ret); if (ret) { - BT_LOGE_STR("Cannot set clock class's absolute flag."); + _BT_LOGE_NODE(entry_node, + "Cannot set clock class's absolute flag."); goto error; } _SET(set, _CLOCK_ABSOLUTE_SET); } else { - BT_LOGW("Unknown attribute in clock class: attr-name=\"%s\"", + _BT_LOGW_NODE(entry_node, + "Unknown attribute in clock class: attr-name=\"%s\"", left); } @@ -4538,7 +4809,8 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node) clock_node->visited = TRUE; clock = bt_ctf_clock_class_create(NULL); if (!clock) { - BT_LOGE_STR("Cannot create default clock class."); + _BT_LOGE_NODE(clock_node, + "Cannot create default clock class."); ret = -ENOMEM; goto error; } @@ -4546,12 +4818,16 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node) bt_list_for_each_entry(entry_node, decl_list, siblings) { ret = visit_clock_decl_entry(ctx, entry_node, clock, &set); if (ret) { + _BT_LOGE_NODE(entry_node, + "Cannot visit clock class's entry: ret=%d", + ret); goto error; } } if (!_IS_SET(&set, _CLOCK_NAME_SET)) { - BT_LOGE_STR("Missing `name` attribute in clock class."); + _BT_LOGE_NODE(clock_node, + "Missing `name` attribute in clock class."); ret = -EPERM; goto error; } @@ -4567,20 +4843,23 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node) */ ret = bt_ctf_clock_class_set_is_absolute(clock, 1); if (ret) { - BT_LOGE_STR("Cannot set clock class's absolute flag."); + _BT_LOGE_NODE(clock_node, + "Cannot set clock class's absolute flag."); goto error; } } ret = apply_clock_class_offset(ctx, clock); if (ret) { - BT_LOGE_STR("Cannot apply clock class's custom offset."); + _BT_LOGE_NODE(clock_node, + "Cannot apply clock class's custom offset."); goto error; } ret = bt_ctf_trace_add_clock_class(ctx->trace, clock); if (ret) { - BT_LOGE_STR("Cannot add clock class to trace."); + _BT_LOGE_NODE(clock_node, + "Cannot add clock class to trace."); goto error; } @@ -4607,7 +4886,8 @@ int visit_root_decl(struct ctx *ctx, struct ctf_node *root_decl_node) root_decl_node->u._typedef.type_specifier_list, &root_decl_node->u._typedef.type_declarators); if (ret) { - BT_LOGE_STR("Cannot add type definition found in root scope."); + _BT_LOGE_NODE(root_decl_node, + "Cannot add type definition found in root scope."); goto end; } break; @@ -4615,7 +4895,8 @@ int visit_root_decl(struct ctx *ctx, struct ctf_node *root_decl_node) ret = visit_typealias(ctx, root_decl_node->u.typealias.target, root_decl_node->u.typealias.alias); if (ret) { - BT_LOGE_STR("Cannot add type alias found in root scope."); + _BT_LOGE_NODE(root_decl_node, + "Cannot add type alias found in root scope."); goto end; } break; @@ -4629,6 +4910,9 @@ int visit_root_decl(struct ctx *ctx, struct ctf_node *root_decl_node) */ ret = visit_type_specifier_list(ctx, root_decl_node, &decl); if (ret) { + _BT_LOGE_NODE(root_decl_node, + "Cannot visit root scope's field type: " + "ret=%d", ret); assert(!decl); goto end; } @@ -4637,6 +4921,9 @@ int visit_root_decl(struct ctx *ctx, struct ctf_node *root_decl_node) break; } default: + _BT_LOGE_NODE(root_decl_node, + "Unexpected node type: node-type=%d", + root_decl_node->type); ret = -EPERM; goto end; } @@ -4655,6 +4942,7 @@ int set_trace_name(struct ctx *ctx) assert(bt_ctf_trace_get_stream_class_count(ctx->trace) == 0); name = g_string_new(NULL); if (!name) { + BT_LOGE_STR("Failed to allocate a GString."); ret = -1; goto end; } @@ -4683,6 +4971,7 @@ int set_trace_name(struct ctx *ctx) ret = bt_ctf_trace_set_name(ctx->trace, name->str); if (ret) { + BT_LOGE("Cannot set trace's name: name=\"%s\"", name->str); goto error; } @@ -4718,6 +5007,7 @@ int move_ctx_stream_classes_to_trace(struct ctx *ctx) */ ret = set_trace_name(ctx); if (ret) { + BT_LOGE_STR("Cannot set trace's name."); goto end; } } @@ -4812,7 +5102,6 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, { struct ctf_node *iter; int got_trace_decl = FALSE; - int found_callsite = FALSE; /* * The first thing we need is the native byte order of @@ -4824,14 +5113,16 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, if (ctx->trace_bo == BT_CTF_BYTE_ORDER_NATIVE) { bt_list_for_each_entry(iter, &node->u.root.trace, siblings) { if (got_trace_decl) { - BT_LOGE_STR("Duplicate trace (`trace` block)."); + _BT_LOGE_NODE(node, + "Duplicate trace (`trace` block)."); ret = -1; goto end; } ret = set_trace_byte_order(ctx, iter); if (ret) { - BT_LOGE("Cannot set trace's native byte order: " + _BT_LOGE_NODE(node, + "Cannot set trace's native byte order: " "ret=%d", ret); goto end; } @@ -4840,6 +5131,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, } if (!got_trace_decl) { + BT_LOGD_STR("Incomplete AST: need trace (`trace` block)."); ret = -EINCOMPLETE; goto end; } @@ -4854,7 +5146,8 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, bt_list_for_each_entry(iter, &node->u.root.env, siblings) { ret = visit_env(ctx, iter); if (ret) { - BT_LOGE("Cannot visit trace's environment (`env` block): " + _BT_LOGE_NODE(iter, + "Cannot visit trace's environment (`env` block) entry: " "ret=%d", ret); goto end; } @@ -4869,7 +5162,8 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, bt_list_for_each_entry(iter, &node->u.root.clock, siblings) { ret = visit_clock_decl(ctx, iter); if (ret) { - BT_LOGE("Cannot visit clock class: ret=%d", + _BT_LOGE_NODE(iter, + "Cannot visit clock class: ret=%d", ret); goto end; } @@ -4886,7 +5180,8 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, siblings) { ret = visit_root_decl(ctx, iter); if (ret) { - BT_LOGE("Cannot visit root entry: ret=%d", + _BT_LOGE_NODE(iter, + "Cannot visit root entry: ret=%d", ret); goto end; } @@ -4897,22 +5192,19 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, /* Callsite blocks are not supported */ bt_list_for_each_entry(iter, &node->u.root.callsite, siblings) { - found_callsite = TRUE; - break; + _BT_LOGW_NODE(iter, + "\"callsite\" blocks are not supported as of this version."); } assert(ctx->current_scope && ctx->current_scope->parent_scope == NULL); - if (found_callsite) { - BT_LOGW("\"callsite\" blocks are not supported as of this version."); - } - /* Trace */ bt_list_for_each_entry(iter, &node->u.root.trace, siblings) { ret = visit_trace_decl(ctx, iter); if (ret) { - BT_LOGE("Cannot visit trace (`trace` block): " + _BT_LOGE_NODE(iter, + "Cannot visit trace (`trace` block): " "ret=%d", ret); goto end; } @@ -4925,7 +5217,8 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, bt_list_for_each_entry(iter, &node->u.root.stream, siblings) { ret = visit_stream_decl(ctx, iter); if (ret) { - BT_LOGE("Cannot visit stream class: ret=%d", + _BT_LOGE_NODE(iter, + "Cannot visit stream class: ret=%d", ret); goto end; } @@ -4938,7 +5231,8 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, bt_list_for_each_entry(iter, &node->u.root.event, siblings) { ret = visit_event_decl(ctx, iter); if (ret) { - BT_LOGE("Cannot visit event class: ret=%d", + _BT_LOGE_NODE(iter, + "Cannot visit event class: ret=%d", ret); goto end; } @@ -4949,7 +5243,8 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, break; } default: - BT_LOGE("Unexpected node type: node-type=%d", + _BT_LOGE_NODE(node, + "Unexpected node type: node-type=%d", node->type); ret = -EINVAL; goto end;