Add -j/--jul to lttng UI and ABI
authorDavid Goulet <dgoulet@efficios.com>
Mon, 30 Sep 2013 16:23:16 +0000 (12:23 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 16 Oct 2013 14:13:31 +0000 (10:13 -0400)
The JUL domain is set as unsupported in the session daemon so only the
client side is implemented with help updated.

Again, on the session daemon side, this is set as unsupported.

Signed-off-by: David Goulet <dgoulet@efficios.com>
13 files changed:
include/lttng/lttng-error.h
include/lttng/lttng.h
src/bin/lttng-sessiond/main.c
src/bin/lttng/commands/add_context.c
src/bin/lttng/commands/calibrate.c
src/bin/lttng/commands/disable_channels.c
src/bin/lttng/commands/disable_events.c
src/bin/lttng/commands/enable_channels.c
src/bin/lttng/commands/enable_events.c
src/bin/lttng/utils.c
src/bin/lttng/utils.h
src/common/error.c
src/lib/lttng-ctl/lttng-ctl.c

index b43c88fbe3de578462f83f1860a3f385d89528f0..7631dbcc2aaf95204f878272c784daccc3a80627 100644 (file)
@@ -92,7 +92,7 @@ enum lttng_error_code {
        LTTNG_ERR_UST_CHAN_NOT_FOUND     = 59,  /* UST channel not found */
        LTTNG_ERR_UST_CHAN_DISABLE_FAIL  = 60,  /* UST disable channel failed */
        LTTNG_ERR_UST_CHAN_ENABLE_FAIL   = 61,  /* UST enable channel failed */
-       /* 62 */
+       LTTNG_ERR_CHAN_EXIST             = 62,  /* Channel already exists. */
        LTTNG_ERR_UST_ENABLE_FAIL        = 63,  /* UST enable event failed */
        LTTNG_ERR_UST_DISABLE_FAIL       = 64,  /* UST disable event failed */
        LTTNG_ERR_UST_META_FAIL          = 65,  /* UST open metadata failed */
index 8f55a889ee408a98bdec10feacd4b059c6e81d0a..0307536d387e600c8d8127b923883af3a56d5385 100644 (file)
@@ -47,18 +47,9 @@ extern "C" {
  * Domain types: the different possible tracers.
  */
 enum lttng_domain_type {
-       LTTNG_DOMAIN_KERNEL                   = 1,
-       LTTNG_DOMAIN_UST                      = 2,
-
-       /*
-        * For now, the domains below are not implemented. However, we keep them
-        * here in order to retain their enum values for future development. Note
-        * that it is on the roadmap to implement them.
-        *
-       LTTNG_DOMAIN_UST_EXEC_NAME            = 3,
-       LTTNG_DOMAIN_UST_PID                  = 4,
-       LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN  = 5,
-       */
+       LTTNG_DOMAIN_KERNEL                   = 1,      /* Linux Kernel tracer. */
+       LTTNG_DOMAIN_UST                      = 2,      /* Global Userspace tracer. */
+       LTTNG_DOMAIN_JUL                      = 3,      /* Java Util Logging. */
 };
 
 /*
index eccc33a7bf5d00abf8b3a95a8cb67b36834200e4..028f5f9d233a0933ddd9199e9171bf620065fbba 100644 (file)
@@ -2744,6 +2744,11 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock,
                }
 
                break;
+       case LTTNG_DOMAIN_JUL:
+       {
+               ret = LTTNG_ERR_UNKNOWN_DOMAIN;
+               goto error;
+       }
        case LTTNG_DOMAIN_UST:
        {
                if (!ust_app_supported()) {
@@ -2835,6 +2840,7 @@ skip_domain:
        if (cmd_ctx->lsm->cmd_type == LTTNG_START_TRACE ||
                        cmd_ctx->lsm->cmd_type == LTTNG_STOP_TRACE) {
                switch (cmd_ctx->lsm->domain.type) {
+               case LTTNG_DOMAIN_JUL:
                case LTTNG_DOMAIN_UST:
                        if (uatomic_read(&ust_consumerd_state) != CONSUMER_STARTED) {
                                ret = LTTNG_ERR_NO_USTCONSUMERD;
index 6286ed8a0a1838e49c4592e5770e02c4ab7f16df..3cd00f3d3411ac2e9b0801c3c8d421cc5feb8744 100644 (file)
@@ -368,7 +368,7 @@ static int add_context(char *session_name)
        } else if (opt_userspace) {
                dom.type = LTTNG_DOMAIN_UST;
        } else {
-               ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
+               print_missing_domain();
                ret = CMD_ERROR;
                goto error;
        }
index 7014fdd58f069da617ccab739dcb76a6c79d08d3..092632cd78ffdea24da1261777d816d264e99c67 100644 (file)
@@ -128,7 +128,7 @@ static int calibrate_lttng(void)
        } else if (opt_userspace) {
                dom.type = LTTNG_DOMAIN_UST;
        } else {
-               ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
+               print_missing_domain();
                ret = CMD_ERROR;
                goto error;
        }
index 50b132eeba7607b8915d1a872be32a51f81c29e9..1aa3916aecb116a0122b50b2128b8111acc093ae 100644 (file)
@@ -93,7 +93,7 @@ static int disable_channels(char *session_name)
        } else if (opt_userspace) {
                dom.type = LTTNG_DOMAIN_UST;
        } else {
-               ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
+               print_missing_domain();
                ret = CMD_ERROR;
                goto error;
        }
@@ -116,7 +116,7 @@ static int disable_channels(char *session_name)
                        warn = 1;
                } else {
                        MSG("%s channel %s disabled for session %s",
-                                       opt_kernel ? "Kernel" : "UST", channel_name, session_name);
+                                       get_domain_str(dom.type), channel_name, session_name);
                }
 
                /* Next channel */
index f9dc3396bf1377ae7caadd10bf780cb3e612a6fc..e71234342deb7f66bc751e5d33d73ebe26460354 100644 (file)
@@ -32,6 +32,7 @@ static char *opt_channel_name;
 static char *opt_session_name;
 static int opt_userspace;
 static int opt_disable_all;
+static int opt_jul;
 #if 0
 /* Not implemented yet */
 static char *opt_cmd_name;
@@ -52,6 +53,7 @@ static struct poptOption long_options[] = {
        {"session",        's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
        {"all-events",     'a', POPT_ARG_VAL, &opt_disable_all, 1, 0, 0},
        {"channel",        'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0},
+       {"jul",            'j', POPT_ARG_VAL, &opt_jul, 1, 0, 0},
        {"kernel",         'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
 #if 0
        /* Not implemented yet */
@@ -79,6 +81,7 @@ static void usage(FILE *ofp)
        fprintf(ofp, "  -a, --all-events         Disable all tracepoints\n");
        fprintf(ofp, "  -k, --kernel             Apply for the kernel tracer\n");
        fprintf(ofp, "  -u, --userspace          Apply to the user-space tracer\n");
+       fprintf(ofp, "  -j, --jul                Apply for Java application using JUL\n");
        fprintf(ofp, "\n");
 }
 
@@ -112,8 +115,10 @@ static int disable_events(char *session_name)
                dom.type = LTTNG_DOMAIN_KERNEL;
        } else if (opt_userspace) {
                dom.type = LTTNG_DOMAIN_UST;
+       } else if (opt_jul) {
+               dom.type = LTTNG_DOMAIN_JUL;
        } else {
-               ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
+               print_missing_domain();
                ret = CMD_ERROR;
                goto error;
        }
@@ -134,8 +139,7 @@ static int disable_events(char *session_name)
                }
 
                MSG("All %s events are disabled in channel %s",
-                               opt_kernel ? "kernel" : "UST",
-                               print_channel_name(channel_name));
+                               get_domain_str(dom.type), print_channel_name(channel_name));
                goto end;
        }
 
@@ -155,7 +159,7 @@ static int disable_events(char *session_name)
                        warn = 1;
                } else {
                        MSG("%s event %s disabled in channel %s for session %s",
-                                       opt_kernel ? "kernel" : "UST", event_name,
+                                       get_domain_str(dom.type), event_name,
                                        print_channel_name(channel_name),
                                        session_name);
                }
index 10c1d3d57400c98f6fd61d75f9aa69a2a936734f..18f8d020eef5089ef4309ec9608a3ebd5589fcd7 100644 (file)
@@ -130,8 +130,8 @@ static void usage(FILE *ofp)
                        DEFAULT_UST_PID_CHANNEL_OUTPUT == LTTNG_EVENT_MMAP ? output_mmap : output_splice,
                        DEFAULT_KERNEL_CHANNEL_OUTPUT == LTTNG_EVENT_MMAP ? output_mmap : output_splice,
                        DEFAULT_METADATA_OUTPUT == LTTNG_EVENT_MMAP ? output_mmap : output_splice);
