Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl> |
| 3 | * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl> |
| 4 | * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 5 | * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> |
| 6 | * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation |
| 7 | * Linux for s390 port by D.J. Barrow |
| 8 | * <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer. |
| 16 | * 2. Redistributions in binary form must reproduce the above copyright |
| 17 | * notice, this list of conditions and the following disclaimer in the |
| 18 | * documentation and/or other materials provided with the distribution. |
| 19 | * 3. The name of the author may not be used to endorse or promote products |
| 20 | * derived from this software without specific prior written permission. |
| 21 | * |
| 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 32 | */ |
| 33 | |
| 34 | #include "defs.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 35 | #include <fcntl.h> |
Maarten ter Huurne | 40c174b | 2014-10-20 01:02:48 +0200 | [diff] [blame] | 36 | |
Dmitry V. Levin | 5503dd2 | 2015-02-13 02:12:14 +0000 | [diff] [blame] | 37 | #include "regs.h" |
Dmitry V. Levin | 7211dbc | 2015-02-28 12:20:21 +0000 | [diff] [blame] | 38 | #include "ptrace.h" |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 39 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 40 | #if defined(SPARC) || defined(SPARC64) || defined(MIPS) |
Roland McGrath | 576b784 | 2007-11-04 00:00:00 +0000 | [diff] [blame] | 41 | typedef struct { |
| 42 | struct pt_regs si_regs; |
| 43 | int si_mask; |
| 44 | } m_siginfo_t; |
Roland McGrath | 30ff45e | 2003-01-30 20:15:23 +0000 | [diff] [blame] | 45 | #elif defined HAVE_ASM_SIGCONTEXT_H |
H.J. Lu | 35be581 | 2012-04-16 13:00:01 +0200 | [diff] [blame] | 46 | # if !defined(IA64) && !defined(X86_64) && !defined(X32) |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 47 | # include <asm/sigcontext.h> |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 48 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 49 | #else /* !HAVE_ASM_SIGCONTEXT_H */ |
Denys Vlasenko | b51f364 | 2013-07-16 12:06:25 +0200 | [diff] [blame] | 50 | # if defined M68K && !defined HAVE_STRUCT_SIGCONTEXT |
| 51 | struct sigcontext { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 52 | unsigned long sc_mask; |
| 53 | unsigned long sc_usp; |
| 54 | unsigned long sc_d0; |
| 55 | unsigned long sc_d1; |
| 56 | unsigned long sc_a0; |
| 57 | unsigned long sc_a1; |
| 58 | unsigned short sc_sr; |
| 59 | unsigned long sc_pc; |
| 60 | unsigned short sc_formatvec; |
| 61 | }; |
Denys Vlasenko | b51f364 | 2013-07-16 12:06:25 +0200 | [diff] [blame] | 62 | # endif /* M68K */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 63 | #endif /* !HAVE_ASM_SIGCONTEXT_H */ |
Denys Vlasenko | 041b3ee | 2011-08-18 12:48:56 +0200 | [diff] [blame] | 64 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 65 | #ifndef NSIG |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 66 | # warning: NSIG is not defined, using 32 |
| 67 | # define NSIG 32 |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 68 | #elif NSIG < 32 |
| 69 | # error: NSIG < 32 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 70 | #endif |
Denys Vlasenko | 041b3ee | 2011-08-18 12:48:56 +0200 | [diff] [blame] | 71 | |
Roland McGrath | 2638cb4 | 2002-12-15 23:58:41 +0000 | [diff] [blame] | 72 | /* The libc headers do not define this constant since it should only be |
Denys Vlasenko | 041b3ee | 2011-08-18 12:48:56 +0200 | [diff] [blame] | 73 | used by the implementation. So we define it here. */ |
Dmitry V. Levin | 5c7f627 | 2014-02-08 00:26:06 +0000 | [diff] [blame] | 74 | #ifndef SA_RESTORER |
| 75 | # ifdef ASM_SA_RESTORER |
| 76 | # define SA_RESTORER ASM_SA_RESTORER |
Roland McGrath | 2638cb4 | 2002-12-15 23:58:41 +0000 | [diff] [blame] | 77 | # endif |
| 78 | #endif |
| 79 | |
Dmitry V. Levin | 24b8eb0 | 2015-02-28 17:17:09 +0000 | [diff] [blame] | 80 | /* |
| 81 | * Some architectures define SA_RESTORER in their headers, |
| 82 | * but do not actually have sa_restorer. |
| 83 | * |
| 84 | * Some architectures, otherwise, do not define SA_RESTORER in their headers, |
| 85 | * but actually have sa_restorer. |
| 86 | */ |
| 87 | #ifdef SA_RESTORER |
| 88 | # if defined HPPA || defined IA64 |
| 89 | # define HAVE_SA_RESTORER 0 |
| 90 | # else |
| 91 | # define HAVE_SA_RESTORER 1 |
| 92 | # endif |
| 93 | #else /* !SA_RESTORER */ |
| 94 | # if defined SPARC || defined SPARC64 |
| 95 | # define HAVE_SA_RESTORER 1 |
| 96 | # else |
| 97 | # define HAVE_SA_RESTORER 0 |
| 98 | # endif |
Mike Frysinger | d632e10 | 2014-08-09 09:04:18 -0400 | [diff] [blame] | 99 | #endif |
| 100 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 101 | #include "xlat/sigact_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 102 | #include "xlat/sigprocmaskcmds.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 103 | |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 104 | /* Anonymous realtime signals. */ |
Dmitry V. Levin | 59f63d3 | 2015-03-05 05:03:41 +0000 | [diff] [blame] | 105 | #ifndef ASM_SIGRTMIN |
| 106 | /* Linux kernel >= 3.18 defines SIGRTMIN to 32 on all architectures. */ |
| 107 | # define ASM_SIGRTMIN 32 |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 108 | #endif |
Dmitry V. Levin | 59f63d3 | 2015-03-05 05:03:41 +0000 | [diff] [blame] | 109 | #ifndef ASM_SIGRTMAX |
| 110 | /* Under glibc 2.1, SIGRTMAX et al are functions, but __SIGRTMAX is a |
| 111 | constant. This is what we want. Otherwise, just use SIGRTMAX. */ |
| 112 | # ifdef SIGRTMAX |
| 113 | # ifndef __SIGRTMAX |
| 114 | # define __SIGRTMAX SIGRTMAX |
| 115 | # endif |
| 116 | # endif |
| 117 | # ifdef __SIGRTMAX |
| 118 | # define ASM_SIGRTMAX __SIGRTMAX |
| 119 | # endif |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 120 | #endif |
| 121 | |
Denys Vlasenko | d9560c1 | 2011-08-19 17:41:28 +0200 | [diff] [blame] | 122 | /* Note on the size of sigset_t: |
| 123 | * |
| 124 | * In glibc, sigset_t is an array with space for 1024 bits (!), |
| 125 | * even though all arches supported by Linux have only 64 signals |
| 126 | * except MIPS, which has 128. IOW, it is 128 bytes long. |
| 127 | * |
| 128 | * In-kernel sigset_t is sized correctly (it is either 64 or 128 bit long). |
| 129 | * However, some old syscall return only 32 lower bits (one word). |
| 130 | * Example: sys_sigpending vs sys_rt_sigpending. |
| 131 | * |
| 132 | * Be aware of this fact when you try to |
| 133 | * memcpy(&tcp->u_arg[1], &something, sizeof(sigset_t)) |
| 134 | * - sizeof(sigset_t) is much bigger than you think, |
| 135 | * it may overflow tcp->u_arg[] array, and it may try to copy more data |
| 136 | * than is really available in <something>. |
| 137 | * Similarly, |
| 138 | * umoven(tcp, addr, sizeof(sigset_t), &sigset) |
| 139 | * may be a bad idea: it'll try to read much more data than needed |
| 140 | * to fetch a sigset_t. |
| 141 | * Use (NSIG / 8) as a size instead. |
| 142 | */ |
| 143 | |
Roland McGrath | ee36ce1 | 2004-09-04 03:53:10 +0000 | [diff] [blame] | 144 | const char * |
Dmitry V. Levin | 3ed5d02 | 2014-09-10 13:46:04 +0000 | [diff] [blame] | 145 | signame(const int sig) |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 146 | { |
Dmitry V. Levin | 3ed5d02 | 2014-09-10 13:46:04 +0000 | [diff] [blame] | 147 | static char buf[sizeof("SIGRT_%u") + sizeof(int)*3]; |
Denys Vlasenko | 041b3ee | 2011-08-18 12:48:56 +0200 | [diff] [blame] | 148 | |
Dmitry V. Levin | 3ed5d02 | 2014-09-10 13:46:04 +0000 | [diff] [blame] | 149 | if (sig >= 0) { |
| 150 | const unsigned int s = sig; |
| 151 | |
| 152 | if (s < nsignals) |
| 153 | return signalent[s]; |
Dmitry V. Levin | 59f63d3 | 2015-03-05 05:03:41 +0000 | [diff] [blame] | 154 | #ifdef ASM_SIGRTMAX |
| 155 | if (s >= ASM_SIGRTMIN && s <= ASM_SIGRTMAX) { |
| 156 | sprintf(buf, "SIGRT_%u", s - ASM_SIGRTMIN); |
Dmitry V. Levin | 3ed5d02 | 2014-09-10 13:46:04 +0000 | [diff] [blame] | 157 | return buf; |
| 158 | } |
Denys Vlasenko | 041b3ee | 2011-08-18 12:48:56 +0200 | [diff] [blame] | 159 | #endif |
Dmitry V. Levin | 3ed5d02 | 2014-09-10 13:46:04 +0000 | [diff] [blame] | 160 | } |
Denys Vlasenko | 041b3ee | 2011-08-18 12:48:56 +0200 | [diff] [blame] | 161 | sprintf(buf, "%d", sig); |
| 162 | return buf; |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 163 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 164 | |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 165 | static unsigned int |
| 166 | popcount32(const uint32_t *a, unsigned int size) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 167 | { |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 168 | unsigned int count = 0; |
Denys Vlasenko | d9560c1 | 2011-08-19 17:41:28 +0200 | [diff] [blame] | 169 | |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 170 | for (; size; ++a, --size) { |
| 171 | uint32_t x = *a; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 172 | |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 173 | #ifdef HAVE___BUILTIN_POPCOUNT |
| 174 | count += __builtin_popcount(x); |
Denys Vlasenko | a877379 | 2013-07-18 20:42:41 +0200 | [diff] [blame] | 175 | #else |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 176 | for (; x; ++count) |
| 177 | x &= x - 1; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 178 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 179 | } |
Denys Vlasenko | 4f3df07 | 2012-01-29 22:38:35 +0100 | [diff] [blame] | 180 | |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 181 | return count; |
| 182 | } |
| 183 | |
| 184 | static const char * |
| 185 | sprintsigmask_n(const char *prefix, const void *sig_mask, unsigned int bytes) |
| 186 | { |
| 187 | /* |
| 188 | * The maximum number of signal names to be printed is NSIG * 2 / 3. |
| 189 | * Most of signal names have length 7, |
| 190 | * average length of signal names is less than 7. |
| 191 | * The length of prefix string does not exceed 16. |
| 192 | */ |
| 193 | static char outstr[128 + 8 * (NSIG * 2 / 3)]; |
| 194 | |
| 195 | char *s; |
| 196 | const uint32_t *mask; |
| 197 | uint32_t inverted_mask[NSIG / 32]; |
| 198 | unsigned int size; |
| 199 | int i; |
| 200 | char sep; |
| 201 | |
| 202 | s = stpcpy(outstr, prefix); |
| 203 | |
| 204 | mask = sig_mask; |
| 205 | /* length of signal mask in 4-byte words */ |
| 206 | size = (bytes >= NSIG / 8) ? NSIG / 32 : (bytes + 3) / 4; |
| 207 | |
| 208 | /* check whether 2/3 or more bits are set */ |
| 209 | if (popcount32(mask, size) >= size * 32 * 2 / 3) { |
| 210 | /* show those signals that are NOT in the mask */ |
| 211 | unsigned int j; |
| 212 | for (j = 0; j < size; ++j) |
| 213 | inverted_mask[j] = ~mask[j]; |
| 214 | mask = inverted_mask; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 215 | *s++ = '~'; |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 216 | } |
Denys Vlasenko | 4f3df07 | 2012-01-29 22:38:35 +0100 | [diff] [blame] | 217 | |
| 218 | sep = '['; |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 219 | for (i = 0; (i = next_set_bit(mask, i, size * 32)) >= 0; ) { |
| 220 | ++i; |
| 221 | *s++ = sep; |
Dmitry V. Levin | 3ed5d02 | 2014-09-10 13:46:04 +0000 | [diff] [blame] | 222 | if ((unsigned) i < nsignals) { |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 223 | s = stpcpy(s, signalent[i] + 3); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 224 | } |
Dmitry V. Levin | 59f63d3 | 2015-03-05 05:03:41 +0000 | [diff] [blame] | 225 | #ifdef ASM_SIGRTMAX |
| 226 | else if (i >= ASM_SIGRTMIN && i <= ASM_SIGRTMAX) { |
| 227 | s += sprintf(s, "RT_%u", i - ASM_SIGRTMIN); |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 228 | } |
| 229 | #endif |
| 230 | else { |
| 231 | s += sprintf(s, "%u", i); |
| 232 | } |
| 233 | sep = ' '; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 234 | } |
Denys Vlasenko | 4f3df07 | 2012-01-29 22:38:35 +0100 | [diff] [blame] | 235 | if (sep == '[') |
| 236 | *s++ = sep; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 237 | *s++ = ']'; |
| 238 | *s = '\0'; |
| 239 | return outstr; |
| 240 | } |
| 241 | |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 242 | #define tprintsigmask_addr(prefix, mask) \ |
| 243 | tprints(sprintsigmask_n((prefix), (mask), sizeof(mask))) |
Denys Vlasenko | 75f4e1f | 2013-07-18 20:37:06 +0200 | [diff] [blame] | 244 | |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 245 | #define sprintsigmask_val(prefix, mask) \ |
| 246 | sprintsigmask_n((prefix), &(mask), sizeof(mask)) |
| 247 | |
| 248 | #define tprintsigmask_val(prefix, mask) \ |
| 249 | tprints(sprintsigmask_n((prefix), &(mask), sizeof(mask))) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 250 | |
| 251 | void |
Denys Vlasenko | eccc48c | 2011-06-09 01:28:11 +0200 | [diff] [blame] | 252 | printsignal(int nr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 253 | { |
Denys Vlasenko | 5940e65 | 2011-09-01 09:55:05 +0200 | [diff] [blame] | 254 | tprints(signame(nr)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 255 | } |
| 256 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 257 | void |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 258 | print_sigset_addr_len(struct tcb *tcp, long addr, long len) |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 259 | { |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 260 | char mask[NSIG / 8]; |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 261 | |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 262 | if (!addr) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 263 | tprints("NULL"); |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 264 | return; |
| 265 | } |
| 266 | /* Here len is usually equals NSIG / 8 or current_wordsize. |
| 267 | * But we code this defensively: |
| 268 | */ |
| 269 | if (len < 0) { |
| 270 | bad: |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 271 | tprintf("%#lx", addr); |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 272 | return; |
| 273 | } |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 274 | if (len >= NSIG / 8) |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 275 | len = NSIG / 8; |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 276 | else |
| 277 | len = (len + 3) & ~3; |
| 278 | |
| 279 | if (umoven(tcp, addr, len, mask) < 0) |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 280 | goto bad; |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 281 | tprints(sprintsigmask_n("", mask, len)); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 282 | } |
| 283 | |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 284 | #ifndef ILL_ILLOPC |
| 285 | #define ILL_ILLOPC 1 /* illegal opcode */ |
| 286 | #define ILL_ILLOPN 2 /* illegal operand */ |
| 287 | #define ILL_ILLADR 3 /* illegal addressing mode */ |
| 288 | #define ILL_ILLTRP 4 /* illegal trap */ |
| 289 | #define ILL_PRVOPC 5 /* privileged opcode */ |
| 290 | #define ILL_PRVREG 6 /* privileged register */ |
| 291 | #define ILL_COPROC 7 /* coprocessor error */ |
| 292 | #define ILL_BADSTK 8 /* internal stack error */ |
| 293 | #define FPE_INTDIV 1 /* integer divide by zero */ |
| 294 | #define FPE_INTOVF 2 /* integer overflow */ |
| 295 | #define FPE_FLTDIV 3 /* floating point divide by zero */ |
| 296 | #define FPE_FLTOVF 4 /* floating point overflow */ |
| 297 | #define FPE_FLTUND 5 /* floating point underflow */ |
| 298 | #define FPE_FLTRES 6 /* floating point inexact result */ |
| 299 | #define FPE_FLTINV 7 /* floating point invalid operation */ |
| 300 | #define FPE_FLTSUB 8 /* subscript out of range */ |
| 301 | #define SEGV_MAPERR 1 /* address not mapped to object */ |
| 302 | #define SEGV_ACCERR 2 /* invalid permissions for mapped object */ |
| 303 | #define BUS_ADRALN 1 /* invalid address alignment */ |
| 304 | #define BUS_ADRERR 2 /* non-existant physical address */ |
| 305 | #define BUS_OBJERR 3 /* object specific hardware error */ |
Dmitry V. Levin | bc091e3 | 2014-03-11 22:18:40 +0000 | [diff] [blame] | 306 | #define SYS_SECCOMP 1 /* seccomp triggered */ |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 307 | #define TRAP_BRKPT 1 /* process breakpoint */ |
| 308 | #define TRAP_TRACE 2 /* process trace trap */ |
| 309 | #define CLD_EXITED 1 /* child has exited */ |
| 310 | #define CLD_KILLED 2 /* child was killed */ |
| 311 | #define CLD_DUMPED 3 /* child terminated abnormally */ |
| 312 | #define CLD_TRAPPED 4 /* traced child has trapped */ |
| 313 | #define CLD_STOPPED 5 /* child has stopped */ |
| 314 | #define CLD_CONTINUED 6 /* stopped child has continued */ |
| 315 | #define POLL_IN 1 /* data input available */ |
| 316 | #define POLL_OUT 2 /* output buffers available */ |
| 317 | #define POLL_MSG 3 /* input message available */ |
| 318 | #define POLL_ERR 4 /* i/o error */ |
| 319 | #define POLL_PRI 5 /* high priority input available */ |
| 320 | #define POLL_HUP 6 /* device disconnected */ |
Dmitry V. Levin | 7d4bff1 | 2011-03-10 21:41:34 +0000 | [diff] [blame] | 321 | #define SI_KERNEL 0x80 /* sent by kernel */ |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 322 | #define SI_USER 0 /* sent by kill, sigsend, raise */ |
| 323 | #define SI_QUEUE -1 /* sent by sigqueue */ |
| 324 | #define SI_TIMER -2 /* sent by timer expiration */ |
| 325 | #define SI_MESGQ -3 /* sent by real time mesq state change */ |
| 326 | #define SI_ASYNCIO -4 /* sent by AIO completion */ |
Dmitry V. Levin | 7d4bff1 | 2011-03-10 21:41:34 +0000 | [diff] [blame] | 327 | #define SI_SIGIO -5 /* sent by SIGIO */ |
| 328 | #define SI_TKILL -6 /* sent by tkill */ |
Dmitry V. Levin | b9d4d21 | 2014-03-11 01:57:02 +0000 | [diff] [blame] | 329 | #define SI_DETHREAD -7 /* sent by execve killing subsidiary threads */ |
Dmitry V. Levin | 7d4bff1 | 2011-03-10 21:41:34 +0000 | [diff] [blame] | 330 | #define SI_ASYNCNL -60 /* sent by asynch name lookup completion */ |
Denys Vlasenko | 2c4fb90 | 2012-03-15 17:24:49 +0100 | [diff] [blame] | 331 | #endif |
Dmitry V. Levin | 6d9e8e8 | 2011-03-10 22:18:56 +0000 | [diff] [blame] | 332 | |
Denys Vlasenko | 2c4fb90 | 2012-03-15 17:24:49 +0100 | [diff] [blame] | 333 | #ifndef SI_FROMUSER |
| 334 | # define SI_FROMUSER(sip) ((sip)->si_code <= 0) |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 335 | #endif |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 336 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 337 | #include "xlat/siginfo_codes.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 338 | #include "xlat/sigill_codes.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 339 | #include "xlat/sigfpe_codes.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 340 | #include "xlat/sigtrap_codes.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 341 | #include "xlat/sigchld_codes.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 342 | #include "xlat/sigpoll_codes.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 343 | #include "xlat/sigprof_codes.h" |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 344 | |
| 345 | #ifdef SIGEMT |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 346 | #include "xlat/sigemt_codes.h" |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 347 | #endif |
| 348 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 349 | #include "xlat/sigsegv_codes.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 350 | #include "xlat/sigbus_codes.h" |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 351 | |
Dmitry V. Levin | bc091e3 | 2014-03-11 22:18:40 +0000 | [diff] [blame] | 352 | #ifndef SYS_SECCOMP |
| 353 | # define SYS_SECCOMP 1 |
| 354 | #endif |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 355 | #include "xlat/sigsys_codes.h" |
Dmitry V. Levin | bc091e3 | 2014-03-11 22:18:40 +0000 | [diff] [blame] | 356 | |
Elliott Hughes | 4dd1e89 | 2014-03-10 19:27:22 +0000 | [diff] [blame] | 357 | static void |
Dmitry V. Levin | 4a524db | 2014-03-11 00:05:19 +0000 | [diff] [blame] | 358 | printsigsource(const siginfo_t *sip) |
| 359 | { |
| 360 | tprintf(", si_pid=%lu, si_uid=%lu", |
| 361 | (unsigned long) sip->si_pid, |
| 362 | (unsigned long) sip->si_uid); |
| 363 | } |
| 364 | |
| 365 | static void |
| 366 | printsigval(const siginfo_t *sip, int verbose) |
Elliott Hughes | 4dd1e89 | 2014-03-10 19:27:22 +0000 | [diff] [blame] | 367 | { |
| 368 | if (!verbose) |
| 369 | tprints(", ..."); |
| 370 | else |
| 371 | tprintf(", si_value={int=%u, ptr=%#lx}", |
| 372 | sip->si_int, |
| 373 | (unsigned long) sip->si_ptr); |
| 374 | } |
| 375 | |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 376 | void |
Dmitry V. Levin | d8890b5 | 2015-02-07 15:47:24 +0000 | [diff] [blame] | 377 | printsiginfo(const siginfo_t *sip, int verbose) |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 378 | { |
Roland McGrath | f9c49b2 | 2004-10-06 22:11:54 +0000 | [diff] [blame] | 379 | const char *code; |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 380 | |
| 381 | if (sip->si_signo == 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 382 | tprints("{}"); |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 383 | return; |
| 384 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 385 | tprints("{si_signo="); |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 386 | printsignal(sip->si_signo); |
| 387 | code = xlookup(siginfo_codes, sip->si_code); |
| 388 | if (!code) { |
| 389 | switch (sip->si_signo) { |
| 390 | case SIGTRAP: |
| 391 | code = xlookup(sigtrap_codes, sip->si_code); |
| 392 | break; |
| 393 | case SIGCHLD: |
| 394 | code = xlookup(sigchld_codes, sip->si_code); |
| 395 | break; |
| 396 | case SIGPOLL: |
| 397 | code = xlookup(sigpoll_codes, sip->si_code); |
| 398 | break; |
| 399 | case SIGPROF: |
| 400 | code = xlookup(sigprof_codes, sip->si_code); |
| 401 | break; |
| 402 | case SIGILL: |
| 403 | code = xlookup(sigill_codes, sip->si_code); |
| 404 | break; |
| 405 | #ifdef SIGEMT |
| 406 | case SIGEMT: |
| 407 | code = xlookup(sigemt_codes, sip->si_code); |
| 408 | break; |
| 409 | #endif |
| 410 | case SIGFPE: |
| 411 | code = xlookup(sigfpe_codes, sip->si_code); |
| 412 | break; |
| 413 | case SIGSEGV: |
| 414 | code = xlookup(sigsegv_codes, sip->si_code); |
| 415 | break; |
| 416 | case SIGBUS: |
| 417 | code = xlookup(sigbus_codes, sip->si_code); |
| 418 | break; |
Dmitry V. Levin | bc091e3 | 2014-03-11 22:18:40 +0000 | [diff] [blame] | 419 | case SIGSYS: |
| 420 | code = xlookup(sigsys_codes, sip->si_code); |
| 421 | break; |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 422 | } |
| 423 | } |
| 424 | if (code) |
| 425 | tprintf(", si_code=%s", code); |
| 426 | else |
| 427 | tprintf(", si_code=%#x", sip->si_code); |
| 428 | #ifdef SI_NOINFO |
| 429 | if (sip->si_code != SI_NOINFO) |
| 430 | #endif |
| 431 | { |
| 432 | if (sip->si_errno) { |
Dmitry V. Levin | b2f8c77 | 2015-02-23 03:10:25 +0000 | [diff] [blame] | 433 | tprints(", si_errno="); |
| 434 | if ((unsigned) sip->si_errno < nerrnos |
| 435 | && errnoent[sip->si_errno]) |
| 436 | tprints(errnoent[sip->si_errno]); |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 437 | else |
Dmitry V. Levin | b2f8c77 | 2015-02-23 03:10:25 +0000 | [diff] [blame] | 438 | tprintf("%d", sip->si_errno); |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 439 | } |
| 440 | #ifdef SI_FROMUSER |
| 441 | if (SI_FROMUSER(sip)) { |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 442 | switch (sip->si_code) { |
Dmitry V. Levin | 6d9e8e8 | 2011-03-10 22:18:56 +0000 | [diff] [blame] | 443 | #ifdef SI_USER |
| 444 | case SI_USER: |
Dmitry V. Levin | 4a524db | 2014-03-11 00:05:19 +0000 | [diff] [blame] | 445 | printsigsource(sip); |
Dmitry V. Levin | 6d9e8e8 | 2011-03-10 22:18:56 +0000 | [diff] [blame] | 446 | break; |
| 447 | #endif |
| 448 | #ifdef SI_TKILL |
| 449 | case SI_TKILL: |
Dmitry V. Levin | 4a524db | 2014-03-11 00:05:19 +0000 | [diff] [blame] | 450 | printsigsource(sip); |
Dmitry V. Levin | 6d9e8e8 | 2011-03-10 22:18:56 +0000 | [diff] [blame] | 451 | break; |
| 452 | #endif |
Dmitry V. Levin | 36ab3d5 | 2015-01-13 09:24:04 +0300 | [diff] [blame] | 453 | #if defined SI_TIMER \ |
| 454 | && defined HAVE_SIGINFO_T_SI_TIMERID && defined HAVE_SIGINFO_T_SI_OVERRUN |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 455 | case SI_TIMER: |
Elliott Hughes | 4dd1e89 | 2014-03-10 19:27:22 +0000 | [diff] [blame] | 456 | tprintf(", si_timerid=%#x, si_overrun=%d", |
| 457 | sip->si_timerid, sip->si_overrun); |
| 458 | printsigval(sip, verbose); |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 459 | break; |
Dmitry V. Levin | 6d9e8e8 | 2011-03-10 22:18:56 +0000 | [diff] [blame] | 460 | #endif |
Dmitry V. Levin | 6d9e8e8 | 2011-03-10 22:18:56 +0000 | [diff] [blame] | 461 | default: |
Dmitry V. Levin | 4a524db | 2014-03-11 00:05:19 +0000 | [diff] [blame] | 462 | printsigsource(sip); |
| 463 | if (sip->si_ptr) |
| 464 | printsigval(sip, verbose); |
Dmitry V. Levin | 6d9e8e8 | 2011-03-10 22:18:56 +0000 | [diff] [blame] | 465 | break; |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 466 | } |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 467 | } |
| 468 | else |
| 469 | #endif /* SI_FROMUSER */ |
| 470 | { |
| 471 | switch (sip->si_signo) { |
| 472 | case SIGCHLD: |
Dmitry V. Levin | 4a524db | 2014-03-11 00:05:19 +0000 | [diff] [blame] | 473 | printsigsource(sip); |
| 474 | tprints(", si_status="); |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 475 | if (sip->si_code == CLD_EXITED) |
| 476 | tprintf("%d", sip->si_status); |
| 477 | else |
| 478 | printsignal(sip->si_status); |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 479 | if (!verbose) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 480 | tprints(", ..."); |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 481 | else |
H.J. Lu | 2bb4581 | 2012-04-15 11:17:13 -0700 | [diff] [blame] | 482 | tprintf(", si_utime=%llu, si_stime=%llu", |
| 483 | (unsigned long long) sip->si_utime, |
| 484 | (unsigned long long) sip->si_stime); |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 485 | break; |
| 486 | case SIGILL: case SIGFPE: |
| 487 | case SIGSEGV: case SIGBUS: |
| 488 | tprintf(", si_addr=%#lx", |
| 489 | (unsigned long) sip->si_addr); |
| 490 | break; |
| 491 | case SIGPOLL: |
| 492 | switch (sip->si_code) { |
| 493 | case POLL_IN: case POLL_OUT: case POLL_MSG: |
| 494 | tprintf(", si_band=%ld", |
| 495 | (long) sip->si_band); |
| 496 | break; |
| 497 | } |
| 498 | break; |
Dmitry V. Levin | bc091e3 | 2014-03-11 22:18:40 +0000 | [diff] [blame] | 499 | #ifdef HAVE_SIGINFO_T_SI_SYSCALL |
| 500 | case SIGSYS: |
| 501 | tprintf(", si_call_addr=%#lx, si_syscall=%d, si_arch=%u", |
| 502 | (unsigned long) sip->si_call_addr, |
| 503 | sip->si_syscall, sip->si_arch); |
| 504 | break; |
| 505 | #endif |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 506 | default: |
Dmitry V. Levin | b41e1c9 | 2011-03-10 23:14:47 +0000 | [diff] [blame] | 507 | if (sip->si_pid || sip->si_uid) |
Dmitry V. Levin | 4a524db | 2014-03-11 00:05:19 +0000 | [diff] [blame] | 508 | printsigsource(sip); |
| 509 | if (sip->si_ptr) |
| 510 | printsigval(sip, verbose); |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 511 | } |
| 512 | } |
| 513 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 514 | tprints("}"); |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 515 | } |
| 516 | |
Denys Vlasenko | d4d3ede | 2013-02-13 16:31:32 +0100 | [diff] [blame] | 517 | void |
| 518 | printsiginfo_at(struct tcb *tcp, long addr) |
| 519 | { |
| 520 | siginfo_t si; |
| 521 | if (!addr) { |
| 522 | tprints("NULL"); |
| 523 | return; |
| 524 | } |
| 525 | if (syserror(tcp)) { |
| 526 | tprintf("%#lx", addr); |
| 527 | return; |
| 528 | } |
| 529 | if (umove(tcp, addr, &si) < 0) { |
| 530 | tprints("{???}"); |
| 531 | return; |
| 532 | } |
| 533 | printsiginfo(&si, verbose(tcp)); |
| 534 | } |
| 535 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 536 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 537 | sys_sigsetmask(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 538 | { |
| 539 | if (entering(tcp)) { |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 540 | tprintsigmask_val("", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 541 | } |
| 542 | else if (!syserror(tcp)) { |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 543 | tcp->auxstr = sprintsigmask_val("old mask ", tcp->u_rval); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 544 | return RVAL_HEX | RVAL_STR; |
| 545 | } |
| 546 | return 0; |
| 547 | } |
| 548 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 549 | #ifdef HAVE_SIGACTION |
| 550 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 551 | struct old_sigaction { |
Denys Vlasenko | 86d9484 | 2013-02-08 12:59:13 +0100 | [diff] [blame] | 552 | /* sa_handler may be a libc #define, need to use other name: */ |
Chris Dearman | 2b4bb1c | 2013-12-09 19:58:42 -0800 | [diff] [blame] | 553 | #ifdef MIPS |
| 554 | unsigned int sa_flags; |
| 555 | void (*__sa_handler)(int); |
| 556 | /* Kernel treats sa_mask as an array of longs. */ |
| 557 | unsigned long sa_mask[NSIG / sizeof(long) ? NSIG / sizeof(long) : 1]; |
| 558 | #else |
Denys Vlasenko | 86d9484 | 2013-02-08 12:59:13 +0100 | [diff] [blame] | 559 | void (*__sa_handler)(int); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 560 | unsigned long sa_mask; |
| 561 | unsigned long sa_flags; |
Chris Dearman | 2b4bb1c | 2013-12-09 19:58:42 -0800 | [diff] [blame] | 562 | #endif /* !MIPS */ |
Dmitry V. Levin | 24b8eb0 | 2015-02-28 17:17:09 +0000 | [diff] [blame] | 563 | #if HAVE_SA_RESTORER |
Vicente Olivert Riera | c3a5c01 | 2014-09-11 20:05:18 +0100 | [diff] [blame] | 564 | void (*sa_restorer)(void); |
| 565 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 566 | }; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 567 | |
Elliott Hughes | 458b3f2 | 2014-02-28 23:21:35 +0000 | [diff] [blame] | 568 | struct old_sigaction32 { |
| 569 | /* sa_handler may be a libc #define, need to use other name: */ |
| 570 | uint32_t __sa_handler; |
| 571 | uint32_t sa_mask; |
| 572 | uint32_t sa_flags; |
Dmitry V. Levin | 24b8eb0 | 2015-02-28 17:17:09 +0000 | [diff] [blame] | 573 | #if HAVE_SA_RESTORER |
Elliott Hughes | 458b3f2 | 2014-02-28 23:21:35 +0000 | [diff] [blame] | 574 | uint32_t sa_restorer; |
Vicente Olivert Riera | c3a5c01 | 2014-09-11 20:05:18 +0100 | [diff] [blame] | 575 | #endif |
Elliott Hughes | 458b3f2 | 2014-02-28 23:21:35 +0000 | [diff] [blame] | 576 | }; |
| 577 | |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 578 | static void |
| 579 | decode_old_sigaction(struct tcb *tcp, long addr) |
| 580 | { |
| 581 | struct old_sigaction sa; |
Elliott Hughes | 458b3f2 | 2014-02-28 23:21:35 +0000 | [diff] [blame] | 582 | int r; |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 583 | |
| 584 | if (!addr) { |
| 585 | tprints("NULL"); |
| 586 | return; |
| 587 | } |
| 588 | if (!verbose(tcp) || (exiting(tcp) && syserror(tcp))) { |
| 589 | tprintf("%#lx", addr); |
| 590 | return; |
| 591 | } |
Elliott Hughes | 458b3f2 | 2014-02-28 23:21:35 +0000 | [diff] [blame] | 592 | |
| 593 | #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 |
| 594 | if (current_wordsize != sizeof(sa.__sa_handler) && current_wordsize == 4) { |
| 595 | struct old_sigaction32 sa32; |
| 596 | r = umove(tcp, addr, &sa32); |
| 597 | if (r >= 0) { |
| 598 | memset(&sa, 0, sizeof(sa)); |
| 599 | sa.__sa_handler = (void*)(uintptr_t)sa32.__sa_handler; |
| 600 | sa.sa_flags = sa32.sa_flags; |
Dmitry V. Levin | 24b8eb0 | 2015-02-28 17:17:09 +0000 | [diff] [blame] | 601 | #if HAVE_SA_RESTORER && defined SA_RESTORER |
Elliott Hughes | 458b3f2 | 2014-02-28 23:21:35 +0000 | [diff] [blame] | 602 | sa.sa_restorer = (void*)(uintptr_t)sa32.sa_restorer; |
Vicente Olivert Riera | c3a5c01 | 2014-09-11 20:05:18 +0100 | [diff] [blame] | 603 | #endif |
Elliott Hughes | 458b3f2 | 2014-02-28 23:21:35 +0000 | [diff] [blame] | 604 | sa.sa_mask = sa32.sa_mask; |
| 605 | } |
| 606 | } else |
| 607 | #endif |
| 608 | { |
| 609 | r = umove(tcp, addr, &sa); |
| 610 | } |
| 611 | if (r < 0) { |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 612 | tprints("{...}"); |
| 613 | return; |
| 614 | } |
| 615 | |
| 616 | /* Architectures using function pointers, like |
| 617 | * hppa, may need to manipulate the function pointer |
| 618 | * to compute the result of a comparison. However, |
| 619 | * the __sa_handler function pointer exists only in |
| 620 | * the address space of the traced process, and can't |
| 621 | * be manipulated by strace. In order to prevent the |
| 622 | * compiler from generating code to manipulate |
| 623 | * __sa_handler we cast the function pointers to long. */ |
| 624 | if ((long)sa.__sa_handler == (long)SIG_ERR) |
| 625 | tprints("{SIG_ERR, "); |
| 626 | else if ((long)sa.__sa_handler == (long)SIG_DFL) |
| 627 | tprints("{SIG_DFL, "); |
| 628 | else if ((long)sa.__sa_handler == (long)SIG_IGN) |
| 629 | tprints("{SIG_IGN, "); |
| 630 | else |
| 631 | tprintf("{%#lx, ", (long) sa.__sa_handler); |
Chris Dearman | 2b4bb1c | 2013-12-09 19:58:42 -0800 | [diff] [blame] | 632 | #ifdef MIPS |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 633 | tprintsigmask_addr("", sa.sa_mask); |
Chris Dearman | 2b4bb1c | 2013-12-09 19:58:42 -0800 | [diff] [blame] | 634 | #else |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 635 | tprintsigmask_val("", sa.sa_mask); |
Chris Dearman | 2b4bb1c | 2013-12-09 19:58:42 -0800 | [diff] [blame] | 636 | #endif |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 637 | tprints(", "); |
| 638 | printflags(sigact_flags, sa.sa_flags, "SA_???"); |
Dmitry V. Levin | 24b8eb0 | 2015-02-28 17:17:09 +0000 | [diff] [blame] | 639 | #if HAVE_SA_RESTORER && defined SA_RESTORER |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 640 | if (sa.sa_flags & SA_RESTORER) |
| 641 | tprintf(", %p", sa.sa_restorer); |
| 642 | #endif |
| 643 | tprints("}"); |
| 644 | } |
| 645 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 646 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 647 | sys_sigaction(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 648 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 649 | if (entering(tcp)) { |
| 650 | printsignal(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 651 | tprints(", "); |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 652 | decode_old_sigaction(tcp, tcp->u_arg[1]); |
| 653 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 654 | } else |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 655 | decode_old_sigaction(tcp, tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 656 | return 0; |
| 657 | } |
| 658 | |
| 659 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 660 | sys_signal(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 661 | { |
| 662 | if (entering(tcp)) { |
| 663 | printsignal(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 664 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 665 | switch (tcp->u_arg[1]) { |
Jan Kratochvil | 1f94271 | 2008-08-06 21:38:52 +0000 | [diff] [blame] | 666 | case (long) SIG_ERR: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 667 | tprints("SIG_ERR"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 668 | break; |
Jan Kratochvil | 1f94271 | 2008-08-06 21:38:52 +0000 | [diff] [blame] | 669 | case (long) SIG_DFL: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 670 | tprints("SIG_DFL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 671 | break; |
Jan Kratochvil | 1f94271 | 2008-08-06 21:38:52 +0000 | [diff] [blame] | 672 | case (long) SIG_IGN: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 673 | tprints("SIG_IGN"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 674 | break; |
| 675 | default: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 676 | tprintf("%#lx", tcp->u_arg[1]); |
| 677 | } |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 678 | return 0; |
| 679 | } |
Dmitry V. Levin | 21a7534 | 2008-09-03 01:22:18 +0000 | [diff] [blame] | 680 | else if (!syserror(tcp)) { |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 681 | switch (tcp->u_rval) { |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 682 | case (long) SIG_ERR: |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 683 | tcp->auxstr = "SIG_ERR"; break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 684 | case (long) SIG_DFL: |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 685 | tcp->auxstr = "SIG_DFL"; break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 686 | case (long) SIG_IGN: |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 687 | tcp->auxstr = "SIG_IGN"; break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 688 | default: |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 689 | tcp->auxstr = NULL; |
| 690 | } |
| 691 | return RVAL_HEX | RVAL_STR; |
| 692 | } |
Dmitry V. Levin | 21a7534 | 2008-09-03 01:22:18 +0000 | [diff] [blame] | 693 | return 0; |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 694 | } |
| 695 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 696 | #endif /* HAVE_SIGACTION */ |
| 697 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 698 | int |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 699 | sys_sigreturn(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 700 | { |
Dmitry V. Levin | 5b9b7e1 | 2015-03-04 23:05:53 +0000 | [diff] [blame] | 701 | #if defined AARCH64 || defined ARM |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 702 | if (entering(tcp)) { |
Dmitry V. Levin | 5b9b7e1 | 2015-03-04 23:05:53 +0000 | [diff] [blame] | 703 | # define SIZEOF_STRUCT_SIGINFO 128 |
Dmitry V. Levin | 26d16c8 | 2015-03-04 22:27:35 +0000 | [diff] [blame] | 704 | # define SIZEOF_STRUCT_SIGCONTEXT (21 * 4) |
| 705 | # define OFFSETOF_STRUCT_UCONTEXT_UC_SIGMASK (5 * 4 + SIZEOF_STRUCT_SIGCONTEXT) |
Dmitry V. Levin | 5b9b7e1 | 2015-03-04 23:05:53 +0000 | [diff] [blame] | 706 | const long addr = |
| 707 | # ifdef AARCH64 |
| 708 | current_personality == 0 ? |
| 709 | (*aarch64_sp_ptr + SIZEOF_STRUCT_SIGINFO + |
| 710 | offsetof(struct ucontext, uc_sigmask)) : |
| 711 | # endif |
| 712 | (*arm_sp_ptr + |
| 713 | OFFSETOF_STRUCT_UCONTEXT_UC_SIGMASK); |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 714 | tprints("{mask="); |
Dmitry V. Levin | 26d16c8 | 2015-03-04 22:27:35 +0000 | [diff] [blame] | 715 | print_sigset_addr_len(tcp, addr, NSIG / 8); |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 716 | tprints("}"); |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 717 | } |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 718 | #elif defined(S390) || defined(S390X) |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 719 | if (entering(tcp)) { |
Dmitry V. Levin | 085411b | 2015-03-04 21:40:00 +0000 | [diff] [blame] | 720 | long mask[NSIG / 8 / sizeof(long)]; |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 721 | tprints("{mask="); |
Dmitry V. Levin | 20eca8a | 2015-03-05 22:10:15 +0000 | [diff] [blame^] | 722 | const long addr = *s390_frame_ptr + __SIGNAL_FRAMESIZE; |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 723 | if (umove(tcp, addr, &mask) < 0) { |
| 724 | tprintf("%#lx", addr); |
| 725 | } else { |
Dmitry V. Levin | 085411b | 2015-03-04 21:40:00 +0000 | [diff] [blame] | 726 | # ifdef S390 |
Dmitry V. Levin | 20eca8a | 2015-03-05 22:10:15 +0000 | [diff] [blame^] | 727 | long v = mask[0]; |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 728 | mask[0] = mask[1]; |
Dmitry V. Levin | 20eca8a | 2015-03-05 22:10:15 +0000 | [diff] [blame^] | 729 | mask[1] = v; |
Dmitry V. Levin | 085411b | 2015-03-04 21:40:00 +0000 | [diff] [blame] | 730 | # endif |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 731 | tprintsigmask_addr("", mask); |
| 732 | } |
| 733 | tprints("}"); |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 734 | } |
Dmitry V. Levin | 5dd336b | 2015-02-23 16:18:09 +0000 | [diff] [blame] | 735 | #elif defined I386 || defined X86_64 || defined X32 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 736 | if (entering(tcp)) { |
Dmitry V. Levin | ccb4fda | 2015-03-04 12:19:55 +0000 | [diff] [blame] | 737 | # ifndef I386 |
| 738 | if (current_personality != 1) { |
| 739 | const unsigned long addr = |
| 740 | (unsigned long) *x86_64_rsp_ptr + |
| 741 | offsetof(struct ucontext, uc_sigmask); |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 742 | tprints("{mask="); |
Dmitry V. Levin | ccb4fda | 2015-03-04 12:19:55 +0000 | [diff] [blame] | 743 | print_sigset_addr_len(tcp, addr, NSIG / 8); |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 744 | tprints("}"); |
Dmitry V. Levin | ccb4fda | 2015-03-04 12:19:55 +0000 | [diff] [blame] | 745 | return 0; |
| 746 | } |
| 747 | # endif |
Dmitry V. Levin | a1c5e07 | 2015-03-05 01:14:33 +0000 | [diff] [blame] | 748 | /* |
| 749 | * On i386, sigcontext is followed on stack by struct fpstate |
| 750 | * and after it an additional u32 extramask which holds |
Denys Vlasenko | b51f364 | 2013-07-16 12:06:25 +0200 | [diff] [blame] | 751 | * upper half of the mask. |
Denys Vlasenko | b11322f | 2012-01-10 16:40:35 +0100 | [diff] [blame] | 752 | */ |
Dmitry V. Levin | a1c5e07 | 2015-03-05 01:14:33 +0000 | [diff] [blame] | 753 | struct { |
| 754 | uint32_t struct_sigcontext_padding1[20]; |
| 755 | uint32_t oldmask; |
| 756 | uint32_t struct_sigcontext_padding2; |
| 757 | uint32_t struct_fpstate_padding[156]; |
| 758 | uint32_t extramask; |
| 759 | } frame; |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 760 | tprints("{mask="); |
Dmitry V. Levin | a1c5e07 | 2015-03-05 01:14:33 +0000 | [diff] [blame] | 761 | if (umove(tcp, *i386_esp_ptr, &frame) < 0) { |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 762 | tprintf("%#lx", (unsigned long) *i386_esp_ptr); |
| 763 | } else { |
Dmitry V. Levin | a1c5e07 | 2015-03-05 01:14:33 +0000 | [diff] [blame] | 764 | uint32_t mask[2] = { frame.oldmask, frame.extramask }; |
| 765 | tprintsigmask_addr("", mask); |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 766 | } |
| 767 | tprints("}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 768 | } |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 769 | #elif defined(IA64) |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 770 | if (entering(tcp)) { |
Dmitry V. Levin | 1e8a454 | 2015-03-04 12:11:31 +0000 | [diff] [blame] | 771 | long addr; |
| 772 | if (upeek(tcp->pid, PT_R12, &addr) < 0) |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 773 | return 0; |
Dmitry V. Levin | 1e8a454 | 2015-03-04 12:11:31 +0000 | [diff] [blame] | 774 | /* offsetof(struct sigframe, sc) */ |
| 775 | # define OFFSETOF_STRUCT_SIGFRAME_SC 0xA0 |
| 776 | addr += 16 + OFFSETOF_STRUCT_SIGFRAME_SC + |
| 777 | offsetof(struct sigcontext, sc_mask); |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 778 | tprints("{mask="); |
Dmitry V. Levin | 1e8a454 | 2015-03-04 12:11:31 +0000 | [diff] [blame] | 779 | print_sigset_addr_len(tcp, addr, NSIG / 8); |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 780 | tprints("}"); |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 781 | } |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 782 | #elif defined(POWERPC) |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 783 | if (entering(tcp)) { |
Dmitry V. Levin | 577be25 | 2015-03-04 16:01:47 +0000 | [diff] [blame] | 784 | long esp = ppc_regs.gpr[1]; |
Dmitry V. Levin | e2de3bd | 2013-11-12 15:27:38 +0000 | [diff] [blame] | 785 | struct sigcontext sc; |
Anton Blanchard | ce6e33b | 2013-06-26 15:53:33 +0200 | [diff] [blame] | 786 | |
Andreas Schwab | edb3934 | 2010-02-23 00:18:51 +0100 | [diff] [blame] | 787 | /* Skip dummy stack frame. */ |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 788 | #ifdef POWERPC64 |
| 789 | if (current_personality == 0) |
| 790 | esp += 128; |
| 791 | else |
Andreas Schwab | edb3934 | 2010-02-23 00:18:51 +0100 | [diff] [blame] | 792 | #endif |
Dmitry V. Levin | 577be25 | 2015-03-04 16:01:47 +0000 | [diff] [blame] | 793 | esp += 64; |
| 794 | |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 795 | tprints("{mask="); |
Dmitry V. Levin | 577be25 | 2015-03-04 16:01:47 +0000 | [diff] [blame] | 796 | if (umove(tcp, esp, &sc) < 0) { |
| 797 | tprintf("%#lx", esp); |
| 798 | } else { |
| 799 | unsigned long mask[NSIG / 8 / sizeof(long)]; |
| 800 | #ifdef POWERPC64 |
Dmitry V. Levin | 67dab70 | 2015-03-05 04:29:37 +0000 | [diff] [blame] | 801 | mask[0] = sc.oldmask | (sc._unused[3] << 32); |
| 802 | #else |
| 803 | mask[0] = sc.oldmask; |
| 804 | mask[1] = sc._unused[3]; |
Dmitry V. Levin | 577be25 | 2015-03-04 16:01:47 +0000 | [diff] [blame] | 805 | #endif |
Dmitry V. Levin | 577be25 | 2015-03-04 16:01:47 +0000 | [diff] [blame] | 806 | tprintsigmask_val("", mask); |
| 807 | } |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 808 | tprints("}"); |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 809 | } |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 810 | #elif defined(M68K) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 811 | if (entering(tcp)) { |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 812 | long addr; |
| 813 | if (upeek(tcp->pid, 4*PT_USP, &addr) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 814 | return 0; |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 815 | addr += offsetof(struct sigcontext, sc_mask); |
| 816 | tprints("{mask="); |
| 817 | print_sigset_addr_len(tcp, addr, NSIG / 8); |
| 818 | tprints("}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 819 | } |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 820 | #elif defined(ALPHA) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 821 | if (entering(tcp)) { |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 822 | long addr; |
| 823 | if (upeek(tcp->pid, REG_FP, &addr) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 824 | return 0; |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 825 | addr += offsetof(struct sigcontext, sc_mask); |
| 826 | tprints("{mask="); |
| 827 | print_sigset_addr_len(tcp, addr, NSIG / 8); |
| 828 | tprints("}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 829 | } |
Denys Vlasenko | c36c352 | 2012-02-25 02:47:15 +0100 | [diff] [blame] | 830 | #elif defined(SPARC) || defined(SPARC64) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 831 | if (entering(tcp)) { |
Dmitry V. Levin | db19936 | 2015-03-04 17:52:42 +0000 | [diff] [blame] | 832 | long fp = sparc_regs.u_regs[U_REG_FP] + sizeof(struct sparc_stackf); |
| 833 | struct { |
| 834 | m_siginfo_t si; |
| 835 | void *fpu_save; |
| 836 | long insns[2] __attribute__ ((aligned (8))); |
| 837 | unsigned int extramask[NSIG / 8 / sizeof(int) - 1]; |
| 838 | } frame; |
| 839 | |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 840 | tprints("{mask="); |
Dmitry V. Levin | db19936 | 2015-03-04 17:52:42 +0000 | [diff] [blame] | 841 | if (umove(tcp, fp, &frame) < 0) { |
| 842 | tprintf("%#lx", fp); |
| 843 | } else { |
| 844 | unsigned int mask[NSIG / 8 / sizeof(int)]; |
| 845 | |
| 846 | mask[0] = frame.si.si_mask; |
| 847 | memcpy(mask + 1, frame.extramask, sizeof(frame.extramask)); |
| 848 | tprintsigmask_val("", mask); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 849 | } |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 850 | tprints("}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 851 | } |
Dmitry V. Levin | fd6d207 | 2015-03-04 20:04:02 +0000 | [diff] [blame] | 852 | #elif defined MIPS |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 853 | if (entering(tcp)) { |
Dmitry V. Levin | fd6d207 | 2015-03-04 20:04:02 +0000 | [diff] [blame] | 854 | # if defined LINUX_MIPSO32 |
| 855 | /* |
| 856 | * offsetof(struct sigframe, sf_mask) == |
| 857 | * sizeof(sf_ass) + sizeof(sf_pad) + sizeof(struct sigcontext) |
| 858 | */ |
| 859 | const long addr = mips_REG_SP + 6 * 4 + |
| 860 | sizeof(struct sigcontext); |
| 861 | # else |
| 862 | /* |
| 863 | * This decodes rt_sigreturn. |
| 864 | * The 64-bit ABIs do not have sigreturn. |
| 865 | * |
| 866 | * offsetof(struct rt_sigframe, rs_uc) == |
| 867 | * sizeof(sf_ass) + sizeof(sf_pad) + sizeof(struct siginfo) |
| 868 | */ |
| 869 | const long addr = mips_REG_SP + 6 * 4 + 128 + |
| 870 | offsetof(struct ucontext, uc_sigmask); |
| 871 | # endif |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 872 | tprints("{mask="); |
Dmitry V. Levin | fd6d207 | 2015-03-04 20:04:02 +0000 | [diff] [blame] | 873 | print_sigset_addr_len(tcp, addr, NSIG / 8); |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 874 | tprints("}"); |
Wichert Akkerman | f90da01 | 1999-10-31 21:15:38 +0000 | [diff] [blame] | 875 | } |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 876 | #elif defined(CRISV10) || defined(CRISV32) |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 877 | if (entering(tcp)) { |
| 878 | long regs[PT_MAX+1]; |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 879 | if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, (long)regs) < 0) { |
Denys Vlasenko | 905e8e0 | 2013-02-26 12:30:09 +0100 | [diff] [blame] | 880 | perror_msg("sigreturn: PTRACE_GETREGS"); |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 881 | return 0; |
| 882 | } |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 883 | const long addr = regs[PT_USP] + |
| 884 | offsetof(struct sigcontext, oldmask); |
| 885 | tprints("{mask="); |
| 886 | print_sigset_addr_len(tcp, addr, NSIG / 8); |
| 887 | tprints("}"); |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 888 | } |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 889 | #elif defined(TILE) |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 890 | if (entering(tcp)) { |
Denys Vlasenko | 56a5298 | 2011-06-09 01:36:29 +0200 | [diff] [blame] | 891 | /* offset of ucontext in the kernel's sigframe structure */ |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 892 | # define SIGFRAME_UC_OFFSET C_ABI_SAVE_AREA_SIZE + sizeof(siginfo_t) |
| 893 | const long addr = tile_regs.sp + SIGFRAME_UC_OFFSET + |
| 894 | offsetof(struct ucontext, uc_sigmask); |
| 895 | tprints("{mask="); |
| 896 | print_sigset_addr_len(tcp, addr, NSIG / 8); |
| 897 | tprints("}"); |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 898 | } |
Edgar E. Iglesias | 939caba | 2010-07-06 14:21:07 +0200 | [diff] [blame] | 899 | #elif defined(MICROBLAZE) |
Edgar E. Iglesias | 939caba | 2010-07-06 14:21:07 +0200 | [diff] [blame] | 900 | /* TODO: Verify that this is correct... */ |
| 901 | if (entering(tcp)) { |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 902 | long addr; |
Edgar E. Iglesias | 939caba | 2010-07-06 14:21:07 +0200 | [diff] [blame] | 903 | /* Read r1, the stack pointer. */ |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 904 | if (upeek(tcp->pid, 1 * 4, &addr) < 0) |
Edgar E. Iglesias | 939caba | 2010-07-06 14:21:07 +0200 | [diff] [blame] | 905 | return 0; |
Dmitry V. Levin | f3582cd | 2015-03-04 23:55:25 +0000 | [diff] [blame] | 906 | addr += offsetof(struct sigcontext, oldmask); |
| 907 | tprints("{mask="); |
| 908 | print_sigset_addr_len(tcp, addr, NSIG / 8); |
| 909 | tprints("}"); |
Edgar E. Iglesias | 939caba | 2010-07-06 14:21:07 +0200 | [diff] [blame] | 910 | } |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 911 | #else |
Dmitry V. Levin | d468992 | 2015-03-04 13:12:06 +0000 | [diff] [blame] | 912 | # warning sigreturn/rt_sigreturn signal mask decoding is not implemented for this architecture |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 913 | #endif |
Dmitry V. Levin | f112d07 | 2012-05-15 00:13:59 +0000 | [diff] [blame] | 914 | return 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 915 | } |
| 916 | |
| 917 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 918 | sys_siggetmask(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 919 | { |
| 920 | if (exiting(tcp)) { |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 921 | tcp->auxstr = sprintsigmask_val("mask ", tcp->u_rval); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 922 | } |
| 923 | return RVAL_HEX | RVAL_STR; |
| 924 | } |
| 925 | |
| 926 | int |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 927 | sys_sigsuspend(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 928 | { |
| 929 | if (entering(tcp)) { |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 930 | tprintsigmask_val("", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 931 | } |
| 932 | return 0; |
| 933 | } |
| 934 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 935 | #if !defined SS_ONSTACK |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 936 | #define SS_ONSTACK 1 |
| 937 | #define SS_DISABLE 2 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 938 | #endif |
| 939 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 940 | #include "xlat/sigaltstack_flags.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 941 | |
Dmitry V. Levin | 338c069 | 2013-02-09 02:03:04 +0000 | [diff] [blame] | 942 | static void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 943 | print_stack_t(struct tcb *tcp, unsigned long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 944 | { |
| 945 | stack_t ss; |
Dmitry V. Levin | d153bfc | 2014-02-26 22:29:27 +0000 | [diff] [blame] | 946 | int r; |
Dmitry V. Levin | 338c069 | 2013-02-09 02:03:04 +0000 | [diff] [blame] | 947 | |
| 948 | if (!addr) { |
| 949 | tprints("NULL"); |
Dmitry V. Levin | d153bfc | 2014-02-26 22:29:27 +0000 | [diff] [blame] | 950 | return; |
| 951 | } |
| 952 | |
| 953 | #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 |
| 954 | if (current_wordsize != sizeof(ss.ss_sp) && current_wordsize == 4) { |
| 955 | struct { |
| 956 | uint32_t ss_sp; |
| 957 | int32_t ss_flags; |
| 958 | uint32_t ss_size; |
| 959 | } ss32; |
| 960 | r = umove(tcp, addr, &ss32); |
| 961 | if (r >= 0) { |
| 962 | memset(&ss, 0, sizeof(ss)); |
| 963 | ss.ss_sp = (void*)(unsigned long) ss32.ss_sp; |
| 964 | ss.ss_flags = ss32.ss_flags; |
| 965 | ss.ss_size = (unsigned long) ss32.ss_size; |
| 966 | } |
| 967 | } else |
| 968 | #endif |
| 969 | { |
| 970 | r = umove(tcp, addr, &ss); |
| 971 | } |
| 972 | if (r < 0) { |
Dmitry V. Levin | 338c069 | 2013-02-09 02:03:04 +0000 | [diff] [blame] | 973 | tprintf("%#lx", addr); |
| 974 | } else { |
| 975 | tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp); |
| 976 | printflags(sigaltstack_flags, ss.ss_flags, "SS_???"); |
| 977 | tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size); |
| 978 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 979 | } |
| 980 | |
| 981 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 982 | sys_sigaltstack(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 983 | { |
| 984 | if (entering(tcp)) { |
Dmitry V. Levin | 338c069 | 2013-02-09 02:03:04 +0000 | [diff] [blame] | 985 | print_stack_t(tcp, tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 986 | } |
| 987 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 988 | tprints(", "); |
Dmitry V. Levin | 338c069 | 2013-02-09 02:03:04 +0000 | [diff] [blame] | 989 | print_stack_t(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 990 | } |
| 991 | return 0; |
| 992 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 993 | |
| 994 | #ifdef HAVE_SIGACTION |
| 995 | |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 996 | /* "Old" sigprocmask, which operates with word-sized signal masks */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 997 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 998 | sys_sigprocmask(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 999 | { |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1000 | # ifdef ALPHA |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1001 | if (entering(tcp)) { |
Mike Frysinger | dde045c | 2012-03-15 00:45:33 -0400 | [diff] [blame] | 1002 | /* |
| 1003 | * Alpha/OSF is different: it doesn't pass in two pointers, |
| 1004 | * but rather passes in the new bitmask as an argument and |
| 1005 | * then returns the old bitmask. This "works" because we |
| 1006 | * only have 64 signals to worry about. If you want more, |
| 1007 | * use of the rt_sigprocmask syscall is required. |
| 1008 | * Alpha: |
| 1009 | * old = osf_sigprocmask(how, new); |
| 1010 | * Everyone else: |
| 1011 | * ret = sigprocmask(how, &new, &old, ...); |
| 1012 | */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1013 | printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???"); |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 1014 | tprintsigmask_val(", ", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1015 | } |
| 1016 | else if (!syserror(tcp)) { |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 1017 | tcp->auxstr = sprintsigmask_val("old mask ", tcp->u_rval); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1018 | return RVAL_HEX | RVAL_STR; |
| 1019 | } |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1020 | # else /* !ALPHA */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1021 | if (entering(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1022 | printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1023 | tprints(", "); |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1024 | print_sigset_addr_len(tcp, tcp->u_arg[1], current_wordsize); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1025 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1026 | } |
| 1027 | else { |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1028 | if (syserror(tcp)) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1029 | tprintf("%#lx", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1030 | else |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1031 | print_sigset_addr_len(tcp, tcp->u_arg[2], current_wordsize); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1032 | } |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1033 | # endif /* !ALPHA */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1034 | return 0; |
| 1035 | } |
| 1036 | |
| 1037 | #endif /* HAVE_SIGACTION */ |
| 1038 | |
| 1039 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1040 | sys_kill(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1041 | { |
| 1042 | if (entering(tcp)) { |
Denys Vlasenko | e015d2d | 2013-02-15 14:58:52 +0100 | [diff] [blame] | 1043 | tprintf("%ld, %s", |
| 1044 | widen_to_long(tcp->u_arg[0]), |
| 1045 | signame(tcp->u_arg[1]) |
| 1046 | ); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1047 | } |
| 1048 | return 0; |
| 1049 | } |
| 1050 | |
Roland McGrath | 8ffc352 | 2003-07-09 09:47:49 +0000 | [diff] [blame] | 1051 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1052 | sys_tgkill(struct tcb *tcp) |
Roland McGrath | 8ffc352 | 2003-07-09 09:47:49 +0000 | [diff] [blame] | 1053 | { |
| 1054 | if (entering(tcp)) { |
| 1055 | tprintf("%ld, %ld, %s", |
Denys Vlasenko | e015d2d | 2013-02-15 14:58:52 +0100 | [diff] [blame] | 1056 | widen_to_long(tcp->u_arg[0]), |
| 1057 | widen_to_long(tcp->u_arg[1]), |
| 1058 | signame(tcp->u_arg[2]) |
| 1059 | ); |
Roland McGrath | 8ffc352 | 2003-07-09 09:47:49 +0000 | [diff] [blame] | 1060 | } |
| 1061 | return 0; |
| 1062 | } |
Roland McGrath | 8ffc352 | 2003-07-09 09:47:49 +0000 | [diff] [blame] | 1063 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1064 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1065 | sys_sigpending(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1066 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1067 | if (exiting(tcp)) { |
| 1068 | if (syserror(tcp)) |
| 1069 | tprintf("%#lx", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1070 | else |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1071 | print_sigset_addr_len(tcp, tcp->u_arg[0], current_wordsize); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1072 | } |
| 1073 | return 0; |
| 1074 | } |
| 1075 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1076 | int |
| 1077 | sys_rt_sigprocmask(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1078 | { |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1079 | /* Note: arg[3] is the length of the sigset. Kernel requires NSIG / 8 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1080 | if (entering(tcp)) { |
| 1081 | printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1082 | tprints(", "); |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1083 | print_sigset_addr_len(tcp, tcp->u_arg[1], tcp->u_arg[3]); |
| 1084 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1085 | } |
| 1086 | else { |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1087 | if (syserror(tcp)) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1088 | tprintf("%#lx", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1089 | else |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1090 | print_sigset_addr_len(tcp, tcp->u_arg[2], tcp->u_arg[3]); |
Nate Sammons | dab325a | 1999-03-29 23:33:35 +0000 | [diff] [blame] | 1091 | tprintf(", %lu", tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1092 | } |
| 1093 | return 0; |
| 1094 | } |
| 1095 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1096 | /* Structure describing the action to be taken when a signal arrives. */ |
| 1097 | struct new_sigaction |
| 1098 | { |
Denys Vlasenko | 86d9484 | 2013-02-08 12:59:13 +0100 | [diff] [blame] | 1099 | /* sa_handler may be a libc #define, need to use other name: */ |
Chris Dearman | 2b4bb1c | 2013-12-09 19:58:42 -0800 | [diff] [blame] | 1100 | #ifdef MIPS |
| 1101 | unsigned int sa_flags; |
| 1102 | void (*__sa_handler)(int); |
| 1103 | #else |
Denys Vlasenko | 86d9484 | 2013-02-08 12:59:13 +0100 | [diff] [blame] | 1104 | void (*__sa_handler)(int); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1105 | unsigned long sa_flags; |
Chris Dearman | 2b4bb1c | 2013-12-09 19:58:42 -0800 | [diff] [blame] | 1106 | #endif /* !MIPS */ |
Dmitry V. Levin | 24b8eb0 | 2015-02-28 17:17:09 +0000 | [diff] [blame] | 1107 | #if HAVE_SA_RESTORER |
Vicente Olivert Riera | c3a5c01 | 2014-09-11 20:05:18 +0100 | [diff] [blame] | 1108 | void (*sa_restorer)(void); |
| 1109 | #endif |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1110 | /* Kernel treats sa_mask as an array of longs. */ |
| 1111 | unsigned long sa_mask[NSIG / sizeof(long) ? NSIG / sizeof(long) : 1]; |
| 1112 | }; |
| 1113 | /* Same for i386-on-x86_64 and similar cases */ |
| 1114 | struct new_sigaction32 |
| 1115 | { |
| 1116 | uint32_t __sa_handler; |
| 1117 | uint32_t sa_flags; |
Dmitry V. Levin | 24b8eb0 | 2015-02-28 17:17:09 +0000 | [diff] [blame] | 1118 | #if HAVE_SA_RESTORER |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1119 | uint32_t sa_restorer; |
Vicente Olivert Riera | c3a5c01 | 2014-09-11 20:05:18 +0100 | [diff] [blame] | 1120 | #endif |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1121 | uint32_t sa_mask[2 * (NSIG / sizeof(long) ? NSIG / sizeof(long) : 1)]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1122 | }; |
| 1123 | |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 1124 | static void |
| 1125 | decode_new_sigaction(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1126 | { |
| 1127 | struct new_sigaction sa; |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1128 | int r; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1129 | |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 1130 | if (!addr) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1131 | tprints("NULL"); |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 1132 | return; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1133 | } |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 1134 | if (!verbose(tcp) || (exiting(tcp) && syserror(tcp))) { |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1135 | tprintf("%#lx", addr); |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 1136 | return; |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1137 | } |
Denys Vlasenko | d4d3ede | 2013-02-13 16:31:32 +0100 | [diff] [blame] | 1138 | #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 |
Denys Vlasenko | 9fd4f96 | 2012-03-19 09:36:42 +0100 | [diff] [blame] | 1139 | if (current_wordsize != sizeof(sa.sa_flags) && current_wordsize == 4) { |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1140 | struct new_sigaction32 sa32; |
| 1141 | r = umove(tcp, addr, &sa32); |
| 1142 | if (r >= 0) { |
| 1143 | memset(&sa, 0, sizeof(sa)); |
| 1144 | sa.__sa_handler = (void*)(unsigned long)sa32.__sa_handler; |
| 1145 | sa.sa_flags = sa32.sa_flags; |
Dmitry V. Levin | 24b8eb0 | 2015-02-28 17:17:09 +0000 | [diff] [blame] | 1146 | #if HAVE_SA_RESTORER && defined SA_RESTORER |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1147 | sa.sa_restorer = (void*)(unsigned long)sa32.sa_restorer; |
Vicente Olivert Riera | c3a5c01 | 2014-09-11 20:05:18 +0100 | [diff] [blame] | 1148 | #endif |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1149 | /* Kernel treats sa_mask as an array of longs. |
| 1150 | * For 32-bit process, "long" is uint32_t, thus, for example, |
| 1151 | * 32th bit in sa_mask will end up as bit 0 in sa_mask[1]. |
| 1152 | * But for (64-bit) kernel, 32th bit in sa_mask is |
| 1153 | * 32th bit in 0th (64-bit) long! |
| 1154 | * For little-endian, it's the same. |
| 1155 | * For big-endian, we swap 32-bit words. |
| 1156 | */ |
| 1157 | sa.sa_mask[0] = sa32.sa_mask[0] + ((long)(sa32.sa_mask[1]) << 32); |
| 1158 | } |
| 1159 | } else |
| 1160 | #endif |
| 1161 | { |
| 1162 | r = umove(tcp, addr, &sa); |
| 1163 | } |
| 1164 | if (r < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1165 | tprints("{...}"); |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 1166 | return; |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1167 | } |
Carlos O'Donell | 4677c8a | 2009-09-09 18:13:19 +0000 | [diff] [blame] | 1168 | /* Architectures using function pointers, like |
| 1169 | * hppa, may need to manipulate the function pointer |
| 1170 | * to compute the result of a comparison. However, |
Denys Vlasenko | 86d9484 | 2013-02-08 12:59:13 +0100 | [diff] [blame] | 1171 | * the __sa_handler function pointer exists only in |
Carlos O'Donell | 4677c8a | 2009-09-09 18:13:19 +0000 | [diff] [blame] | 1172 | * the address space of the traced process, and can't |
| 1173 | * be manipulated by strace. In order to prevent the |
| 1174 | * compiler from generating code to manipulate |
Denys Vlasenko | 86d9484 | 2013-02-08 12:59:13 +0100 | [diff] [blame] | 1175 | * __sa_handler we cast the function pointers to long. */ |
Carlos O'Donell | 4677c8a | 2009-09-09 18:13:19 +0000 | [diff] [blame] | 1176 | if ((long)sa.__sa_handler == (long)SIG_ERR) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1177 | tprints("{SIG_ERR, "); |
Carlos O'Donell | 4677c8a | 2009-09-09 18:13:19 +0000 | [diff] [blame] | 1178 | else if ((long)sa.__sa_handler == (long)SIG_DFL) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1179 | tprints("{SIG_DFL, "); |
Carlos O'Donell | 4677c8a | 2009-09-09 18:13:19 +0000 | [diff] [blame] | 1180 | else if ((long)sa.__sa_handler == (long)SIG_IGN) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1181 | tprints("{SIG_IGN, "); |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1182 | else |
| 1183 | tprintf("{%#lx, ", (long) sa.__sa_handler); |
Denys Vlasenko | 80b73a2 | 2013-07-18 10:10:46 +0200 | [diff] [blame] | 1184 | /* |
| 1185 | * Sigset size is in tcp->u_arg[4] (SPARC) |
| 1186 | * or in tcp->u_arg[3] (all other), |
| 1187 | * but kernel won't handle sys_rt_sigaction |
| 1188 | * with wrong sigset size (just returns EINVAL instead). |
| 1189 | * We just fetch the right size, which is NSIG / 8. |
| 1190 | */ |
Dmitry V. Levin | 38593e9 | 2014-02-26 16:51:28 +0000 | [diff] [blame] | 1191 | tprintsigmask_val("", sa.sa_mask); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1192 | tprints(", "); |
Denys Vlasenko | 80b73a2 | 2013-07-18 10:10:46 +0200 | [diff] [blame] | 1193 | |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1194 | printflags(sigact_flags, sa.sa_flags, "SA_???"); |
Dmitry V. Levin | 24b8eb0 | 2015-02-28 17:17:09 +0000 | [diff] [blame] | 1195 | #if HAVE_SA_RESTORER && defined SA_RESTORER |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1196 | if (sa.sa_flags & SA_RESTORER) |
| 1197 | tprintf(", %p", sa.sa_restorer); |
| 1198 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1199 | tprints("}"); |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 1200 | } |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1201 | |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 1202 | int |
| 1203 | sys_rt_sigaction(struct tcb *tcp) |
| 1204 | { |
| 1205 | if (entering(tcp)) { |
| 1206 | printsignal(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1207 | tprints(", "); |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 1208 | decode_new_sigaction(tcp, tcp->u_arg[1]); |
| 1209 | tprints(", "); |
| 1210 | } else { |
| 1211 | decode_new_sigaction(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 1212 | #if defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 1213 | tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]); |
| 1214 | #elif defined(ALPHA) |
| 1215 | tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]); |
| 1216 | #else |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1217 | tprintf(", %lu", tcp->u_arg[3]); |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 1218 | #endif |
Dmitry V. Levin | ac655a8 | 2014-01-07 22:41:30 +0000 | [diff] [blame] | 1219 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1220 | return 0; |
| 1221 | } |
| 1222 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1223 | int |
| 1224 | sys_rt_sigpending(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1225 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1226 | if (exiting(tcp)) { |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1227 | /* |
| 1228 | * One of the few syscalls where sigset size (arg[1]) |
| 1229 | * is allowed to be <= NSIG / 8, not strictly ==. |
| 1230 | * This allows non-rt sigpending() syscall |
| 1231 | * to reuse rt_sigpending() code in kernel. |
| 1232 | */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1233 | if (syserror(tcp)) |
| 1234 | tprintf("%#lx", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1235 | else |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1236 | print_sigset_addr_len(tcp, tcp->u_arg[0], tcp->u_arg[1]); |
| 1237 | tprintf(", %lu", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1238 | } |
| 1239 | return 0; |
| 1240 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1241 | |
| 1242 | int |
| 1243 | sys_rt_sigsuspend(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1244 | { |
| 1245 | if (entering(tcp)) { |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1246 | /* NB: kernel requires arg[1] == NSIG / 8 */ |
| 1247 | print_sigset_addr_len(tcp, tcp->u_arg[0], tcp->u_arg[1]); |
| 1248 | tprintf(", %lu", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1249 | } |
| 1250 | return 0; |
| 1251 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1252 | |
Dmitry V. Levin | 297632b | 2012-03-13 15:51:13 +0000 | [diff] [blame] | 1253 | static void |
| 1254 | print_sigqueueinfo(struct tcb *tcp, int sig, unsigned long uinfo) |
| 1255 | { |
Dmitry V. Levin | 297632b | 2012-03-13 15:51:13 +0000 | [diff] [blame] | 1256 | printsignal(sig); |
| 1257 | tprints(", "); |
Denys Vlasenko | d4d3ede | 2013-02-13 16:31:32 +0100 | [diff] [blame] | 1258 | printsiginfo_at(tcp, uinfo); |
Dmitry V. Levin | 297632b | 2012-03-13 15:51:13 +0000 | [diff] [blame] | 1259 | } |
| 1260 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1261 | int |
| 1262 | sys_rt_sigqueueinfo(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1263 | { |
| 1264 | if (entering(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1265 | tprintf("%lu, ", tcp->u_arg[0]); |
Dmitry V. Levin | 297632b | 2012-03-13 15:51:13 +0000 | [diff] [blame] | 1266 | print_sigqueueinfo(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 1267 | } |
| 1268 | return 0; |
| 1269 | } |
| 1270 | |
| 1271 | int |
| 1272 | sys_rt_tgsigqueueinfo(struct tcb *tcp) |
| 1273 | { |
| 1274 | if (entering(tcp)) { |
| 1275 | tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 1276 | print_sigqueueinfo(tcp, tcp->u_arg[2], tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1277 | } |
| 1278 | return 0; |
| 1279 | } |
| 1280 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1281 | int sys_rt_sigtimedwait(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1282 | { |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1283 | /* NB: kernel requires arg[3] == NSIG / 8 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1284 | if (entering(tcp)) { |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1285 | print_sigset_addr_len(tcp, tcp->u_arg[0], tcp->u_arg[3]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1286 | tprints(", "); |
Denys Vlasenko | b1a78cf | 2009-04-15 13:31:59 +0000 | [diff] [blame] | 1287 | /* This is the only "return" parameter, */ |
| 1288 | if (tcp->u_arg[1] != 0) |
| 1289 | return 0; |
| 1290 | /* ... if it's NULL, can decode all on entry */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1291 | tprints("NULL, "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1292 | } |
Denys Vlasenko | b1a78cf | 2009-04-15 13:31:59 +0000 | [diff] [blame] | 1293 | else if (tcp->u_arg[1] != 0) { |
| 1294 | /* syscall exit, and u_arg[1] wasn't NULL */ |
Denys Vlasenko | d4d3ede | 2013-02-13 16:31:32 +0100 | [diff] [blame] | 1295 | printsiginfo_at(tcp, tcp->u_arg[1]); |
| 1296 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1297 | } |
Denys Vlasenko | b1a78cf | 2009-04-15 13:31:59 +0000 | [diff] [blame] | 1298 | else { |
| 1299 | /* syscall exit, and u_arg[1] was NULL */ |
| 1300 | return 0; |
| 1301 | } |
| 1302 | print_timespec(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1303 | tprintf(", %lu", tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1304 | return 0; |
| 1305 | }; |
| 1306 | |
Roland McGrath | 79dcd7a | 2006-01-12 22:34:50 +0000 | [diff] [blame] | 1307 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1308 | sys_restart_syscall(struct tcb *tcp) |
Roland McGrath | 79dcd7a | 2006-01-12 22:34:50 +0000 | [diff] [blame] | 1309 | { |
| 1310 | if (entering(tcp)) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1311 | tprints("<... resuming interrupted call ...>"); |
Roland McGrath | 79dcd7a | 2006-01-12 22:34:50 +0000 | [diff] [blame] | 1312 | return 0; |
| 1313 | } |
| 1314 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1315 | static int |
| 1316 | do_signalfd(struct tcb *tcp, int flags_arg) |
Roland McGrath | f46ccd3 | 2007-08-02 01:15:59 +0000 | [diff] [blame] | 1317 | { |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1318 | /* NB: kernel requires arg[2] == NSIG / 8 */ |
Roland McGrath | f46ccd3 | 2007-08-02 01:15:59 +0000 | [diff] [blame] | 1319 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1320 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1321 | tprints(", "); |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 1322 | print_sigset_addr_len(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Dmitry V. Levin | 9d2ee3d | 2009-10-05 13:45:19 +0000 | [diff] [blame] | 1323 | tprintf(", %lu", tcp->u_arg[2]); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1324 | if (flags_arg >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1325 | tprints(", "); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1326 | printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???"); |
| 1327 | } |
Roland McGrath | f46ccd3 | 2007-08-02 01:15:59 +0000 | [diff] [blame] | 1328 | } |
| 1329 | return 0; |
| 1330 | } |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1331 | |
| 1332 | int |
| 1333 | sys_signalfd(struct tcb *tcp) |
| 1334 | { |
| 1335 | return do_signalfd(tcp, -1); |
| 1336 | } |
| 1337 | |
| 1338 | int |
| 1339 | sys_signalfd4(struct tcb *tcp) |
| 1340 | { |
| 1341 | return do_signalfd(tcp, 3); |
| 1342 | } |