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