Branch data Line data Source code
1 : : /*
2 : : * Copyright (c) 2002-2003 Roland McGrath <roland@redhat.com>
3 : : * Copyright (c) 2007-2008 Ulrich Drepper <drepper@redhat.com>
4 : : * Copyright (c) 2009 Andreas Schwab <schwab@redhat.com>
5 : : * Copyright (c) 2014-2015 Dmitry V. Levin <ldv@altlinux.org>
6 : : * Copyright (c) 2014-2017 The strace developers.
7 : : * All rights reserved.
8 : : *
9 : : * Redistribution and use in source and binary forms, with or without
10 : : * modification, are permitted provided that the following conditions
11 : : * are met:
12 : : * 1. Redistributions of source code must retain the above copyright
13 : : * notice, this list of conditions and the following disclaimer.
14 : : * 2. Redistributions in binary form must reproduce the above copyright
15 : : * notice, this list of conditions and the following disclaimer in the
16 : : * documentation and/or other materials provided with the distribution.
17 : : * 3. The name of the author may not be used to endorse or promote products
18 : : * derived from this software without specific prior written permission.
19 : : *
20 : : * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 : : * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 : : * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 : : * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 : : * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 : : * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 : : * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 : : * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 : : * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 : : * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 : : */
31 : :
32 : : #include "defs.h"
33 : :
34 : : #ifndef FUTEX_PRIVATE_FLAG
35 : : # define FUTEX_PRIVATE_FLAG 128
36 : : #endif
37 : : #ifndef FUTEX_CLOCK_REALTIME
38 : : # define FUTEX_CLOCK_REALTIME 256
39 : : #endif
40 : :
41 : : #include "xlat/futexops.h"
42 : : #include "xlat/futexwakeops.h"
43 : : #include "xlat/futexwakecmps.h"
44 : :
45 : 444 : SYS_FUNC(futex)
46 : : {
47 : 444 : const kernel_ulong_t uaddr = tcp->u_arg[0];
48 : 444 : const int op = tcp->u_arg[1];
49 : 444 : const int cmd = op & 127;
50 : 444 : const kernel_ulong_t timeout = tcp->u_arg[3];
51 : 444 : const kernel_ulong_t uaddr2 = tcp->u_arg[4];
52 : 444 : const unsigned int val = tcp->u_arg[2];
53 : 444 : const unsigned int val2 = tcp->u_arg[3];
54 : 444 : const unsigned int val3 = tcp->u_arg[5];
55 : : const char *comment;
56 : :
57 : 444 : printaddr(uaddr);
58 : 444 : tprints(", ");
59 : 444 : printxval(futexops, op, "FUTEX_???");
60 [ + + + + : 444 : switch (cmd) {
+ + + + +
+ + ]
61 : : case FUTEX_WAIT:
62 : 36 : tprintf(", %u", val);
63 : 36 : tprints(", ");
64 : 36 : print_timespec(tcp, timeout);
65 : 36 : break;
66 : : case FUTEX_LOCK_PI:
67 : 16 : tprints(", ");
68 : 16 : print_timespec(tcp, timeout);
69 : 16 : break;
70 : : case FUTEX_WAIT_BITSET:
71 : 24 : tprintf(", %u", val);
72 : 24 : tprints(", ");
73 : 24 : print_timespec(tcp, timeout);
74 : 24 : tprintf(", %#x", val3);
75 : 24 : break;
76 : : case FUTEX_WAKE_BITSET:
77 : 20 : tprintf(", %u", val);
78 : 20 : tprintf(", %#x", val3);
79 : 20 : break;
80 : : case FUTEX_REQUEUE:
81 : 16 : tprintf(", %u", val);
82 : 16 : tprintf(", %u, ", val2);
83 : 16 : printaddr(uaddr2);
84 : 16 : break;
85 : : case FUTEX_CMP_REQUEUE:
86 : : case FUTEX_CMP_REQUEUE_PI:
87 : 40 : tprintf(", %u", val);
88 : 40 : tprintf(", %u, ", val2);
89 : 40 : printaddr(uaddr2);
90 : 40 : tprintf(", %u", val3);
91 : 40 : break;
92 : : case FUTEX_WAKE_OP:
93 : 200 : tprintf(", %u", val);
94 : 200 : tprintf(", %u, ", val2);
95 : 200 : printaddr(uaddr2);
96 : 200 : tprints(", ");
97 [ + + ]: 200 : if ((val3 >> 28) & 8)
98 : 40 : tprints("FUTEX_OP_OPARG_SHIFT<<28|");
99 : 400 : comment = printxval(futexwakeops, (val3 >> 28) & 0x7, NULL)
100 [ + + ]: 200 : ? NULL : "FUTEX_OP_???";
101 : 200 : tprints("<<28");
102 : 200 : tprints_comment(comment);
103 : 200 : tprintf("|%#x<<12|", (val3 >> 12) & 0xfff);
104 : 400 : comment = printxval(futexwakecmps, (val3 >> 24) & 0xf, NULL)
105 [ + + ]: 200 : ? NULL : "FUTEX_OP_CMP_???";
106 : 200 : tprints("<<24");
107 : 200 : tprints_comment(comment);
108 : 200 : tprintf("|%#x", val3 & 0xfff);
109 : 200 : break;
110 : : case FUTEX_WAIT_REQUEUE_PI:
111 : 16 : tprintf(", %u", val);
112 : 16 : tprints(", ");
113 : 16 : print_timespec(tcp, timeout);
114 : 16 : tprints(", ");
115 : 16 : printaddr(uaddr2);
116 : 16 : break;
117 : : case FUTEX_FD:
118 : : case FUTEX_WAKE:
119 : 36 : tprintf(", %u", val);
120 : 36 : break;
121 : : case FUTEX_UNLOCK_PI:
122 : : case FUTEX_TRYLOCK_PI:
123 : : break;
124 : : default:
125 : 8 : tprintf(", %u", val);
126 : 8 : tprints(", ");
127 : 8 : printaddr(timeout);
128 : 8 : tprints(", ");
129 : 8 : printaddr(uaddr2);
130 : 8 : tprintf(", %#x", val3);
131 : 8 : break;
132 : : }
133 : :
134 : 444 : return RVAL_DECODED;
135 : : }
|