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