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