[ 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",
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 */
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include "ltt-sessiond.h"
#include "libkernelctl.h"
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;
+}
#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 */
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;
}
/* Kernel event */
struct ltt_kernel_event {
- char name[NAME_MAX];
int fd;
+ struct lttng_kernel_event *event;
struct cds_list_head list;
};
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) {
}
/* 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;
}