|
From: Nicholas N. <nj...@ca...> - 2004-02-10 23:44:36
|
CVS commit by nethercote:
Added support for epoll.
M +50 -1 coregrind/vg_syscalls.c 1.83
M +0 -1 coregrind/vg_unsafe.h 1.24
M +13 -0 include/vg_kerneliface.h 1.13
--- valgrind/coregrind/vg_syscalls.c #1.82:1.83
@@ -2129,5 +2129,5 @@ POST(fcntl)
{
if (arg2 == VKI_F_DUPFD)
- if(VG_(clo_track_fds))
+ if (VG_(clo_track_fds))
record_fd_open(tid, res, VG_(resolve_filename)(res));
}
@@ -3946,4 +3946,50 @@ POST(poll)
}
+PRE(epoll_create)
+{
+ /* int epoll_create(int size) */
+ MAYBE_PRINTF("epoll_create ( %d )\n", arg1);
+}
+
+POST(epoll_create)
+{
+ if (!fd_allowed(res, "open", tid)) {
+ VG_(close)(res);
+ res = -VKI_EMFILE;
+ } else {
+ if (VG_(clo_track_fds))
+ record_fd_open (tid, res, NULL);
+ }
+}
+
+PRE(epoll_ctl)
+{
+ /* int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) */
+ static const char* epoll_ctl_s[3] = {
+ "EPOLL_CTL_ADD",
+ "EPOLL_CTL_DEL",
+ "EPOLL_CTL_MOD"
+ };
+ MAYBE_PRINTF("epoll_ctl ( %d, %s, %d, %p )\n",
+ arg1, ( arg2<3 ? epoll_ctl_s[arg2] : "?" ), arg3, arg4);
+ SYSCALL_TRACK( pre_mem_read, tid, "epoll_ctl(event)",
+ arg4, sizeof(struct vki_epoll_event) );
+}
+
+PRE(epoll_wait)
+{
+ /* int epoll_wait(int epfd, struct epoll_event * events,
+ int maxevents, int timeout) */
+ MAYBE_PRINTF("epoll_wait ( %d, %p, %d, %d )\n", arg1, arg2, arg3, arg4);
+ SYSCALL_TRACK( pre_mem_write, tid, "epoll_wait(events)",
+ arg2, sizeof(struct vki_epoll_event)*arg3);
+}
+
+POST(epoll_wait)
+{
+ if (res > 0)
+ VG_TRACK( post_mem_write, arg2, sizeof(struct vki_epoll_event)*res ) ;
+}
+
PRE(readlink)
{
@@ -5202,4 +5248,7 @@ static const struct sys_info sys_info[]
SYSBA(pipe, False),
SYSBA(poll, True),
+ SYSBA(epoll_create, False),
+ SYSB_(epoll_ctl, False),
+ SYSBA(epoll_wait, True),
SYSBA(readlink, False),
SYSBA(readv, True),
--- valgrind/include/vg_kerneliface.h #1.12:1.13
@@ -510,4 +510,17 @@ struct vki_pollfd {
+/* sys/epoll.h */
+typedef union vki_epoll_data {
+ void *ptr;
+ Int fd;
+ UInt u32;
+ ULong u64;
+} vki_epoll_data_t;
+
+struct vki_epoll_event {
+ UInt events; /* Epoll events */
+ vki_epoll_data_t data; /* User data variable */
+};
+
/*
|