Add ust create trace feature
authorDavid Goulet <david.goulet@polymtl.ca>
Wed, 27 Apr 2011 17:25:48 +0000 (13:25 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Wed, 27 Apr 2011 17:27:45 +0000 (13:27 -0400)
Can now create a trace with name set to 'auto' using
the PID of the application.

Also, this patch adds a missing param to the long_options, add
some information for help and sort the option's array.

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

index a3bdff80708284fbf2ba2c68a5ee44860ed4c095..3025571e1705ced922c621b7c115977f320b5e18 100644 (file)
@@ -52,5 +52,6 @@ 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);
+extern int lttng_ust_create_trace(pid_t pid);
 
 #endif /* _LIBLTTNGCTL_H */
index 7c5af7fe784e3169ed841e66413e6048e149f953..a586b34f53a61d2ba6dd630204325d1f71a31835 100644 (file)
@@ -167,6 +167,21 @@ const char *lttng_get_readable_code(int code)
        return lttcomm_get_readable_code(code);
 }
 
+/*
+ *  lttng_ust_create_trace
+ *
+ *  Request a trace creation for pid.
+ */
+int lttng_ust_create_trace(pid_t pid)
+{
+       int ret;
+
+       lsm.pid = pid;
+       ret = ask_sessiond(UST_CREATE_TRACE, NULL);
+
+       return ret;
+}
+
 /*
  *  lttng_ust_list_apps
  *
index 8413f6b08eb6c0aa863e5bf2028eae0281419421..bc74cc9e837ac867fab89c38836929f6096f236d 100644 (file)
@@ -41,6 +41,7 @@ static const char *lttcomm_readable_code[] = {
        [ LTTCOMM_ERR_INDEX(LTTCOMM_NO_APPS) ] = "No traceable apps found",
        [ LTTCOMM_ERR_INDEX(LTTCOMM_NO_SESS) ] = "No session found",
        [ LTTCOMM_ERR_INDEX(LTTCOMM_FATAL) ] = "Fatal error of the session daemon",
+       [ LTTCOMM_ERR_INDEX(LTTCOMM_CREATE_FAIL) ] = "Create trace failed",
 };
 
 /*
index eee4cc84fb1729cc02afc36a3f04d23251bc7d3d..6df78d8e3c40cb88d11301d66be4878aabd77fcf 100644 (file)
@@ -587,6 +587,20 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm)
                        /* No auxiliary data so only send the llm struct. */
                        goto end;
                }
+               case UST_CREATE_TRACE:
+               {
+                       int sock;
+                       sock = connect_app(lsm->pid);
+
+                       ret = ustctl_create_trace(sock, "auto");
+                       if (ret < 0) {
+                               ret = LTTCOMM_CREATE_FAIL;
+                       } else {
+                               ret = LTTCOMM_OK;
+                       }
+
+                       goto end;
+               }
                case UST_LIST_APPS:
                {
                        /* Stop right now if no apps */
index 40cf52bc6a3b02059a1ea8635c412737f8a5f71f..3878fb8367614654d1e837951c121024803e8366 100644 (file)
@@ -97,6 +97,15 @@ static int process_client_opt(void)
                lttng_set_current_session_uuid(opt_session_uuid);
        }
 
+       if (opt_create_trace) {
+               DBG("Create trace for pid %d", opt_create_trace);
+               ret = lttng_ust_create_trace(opt_create_trace);
+               if (ret < 0) {
+                       goto end;
+               }
+               MSG("Trace created successfully!\nUse --start PID to start tracing");
+       }
+
        return 0;
 
 end:
index 804ccf69454894b945eedd8478d380540a6a4dc1..a2dd7d73f639c8820939cff17fc8ebe5755e9ce4 100644 (file)
@@ -34,6 +34,7 @@ extern char *opt_destroy_session;
 extern int opt_list_apps;
 extern int opt_no_sessiond;
 extern int opt_list_session;
+extern pid_t opt_create_trace;
 
 #define SESSIOND_PATH_NUM 6
 
index 59d59046dad25d43d680b638fa70dbd418203cb8..61a3802e5548872e72c82d614df76a7b9e6f66cd 100644 (file)
@@ -33,6 +33,7 @@ int opt_verbose = 0;
 int opt_list_apps = 0;
 int opt_no_sessiond = 0;
 int opt_list_session = 0;
