ABI update: only send loglevel value to UST: fixed loglevels
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 2 Feb 2012 00:24:47 +0000 (19:24 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 2 Feb 2012 00:25:45 +0000 (19:25 -0500)
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
src/bin/lttng/lttng.c
tests/lttng/ust_global_all_events_basic.c
tests/lttng/ust_global_event_basic.c

index c83f9832588e8bfea1a1d73c56ca2b79dfc80690..f4c7cb97aee4cd4235d690edd41772064439b8d8 100644 (file)
@@ -71,8 +71,9 @@ enum lttng_event_type {
  * Loglevel information.
  */
 enum lttng_loglevel_type {
-       LTTNG_EVENT_LOGLEVEL                  = 0,
-       LTTNG_EVENT_LOGLEVEL_ONLY             = 1,
+       LTTNG_EVENT_LOGLEVEL_ALL              = 0,
+       LTTNG_EVENT_LOGLEVEL_RANGE            = 1,
+       LTTNG_EVENT_LOGLEVEL_SINGLE           = 2,
 };
 
 /*
@@ -152,9 +153,8 @@ struct lttng_event {
        char name[LTTNG_SYMBOL_NAME_LEN];
 
        enum lttng_loglevel_type loglevel_type;
-       char loglevel[LTTNG_SYMBOL_NAME_LEN];   /* '\0' for all loglevels */
+       int loglevel;
 
-       int64_t loglevel_value;         /* for printing */
        uint32_t enabled;
        pid_t pid;
        /* Per event type configuration */
index 28962aaf747dd3a7107033b2dc2a99f49d423343..bd83c00ff776de7046a5ec7297f5df9f57c8c7e9 100644 (file)
@@ -25,8 +25,9 @@ enum lttng_ust_instrumentation {
 };
 
 enum lttng_ust_loglevel_type {
-       LTTNG_UST_LOGLEVEL              = 0,
-       LTTNG_UST_LOGLEVEL_ONLY         = 1,
+       LTTNG_UST_LOGLEVEL_ALL          = 0,
+       LTTNG_UST_LOGLEVEL_RANGE        = 1,
+       LTTNG_UST_LOGLEVEL_SINGLE       = 2,
 };
 
 enum lttng_ust_output {
@@ -53,7 +54,7 @@ struct lttng_ust_event {
        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 */
+       int loglevel;   /* value, -1: all */
 
        /* Per instrumentation type configuration */
        union {
@@ -87,8 +88,7 @@ struct lttng_ust_channel_attr {
 
 struct lttng_ust_tracepoint_iter {
        char name[LTTNG_UST_SYM_NAME_LEN];      /* provider:name */
-       char loglevel[LTTNG_UST_SYM_NAME_LEN];  /* loglevel */
-       int64_t loglevel_value;
+       int loglevel;
 };
 
 struct lttng_ust_object_data {
index e990c34843f7eba9d21d0f2df5e8d43dbc750882..61a762803668af2ffbbc330303b5034010bc6b87 100644 (file)
@@ -2032,14 +2032,16 @@ static int list_lttng_ust_global_events(char *channel_name,
                        tmp[i].type = LTTNG_EVENT_FUNCTION;
                        break;
                }
-               strncpy(tmp[i].loglevel, uevent->attr.loglevel, LTTNG_SYMBOL_NAME_LEN);
-               tmp[i].loglevel[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
+               tmp[i].loglevel = uevent->attr.loglevel;
                switch (uevent->attr.loglevel_type) {
-               case LTTNG_UST_LOGLEVEL:
-                       tmp[i].type = LTTNG_EVENT_LOGLEVEL;
+               case LTTNG_UST_LOGLEVEL_ALL:
+                       tmp[i].type = LTTNG_EVENT_LOGLEVEL_ALL;
                        break;
-               case LTTNG_UST_LOGLEVEL_ONLY:
-                       tmp[i].type = LTTNG_EVENT_LOGLEVEL_ONLY;
+               case LTTNG_UST_LOGLEVEL_RANGE:
+                       tmp[i].type = LTTNG_EVENT_LOGLEVEL_RANGE;
+                       break;
+               case LTTNG_UST_LOGLEVEL_SINGLE:
+                       tmp[i].type = LTTNG_EVENT_LOGLEVEL_SINGLE;
                        break;
                }
                i++;
index 0a90cac0ec13aa1d71049d9053217ab0fde0fffe..7f422a99e2e24658f1ea1c1d9a27c1e26463723e 100644 (file)
@@ -223,20 +223,22 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev)
        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;
+       case LTTNG_EVENT_LOGLEVEL_ALL:
+               lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL_ALL;
                break;
-       case LTTNG_EVENT_LOGLEVEL_ONLY:
-               lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL_ONLY;
+       case LTTNG_EVENT_LOGLEVEL_RANGE:
+               lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL_RANGE;
+               break;
+       case LTTNG_EVENT_LOGLEVEL_SINGLE:
+               lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL_SINGLE;
                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';
+       /* Copy loglevel */
+       lue->attr.loglevel = ev->loglevel;
 
        /* Init node */
        lttng_ht_node_init_str(&lue->node, lue->attr.name);
index 8e329a29f08adb661b2c053b3c361b616aa64027..77888048794c39d2cdd329122eccb3af633da39f 100644 (file)
@@ -1420,9 +1420,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 = uiter.loglevel;
                        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 449f20f47f8616ecc468d3332f0de3e9e2a3f396..6e912c11693e70b2fa35f28f45c5359f0b587589 100644 (file)
@@ -209,6 +209,66 @@ end:
        return ret;
 }
 
+/*
+ * Maps this from string to value
+ *
+ * TRACE_EMERG = 0,
+ * TRACE_ALERT = 1,
+ * TRACE_CRIT = 2,
+ * TRACE_ERR = 3,
+ * TRACE_WARNING = 4,
+ * TRACE_NOTICE = 5,
+ * TRACE_INFO = 6,
+ * TRACE_SYSTEM = 7,
+ * TRACE_PROCESS = 8,
+ * TRACE_MODULE = 9,
+ * TRACE_UNIT = 10,
+ * TRACE_CLASS = 11,
+ * TRACE_OBJECT = 12,
+ * TRACE_FUNCTION = 13,
+ * TRACE_PRINTF = 14,
+ * TRACE_DEBUG = 15,
+ */
+static
+int loglevel_str_to_value(const char *str)
+{
+       if (!strcmp(str, "TRACE_EMERG")) {
+               return 0;
+       } else if (!strcmp(str, "TRACE_ALERT")) {
+               return 1;
+       } else if (!strcmp(str, "TRACE_CRIT")) {
+               return 2;
+       } else if (!strcmp(str, "TRACE_ERR")) {
+               return 3;
+       } else if (!strcmp(str, "TRACE_WARNING")) {
+               return 4;
+       } else if (!strcmp(str, "TRACE_NOTICE")) {
+               return 5;
+       } else if (!strcmp(str, "TRACE_INFO")) {
+               return 6;
+       } else if (!strcmp(str, "TRACE_SYSTEM")) {
+               return 7;
+       } else if (!strcmp(str, "TRACE_PROCESS")) {
+               return 8;
+       } else if (!strcmp(str, "TRACE_MODULE")) {
+               return 9;
+       } else if (!strcmp(str, "TRACE_UNIT")) {
+               return 10;
+       } else if (!strcmp(str, "TRACE_CLASS")) {
+               return 11;
+       } else if (!strcmp(str, "TRACE_OBJECT")) {
+               return 12;
+       } else if (!strcmp(str, "TRACE_FUNCTION")) {
+               return 13;
+       } else if (!strcmp(str, "TRACE_PRINTF")) {
+               return 14;
+       } else if (!strcmp(str, "TRACE_DEBUG")) {
+               return 15;
+       } else {
+               return -1;
+       }
+}
+
 /*
  * Enabling event using the lttng API.
  */
@@ -341,8 +401,7 @@ static int enable_events(char *session_name)
                        }
 
                        /* kernel loglevels not implemented */
-                       ev.loglevel_type = opt_loglevel_type;
-                       ev.loglevel[0] = '\0';
+                       ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
                } else if (opt_userspace) {             /* User-space tracer action */
 #if 0
                        if (opt_cmd_name != NULL || opt_pid) {
@@ -376,10 +435,11 @@ static int enable_events(char *session_name)
 
                        ev.loglevel_type = opt_loglevel_type;
                        if (opt_loglevel) {
-                               strncpy(ev.loglevel, opt_loglevel, LTTNG_SYMBOL_NAME_LEN);
-                               ev.loglevel[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
-                       } else {
-                               ev.loglevel[0] = '\0';
+                               ev.loglevel = loglevel_str_to_value(opt_loglevel);
+                               if (ev.loglevel == -1) {
+                                       ERR("Unknown loglevel %s", opt_loglevel);
+                                       goto error;
+                               }
                        }
                } else {
                        ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
@@ -452,11 +512,11 @@ int cmd_enable_events(int argc, const char **argv)
                        opt_userspace = 1;
                        break;
                case OPT_LOGLEVEL:
-                       opt_loglevel_type = LTTNG_EVENT_LOGLEVEL;
+                       opt_loglevel_type = LTTNG_EVENT_LOGLEVEL_RANGE;
                        opt_loglevel = poptGetOptArg(pc);
                        break;
                case OPT_LOGLEVEL_ONLY:
-                       opt_loglevel_type = LTTNG_EVENT_LOGLEVEL_ONLY;
+                       opt_loglevel_type = LTTNG_EVENT_LOGLEVEL_SINGLE;
                        opt_loglevel = poptGetOptArg(pc);
                        break;
                case OPT_LIST_OPTIONS:
index ef1efc79371876406eccea376fcec64083d2575c..c22206952160c7bc6e477d4250feed230ed99000 100644 (file)
@@ -145,9 +145,9 @@ const char *enabled_string(int value)
 }
 
 static
-const char *loglevel_string_pre(const char *loglevel)
+const char *loglevel_string_pre(int loglevel)
 {
-       if (loglevel[0] == '\0') {
+       if (loglevel == -1) {
                return "";
        } else {
                return " (loglevel: ";
@@ -155,15 +155,39 @@ const char *loglevel_string_pre(const char *loglevel)
 }
 
 static
-const char *loglevel_string_post(const char *loglevel)
+const char *loglevel_string_post(int loglevel)
 {
-       if (loglevel[0] == '\0') {
+       if (loglevel == -1) {
                return "";
        } else {
                return ")";
        }
 }
 
+static const char *loglevel_string(int value)
+{
+       switch (value) {
+       case -1: return "";
+       case 0: return "TRACE_EMERG";
+       case 1: return "TRACE_ALERT";
+       case 2: return "TRACE_CRIT";
+       case 3: return "TRACE_ERR";
+       case 4: return "TRACE_WARNING";
+       case 5: return "TRACE_NOTICE";
+       case 6: return "TRACE_INFO";
+       case 7: return "TRACE_SYSTEM";
+       case 8: return "TRACE_PROCESS";
+       case 9: return "TRACE_MODULE";
+       case 10: return "TRACE_UNIT";
+       case 11: return "TRACE_CLASS";
+       case 12: return "TRACE_OBJECT";
+       case 13: return "TRACE_FUNCTION";
+       case 14: return "TRACE_PRINTF";
+       case 15: return "TRACE_DEBUG";
+       default: return "<<UNKNOWN>>";
+       }
+}
+
 /*
  * Pretty print single event.
  */
@@ -172,22 +196,11 @@ static void print_events(struct lttng_event *event)
        switch (event->type) {
        case LTTNG_EVENT_TRACEPOINT:
        {
-               char ll_value[LTTNG_SYMBOL_NAME_LEN] = "";
-
-               if (event->loglevel[0] != '\0') {
-                       int ret;
-
-                       ret = snprintf(ll_value, LTTNG_SYMBOL_NAME_LEN,
-                               " (%lld)", (long long) event->loglevel_value);
-                       if (ret < 0) {
-                               ERR("snprintf error");
-                       }
-               }
-               MSG("%s%s%s%s%s%s (type: tracepoint)%s", indent6,
+               MSG("%s%s%s%s%d%s (type: tracepoint)%s", indent6,
                                event->name,
                                loglevel_string_pre(event->loglevel),
+                               loglevel_string(event->loglevel),
                                event->loglevel,
-                               ll_value,
                                loglevel_string_post(event->loglevel),
                                enabled_string(event->enabled));
                break;
index 438320d97616bca6f6ac3bbe4280e4a0d61ddf55..48658a42ddfb9d9e5f2a7ddd820f258bcd0914ac 100644 (file)
@@ -465,12 +465,14 @@ static int parse_args(int argc, char **argv)
        /* Spawn session daemon if needed */
        if (opt_no_sessiond == 0 && check_args_no_sessiond(argc, argv) == 0 &&
                        (check_sessiond() < 0)) {
+               ret = 1;
                goto error;
        }
 
        /* No leftovers, print usage and quit */
        if ((argc - optind) == 0) {
                usage(stderr);
+               ret = 1;
                goto error;
        }
 
index b141057c6b8d4a44c31ee95882f071697fc44b99..56746a73fbf9fff241e80439560d62540e8c02be 100644 (file)
@@ -42,8 +42,7 @@ int main(int argc, char **argv)
 
        memset(&event, 0, sizeof(struct lttng_event));
        event.type = LTTNG_EVENT_TRACEPOINT;
-       event.loglevel[0] = '\0';
-       event.loglevel_type = LTTNG_EVENT_LOGLEVEL;
+       event.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
 
        printf("\nTesting tracing all UST events:\n");
        printf("-----------\n");
index ac0687daa11120e112ad5cc9d6e42014461e0453..5a7af53e2677c5a8a273a59fd7e604429b9d70d5 100644 (file)
@@ -52,18 +52,15 @@ int main(int argc, char **argv)
 
        strcpy(ev1.name, "tp1");
        ev1.type = LTTNG_EVENT_TRACEPOINT;
-       ev1.loglevel[0] = '\0';
-       ev1.loglevel_type = LTTNG_EVENT_LOGLEVEL;
+       ev1.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
 
        strcpy(ev2.name, "ev2");
        ev2.type = LTTNG_EVENT_TRACEPOINT;
-       ev2.loglevel[0] = '\0';
-       ev2.loglevel_type = LTTNG_EVENT_LOGLEVEL;
+       ev2.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
 
        strcpy(ev3.name, "ev3");
        ev3.type = LTTNG_EVENT_TRACEPOINT;
-       ev3.loglevel[0] = '\0';
-       ev3.loglevel_type = LTTNG_EVENT_LOGLEVEL;
+       ev3.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
 
        printf("\nTesting tracing UST events:\n");
        printf("-----------\n");
This page took 0.03412 seconds and 4 git commands to generate.