Fix multiple enable events
[lttng-tools.git] / lttng / commands / enable_events.c
index 9657571473410558d15ea83d79f9aabd9baf8655..5d025e7085cb881393b795c9816f2048bf1c6fd5 100644 (file)
@@ -104,7 +104,7 @@ static void usage(FILE *ofp)
 static int parse_probe_opts(struct lttng_event *ev, char *opt)
 {
        int ret;
-       uint64_t hex;
+       char s_hex[19];
        char name[LTTNG_SYMBOL_NAME_LEN];
 
        if (opt == NULL) {
@@ -113,30 +113,33 @@ static int parse_probe_opts(struct lttng_event *ev, char *opt)
        }
 
        /* Check for symbol+offset */
-       ret = sscanf(opt, "%[^'+']+%" SCNu64, name, &hex);
+       ret = sscanf(opt, "%[^'+']+%s", name, s_hex);
        if (ret == 2) {
                strncpy(ev->attr.probe.symbol_name, name, LTTNG_SYMBOL_NAME_LEN);
                DBG("probe symbol %s", ev->attr.probe.symbol_name);
-               if (hex == 0) {
-                       ERR("Invalid probe offset %" PRIu64, hex);
+               if (strlen(s_hex) == 0) {
+                       ERR("Invalid probe offset %s", s_hex);
                        ret = -1;
                        goto error;
                }
-               ev->attr.probe.offset = hex;
+               ev->attr.probe.offset = strtoul(s_hex, NULL, 0);
                DBG("probe offset %" PRIu64, ev->attr.probe.offset);
+               ev->attr.probe.addr = 0;
                goto error;
        }
 
        /* Check for address */
-       ret = sscanf(opt, "%" SCNu64, &hex);
+       ret = sscanf(opt, "%s", s_hex);
        if (ret > 0) {
-               if (hex == 0) {
-                       ERR("Invalid probe address %" PRIu64, hex);
+               if (strlen(s_hex) == 0) {
+                       ERR("Invalid probe address %s", s_hex);
                        ret = -1;
                        goto error;
                }
-               ev->attr.probe.addr = hex;
+               ev->attr.probe.addr = strtoul(s_hex, NULL, 0);
                DBG("probe addr %" PRIu64, ev->attr.probe.addr);
+               ev->attr.probe.offset = 0;
+               memset(ev->attr.probe.symbol_name, 0, LTTNG_SYMBOL_NAME_LEN);
                goto error;
        }
 
@@ -159,11 +162,6 @@ static int enable_events(void)
        struct lttng_event ev;
        struct lttng_domain dom;
 
-       if (set_session_name(opt_session_name) < 0) {
-               ret = CMD_ERROR;
-               goto error;
-       }
-
        if (opt_channel_name == NULL) {
                err = asprintf(&channel_name, DEFAULT_CHANNEL_NAME);
                if (err < 0) {
@@ -180,6 +178,11 @@ static int enable_events(void)
        }
 
        if (opt_enable_all) {
+               if (set_session_name(opt_session_name) < 0) {
+                       ret = CMD_ERROR;
+                       goto error;
+               }
+
                if (opt_kernel) {
                        ret = lttng_enable_event(&dom, NULL, channel_name);
                        if (ret == 0) {
@@ -194,6 +197,11 @@ static int enable_events(void)
        /* Strip event list */
        event_name = strtok(opt_event_list, ",");
        while (event_name != NULL) {
+               if (set_session_name(opt_session_name) < 0) {
+                       ret = CMD_ERROR;
+                       goto error;
+               }
+
                /* Kernel tracer action */
                if (opt_kernel) {
                        DBG("Enabling kernel event %s for channel %s",
@@ -224,8 +232,6 @@ static int enable_events(void)
                        ret = lttng_enable_event(&dom, &ev, channel_name);
                        if (ret == 0) {
                                MSG("Kernel event %s created in channel %s", event_name, channel_name);
-                       } else if (ret < 0) {
-                               ERR("Unable to find event %s", ev.name);
                        }
                } else if (opt_userspace) {             /* User-space tracer action */
                        /*
This page took 0.025784 seconds and 4 git commands to generate.