Add metadata env fields
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 13 Aug 2019 18:14:24 +0000 (14:14 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 13 Aug 2019 20:29:17 +0000 (16:29 -0400)
Add the following fields:

  - tracer_buffering_scheme
      The buffering scheme used by the tracer. lttng-modules sole
      buffering scheme is "global".
  - trace_name
      The name of the trace. Use the session name.

Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-events.c

index a4570b7b45a7d175ec2cf03680c7376786464eef..2e7670b8c9d4b59d05c2fb02568326921da7bc3f 100644 (file)
@@ -2478,6 +2478,60 @@ int64_t measure_clock_offset(void)
        return offset;
 }
 
+static
+int print_escaped_ctf_string(struct lttng_session *session, const char *string)
+{
+       int ret;
+       size_t i;
+       char cur;
+
+       i = 0;
+       cur = string[i];
+       while (cur != '\0') {
+               switch (cur) {
+               case '\n':
+                       ret = lttng_metadata_printf(session, "%s", "\\n");
+                       break;
+               case '\\':
+               case '"':
+                       ret = lttng_metadata_printf(session, "%c", '\\');
+                       if (ret)
+                               goto error;
+                       /* We still print the current char */
+                       /* Fallthrough */
+               default:
+                       ret = lttng_metadata_printf(session, "%c", cur);
+                       break;
+               }
+
+               if (ret)
+                       goto error;
+
+               cur = string[++i];
+       }
+error:
+       return ret;
+}
+
+static
+int print_metadata_session_name(struct lttng_session *session)
+{
+       int ret;
+
+       ret = lttng_metadata_printf(session, "  trace_name = \"");
+       if (ret)
+               goto error;
+
+       ret = print_escaped_ctf_string(session, session->name);
+       if (ret)
+               goto error;
+
+       ret = lttng_metadata_printf(session, "\";\n");
+
+error:
+       return ret;
+}
+
 /*
  * Output metadata into this session's metadata buffers.
  * Must be called with sessions_mutex held.
@@ -2553,7 +2607,7 @@ int _lttng_session_metadata_statedump(struct lttng_session *session)
                "       tracer_major = %d;\n"
                "       tracer_minor = %d;\n"
                "       tracer_patchlevel = %d;\n"
-               "};\n\n",
+               "       trace_buffering_scheme = \"global\";\n",
                current->nsproxy->uts_ns->name.nodename,
                utsname()->sysname,
                utsname()->release,
@@ -2565,6 +2619,15 @@ int _lttng_session_metadata_statedump(struct lttng_session *session)
        if (ret)
                goto end;
 
+       ret = print_metadata_session_name(session);
+       if (ret)
+               goto end;
+
+       /* Close env */
+       ret = lttng_metadata_printf(session, "};\n\n");
+       if (ret)
+               goto end;
+
        ret = lttng_metadata_printf(session,
                "clock {\n"
                "       name = \"%s\";\n",
This page took 0.036551 seconds and 4 git commands to generate.