Add procname context
[lttng-ust.git] / tests / ust-basic-tracing / ust-basic-tracing.c
index 437b9c24c7fdd0e299673a95e4df8bf8d8891ee4..e97552a13ba1d4f00643e12fa1d4c79c5d81d8fa 100644 (file)
@@ -56,6 +56,7 @@ static struct object_data metadata_data;
 static struct object_data channel_data;
 static struct object_data stream_data[MAX_NR_STREAMS];
 static int event_handle[MAX_NR_EVENTS];
+static int context_handle;
 
 static int apps_socket = -1;
 static char apps_sock_path[PATH_MAX];
@@ -159,6 +160,11 @@ static int lttcomm_recv_fd(int sock)
        struct cmsghdr *cmsg;
        char recv_fd[CMSG_SPACE(sizeof(int))];
        struct msghdr msg = { 0 };
+       union {
+               unsigned char vc[4];
+               int vi;
+       } tmp;
+       int i;
 
        /* Prepare to receive the structures */
        iov[0].iov_base = &data_fd;
@@ -189,7 +195,9 @@ static int lttcomm_recv_fd(int sock)
                goto end;
        }
        /* this is our fd */
-       ret = ((int *) CMSG_DATA(cmsg))[0];
+       for (i = 0; i < sizeof(int); i++)
+               tmp.vc[i] = CMSG_DATA(cmsg)[i];
+       ret = tmp.vi;
        printf("received fd %d\n", ret);
 end:
        return ret;
@@ -557,6 +565,20 @@ int send_app_msgs(int sock, const char *outputpath,
                printf("received event handle %u\n", event_handle[k]);
        }
 
+       /* Attach vtid context */
+       memset(&lum, 0, sizeof(lum));
+       lum.handle = channel_data.handle;
+       lum.cmd = LTTNG_UST_CONTEXT;
+       lum.u.context.ctx = LTTNG_UST_CONTEXT_VTID;
+       //lum.u.context.ctx = LTTNG_UST_CONTEXT_PTHREAD_ID;
+       //lum.u.context.ctx = LTTNG_UST_CONTEXT_VPID;
+       //lum.u.context.ctx = LTTNG_UST_CONTEXT_PROCNAME;
+       ret = send_app_cmd(sock, &lum, &lur);
+       if (ret)
+               return ret;
+       context_handle = lur.ret_val;
+       printf("received context handle %u\n", context_handle);
+
        /* Get references to channel streams */
        ret = open_streams(sock, channel_data.handle,
                        stream_data, MAX_NR_STREAMS);
@@ -597,6 +619,14 @@ int send_app_msgs(int sock, const char *outputpath,
        if (ret)
                return ret;
 
+       /* Release context */
+       memset(&lum, 0, sizeof(lum));
+       lum.handle = context_handle;
+       lum.cmd = LTTNG_UST_RELEASE;
+       ret = send_app_cmd(sock, &lum, &lur);
+       if (ret)
+               return ret;
+
        /* Release events */
        for (k = 0; k < nr_events; k++) {
                memset(&lum, 0, sizeof(lum));
@@ -810,7 +840,7 @@ int main(int argc, const char **argv)
        const char *home_dir;
        int ret, wait_shm_fd;
        struct sigaction act;
-       mode_t old_umask;
+       mode_t old_umask = 0;
        const char *outputpath;
        const char **event_names;
        unsigned int nr_events;
This page took 0.025043 seconds and 4 git commands to generate.