From: jdesfossez@efficios.com (Julien Desfossez)
Subject: [lttng-dev] [PATCH lttng-modules v7 4/5] Extract the payload for epoll_ctl
Date: Sat, 30 Apr 2016 11:09:29 -0400 [thread overview]
Message-ID: <1462028970-16870-5-git-send-email-jdesfossez@efficios.com> (raw)
In-Reply-To: <1462028970-16870-1-git-send-email-jdesfossez@efficios.com>
Map the operation to its name (EPOLL_CTL_*), extract the standard event
flags (EPOLL*) and output the data in two different formats: FD as an
int in decimal, and u64 in hex. The less standard event flags are not
extracted yet, but we extract the raw value in hex for more advanced
analyses.
Here is an example output:
syscall_entry_epoll_ctl: {
epfd = 4, op_enum = ( "EPOLL_CTL_ADD" : container = 1 ),
fd = 0, event = { raw_events = 0x80000003,
events = { EPOLLIN = 1, EPOLLPRI = 1, EPOLLOUT = 0, EPOLLERR = 0,
padding = 0 },
data_union = { u64 = 0x0, fd = 0 } }
}
syscall_exit_epoll_ctl: { ret = 0 }
Signed-off-by: Julien Desfossez <jdesfossez at efficios.com>
---
| 140 +++++++++++++++++++++
1 file changed, 140 insertions(+)
--git a/instrumentation/syscalls/headers/syscalls_pointers_override.h b/instrumentation/syscalls/headers/syscalls_pointers_override.h
index 2ffe814..636287f 100644
--- a/instrumentation/syscalls/headers/syscalls_pointers_override.h
+++ b/instrumentation/syscalls/headers/syscalls_pointers_override.h
@@ -555,4 +555,144 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(ppoll,
)
#endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
+#include <linux/eventpoll.h>
+
+SC_LTTNG_TRACEPOINT_ENUM(lttng_epoll_op,
+ TP_ENUM_VALUES(
+ ctf_enum_value("EPOLL_CTL_ADD", EPOLL_CTL_ADD)
+ ctf_enum_value("EPOLL_CTL_DEL", EPOLL_CTL_DEL)
+ ctf_enum_value("EPOLL_CTL_MOD", EPOLL_CTL_MOD)
+ )
+)
+
+#ifndef ONCE_LTTNG_TRACE_EPOLL_CTL_H
+#define ONCE_LTTNG_TRACE_EPOLL_CTL_H
+
+#define LTTNG_EPOLL_NRFLAGS (POLLHUP + 1)
+#define EPOLL_FLAGS_PADDING_SIZE (sizeof(uint8_t) * BITS_PER_BYTE) - \
+ ilog2(LTTNG_EPOLL_NRFLAGS - 1)
+
+/*
+ * Only extract the values specified by iBCS2 for now.
+ */
+static struct lttng_event_field lttng_epoll_ctl_events_fields[] = {
+ /* 0x0001 */
+ [ilog2(POLLIN)] = {
+ .name = "EPOLLIN",
+ .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
+ },
+ /* 0x0002 */
+ [ilog2(POLLPRI)] = {
+ .name = "EPOLLPRI",
+ .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
+ },
+ /* 0x0004 */
+ [ilog2(POLLOUT)] = {
+ .name = "EPOLLOUT",
+ .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
+ },
+ /* 0x0008 */
+ [ilog2(POLLERR)] = {
+ .name = "EPOLLERR",
+ .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
+ },
+ /* 0x0010 */
+ [ilog2(POLLHUP)] = {
+ .name = "EPOLLHUP",
+ .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
+ },
+ [ilog2(LTTNG_EPOLL_NRFLAGS)] = {
+ .name = "padding",
+ .type = __type_integer(int, EPOLL_FLAGS_PADDING_SIZE, 1, 0,
+ __LITTLE_ENDIAN, 10, none),
+ },
+
+};
+
+static struct lttng_event_field lttng_epoll_data_fields[] = {
+ [0] = {
+ .name = "u64",
+ .type = __type_integer(uint64_t, 0, 0, 0, __BYTE_ORDER, 16, none),
+ },
+ [1] = {
+ .name = "fd",
+ .type = __type_integer(int, 0, 0, 0, __BYTE_ORDER, 10, none),
+ },
+};
+
+static struct lttng_event_field epoll_ctl_fields[] = {
+ [0] = {
+ .name = "data_union",
+ .type = {
+ .atype = atype_struct,
+ .u._struct.nr_fields = ARRAY_SIZE(lttng_epoll_data_fields),
+ .u._struct.fields = lttng_epoll_data_fields,
+ }
+ },
+ [1] = {
+ .name = "raw_events",
+ .type = __type_integer(uint32_t, 0, 0, 0, __BYTE_ORDER, 16, none),
+ },
+ [2] = {
+ .name = "events",
+ .type = {
+ .atype = atype_struct,
+ .u._struct.nr_fields = ARRAY_SIZE(lttng_epoll_ctl_events_fields),
+ .u._struct.fields = lttng_epoll_ctl_events_fields,
+ }
+ },
+};
+#endif /* ONCE_LTTNG_TRACE_EPOLL_CTL_H */
+
+#if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
+#define OVERRIDE_32_epoll_ctl
+#define OVERRIDE_64_epoll_ctl
+SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_ctl,
+ TP_PROTO(sc_exit(long ret,) int epfd, int op, int fd,
+ struct epoll_event __user * uevent),
+ TP_ARGS(sc_exit(ret,) epfd, op, fd, uevent),
+ TP_locvar(
+ struct epoll_event event;
+ int err;
+ ),
+ TP_code_pre(
+ tp_locvar->err = lib_ring_buffer_copy_from_user_check_nofault(
+ &tp_locvar->event, uevent, sizeof(struct epoll_event));
+ ),
+ TP_FIELDS(
+ sc_exit(ctf_integer(long, ret, ret))
+ sc_in(ctf_integer(int, epfd, epfd))
+ sc_in(ctf_enum(lttng_epoll_op, int, op_enum, op))
+ sc_in(ctf_integer(int, fd, fd))
+ sc_in(
+ ctf_custom_field(
+ ctf_custom_type(
+ .atype = atype_struct,
+ .u._struct.nr_fields = ARRAY_SIZE(epoll_ctl_fields),
+ .u._struct.fields = epoll_ctl_fields,
+ ),
+ event,
+ ctf_custom_code(
+ ctf_align(uint64_t)
+ if (!tp_locvar->err) {
+ ctf_integer_type(uint64_t, tp_locvar->event.data)
+ ctf_integer_type(int, tp_locvar->event.data)
+ ctf_integer_bitfield_type(uint32_t,
+ tp_locvar->event.events)
+ ctf_integer_bitfield_type(uint8_t,
+ (uint8_t) tp_locvar->event.events)
+ } else {
+ ctf_integer_type(uint64_t, 0)
+ ctf_integer_type(int, 0)
+ ctf_integer_bitfield_type(uint32_t, 0)
+ ctf_integer_bitfield_type(uint8_t, 0)
+ }
+ )
+ )
+ )
+ ),
+ TP_code_post()
+)
+#endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
+
#endif /* CREATE_SYSCALL_TABLE */
--
1.9.1
next prev parent reply other threads:[~2016-04-30 15:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-30 15:09 [lttng-dev] [PATCH lttng-modules v7 0/5] Extract payload from polling syscalls Julien Desfossez
2016-04-30 15:09 ` [lttng-dev] [PATCH lttng-modules v7 1/5] Add ctf_integer_bitfield_type Julien Desfossez
2016-04-30 15:09 ` [lttng-dev] [PATCH lttng-modules v7 2/5] Extract the FD sets in select and pselect6 Julien Desfossez
2016-04-30 15:09 ` [lttng-dev] [PATCH lttng-modules v7 3/5] Extract the FDs and flags from poll and ppoll Julien Desfossez
2016-04-30 15:09 ` Julien Desfossez [this message]
2016-04-30 15:09 ` [lttng-dev] [PATCH lttng-modules v7 5/5] Extract the payload of epoll_wait/epoll_pwait Julien Desfossez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462028970-16870-5-git-send-email-jdesfossez@efficios.com \
--to=jdesfossez@efficios.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox