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