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