From: gbastien+lttng@versatic.net (Geneviève Bastien)
Subject: [lttng-dev] [Patch LTTng-tools v2 3/5] Statedump the metadata for CTF global enumerations
Date: Tue, 11 Feb 2014 16:40:50 -0500 [thread overview]
Message-ID: <1392154852-31268-4-git-send-email-gbastien+lttng@versatic.net> (raw)
In-Reply-To: <1392154852-31268-1-git-send-email-gbastien+lttng@versatic.net>
The global type declaration is dumped along with the event description,
before the event itself so that the corresponding metadata precedes it in the
metadata file.
Signed-off-by: Genevi?ve Bastien <gbastien+lttng at versatic.net>
---
src/bin/lttng-sessiond/ust-metadata.c | 94 ++++++++++++++++++++++++++++++++++-
1 file changed, 92 insertions(+), 2 deletions(-)
diff --git a/src/bin/lttng-sessiond/ust-metadata.c b/src/bin/lttng-sessiond/ust-metadata.c
index f430ae1..743901a 100644
--- a/src/bin/lttng-sessiond/ust-metadata.c
+++ b/src/bin/lttng-sessiond/ust-metadata.c
@@ -187,6 +187,12 @@ int _lttng_field_statedump(struct ust_registry_session *session,
field->type.u.basic.integer.reverse_byte_order ? bo_reverse : bo_native,
field->name);
break;
+ case ustctl_atype_enum:
+ ret = lttng_metadata_printf(session,
+ " enum __ust_enum__%s _%s;\n",
+ field->type.u.basic.enumeration.name,
+ field->name);
+ break;
case ustctl_atype_float:
ret = lttng_metadata_printf(session,
" floating_point { exp_dig = %u; mant_dig = %u; align = %u;%s } _%s;\n",
@@ -196,8 +202,6 @@ int _lttng_field_statedump(struct ust_registry_session *session,
field->type.u.basic.integer.reverse_byte_order ? bo_reverse : bo_native,
field->name);
break;
- case ustctl_atype_enum:
- return -EINVAL;
case ustctl_atype_array:
{
const struct ustctl_basic_type *elem_type;
@@ -310,6 +314,87 @@ int _lttng_fields_metadata_statedump(struct ust_registry_session *session,
}
/*
+ * Dumps a global type to the metadata file for the session. It should
+ * verify whether this metadata was already dumped by a previous event.
+ */
+static
+int _lttng_one_global_type_statedump(struct ust_registry_session *session,
+ const struct ustctl_global_type_decl *global_type_decl)
+{
+ int ret = 0, i;
+
+ switch (global_type_decl->mtype) {
+ case ustctl_mtype_enum:
+ {
+ const struct ustctl_enum *uenum;
+
+ uenum = &global_type_decl->u.ctf_enum;
+ ret = lttng_metadata_printf(session,
+ "enum __ust_enum__%s: integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u; } {\n",
+ uenum->name,
+ uenum->container_type.size,
+ uenum->container_type.alignment,
+ uenum->container_type.signedness,
+ (uenum->container_type.encoding == ustctl_encode_none)
+ ? "none"
+ : (uenum->container_type.encoding == ustctl_encode_UTF8)
+ ? "UTF8"
+ : "ASCII",
+ uenum->container_type.base);
+ if (ret)
+ return ret;
+ /* Dump the entries */
+ for (i = 0; i < uenum->len; i++) {
+ struct ustctl_enum_entry entry;
+
+ entry = uenum->entries[i];
+ if (entry.start == entry.end) {
+ ret = lttng_metadata_printf(session,
+ " %s = %d,\n",
+ entry.string, entry.start);
+ if (ret)
+ return ret;
+ } else {
+ ret = lttng_metadata_printf(session,
+ " %s = %d ... %d,\n",
+ entry.string, entry.start, entry.end);
+ if (ret)
+ return ret;
+ }
+ }
+ ret = lttng_metadata_printf(session, "};\n\n");
+ if (ret)
+ return ret;
+ break;
+ }
+ default:
+ return -EINVAL;
+ }
+
+ return ret;
+}
+
+/*
+ * This function dumps to the metadata the global type declarations used by
+ * the event.
+ */
+static
+int _lttng_global_type_decl_statedump(struct ust_registry_session *session,
+ struct ust_registry_event *event)
+{
+ int ret = 0, i;
+
+ for (i = 0; i < event->nr_global_type_decl; i++) {
+ const struct ustctl_global_type_decl *global_type_decl = &event->global_type_decl[i];
+
+ ret = _lttng_one_global_type_statedump(session, global_type_decl);
+ if (ret)
+ return ret;
+ }
+ return ret;
+}
+
+/*
* Should be called with session registry mutex held.
*/
int ust_metadata_event_statedump(struct ust_registry_session *session,
@@ -322,6 +407,11 @@ int ust_metadata_event_statedump(struct ust_registry_session *session,
if (chan->chan_id == -1U)
return 0;
+ /* Dump the global types needed by this event */
+ ret = _lttng_global_type_decl_statedump(session, event);
+ if (ret)
+ goto end;
+
ret = lttng_metadata_printf(session,
"event {\n"
" name = \"%s\";\n"
--
1.8.5.4
next prev parent reply other threads:[~2014-02-11 21:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1390594045-7556-1-git-send-email-gbastien+lttng@versatic.net>
2014-02-11 21:40 ` [lttng-dev] LTTng-tools: Add support of global types and CTF enumerations Geneviève Bastien
2014-02-11 21:40 ` [lttng-dev] [Patch LTTng-tools v2 1/5] Update data structures to support CTF global type declarations Geneviève Bastien
2014-02-11 21:40 ` [lttng-dev] [Patch LTTng-tools v2 2/5] Receive the CTF global enumerations from ust by the session daemon Geneviève Bastien
2014-02-11 21:40 ` Geneviève Bastien [this message]
2014-02-11 21:40 ` [lttng-dev] [Patch LTTng-tools v2 4/5] Dump a global type only once per session Geneviève Bastien
2014-02-11 21:40 ` [lttng-dev] [Patch LTTng-tools v2 5/5] Regression tests for global type declarations in UST Geneviève Bastien
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1392154852-31268-4-git-send-email-gbastien+lttng@versatic.net \
--to=gbastien+lttng@versatic.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox