return 0;
}
+static
+void sanitize_ctf_identifier(char *out, const char *in)
+{
+ size_t i;
+
+ for (i = 0; i < LTTNG_UST_SYM_NAME_LEN; i++) {
+ switch (in[i]) {
+ case '.':
+ case '$':
+ case ':':
+ out[i] = '_';
+ break;
+ default:
+ out[i] = in[i];
+ }
+ }
+}
+
/* Called with session registry mutex held. */
static
int ust_metadata_enum_statedump(struct ust_registry_session *session,
size_t nr_entries;
int ret = 0;
size_t i;
+ char identifier[LTTNG_UST_SYM_NAME_LEN];
rcu_read_lock();
reg_enum = ust_registry_lookup_enum_by_id(session, enum_name, enum_id);
const struct ustctl_enum_entry *entry = &entries[i];
int j, len;
+ ret = print_tabs(session, nesting);
+ if (ret) {
+ goto end;
+ }
ret = lttng_metadata_printf(session,
- " \"");
+ "\"");
if (ret) {
goto end;
}
goto end;
}
}
- ret = lttng_metadata_printf(session, " } _%s;\n",
- field_name);
+ sanitize_ctf_identifier(identifier, field_name);
+ ret = print_tabs(session, nesting);
+ if (ret) {
+ goto end;
+ }
+ ret = lttng_metadata_printf(session, "} _%s;\n",
+ identifier);
end:
(*iter_field)++;
return ret;
}
-
static
int _lttng_variant_statedump(struct ust_registry_session *session,
const struct ustctl_field *fields, size_t nr_fields,
const struct ustctl_field *variant = &fields[*iter_field];
uint32_t nr_choices, i;
int ret;
+ char identifier[LTTNG_UST_SYM_NAME_LEN];
if (variant->type.atype != ustctl_atype_variant) {
ret = -EINVAL;
}
nr_choices = variant->type.u.variant.nr_choices;
(*iter_field)++;
+ sanitize_ctf_identifier(identifier, variant->type.u.variant.tag_name);
+ ret = print_tabs(session, nesting);
+ if (ret) {
+ goto end;
+ }
ret = lttng_metadata_printf(session,
- " variant <_%s> {\n",
- variant->type.u.variant.tag_name);
+ "variant <_%s> {\n",
+ identifier);
if (ret) {
goto end;
}
fields, nr_fields,
iter_field, nesting + 1);
}
+ sanitize_ctf_identifier(identifier, variant->name);
+ ret = print_tabs(session, nesting);
ret = lttng_metadata_printf(session,
- " } _%s;\n",
- variant->name);
+ "} _%s;\n",
+ identifier);
if (ret) {
goto end;
}
OCTALDIGIT [0-7]
UCHARLOWERCASE \\u{HEXDIGIT}{4}
UCHARUPPERCASE \\U{HEXDIGIT}{8}
-ID_NONDIGIT {NONDIGIT}|{UCHARLOWERCASE}|{UCHARUPPERCASE}
+ID_EXTRA_CHAR (":"|".")
+ID_NONDIGIT {NONDIGIT}|{UCHARLOWERCASE}|{UCHARUPPERCASE}|{ID_EXTRA_CHAR}
IDENTIFIER {ID_NONDIGIT}({ID_NONDIGIT}|{DIGIT})*
ESCSEQ \\(\'|\"|\?|\\|a|b|f|n|r|t|v|{OCTALDIGIT}{1,3}|u{HEXDIGIT}{4}|U{HEXDIGIT}{8}|x{HEXDIGIT}+)
%%
side);
case AST_EXP_GLOBAL_IDENTIFIER:
{
- struct filter_node *next;
+ const char *name;
- if (node->u.expression.pre_op == AST_LINK_UNKNOWN) {
- fprintf(stderr, "[error] %s: global identifiers need chained identifier \n", __func__);
- return NULL;
- }
- /* We currently only support $ctx (context) identifiers */
+ /*
+ * We currently only support $ctx (context) and $app
+ * identifiers.
+ */
if (strncmp(node->u.expression.u.identifier,
- "$ctx", strlen("$ctx")) != 0) {
- fprintf(stderr, "[error] %s: \"%s\" global identifier is unknown. Only \"$ctx\" currently implemented.\n", __func__, node->u.expression.u.identifier);
- return NULL;
- }
- next = node->u.expression.next;
- if (!next) {
- fprintf(stderr, "[error] %s: Expecting a context name, e.g. \'$ctx.name\'.\n", __func__);
+ "$ctx.", strlen("$ctx.")) != 0
+ && strncmp(node->u.expression.u.identifier,
+ "$app.", strlen("$app.")) != 0) {
+ fprintf(stderr, "[error] %s: \"%s\" global identifier is unknown. Only \"$ctx\" and \"$app\" are currently implemented.\n", __func__, node->u.expression.u.identifier);
return NULL;
}
- if (next->type != NODE_EXPRESSION) {
- fprintf(stderr, "[error] %s: Expecting expression.\n", __func__);
+ name = strchr(node->u.expression.u.identifier, '.');
+ if (!name) {
+ fprintf(stderr, "[error] %s: Expecting '.'\n", __func__);
return NULL;
}
- if (next->u.expression.type != AST_EXP_IDENTIFIER) {
- fprintf(stderr, "[error] %s: Expecting identifier.\n", __func__);
- return NULL;
- }
- if (next->u.expression.pre_op != AST_LINK_UNKNOWN) {
- fprintf(stderr, "[error] %s: dotted and dereferenced identifiers not supported after identifier\n", __func__);
+ name++; /* Skip . */
+ if (!strlen(name)) {
+ fprintf(stderr, "[error] %s: Expecting a context name, e.g. \'$ctx.name\'.\n", __func__);
return NULL;
}
- return make_op_load_get_context_ref(next->u.expression.u.identifier,
+ return make_op_load_get_context_ref(node->u.expression.u.identifier,
side);
}
case AST_EXP_NESTED: