Introduce LTTNG_KERNEL_SESSION_SET_CREATION_TIME
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 13 Aug 2019 18:14:25 +0000 (14:14 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 13 Aug 2019 20:29:30 +0000 (16:29 -0400)
Add trace_creation_datetime to the metadata env field

This allows a viewer to get more information regarding the creation time
of a trace. This information is normally inferred from the trace
hierarchy.

The ABI expects an ISO8601 compliant string value. We leave the
formatting to the trace controller.

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

index aab2caca467f15eadcfb916858931b134daad6d5..cc8f1838360faf8e60d7a369fe28924bad0ceb7c 100644 (file)
@@ -470,6 +470,23 @@ int lttng_abi_session_set_name(struct lttng_session *session,
        return 0;
 }
 
+static
+int lttng_abi_session_set_creation_time(struct lttng_session *session,
+               struct lttng_kernel_session_creation_time *time)
+{
+       size_t len;
+
+       len = strnlen(time->iso8601, LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN);
+
+       if (len == LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN) {
+               /* Time is too long/malformed */
+               return -EINVAL;
+       }
+
+       strcpy(session->creation_time, time->iso8601);
+       return 0;
+}
+
 /**
  *     lttng_session_ioctl - lttng session fd ioctl
  *
@@ -589,6 +606,16 @@ long lttng_session_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                        return -EFAULT;
                return lttng_abi_session_set_name(session, &name);
        }
+       case LTTNG_KERNEL_SESSION_SET_CREATION_TIME:
+       {
+               struct lttng_kernel_session_creation_time time;
+
+               if (copy_from_user(&time,
+                               (struct lttng_kernel_session_creation_time __user *) arg,
+                               sizeof(struct lttng_kernel_session_creation_time)))
+                       return -EFAULT;
+               return lttng_abi_session_set_creation_time(session, &time);
+       }
        default:
                return -ENOIOCTLCMD;
        }
index 0dd9a9fe91c561bc52a9e91ef338e14873365a3a..c292de01bb2192a520c616894862c56b7c3fd2cc 100644 (file)
@@ -21,6 +21,7 @@
 
 #define LTTNG_KERNEL_SYM_NAME_LEN      256
 #define LTTNG_KERNEL_SESSION_NAME_LEN  256
+#define LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN 26
 
 enum lttng_kernel_instrumentation {
        LTTNG_KERNEL_TRACEPOINT = 0,
@@ -124,6 +125,10 @@ struct lttng_kernel_session_name {
        char name[LTTNG_KERNEL_SESSION_NAME_LEN];
 } __attribute__((packed));
 
+struct lttng_kernel_session_creation_time {
+       char iso8601[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN];
+} __attribute__((packed));
+
 enum lttng_kernel_calibrate_type {
        LTTNG_KERNEL_CALIBRATE_KRETPROBE,
 };
@@ -219,6 +224,8 @@ struct lttng_kernel_filter_bytecode {
 #define LTTNG_KERNEL_SESSION_STATEDUMP         _IO(0xF6, 0x5C)
 #define LTTNG_KERNEL_SESSION_SET_NAME          \
        _IOR(0xF6, 0x5D, struct lttng_kernel_session_name)
+#define LTTNG_KERNEL_SESSION_SET_CREATION_TIME         \
+       _IOR(0xF6, 0x5E, struct lttng_kernel_session_creation_time)
 
 /* Channel FD ioctl */
 #define LTTNG_KERNEL_STREAM                    _IO(0xF6, 0x62)
index 2e7670b8c9d4b59d05c2fb02568326921da7bc3f..38cd4447696087cbff8719796651e149ffd11b77 100644 (file)
@@ -2514,15 +2514,16 @@ error:
 }
 
 static
-int print_metadata_session_name(struct lttng_session *session)
+int print_metadata_escaped_field(struct lttng_session *session, const char *field,
+               const char *field_value)
 {
        int ret;
 
-       ret = lttng_metadata_printf(session, "  trace_name = \"");
+       ret = lttng_metadata_printf(session, "  %s = \"", field);
        if (ret)
                goto error;
 
-       ret = print_escaped_ctf_string(session, session->name);
+       ret = print_escaped_ctf_string(session, field_value);
        if (ret)
                goto error;
 
@@ -2619,7 +2620,11 @@ int _lttng_session_metadata_statedump(struct lttng_session *session)
        if (ret)
                goto end;
 
-       ret = print_metadata_session_name(session);
+       ret = print_metadata_escaped_field(session, "trace_name", session->name);
+       if (ret)
+               goto end;
+       ret = print_metadata_escaped_field(session, "trace_creation_datetime",
+                       session->creation_time);
        if (ret)
                goto end;
 
index bdd73ff6e9279cda143459cab8aea0cd6a43f44e..8fe36a7326121f7f7325112c7d77b0105e1eb9ea 100644 (file)
@@ -522,6 +522,7 @@ struct lttng_session {
        /* Hash table of events */
        struct lttng_event_ht events_ht;
        char name[LTTNG_KERNEL_SESSION_NAME_LEN];
+       char creation_time[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN];
 };
 
 struct lttng_metadata_cache {
This page took 0.034305 seconds and 4 git commands to generate.