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