Implement detailed syscall event probe
[lttng-modules.git] / ltt-debugfs-abi.c
index cfc364a844635f1476a17e7e7c794b73478f6017..81afdbdbae28f13459fc84f9e3ed7dbe97137945 100644 (file)
@@ -220,6 +220,20 @@ long lttng_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        case LTTNG_KERNEL_WAIT_QUIESCENT:
                synchronize_trace();
                return 0;
+       case LTTNG_KERNEL_CALIBRATE:
+       {
+               struct lttng_kernel_calibrate __user *ucalibrate =
+                       (struct lttng_kernel_calibrate __user *) arg;
+               struct lttng_kernel_calibrate calibrate;
+               int ret;
+
+               if (copy_from_user(&calibrate, ucalibrate, sizeof(calibrate)))
+                       return -EFAULT;
+               ret = lttng_calibrate(&calibrate);
+               if (copy_to_user(ucalibrate, &calibrate, sizeof(calibrate)))
+                       return -EFAULT;
+               return ret;
+       }
        default:
                return -ENOIOCTLCMD;
        }
@@ -247,7 +261,6 @@ void lttng_metadata_create_events(struct file *channel_file)
                .name = "lttng_metadata",
        };
        struct ltt_event *event;
-       int ret;
 
        /*
         * We tolerate no failure path after event creation. It will stay
@@ -255,7 +268,6 @@ void lttng_metadata_create_events(struct file *channel_file)
         */
        event = ltt_event_create(channel, &metadata_params, NULL);
        if (!event) {
-               ret = -EINVAL;
                goto create_error;
        }
        return;
@@ -271,7 +283,7 @@ int lttng_abi_create_channel(struct file *session_file,
                             enum channel_type channel_type)
 {
        struct ltt_session *session = session_file->private_data;
-       const struct file_operations *fops;
+       const struct file_operations *fops = NULL;
        const char *transport_name;
        struct ltt_channel *chan;
        struct file *chan_file;
@@ -286,8 +298,17 @@ int lttng_abi_create_channel(struct file *session_file,
                ret = chan_fd;
                goto fd_error;
        }
+       switch (channel_type) {
+       case PER_CPU_CHANNEL:
+               fops = &lttng_channel_fops;
+               break;
+       case METADATA_CHANNEL:
+               fops = &lttng_metadata_fops;
+               break;
+       }
+               
        chan_file = anon_inode_getfile("[lttng_channel]",
-                                      &lttng_channel_fops,
+                                      fops,
                                       NULL, O_RDWR);
        if (IS_ERR(chan_file)) {
                ret = PTR_ERR(chan_file);
@@ -304,7 +325,6 @@ int lttng_abi_create_channel(struct file *session_file,
                } else {
                        return -EINVAL;
                }
-               fops = &lttng_channel_fops;
                break;
        case METADATA_CHANNEL:
                if (chan_param.output == LTTNG_KERNEL_SPLICE)
@@ -313,7 +333,6 @@ int lttng_abi_create_channel(struct file *session_file,
                        transport_name = "relay-metadata-mmap";
                else
                        return -EINVAL;
-               fops = &lttng_metadata_fops;
                break;
        default:
                transport_name = "<unknown>";
@@ -483,6 +502,9 @@ int lttng_abi_create_event(struct file *channel_file,
                return -EFAULT;
        event_param.name[LTTNG_SYM_NAME_LEN - 1] = '\0';
        switch (event_param.instrumentation) {
+       case LTTNG_KERNEL_KRETPROBE:
+               event_param.u.kretprobe.symbol_name[LTTNG_SYM_NAME_LEN - 1] = '\0';
+               break;
        case LTTNG_KERNEL_KPROBE:
                event_param.u.kprobe.symbol_name[LTTNG_SYM_NAME_LEN - 1] = '\0';
                break;
@@ -492,31 +514,41 @@ int lttng_abi_create_event(struct file *channel_file,
        default:
                break;
        }
-       event_fd = get_unused_fd();
-       if (event_fd < 0) {
-               ret = event_fd;
-               goto fd_error;
-       }
-       event_file = anon_inode_getfile("[lttng_event]",
-                                       &lttng_event_fops,
-                                       NULL, O_RDWR);
-       if (IS_ERR(event_file)) {
-               ret = PTR_ERR(event_file);
-               goto file_error;
-       }
-       /*
-        * We tolerate no failure path after event creation. It will stay
-        * invariant for the rest of the session.
-        */
-       event = ltt_event_create(channel, &event_param, NULL);
-       if (!event) {
-               ret = -EINVAL;
-               goto event_error;
+       switch (event_param.instrumentation) {
+       default:
+               event_fd = get_unused_fd();
+               if (event_fd < 0) {
+                       ret = event_fd;
+                       goto fd_error;
+               }
+               event_file = anon_inode_getfile("[lttng_event]",
+                                               &lttng_event_fops,
+                                               NULL, O_RDWR);
+               if (IS_ERR(event_file)) {
+                       ret = PTR_ERR(event_file);
+                       goto file_error;
+               }
+               /*
+                * We tolerate no failure path after event creation. It
+                * will stay invariant for the rest of the session.
+                */
+               event = ltt_event_create(channel, &event_param, NULL);
+               if (!event) {
+                       ret = -EINVAL;
+                       goto event_error;
+               }
+               event_file->private_data = event;
+               fd_install(event_fd, event_file);
+               /* The event holds a reference on the channel */
+               atomic_long_inc(&channel_file->f_count);
+               break;
+       case LTTNG_KERNEL_SYSCALLS:
+               ret = lttng_syscalls_register(channel, NULL);
+               if (ret)
+                       goto fd_error;
+               event_fd = 0;
+               break;
        }
-       event_file->private_data = event;
-       fd_install(event_fd, event_file);
-       /* The event holds a reference on the channel */
-       atomic_long_inc(&channel_file->f_count);
        return event_fd;
 
 event_error:
This page took 0.026946 seconds and 4 git commands to generate.