Fix context mapping for UST and kernel
[lttng-tools.git] / src / bin / lttng / commands / add_context.c
index 73aff31130e8e5e5f5489d988bff3583ae8ecc86..6c374d17da93ffbd16174d88883f7dec7a35f908 100644 (file)
@@ -67,6 +67,7 @@ enum context_type {
        CONTEXT_VTID         = 7,
        CONTEXT_PPID         = 8,
        CONTEXT_VPPID        = 9,
+       CONTEXT_PTHREAD_ID   = 10,
 };
 
 /*
@@ -205,6 +206,7 @@ const struct ctx_opts {
        { "nice", CONTEXT_NICE },
        { "vpid", CONTEXT_VPID },
        { "tid", CONTEXT_TID },
+       { "pthread_id", CONTEXT_PTHREAD_ID },
        { "vtid", CONTEXT_VTID },
        { "ppid", CONTEXT_PPID },
        { "vppid", CONTEXT_VPPID },
@@ -361,7 +363,7 @@ end:
  */
 static int add_context(char *session_name)
 {
-       int ret = CMD_SUCCESS;
+       int ret = CMD_SUCCESS, warn = 0;
        struct lttng_event_context context;
        struct lttng_domain dom;
        struct ctx_type *type;
@@ -373,7 +375,7 @@ static int add_context(char *session_name)
                dom.type = LTTNG_DOMAIN_UST;
        } else {
                ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
-               ret = CMD_UNDEFINED;
+               ret = CMD_ERROR;
                goto error;
        }
 
@@ -404,6 +406,7 @@ static int add_context(char *session_name)
                                opt_channel_name);
                if (ret < 0) {
                        ERR("%s: ", type->opt->symbol);
+                       warn = 1;
                        continue;
                } else {
                        MSG("%s context %s added to %s event in %s",
@@ -418,6 +421,13 @@ static int add_context(char *session_name)
 error:
        lttng_destroy_handle(handle);
 
+       /*
+        * This means that at least one add_context failed and tells the user to
+        * look on stderr for error(s).
+        */
+       if (warn) {
+               ret = CMD_WARNING;
+       }
        return ret;
 }
 
This page took 0.026955 seconds and 5 git commands to generate.