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. |
| 32 | * |
| 33 | * $Id$ |
| 34 | */ |
| 35 | |
| 36 | #include "defs.h" |
| 37 | |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 38 | #include <stdint.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 39 | #include <signal.h> |
| 40 | #include <sys/user.h> |
| 41 | #include <fcntl.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 42 | |
| 43 | #ifdef SVR4 |
| 44 | #include <sys/ucontext.h> |
| 45 | #endif /* SVR4 */ |
| 46 | |
Wichert Akkerman | 36915a1 | 1999-07-13 15:45:02 +0000 | [diff] [blame] | 47 | #ifdef HAVE_SYS_REG_H |
| 48 | # include <sys/reg.h> |
Wichert Akkerman | 15dea97 | 1999-10-06 13:06:34 +0000 | [diff] [blame] | 49 | #ifndef PTRACE_PEEKUSR |
Wichert Akkerman | 36915a1 | 1999-07-13 15:45:02 +0000 | [diff] [blame] | 50 | # define PTRACE_PEEKUSR PTRACE_PEEKUSER |
Wichert Akkerman | 15dea97 | 1999-10-06 13:06:34 +0000 | [diff] [blame] | 51 | #endif |
| 52 | #ifndef PTRACE_POKEUSR |
Wichert Akkerman | 36915a1 | 1999-07-13 15:45:02 +0000 | [diff] [blame] | 53 | # define PTRACE_POKEUSR PTRACE_POKEUSER |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 54 | #endif |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 55 | #elif defined(HAVE_LINUX_PTRACE_H) |
| 56 | #undef PTRACE_SYSCALL |
Roland McGrath | b0acdfd | 2004-03-01 21:31:02 +0000 | [diff] [blame] | 57 | # ifdef HAVE_STRUCT_IA64_FPREG |
| 58 | # define ia64_fpreg XXX_ia64_fpreg |
| 59 | # endif |
| 60 | # ifdef HAVE_STRUCT_PT_ALL_USER_REGS |
| 61 | # define pt_all_user_regs XXX_pt_all_user_regs |
| 62 | # endif |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 63 | #include <linux/ptrace.h> |
Roland McGrath | b0acdfd | 2004-03-01 21:31:02 +0000 | [diff] [blame] | 64 | # undef ia64_fpreg |
| 65 | # undef pt_all_user_regs |
Wichert Akkerman | 15dea97 | 1999-10-06 13:06:34 +0000 | [diff] [blame] | 66 | #endif |
Wichert Akkerman | 36915a1 | 1999-07-13 15:45:02 +0000 | [diff] [blame] | 67 | |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 68 | |
Wichert Akkerman | 36915a1 | 1999-07-13 15:45:02 +0000 | [diff] [blame] | 69 | #ifdef LINUX |
| 70 | |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 71 | #ifdef IA64 |
| 72 | # include <asm/ptrace_offsets.h> |
| 73 | #endif /* !IA64 */ |
| 74 | |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 75 | #if defined (LINUX) && defined (SPARC64) |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 76 | # undef PTRACE_GETREGS |
| 77 | # define PTRACE_GETREGS PTRACE_GETREGS64 |
| 78 | # undef PTRACE_SETREGS |
| 79 | # define PTRACE_SETREGS PTRACE_SETREGS64 |
| 80 | #endif /* LINUX && SPARC64 */ |
Roland McGrath | 30ff45e | 2003-01-30 20:15:23 +0000 | [diff] [blame] | 81 | |
Mike Frysinger | 8566c50 | 2009-10-12 11:05:14 -0400 | [diff] [blame] | 82 | #if defined (SPARC) || defined (SPARC64) || defined (MIPS) |
Roland McGrath | 576b784 | 2007-11-04 00:00:00 +0000 | [diff] [blame] | 83 | typedef struct { |
| 84 | struct pt_regs si_regs; |
| 85 | int si_mask; |
| 86 | } m_siginfo_t; |
Roland McGrath | 30ff45e | 2003-01-30 20:15:23 +0000 | [diff] [blame] | 87 | #elif defined HAVE_ASM_SIGCONTEXT_H |
| 88 | #if !defined(IA64) && !defined(X86_64) |
Wichert Akkerman | 00a82ee | 2001-03-28 20:29:17 +0000 | [diff] [blame] | 89 | #include <asm/sigcontext.h> |
Roland McGrath | 30ff45e | 2003-01-30 20:15:23 +0000 | [diff] [blame] | 90 | #endif /* !IA64 && !X86_64 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 91 | #else /* !HAVE_ASM_SIGCONTEXT_H */ |
Roland McGrath | 0cbb4e4 | 2008-05-20 01:26:21 +0000 | [diff] [blame] | 92 | #if defined I386 && !defined HAVE_STRUCT_SIGCONTEXT_STRUCT |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 93 | struct sigcontext_struct { |
| 94 | unsigned short gs, __gsh; |
| 95 | unsigned short fs, __fsh; |
| 96 | unsigned short es, __esh; |
| 97 | unsigned short ds, __dsh; |
| 98 | unsigned long edi; |
| 99 | unsigned long esi; |
| 100 | unsigned long ebp; |
| 101 | unsigned long esp; |
| 102 | unsigned long ebx; |
| 103 | unsigned long edx; |
| 104 | unsigned long ecx; |
| 105 | unsigned long eax; |
| 106 | unsigned long trapno; |
| 107 | unsigned long err; |
| 108 | unsigned long eip; |
| 109 | unsigned short cs, __csh; |
| 110 | unsigned long eflags; |
| 111 | unsigned long esp_at_signal; |
| 112 | unsigned short ss, __ssh; |
| 113 | unsigned long i387; |
| 114 | unsigned long oldmask; |
| 115 | unsigned long cr2; |
| 116 | }; |
| 117 | #else /* !I386 */ |
Roland McGrath | 587c7b5 | 2009-02-11 03:03:28 +0000 | [diff] [blame] | 118 | #if defined M68K && !defined HAVE_STRUCT_SIGCONTEXT |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 119 | struct sigcontext |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 120 | { |
| 121 | unsigned long sc_mask; |
| 122 | unsigned long sc_usp; |
| 123 | unsigned long sc_d0; |
| 124 | unsigned long sc_d1; |
| 125 | unsigned long sc_a0; |
| 126 | unsigned long sc_a1; |
| 127 | unsigned short sc_sr; |
| 128 | unsigned long sc_pc; |
| 129 | unsigned short sc_formatvec; |
| 130 | }; |
| 131 | #endif /* M68K */ |
| 132 | #endif /* !I386 */ |
| 133 | #endif /* !HAVE_ASM_SIGCONTEXT_H */ |
| 134 | #ifndef NSIG |
| 135 | #define NSIG 32 |
| 136 | #endif |
| 137 | #ifdef ARM |
| 138 | #undef NSIG |
| 139 | #define NSIG 32 |
| 140 | #endif |
| 141 | #endif /* LINUX */ |
| 142 | |
Roland McGrath | ee36ce1 | 2004-09-04 03:53:10 +0000 | [diff] [blame] | 143 | const char *const signalent0[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 144 | #include "signalent.h" |
| 145 | }; |
Roland McGrath | ee36ce1 | 2004-09-04 03:53:10 +0000 | [diff] [blame] | 146 | const int nsignals0 = sizeof signalent0 / sizeof signalent0[0]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 147 | |
| 148 | #if SUPPORTED_PERSONALITIES >= 2 |
Roland McGrath | ee36ce1 | 2004-09-04 03:53:10 +0000 | [diff] [blame] | 149 | const char *const signalent1[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 150 | #include "signalent1.h" |
| 151 | }; |
Roland McGrath | ee36ce1 | 2004-09-04 03:53:10 +0000 | [diff] [blame] | 152 | const int nsignals1 = sizeof signalent1 / sizeof signalent1[0]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 153 | #endif /* SUPPORTED_PERSONALITIES >= 2 */ |
| 154 | |
| 155 | #if SUPPORTED_PERSONALITIES >= 3 |
Roland McGrath | ee36ce1 | 2004-09-04 03:53:10 +0000 | [diff] [blame] | 156 | const char *const signalent2[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 157 | #include "signalent2.h" |
| 158 | }; |
Roland McGrath | ee36ce1 | 2004-09-04 03:53:10 +0000 | [diff] [blame] | 159 | const int nsignals2 = sizeof signalent2 / sizeof signalent2[0]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 160 | #endif /* SUPPORTED_PERSONALITIES >= 3 */ |
| 161 | |
Roland McGrath | ee36ce1 | 2004-09-04 03:53:10 +0000 | [diff] [blame] | 162 | const char *const *signalent; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 163 | int nsignals; |
| 164 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 165 | #if defined(SUNOS4) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 166 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 167 | static const struct xlat sigvec_flags[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 168 | { SV_ONSTACK, "SV_ONSTACK" }, |
| 169 | { SV_INTERRUPT, "SV_INTERRUPT" }, |
| 170 | { SV_RESETHAND, "SV_RESETHAND" }, |
| 171 | { SA_NOCLDSTOP, "SA_NOCLDSTOP" }, |
| 172 | { 0, NULL }, |
| 173 | }; |
| 174 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 175 | #endif /* SUNOS4 || FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 176 | |
| 177 | #ifdef HAVE_SIGACTION |
| 178 | |
Roland McGrath | 063ae2d | 2005-02-02 04:16:54 +0000 | [diff] [blame] | 179 | #if defined LINUX && (defined I386 || defined X86_64) |
Roland McGrath | 2638cb4 | 2002-12-15 23:58:41 +0000 | [diff] [blame] | 180 | /* The libc headers do not define this constant since it should only be |
| 181 | used by the implementation. So wwe define it here. */ |
| 182 | # ifndef SA_RESTORER |
| 183 | # define SA_RESTORER 0x04000000 |
| 184 | # endif |
| 185 | #endif |
| 186 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 187 | static const struct xlat sigact_flags[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 188 | #ifdef SA_RESTORER |
| 189 | { SA_RESTORER, "SA_RESTORER" }, |
| 190 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 191 | #ifdef SA_STACK |
| 192 | { SA_STACK, "SA_STACK" }, |
| 193 | #endif |
| 194 | #ifdef SA_RESTART |
| 195 | { SA_RESTART, "SA_RESTART" }, |
| 196 | #endif |
| 197 | #ifdef SA_INTERRUPT |
| 198 | { SA_INTERRUPT, "SA_INTERRUPT" }, |
| 199 | #endif |
Roland McGrath | 4fef51d | 2008-07-18 01:02:41 +0000 | [diff] [blame] | 200 | #ifdef SA_NODEFER |
| 201 | { SA_NODEFER, "SA_NODEFER" }, |
| 202 | #endif |
| 203 | #if defined SA_NOMASK && SA_NODEFER != SA_NOMASK |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 204 | { SA_NOMASK, "SA_NOMASK" }, |
| 205 | #endif |
Roland McGrath | 4fef51d | 2008-07-18 01:02:41 +0000 | [diff] [blame] | 206 | #ifdef SA_RESETHAND |
| 207 | { SA_RESETHAND, "SA_RESETHAND" }, |
| 208 | #endif |
| 209 | #if defined SA_ONESHOT && SA_ONESHOT != SA_RESETHAND |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 210 | { SA_ONESHOT, "SA_ONESHOT" }, |
| 211 | #endif |
| 212 | #ifdef SA_SIGINFO |
| 213 | { SA_SIGINFO, "SA_SIGINFO" }, |
| 214 | #endif |
| 215 | #ifdef SA_RESETHAND |
| 216 | { SA_RESETHAND, "SA_RESETHAND" }, |
| 217 | #endif |
| 218 | #ifdef SA_ONSTACK |
| 219 | { SA_ONSTACK, "SA_ONSTACK" }, |
| 220 | #endif |
| 221 | #ifdef SA_NODEFER |
| 222 | { SA_NODEFER, "SA_NODEFER" }, |
| 223 | #endif |
| 224 | #ifdef SA_NOCLDSTOP |
| 225 | { SA_NOCLDSTOP, "SA_NOCLDSTOP" }, |
| 226 | #endif |
| 227 | #ifdef SA_NOCLDWAIT |
| 228 | { SA_NOCLDWAIT, "SA_NOCLDWAIT" }, |
| 229 | #endif |
| 230 | #ifdef _SA_BSDCALL |
| 231 | { _SA_BSDCALL, "_SA_BSDCALL" }, |
| 232 | #endif |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 233 | #ifdef SA_NOPTRACE |
| 234 | { SA_NOPTRACE, "SA_NOPTRACE" }, |
| 235 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 236 | { 0, NULL }, |
| 237 | }; |
| 238 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 239 | static const struct xlat sigprocmaskcmds[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 240 | { SIG_BLOCK, "SIG_BLOCK" }, |
| 241 | { SIG_UNBLOCK, "SIG_UNBLOCK" }, |
| 242 | { SIG_SETMASK, "SIG_SETMASK" }, |
| 243 | #ifdef SIG_SETMASK32 |
| 244 | { SIG_SETMASK32,"SIG_SETMASK32" }, |
| 245 | #endif |
| 246 | { 0, NULL }, |
| 247 | }; |
| 248 | |
| 249 | #endif /* HAVE_SIGACTION */ |
| 250 | |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 251 | /* Anonymous realtime signals. */ |
| 252 | /* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a |
| 253 | constant. This is what we want. Otherwise, just use SIGRTMIN. */ |
| 254 | #ifdef SIGRTMIN |
| 255 | #ifndef __SIGRTMIN |
| 256 | #define __SIGRTMIN SIGRTMIN |
| 257 | #define __SIGRTMAX SIGRTMAX /* likewise */ |
| 258 | #endif |
| 259 | #endif |
| 260 | |
Roland McGrath | ee36ce1 | 2004-09-04 03:53:10 +0000 | [diff] [blame] | 261 | const char * |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 262 | signame(sig) |
| 263 | int sig; |
| 264 | { |
| 265 | static char buf[30]; |
Roland McGrath | ad81dce | 2005-05-09 07:40:30 +0000 | [diff] [blame] | 266 | if (sig >= 0 && sig < nsignals) { |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 267 | return signalent[sig]; |
| 268 | #ifdef SIGRTMIN |
Nate Sammons | 3080aa4 | 1999-03-30 00:16:41 +0000 | [diff] [blame] | 269 | } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 270 | sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN)); |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 271 | return buf; |
| 272 | #endif /* SIGRTMIN */ |
| 273 | } else { |
| 274 | sprintf(buf, "%d", sig); |
| 275 | return buf; |
| 276 | } |
| 277 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 278 | |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 279 | #ifndef UNIXWARE |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 280 | static void |
| 281 | long_to_sigset(l, s) |
| 282 | long l; |
| 283 | sigset_t *s; |
| 284 | { |
| 285 | sigemptyset(s); |
| 286 | *(long *)s = l; |
| 287 | } |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 288 | #endif |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 289 | |
| 290 | static int |
| 291 | copy_sigset_len(tcp, addr, s, len) |
| 292 | struct tcb *tcp; |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 293 | long addr; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 294 | sigset_t *s; |
| 295 | int len; |
| 296 | { |
| 297 | if (len > sizeof(*s)) |
| 298 | len = sizeof(*s); |
| 299 | sigemptyset(s); |
| 300 | if (umoven(tcp, addr, len, (char *)s) < 0) |
| 301 | return -1; |
| 302 | return 0; |
| 303 | } |
| 304 | |
| 305 | #ifdef LINUX |
| 306 | /* Original sigset is unsigned long */ |
| 307 | #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long)) |
| 308 | #else |
| 309 | #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t)) |
| 310 | #endif |
| 311 | |
Dmitry V. Levin | ab9008b | 2007-01-11 22:05:04 +0000 | [diff] [blame] | 312 | static const char * |
| 313 | sprintsigmask(const char *str, sigset_t *mask, int rt) |
| 314 | /* set might include realtime sigs */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 315 | { |
| 316 | int i, nsigs; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 317 | int maxsigs; |
Dmitry V. Levin | ab9008b | 2007-01-11 22:05:04 +0000 | [diff] [blame] | 318 | char *format, *s; |
Roland McGrath | a39c5a1 | 2002-12-17 05:10:37 +0000 | [diff] [blame] | 319 | static char outstr[8 * sizeof(sigset_t) * 8]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 320 | |
Dmitry V. Levin | ab9008b | 2007-01-11 22:05:04 +0000 | [diff] [blame] | 321 | strcpy(outstr, str); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 322 | s = outstr + strlen(outstr); |
| 323 | nsigs = 0; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 324 | maxsigs = nsignals; |
| 325 | #ifdef __SIGRTMAX |
| 326 | if (rt) |
| 327 | maxsigs = __SIGRTMAX; /* instead */ |
| 328 | #endif |
| 329 | for (i = 1; i < maxsigs; i++) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 330 | if (sigismember(mask, i) == 1) |
| 331 | nsigs++; |
| 332 | } |
| 333 | if (nsigs >= nsignals * 2 / 3) { |
| 334 | *s++ = '~'; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 335 | for (i = 1; i < maxsigs; i++) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 336 | switch (sigismember(mask, i)) { |
| 337 | case 1: |
| 338 | sigdelset(mask, i); |
| 339 | break; |
| 340 | case 0: |
| 341 | sigaddset(mask, i); |
| 342 | break; |
| 343 | } |
| 344 | } |
| 345 | } |
| 346 | format = "%s"; |
| 347 | *s++ = '['; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 348 | for (i = 1; i < maxsigs; i++) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 349 | if (sigismember(mask, i) == 1) { |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 350 | /* real-time signals on solaris don't have |
| 351 | * signalent entries |
| 352 | */ |
| 353 | if (i < nsignals) { |
| 354 | sprintf(s, format, signalent[i] + 3); |
| 355 | } |
Roland McGrath | 90b4cb5 | 2003-09-23 22:19:32 +0000 | [diff] [blame] | 356 | #ifdef SIGRTMIN |
| 357 | else if (i >= __SIGRTMIN && i <= __SIGRTMAX) { |
| 358 | char tsig[40]; |
| 359 | sprintf(tsig, "RT_%u", i - __SIGRTMIN); |
| 360 | sprintf(s, format, tsig); |
| 361 | } |
| 362 | #endif /* SIGRTMIN */ |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 363 | else { |
| 364 | char tsig[32]; |
| 365 | sprintf(tsig, "%u", i); |
| 366 | sprintf(s, format, tsig); |
| 367 | } |
| 368 | s += strlen(s); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 369 | format = " %s"; |
| 370 | } |
| 371 | } |
| 372 | *s++ = ']'; |
| 373 | *s = '\0'; |
| 374 | return outstr; |
| 375 | } |
| 376 | |
| 377 | static void |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 378 | printsigmask(mask, rt) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 379 | sigset_t *mask; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 380 | int rt; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 381 | { |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 382 | tprintf("%s", sprintsigmask("", mask, rt)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | void |
| 386 | printsignal(nr) |
| 387 | int nr; |
| 388 | { |
Dmitry V. Levin | 4bcd5ef | 2009-06-01 10:32:27 +0000 | [diff] [blame] | 389 | tprintf("%s", signame(nr)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 390 | } |
| 391 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 392 | void |
| 393 | print_sigset(struct tcb *tcp, long addr, int rt) |
| 394 | { |
| 395 | sigset_t ss; |
| 396 | |
| 397 | if (!addr) |
| 398 | tprintf("NULL"); |
| 399 | else if (copy_sigset(tcp, addr, &ss) < 0) |
| 400 | tprintf("%#lx", addr); |
| 401 | else |
| 402 | printsigmask(&ss, rt); |
| 403 | } |
| 404 | |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 405 | #ifdef LINUX |
| 406 | |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 407 | #ifndef ILL_ILLOPC |
| 408 | #define ILL_ILLOPC 1 /* illegal opcode */ |
| 409 | #define ILL_ILLOPN 2 /* illegal operand */ |
| 410 | #define ILL_ILLADR 3 /* illegal addressing mode */ |
| 411 | #define ILL_ILLTRP 4 /* illegal trap */ |
| 412 | #define ILL_PRVOPC 5 /* privileged opcode */ |
| 413 | #define ILL_PRVREG 6 /* privileged register */ |
| 414 | #define ILL_COPROC 7 /* coprocessor error */ |
| 415 | #define ILL_BADSTK 8 /* internal stack error */ |
| 416 | #define FPE_INTDIV 1 /* integer divide by zero */ |
| 417 | #define FPE_INTOVF 2 /* integer overflow */ |
| 418 | #define FPE_FLTDIV 3 /* floating point divide by zero */ |
| 419 | #define FPE_FLTOVF 4 /* floating point overflow */ |
| 420 | #define FPE_FLTUND 5 /* floating point underflow */ |
| 421 | #define FPE_FLTRES 6 /* floating point inexact result */ |
| 422 | #define FPE_FLTINV 7 /* floating point invalid operation */ |
| 423 | #define FPE_FLTSUB 8 /* subscript out of range */ |
| 424 | #define SEGV_MAPERR 1 /* address not mapped to object */ |
| 425 | #define SEGV_ACCERR 2 /* invalid permissions for mapped object */ |
| 426 | #define BUS_ADRALN 1 /* invalid address alignment */ |
| 427 | #define BUS_ADRERR 2 /* non-existant physical address */ |
| 428 | #define BUS_OBJERR 3 /* object specific hardware error */ |
| 429 | #define TRAP_BRKPT 1 /* process breakpoint */ |
| 430 | #define TRAP_TRACE 2 /* process trace trap */ |
| 431 | #define CLD_EXITED 1 /* child has exited */ |
| 432 | #define CLD_KILLED 2 /* child was killed */ |
| 433 | #define CLD_DUMPED 3 /* child terminated abnormally */ |
| 434 | #define CLD_TRAPPED 4 /* traced child has trapped */ |
| 435 | #define CLD_STOPPED 5 /* child has stopped */ |
| 436 | #define CLD_CONTINUED 6 /* stopped child has continued */ |
| 437 | #define POLL_IN 1 /* data input available */ |
| 438 | #define POLL_OUT 2 /* output buffers available */ |
| 439 | #define POLL_MSG 3 /* input message available */ |
| 440 | #define POLL_ERR 4 /* i/o error */ |
| 441 | #define POLL_PRI 5 /* high priority input available */ |
| 442 | #define POLL_HUP 6 /* device disconnected */ |
| 443 | #define SI_USER 0 /* sent by kill, sigsend, raise */ |
| 444 | #define SI_QUEUE -1 /* sent by sigqueue */ |
| 445 | #define SI_TIMER -2 /* sent by timer expiration */ |
| 446 | #define SI_MESGQ -3 /* sent by real time mesq state change */ |
| 447 | #define SI_ASYNCIO -4 /* sent by AIO completion */ |
Roland McGrath | 941b740 | 2003-05-23 00:29:02 +0000 | [diff] [blame] | 448 | #define SI_SIGIO -5 /* Sent by SIGIO */ |
| 449 | #define SI_TKILL -6 /* Sent by tkill */ |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 450 | #endif |
| 451 | |
| 452 | #if __GLIBC_MINOR__ < 1 |
| 453 | /* Type for data associated with a signal. */ |
| 454 | typedef union sigval |
| 455 | { |
| 456 | int sival_int; |
| 457 | void *sival_ptr; |
| 458 | } sigval_t; |
| 459 | |
| 460 | # define __SI_MAX_SIZE 128 |
| 461 | # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3) |
| 462 | |
| 463 | typedef struct siginfo |
| 464 | { |
| 465 | int si_signo; /* Signal number. */ |
| 466 | int si_errno; /* If non-zero, an errno value associated with |
| 467 | this signal, as defined in <errno.h>. */ |
| 468 | int si_code; /* Signal code. */ |
| 469 | |
| 470 | union |
| 471 | { |
| 472 | int _pad[__SI_PAD_SIZE]; |
| 473 | |
| 474 | /* kill(). */ |
| 475 | struct |
| 476 | { |
| 477 | __pid_t si_pid; /* Sending process ID. */ |
| 478 | __uid_t si_uid; /* Real user ID of sending process. */ |
| 479 | } _kill; |
| 480 | |
| 481 | /* POSIX.1b timers. */ |
| 482 | struct |
| 483 | { |
| 484 | unsigned int _timer1; |
| 485 | unsigned int _timer2; |
| 486 | } _timer; |
| 487 | |
| 488 | /* POSIX.1b signals. */ |
| 489 | struct |
| 490 | { |
| 491 | __pid_t si_pid; /* Sending process ID. */ |
| 492 | __uid_t si_uid; /* Real user ID of sending process. */ |
| 493 | sigval_t si_sigval; /* Signal value. */ |
| 494 | } _rt; |
| 495 | |
| 496 | /* SIGCHLD. */ |
| 497 | struct |
| 498 | { |
| 499 | __pid_t si_pid; /* Which child. */ |
| 500 | int si_status; /* Exit value or signal. */ |
| 501 | __clock_t si_utime; |
| 502 | __clock_t si_stime; |
| 503 | } _sigchld; |
| 504 | |
| 505 | /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */ |
| 506 | struct |
| 507 | { |
| 508 | void *si_addr; /* Faulting insn/memory ref. */ |
| 509 | } _sigfault; |
| 510 | |
| 511 | /* SIGPOLL. */ |
| 512 | struct |
| 513 | { |
| 514 | int si_band; /* Band event for SIGPOLL. */ |
| 515 | int si_fd; |
| 516 | } _sigpoll; |
| 517 | } _sifields; |
| 518 | } siginfo_t; |
| 519 | |
| 520 | #define si_pid _sifields._kill.si_pid |
| 521 | #define si_uid _sifields._kill.si_uid |
| 522 | #define si_status _sifields._sigchld.si_status |
| 523 | #define si_utime _sifields._sigchld.si_utime |
| 524 | #define si_stime _sifields._sigchld.si_stime |
| 525 | #define si_value _sifields._rt.si_sigval |
| 526 | #define si_int _sifields._rt.si_sigval.sival_int |
| 527 | #define si_ptr _sifields._rt.si_sigval.sival_ptr |
| 528 | #define si_addr _sifields._sigfault.si_addr |
| 529 | #define si_band _sifields._sigpoll.si_band |
| 530 | #define si_fd _sifields._sigpoll.si_fd |
| 531 | |
| 532 | #endif |
| 533 | |
| 534 | #endif |
| 535 | |
| 536 | #if defined (SVR4) || defined (LINUX) |
| 537 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 538 | static const struct xlat siginfo_codes[] = { |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 539 | #ifdef SI_NOINFO |
| 540 | { SI_NOINFO, "SI_NOINFO" }, |
| 541 | #endif |
| 542 | #ifdef SI_USER |
| 543 | { SI_USER, "SI_USER" }, |
| 544 | #endif |
| 545 | #ifdef SI_LWP |
| 546 | { SI_LWP, "SI_LWP" }, |
| 547 | #endif |
| 548 | #ifdef SI_QUEUE |
| 549 | { SI_QUEUE, "SI_QUEUE" }, |
| 550 | #endif |
| 551 | #ifdef SI_TIMER |
| 552 | { SI_TIMER, "SI_TIMER" }, |
| 553 | #endif |
| 554 | #ifdef SI_ASYNCIO |
| 555 | { SI_ASYNCIO, "SI_ASYNCIO" }, |
| 556 | #endif |
| 557 | #ifdef SI_MESGQ |
| 558 | { SI_MESGQ, "SI_MESGQ" }, |
| 559 | #endif |
Roland McGrath | 941b740 | 2003-05-23 00:29:02 +0000 | [diff] [blame] | 560 | #ifdef SI_SIGIO |
| 561 | { SI_SIGIO, "SI_SIGIO" }, |
| 562 | #endif |
| 563 | #ifdef SI_TKILL |
| 564 | { SI_TKILL, "SI_TKILL" }, |
| 565 | #endif |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 566 | { 0, NULL }, |
| 567 | }; |
| 568 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 569 | static const struct xlat sigill_codes[] = { |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 570 | { ILL_ILLOPC, "ILL_ILLOPC" }, |
| 571 | { ILL_ILLOPN, "ILL_ILLOPN" }, |
| 572 | { ILL_ILLADR, "ILL_ILLADR" }, |
| 573 | { ILL_ILLTRP, "ILL_ILLTRP" }, |
| 574 | { ILL_PRVOPC, "ILL_PRVOPC" }, |
| 575 | { ILL_PRVREG, "ILL_PRVREG" }, |
| 576 | { ILL_COPROC, "ILL_COPROC" }, |
| 577 | { ILL_BADSTK, "ILL_BADSTK" }, |
| 578 | { 0, NULL }, |
| 579 | }; |
| 580 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 581 | static const struct xlat sigfpe_codes[] = { |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 582 | { FPE_INTDIV, "FPE_INTDIV" }, |
| 583 | { FPE_INTOVF, "FPE_INTOVF" }, |
| 584 | { FPE_FLTDIV, "FPE_FLTDIV" }, |
| 585 | { FPE_FLTOVF, "FPE_FLTOVF" }, |
| 586 | { FPE_FLTUND, "FPE_FLTUND" }, |
| 587 | { FPE_FLTRES, "FPE_FLTRES" }, |
| 588 | { FPE_FLTINV, "FPE_FLTINV" }, |
| 589 | { FPE_FLTSUB, "FPE_FLTSUB" }, |
| 590 | { 0, NULL }, |
| 591 | }; |
| 592 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 593 | static const struct xlat sigtrap_codes[] = { |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 594 | { TRAP_BRKPT, "TRAP_BRKPT" }, |
| 595 | { TRAP_TRACE, "TRAP_TRACE" }, |
| 596 | { 0, NULL }, |
| 597 | }; |
| 598 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 599 | static const struct xlat sigchld_codes[] = { |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 600 | { CLD_EXITED, "CLD_EXITED" }, |
| 601 | { CLD_KILLED, "CLD_KILLED" }, |
| 602 | { CLD_DUMPED, "CLD_DUMPED" }, |
| 603 | { CLD_TRAPPED, "CLD_TRAPPED" }, |
| 604 | { CLD_STOPPED, "CLD_STOPPED" }, |
| 605 | { CLD_CONTINUED,"CLD_CONTINUED" }, |
| 606 | { 0, NULL }, |
| 607 | }; |
| 608 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 609 | static const struct xlat sigpoll_codes[] = { |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 610 | { POLL_IN, "POLL_IN" }, |
| 611 | { POLL_OUT, "POLL_OUT" }, |
| 612 | { POLL_MSG, "POLL_MSG" }, |
| 613 | { POLL_ERR, "POLL_ERR" }, |
| 614 | { POLL_PRI, "POLL_PRI" }, |
| 615 | { POLL_HUP, "POLL_HUP" }, |
| 616 | { 0, NULL }, |
| 617 | }; |
| 618 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 619 | static const struct xlat sigprof_codes[] = { |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 620 | #ifdef PROF_SIG |
| 621 | { PROF_SIG, "PROF_SIG" }, |
| 622 | #endif |
| 623 | { 0, NULL }, |
| 624 | }; |
| 625 | |
| 626 | #ifdef SIGEMT |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 627 | static const struct xlat sigemt_codes[] = { |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 628 | #ifdef EMT_TAGOVF |
| 629 | { EMT_TAGOVF, "EMT_TAGOVF" }, |
| 630 | #endif |
| 631 | { 0, NULL }, |
| 632 | }; |
| 633 | #endif |
| 634 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 635 | static const struct xlat sigsegv_codes[] = { |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 636 | { SEGV_MAPERR, "SEGV_MAPERR" }, |
| 637 | { SEGV_ACCERR, "SEGV_ACCERR" }, |
| 638 | { 0, NULL }, |
| 639 | }; |
| 640 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 641 | static const struct xlat sigbus_codes[] = { |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 642 | { BUS_ADRALN, "BUS_ADRALN" }, |
| 643 | { BUS_ADRERR, "BUS_ADRERR" }, |
| 644 | { BUS_OBJERR, "BUS_OBJERR" }, |
| 645 | { 0, NULL }, |
| 646 | }; |
| 647 | |
| 648 | void |
| 649 | printsiginfo(sip, verbose) |
| 650 | siginfo_t *sip; |
| 651 | int verbose; |
| 652 | { |
Roland McGrath | f9c49b2 | 2004-10-06 22:11:54 +0000 | [diff] [blame] | 653 | const char *code; |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 654 | |
| 655 | if (sip->si_signo == 0) { |
| 656 | tprintf ("{}"); |
| 657 | return; |
| 658 | } |
| 659 | tprintf("{si_signo="); |
| 660 | printsignal(sip->si_signo); |
| 661 | code = xlookup(siginfo_codes, sip->si_code); |
| 662 | if (!code) { |
| 663 | switch (sip->si_signo) { |
| 664 | case SIGTRAP: |
| 665 | code = xlookup(sigtrap_codes, sip->si_code); |
| 666 | break; |
| 667 | case SIGCHLD: |
| 668 | code = xlookup(sigchld_codes, sip->si_code); |
| 669 | break; |
| 670 | case SIGPOLL: |
| 671 | code = xlookup(sigpoll_codes, sip->si_code); |
| 672 | break; |
| 673 | case SIGPROF: |
| 674 | code = xlookup(sigprof_codes, sip->si_code); |
| 675 | break; |
| 676 | case SIGILL: |
| 677 | code = xlookup(sigill_codes, sip->si_code); |
| 678 | break; |
| 679 | #ifdef SIGEMT |
| 680 | case SIGEMT: |
| 681 | code = xlookup(sigemt_codes, sip->si_code); |
| 682 | break; |
| 683 | #endif |
| 684 | case SIGFPE: |
| 685 | code = xlookup(sigfpe_codes, sip->si_code); |
| 686 | break; |
| 687 | case SIGSEGV: |
| 688 | code = xlookup(sigsegv_codes, sip->si_code); |
| 689 | break; |
| 690 | case SIGBUS: |
| 691 | code = xlookup(sigbus_codes, sip->si_code); |
| 692 | break; |
| 693 | } |
| 694 | } |
| 695 | if (code) |
| 696 | tprintf(", si_code=%s", code); |
| 697 | else |
| 698 | tprintf(", si_code=%#x", sip->si_code); |
| 699 | #ifdef SI_NOINFO |
| 700 | if (sip->si_code != SI_NOINFO) |
| 701 | #endif |
| 702 | { |
| 703 | if (sip->si_errno) { |
| 704 | if (sip->si_errno < 0 || sip->si_errno >= nerrnos) |
| 705 | tprintf(", si_errno=%d", sip->si_errno); |
| 706 | else |
| 707 | tprintf(", si_errno=%s", |
| 708 | errnoent[sip->si_errno]); |
| 709 | } |
| 710 | #ifdef SI_FROMUSER |
| 711 | if (SI_FROMUSER(sip)) { |
| 712 | tprintf(", si_pid=%ld, si_uid=%ld", |
| 713 | sip->si_pid, sip->si_uid); |
| 714 | #ifdef SI_QUEUE |
| 715 | switch (sip->si_code) { |
| 716 | case SI_QUEUE: |
| 717 | #ifdef SI_TIMER |
| 718 | case SI_TIMER: |
| 719 | #endif /* SI_QUEUE */ |
| 720 | case SI_ASYNCIO: |
| 721 | #ifdef SI_MESGQ |
| 722 | case SI_MESGQ: |
| 723 | #endif /* SI_MESGQ */ |
| 724 | tprintf(", si_value=%d", |
| 725 | sip->si_value.sival_int); |
| 726 | break; |
| 727 | } |
| 728 | #endif /* SI_QUEUE */ |
| 729 | } |
| 730 | else |
| 731 | #endif /* SI_FROMUSER */ |
| 732 | { |
| 733 | switch (sip->si_signo) { |
| 734 | case SIGCHLD: |
| 735 | tprintf(", si_pid=%ld, si_status=", |
| 736 | (long) sip->si_pid); |
| 737 | if (sip->si_code == CLD_EXITED) |
| 738 | tprintf("%d", sip->si_status); |
| 739 | else |
| 740 | printsignal(sip->si_status); |
| 741 | #if LINUX |
| 742 | if (!verbose) |
| 743 | tprintf(", ..."); |
| 744 | else |
| 745 | tprintf(", si_utime=%lu, si_stime=%lu", |
| 746 | sip->si_utime, |
| 747 | sip->si_stime); |
| 748 | #endif |
| 749 | break; |
| 750 | case SIGILL: case SIGFPE: |
| 751 | case SIGSEGV: case SIGBUS: |
| 752 | tprintf(", si_addr=%#lx", |
| 753 | (unsigned long) sip->si_addr); |
| 754 | break; |
| 755 | case SIGPOLL: |
| 756 | switch (sip->si_code) { |
| 757 | case POLL_IN: case POLL_OUT: case POLL_MSG: |
| 758 | tprintf(", si_band=%ld", |
| 759 | (long) sip->si_band); |
| 760 | break; |
| 761 | } |
| 762 | break; |
| 763 | #ifdef LINUX |
| 764 | default: |
| 765 | tprintf(", si_pid=%lu, si_uid=%lu, ", |
| 766 | (unsigned long) sip->si_pid, |
| 767 | (unsigned long) sip->si_uid); |
| 768 | if (!verbose) |
| 769 | tprintf("..."); |
| 770 | else { |
| 771 | tprintf("si_value={int=%u, ptr=%#lx}", |
| 772 | sip->si_int, |
| 773 | (unsigned long) sip->si_ptr); |
| 774 | } |
| 775 | #endif |
Roland McGrath | a39c5a1 | 2002-12-17 05:10:37 +0000 | [diff] [blame] | 776 | |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 777 | } |
| 778 | } |
| 779 | } |
| 780 | tprintf("}"); |
| 781 | } |
| 782 | |
| 783 | #endif /* SVR4 || LINUX */ |
| 784 | |
| 785 | #ifdef LINUX |
| 786 | |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 787 | static void |
| 788 | parse_sigset_t (const char *str, sigset_t *set) |
| 789 | { |
Roland McGrath | c38feca | 2003-10-01 07:50:28 +0000 | [diff] [blame] | 790 | const char *p; |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 791 | unsigned int digit; |
| 792 | int i; |
| 793 | |
| 794 | sigemptyset(set); |
| 795 | |
Roland McGrath | c38feca | 2003-10-01 07:50:28 +0000 | [diff] [blame] | 796 | p = strchr(str, '\n'); |
| 797 | if (p == NULL) |
| 798 | p = strchr(str, '\0'); |
| 799 | for (i = 0; p-- > str; i += 4) { |
| 800 | if (*p >= '0' && *p <= '9') |
| 801 | digit = *p - '0'; |
| 802 | else if (*p >= 'a' && *p <= 'f') |
Roland McGrath | 92f1d6d | 2004-08-31 07:03:20 +0000 | [diff] [blame] | 803 | digit = *p - 'a' + 10; |
Roland McGrath | c38feca | 2003-10-01 07:50:28 +0000 | [diff] [blame] | 804 | else if (*p >= 'A' && *p <= 'F') |
Roland McGrath | 92f1d6d | 2004-08-31 07:03:20 +0000 | [diff] [blame] | 805 | digit = *p - 'A' + 10; |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 806 | else |
Roland McGrath | c38feca | 2003-10-01 07:50:28 +0000 | [diff] [blame] | 807 | break; |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 808 | if (digit & 1) |
| 809 | sigaddset(set, i + 1); |
| 810 | if (digit & 2) |
| 811 | sigaddset(set, i + 2); |
| 812 | if (digit & 4) |
| 813 | sigaddset(set, i + 3); |
| 814 | if (digit & 8) |
| 815 | sigaddset(set, i + 4); |
| 816 | } |
| 817 | } |
| 818 | |
| 819 | #endif |
| 820 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 821 | /* |
| 822 | * Check process TCP for the disposition of signal SIG. |
| 823 | * Return 1 if the process would somehow manage to survive signal SIG, |
| 824 | * else return 0. This routine will never be called with SIGKILL. |
| 825 | */ |
| 826 | int |
| 827 | sigishandled(tcp, sig) |
| 828 | struct tcb *tcp; |
| 829 | int sig; |
| 830 | { |
| 831 | #ifdef LINUX |
| 832 | int sfd; |
| 833 | char sname[32]; |
Wichert Akkerman | d5c2dae | 2001-04-12 09:10:24 +0000 | [diff] [blame] | 834 | char buf[2048]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 835 | char *s; |
| 836 | int i; |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 837 | sigset_t ignored, caught; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 838 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 839 | #ifdef SVR4 |
| 840 | /* |
| 841 | * Since procfs doesn't interfere with wait I think it is safe |
| 842 | * to punt on this question. If not, the information is there. |
| 843 | */ |
| 844 | return 1; |
| 845 | #else /* !SVR4 */ |
| 846 | switch (sig) { |
| 847 | case SIGCONT: |
| 848 | case SIGSTOP: |
| 849 | case SIGTSTP: |
| 850 | case SIGTTIN: |
| 851 | case SIGTTOU: |
| 852 | case SIGCHLD: |
| 853 | case SIGIO: |
| 854 | #if defined(SIGURG) && SIGURG != SIGIO |
| 855 | case SIGURG: |
| 856 | #endif |
| 857 | case SIGWINCH: |
| 858 | /* Gloria Gaynor says ... */ |
| 859 | return 1; |
| 860 | default: |
| 861 | break; |
| 862 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 863 | #endif /* !SVR4 */ |
Wichert Akkerman | d5c2dae | 2001-04-12 09:10:24 +0000 | [diff] [blame] | 864 | #ifdef LINUX |
| 865 | |
| 866 | /* This is incredibly costly but it's worth it. */ |
| 867 | /* NOTE: LinuxThreads internally uses SIGRTMIN, SIGRTMIN + 1 and |
| 868 | SIGRTMIN + 2, so we can't use the obsolete /proc/%d/stat which |
| 869 | doesn't handle real-time signals). */ |
| 870 | sprintf(sname, "/proc/%d/status", tcp->pid); |
| 871 | if ((sfd = open(sname, O_RDONLY)) == -1) { |
| 872 | perror(sname); |
| 873 | return 1; |
| 874 | } |
| 875 | i = read(sfd, buf, sizeof(buf)); |
| 876 | buf[i] = '\0'; |
| 877 | close(sfd); |
| 878 | /* |
| 879 | * Skip the extraneous fields. We need to skip |
| 880 | * command name has any spaces in it. So be it. |
| 881 | */ |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 882 | s = strstr(buf, "SigIgn:\t"); |
Wichert Akkerman | d5c2dae | 2001-04-12 09:10:24 +0000 | [diff] [blame] | 883 | if (!s) |
| 884 | { |
| 885 | fprintf(stderr, "/proc/pid/status format error\n"); |
| 886 | return 1; |
| 887 | } |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 888 | parse_sigset_t(s + 8, &ignored); |
Wichert Akkerman | d5c2dae | 2001-04-12 09:10:24 +0000 | [diff] [blame] | 889 | |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 890 | s = strstr(buf, "SigCgt:\t"); |
| 891 | if (!s) |
| 892 | { |
| 893 | fprintf(stderr, "/proc/pid/status format error\n"); |
| 894 | return 1; |
| 895 | } |
| 896 | parse_sigset_t(s + 8, &caught); |
Wichert Akkerman | d5c2dae | 2001-04-12 09:10:24 +0000 | [diff] [blame] | 897 | |
| 898 | #ifdef DEBUG |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 899 | fprintf(stderr, "sigs: %016qx %016qx (sig=%d)\n", |
| 900 | *(long long *) &ignored, *(long long *) &caught, sig); |
Wichert Akkerman | d5c2dae | 2001-04-12 09:10:24 +0000 | [diff] [blame] | 901 | #endif |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 902 | if (sigismember(&ignored, sig) || sigismember(&caught, sig)) |
Wichert Akkerman | d5c2dae | 2001-04-12 09:10:24 +0000 | [diff] [blame] | 903 | return 1; |
| 904 | #endif /* LINUX */ |
| 905 | |
| 906 | #ifdef SUNOS4 |
| 907 | void (*u_signal)(); |
| 908 | |
Denys Vlasenko | 932fc7d | 2008-12-16 18:18:40 +0000 | [diff] [blame] | 909 | if (upeek(tcp, uoff(u_signal[0]) + sig*sizeof(u_signal), |
Wichert Akkerman | d5c2dae | 2001-04-12 09:10:24 +0000 | [diff] [blame] | 910 | (long *) &u_signal) < 0) { |
| 911 | return 0; |
| 912 | } |
| 913 | if (u_signal != SIG_DFL) |
| 914 | return 1; |
| 915 | #endif /* SUNOS4 */ |
| 916 | |
| 917 | return 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 918 | } |
| 919 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 920 | #if defined(SUNOS4) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 921 | |
| 922 | int |
| 923 | sys_sigvec(tcp) |
| 924 | struct tcb *tcp; |
| 925 | { |
| 926 | struct sigvec sv; |
| 927 | long addr; |
| 928 | |
| 929 | if (entering(tcp)) { |
| 930 | printsignal(tcp->u_arg[0]); |
| 931 | tprintf(", "); |
| 932 | addr = tcp->u_arg[1]; |
| 933 | } else { |
| 934 | addr = tcp->u_arg[2]; |
| 935 | } |
| 936 | if (addr == 0) |
| 937 | tprintf("NULL"); |
| 938 | else if (!verbose(tcp)) |
| 939 | tprintf("%#lx", addr); |
| 940 | else if (umove(tcp, addr, &sv) < 0) |
| 941 | tprintf("{...}"); |
| 942 | else { |
| 943 | switch ((int) sv.sv_handler) { |
| 944 | case (int) SIG_ERR: |
| 945 | tprintf("{SIG_ERR}"); |
| 946 | break; |
| 947 | case (int) SIG_DFL: |
| 948 | tprintf("{SIG_DFL}"); |
| 949 | break; |
| 950 | case (int) SIG_IGN: |
| 951 | if (tcp->u_arg[0] == SIGTRAP) { |
| 952 | tcp->flags |= TCB_SIGTRAPPED; |
| 953 | kill(tcp->pid, SIGSTOP); |
| 954 | } |
| 955 | tprintf("{SIG_IGN}"); |
| 956 | break; |
| 957 | case (int) SIG_HOLD: |
| 958 | if (tcp->u_arg[0] == SIGTRAP) { |
| 959 | tcp->flags |= TCB_SIGTRAPPED; |
| 960 | kill(tcp->pid, SIGSTOP); |
| 961 | } |
| 962 | tprintf("SIG_HOLD"); |
| 963 | break; |
| 964 | default: |
| 965 | if (tcp->u_arg[0] == SIGTRAP) { |
| 966 | tcp->flags |= TCB_SIGTRAPPED; |
| 967 | kill(tcp->pid, SIGSTOP); |
| 968 | } |
| 969 | tprintf("{%#lx, ", (unsigned long) sv.sv_handler); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 970 | printsigmask(&sv.sv_mask, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 971 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 972 | printflags(sigvec_flags, sv.sv_flags, "SV_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 973 | tprintf("}"); |
| 974 | } |
| 975 | } |
| 976 | if (entering(tcp)) |
| 977 | tprintf(", "); |
| 978 | return 0; |
| 979 | } |
| 980 | |
| 981 | int |
| 982 | sys_sigpause(tcp) |
| 983 | struct tcb *tcp; |
| 984 | { |
| 985 | if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */ |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 986 | sigset_t sigm; |
| 987 | long_to_sigset(tcp->u_arg[0], &sigm); |
| 988 | printsigmask(&sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 989 | } |
| 990 | return 0; |
| 991 | } |
| 992 | |
| 993 | int |
| 994 | sys_sigstack(tcp) |
| 995 | struct tcb *tcp; |
| 996 | { |
| 997 | struct sigstack ss; |
| 998 | long addr; |
| 999 | |
| 1000 | if (entering(tcp)) |
| 1001 | addr = tcp->u_arg[0]; |
| 1002 | else |
| 1003 | addr = tcp->u_arg[1]; |
| 1004 | if (addr == 0) |
| 1005 | tprintf("NULL"); |
| 1006 | else if (umove(tcp, addr, &ss) < 0) |
| 1007 | tprintf("%#lx", addr); |
| 1008 | else { |
| 1009 | tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp); |
| 1010 | tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO"); |
| 1011 | } |
| 1012 | if (entering(tcp)) |
| 1013 | tprintf(", "); |
| 1014 | return 0; |
| 1015 | } |
| 1016 | |
| 1017 | int |
| 1018 | sys_sigcleanup(tcp) |
| 1019 | struct tcb *tcp; |
| 1020 | { |
| 1021 | return 0; |
| 1022 | } |
| 1023 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1024 | #endif /* SUNOS4 || FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1025 | |
| 1026 | #ifndef SVR4 |
| 1027 | |
| 1028 | int |
| 1029 | sys_sigsetmask(tcp) |
| 1030 | struct tcb *tcp; |
| 1031 | { |
| 1032 | if (entering(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1033 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1034 | long_to_sigset(tcp->u_arg[0], &sigm); |
| 1035 | printsigmask(&sigm, 0); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1036 | #ifndef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1037 | if ((tcp->u_arg[0] & sigmask(SIGTRAP))) { |
| 1038 | /* Mark attempt to block SIGTRAP */ |
| 1039 | tcp->flags |= TCB_SIGTRAPPED; |
| 1040 | /* Send unblockable signal */ |
| 1041 | kill(tcp->pid, SIGSTOP); |
| 1042 | } |
Roland McGrath | a39c5a1 | 2002-12-17 05:10:37 +0000 | [diff] [blame] | 1043 | #endif /* !USE_PROCFS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1044 | } |
| 1045 | else if (!syserror(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1046 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1047 | long_to_sigset(tcp->u_rval, &sigm); |
| 1048 | tcp->auxstr = sprintsigmask("old mask ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1049 | |
| 1050 | return RVAL_HEX | RVAL_STR; |
| 1051 | } |
| 1052 | return 0; |
| 1053 | } |
| 1054 | |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 1055 | #if defined(SUNOS4) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1056 | int |
| 1057 | sys_sigblock(tcp) |
| 1058 | struct tcb *tcp; |
| 1059 | { |
| 1060 | return sys_sigsetmask(tcp); |
| 1061 | } |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 1062 | #endif /* SUNOS4 || FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1063 | |
| 1064 | #endif /* !SVR4 */ |
| 1065 | |
| 1066 | #ifdef HAVE_SIGACTION |
| 1067 | |
| 1068 | #ifdef LINUX |
| 1069 | struct old_sigaction { |
| 1070 | __sighandler_t __sa_handler; |
| 1071 | unsigned long sa_mask; |
| 1072 | unsigned long sa_flags; |
| 1073 | void (*sa_restorer)(void); |
| 1074 | }; |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1075 | #define SA_HANDLER __sa_handler |
| 1076 | #endif /* LINUX */ |
| 1077 | |
Roland McGrath | a39c5a1 | 2002-12-17 05:10:37 +0000 | [diff] [blame] | 1078 | #ifndef SA_HANDLER |
| 1079 | #define SA_HANDLER sa_handler |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1080 | #endif |
| 1081 | |
| 1082 | int |
| 1083 | sys_sigaction(tcp) |
| 1084 | struct tcb *tcp; |
| 1085 | { |
| 1086 | long addr; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1087 | #ifdef LINUX |
John Hughes | 1e4cb34 | 2001-03-06 09:25:46 +0000 | [diff] [blame] | 1088 | sigset_t sigset; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1089 | struct old_sigaction sa; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1090 | #else |
| 1091 | struct sigaction sa; |
| 1092 | #endif |
| 1093 | |
| 1094 | |
| 1095 | if (entering(tcp)) { |
| 1096 | printsignal(tcp->u_arg[0]); |
| 1097 | tprintf(", "); |
| 1098 | addr = tcp->u_arg[1]; |
| 1099 | } else |
| 1100 | addr = tcp->u_arg[2]; |
| 1101 | if (addr == 0) |
| 1102 | tprintf("NULL"); |
| 1103 | else if (!verbose(tcp)) |
| 1104 | tprintf("%#lx", addr); |
| 1105 | else if (umove(tcp, addr, &sa) < 0) |
| 1106 | tprintf("{...}"); |
| 1107 | else { |
Carlos O'Donell | 4677c8a | 2009-09-09 18:13:19 +0000 | [diff] [blame] | 1108 | /* Architectures using function pointers, like |
| 1109 | * hppa, may need to manipulate the function pointer |
| 1110 | * to compute the result of a comparison. However, |
| 1111 | * the SA_HANDLER function pointer exists only in |
| 1112 | * the address space of the traced process, and can't |
| 1113 | * be manipulated by strace. In order to prevent the |
| 1114 | * compiler from generating code to manipulate |
| 1115 | * SA_HANDLER we cast the function pointers to long. */ |
| 1116 | if ((long)sa.SA_HANDLER == (long)SIG_ERR) |
Roland McGrath | 5f20681 | 2008-08-20 01:59:40 +0000 | [diff] [blame] | 1117 | tprintf("{SIG_ERR, "); |
Carlos O'Donell | 4677c8a | 2009-09-09 18:13:19 +0000 | [diff] [blame] | 1118 | else if ((long)sa.SA_HANDLER == (long)SIG_DFL) |
Roland McGrath | 5f20681 | 2008-08-20 01:59:40 +0000 | [diff] [blame] | 1119 | tprintf("{SIG_DFL, "); |
Carlos O'Donell | 4677c8a | 2009-09-09 18:13:19 +0000 | [diff] [blame] | 1120 | else if ((long)sa.SA_HANDLER == (long)SIG_IGN) { |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1121 | #ifndef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1122 | if (tcp->u_arg[0] == SIGTRAP) { |
| 1123 | tcp->flags |= TCB_SIGTRAPPED; |
| 1124 | kill(tcp->pid, SIGSTOP); |
| 1125 | } |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1126 | #endif /* !USE_PROCFS */ |
Roland McGrath | 5f20681 | 2008-08-20 01:59:40 +0000 | [diff] [blame] | 1127 | tprintf("{SIG_IGN, "); |
| 1128 | } |
| 1129 | else { |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1130 | #ifndef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1131 | if (tcp->u_arg[0] == SIGTRAP) { |
| 1132 | tcp->flags |= TCB_SIGTRAPPED; |
| 1133 | kill(tcp->pid, SIGSTOP); |
| 1134 | } |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1135 | #endif /* !USE_PROCFS */ |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1136 | tprintf("{%#lx, ", (long) sa.SA_HANDLER); |
Wichert Akkerman | 48214be | 1999-11-26 09:55:42 +0000 | [diff] [blame] | 1137 | #ifndef LINUX |
| 1138 | printsigmask (&sa.sa_mask, 0); |
| 1139 | #else |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1140 | long_to_sigset(sa.sa_mask, &sigset); |
| 1141 | printsigmask(&sigset, 0); |
Wichert Akkerman | 48214be | 1999-11-26 09:55:42 +0000 | [diff] [blame] | 1142 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1143 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1144 | printflags(sigact_flags, sa.sa_flags, "SA_???"); |
Roland McGrath | 2638cb4 | 2002-12-15 23:58:41 +0000 | [diff] [blame] | 1145 | #ifdef SA_RESTORER |
| 1146 | if (sa.sa_flags & SA_RESTORER) |
| 1147 | tprintf(", %p", sa.sa_restorer); |
| 1148 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1149 | tprintf("}"); |
| 1150 | } |
| 1151 | } |
| 1152 | if (entering(tcp)) |
| 1153 | tprintf(", "); |
| 1154 | #ifdef LINUX |
| 1155 | else |
| 1156 | tprintf(", %#lx", (unsigned long) sa.sa_restorer); |
| 1157 | #endif |
| 1158 | return 0; |
| 1159 | } |
| 1160 | |
| 1161 | int |
| 1162 | sys_signal(tcp) |
| 1163 | struct tcb *tcp; |
| 1164 | { |
| 1165 | if (entering(tcp)) { |
| 1166 | printsignal(tcp->u_arg[0]); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 1167 | tprintf(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1168 | switch (tcp->u_arg[1]) { |
Jan Kratochvil | 1f94271 | 2008-08-06 21:38:52 +0000 | [diff] [blame] | 1169 | case (long) SIG_ERR: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1170 | tprintf("SIG_ERR"); |
| 1171 | break; |
Jan Kratochvil | 1f94271 | 2008-08-06 21:38:52 +0000 | [diff] [blame] | 1172 | case (long) SIG_DFL: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1173 | tprintf("SIG_DFL"); |
| 1174 | break; |
Jan Kratochvil | 1f94271 | 2008-08-06 21:38:52 +0000 | [diff] [blame] | 1175 | case (long) SIG_IGN: |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1176 | #ifndef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1177 | if (tcp->u_arg[0] == SIGTRAP) { |
| 1178 | tcp->flags |= TCB_SIGTRAPPED; |
| 1179 | kill(tcp->pid, SIGSTOP); |
| 1180 | } |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1181 | #endif /* !USE_PROCFS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1182 | tprintf("SIG_IGN"); |
| 1183 | break; |
| 1184 | default: |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1185 | #ifndef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1186 | if (tcp->u_arg[0] == SIGTRAP) { |
| 1187 | tcp->flags |= TCB_SIGTRAPPED; |
| 1188 | kill(tcp->pid, SIGSTOP); |
| 1189 | } |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1190 | #endif /* !USE_PROCFS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1191 | tprintf("%#lx", tcp->u_arg[1]); |
| 1192 | } |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 1193 | return 0; |
| 1194 | } |
Dmitry V. Levin | 21a7534 | 2008-09-03 01:22:18 +0000 | [diff] [blame] | 1195 | else if (!syserror(tcp)) { |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 1196 | switch (tcp->u_rval) { |
Jan Kratochvil | 1f94271 | 2008-08-06 21:38:52 +0000 | [diff] [blame] | 1197 | case (long) SIG_ERR: |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 1198 | tcp->auxstr = "SIG_ERR"; break; |
Jan Kratochvil | 1f94271 | 2008-08-06 21:38:52 +0000 | [diff] [blame] | 1199 | case (long) SIG_DFL: |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 1200 | tcp->auxstr = "SIG_DFL"; break; |
Jan Kratochvil | 1f94271 | 2008-08-06 21:38:52 +0000 | [diff] [blame] | 1201 | case (long) SIG_IGN: |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 1202 | tcp->auxstr = "SIG_IGN"; break; |
| 1203 | default: |
| 1204 | tcp->auxstr = NULL; |
| 1205 | } |
| 1206 | return RVAL_HEX | RVAL_STR; |
| 1207 | } |
Dmitry V. Levin | 21a7534 | 2008-09-03 01:22:18 +0000 | [diff] [blame] | 1208 | return 0; |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 1209 | } |
| 1210 | |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 1211 | #ifdef SVR4 |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 1212 | int |
| 1213 | sys_sighold(tcp) |
| 1214 | struct tcb *tcp; |
| 1215 | { |
| 1216 | if (entering(tcp)) { |
| 1217 | printsignal(tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1218 | } |
| 1219 | return 0; |
| 1220 | } |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 1221 | #endif /* SVR4 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1222 | |
| 1223 | #endif /* HAVE_SIGACTION */ |
| 1224 | |
| 1225 | #ifdef LINUX |
| 1226 | |
| 1227 | int |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 1228 | sys_sigreturn(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1229 | { |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 1230 | #if defined(ARM) |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1231 | struct pt_regs regs; |
| 1232 | struct sigcontext_struct sc; |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 1233 | |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1234 | if (entering(tcp)) { |
| 1235 | tcp->u_arg[0] = 0; |
| 1236 | |
| 1237 | if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, (void *)®s) == -1) |
| 1238 | return 0; |
| 1239 | |
| 1240 | if (umove(tcp, regs.ARM_sp, &sc) < 0) |
| 1241 | return 0; |
| 1242 | |
| 1243 | tcp->u_arg[0] = 1; |
| 1244 | tcp->u_arg[1] = sc.oldmask; |
| 1245 | } else { |
| 1246 | sigset_t sigm; |
| 1247 | long_to_sigset(tcp->u_arg[1], &sigm); |
| 1248 | tcp->u_rval = tcp->u_error = 0; |
| 1249 | if (tcp->u_arg[0] == 0) |
| 1250 | return 0; |
| 1251 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
| 1252 | return RVAL_NONE | RVAL_STR; |
| 1253 | } |
| 1254 | return 0; |
| 1255 | #elif defined(S390) || defined(S390X) |
| 1256 | long usp; |
| 1257 | struct sigcontext_struct sc; |
| 1258 | |
| 1259 | if (entering(tcp)) { |
| 1260 | tcp->u_arg[0] = 0; |
Denys Vlasenko | 932fc7d | 2008-12-16 18:18:40 +0000 | [diff] [blame] | 1261 | if (upeek(tcp,PT_GPR15,&usp)<0) |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1262 | return 0; |
| 1263 | if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0) |
| 1264 | return 0; |
| 1265 | tcp->u_arg[0] = 1; |
| 1266 | memcpy(&tcp->u_arg[1],&sc.oldmask[0],sizeof(sigset_t)); |
| 1267 | } else { |
| 1268 | tcp->u_rval = tcp->u_error = 0; |
| 1269 | if (tcp->u_arg[0] == 0) |
| 1270 | return 0; |
| 1271 | tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1],0); |
| 1272 | return RVAL_NONE | RVAL_STR; |
| 1273 | } |
| 1274 | return 0; |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 1275 | #elif defined(I386) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1276 | long esp; |
| 1277 | struct sigcontext_struct sc; |
| 1278 | |
| 1279 | if (entering(tcp)) { |
| 1280 | tcp->u_arg[0] = 0; |
Denys Vlasenko | 932fc7d | 2008-12-16 18:18:40 +0000 | [diff] [blame] | 1281 | if (upeek(tcp, 4*UESP, &esp) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1282 | return 0; |
| 1283 | if (umove(tcp, esp, &sc) < 0) |
| 1284 | return 0; |
| 1285 | tcp->u_arg[0] = 1; |
| 1286 | tcp->u_arg[1] = sc.oldmask; |
| 1287 | } |
| 1288 | else { |
| 1289 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1290 | long_to_sigset(tcp->u_arg[1], &sigm); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1291 | tcp->u_rval = tcp->u_error = 0; |
| 1292 | if (tcp->u_arg[0] == 0) |
| 1293 | return 0; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1294 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1295 | return RVAL_NONE | RVAL_STR; |
| 1296 | } |
| 1297 | return 0; |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 1298 | #elif defined(IA64) |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1299 | struct sigcontext sc; |
| 1300 | long sp; |
| 1301 | |
| 1302 | if (entering(tcp)) { |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 1303 | /* offset of sigcontext in the kernel's sigframe structure: */ |
| 1304 | # define SIGFRAME_SC_OFFSET 0x90 |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1305 | tcp->u_arg[0] = 0; |
Denys Vlasenko | 932fc7d | 2008-12-16 18:18:40 +0000 | [diff] [blame] | 1306 | if (upeek(tcp, PT_R12, &sp) < 0) |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1307 | return 0; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 1308 | if (umove(tcp, sp + 16 + SIGFRAME_SC_OFFSET, &sc) < 0) |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1309 | return 0; |
| 1310 | tcp->u_arg[0] = 1; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 1311 | memcpy(tcp->u_arg + 1, &sc.sc_mask, sizeof(sc.sc_mask)); |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1312 | } |
| 1313 | else { |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 1314 | sigset_t sigm; |
| 1315 | |
| 1316 | memcpy(&sigm, tcp->u_arg + 1, sizeof (sigm)); |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1317 | tcp->u_rval = tcp->u_error = 0; |
| 1318 | if (tcp->u_arg[0] == 0) |
| 1319 | return 0; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 1320 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1321 | return RVAL_NONE | RVAL_STR; |
| 1322 | } |
| 1323 | return 0; |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 1324 | #elif defined(POWERPC) |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1325 | long esp; |
| 1326 | struct sigcontext_struct sc; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1327 | |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1328 | if (entering(tcp)) { |
| 1329 | tcp->u_arg[0] = 0; |
Denys Vlasenko | 932fc7d | 2008-12-16 18:18:40 +0000 | [diff] [blame] | 1330 | if (upeek(tcp, sizeof(unsigned long)*PT_R1, &esp) < 0) |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1331 | return 0; |
Andreas Schwab | edb3934 | 2010-02-23 00:18:51 +0100 | [diff] [blame] | 1332 | /* Skip dummy stack frame. */ |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 1333 | #ifdef POWERPC64 |
| 1334 | if (current_personality == 0) |
| 1335 | esp += 128; |
| 1336 | else |
| 1337 | esp += 64; |
Andreas Schwab | edb3934 | 2010-02-23 00:18:51 +0100 | [diff] [blame] | 1338 | #else |
| 1339 | esp += 64; |
| 1340 | #endif |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1341 | if (umove(tcp, esp, &sc) < 0) |
| 1342 | return 0; |
| 1343 | tcp->u_arg[0] = 1; |
| 1344 | tcp->u_arg[1] = sc.oldmask; |
| 1345 | } |
| 1346 | else { |
| 1347 | sigset_t sigm; |
| 1348 | long_to_sigset(tcp->u_arg[1], &sigm); |
| 1349 | tcp->u_rval = tcp->u_error = 0; |
| 1350 | if (tcp->u_arg[0] == 0) |
| 1351 | return 0; |
| 1352 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
| 1353 | return RVAL_NONE | RVAL_STR; |
| 1354 | } |
| 1355 | return 0; |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 1356 | #elif defined(M68K) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1357 | long usp; |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1358 | struct sigcontext sc; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1359 | |
| 1360 | if (entering(tcp)) { |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1361 | tcp->u_arg[0] = 0; |
Denys Vlasenko | 932fc7d | 2008-12-16 18:18:40 +0000 | [diff] [blame] | 1362 | if (upeek(tcp, 4*PT_USP, &usp) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1363 | return 0; |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1364 | if (umove(tcp, usp, &sc) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1365 | return 0; |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1366 | tcp->u_arg[0] = 1; |
| 1367 | tcp->u_arg[1] = sc.sc_mask; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1368 | } |
| 1369 | else { |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1370 | sigset_t sigm; |
| 1371 | long_to_sigset(tcp->u_arg[1], &sigm); |
| 1372 | tcp->u_rval = tcp->u_error = 0; |
| 1373 | if (tcp->u_arg[0] == 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1374 | return 0; |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1375 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
| 1376 | return RVAL_NONE | RVAL_STR; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1377 | } |
| 1378 | return 0; |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 1379 | #elif defined(ALPHA) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1380 | long fp; |
| 1381 | struct sigcontext_struct sc; |
| 1382 | |
| 1383 | if (entering(tcp)) { |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1384 | tcp->u_arg[0] = 0; |
Denys Vlasenko | 932fc7d | 2008-12-16 18:18:40 +0000 | [diff] [blame] | 1385 | if (upeek(tcp, REG_FP, &fp) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1386 | return 0; |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1387 | if (umove(tcp, fp, &sc) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1388 | return 0; |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1389 | tcp->u_arg[0] = 1; |
| 1390 | tcp->u_arg[1] = sc.sc_mask; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1391 | } |
| 1392 | else { |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1393 | sigset_t sigm; |
| 1394 | long_to_sigset(tcp->u_arg[1], &sigm); |
| 1395 | tcp->u_rval = tcp->u_error = 0; |
| 1396 | if (tcp->u_arg[0] == 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1397 | return 0; |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1398 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
| 1399 | return RVAL_NONE | RVAL_STR; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1400 | } |
| 1401 | return 0; |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 1402 | #elif defined (SPARC) || defined (SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1403 | long i1; |
Mike Frysinger | 8566c50 | 2009-10-12 11:05:14 -0400 | [diff] [blame] | 1404 | struct pt_regs regs; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1405 | m_siginfo_t si; |
| 1406 | |
Roland McGrath | eb9e2e8 | 2009-06-02 16:49:22 -0700 | [diff] [blame] | 1407 | if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) { |
| 1408 | perror("sigreturn: PTRACE_GETREGS "); |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 1409 | return 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1410 | } |
Roland McGrath | eb9e2e8 | 2009-06-02 16:49:22 -0700 | [diff] [blame] | 1411 | if(entering(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1412 | tcp->u_arg[0] = 0; |
Mike Frysinger | 8566c50 | 2009-10-12 11:05:14 -0400 | [diff] [blame] | 1413 | i1 = regs.u_regs[U_REG_O1]; |
Roland McGrath | eb9e2e8 | 2009-06-02 16:49:22 -0700 | [diff] [blame] | 1414 | if(umove(tcp, i1, &si) < 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1415 | perror("sigreturn: umove "); |
| 1416 | return 0; |
| 1417 | } |
| 1418 | tcp->u_arg[0] = 1; |
| 1419 | tcp->u_arg[1] = si.si_mask; |
| 1420 | } else { |
| 1421 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1422 | long_to_sigset(tcp->u_arg[1], &sigm); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1423 | tcp->u_rval = tcp->u_error = 0; |
| 1424 | if(tcp->u_arg[0] == 0) |
| 1425 | return 0; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1426 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1427 | return RVAL_NONE | RVAL_STR; |
| 1428 | } |
| 1429 | return 0; |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 1430 | #elif defined (LINUX_MIPSN32) || defined (LINUX_MIPSN64) |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 1431 | /* This decodes rt_sigreturn. The 64-bit ABIs do not have |
| 1432 | sigreturn. */ |
| 1433 | long sp; |
| 1434 | struct ucontext uc; |
| 1435 | |
| 1436 | if(entering(tcp)) { |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 1437 | tcp->u_arg[0] = 0; |
Denys Vlasenko | 932fc7d | 2008-12-16 18:18:40 +0000 | [diff] [blame] | 1438 | if (upeek(tcp, REG_SP, &sp) < 0) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 1439 | return 0; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 1440 | /* There are six words followed by a 128-byte siginfo. */ |
| 1441 | sp = sp + 6 * 4 + 128; |
| 1442 | if (umove(tcp, sp, &uc) < 0) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 1443 | return 0; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 1444 | tcp->u_arg[0] = 1; |
| 1445 | tcp->u_arg[1] = *(long *) &uc.uc_sigmask; |
| 1446 | } else { |
| 1447 | sigset_t sigm; |
| 1448 | long_to_sigset(tcp->u_arg[1], &sigm); |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 1449 | tcp->u_rval = tcp->u_error = 0; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 1450 | if(tcp->u_arg[0] == 0) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 1451 | return 0; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 1452 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
| 1453 | return RVAL_NONE | RVAL_STR; |
| 1454 | } |
| 1455 | return 0; |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 1456 | #elif defined(MIPS) |
Wichert Akkerman | f90da01 | 1999-10-31 21:15:38 +0000 | [diff] [blame] | 1457 | long sp; |
Roland McGrath | 576b784 | 2007-11-04 00:00:00 +0000 | [diff] [blame] | 1458 | struct pt_regs regs; |
| 1459 | m_siginfo_t si; |
Wichert Akkerman | f90da01 | 1999-10-31 21:15:38 +0000 | [diff] [blame] | 1460 | |
Roland McGrath | 576b784 | 2007-11-04 00:00:00 +0000 | [diff] [blame] | 1461 | if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) { |
| 1462 | perror("sigreturn: PTRACE_GETREGS "); |
| 1463 | return 0; |
| 1464 | } |
Wichert Akkerman | f90da01 | 1999-10-31 21:15:38 +0000 | [diff] [blame] | 1465 | if(entering(tcp)) { |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 1466 | tcp->u_arg[0] = 0; |
Roland McGrath | 576b784 | 2007-11-04 00:00:00 +0000 | [diff] [blame] | 1467 | sp = regs.regs[29]; |
| 1468 | if (umove(tcp, sp, &si) < 0) |
Wichert Akkerman | f90da01 | 1999-10-31 21:15:38 +0000 | [diff] [blame] | 1469 | tcp->u_arg[0] = 1; |
Roland McGrath | 576b784 | 2007-11-04 00:00:00 +0000 | [diff] [blame] | 1470 | tcp->u_arg[1] = si.si_mask; |
Wichert Akkerman | f90da01 | 1999-10-31 21:15:38 +0000 | [diff] [blame] | 1471 | } else { |
Roland McGrath | 576b784 | 2007-11-04 00:00:00 +0000 | [diff] [blame] | 1472 | sigset_t sigm; |
| 1473 | long_to_sigset(tcp->u_arg[1], &sigm); |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 1474 | tcp->u_rval = tcp->u_error = 0; |
Wichert Akkerman | f90da01 | 1999-10-31 21:15:38 +0000 | [diff] [blame] | 1475 | if(tcp->u_arg[0] == 0) |
Roland McGrath | 576b784 | 2007-11-04 00:00:00 +0000 | [diff] [blame] | 1476 | return 0; |
| 1477 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
Wichert Akkerman | f90da01 | 1999-10-31 21:15:38 +0000 | [diff] [blame] | 1478 | return RVAL_NONE | RVAL_STR; |
| 1479 | } |
| 1480 | return 0; |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 1481 | #elif defined(CRISV10) || defined(CRISV32) |
| 1482 | struct sigcontext sc; |
| 1483 | |
| 1484 | if (entering(tcp)) { |
| 1485 | long regs[PT_MAX+1]; |
| 1486 | |
| 1487 | tcp->u_arg[0] = 0; |
| 1488 | |
| 1489 | if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, (long)regs) < 0) { |
| 1490 | perror("sigreturn: PTRACE_GETREGS"); |
| 1491 | return 0; |
| 1492 | } |
| 1493 | if (umove(tcp, regs[PT_USP], &sc) < 0) |
| 1494 | return 0; |
| 1495 | tcp->u_arg[0] = 1; |
| 1496 | tcp->u_arg[1] = sc.oldmask; |
| 1497 | } else { |
| 1498 | sigset_t sigm; |
| 1499 | long_to_sigset(tcp->u_arg[1], &sigm); |
| 1500 | tcp->u_rval = tcp->u_error = 0; |
| 1501 | |
| 1502 | if (tcp->u_arg[0] == 0) |
| 1503 | return 0; |
| 1504 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
| 1505 | return RVAL_NONE | RVAL_STR; |
| 1506 | } |
| 1507 | return 0; |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 1508 | #elif defined(TILE) |
| 1509 | struct ucontext uc; |
| 1510 | long sp; |
| 1511 | |
| 1512 | /* offset of ucontext in the kernel's sigframe structure */ |
| 1513 | # define SIGFRAME_UC_OFFSET C_ABI_SAVE_AREA_SIZE + sizeof(struct siginfo) |
| 1514 | |
| 1515 | if (entering(tcp)) { |
| 1516 | tcp->u_arg[0] = 0; |
| 1517 | if (upeek(tcp, PTREGS_OFFSET_SP, &sp) < 0) |
| 1518 | return 0; |
| 1519 | if (umove(tcp, sp + SIGFRAME_UC_OFFSET, &uc) < 0) |
| 1520 | return 0; |
| 1521 | tcp->u_arg[0] = 1; |
| 1522 | memcpy(tcp->u_arg + 1, &uc.uc_sigmask, sizeof(uc.uc_sigmask)); |
| 1523 | } |
| 1524 | else { |
| 1525 | sigset_t sigm; |
| 1526 | |
| 1527 | memcpy(&sigm, tcp->u_arg + 1, sizeof (sigm)); |
| 1528 | tcp->u_rval = tcp->u_error = 0; |
| 1529 | if (tcp->u_arg[0] == 0) |
| 1530 | return 0; |
| 1531 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
| 1532 | return RVAL_NONE | RVAL_STR; |
| 1533 | } |
| 1534 | return 0; |
Edgar E. Iglesias | 939caba | 2010-07-06 14:21:07 +0200 | [diff] [blame^] | 1535 | #elif defined(MICROBLAZE) |
| 1536 | struct sigcontext sc; |
| 1537 | |
| 1538 | /* TODO: Verify that this is correct... */ |
| 1539 | if (entering(tcp)) { |
| 1540 | long sp; |
| 1541 | |
| 1542 | tcp->u_arg[0] = 0; |
| 1543 | |
| 1544 | /* Read r1, the stack pointer. */ |
| 1545 | if (upeek(tcp, 1 * 4, &sp) < 0) |
| 1546 | return 0; |
| 1547 | if (umove(tcp, sp, &sc) < 0) |
| 1548 | return 0; |
| 1549 | tcp->u_arg[0] = 1; |
| 1550 | tcp->u_arg[1] = sc.oldmask; |
| 1551 | } else { |
| 1552 | sigset_t sigm; |
| 1553 | long_to_sigset(tcp->u_arg[1], &sigm); |
| 1554 | tcp->u_rval = tcp->u_error = 0; |
| 1555 | if (tcp->u_arg[0] == 0) |
| 1556 | return 0; |
| 1557 | tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); |
| 1558 | return RVAL_NONE | RVAL_STR; |
| 1559 | } |
| 1560 | return 0; |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 1561 | #else |
Michal Ludvig | 0e03550 | 2002-09-23 15:41:01 +0000 | [diff] [blame] | 1562 | #warning No sys_sigreturn() for this architecture |
| 1563 | #warning (no problem, just a reminder :-) |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 1564 | return 0; |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 1565 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1566 | } |
| 1567 | |
| 1568 | int |
| 1569 | sys_siggetmask(tcp) |
| 1570 | struct tcb *tcp; |
| 1571 | { |
| 1572 | if (exiting(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1573 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1574 | long_to_sigset(tcp->u_rval, &sigm); |
| 1575 | tcp->auxstr = sprintsigmask("mask ", &sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1576 | } |
| 1577 | return RVAL_HEX | RVAL_STR; |
| 1578 | } |
| 1579 | |
| 1580 | int |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 1581 | sys_sigsuspend(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1582 | { |
| 1583 | if (entering(tcp)) { |
| 1584 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1585 | long_to_sigset(tcp->u_arg[2], &sigm); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1586 | printsigmask(&sigm, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1587 | } |
| 1588 | return 0; |
| 1589 | } |
| 1590 | |
| 1591 | #endif /* LINUX */ |
| 1592 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1593 | #if defined(SVR4) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1594 | |
| 1595 | int |
| 1596 | sys_sigsuspend(tcp) |
| 1597 | struct tcb *tcp; |
| 1598 | { |
| 1599 | sigset_t sigset; |
| 1600 | |
| 1601 | if (entering(tcp)) { |
| 1602 | if (umove(tcp, tcp->u_arg[0], &sigset) < 0) |
| 1603 | tprintf("[?]"); |
| 1604 | else |
Wichert Akkerman | 4695657 | 1999-11-26 10:12:59 +0000 | [diff] [blame] | 1605 | printsigmask(&sigset, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1606 | } |
| 1607 | return 0; |
| 1608 | } |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1609 | #ifndef FREEBSD |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 1610 | static const struct xlat ucontext_flags[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1611 | { UC_SIGMASK, "UC_SIGMASK" }, |
| 1612 | { UC_STACK, "UC_STACK" }, |
| 1613 | { UC_CPU, "UC_CPU" }, |
| 1614 | #ifdef UC_FPU |
| 1615 | { UC_FPU, "UC_FPU" }, |
| 1616 | #endif |
| 1617 | #ifdef UC_INTR |
| 1618 | { UC_INTR, "UC_INTR" }, |
| 1619 | #endif |
| 1620 | { 0, NULL }, |
| 1621 | }; |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1622 | #endif /* !FREEBSD */ |
| 1623 | #endif /* SVR4 || FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1624 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1625 | #if defined SVR4 || defined LINUX || defined FREEBSD |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1626 | #if defined LINUX && !defined SS_ONSTACK |
| 1627 | #define SS_ONSTACK 1 |
| 1628 | #define SS_DISABLE 2 |
| 1629 | #if __GLIBC_MINOR__ == 0 |
| 1630 | typedef struct |
| 1631 | { |
| 1632 | __ptr_t ss_sp; |
| 1633 | int ss_flags; |
| 1634 | size_t ss_size; |
| 1635 | } stack_t; |
| 1636 | #endif |
| 1637 | #endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1638 | #ifdef FREEBSD |
| 1639 | #define stack_t struct sigaltstack |
| 1640 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1641 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 1642 | static const struct xlat sigaltstack_flags[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1643 | { SS_ONSTACK, "SS_ONSTACK" }, |
| 1644 | { SS_DISABLE, "SS_DISABLE" }, |
| 1645 | { 0, NULL }, |
| 1646 | }; |
| 1647 | #endif |
| 1648 | |
| 1649 | #ifdef SVR4 |
| 1650 | static void |
| 1651 | printcontext(tcp, ucp) |
| 1652 | struct tcb *tcp; |
| 1653 | ucontext_t *ucp; |
| 1654 | { |
| 1655 | tprintf("{"); |
| 1656 | if (!abbrev(tcp)) { |
| 1657 | tprintf("uc_flags="); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1658 | printflags(ucontext_flags, ucp->uc_flags, "UC_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1659 | tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link); |
| 1660 | } |
| 1661 | tprintf("uc_sigmask="); |
John Hughes | 70c5e7a | 2001-05-15 15:09:14 +0000 | [diff] [blame] | 1662 | printsigmask(&ucp->uc_sigmask, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1663 | if (!abbrev(tcp)) { |
| 1664 | tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=", |
| 1665 | (unsigned long) ucp->uc_stack.ss_sp, |
| 1666 | ucp->uc_stack.ss_size); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1667 | printflags(sigaltstack_flags, ucp->uc_stack.ss_flags, "SS_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1668 | tprintf("}"); |
| 1669 | } |
| 1670 | tprintf(", ...}"); |
| 1671 | } |
| 1672 | |
| 1673 | int |
| 1674 | sys_getcontext(tcp) |
| 1675 | struct tcb *tcp; |
| 1676 | { |
| 1677 | ucontext_t uc; |
| 1678 | |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 1679 | if (exiting(tcp)) { |
| 1680 | if (tcp->u_error) |
| 1681 | tprintf("%#lx", tcp->u_arg[0]); |
| 1682 | else if (!tcp->u_arg[0]) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1683 | tprintf("NULL"); |
| 1684 | else if (umove(tcp, tcp->u_arg[0], &uc) < 0) |
| 1685 | tprintf("{...}"); |
| 1686 | else |
| 1687 | printcontext(tcp, &uc); |
| 1688 | } |
| 1689 | return 0; |
| 1690 | } |
| 1691 | |
| 1692 | int |
| 1693 | sys_setcontext(tcp) |
| 1694 | struct tcb *tcp; |
| 1695 | { |
| 1696 | ucontext_t uc; |
| 1697 | |
| 1698 | if (entering(tcp)) { |
| 1699 | if (!tcp->u_arg[0]) |
| 1700 | tprintf("NULL"); |
| 1701 | else if (umove(tcp, tcp->u_arg[0], &uc) < 0) |
| 1702 | tprintf("{...}"); |
| 1703 | else |
| 1704 | printcontext(tcp, &uc); |
| 1705 | } |
| 1706 | else { |
| 1707 | tcp->u_rval = tcp->u_error = 0; |
| 1708 | if (tcp->u_arg[0] == 0) |
| 1709 | return 0; |
| 1710 | return RVAL_NONE; |
| 1711 | } |
| 1712 | return 0; |
| 1713 | } |
| 1714 | |
| 1715 | #endif /* SVR4 */ |
| 1716 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1717 | #if defined(LINUX) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1718 | |
| 1719 | static int |
| 1720 | print_stack_t(tcp, addr) |
| 1721 | struct tcb *tcp; |
| 1722 | unsigned long addr; |
| 1723 | { |
| 1724 | stack_t ss; |
| 1725 | if (umove(tcp, addr, &ss) < 0) |
| 1726 | return -1; |
| 1727 | tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1728 | printflags(sigaltstack_flags, ss.ss_flags, "SS_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1729 | tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size); |
| 1730 | return 0; |
| 1731 | } |
| 1732 | |
| 1733 | int |
| 1734 | sys_sigaltstack(tcp) |
| 1735 | struct tcb *tcp; |
| 1736 | { |
| 1737 | if (entering(tcp)) { |
| 1738 | if (tcp->u_arg[0] == 0) |
| 1739 | tprintf("NULL"); |
| 1740 | else if (print_stack_t(tcp, tcp->u_arg[0]) < 0) |
| 1741 | return -1; |
| 1742 | } |
| 1743 | else { |
| 1744 | tprintf(", "); |
| 1745 | if (tcp->u_arg[1] == 0) |
| 1746 | tprintf("NULL"); |
| 1747 | else if (print_stack_t(tcp, tcp->u_arg[1]) < 0) |
| 1748 | return -1; |
| 1749 | } |
| 1750 | return 0; |
| 1751 | } |
| 1752 | #endif |
| 1753 | |
| 1754 | #ifdef HAVE_SIGACTION |
| 1755 | |
| 1756 | int |
| 1757 | sys_sigprocmask(tcp) |
| 1758 | struct tcb *tcp; |
| 1759 | { |
| 1760 | #ifdef ALPHA |
| 1761 | if (entering(tcp)) { |
| 1762 | printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???"); |
| 1763 | tprintf(", "); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1764 | printsigmask(tcp->u_arg[1], 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1765 | } |
| 1766 | else if (!syserror(tcp)) { |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1767 | tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1768 | return RVAL_HEX | RVAL_STR; |
| 1769 | } |
| 1770 | #else /* !ALPHA */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1771 | if (entering(tcp)) { |
| 1772 | #ifdef SVR4 |
| 1773 | if (tcp->u_arg[0] == 0) |
| 1774 | tprintf("0"); |
| 1775 | else |
| 1776 | #endif /* SVR4 */ |
| 1777 | printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???"); |
| 1778 | tprintf(", "); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1779 | print_sigset(tcp, tcp->u_arg[1], 0); |
| 1780 | tprintf(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1781 | } |
| 1782 | else { |
| 1783 | if (!tcp->u_arg[2]) |
| 1784 | tprintf("NULL"); |
| 1785 | else if (syserror(tcp)) |
| 1786 | tprintf("%#lx", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1787 | else |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1788 | print_sigset(tcp, tcp->u_arg[2], 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1789 | } |
| 1790 | #endif /* !ALPHA */ |
| 1791 | return 0; |
| 1792 | } |
| 1793 | |
| 1794 | #endif /* HAVE_SIGACTION */ |
| 1795 | |
| 1796 | int |
| 1797 | sys_kill(tcp) |
| 1798 | struct tcb *tcp; |
| 1799 | { |
| 1800 | if (entering(tcp)) { |
Roland McGrath | 4d7ed02 | 2008-05-20 01:43:09 +0000 | [diff] [blame] | 1801 | /* |
| 1802 | * Sign-extend a 32-bit value when that's what it is. |
| 1803 | */ |
| 1804 | long pid = tcp->u_arg[0]; |
| 1805 | if (personality_wordsize[current_personality] < sizeof pid) |
| 1806 | pid = (long) (int) pid; |
| 1807 | tprintf("%ld, %s", pid, signame(tcp->u_arg[1])); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1808 | } |
| 1809 | return 0; |
| 1810 | } |
| 1811 | |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 1812 | #if defined(FREEBSD) || defined(SUNOS4) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1813 | int |
| 1814 | sys_killpg(tcp) |
| 1815 | struct tcb *tcp; |
| 1816 | { |
| 1817 | return sys_kill(tcp); |
| 1818 | } |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 1819 | #endif /* FREEBSD || SUNOS4 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1820 | |
Roland McGrath | 8ffc352 | 2003-07-09 09:47:49 +0000 | [diff] [blame] | 1821 | #ifdef LINUX |
| 1822 | int |
| 1823 | sys_tgkill(tcp) |
| 1824 | struct tcb *tcp; |
| 1825 | { |
| 1826 | if (entering(tcp)) { |
| 1827 | tprintf("%ld, %ld, %s", |
| 1828 | tcp->u_arg[0], tcp->u_arg[1], signame(tcp->u_arg[2])); |
| 1829 | } |
| 1830 | return 0; |
| 1831 | } |
| 1832 | #endif |
| 1833 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1834 | int |
| 1835 | sys_sigpending(tcp) |
| 1836 | struct tcb *tcp; |
| 1837 | { |
| 1838 | sigset_t sigset; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1839 | |
| 1840 | if (exiting(tcp)) { |
| 1841 | if (syserror(tcp)) |
| 1842 | tprintf("%#lx", tcp->u_arg[0]); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1843 | else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1844 | tprintf("[?]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1845 | else |
Wichert Akkerman | 4695657 | 1999-11-26 10:12:59 +0000 | [diff] [blame] | 1846 | printsigmask(&sigset, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1847 | } |
| 1848 | return 0; |
| 1849 | } |
| 1850 | |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 1851 | #ifdef SVR4 |
John Hughes | 4216208 | 2001-10-18 14:48:26 +0000 | [diff] [blame] | 1852 | int sys_sigwait(tcp) |
| 1853 | struct tcb *tcp; |
| 1854 | { |
| 1855 | sigset_t sigset; |
| 1856 | |
| 1857 | if (entering(tcp)) { |
| 1858 | if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0) |
| 1859 | tprintf("[?]"); |
| 1860 | else |
| 1861 | printsigmask(&sigset, 0); |
| 1862 | } |
| 1863 | else { |
| 1864 | if (!syserror(tcp)) { |
| 1865 | tcp->auxstr = signalent[tcp->u_rval]; |
| 1866 | return RVAL_DECIMAL | RVAL_STR; |
| 1867 | } |
| 1868 | } |
| 1869 | return 0; |
| 1870 | } |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 1871 | #endif /* SVR4 */ |
John Hughes | 4216208 | 2001-10-18 14:48:26 +0000 | [diff] [blame] | 1872 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1873 | #ifdef LINUX |
| 1874 | |
| 1875 | int |
| 1876 | sys_rt_sigprocmask(tcp) |
| 1877 | struct tcb *tcp; |
| 1878 | { |
| 1879 | sigset_t sigset; |
| 1880 | |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1881 | /* Note: arg[3] is the length of the sigset. */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1882 | if (entering(tcp)) { |
| 1883 | printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???"); |
| 1884 | tprintf(", "); |
| 1885 | if (!tcp->u_arg[1]) |
| 1886 | tprintf("NULL, "); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1887 | else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1888 | tprintf("%#lx, ", tcp->u_arg[1]); |
| 1889 | else { |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1890 | printsigmask(&sigset, 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1891 | tprintf(", "); |
| 1892 | } |
| 1893 | } |
| 1894 | else { |
| 1895 | if (!tcp->u_arg[2]) |
| 1896 | |
| 1897 | tprintf("NULL"); |
| 1898 | else if (syserror(tcp)) |
| 1899 | tprintf("%#lx", tcp->u_arg[2]); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1900 | else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1901 | tprintf("[?]"); |
| 1902 | else |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 1903 | printsigmask(&sigset, 1); |
Nate Sammons | dab325a | 1999-03-29 23:33:35 +0000 | [diff] [blame] | 1904 | tprintf(", %lu", tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1905 | } |
| 1906 | return 0; |
| 1907 | } |
| 1908 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1909 | |
| 1910 | /* Structure describing the action to be taken when a signal arrives. */ |
| 1911 | struct new_sigaction |
| 1912 | { |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1913 | __sighandler_t __sa_handler; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1914 | unsigned long sa_flags; |
| 1915 | void (*sa_restorer) (void); |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1916 | /* Kernel treats sa_mask as an array of longs. */ |
| 1917 | unsigned long sa_mask[NSIG / sizeof(long) ? NSIG / sizeof(long) : 1]; |
| 1918 | }; |
| 1919 | /* Same for i386-on-x86_64 and similar cases */ |
| 1920 | struct new_sigaction32 |
| 1921 | { |
| 1922 | uint32_t __sa_handler; |
| 1923 | uint32_t sa_flags; |
| 1924 | uint32_t sa_restorer; |
| 1925 | uint32_t sa_mask[2 * (NSIG / sizeof(long) ? NSIG / sizeof(long) : 1)]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1926 | }; |
| 1927 | |
| 1928 | |
Roland McGrath | 5f20681 | 2008-08-20 01:59:40 +0000 | [diff] [blame] | 1929 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1930 | sys_rt_sigaction(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1931 | { |
| 1932 | struct new_sigaction sa; |
| 1933 | sigset_t sigset; |
| 1934 | long addr; |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1935 | int r; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1936 | |
| 1937 | if (entering(tcp)) { |
| 1938 | printsignal(tcp->u_arg[0]); |
| 1939 | tprintf(", "); |
| 1940 | addr = tcp->u_arg[1]; |
| 1941 | } else |
| 1942 | addr = tcp->u_arg[2]; |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1943 | |
| 1944 | if (addr == 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1945 | tprintf("NULL"); |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1946 | goto after_sa; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1947 | } |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1948 | if (!verbose(tcp)) { |
| 1949 | tprintf("%#lx", addr); |
| 1950 | goto after_sa; |
| 1951 | } |
| 1952 | #if SUPPORTED_PERSONALITIES > 1 |
| 1953 | if (personality_wordsize[current_personality] != sizeof(sa.sa_flags) |
| 1954 | && personality_wordsize[current_personality] == 4 |
| 1955 | ) { |
| 1956 | struct new_sigaction32 sa32; |
| 1957 | r = umove(tcp, addr, &sa32); |
| 1958 | if (r >= 0) { |
| 1959 | memset(&sa, 0, sizeof(sa)); |
| 1960 | sa.__sa_handler = (void*)(unsigned long)sa32.__sa_handler; |
| 1961 | sa.sa_flags = sa32.sa_flags; |
| 1962 | sa.sa_restorer = (void*)(unsigned long)sa32.sa_restorer; |
| 1963 | /* Kernel treats sa_mask as an array of longs. |
| 1964 | * For 32-bit process, "long" is uint32_t, thus, for example, |
| 1965 | * 32th bit in sa_mask will end up as bit 0 in sa_mask[1]. |
| 1966 | * But for (64-bit) kernel, 32th bit in sa_mask is |
| 1967 | * 32th bit in 0th (64-bit) long! |
| 1968 | * For little-endian, it's the same. |
| 1969 | * For big-endian, we swap 32-bit words. |
| 1970 | */ |
| 1971 | sa.sa_mask[0] = sa32.sa_mask[0] + ((long)(sa32.sa_mask[1]) << 32); |
| 1972 | } |
| 1973 | } else |
| 1974 | #endif |
| 1975 | { |
| 1976 | r = umove(tcp, addr, &sa); |
| 1977 | } |
| 1978 | if (r < 0) { |
| 1979 | tprintf("{...}"); |
| 1980 | goto after_sa; |
| 1981 | } |
Carlos O'Donell | 4677c8a | 2009-09-09 18:13:19 +0000 | [diff] [blame] | 1982 | /* Architectures using function pointers, like |
| 1983 | * hppa, may need to manipulate the function pointer |
| 1984 | * to compute the result of a comparison. However, |
| 1985 | * the SA_HANDLER function pointer exists only in |
| 1986 | * the address space of the traced process, and can't |
| 1987 | * be manipulated by strace. In order to prevent the |
| 1988 | * compiler from generating code to manipulate |
| 1989 | * SA_HANDLER we cast the function pointers to long. */ |
| 1990 | if ((long)sa.__sa_handler == (long)SIG_ERR) |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1991 | tprintf("{SIG_ERR, "); |
Carlos O'Donell | 4677c8a | 2009-09-09 18:13:19 +0000 | [diff] [blame] | 1992 | else if ((long)sa.__sa_handler == (long)SIG_DFL) |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1993 | tprintf("{SIG_DFL, "); |
Carlos O'Donell | 4677c8a | 2009-09-09 18:13:19 +0000 | [diff] [blame] | 1994 | else if ((long)sa.__sa_handler == (long)SIG_IGN) |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 1995 | tprintf("{SIG_IGN, "); |
| 1996 | else |
| 1997 | tprintf("{%#lx, ", (long) sa.__sa_handler); |
| 1998 | /* Questionable code below. |
| 1999 | * Kernel won't handle sys_rt_sigaction |
| 2000 | * with wrong sigset size (just returns EINVAL) |
| 2001 | * therefore tcp->u_arg[3(4)] _must_ be NSIG / 8 here, |
| 2002 | * and we always use smaller memcpy. */ |
| 2003 | sigemptyset(&sigset); |
| 2004 | #ifdef LINUXSPARC |
| 2005 | if (tcp->u_arg[4] <= sizeof(sigset)) |
| 2006 | memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]); |
| 2007 | #else |
| 2008 | if (tcp->u_arg[3] <= sizeof(sigset)) |
| 2009 | memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]); |
| 2010 | #endif |
| 2011 | else |
| 2012 | memcpy(&sigset, &sa.sa_mask, sizeof(sigset)); |
| 2013 | printsigmask(&sigset, 1); |
| 2014 | tprintf(", "); |
| 2015 | printflags(sigact_flags, sa.sa_flags, "SA_???"); |
| 2016 | #ifdef SA_RESTORER |
| 2017 | if (sa.sa_flags & SA_RESTORER) |
| 2018 | tprintf(", %p", sa.sa_restorer); |
| 2019 | #endif |
| 2020 | tprintf("}"); |
| 2021 | |
| 2022 | after_sa: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2023 | if (entering(tcp)) |
| 2024 | tprintf(", "); |
| 2025 | else |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 2026 | #ifdef LINUXSPARC |
| 2027 | tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]); |
| 2028 | #elif defined(ALPHA) |
| 2029 | tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]); |
| 2030 | #else |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 2031 | tprintf(", %lu", tcp->u_arg[3]); |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 2032 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2033 | return 0; |
| 2034 | } |
| 2035 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2036 | int |
| 2037 | sys_rt_sigpending(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2038 | { |
| 2039 | sigset_t sigset; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2040 | |
| 2041 | if (exiting(tcp)) { |
| 2042 | if (syserror(tcp)) |
| 2043 | tprintf("%#lx", tcp->u_arg[0]); |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 2044 | else if (copy_sigset_len(tcp, tcp->u_arg[0], |
| 2045 | &sigset, tcp->u_arg[1]) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2046 | tprintf("[?]"); |
| 2047 | else |
Wichert Akkerman | 4695657 | 1999-11-26 10:12:59 +0000 | [diff] [blame] | 2048 | printsigmask(&sigset, 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2049 | } |
| 2050 | return 0; |
| 2051 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2052 | |
| 2053 | int |
| 2054 | sys_rt_sigsuspend(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2055 | { |
| 2056 | if (entering(tcp)) { |
| 2057 | sigset_t sigm; |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 2058 | if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0) |
| 2059 | tprintf("[?]"); |
| 2060 | else |
| 2061 | printsigmask(&sigm, 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2062 | } |
| 2063 | return 0; |
| 2064 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2065 | |
| 2066 | int |
| 2067 | sys_rt_sigqueueinfo(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2068 | { |
| 2069 | if (entering(tcp)) { |
| 2070 | siginfo_t si; |
| 2071 | tprintf("%lu, ", tcp->u_arg[0]); |
| 2072 | printsignal(tcp->u_arg[1]); |
| 2073 | tprintf(", "); |
| 2074 | if (umove(tcp, tcp->u_arg[2], &si) < 0) |
| 2075 | tprintf("%#lx", tcp->u_arg[2]); |
| 2076 | else |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2077 | printsiginfo(&si, verbose(tcp)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2078 | } |
| 2079 | return 0; |
| 2080 | } |
| 2081 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2082 | int sys_rt_sigtimedwait(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2083 | { |
| 2084 | if (entering(tcp)) { |
| 2085 | sigset_t sigset; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2086 | |
Roland McGrath | a39c5a1 | 2002-12-17 05:10:37 +0000 | [diff] [blame] | 2087 | if (copy_sigset_len(tcp, tcp->u_arg[0], |
Nate Sammons | 4a12143 | 1999-04-06 01:19:39 +0000 | [diff] [blame] | 2088 | &sigset, tcp->u_arg[3]) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2089 | tprintf("[?]"); |
| 2090 | else |
Wichert Akkerman | 4695657 | 1999-11-26 10:12:59 +0000 | [diff] [blame] | 2091 | printsigmask(&sigset, 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2092 | tprintf(", "); |
Denys Vlasenko | b1a78cf | 2009-04-15 13:31:59 +0000 | [diff] [blame] | 2093 | /* This is the only "return" parameter, */ |
| 2094 | if (tcp->u_arg[1] != 0) |
| 2095 | return 0; |
| 2096 | /* ... if it's NULL, can decode all on entry */ |
| 2097 | tprintf("NULL, "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2098 | } |
Denys Vlasenko | b1a78cf | 2009-04-15 13:31:59 +0000 | [diff] [blame] | 2099 | else if (tcp->u_arg[1] != 0) { |
| 2100 | /* syscall exit, and u_arg[1] wasn't NULL */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2101 | if (syserror(tcp)) |
Denys Vlasenko | b1a78cf | 2009-04-15 13:31:59 +0000 | [diff] [blame] | 2102 | tprintf("%#lx, ", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2103 | else { |
| 2104 | siginfo_t si; |
| 2105 | if (umove(tcp, tcp->u_arg[1], &si) < 0) |
Denys Vlasenko | b1a78cf | 2009-04-15 13:31:59 +0000 | [diff] [blame] | 2106 | tprintf("%#lx, ", tcp->u_arg[1]); |
| 2107 | else { |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2108 | printsiginfo(&si, verbose(tcp)); |
Denys Vlasenko | b1a78cf | 2009-04-15 13:31:59 +0000 | [diff] [blame] | 2109 | tprintf(", "); |
| 2110 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2111 | } |
| 2112 | } |
Denys Vlasenko | b1a78cf | 2009-04-15 13:31:59 +0000 | [diff] [blame] | 2113 | else { |
| 2114 | /* syscall exit, and u_arg[1] was NULL */ |
| 2115 | return 0; |
| 2116 | } |
| 2117 | print_timespec(tcp, tcp->u_arg[2]); |
| 2118 | tprintf(", %d", (int) tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2119 | return 0; |
| 2120 | }; |
| 2121 | |
Roland McGrath | 79dcd7a | 2006-01-12 22:34:50 +0000 | [diff] [blame] | 2122 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2123 | sys_restart_syscall(struct tcb *tcp) |
Roland McGrath | 79dcd7a | 2006-01-12 22:34:50 +0000 | [diff] [blame] | 2124 | { |
| 2125 | if (entering(tcp)) |
| 2126 | tprintf("<... resuming interrupted call ...>"); |
| 2127 | return 0; |
| 2128 | } |
| 2129 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 2130 | static int |
| 2131 | do_signalfd(struct tcb *tcp, int flags_arg) |
Roland McGrath | f46ccd3 | 2007-08-02 01:15:59 +0000 | [diff] [blame] | 2132 | { |
| 2133 | if (entering(tcp)) { |
| 2134 | tprintf("%ld, ", tcp->u_arg[0]); |
| 2135 | print_sigset(tcp, tcp->u_arg[1], 1); |
Dmitry V. Levin | 9d2ee3d | 2009-10-05 13:45:19 +0000 | [diff] [blame] | 2136 | tprintf(", %lu", tcp->u_arg[2]); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 2137 | if (flags_arg >= 0) { |
| 2138 | tprintf(", "); |
| 2139 | printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???"); |
| 2140 | } |
Roland McGrath | f46ccd3 | 2007-08-02 01:15:59 +0000 | [diff] [blame] | 2141 | } |
| 2142 | return 0; |
| 2143 | } |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 2144 | |
| 2145 | int |
| 2146 | sys_signalfd(struct tcb *tcp) |
| 2147 | { |
| 2148 | return do_signalfd(tcp, -1); |
| 2149 | } |
| 2150 | |
| 2151 | int |
| 2152 | sys_signalfd4(struct tcb *tcp) |
| 2153 | { |
| 2154 | return do_signalfd(tcp, 3); |
| 2155 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2156 | #endif /* LINUX */ |