From: Francis Deslauriers Date: Fri, 29 Jun 2018 18:16:25 +0000 (-0400) Subject: Implement 2-step registration of userspace probe events X-Git-Tag: v2.11.0-rc1~75 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=1ab8c2ad460ea71dd6d1580d6b69fb0cf68ce9ad;p=lttng-tools.git Implement 2-step registration of userspace probe events 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 Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index c5c7564b6..fa7aa82bd 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -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; } diff --git a/src/common/kernel-ctl/kernel-ctl.c b/src/common/kernel-ctl/kernel-ctl.c index a495ca9b7..047d40a34 100644 --- a/src/common/kernel-ctl/kernel-ctl.c +++ b/src/common/kernel-ctl/kernel-ctl.c @@ -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, diff --git a/src/common/kernel-ctl/kernel-ctl.h b/src/common/kernel-ctl/kernel-ctl.h index fbb273190..841c31da0 100644 --- a/src/common/kernel-ctl/kernel-ctl.h +++ b/src/common/kernel-ctl/kernel-ctl.h @@ -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); diff --git a/src/common/kernel-ctl/kernel-ioctl.h b/src/common/kernel-ctl/kernel-ioctl.h index 4ab0eabbc..e7ff50b24 100644 --- a/src/common/kernel-ctl/kernel-ioctl.h +++ b/src/common/kernel-ctl/kernel-ioctl.h @@ -163,5 +163,6 @@ /* Event FD ioctl */ #define LTTNG_KERNEL_FILTER _IO(0xF6, 0x90) +#define LTTNG_KERNEL_ADD_CALLSITE _IO(0xF6, 0x91) #endif /* _LTT_KERNEL_IOCTL_H */ diff --git a/src/common/lttng-kernel.h b/src/common/lttng-kernel.h index 922da33c8..cd1a15f67 100644 --- a/src/common/lttng-kernel.h +++ b/src/common/lttng-kernel.h @@ -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;