Mi: mi backend + mi for command version
[lttng-tools.git] / src / bin / lttng / commands / enable_events.c
index 29a399e9714ac280011a41837619d500c452bdcd..9b16d7c86ec7959230e83ac97160987e5b30d719 100644 (file)
 #include "../command.h"
 #include <src/common/sessiond-comm/sessiond-comm.h>
 
+#if (LTTNG_SYMBOL_NAME_LEN == 256)
+#define LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API    "255"
+#endif
+
 static char *opt_event_list;
 static int opt_event_type;
 static const char *opt_loglevel;
@@ -226,6 +230,7 @@ static int parse_probe_opts(struct lttng_event *ev, char *opt)
 {
        int ret;
        char s_hex[19];
+#define S_HEX_LEN_SCANF_IS_A_BROKEN_API "18"   /* 18 is (19 - 1) (\0 is extra) */
        char name[LTTNG_SYMBOL_NAME_LEN];
 
        if (opt == NULL) {
@@ -234,7 +239,8 @@ static int parse_probe_opts(struct lttng_event *ev, char *opt)
        }
 
        /* Check for symbol+offset */
-       ret = sscanf(opt, "%[^'+']+%s", name, s_hex);
+       ret = sscanf(opt, "%" LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API
+                       "[^'+']+%" S_HEX_LEN_SCANF_IS_A_BROKEN_API "s", name, s_hex);
        if (ret == 2) {
                strncpy(ev->attr.probe.symbol_name, name, LTTNG_SYMBOL_NAME_LEN);
                ev->attr.probe.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
@@ -252,7 +258,8 @@ static int parse_probe_opts(struct lttng_event *ev, char *opt)
 
        /* Check for symbol */
        if (isalpha(name[0])) {
-               ret = sscanf(opt, "%s", name);
+               ret = sscanf(opt, "%" LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "s",
+                       name);
                if (ret == 1) {
                        strncpy(ev->attr.probe.symbol_name, name, LTTNG_SYMBOL_NAME_LEN);
                        ev->attr.probe.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
@@ -265,7 +272,7 @@ static int parse_probe_opts(struct lttng_event *ev, char *opt)
        }
 
        /* Check for address */
-       ret = sscanf(opt, "%s", s_hex);
+       ret = sscanf(opt, "%" S_HEX_LEN_SCANF_IS_A_BROKEN_API "s", s_hex);
        if (ret > 0) {
                if (*s_hex == '\0') {
                        ERR("Invalid probe address %s", s_hex);
@@ -883,10 +890,17 @@ static int enable_events(char *session_name)
                                }
                                warn = 1;
                        } else {
-                               MSG("%s event %s%s created in channel %s",
-                                               get_domain_str(dom.type), event_name,
-                                               exclusion_string,
-                                               print_channel_name(channel_name));
+                               /* So we don't print the default channel name for JUL. */
+                               if (dom.type == LTTNG_DOMAIN_JUL) {
+                                       MSG("%s event %s%s enabled.",
+                                                       get_domain_str(dom.type), event_name,
+                                                       exclusion_string);
+                               } else {
+                                       MSG("%s event %s%s created in channel %s",
+                                                       get_domain_str(dom.type), event_name,
+                                                       exclusion_string,
+                                                       print_channel_name(channel_name));
+                               }
                        }
                        free(exclusion_string);
                }
@@ -961,6 +975,13 @@ int cmd_enable_events(int argc, const char **argv)
        pc = poptGetContext(NULL, argc, argv, long_options, 0);
        poptReadDefaultConfig(pc, 0);
 
+       /* TODO: mi support */
+       if (lttng_opt_mi) {
+               ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+               ERR("mi option not supported");
+               goto end;
+       }
+
        /* Default event type */
        opt_event_type = LTTNG_EVENT_ALL;
 
This page took 0.025167 seconds and 4 git commands to generate.