From d01c0e5606d656a1118348f693b3593554b1e58f Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 4 Jul 2018 16:15:07 -0400 Subject: [PATCH] trackers: update lttng-modules tracer ABI MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathieu Desnoyers Change-Id: I27e1e552b13b5a541b43ff250d1d4839e399f1f3 Signed-off-by: Jérémie Galarneau --- src/common/kernel-ctl/kernel-ctl.c | 61 ++++++++++++++++++++++++++++ src/common/kernel-ctl/kernel-ctl.h | 4 ++ src/common/kernel-ctl/kernel-ioctl.h | 8 ++++ src/common/lttng-kernel.h | 16 ++++++++ 4 files changed, 89 insertions(+) diff --git a/src/common/kernel-ctl/kernel-ctl.c b/src/common/kernel-ctl/kernel-ctl.c index 5f25adf02..1df6849a9 100644 --- a/src/common/kernel-ctl/kernel-ctl.c +++ b/src/common/kernel-ctl/kernel-ctl.c @@ -230,6 +230,67 @@ int kernctl_list_tracker_pids(int fd) return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS); } +static enum lttng_kernel_tracker_type get_kernel_tracker_type( + enum lttng_tracker_type type) +{ + switch (type) { + case LTTNG_TRACKER_PID: + return LTTNG_KERNEL_TRACKER_PID; + case LTTNG_TRACKER_VPID: + return LTTNG_KERNEL_TRACKER_VPID; + case LTTNG_TRACKER_UID: + return LTTNG_KERNEL_TRACKER_UID; + case LTTNG_TRACKER_VUID: + return LTTNG_KERNEL_TRACKER_VUID; + case LTTNG_TRACKER_GID: + return LTTNG_KERNEL_TRACKER_GID; + case LTTNG_TRACKER_VGID: + return LTTNG_KERNEL_TRACKER_VGID; + default: + return LTTNG_KERNEL_TRACKER_UNKNOWN; + } +} + +int kernctl_track_id(int fd, enum lttng_tracker_type tracker_type, int id) +{ + struct lttng_kernel_tracker_args args; + + args.id = id; + args.type = get_kernel_tracker_type(tracker_type); + if (args.type == LTTNG_KERNEL_TRACKER_UNKNOWN) { + errno = EINVAL; + return -1; + } + return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SESSION_TRACK_ID, &args); +} + +int kernctl_untrack_id(int fd, enum lttng_tracker_type tracker_type, int id) +{ + struct lttng_kernel_tracker_args args; + + args.id = id; + args.type = get_kernel_tracker_type(tracker_type); + if (args.type == LTTNG_KERNEL_TRACKER_UNKNOWN) { + errno = EINVAL; + return -1; + } + return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SESSION_UNTRACK_ID, &args); +} + +int kernctl_list_tracker_ids(int fd, enum lttng_tracker_type tracker_type) +{ + struct lttng_kernel_tracker_args args; + + args.id = -1; + args.type = get_kernel_tracker_type(tracker_type); + if (args.type == LTTNG_KERNEL_TRACKER_UNKNOWN) { + errno = EINVAL; + return -1; + } + return LTTNG_IOCTL_NO_CHECK( + fd, LTTNG_KERNEL_SESSION_LIST_TRACKER_IDS, &args); +} + int kernctl_session_regenerate_metadata(int fd) { return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SESSION_METADATA_REGEN); diff --git a/src/common/kernel-ctl/kernel-ctl.h b/src/common/kernel-ctl/kernel-ctl.h index fcaca84fe..a662ac90b 100644 --- a/src/common/kernel-ctl/kernel-ctl.h +++ b/src/common/kernel-ctl/kernel-ctl.h @@ -65,6 +65,10 @@ int kernctl_track_pid(int fd, int pid); int kernctl_untrack_pid(int fd, int pid); int kernctl_list_tracker_pids(int fd); +int kernctl_track_id(int fd, enum lttng_tracker_type tracker_type, int id); +int kernctl_untrack_id(int fd, enum lttng_tracker_type tracker_type, int id); +int kernctl_list_tracker_ids(int fd, enum lttng_tracker_type tracker_type); + int kernctl_session_regenerate_metadata(int fd); int kernctl_session_regenerate_statedump(int fd); int kernctl_session_set_name(int fd, const char *name); diff --git a/src/common/kernel-ctl/kernel-ioctl.h b/src/common/kernel-ctl/kernel-ioctl.h index f38f5dd67..4fef928d6 100644 --- a/src/common/kernel-ctl/kernel-ioctl.h +++ b/src/common/kernel-ctl/kernel-ioctl.h @@ -171,4 +171,12 @@ #define LTTNG_KERNEL_FILTER _IO(0xF6, 0x90) #define LTTNG_KERNEL_ADD_CALLSITE _IO(0xF6, 0x91) +/* Session FD ioctl (continued) */ +#define LTTNG_KERNEL_SESSION_LIST_TRACKER_IDS \ + _IOR(0xF6, 0xA0, struct lttng_kernel_tracker_args) +#define LTTNG_KERNEL_SESSION_TRACK_ID \ + _IOR(0xF6, 0xA1, struct lttng_kernel_tracker_args) +#define LTTNG_KERNEL_SESSION_UNTRACK_ID \ + _IOR(0xF6, 0xA2, struct lttng_kernel_tracker_args) + #endif /* _LTT_KERNEL_IOCTL_H */ diff --git a/src/common/lttng-kernel.h b/src/common/lttng-kernel.h index 4008b50cf..151137004 100644 --- a/src/common/lttng-kernel.h +++ b/src/common/lttng-kernel.h @@ -213,4 +213,20 @@ struct lttng_kernel_session_creation_time { char iso8601[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN]; } LTTNG_PACKED; +enum lttng_kernel_tracker_type { + LTTNG_KERNEL_TRACKER_UNKNOWN = -1, + + LTTNG_KERNEL_TRACKER_PID = 0, + LTTNG_KERNEL_TRACKER_VPID = 1, + LTTNG_KERNEL_TRACKER_UID = 2, + LTTNG_KERNEL_TRACKER_VUID = 3, + LTTNG_KERNEL_TRACKER_GID = 4, + LTTNG_KERNEL_TRACKER_VGID = 5, +}; + +struct lttng_kernel_tracker_args { + enum lttng_kernel_tracker_type type; + int32_t id; +}; + #endif /* _LTTNG_KERNEL_H */ -- 2.34.1