Add environment information
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 6 Feb 2012 23:16:40 +0000 (18:16 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 6 Feb 2012 23:16:40 +0000 (18:16 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust/ltt-events.c

index 71e959d64cf2d9840f885b91128865842cae1639..9d5d882794dbe9a555405a3c0f0f84b8714f93b0 100644 (file)
@@ -22,6 +22,7 @@
 #include <stddef.h>
 #include <inttypes.h>
 #include <time.h>
+#include <sys/prctl.h>
 #include "clock.h"
 
 #include <urcu-bp.h>
@@ -43,6 +44,8 @@
 #include "../libringbuffer/shm.h"
 #include "jhash.h"
 
+#define PROCNAME_LEN 17
+
 /*
  * The sessions mutex is the centralized mutex across UST tracing
  * control and probe registration. All operations within this file are
@@ -1088,6 +1091,7 @@ int _ltt_session_metadata_statedump(struct ltt_session *session)
        struct ltt_channel *chan;
        struct ltt_event *event;
        int ret = 0;
+       char procname[PROCNAME_LEN] = "";
 
        if (!CMM_ACCESS_ONCE(session->active))
                return 0;
@@ -1140,6 +1144,22 @@ int _ltt_session_metadata_statedump(struct ltt_session *session)
        if (ret)
                goto end;
 
+       /* ignore error, just use empty string if error. */
+       (void) prctl(PR_GET_NAME, (unsigned long) procname, 0, 0, 0);
+       procname[PROCNAME_LEN - 1] = '\0';
+       ret = lttng_metadata_printf(session,
+               "env {\n"
+               "       vpid = %d;\n"
+               "       procname = \"%s\";\n"
+               "       domain = %s;\n"
+               "};\n\n",
+               (int) getpid(),
+               procname,
+               "ust"
+               );
+       if (ret)
+               goto end;
+
        ret = lttng_metadata_printf(session,
                "clock {\n"
                "       name = %s;\n",
This page took 0.025575 seconds and 4 git commands to generate.