Support lttng-modules syscall wildcards
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 5 Nov 2014 00:14:19 +0000 (19:14 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 5 Nov 2014 00:14:19 +0000 (19:14 -0500)
While we are there, fix semantic issues with disable-event and various
types of instrumentation.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/event.c
src/bin/lttng-sessiond/event.h
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/kernel.h
src/bin/lttng-sessiond/trace-kernel.c
src/bin/lttng-sessiond/trace-kernel.h
src/common/kernel-ctl/kernel-ctl.c
src/common/kernel-ctl/kernel-ctl.h
src/common/lttng-kernel.h

index 31c3aff77d175571a44a1f0cfdc6befdb9a6c936..7eea28121e3e55394c67fc96ad484d4574b5f4da 100644 (file)
@@ -1167,23 +1167,28 @@ int cmd_disable_event(struct ltt_session *session, int domain,
 
                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;
                        }
@@ -1481,7 +1486,7 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
                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. */
@@ -1490,7 +1495,7 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
                                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;
                        }
@@ -1500,7 +1505,7 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
                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. */
@@ -1510,7 +1515,7 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
                        }
                        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;
                        }
index 564cbb784f463f2f48e4539bba70759c28e96381..0efdc9253d59adc98da8508c8909b9a6d9e58f06 100644 (file)
@@ -61,7 +61,7 @@ static void add_unique_ust_event(struct lttng_ht *ht,
 /*
  * 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;
@@ -69,7 +69,8 @@ int event_kernel_disable_tracepoint(struct ltt_kernel_channel *kchan,
 
        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;
@@ -90,61 +91,11 @@ 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;
@@ -153,6 +104,8 @@ int event_kernel_disable_all_tracepoints(struct ltt_kernel_channel *kchan)
 
        /* 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 */
@@ -166,24 +119,16 @@ int event_kernel_disable_all_tracepoints(struct ltt_kernel_channel *kchan)
 /*
  * 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;
@@ -192,7 +137,8 @@ int event_kernel_enable_tracepoint(struct ltt_kernel_channel *kchan,
        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) {
index 4fa44560e628d833dcf7befcc1b013d7d4efbc4d..536b2be707d05dd4feb6483575109db718d8faf2 100644 (file)
 #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,
index 59d86f45ae1b399866d8656228cedb9c49ce5a37..bf9f8b623288eb2e7eb58652bb5f26493ecf399e 100644 (file)
@@ -209,19 +209,7 @@ int kernel_create_event(struct lttng_event *ev,
                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);
@@ -229,7 +217,6 @@ int kernel_create_event(struct lttng_event *ev,
                PERROR("fcntl session fd");
        }
 
-add_list:
        /* Add event to event list */
        cds_list_add(&event->list, &channel->events_list.head);
        channel->event_count++;
@@ -355,17 +342,6 @@ error:
        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)
 {
index a2d19f1434102e2d15b1ce790c28b9f43e42e2f1..2f7cc15fb285c8b1316949ec0929075e434e6c6e 100644 (file)
@@ -42,10 +42,6 @@ int kernel_disable_channel(struct ltt_kernel_channel *chan);
 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);
index 1069d1f8fcb2e6f23b0d81df6c0d8c243f4c4f5e..ab3282a17f189b9c7b288fab65a5dd224f38fe2b 100644 (file)
@@ -62,7 +62,8 @@ struct ltt_kernel_channel *trace_kernel_get_channel_by_name(
  * 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;
 
@@ -70,6 +71,8 @@ struct ltt_kernel_event *trace_kernel_get_event_by_name(
        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);
index db91b2ed24cd57191e92a32376f0bc94e6b47482..5c518135d0144b71aef0369f8f4527e84d92ebb2 100644 (file)
@@ -51,6 +51,7 @@ struct ltt_kernel_context {
 struct ltt_kernel_event {
        int fd;
        int enabled;
+       enum lttng_event_type type;
        struct lttng_kernel_event *event;
        struct cds_list_head list;
 };
@@ -122,7 +123,8 @@ struct ltt_kernel_session {
  * 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);
 
index c6ff5c4457bd362b25a8203567db906d6c34cc37..51d01341338441bc3faffbf5f3d9fb5c52b29486 100644 (file)
@@ -142,30 +142,6 @@ int kernctl_create_channel(int fd, struct lttng_channel_attr *chops)
        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;
index 5f2e014d19c0b3cc984bdf2a8b2f6fb95894a227..d8e69809e97fa22bb51f21adbaf9f0bba91c6e55 100644 (file)
@@ -42,9 +42,6 @@ int kernctl_tracer_abi_version(int fd, struct lttng_kernel_tracer_abi_version *v
 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.
  *
index abd22c99b5a42c011f5d9915ed73340bbe41bac6..8336248427e66b28c84000d6dbe853f868941065 100644 (file)
@@ -97,10 +97,6 @@ struct lttng_kernel_function {
        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 {
@@ -113,7 +109,6 @@ 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;
This page took 0.033102 seconds and 4 git commands to generate.