Make "please specify tracer" comment more helpful
[lttng-tools.git] / lttng / commands / add_context.c
index 38d3cc1dc1425050c0f4740482f6a6157e180418..eb88f246517ed2e387e47846525fdd418a84c2c5 100644 (file)
@@ -164,8 +164,8 @@ static struct poptOption long_options[] = {
                .u.perf = {                                             \
                        PERF_TYPE_HW_CACHE,                             \
                        (uint64_t) PERF_COUNT_HW_CACHE_##name           \
-                       * (uint64_t) PERF_COUNT_HW_CACHE_OP_##op        \
-                       * (uint64_t) PERF_COUNT_HW_CACHE_RESULT_##result, \
+                       | ((uint64_t) PERF_COUNT_HW_CACHE_OP_##op << 8) \
+                       | ((uint64_t) PERF_COUNT_HW_CACHE_RESULT_##result << 16), \
                },                                                      \
        }
 
@@ -349,19 +349,19 @@ static int add_context(void)
        struct ctx_type *type;
        char *ptr;
 
-       if (set_session_name(opt_session_name) < 0) {
-               ret = CMD_ERROR;
-               goto error;
-       }
-
        /* Iterate over all context type given */
        cds_list_for_each_entry(type, &ctx_type_list.head, list) {
+               /* Set session name for the current command */
+               if (set_session_name(opt_session_name) < 0) {
+                       ret = CMD_ERROR;
+                       goto error;
+               }
+
                context.ctx = type->opt->ctx_type;
                if (context.ctx == LTTNG_EVENT_CONTEXT_PERF_COUNTER) {
                        context.u.perf_counter.type = type->opt->u.perf.type;
                        context.u.perf_counter.config = type->opt->u.perf.config;
-                       strcpy(context.u.perf_counter.name,
-                              type->opt->symbol);
+                       strcpy(context.u.perf_counter.name, type->opt->symbol);
                        /* Replace : and - by _ */
                        while ((ptr = strchr(context.u.perf_counter.name, '-')) != NULL) {
                                *ptr = '_';
@@ -378,6 +378,7 @@ static int add_context(void)
                        ret = lttng_add_context(&dom, &context, opt_event_name,
                                        opt_channel_name);
                        if (ret < 0) {
+                               fprintf(stderr, "%s: ", type->opt->symbol);
                                goto error;
                        } else {
                                MSG("Kernel context %s added", type->opt->symbol);
@@ -392,7 +393,7 @@ static int add_context(void)
                        ret = CMD_NOT_IMPLEMENTED;
                        goto error;
                } else {
-                       ERR("Please specify a tracer (kernel or user-space)");
+                       ERR("Please specify a tracer (--kernel or --userspace)");
                        goto error;
                }
        }
This page took 0.02361 seconds and 4 git commands to generate.