Branch data Line data Source code
1 : : /*
2 : : * Copyright (c) 2004-2007 Ulrich Drepper <drepper@redhat.com>
3 : : * Copyright (c) 2004 Roland McGrath <roland@redhat.com>
4 : : * Copyright (c) 2005-2015 Dmitry V. Levin <ldv@altlinux.org>
5 : : * Copyright (c) 2015-2017 The strace developers.
6 : : * All rights reserved.
7 : : *
8 : : * Redistribution and use in source and binary forms, with or without
9 : : * modification, are permitted provided that the following conditions
10 : : * are met:
11 : : * 1. Redistributions of source code must retain the above copyright
12 : : * notice, this list of conditions and the following disclaimer.
13 : : * 2. Redistributions in binary form must reproduce the above copyright
14 : : * notice, this list of conditions and the following disclaimer in the
15 : : * documentation and/or other materials provided with the distribution.
16 : : * 3. The name of the author may not be used to endorse or promote products
17 : : * derived from this software without specific prior written permission.
18 : : *
19 : : * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 : : * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 : : * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 : : * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 : : * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 : : * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 : : * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 : : * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 : : * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 : : * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 : : */
30 : :
31 : : #include "defs.h"
32 : : #include <fcntl.h>
33 : : #include <sys/epoll.h>
34 : :
35 : 2 : SYS_FUNC(epoll_create)
36 : : {
37 : 2 : tprintf("%d", (int) tcp->u_arg[0]);
38 : :
39 : 2 : return RVAL_DECODED | RVAL_FD;
40 : : }
41 : :
42 : : #include "xlat/epollflags.h"
43 : :
44 : 4 : SYS_FUNC(epoll_create1)
45 : : {
46 : 4 : printflags(epollflags, tcp->u_arg[0], "EPOLL_???");
47 : :
48 : 4 : return RVAL_DECODED | RVAL_FD;
49 : : }
50 : :
51 : : #include "xlat/epollevents.h"
52 : :
53 : : static bool
54 : 2 : print_epoll_event(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
55 : : {
56 : 2 : const struct epoll_event *ev = elem_buf;
57 : :
58 : 2 : tprints("{");
59 : 2 : printflags(epollevents, ev->events, "EPOLL???");
60 : : /* We cannot know what format the program uses, so print u32 and u64
61 : : which will cover every value. */
62 : 2 : tprintf(", {u32=%" PRIu32 ", u64=%" PRIu64 "}}",
63 : : ev->data.u32, ev->data.u64);
64 : :
65 : 2 : return true;
66 : : }
67 : :
68 : : #include "xlat/epollctls.h"
69 : :
70 : 6 : SYS_FUNC(epoll_ctl)
71 : : {
72 : 6 : printfd(tcp, tcp->u_arg[0]);
73 : 6 : tprints(", ");
74 : 6 : const unsigned int op = tcp->u_arg[1];
75 : : printxval(epollctls, op, "EPOLL_CTL_???");
76 : 6 : tprints(", ");
77 : 6 : printfd(tcp, tcp->u_arg[2]);
78 : 6 : tprints(", ");
79 : : struct epoll_event ev;
80 [ + + ]: 6 : if (EPOLL_CTL_DEL == op)
81 : 2 : printaddr(tcp->u_arg[3]);
82 [ + + ]: 4 : else if (!umove_or_printaddr(tcp, tcp->u_arg[3], &ev))
83 : 2 : print_epoll_event(tcp, &ev, sizeof(ev), 0);
84 : :
85 : 6 : return RVAL_DECODED;
86 : : }
87 : :
88 : : static void
89 : 8 : epoll_wait_common(struct tcb *tcp)
90 : : {
91 [ + + ]: 8 : if (entering(tcp)) {
92 : 4 : printfd(tcp, tcp->u_arg[0]);
93 : 4 : tprints(", ");
94 : : } else {
95 : : struct epoll_event ev;
96 : 4 : print_array(tcp, tcp->u_arg[1], tcp->u_rval, &ev, sizeof(ev),
97 : : umoven_or_printaddr, print_epoll_event, 0);
98 : 4 : tprintf(", %d, %d", (int) tcp->u_arg[2], (int) tcp->u_arg[3]);
99 : : }
100 : 8 : }
101 : :
102 : 4 : SYS_FUNC(epoll_wait)
103 : : {
104 : 4 : epoll_wait_common(tcp);
105 : 4 : return 0;
106 : : }
107 : :
108 : 4 : SYS_FUNC(epoll_pwait)
109 : : {
110 : 4 : epoll_wait_common(tcp);
111 [ + + ]: 4 : if (exiting(tcp)) {
112 : 2 : tprints(", ");
113 : : /* NB: kernel requires arg[5] == NSIG_BYTES */
114 : 2 : print_sigset_addr_len(tcp, tcp->u_arg[4], tcp->u_arg[5]);
115 : 2 : tprintf(", %" PRI_klu, tcp->u_arg[5]);
116 : : }
117 : 4 : return 0;
118 : : }
|