Implement 2-step registration of userspace probe events
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 29 Jun 2018 18:16:25 +0000 (14:16 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 24 Aug 2018 19:59:44 +0000 (15:59 -0400)
Userspace-probe registration is implemented in a 2-step process. The two
steps registration is necessary because a userspace-probe event can have
an arbitrary number of call sites.

The first step is registering the event through the existing
LTTNG_KERNEL_EVENT command on the channel ioctl FD. This creates an
event with no callsites and thus no instrumentation at all.

The second step is attaching callsites to the event. It's done through
the new LTTNG_KERNEL_ADD_CALLSITE command on the event ioctl FD
received during the first step.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/cmd.c
src/common/kernel-ctl/kernel-ctl.c
src/common/kernel-ctl/kernel-ctl.h
src/common/kernel-ctl/kernel-ioctl.h
src/common/lttng-kernel.h

index c5c7564b69afd9f01a36c1b402d9ec39b8fe1937..fa7aa82bd540fc1227076f665ff6d24fd27b4b57 100644 (file)
@@ -712,6 +712,8 @@ static int list_lttng_kernel_events(char *channel_name,
                        (*events)[i].type = LTTNG_EVENT_SYSCALL;
                        break;
                case LTTNG_KERNEL_ALL:
+                       /* fall-through. */
+               default:
                        assert(0);
                        break;
                }
index a495ca9b705bee48c94d7d32c9b602cbc9a48a7f..047d40a34d80ea611ff940a78efdb26ebf9127bd 100644 (file)
@@ -350,6 +350,11 @@ int kernctl_filter(int fd, struct lttng_filter_bytecode *filter)
        return ret;
 }
 
+int kernctl_add_callsite(int fd, struct lttng_kernel_event_callsite *callsite)
+{
+       return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ADD_CALLSITE, callsite);
+}
+
 int kernctl_tracepoint_list(int fd)
 {
        return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_TRACEPOINT_LIST,
index fbb273190cf56aaf8477c75fb8161128de977efb..841c31da0d4c17d0fe353e32b0b73c73e0e3d65b 100644 (file)
@@ -38,6 +38,7 @@ int kernctl_stop_session(int fd);
 
 /* Apply on event FD */
 int kernctl_filter(int fd, struct lttng_filter_bytecode *filter);
+int kernctl_add_callsite(int fd, struct lttng_kernel_event_callsite *callsite);
 
 int kernctl_tracepoint_list(int fd);
 int kernctl_syscall_list(int fd);
index 4ab0eabbc140f757e9af4aedb15ef43b25458536..e7ff50b24349e0f152856a30177f36b6cbebb8f3 100644 (file)
 
 /* Event FD ioctl */
 #define LTTNG_KERNEL_FILTER                    _IO(0xF6, 0x90)
+#define LTTNG_KERNEL_ADD_CALLSITE      _IO(0xF6, 0x91)
 
 #endif /* _LTT_KERNEL_IOCTL_H */
index 922da33c84108a71c7ddee04b5ebfcce61b20934..cd1a15f67cf256fb66c63edd2517acb1d9e683c8 100644 (file)
@@ -42,6 +42,7 @@ enum lttng_kernel_instrumentation {
        LTTNG_KERNEL_KRETPROBE     = 3,
        LTTNG_KERNEL_NOOP          = 4,    /* not hooked */
        LTTNG_KERNEL_SYSCALL       = 5,
+       LTTNG_KERNEL_UPROBE        = 6,
 };
 
 enum lttng_kernel_context_type {
@@ -102,6 +103,20 @@ struct lttng_kernel_kprobe {
        char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN];
 } LTTNG_PACKED;
 
+struct lttng_kernel_uprobe {
+       int fd;
+} LTTNG_PACKED;
+
+struct lttng_kernel_event_callsite_uprobe {
+       uint64_t offset;
+} LTTNG_PACKED;
+
+struct lttng_kernel_event_callsite {
+       union {
+               struct lttng_kernel_event_callsite_uprobe uprobe;
+       } u;
+} LTTNG_PACKED;
+
 /* Function tracer */
 struct lttng_kernel_function {
        char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN];
@@ -118,6 +133,7 @@ struct lttng_kernel_event {
        union {
                struct lttng_kernel_kretprobe kretprobe;
                struct lttng_kernel_kprobe kprobe;
+               struct lttng_kernel_uprobe uprobe;
                struct lttng_kernel_function ftrace;
                char padding[LTTNG_KERNEL_EVENT_PADDING2];
        } u;
This page took 0.029324 seconds and 4 git commands to generate.