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