Add kernel sesison and channel creation support
authorDavid Goulet <david.goulet@polymtl.ca>
Thu, 19 May 2011 21:59:14 +0000 (17:59 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Thu, 19 May 2011 22:01:23 +0000 (18:01 -0400)
New kernel-ctl.c/.h files used to interact with the libkernelctl for the
session daemon. All kernel trace actions are made in this C file.

Signed-off-by: David Goulet <david.goulet@polymtl.ca>
16 files changed:
include/lttng/lttng.h
liblttngctl/liblttngctl.c
liblttsessiondcomm/liblttsessiondcomm.c
liblttsessiondcomm/liblttsessiondcomm.h
ltt-sessiond/Makefile.am
ltt-sessiond/kernel-ctl.c [new file with mode: 0644]
ltt-sessiond/kernel-ctl.h [new file with mode: 0644]
ltt-sessiond/ltt-sessiond.h
ltt-sessiond/main.c
ltt-sessiond/session.c
ltt-sessiond/session.h
ltt-sessiond/trace.c
ltt-sessiond/trace.h
lttng/lttng.c
lttng/lttng.h
lttng/options.c

index 6f4ce130f684341e2799b84ce606c3bb7f127e24..98d632c7624d60f47d89a70373fab5172b097f51 100644 (file)
@@ -81,9 +81,6 @@ extern int lttng_kernel_disable_event(char *event_name);
 extern int lttng_kernel_create_session(void);
 extern int lttng_kernel_start_tracing(void);
 extern int lttng_kernel_stop_tracing(void);
 extern int lttng_kernel_create_session(void);
 extern int lttng_kernel_start_tracing(void);
 extern int lttng_kernel_stop_tracing(void);
-extern int lttng_kernel_create_channel(int overwrite,
-               uint64_t subbuf_size, uint64_t num_subbuf,
-               unsigned int switch_timer_interval,
-               unsigned int read_timer_interval);
+extern int lttng_kernel_create_channel(void);
 
 #endif /* _LIBLTTNGCTL_H */
 
 #endif /* _LIBLTTNGCTL_H */
index 230a19d7e8a25805602e71c7f541451213dc9edf..2cf79f4ed96987a9b95c59bb373ee1d80d44d1d0 100644 (file)
@@ -198,18 +198,8 @@ int lttng_kernel_create_session(void)
  *
  *  Create a channel in the kernel tracer.
  */
  *
  *  Create a channel in the kernel tracer.
  */
-int lttng_kernel_create_channel(int overwrite,
-               u64 subbuf_size, u64 num_subbuf,
-               unsigned int switch_timer_interval,
-               unsigned int read_timer_interval)
+int lttng_kernel_create_channel(void)
 {
 {
-       /* Write setting to the session message */
-       lsm.u.create_channel.overwrite = overwrite;
-       lsm.u.create_channel.subbuf_size = subbuf_size;
-       lsm.u.create_channel.num_subbuf = num_subbuf;
-       lsm.u.create_channel.switch_timer_interval = switch_timer_interval;
-       lsm.u.create_channel.read_timer_interval = read_timer_interval;
-
        return ask_sessiond(KERNEL_CREATE_CHANNEL, NULL);
 }
 
        return ask_sessiond(KERNEL_CREATE_CHANNEL, NULL);
 }
 
index a5b3818c42b4e8d80facf287b149c54fc07fbd99..d754f59daee86876a1fef4e783b0a75ab62545db 100644 (file)
@@ -48,6 +48,9 @@ static const char *lttcomm_readable_code[] = {
        [ LTTCOMM_ERR_INDEX(LTTCOMM_NO_TRACEABLE) ] = "App is not traceable",
        [ LTTCOMM_ERR_INDEX(LTTCOMM_SELECT_SESS) ] = "A session MUST be selected",
        [ LTTCOMM_ERR_INDEX(LTTCOMM_EXIST_SESS) ] = "Session name already exist",
        [ LTTCOMM_ERR_INDEX(LTTCOMM_NO_TRACEABLE) ] = "App is not traceable",
        [ LTTCOMM_ERR_INDEX(LTTCOMM_SELECT_SESS) ] = "A session MUST be selected",
        [ LTTCOMM_ERR_INDEX(LTTCOMM_EXIST_SESS) ] = "Session name already exist",
+       [ 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(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",
        [ 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 abcca250930bd766c19a581f9ac8dfd000a3d2c2..8e6a862efcdc6791cb100b8d8f070e9cdbe90997 100644 (file)
@@ -82,34 +82,38 @@ enum lttcomm_sessiond_command {
  * lttcomm error code.
  */
 enum lttcomm_return_code {
  * lttcomm error code.
  */
 enum lttcomm_return_code {
-       LTTCOMM_OK = 1000,              /* Ok */
-       LTTCOMM_ERR,                    /* Unknown Error */
-       LTTCOMM_UND,                    /* Undefine command */
-       LTTCOMM_ALLOC_FAIL,             /* Trace allocation fail */
-       LTTCOMM_NO_SESSION,             /* No session found */
-       LTTCOMM_CREATE_FAIL,    /* Create trace fail */
-       LTTCOMM_SESSION_FAIL,   /* Create session fail */
-       LTTCOMM_START_FAIL,             /* Start tracing fail */
-       LTTCOMM_STOP_FAIL,              /* Stop tracing fail */
-       LTTCOMM_LIST_FAIL,              /* Listing apps fail */
-       LTTCOMM_NO_APPS,                /* No traceable application */
-       LTTCOMM_NO_SESS,                /* No sessions available */
-       LTTCOMM_NO_TRACE,               /* No trace exist */
-       LTTCOMM_FATAL,                  /* Session daemon had a fatal error */
-       LTTCOMM_NO_TRACEABLE,   /* Error for non traceable app */
-       LTTCOMM_SELECT_SESS,    /* Must select a session */
-       LTTCOMM_EXIST_SESS,             /* Session name already exist */
-       LTTCOMM_NO_EVENT,               /* No event found */
-       LTTCOMM_NR,                             /* Last element */
+       LTTCOMM_OK = 1000,                              /* Ok */
+       LTTCOMM_ERR,                                    /* Unknown Error */
+       LTTCOMM_UND,                                    /* Undefine command */
+       LTTCOMM_ALLOC_FAIL,                             /* Trace allocation fail */
+       LTTCOMM_NO_SESSION,                             /* No session found */
+       LTTCOMM_CREATE_FAIL,                    /* Create trace fail */
+       LTTCOMM_SESSION_FAIL,                   /* Create session fail */
+       LTTCOMM_START_FAIL,                             /* Start tracing fail */
+       LTTCOMM_STOP_FAIL,                              /* Stop tracing fail */
+       LTTCOMM_LIST_FAIL,                              /* Listing apps fail */
+       LTTCOMM_NO_APPS,                                /* No traceable application */
+       LTTCOMM_NO_SESS,                                /* No sessions available */
+       LTTCOMM_NO_TRACE,                               /* No trace exist */
+       LTTCOMM_FATAL,                                  /* Session daemon had a fatal error */
+       LTTCOMM_NO_TRACEABLE,                   /* Error for non traceable app */
+       LTTCOMM_SELECT_SESS,                    /* Must select a session */
+       LTTCOMM_EXIST_SESS,                             /* Session name already exist */
+       LTTCOMM_NO_EVENT,                               /* No event found */
+       LTTCOMM_KERN_NA,                                /* Kernel tracer unavalable */
+       LTTCOMM_KERN_SESS_FAIL,                 /* Kernel create session failed */
+       LTTCOMM_KERN_CHAN_FAIL,                 /* Kernel create channel failed */
        KCONSUMERD_COMMAND_SOCK_READY,  /* when kconsumerd command socket ready */
        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 */
-       KCONSUMERD_POLL_ERROR,  /* Error in polling thread in kconsumerd */
-       KCONSUMERD_POLL_NVAL,   /* Poll on closed fd */
-       KCONSUMERD_POLL_HUP,    /* All fds have hungup */
-       KCONSUMERD_EXIT_SUCCESS,        /* kconsumerd exiting normally */
-       KCONSUMERD_EXIT_FAILURE,        /* kconsumerd exiting on error */
-       KCONSUMERD_OUTFD_ERROR, /* error opening the tracefile */
+       KCONSUMERD_SUCCESS_RECV_FD,             /* success on receiving fds */
+       KCONSUMERD_ERROR_RECV_FD,               /* error on receiving fds */
+       KCONSUMERD_POLL_ERROR,                  /* Error in polling thread in kconsumerd */
+       KCONSUMERD_POLL_NVAL,                   /* Poll on closed fd */
+       KCONSUMERD_POLL_HUP,                    /* All fds have hungup */
+       KCONSUMERD_EXIT_SUCCESS,                /* kconsumerd exiting normally */
+       KCONSUMERD_EXIT_FAILURE,                /* kconsumerd exiting on error */
+       KCONSUMERD_OUTFD_ERROR,                 /* error opening the tracefile */
+       /* MUST be last element */
+       LTTCOMM_NR,                                             /* Last element */
 };
 
 /* commands for kconsumerd */
 };
 
 /* commands for kconsumerd */
@@ -143,14 +147,6 @@ struct lttcomm_session_msg {
                struct {
                        char event_name[NAME_MAX];
                } event;
                struct {
                        char event_name[NAME_MAX];
                } event;
-               /* Create channel kernel */
-               struct {
-                       int overwrite;
-                       u64 subbuf_size;
-                       u64 num_subbuf;
-                       unsigned int switch_timer_interval;
-                       unsigned int read_timer_interval;
-               } create_channel;
        } u;
 };
 
        } u;
 };
 
index d24a23aec8ad04afc503fa03df140eb6380b4c0a..525851b42149ab4fb61cb5f62bb145ffc2eacf10 100644 (file)
@@ -1,9 +1,10 @@
-AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/liblttsessiondcomm
+AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/liblttsessiondcomm -I$(top_srcdir)/libkernelctl
 AM_CFLAGS = -fno-strict-aliasing
 
 bin_PROGRAMS = ltt-sessiond
 
 AM_CFLAGS = -fno-strict-aliasing
 
 bin_PROGRAMS = ltt-sessiond
 
-ltt_sessiond_SOURCES = session.c trace.c traceable-app.c main.c
+ltt_sessiond_SOURCES = session.c trace.c traceable-app.c kernel-ctl.c main.c
 
 ltt_sessiond_LDADD = \
 
 ltt_sessiond_LDADD = \
-                $(top_builddir)/liblttsessiondcomm/liblttsessiondcomm.la
+                $(top_builddir)/liblttsessiondcomm/liblttsessiondcomm.la \
+                $(top_builddir)/libkernelctl/libkernelctl.la
diff --git a/ltt-sessiond/kernel-ctl.c b/ltt-sessiond/kernel-ctl.c
new file mode 100644 (file)
index 0000000..12a00eb
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "ltt-sessiond.h"
+#include "libkernelctl.h"
+#include "kernel-ctl.h"
+#include "trace.h"
+
+/*
+ *  kernel_create_session
+ *
+ *  Create a new kernel session using the command context session.
+ */
+int kernel_create_session(struct command_ctx *cmd_ctx, int tracer_fd)
+{
+       int ret;
+       struct ltt_kernel_session *lks;
+
+       /* Allocate a new kernel session */
+       lks = malloc(sizeof(struct ltt_kernel_session));
+       if (lks == NULL) {
+               perror("kernel session malloc");
+               ret = -errno;
+               goto error;
+       }
+
+       ret = kernctl_create_session(tracer_fd);
+       if (ret < 0) {
+               goto error;
+       }
+
+       /* Assigning session fd and to the command context */
+       lks->fd = ret;
+       cmd_ctx->session->kernel_session = lks;
+       cmd_ctx->session->kern_session_count++;
+
+       return 0;
+
+error:
+       return ret;
+}
+
+/*
+ *  kernel_create_channel
+ *
+ *  Create a kernel channel within the kernel session.
+ */
+int kernel_create_channel(struct command_ctx *cmd_ctx)
+{
+       int ret;
+       struct ltt_kernel_channel *lkc;
+       struct lttng_channel *chan;
+
+       lkc = malloc(sizeof(struct ltt_kernel_channel));
+       chan = malloc(sizeof(struct lttng_channel));
+
+       if (lkc == NULL || chan == NULL) {
+               perror("kernel channel malloc");
+               ret = -errno;
+               goto error;
+       }
+
+       chan->overwrite = DEFAULT_KERNEL_OVERWRITE;
+       chan->subbuf_size = DEFAULT_KERNEL_SUBBUF_SIZE;
+       chan->num_subbuf = DEFAULT_KERNEL_SUBBUF_NUM;
+       chan->switch_timer_interval = DEFAULT_KERNEL_SWITCH_TIMER;
+       chan->read_timer_interval = DEFAULT_KERNEL_READ_TIMER;
+
+       ret = kernctl_create_channel(cmd_ctx->session->kernel_session->fd, chan);
+       if (ret < 0) {
+               goto error;
+       }
+
+       lkc->fd = ret;
+       lkc->channel = chan;
+       CDS_INIT_LIST_HEAD(&lkc->events_list.head);
+
+       cmd_ctx->session->kernel_session->channel = lkc;
+
+       return 0;
+
+error:
+       return ret;
+}
diff --git a/ltt-sessiond/kernel-ctl.h b/ltt-sessiond/kernel-ctl.h
new file mode 100644 (file)
index 0000000..35057be
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#ifndef _LTT_KERNEL_CTL_H
+#define _LTT_KERNEL_CTL_H
+
+int kernel_create_session(struct command_ctx *cmd_ctx, int tracer_fd);
+int kernel_create_channel(struct command_ctx *cmd_ctx);
+
+#endif /* _LTT_KERNEL_CTL_H */
index 7133d061fee9d03d064dd206e7017969141284d1..d563d1016a9672d18f607d4142c91bea2d1cabee 100644 (file)
 #define DEFAULT_UST_SOCK_DIR           "/tmp/ust-app-socks"
 #define DEFAULT_GLOBAL_APPS_PIPE       "/tmp/ust-app-socks/global"
 
 #define DEFAULT_UST_SOCK_DIR           "/tmp/ust-app-socks"
 #define DEFAULT_GLOBAL_APPS_PIPE       "/tmp/ust-app-socks/global"
 
+/*
+ * Kernel tracer defines
+ */
+#define DEFAULT_KERNEL_TRACER_PATH                     "/mnt/debugfs/lttng"
+#define DEFAULT_KERNEL_OVERWRITE            0
+#define DEFAULT_KERNEL_SUBBUF_SIZE          512                /* bytes */
+#define DEFAULT_KERNEL_SUBBUF_NUM           2          /* Must always be a power of 2 */
+#define DEFAULT_KERNEL_SWITCH_TIMER         0          /* usec */
+#define DEFAULT_KERNEL_READ_TIMER           10000      /* usec */
+
 extern const char default_home_dir[],
        default_tracing_group[],
        default_ust_sock_dir[],
 extern const char default_home_dir[],
        default_tracing_group[],
        default_ust_sock_dir[],
index 76e927e43a3fa68b938e79a1d3b28549886d0c20..5b7fb0c212ad77acae4e33f3b91a47e667c1d351 100644 (file)
@@ -40,6 +40,7 @@
 #include "liblttsessiondcomm.h"
 #include "ltt-sessiond.h"
 #include "lttngerr.h"
 #include "liblttsessiondcomm.h"
 #include "ltt-sessiond.h"
 #include "lttngerr.h"
+#include "kernel-ctl.h"
 #include "session.h"
 #include "trace.h"
 #include "traceable-app.h"
 #include "session.h"
 #include "trace.h"
 #include "traceable-app.h"
@@ -95,6 +96,7 @@ static char kconsumerd_cmd_unix_sock_path[PATH_MAX];  /* kconsumerd command Unix
 static int client_sock;
 static int apps_sock;
 static int kconsumerd_err_sock;
 static int client_sock;
 static int apps_sock;
 static int kconsumerd_err_sock;
+static int kernel_tracer_fd;
 
 /*
  *  thread_manage_kconsumerd
 
 /*
  *  thread_manage_kconsumerd
@@ -455,6 +457,17 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
                break;
        }
 
                break;
        }
 
+       /* Check command for kernel tracing */
+       switch (cmd_ctx->lsm->cmd_type) {
+       case KERNEL_CREATE_SESSION:
+       case KERNEL_CREATE_CHANNEL:
+               if (kernel_tracer_fd == 0) {
+                       ret = LTTCOMM_KERN_NA;
+                       goto error;
+               }
+               break;
+       }
+
        /* Connect to ust apps if available pid */
        if (cmd_ctx->lsm->pid > 0) {
                /* Connect to app using ustctl API */
        /* Connect to ust apps if available pid */
        if (cmd_ctx->lsm->pid > 0) {
                /* Connect to app using ustctl API */
@@ -467,6 +480,42 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
 
        /* Process by command type */
        switch (cmd_ctx->lsm->cmd_type) {
 
        /* Process by command type */
        switch (cmd_ctx->lsm->cmd_type) {
+       case KERNEL_CREATE_SESSION:
+       {
+               ret = setup_lttng_msg(cmd_ctx, 0);
+               if (ret < 0) {
+                       goto setup_error;
+               }
+
+               DBG("Creating kernel session");
+
+               ret = kernel_create_session(cmd_ctx, kernel_tracer_fd);
+               if (ret < 0) {
+                       ret = LTTCOMM_KERN_SESS_FAIL;
+                       goto error;
+               }
+
+               ret = LTTCOMM_OK;
+               break;
+       }
+       case KERNEL_CREATE_CHANNEL:
+       {
+               ret = setup_lttng_msg(cmd_ctx, 0);
+               if (ret < 0) {
+                       goto setup_error;
+               }
+
+               DBG("Creating kernel session");
+
+               ret = kernel_create_channel(cmd_ctx);
+               if (ret < 0) {
+                       ret = LTTCOMM_KERN_CHAN_FAIL;
+                       goto error;
+               }
+
+               ret = LTTCOMM_OK;
+               break;
+       }
        case KERNEL_ENABLE_EVENT:
        {
                /* Setup lttng message with no payload */
        case KERNEL_ENABLE_EVENT:
        {
                /* Setup lttng message with no payload */
@@ -909,6 +958,21 @@ error:
        return ret;
 }
 
        return ret;
 }
 
+/*
+ *  init_kernel_tracer
+ *
+ *  Setup necessary data for kernel tracer action.
+ */
+static void init_kernel_tracer(void)
+{
+       /* Set the global kernel tracer fd */
+       kernel_tracer_fd = open(DEFAULT_KERNEL_TRACER_PATH, O_RDWR);
+       if (kernel_tracer_fd < 0) {
+               WARN("No kernel tracer available");
+               kernel_tracer_fd = 0;
+       }
+}
+
 /*
  *  set_kconsumerd_sockets
  *
 /*
  *  set_kconsumerd_sockets
  *
@@ -1101,6 +1165,9 @@ int main(int argc, char **argv)
                if (ret < 0) {
                        goto error;
                }
                if (ret < 0) {
                        goto error;
                }
+
+               /* Setup kernel tracer */
+               init_kernel_tracer();
        } else {
                if (strlen(apps_unix_sock_path) == 0) {
                        snprintf(apps_unix_sock_path, PATH_MAX,
        } else {
                if (strlen(apps_unix_sock_path) == 0) {
                        snprintf(apps_unix_sock_path, PATH_MAX,
index 069213655323a978eb0c355f482782be2e0f2fe6..9fef73cf7ecdce33e10a7599b2a580742ecc3257 100644 (file)
@@ -200,11 +200,9 @@ int create_session(char *name, uuid_t *session_id)
 
        /* Init list */
        CDS_INIT_LIST_HEAD(&new_session->ust_traces);
 
        /* Init list */
        CDS_INIT_LIST_HEAD(&new_session->ust_traces);
-       CDS_INIT_LIST_HEAD(&new_session->kernel_traces);
 
        /* Set trace list counter */
        new_session->ust_trace_count = 0;
 
        /* Set trace list counter */
        new_session->ust_trace_count = 0;
-       new_session->kern_trace_count = 0;
 
        /* Add new session to the global session list */
        add_session_list(new_session);
 
        /* Add new session to the global session list */
        add_session_list(new_session);
index 586c55a246ddc70908fe76e0265239c8ae481c4c..7567d986767b185e2be046c44eb3675c949570f3 100644 (file)
@@ -20,6 +20,7 @@
 #define _LTT_SESSION_H
 
 #include <lttng/lttng.h>
 #define _LTT_SESSION_H
 
 #include <lttng/lttng.h>
+#include <urcu/list.h>
 #include <uuid/uuid.h>
 
 /* Global session list */
 #include <uuid/uuid.h>
 
 /* Global session list */
@@ -31,13 +32,13 @@ struct ltt_session_list {
  * to identify a tracing session for both LTTng and UST.
  */
 struct ltt_session {
  * to identify a tracing session for both LTTng and UST.
  */
 struct ltt_session {
-       char *name;
        struct cds_list_head list;
        struct cds_list_head list;
+       char *name;
        uuid_t uuid;
        struct cds_list_head ust_traces;
        uuid_t uuid;
        struct cds_list_head ust_traces;
-       struct cds_list_head kernel_traces;
+       struct ltt_kernel_session *kernel_session;
        unsigned int ust_trace_count;
        unsigned int ust_trace_count;
-       unsigned int kern_trace_count;
+       unsigned int kern_session_count;
        pid_t ust_consumer;
        pid_t kernel_consumer;
 };
        pid_t ust_consumer;
        pid_t kernel_consumer;
 };
index 9a3c95956439e08a462b8e1e21f25ed050359a08..1cddb31fac9c6bb68a8a9f401e6567a08941f33d 100644 (file)
@@ -63,7 +63,7 @@ static struct ltt_ust_trace *find_session_ust_trace_by_pid(
  */
 int get_trace_count_per_session(struct ltt_session *session)
 {
  */
 int get_trace_count_per_session(struct ltt_session *session)
 {
-       return session->ust_trace_count + session->kern_trace_count;
+       return session->ust_trace_count + session->kern_session_count;
 }
 
 /*
 }
 
 /*
@@ -76,7 +76,6 @@ void get_traces_per_session(struct ltt_session *session, struct lttng_trace *tra
 {
        int i = 0;
        struct ltt_ust_trace *ust_iter;
 {
        int i = 0;
        struct ltt_ust_trace *ust_iter;
-       struct ltt_kernel_trace *kern_iter;
        struct lttng_trace trace;
 
        DBG("Getting userspace traces for session %s", session->name);
        struct lttng_trace trace;
 
        DBG("Getting userspace traces for session %s", session->name);
@@ -95,13 +94,10 @@ void get_traces_per_session(struct ltt_session *session, struct lttng_trace *tra
        DBG("Getting kernel traces for session %s", session->name);
 
        /* Getting kernel traces */
        DBG("Getting kernel traces for session %s", session->name);
 
        /* Getting kernel traces */
-       cds_list_for_each_entry(kern_iter, &session->kernel_traces, list) {
+       if (session->kern_session_count > 0) {
                trace.type = KERNEL;
                trace.type = KERNEL;
-               strncpy(trace.name, kern_iter->name, sizeof(trace.name));
-               trace.name[sizeof(trace.name) - 1] = '\0';
+               strncpy(trace.name, "kernel", 6);
                memcpy(&traces[i], &trace, sizeof(trace));
                memcpy(&traces[i], &trace, sizeof(trace));
-               memset(&trace, 0, sizeof(trace));
-               i++;
        }
 }
 
        }
 }
 
index 5114272d879d3e354e081dd1c786a35b526f4454..6e86915b60ef69f0519485dfb5291982f955aa17 100644 (file)
 
 #include "ltt-sessiond.h"
 #include "session.h"
 
 #include "ltt-sessiond.h"
 #include "session.h"
+#include "lttng-kernel.h"
 
 
-/* LTTng trace representation */
-struct ltt_kernel_trace {
-       struct cds_list_head list;
+/* Kernel event list */
+struct ltt_kernel_event_list {
+       struct cds_list_head head;
+};
+
+/* Kernel event */
+struct ltt_kernel_event {
        char name[NAME_MAX];
        char name[NAME_MAX];
-       struct cds_list_head marker_list;
+       int fd;
+       struct cds_list_head list;
+};
+
+/* Kernel channel */
+struct ltt_kernel_channel {
+       int fd;
+       struct lttng_channel *channel;
+       struct ltt_kernel_event_list events_list;
+};
+
+/* Kernel session */
+struct ltt_kernel_session {
+       int fd;
+       struct ltt_kernel_channel *channel;
 };
 
 /* UST trace representation */
 };
 
 /* UST trace representation */
index 10ce2ddfc08539bb121c2a0aa8b3bfe017a93f20..beb67ffb446afa430ab4ca34982e26b8237bb0a0 100644 (file)
@@ -181,7 +181,24 @@ error:     /* fall through */
  */
 static int process_kernel_create_trace(void)
 {
  */
 static int process_kernel_create_trace(void)
 {
+       int ret;
+
+       /* Setup kernel session */
+       ret = lttng_kernel_create_session();
+       if (ret < 0) {
+               goto error;
+       }
+
+       /* Create an empty channel (with no event) */
+       ret = lttng_kernel_create_channel();
+       if (ret < 0) {
+               goto error;
+       }
+
        return 0;
        return 0;
+
+error:
+       return ret;
 }
 
 /*
 }
 
 /*
index 412eba355b78b256a8e96eb3707e8f982c8105e4..efaed09b5b313c7290dbd1aeb1c973cde3da881c 100644 (file)
@@ -37,7 +37,7 @@ extern int opt_enable_event;
 extern int opt_disable_event;
 extern int opt_destroy_session;
 extern int opt_create_session;
 extern int opt_disable_event;
 extern int opt_destroy_session;
 extern int opt_create_session;
-extern int opt_create_channel;
+extern int opt_kern_create_channel;
 extern int opt_list_apps;
 extern int opt_no_sessiond;
 extern int opt_list_session;
 extern int opt_list_apps;
 extern int opt_no_sessiond;
 extern int opt_list_session;
index bb0233e7e7f79270b8831c231011f0cd549f2d59..bb3ecbb0cdaf5e6014b74d7583b96c0532d0b8ab 100644 (file)
@@ -42,7 +42,7 @@ int opt_start_trace = 0;
 int opt_stop_trace = 0;
 int opt_enable_event;
 int opt_disable_event;
 int opt_stop_trace = 0;
 int opt_enable_event;
 int opt_disable_event;
-int opt_create_channel;
+int opt_kern_create_channel;
 pid_t opt_trace_pid = 0;
 
 enum {
 pid_t opt_trace_pid = 0;
 
 enum {
@@ -68,6 +68,7 @@ static struct poptOption long_options[] = {
        {"group",                       0,              POPT_ARG_STRING,        &opt_tracing_group, 0, 0, 0},
        {"help",                        'h',    POPT_ARG_NONE,          0, OPT_HELP, 0, 0},
        {"kernel",                      'k',    POPT_ARG_VAL,           &opt_trace_kernel, 1, 0, 0},
        {"group",                       0,              POPT_ARG_STRING,        &opt_tracing_group, 0, 0, 0},
        {"help",                        'h',    POPT_ARG_NONE,          0, OPT_HELP, 0, 0},
        {"kernel",                      'k',    POPT_ARG_VAL,           &opt_trace_kernel, 1, 0, 0},
+       {"kern-create-channel",0,   POPT_ARG_VAL,               &opt_kern_create_channel, 1, 0, 0},
        {"list-apps",           'L',    POPT_ARG_VAL,           &opt_list_apps, 1, 0, 0},
        {"list-sessions",       'l',    POPT_ARG_VAL,           &opt_list_session, 1, 0, 0},
        {"list-traces",         't',    POPT_ARG_VAL,           &opt_list_traces, 1, 0, 0},
        {"list-apps",           'L',    POPT_ARG_VAL,           &opt_list_apps, 1, 0, 0},
        {"list-sessions",       'l',    POPT_ARG_VAL,           &opt_list_session, 1, 0, 0},
        {"list-traces",         't',    POPT_ARG_VAL,           &opt_list_traces, 1, 0, 0},
@@ -119,7 +120,7 @@ static void usage(FILE *ofp)
        fprintf(ofp, "      --stop [NAME]            Stop tracing. Use NAME to identify user-space trace\n");
        fprintf(ofp, "\n");
        fprintf(ofp, "Kernel tracing options:\n");
        fprintf(ofp, "      --stop [NAME]            Stop tracing. Use NAME to identify user-space trace\n");
        fprintf(ofp, "\n");
        fprintf(ofp, "Kernel tracing options:\n");
-       fprintf(ofp, "      --create-channel         Create kernel channel\n");
+       fprintf(ofp, "      --kern-create-channel    Create a kernel channel\n");
        fprintf(ofp, "\n");
        fprintf(ofp, "User-space tracing options:\n");
        fprintf(ofp, "\n");
        fprintf(ofp, "\n");
        fprintf(ofp, "User-space tracing options:\n");
        fprintf(ofp, "\n");
This page took 0.052176 seconds and 4 git commands to generate.