switch (event->type) {
case LTTNG_EVENT_ALL:
- ret = event_kernel_disable_all(kchan);
+ ret = event_kernel_disable_event_all(kchan);
if (ret != LTTNG_OK) {
goto error;
}
break;
- case LTTNG_EVENT_TRACEPOINT:
+ case LTTNG_EVENT_TRACEPOINT: /* fall-through */
+ case LTTNG_EVENT_SYSCALL:
if (!strcmp(event_name, "*")) {
- ret = event_kernel_disable_all_tracepoints(kchan);
+ ret = event_kernel_disable_event_type(kchan,
+ event->type);
} else {
- ret = event_kernel_disable_tracepoint(kchan, event_name);
+ ret = event_kernel_disable_event(kchan,
+ event_name);
}
if (ret != LTTNG_OK) {
goto error;
}
break;
- case LTTNG_EVENT_SYSCALL:
- ret = event_kernel_disable_syscall(kchan, event_name);
+ case LTTNG_EVENT_PROBE:
+ case LTTNG_EVENT_FUNCTION:
+ case LTTNG_EVENT_FUNCTION_ENTRY:
+ ret = event_kernel_disable_event(kchan, event_name);
if (ret != LTTNG_OK) {
goto error;
}
case LTTNG_EVENT_ALL:
{
event->type = LTTNG_EVENT_TRACEPOINT; /* Hack */
- ret = event_kernel_enable_tracepoint(kchan, event);
+ ret = event_kernel_enable_event(kchan, event);
if (ret != LTTNG_OK) {
if (channel_created) {
/* Let's not leak a useless channel. */
goto error;
}
event->type = LTTNG_EVENT_SYSCALL; /* Hack */
- ret = event_kernel_enable_syscall(kchan, event->name);
+ ret = event_kernel_enable_event(kchan, event);
if (ret != LTTNG_OK) {
goto error;
}
case LTTNG_EVENT_FUNCTION:
case LTTNG_EVENT_FUNCTION_ENTRY:
case LTTNG_EVENT_TRACEPOINT:
- ret = event_kernel_enable_tracepoint(kchan, event);
+ ret = event_kernel_enable_event(kchan, event);
if (ret != LTTNG_OK) {
if (channel_created) {
/* Let's not leak a useless channel. */
}
break;
case LTTNG_EVENT_SYSCALL:
- ret = event_kernel_enable_syscall(kchan, event->name);
+ ret = event_kernel_enable_event(kchan, event);
if (ret != LTTNG_OK) {
goto error;
}
/*
* Disable kernel tracepoint event for a channel from the kernel session.
*/
-int event_kernel_disable_tracepoint(struct ltt_kernel_channel *kchan,
+int event_kernel_disable_event(struct ltt_kernel_channel *kchan,
char *event_name)
{
int ret;
assert(kchan);
- kevent = trace_kernel_get_event_by_name(event_name, kchan);
+ kevent = trace_kernel_get_event_by_name(event_name, kchan,
+ LTTNG_EVENT_ALL);
if (kevent == NULL) {
ret = LTTNG_ERR_NO_EVENT;
goto error;
return ret;
}
-/*
- * Enable kernel system call for a channel from the kernel session.
- */
-int event_kernel_enable_syscall(struct ltt_kernel_channel *kchan,
- char *syscall_name)
-{
- int ret;
-
- assert(kchan);
-
- ret = kernel_enable_syscall(syscall_name, kchan);
- if (ret < 0) {
- ret = LTTNG_ERR_KERN_ENABLE_FAIL;
- goto error;
- }
-
- DBG("Kernel syscall %s enable for channel %s.",
- syscall_name, kchan->channel->name);
-
- ret = LTTNG_OK;
-
-error:
- return ret;
-}
-
-/*
- * Disable kernel system call for a channel from the kernel session.
- */
-int event_kernel_disable_syscall(struct ltt_kernel_channel *kchan,
- char *syscall_name)
-{
- int ret;
-
- assert(kchan);
-
- ret = kernel_disable_syscall(syscall_name, kchan);
- if (ret < 0) {
- ret = LTTNG_ERR_KERN_DISABLE_FAIL;
- goto error;
- }
-
- DBG("Kernel syscall %s disable for channel %s.",
- !strcmp(syscall_name, "*") ? "<all>" : syscall_name,
- kchan->channel->name);
-
- ret = LTTNG_OK;
-
-error:
- return ret;
-}
-
/*
* Disable kernel tracepoint events for a channel from the kernel session.
*/
-int event_kernel_disable_all_tracepoints(struct ltt_kernel_channel *kchan)
+int event_kernel_disable_event_type(struct ltt_kernel_channel *kchan,
+ enum lttng_event_type type)
{
int ret;
struct ltt_kernel_event *kevent;
/* For each event in the kernel session */
cds_list_for_each_entry(kevent, &kchan->events_list.head, list) {
+ if (type != LTTNG_EVENT_ALL && kevent->type != type)
+ continue;
ret = kernel_disable_event(kevent);
if (ret < 0) {
/* We continue disabling the rest */
/*
* Disable all kernel event for a channel from the kernel session.
*/
-int event_kernel_disable_all(struct ltt_kernel_channel *kchan)
+int event_kernel_disable_event_all(struct ltt_kernel_channel *kchan)
{
- int ret;
-
- assert(kchan);
-
- ret = event_kernel_disable_all_tracepoints(kchan);
- if (ret != LTTNG_OK)
- return ret;
- ret = event_kernel_disable_syscall(kchan, "*");
- return ret;
+ return event_kernel_disable_event_type(kchan, LTTNG_EVENT_ALL);
}
/*
* Enable kernel tracepoint event for a channel from the kernel session.
* We own filter_expression and filter.
*/
-int event_kernel_enable_tracepoint(struct ltt_kernel_channel *kchan,
+int event_kernel_enable_event(struct ltt_kernel_channel *kchan,
struct lttng_event *event)
{
int ret;
assert(kchan);
assert(event);
- kevent = trace_kernel_get_event_by_name(event->name, kchan);
+ kevent = trace_kernel_get_event_by_name(event->name, kchan,
+ event->type);
if (kevent == NULL) {
ret = kernel_create_event(event, kchan);
if (ret < 0) {
#include "agent.h"
#include "trace-kernel.h"
-int event_kernel_disable_tracepoint(struct ltt_kernel_channel *kchan,
+int event_kernel_disable_event(struct ltt_kernel_channel *kchan,
char *event_name);
-int event_kernel_disable_syscall(struct ltt_kernel_channel *kchan,
- char *syscall_name);
-int event_kernel_disable_all_tracepoints(struct ltt_kernel_channel *kchan);
-int event_kernel_disable_all(struct ltt_kernel_channel *kchan);
+int event_kernel_disable_event_type(struct ltt_kernel_channel *kchan,
+ enum lttng_event_type type);
+int event_kernel_disable_event_all(struct ltt_kernel_channel *kchan);
-int event_kernel_enable_tracepoint(struct ltt_kernel_channel *kchan,
+int event_kernel_enable_event(struct ltt_kernel_channel *kchan,
struct lttng_event *event);
-int event_kernel_enable_syscall(struct ltt_kernel_channel *kchan,
- char *syscall_name);
int event_ust_enable_tracepoint(struct ltt_ust_session *usess,
struct ltt_ust_channel *uchan, struct lttng_event *event,
goto free_event;
}
- /*
- * LTTNG_KERNEL_SYSCALL event creation will return 0 on success.
- */
- if (ret == 0 && event->event->instrumentation == LTTNG_KERNEL_SYSCALL) {
- DBG2("Kernel event syscall creation success");
- /*
- * We use fd == -1 to ensure that we never trigger a close of fd
- * 0.
- */
- event->fd = -1;
- goto add_list;
- }
-
+ event->type = ev->type;
event->fd = ret;
/* Prevent fd duplication after execlp() */
ret = fcntl(event->fd, F_SETFD, FD_CLOEXEC);
PERROR("fcntl session fd");
}
-add_list:
/* Add event to event list */
cds_list_add(&event->list, &channel->events_list.head);
channel->event_count++;
return ret;
}
-int kernel_enable_syscall(const char *syscall_name,
- struct ltt_kernel_channel *channel)
-{
- return kernctl_enable_syscall(channel->fd, syscall_name);
-}
-
-int kernel_disable_syscall(const char *syscall_name,
- struct ltt_kernel_channel *channel)
-{
- return kernctl_disable_syscall(channel->fd, syscall_name);
-}
int kernel_track_pid(struct ltt_kernel_session *session, int pid)
{
int kernel_disable_event(struct ltt_kernel_event *event);
int kernel_enable_event(struct ltt_kernel_event *event);
int kernel_enable_channel(struct ltt_kernel_channel *chan);
-int kernel_enable_syscall(const char *syscall_name,
- struct ltt_kernel_channel *channel);
-int kernel_disable_syscall(const char *syscall_name,
- struct ltt_kernel_channel *channel);
int kernel_track_pid(struct ltt_kernel_session *session, int pid);
int kernel_untrack_pid(struct ltt_kernel_session *session, int pid);
int kernel_open_metadata(struct ltt_kernel_session *session);
* Find the event name for the given channel.
*/
struct ltt_kernel_event *trace_kernel_get_event_by_name(
- char *name, struct ltt_kernel_channel *channel)
+ char *name, struct ltt_kernel_channel *channel,
+ enum lttng_event_type type)
{
struct ltt_kernel_event *ev;
assert(channel);
cds_list_for_each_entry(ev, &channel->events_list.head, list) {
+ if (type != LTTNG_EVENT_ALL && ev->type != type)
+ continue;
if (strcmp(name, ev->event->name) == 0) {
DBG("Found event by name %s for channel %s", name,
channel->channel->name);
struct ltt_kernel_event {
int fd;
int enabled;
+ enum lttng_event_type type;
struct lttng_kernel_event *event;
struct cds_list_head list;
};
* Lookup functions. NULL is returned if not found.
*/
struct ltt_kernel_event *trace_kernel_get_event_by_name(
- char *name, struct ltt_kernel_channel *channel);
+ char *name, struct ltt_kernel_channel *channel,
+ enum lttng_event_type type);
struct ltt_kernel_channel *trace_kernel_get_channel_by_name(
char *name, struct ltt_kernel_session *session);
return ioctl(fd, LTTNG_KERNEL_CHANNEL, &channel);
}
-int kernctl_enable_syscall(int fd, const char *syscall_name)
-{
- struct lttng_kernel_event event;
-
- memset(&event, 0, sizeof(event));
- strncpy(event.name, syscall_name, sizeof(event.name));
- event.name[sizeof(event.name) - 1] = '\0';
- event.instrumentation = LTTNG_KERNEL_SYSCALL;
- event.u.syscall.enable = 1;
- return ioctl(fd, LTTNG_KERNEL_EVENT, &event);
-}
-
-int kernctl_disable_syscall(int fd, const char *syscall_name)
-{
- struct lttng_kernel_event event;
-
- memset(&event, 0, sizeof(event));
- strncpy(event.name, syscall_name, sizeof(event.name));
- event.name[sizeof(event.name) - 1] = '\0';
- event.instrumentation = LTTNG_KERNEL_SYSCALL;
- event.u.syscall.enable = 0;
- return ioctl(fd, LTTNG_KERNEL_EVENT, &event);
-}
-
int kernctl_syscall_mask(int fd, char **syscall_mask, uint32_t *nr_bits)
{
struct lttng_kernel_syscall_mask kmask_len, *kmask = NULL;
int kernctl_wait_quiescent(int fd);
int kernctl_calibrate(int fd, struct lttng_kernel_calibrate *calibrate);
-int kernctl_enable_syscall(int fd, const char *syscall_name);
-int kernctl_disable_syscall(int fd, const char *syscall_name);
-
/*
* kernctl_syscall_mask - Get syscall mask associated to a channel FD.
*
char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN];
} LTTNG_PACKED;
-struct lttng_kernel_syscall {
- char enable;
-} __attribute__((packed));
-
#define LTTNG_KERNEL_EVENT_PADDING1 16
#define LTTNG_KERNEL_EVENT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32
struct lttng_kernel_event {
struct lttng_kernel_kretprobe kretprobe;
struct lttng_kernel_kprobe kprobe;
struct lttng_kernel_function ftrace;
- struct lttng_kernel_syscall syscall;
char padding[LTTNG_KERNEL_EVENT_PADDING2];
} u;
} LTTNG_PACKED;