+pid_t opt_create_trace = 0;
 
 enum {
        OPT_HELP = 42,
@@ -40,21 +41,22 @@ enum {
 
 static struct poptOption long_options[] = {
        /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
-       {"help",                        'h',    POPT_ARG_NONE,          0, OPT_HELP, 0, 0},
+       {"create-session",  'c',        POPT_ARG_STRING,        &opt_create_session, 0, 0, 0},
+       {"create-trace",        'C',    POPT_ARG_INT,           &opt_create_trace, 0, 0, 0},
+       {"destroy-session", 'd',        POPT_ARG_STRING,        &opt_destroy_session, 0, 0, 0},
        {"group",                       0,              POPT_ARG_STRING,        &opt_tracing_group, 0, 0},
+       {"help",                        'h',    POPT_ARG_NONE,          0, OPT_HELP, 0, 0},
        {"kernel",                      0,              POPT_ARG_VAL,           &opt_trace_kernel, 1, 0, 0},
+       {"list-apps",           'L',    POPT_ARG_VAL,           &opt_list_apps, 1, 0, 0},
+       {"list-sessions",       'l',    POPT_ARG_VAL,           &opt_list_session, 1, 0, 0},
        {"no-kernel",           0,              POPT_ARG_VAL,           &opt_trace_kernel, 0, 0, 0},
+       {"no-sessiond",         0,              POPT_ARG_VAL,           &opt_no_sessiond, 1, 0, 0},
+       {"quiet",                       'q',    POPT_ARG_VAL,           &opt_quiet, 1, 0, 0},
+       {"session",                     's',    POPT_ARG_STRING,        &opt_session_uuid, 0, 0, 0},
+       {"sessiond-path",       0,              POPT_ARG_STRING,        &opt_sessiond_path, 0, 0, 0},
+       {"verbose",                     'v',    POPT_ARG_VAL,           &opt_verbose, 1, 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},
-       {"list-apps",           'L',    POPT_ARG_VAL,           &opt_list_apps, 1, 0},
-       {"no-sessiond",         0,              POPT_ARG_VAL,           &opt_no_sessiond, 1, 0},
-       {"sessiond-path",       0,              POPT_ARG_STRING,        &opt_sessiond_path, 0, 0},
-       {"list-sessions",       'l',    POPT_ARG_VAL,           &opt_list_session, 1, 0},
-       {"destroy-session", 'd',        POPT_ARG_STRING,        &opt_destroy_session, 0, 0},
-       {0, 0, 0, 0, 0, 0}
+       {0, 0, 0, 0, 0, 0, 0}
 };
 
 
@@ -71,19 +73,23 @@ static void usage(FILE *ofp)
        fprintf(ofp, "  -q, --quiet                  Quiet mode\n");
        fprintf(ofp, "      --help                   Show help\n");
        fprintf(ofp, "      --group NAME             Unix tracing group name. (default: tracing)\n");
-       fprintf(ofp, "      --no-sessiond            Don't spawn a session daemon.\n");
+       fprintf(ofp, "      --no-sessiond            Don't spawn a session daemon\n");
        fprintf(ofp, "      --sessiond-path          Session daemon full path\n");
        fprintf(ofp, "\n");
        fprintf(ofp, "Session options:\n");
        fprintf(ofp, "  -c, --create-session NAME    Create a new session\n");
        fprintf(ofp, "  -l, --list-sessions          List all available sessions\n");
-       fprintf(ofp, "  -s, --session UUID           Specify tracing session using UUID.\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");
        //fprintf(ofp, "      --kernel               Enable kernel tracing\n");
        //fprintf(ofp, "      --no-kernel            Disable kernel tracing\n");
        fprintf(ofp, "  -L, --list-apps              List traceable UST applications\n");
+       fprintf(ofp, "  -C, --create-trace PID       Create trace for PID\n");
+       fprintf(ofp, "\n");
+       fprintf(ofp, "Please see the lttng(1) man page for full documentation.\n");
+       fprintf(ofp, "See http://lttng.org/ust for updates, bug reports and news.\n");
 }
 
 /*
This page took 0.039867 seconds and 4 git commands to generate.