Add --session feature
authorDavid Goulet <david.goulet@polymtl.ca>
Wed, 27 Apr 2011 15:18:25 +0000 (11:18 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Wed, 27 Apr 2011 15:19:16 +0000 (11:19 -0400)
This allows any user to select a session and any
tracing command will affect that particular session.

Signed-off-by: David Goulet <david.goulet@polymtl.ca>
include/lttng/liblttngctl.h
liblttngctl/liblttngctl.c
lttng/lttng.c
lttng/lttng.h
lttng/options.c

index b729f2b5b0c29f520fb5f4f7e3aa6ba047f45d1f..df97313429143d2eb6902f2cd1a80747babe61d7 100644 (file)
@@ -50,5 +50,6 @@ extern int lttng_check_session_daemon(void);
 extern const char *lttng_get_readable_code(int code);
 extern int lttng_ust_list_apps(pid_t **pids);
 extern int lttng_list_sessions(struct lttng_session **sessions);
+extern void lttng_set_current_session_uuid(char *uuid);
 
 #endif /* _LIBLTTNGCTL_H */
index 9afd6fda3239e0085c24ec433383ac2755019bd8..a15a26dff82f2e348cff63455829402ef780aa6d 100644 (file)
@@ -197,7 +197,6 @@ int lttng_ust_list_apps(pid_t **pids)
 int lttng_create_session(char *name, uuid_t *session_id)
 {
        int ret;
-       char *uuid;
 
        strncpy(lsm.session_name, name, sizeof(lsm.session_name));
        lsm.session_name[sizeof(lsm.session_name) - 1] = '\0';
@@ -281,6 +280,16 @@ int lttng_connect_sessiond(void)
        return 0;
 }
 
+/*
+ *  lttng_set_current_session_uuid
+ *
+ *  Set the session uuid for current lsm.
+ */
+void lttng_set_current_session_uuid(char *uuid)
+{
+       uuid_parse(uuid, lsm.session_id);
+}
+
 /*
  *  lttng_set_tracing_group
  *
index 169e70eb0ddeedf5d29ffbe57ffb4f8581b3990f..9ef92a7d418418bf005361084421920c409989e3 100644 (file)
@@ -93,6 +93,10 @@ static int process_client_opt(void)
                }
        }
 
+       if (opt_session_uuid != NULL) {
+               lttng_set_current_session_uuid(opt_session_uuid);
+       }
+
        return 0;
 
 end:
index f9e75538c96d9213ac2220a76f0a149e4f35c601..804ccf69454894b945eedd8478d380540a6a4dc1 100644 (file)
@@ -27,7 +27,7 @@ extern int opt_trace_kernel;
 extern int opt_verbose;
 extern int opt_quiet;
 extern char *opt_tracing_group;
-extern char *opt_session_name;
+extern char *opt_session_uuid;
 extern char *opt_create_session;
 extern char *opt_sessiond_path;
 extern char *opt_destroy_session;
index befeab54af83d8f34b07bb7673b0b19597ae9e7a..11b82fba7da5ed1665724aa64197ec705a5faa33 100644 (file)
@@ -23,7 +23,7 @@
 
 /* Option variables */
 char *opt_tracing_group;
-char *opt_session_name;
+char *opt_session_uuid;
 char *opt_create_session;
 char *opt_sessiond_path;
 char *opt_destroy_session;
@@ -44,7 +44,8 @@ static struct poptOption long_options[] = {
        {"group",                       0,              POPT_ARG_STRING,        &opt_tracing_group, 0, 0},
        {"kernel",                      0,              POPT_ARG_VAL,           &opt_trace_kernel, 1, 0, 0},
        {"no-kernel",           0,              POPT_ARG_VAL,           &opt_trace_kernel, 0, 0, 0},
-       {"session",                     0,              POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_session_name, 0, 0},
+       //{"session",                   0,              POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_session_name, 0, 0},
+       {"session",                     's',    POPT_ARG_STRING,        &opt_session_uuid, 0, 0},
        {"create-session",  'c',        POPT_ARG_STRING,        &opt_create_session, 0, 0},
        {"quiet",                       'q',    POPT_ARG_VAL,           &opt_quiet, 1, 0},
        {"verbose",                     'v',    POPT_ARG_VAL,           &opt_verbose, 1, 0},
@@ -76,8 +77,7 @@ static void usage(FILE *ofp)
        fprintf(ofp, "Session options:\n");
        fprintf(ofp, "  -c, --create-session NAME    Create a new session\n");
        fprintf(ofp, "      --list-session           List all available sessions\n");
-       fprintf(ofp, "      --session [NAME]         Specify tracing session. If no NAME is given\n");
-       fprintf(ofp, "                               or option is ommited, a session will be created\n");
+       fprintf(ofp, "  -s, --session UUID           Specify tracing session using UUID.\n");
        fprintf(ofp, "  -d, --destroy-session=NAME   Destroy the session specified by NAME\n");
        fprintf(ofp, "\n");
        fprintf(ofp, "Tracing options:\n");
@@ -97,6 +97,11 @@ int parse_args(int argc, const char **argv)
        static poptContext pc;
        int opt;
 
+       /* If no options, fail */
+       if (argc < 2) {
+               return -1;
+       }
+
        pc = poptGetContext("lttng", argc, argv, long_options, 0);
        poptReadDefaultConfig(pc, 0);
 
This page took 0.029622 seconds and 5 git commands to generate.