-       fprintf(ofp, "      --buffers-uid        Use per UID buffer (-u only)\n");
-       fprintf(ofp, "      --buffers-pid        Use per PID buffer (-u only)\n");
+       fprintf(ofp, "      --buffers-uid        Use per UID buffer (-u/-j only)\n");
+       fprintf(ofp, "      --buffers-pid        Use per PID buffer (-u/-j only)\n");
        fprintf(ofp, "      --buffers-global     Use shared buffer for the whole system (-k only)\n");
        fprintf(ofp, "  -C, --tracefile-size SIZE\n");
        fprintf(ofp, "                           Maximum size of each tracefile within a stream (in bytes). 0 means unlimited.\n");
@@ -213,7 +213,7 @@ static int enable_channel(char *session_name)
                        dom.buf_type = LTTNG_BUFFER_PER_UID;
                }
        } else {
-               ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
+               print_missing_domain();
                ret = CMD_ERROR;
                goto error;
        }
@@ -269,6 +269,7 @@ static int enable_channel(char *session_name)
                        switch (-ret) {
                        case LTTNG_ERR_KERN_CHAN_EXIST:
                        case LTTNG_ERR_UST_CHAN_EXIST:
+                       case LTTNG_ERR_CHAN_EXIST:
                                WARN("Channel %s: %s (session %s)", channel_name,
                                                lttng_strerror(ret), session_name);
                                goto error;
@@ -280,8 +281,7 @@ static int enable_channel(char *session_name)
                        warn = 1;
                } else {
                        MSG("%s channel %s enabled for session %s",
-                                       opt_kernel ? "Kernel" : "UST", channel_name,
-                                       session_name);
+                                       get_domain_str(dom.type), channel_name, session_name);
                }
 
                /* Next event */
