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