lttng-sessiond: keep enabled/active state for sessions, cleanup enabled state for...
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 16 Nov 2011 00:15:18 +0000 (19:15 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 16 Nov 2011 00:15:18 +0000 (19:15 -0500)
allows

lttng list
Available tracing sessions:
  1) test1 (/root/lttng-traces/test1-20111115-191312) [inactive]
  2) test2 (/root/lttng-traces/test2-20111115-191310) [active]

and

root@thinkos:~# lttng list test2
Tracing session test2: [active]
    Trace path: /root/lttng-traces/test2-20111115-191502

When events/channels/sessions enabled state is set to -1, show an empty
string instead of the meaningless "[enabled: -1]".

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/lttng.h
lttng-sessiond/main.c
lttng-sessiond/session.h
lttng/commands/list.c

index ee749c1f6113c6f419ea71067d6b1775bdb4195f..280075037abdf9515111b90f4cb0756f33d752c3 100644 (file)
@@ -189,6 +189,7 @@ struct lttng_session {
        char name[NAME_MAX];
        /* The path where traces are written */
        char path[PATH_MAX];
+       uint32_t enabled;       /* enabled/started: 1, disabled/stopped: 0 */
 };
 
 /*
index d1cc3fa8f81a3aec484e6ca476720ff9a3e7fa48..2e6292d38a7e567b84d96484d8be22c10f9e28eb 100644 (file)
@@ -1790,6 +1790,7 @@ static void list_lttng_sessions(struct lttng_session *sessions)
                sessions[i].path[PATH_MAX - 1] = '\0';
                strncpy(sessions[i].name, session->name, NAME_MAX);
                sessions[i].name[NAME_MAX - 1] = '\0';
+               sessions[i].enabled = session->enabled;
                i++;
        }
 }
@@ -2512,6 +2513,10 @@ static int cmd_start_trace(struct ltt_session *session)
        ksession = session->kernel_session;
        usess = session->ust_session;
 
+       if (session->enabled)
+               return LTTCOMM_UST_START_FAIL;
+       session->enabled = 1;
+
        /* Kernel tracing */
        if (ksession != NULL) {
                struct ltt_kernel_channel *kchan;
@@ -2597,6 +2602,10 @@ static int cmd_stop_trace(struct ltt_session *session)
        /* Short cut */
        ksession = session->kernel_session;
 
+       if (!session->enabled)
+               return LTTCOMM_UST_START_FAIL;
+       session->enabled = 0;
+
        /* Kernel tracer */
        if (ksession != NULL) {
                DBG("Stop kernel tracing");
index f6a9fff4de0a2351f004ca24fdea5ec409a0b3bc..2d077a4bc2e60e3d1cd871ae4d1bb60ac4595344 100644 (file)
@@ -67,6 +67,7 @@ struct ltt_session {
         */
        pthread_mutex_t lock;
        struct cds_list_head list;
+       int enabled;    /* enabled/started flag */
 };
 
 /* Prototypes */
index fcfaa3f23513d0970c0f609f521f5f25ac2e20dd..a3d8868b52c6539117c7b5f8f8b07173d5cc18d0 100644 (file)
@@ -109,6 +109,28 @@ end:
        return cmdline;
 }
 
+static
+const char *active_string(int value)
+{
+       switch (value) {
+       case 0: return " [active]";
+       case 1: return " [inactive]";
+       case -1: return "";
+       default: return NULL;
+       }
+}
+
+static
+const char *enabled_string(int value)
+{
+       switch (value) {
+       case 0: return " [enabled]";
+       case 1: return " [disabled]";
+       case -1: return "";
+       default: return NULL;
+       }
+}
+
 /*
  * Pretty print single event.
  */
@@ -116,12 +138,12 @@ static void print_events(struct lttng_event *event)
 {
        switch (event->type) {
        case LTTNG_EVENT_TRACEPOINT:
-               MSG("%s%s (type: tracepoint) [enabled: %d]", indent6,
-                               event->name, event->enabled);
+               MSG("%s%s (type: tracepoint)%s", indent6,
+                               event->name, enabled_string(event->enabled));
                break;
        case LTTNG_EVENT_PROBE:
-               MSG("%s%s (type: probe) [enabled: %d]", indent6,
-                               event->name, event->enabled);
+               MSG("%s%s (type: probe)%s", indent6,
+                               event->name, enabled_string(event->enabled));
                if (event->attr.probe.addr != 0) {
                        MSG("%saddr: 0x%" PRIx64, indent8, event->attr.probe.addr);
                } else {
@@ -131,17 +153,17 @@ static void print_events(struct lttng_event *event)
                break;
        case LTTNG_EVENT_FUNCTION:
        case LTTNG_EVENT_FUNCTION_ENTRY:
-               MSG("%s%s (type: function) [enabled: %d]", indent6,
-                               event->name, event->enabled);
+               MSG("%s%s (type: function)%s", indent6,
+                               event->name, enabled_string(event->enabled));
                MSG("%ssymbol: \"%s\"", indent8, event->attr.ftrace.symbol_name);
                break;
        case LTTNG_EVENT_SYSCALL:
-               MSG("%s (type: syscall) [enabled: %d]", indent6,
-                               event->enabled);
+               MSG("%s (type: syscall)%s", indent6,
+                               enabled_string(event->enabled));
                break;
        case LTTNG_EVENT_NOOP:
-               MSG("%s (type: noop) [enabled: %d]", indent6,
-                               event->enabled);
+               MSG("%s (type: noop)%s", indent6,
+                               enabled_string(event->enabled));
                break;
        case LTTNG_EVENT_ALL:
                /* We should never have "all" events in list. */
@@ -282,7 +304,7 @@ error:
  */
 static void print_channel(struct lttng_channel *channel)
 {
-       MSG("- %s (enabled: %d):\n", channel->name, channel->enabled);
+       MSG("- %s:%s\n", channel->name, enabled_string(channel->enabled));
 
        MSG("%sAttributes:", indent4);
        MSG("%soverwrite mode: %d", indent6, channel->attr.overwrite);
@@ -385,14 +407,14 @@ static int list_sessions(const char *session_name)
                if (session_name != NULL) {
                        if (strncmp(sessions[i].name, session_name, NAME_MAX) == 0) {
                                session_found = 1;
-                               MSG("Tracing session %s:", session_name);
+                               MSG("Tracing session %s:%s", session_name, active_string(sessions[i].enabled));
                                MSG("%sTrace path: %s\n", indent4, sessions[i].path);
                                break;
                        }
                        continue;
                }
 
-               MSG("  %d) %s (%s)", i + 1, sessions[i].name, sessions[i].path);
+               MSG("  %d) %s (%s)%s", i + 1, sessions[i].name, sessions[i].path, active_string(sessions[i].enabled));
 
                if (session_found) {
                        break;
This page took 0.051086 seconds and 4 git commands to generate.