index 36ee84f39d6772b1f24d18994d6a939379a06c48..a7b70c3f9dada482aa76cdd3113ccfa61535d4e0 100644 (file)
@@ -36,6 +36,7 @@ static int opt_loglevel_type;
 static int opt_kernel;
 static char *opt_session_name;
 static int opt_userspace;
+static int opt_jul;
 static int opt_enable_all;
 static char *opt_probe;
 static char *opt_function;
@@ -72,6 +73,7 @@ static struct poptOption long_options[] = {
        {"channel",        'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0},
        {"kernel",         'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
        {"userspace",      'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0},
+       {"jul",            'j', POPT_ARG_VAL, &opt_jul, 1, 0, 0},
        {"tracepoint",     0,   POPT_ARG_NONE, 0, OPT_TRACEPOINT, 0, 0},
        {"probe",          0,   POPT_ARG_STRING, &opt_probe, OPT_PROBE, 0, 0},
        {"function",       0,   POPT_ARG_STRING, &opt_function, OPT_FUNCTION, 0, 0},
@@ -105,6 +107,7 @@ static void usage(FILE *ofp)
        fprintf(ofp, "  -a, --all                Enable all tracepoints and syscalls\n");
        fprintf(ofp, "  -k, --kernel             Apply for the kernel tracer\n");
        fprintf(ofp, "  -u, --userspace          Apply to the user-space tracer\n");
+       fprintf(ofp, "  -j, --jul                Apply for Java application using JUL\n");
        fprintf(ofp, "\n");
        fprintf(ofp, "Event options:\n");
        fprintf(ofp, "    --tracepoint           Tracepoint event (default)\n");
@@ -353,8 +356,12 @@ static int enable_events(char *session_name)
                dom.type = LTTNG_DOMAIN_UST;
                /* Default. */
                dom.buf_type = LTTNG_BUFFER_PER_UID;
+       } else if (opt_jul) {
+               dom.type = LTTNG_DOMAIN_JUL;
+               /* Default. */
+               dom.buf_type = LTTNG_BUFFER_PER_UID;
        } else {
-               ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
+               print_missing_domain();
                ret = CMD_ERROR;
                goto error;
        }
@@ -414,12 +421,12 @@ static int enable_events(char *session_name)
                        case LTTNG_EVENT_TRACEPOINT:
                                if (opt_loglevel) {
                                        MSG("All %s tracepoints are enabled in channel %s for loglevel %s",
-                                                       opt_kernel ? "kernel" : "UST",
+                                                       get_domain_str(dom.type),
                                                        print_channel_name(channel_name),
                                                        opt_loglevel);
                                } else {
                                        MSG("All %s tracepoints are enabled in channel %s",
-                                                       opt_kernel ? "kernel" : "UST",
+                                                       get_domain_str(dom.type),
                                                        print_channel_name(channel_name));
 
                                }
@@ -433,12 +440,12 @@ static int enable_events(char *session_name)
                        case LTTNG_EVENT_ALL:
                                if (opt_loglevel) {
                                        MSG("All %s events are enabled in channel %s for loglevel %s",
-                                                       opt_kernel ? "kernel" : "UST",
+                                                       get_domain_str(dom.type),
                                                        print_channel_name(channel_name),
                                                        opt_loglevel);
                                } else {
                                        MSG("All %s events are enabled in channel %s",
-                                                       opt_kernel ? "kernel" : "UST",
+                                                       get_domain_str(dom.type),
                                                        print_channel_name(channel_name));
                                }
                                break;
@@ -576,8 +583,18 @@ static int enable_events(char *session_name)
                        } else {
                                ev.loglevel = -1;
                        }
+               } else if (opt_jul) {
+                       if (opt_event_type != LTTNG_EVENT_ALL &&
+                                       opt_event_type != LTTNG_EVENT_TRACEPOINT) {
+                               ERR("Event type not supported for JUL domain.");
+                               ret = CMD_UNSUPPORTED;
+                               goto error;
+                       }
+                       ev.type = LTTNG_EVENT_TRACEPOINT;
+                       strncpy(ev.name, event_name, LTTNG_SYMBOL_NAME_LEN);
+                       ev.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
                } else {
-                       ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
+                       print_missing_domain();
                        ret = CMD_ERROR;
                        goto error;
                }
@@ -604,7 +621,7 @@ static int enable_events(char *session_name)
                                warn = 1;
                        } else {
                                MSG("%s event %s created in channel %s",
-                                               opt_kernel ? "kernel": "UST", event_name,
+                                               get_domain_str(dom.type), event_name,
                                                print_channel_name(channel_name));
                        }
                }
