Add kernel enable event support
authorDavid Goulet <david.goulet@polymtl.ca>
Tue, 24 May 2011 15:32:17 +0000 (11:32 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Tue, 24 May 2011 15:32:33 +0000 (11:32 -0400)
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
liblttsessiondcomm/liblttsessiondcomm.c
liblttsessiondcomm/liblttsessiondcomm.h
ltt-sessiond/kernel-ctl.c
ltt-sessiond/kernel-ctl.h
ltt-sessiond/main.c
ltt-sessiond/trace.h
lttng/lttng.c

index 19bda83883df09ddd7db9700c8c946451b93c4cc..5cd0f1203d594a10e565dc8e95143b225df17b64 100644 (file)
@@ -51,6 +51,8 @@ static const char *lttcomm_readable_code[] = {
        [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_NA) ] = "Kernel tracer not available",
        [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_SESS_FAIL) ] = "Kernel create session failed",
        [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_CHAN_FAIL) ] = "Kernel create channel failed",
+       [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_ENABLE_FAIL) ] = "Enable kernel event failed",
+       [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_DISABLE_FAIL) ] = "Disable kernel event failed",
        [ LTTCOMM_ERR_INDEX(KCONSUMERD_COMMAND_SOCK_READY) ] = "Kconsumerd command socket ready",
        [ LTTCOMM_ERR_INDEX(KCONSUMERD_SUCCESS_RECV_FD) ] = "Kconsumerd success on receiving fds",
        [ LTTCOMM_ERR_INDEX(KCONSUMERD_ERROR_RECV_FD) ] = "Kconsumerd error on receiving fds",
index 580d4c2c75381fbe30220d7d2111be7d6c753057..879982101dd901838065cfb9205a7353cf5e035b 100644 (file)
@@ -103,6 +103,8 @@ enum lttcomm_return_code {
        LTTCOMM_KERN_NA,                                /* Kernel tracer unavalable */
        LTTCOMM_KERN_SESS_FAIL,                 /* Kernel create session failed */
        LTTCOMM_KERN_CHAN_FAIL,                 /* Kernel create channel failed */
+       LTTCOMM_KERN_ENABLE_FAIL,               /* Kernel enable event failed */
+       LTTCOMM_KERN_DISABLE_FAIL,              /* Kernel disable event failed */
        KCONSUMERD_COMMAND_SOCK_READY,  /* when kconsumerd command socket ready */
        KCONSUMERD_SUCCESS_RECV_FD,             /* success on receiving fds */
        KCONSUMERD_ERROR_RECV_FD,               /* error on receiving fds */
index 5d70296ea82008669c6710c57a19024c4620f051..02e87e3401b88d1e6f81b999dd71e6f81a2d4438 100644 (file)
@@ -19,6 +19,7 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 
 #include "ltt-sessiond.h"
 #include "libkernelctl.h"
@@ -101,3 +102,42 @@ int kernel_create_channel(struct command_ctx *cmd_ctx)
 error:
        return ret;
 }
+
+/*
+ *  kernel_enable_event
+ *
+ *  Enable kernel event.
+ */
+int kernel_enable_event(struct ltt_kernel_channel *channel, char *name)
+{
+       int ret;
+       struct ltt_kernel_event *event;
+       struct lttng_kernel_event *lke;
+
+       event = malloc(sizeof(struct ltt_kernel_event));
+       lke = malloc(sizeof(struct lttng_kernel_event));
+
+       if (event == NULL || lke == NULL) {
+               perror("kernel enable event malloc");
+               ret = -errno;
+               goto error;
+       }
+
+       /* Setting up a kernel event */
+       strncpy(lke->name, name, LTTNG_SYM_NAME_LEN);
+       lke->instrumentation = LTTNG_KERNEL_TRACEPOINTS;
+       event->event = lke;
+
+       ret = kernctl_create_event(channel->fd, lke);
+       if (ret < 0) {
+               goto error;
+       }
+
+       /* Add event to event list */
+       cds_list_add(&event->list, &channel->events_list.head);
+
+       return 0;
+
+error:
+       return ret;
+}
index 35057be08503a77f90998622753992c3c2787786..b8f41e7d98bb08af0ea9cd8ccab5cdf0e0a37d05 100644 (file)
 #ifndef _LTT_KERNEL_CTL_H
 #define _LTT_KERNEL_CTL_H
 
+#include "trace.h"
+
 int kernel_create_session(struct command_ctx *cmd_ctx, int tracer_fd);
 int kernel_create_channel(struct command_ctx *cmd_ctx);
+int kernel_enable_event(struct ltt_kernel_channel *channel, char *name);
 
 #endif /* _LTT_KERNEL_CTL_H */
index 5b7fb0c212ad77acae4e33f3b91a47e667c1d351..88a43d9683975d5c4657e977b16662a869177699 100644 (file)
@@ -526,6 +526,12 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
 
                DBG("Enabling kernel event %s", cmd_ctx->lsm->u.event.event_name);
 
+               ret = kernel_enable_event(cmd_ctx->session->kernel_session->channel, cmd_ctx->lsm->u.event.event_name);
+               if (ret < 0) {
+                       ret = LTTCOMM_KERN_ENABLE_FAIL;
+                       goto error;
+               }
+
                ret = LTTCOMM_OK;
                break;
        }
index 9cfbd84ab1a636b86286e58623058af21d29cfc4..5b4ff68ff3a0c2718d90c5f5c8f377551e81e052 100644 (file)
@@ -30,8 +30,8 @@ struct ltt_kernel_event_list {
 
 /* Kernel event */
 struct ltt_kernel_event {
-       char name[NAME_MAX];
        int fd;
+       struct lttng_kernel_event *event;
        struct cds_list_head list;
 };
 
index beb67ffb446afa430ab4ca34982e26b8237bb0a0..c7c88f6315a0a8987912dc003979d0f8454247bd 100644 (file)
@@ -131,11 +131,12 @@ static int process_client_opt(void)
 
                if (opt_event_list != NULL) {
                        ret = process_opt_kernel_event();
+                       if (ret < 0) {
+                               goto end;
+                       }
                } else {
                        // Enable all events
                }
-
-               goto error;
        }
 
        if (opt_trace_pid != 0) {
@@ -521,7 +522,7 @@ static int validate_options(void)
        }
 
        /* If start trace, auto start tracing */
-       if (opt_start_trace) {
+       if (opt_start_trace || opt_event_list != NULL) {
                DBG("Requesting auto tracing");
                auto_trace = 1;
        }
This page took 0.028406 seconds and 4 git commands to generate.