Revert "Revert "Update loglevel ABI""
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 1 Feb 2012 19:01:28 +0000 (14:01 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 1 Feb 2012 19:01:28 +0000 (14:01 -0500)
This reverts commit 69892bbba677a6695b216046d586e58bfa0f82c9.

Revert of revert, need to go forward for ABI change.

Will fix problems in a following commit.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/lttng.h
src/bin/lttng-sessiond/lttng-ust-abi.h
src/bin/lttng-sessiond/main.c
src/bin/lttng-sessiond/trace-ust.c
src/bin/lttng-sessiond/ust-app.c
src/bin/lttng/commands/enable_events.c
src/bin/lttng/commands/list.c

index a791338c89d5948eea001d7624d585e02dd70bfb..433d2d804829749b2909b2485213b1c06607377f 100644 (file)
@@ -65,7 +65,14 @@ enum lttng_event_type {
        LTTNG_EVENT_FUNCTION_ENTRY            = 3,
        LTTNG_EVENT_NOOP                      = 4,
        LTTNG_EVENT_SYSCALL                   = 5,
-       LTTNG_EVENT_TRACEPOINT_LOGLEVEL       = 6,
+};
+
+/*
+ * Loglevel information.
+ */
+enum lttng_loglevel_type {
+       LTTNG_EVENT_LOGLEVEL                  = 0,
+       LTTNG_EVENT_LOGLEVEL_ONLY             = 1,
 };
 
 /*
@@ -141,10 +148,13 @@ struct lttng_event_function_attr {
  * Generic lttng event
  */
 struct lttng_event {
+       enum lttng_event_type type;
        char name[LTTNG_SYMBOL_NAME_LEN];
+
+       enum lttng_loglevel_type loglevel_type;
        char loglevel[LTTNG_SYMBOL_NAME_LEN];
-       int64_t loglevel_value;
-       enum lttng_event_type type;
+       int64_t loglevel_value;         /* for printing */
+
        uint32_t enabled;
        pid_t pid;
        /* Per event type configuration */
index f30dbde3f92e76f76ba6480a6f644ccd504e6c5e..28962aaf747dd3a7107033b2dc2a99f49d423343 100644 (file)
@@ -22,7 +22,11 @@ enum lttng_ust_instrumentation {
        LTTNG_UST_TRACEPOINT            = 0,
        LTTNG_UST_PROBE                 = 1,
        LTTNG_UST_FUNCTION              = 2,
-       LTTNG_UST_TRACEPOINT_LOGLEVEL   = 3,
+};
+
+enum lttng_ust_loglevel_type {
+       LTTNG_UST_LOGLEVEL              = 0,
+       LTTNG_UST_LOGLEVEL_ONLY         = 1,
 };
 
 enum lttng_ust_output {
@@ -45,8 +49,12 @@ struct lttng_ust_channel {
 };
 
 struct lttng_ust_event {
-       char name[LTTNG_UST_SYM_NAME_LEN];      /* event name */
        enum lttng_ust_instrumentation instrumentation;
+       char name[LTTNG_UST_SYM_NAME_LEN];      /* event name */
+
+       enum lttng_ust_loglevel_type loglevel_type;
+       char loglevel[LTTNG_UST_SYM_NAME_LEN];  /* loglevel name */
+
        /* Per instrumentation type configuration */
        union {
        } u;
index 8304de8be394ca034f0726f622fdebe865c7c5df..8e4afb00ba0827295d86f53ed728763eb5ebe463 100644 (file)
@@ -2031,8 +2031,15 @@ static int list_lttng_ust_global_events(char *channel_name,
                case LTTNG_UST_FUNCTION:
                        tmp[i].type = LTTNG_EVENT_FUNCTION;
                        break;
-               case LTTNG_UST_TRACEPOINT_LOGLEVEL:
-                       tmp[i].type = LTTNG_EVENT_TRACEPOINT_LOGLEVEL;
+               }
+               strncpy(tmp[i].loglevel, uevent->attr.loglevel, LTTNG_SYMBOL_NAME_LEN);
+               tmp[i].loglevel[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
+               switch (uevent->attr.loglevel_type) {
+               case LTTNG_UST_LOGLEVEL:
+                       tmp[i].type = LTTNG_EVENT_LOGLEVEL;
+                       break;
+               case LTTNG_UST_LOGLEVEL_ONLY:
+                       tmp[i].type = LTTNG_EVENT_LOGLEVEL_ONLY;
                        break;
                }
                i++;
index 0858f47d53b29ea598f94471b4271d029ba1a2bd..0a90cac0ec13aa1d71049d9053217ab0fde0fffe 100644 (file)
@@ -213,9 +213,6 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev)
        case LTTNG_EVENT_TRACEPOINT:
                lue->attr.instrumentation = LTTNG_UST_TRACEPOINT;
                break;
-       case LTTNG_EVENT_TRACEPOINT_LOGLEVEL:
-               lue->attr.instrumentation = LTTNG_UST_TRACEPOINT_LOGLEVEL;
-               break;
        default:
                ERR("Unknown ust instrumentation type (%d)", ev->type);
                goto error_free_event;
@@ -225,6 +222,22 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev)
        strncpy(lue->attr.name, ev->name, LTTNG_UST_SYM_NAME_LEN);
        lue->attr.name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
 
+       switch (ev->loglevel_type) {
+       case LTTNG_EVENT_LOGLEVEL:
+               lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL;
+               break;
+       case LTTNG_EVENT_LOGLEVEL_ONLY:
+               lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL_ONLY;
+               break;
+       default:
+               ERR("Unknown ust loglevel type (%d)", ev->type);
+               goto error_free_event;
+       }
+
+       /* Copy loglevel name */
+       strncpy(lue->attr.loglevel, ev->loglevel, LTTNG_UST_SYM_NAME_LEN);
+       lue->attr.loglevel[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
+
        /* Init node */
        lttng_ht_node_init_str(&lue->node, lue->attr.name);
        /* Alloc context hash tables */
index 39dd9ba36e004e448915239063a1ddcf34253671..8e329a29f08adb661b2c053b3c361b616aa64027 100644 (file)
@@ -1421,8 +1421,8 @@ int ust_app_list_events(struct lttng_event **events)
                        }
                        memcpy(tmp[count].name, uiter.name, LTTNG_UST_SYM_NAME_LEN);
                        memcpy(tmp[count].loglevel, uiter.loglevel, LTTNG_UST_SYM_NAME_LEN);
-                       tmp[count].loglevel_value = uiter.loglevel_value;
                        tmp[count].type = LTTNG_UST_TRACEPOINT;
+                       tmp[count].loglevel_value = uiter.loglevel_value;
                        tmp[count].pid = app->key.pid;
                        tmp[count].enabled = -1;
                        count++;
index 3f30ab8ba5156449ee3dba7084f957bbf7027664..0fa3e916c835b48e2d9228ac8c86ee1e0e4a5dcf 100644 (file)
@@ -31,6 +31,8 @@
 
 static char *opt_event_list;
 static int opt_event_type;
+static const char *opt_loglevel;
+static int opt_loglevel_type;
 static int opt_kernel;
 static char *opt_session_name;
 static int opt_userspace;
@@ -53,7 +55,8 @@ enum {
        OPT_FUNCTION_ENTRY,
        OPT_SYSCALL,
        OPT_USERSPACE,
-       OPT_TRACEPOINT_LOGLEVEL,
+       OPT_LOGLEVEL,
+       OPT_LOGLEVEL_ONLY,
        OPT_LIST_OPTIONS,
 };
 
@@ -84,7 +87,8 @@ static struct poptOption long_options[] = {
        {"function:entry", 0,   POPT_ARG_STRING, &opt_function_entry_symbol, OPT_FUNCTION_ENTRY, 0, 0},
 #endif
        {"syscall",        0,   POPT_ARG_NONE, 0, OPT_SYSCALL, 0, 0},
-       {"loglevel",     0,     POPT_ARG_NONE, 0, OPT_TRACEPOINT_LOGLEVEL, 0, 0},
+       {"loglevel",       0,     POPT_ARG_STRING, 0, OPT_LOGLEVEL, 0, 0},
+       {"loglevel-only",  0,     POPT_ARG_STRING, 0, OPT_LOGLEVEL_ONLY, 0, 0},
        {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
        {0, 0, 0, 0, 0, 0, 0}
 };
@@ -118,7 +122,10 @@ static void usage(FILE *ofp)
        fprintf(ofp, "                             e.g.:\n");
        fprintf(ofp, "                               \"*\"\n");
        fprintf(ofp, "                               \"app_component:na*\"\n");
-       fprintf(ofp, "    --loglevel             Tracepoint loglevel\n");
+       fprintf(ofp, "    --loglevel name\n");
+       fprintf(ofp, "                           Tracepoint loglevel (range: 0 to loglevel)\n");
+       fprintf(ofp, "    --loglevel-only name\n");
+       fprintf(ofp, "                           Tracepoint loglevel (only this loglevel)\n");
        fprintf(ofp, "    --probe [addr | symbol | symbol+offset]\n");
        fprintf(ofp, "                           Dynamic probe.\n");
        fprintf(ofp, "                           Addr and offset can be octal (0NNN...),\n");
@@ -333,6 +340,16 @@ static int enable_events(char *session_name)
                                ret = CMD_UNDEFINED;
                                goto error;
                        }
+
+                       if (opt_loglevel[0] != '\0') {
+                               MSG("Kernel loglevels are not supported.");
+                               ret = CMD_UNDEFINED;
+                               goto error;
+                       }
+
+                       /* kernel loglevels not implemented */
+                       ev.loglevel_type = opt_loglevel_type;
+                       ev.loglevel[0] = '\0';
                } else if (opt_userspace) {             /* User-space tracer action */
 #if 0
                        if (opt_cmd_name != NULL || opt_pid) {
@@ -354,12 +371,6 @@ static int enable_events(char *session_name)
                                strncpy(ev.name, event_name, LTTNG_SYMBOL_NAME_LEN);
                                ev.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
                                break;
-                       case LTTNG_EVENT_TRACEPOINT_LOGLEVEL:
-                               /* Copy name and type of the event */
-                               ev.type = LTTNG_EVENT_TRACEPOINT_LOGLEVEL;
-                               strncpy(ev.name, event_name, LTTNG_SYMBOL_NAME_LEN);
-                               ev.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
-                               break;
                        case LTTNG_EVENT_PROBE:
                        case LTTNG_EVENT_FUNCTION:
                        case LTTNG_EVENT_FUNCTION_ENTRY:
@@ -368,6 +379,10 @@ static int enable_events(char *session_name)
                                ret = CMD_UNDEFINED;
                                goto error;
                        }
+
+                       ev.loglevel_type = opt_loglevel_type;
+                       strncpy(ev.loglevel, opt_loglevel, LTTNG_SYMBOL_NAME_LEN);
+                       ev.loglevel[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
                } else {
                        ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
                        goto error;
@@ -432,8 +447,13 @@ int cmd_enable_events(int argc, const char **argv)
                case OPT_USERSPACE:
                        opt_userspace = 1;
                        break;
-               case OPT_TRACEPOINT_LOGLEVEL:
-                       opt_event_type = LTTNG_EVENT_TRACEPOINT_LOGLEVEL;
+               case OPT_LOGLEVEL:
+                       opt_loglevel_type = LTTNG_EVENT_LOGLEVEL;
+                       opt_loglevel = poptGetOptArg(pc);
+                       break;
+               case OPT_LOGLEVEL_ONLY:
+                       opt_loglevel_type = LTTNG_EVENT_LOGLEVEL_ONLY;
+                       opt_loglevel = poptGetOptArg(pc);
                        break;
                case OPT_LIST_OPTIONS:
                        list_cmd_options(stdout, long_options);
index 701ce83c05ba5e2e8715b1eb6aa5ecf8735719e4..4b8a07c48fc6aa29dc316711f8cf0774c6fbe334 100644 (file)
@@ -179,8 +179,9 @@ static void print_events(struct lttng_event *event)
 
                        ret = snprintf(ll_value, LTTNG_SYMBOL_NAME_LEN,
                                " (%lld)", (long long) event->loglevel_value);
-                       if (ret < 0)
+                       if (ret < 0) {
                                ERR("snprintf error");
+                       }
                }
                MSG("%s%s%s%s%s%s (type: tracepoint)%s", indent6,
                                event->name,
@@ -215,11 +216,6 @@ static void print_events(struct lttng_event *event)
                MSG("%s (type: noop)%s", indent6,
                                enabled_string(event->enabled));
                break;
-       case LTTNG_EVENT_TRACEPOINT_LOGLEVEL:
-               MSG("%s%s (type: tracepoint loglevel)%s", indent6,
-                       event->name,
-                       enabled_string(event->enabled));
-               break;
        case LTTNG_EVENT_ALL:
                /* We should never have "all" events in list. */
                assert(0);
This page took 0.044086 seconds and 4 git commands to generate.