index e40c3fd708e3d4c3d18bfcc7a0e8be1b7ee89ea3..556728da23773f19935d0ea8b484a1b2cf901664 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #define _GNU_SOURCE
+#include <assert.h>
 #include <stdlib.h>
 #include <ctype.h>
 #include <limits.h>
 #include "utils.h"
 #include "command.h"
 
+static const char *str_kernel = "Kernel";
+static const char *str_ust = "UST";
+static const char *str_jul = "JUL";
+
 /*
  *  get_session_name
  *
@@ -249,3 +254,25 @@ int get_count_order_ulong(unsigned long x)
 
        return fls_ulong(x - 1);
 }
+
+const char *get_domain_str(enum lttng_domain_type domain)
+{
+       const char *str_dom;
+
+       switch (domain) {
+       case LTTNG_DOMAIN_KERNEL:
+               str_dom = str_kernel;
+               break;
+       case LTTNG_DOMAIN_UST:
+               str_dom = str_ust;
+               break;
+       case LTTNG_DOMAIN_JUL:
+               str_dom = str_jul;
+               break;
+       default:
+               /* Should not have an unknown domain or else define it. */
+               assert(0);
+       }
+
+       return str_dom;
+}
index fb973caa5f44238bb78da41007ae2839157f776f..9dacbb20f09513be2b604fd0eb1e00c5a161fd0c 100644 (file)
@@ -20,6 +20,8 @@
 
 #include <popt.h>
 
+#include <lttng/lttng.h>
+
 struct cmd_struct;
 
 char *get_session_name(void);
@@ -44,4 +46,12 @@ int get_count_order_u64(uint64_t x);
  */
 int get_count_order_ulong(unsigned long x);
 
+const char *get_domain_str(enum lttng_domain_type domain);
+
+static inline
+void print_missing_domain(void)
+{
+       ERR("Please specify a domain (-k/-u/-j).");
+}
+
 #endif /* _LTTNG_UTILS_H */
index 911baea3ed4b42f0671dc1e53d9c32dd78287b22..2733d0d11881cabaada536ac1d4a0d9401754f54 100644 (file)
@@ -113,6 +113,7 @@ static const char *error_string_array[] = {
        [ ERROR_INDEX(LTTNG_ERR_SNAPSHOT_OUTPUT_EXIST) ] = "Snapshot output already exists",
        [ ERROR_INDEX(LTTNG_ERR_START_SESSION_ONCE) ] = "Session needs to be started once",
        [ ERROR_INDEX(LTTNG_ERR_SNAPSHOT_FAIL) ] = "Snapshot record failed",
+       [ ERROR_INDEX(LTTNG_ERR_CHAN_EXIST) ] = "Channel already exists",
 
        /* Last element */
        [ ERROR_INDEX(LTTNG_ERR_NR) ] = "Unknown error code"
index 540e24590cab7e45a897d4944c41889d6c6198da..83a46a45d1edfd12699597005007de9c4b6c47ff 100644 (file)
@@ -103,6 +103,7 @@ void lttng_ctl_copy_lttng_domain(struct lttng_domain *dst,
                switch (src->type) {
                case LTTNG_DOMAIN_KERNEL:
                case LTTNG_DOMAIN_UST:
+               case LTTNG_DOMAIN_JUL:
                        memcpy(dst, src, sizeof(struct lttng_domain));
                        break;
                default:
This page took 0.037166 seconds and 4 git commands to generate.