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