blob: 05ab30a984459198c476e434701571f15267bfec [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
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 Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * 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 Akkerman76baf7c1999-02-19 00:21:36 +00009 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $Id$
34 */
35
36#include "defs.h"
37
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000038#include <signal.h>
39#include <sys/user.h>
40#include <fcntl.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000041
42#ifdef SVR4
43#include <sys/ucontext.h>
44#endif /* SVR4 */
45
Wichert Akkerman36915a11999-07-13 15:45:02 +000046#ifdef HAVE_SYS_REG_H
47# include <sys/reg.h>
Wichert Akkerman15dea971999-10-06 13:06:34 +000048#ifndef PTRACE_PEEKUSR
Wichert Akkerman36915a11999-07-13 15:45:02 +000049# define PTRACE_PEEKUSR PTRACE_PEEKUSER
Wichert Akkerman15dea971999-10-06 13:06:34 +000050#endif
51#ifndef PTRACE_POKEUSR
Wichert Akkerman36915a11999-07-13 15:45:02 +000052# define PTRACE_POKEUSR PTRACE_POKEUSER
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000053#endif
Wichert Akkermanfaf72222000-02-19 23:59:03 +000054#elif defined(HAVE_LINUX_PTRACE_H)
55#undef PTRACE_SYSCALL
Roland McGrathb0acdfd2004-03-01 21:31:02 +000056# ifdef HAVE_STRUCT_IA64_FPREG
57# define ia64_fpreg XXX_ia64_fpreg
58# endif
59# ifdef HAVE_STRUCT_PT_ALL_USER_REGS
60# define pt_all_user_regs XXX_pt_all_user_regs
61# endif
Wichert Akkermanfaf72222000-02-19 23:59:03 +000062#include <linux/ptrace.h>
Roland McGrathb0acdfd2004-03-01 21:31:02 +000063# undef ia64_fpreg
64# undef pt_all_user_regs
Wichert Akkerman15dea971999-10-06 13:06:34 +000065#endif
Wichert Akkerman36915a11999-07-13 15:45:02 +000066
Wichert Akkermanfaf72222000-02-19 23:59:03 +000067
Wichert Akkerman36915a11999-07-13 15:45:02 +000068#ifdef LINUX
69
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +000070#ifdef IA64
71# include <asm/ptrace_offsets.h>
72#endif /* !IA64 */
73
Wichert Akkerman00a82ee2001-03-28 20:29:17 +000074#if HAVE_ASM_REG_H
Roland McGrath6d1a65c2004-07-12 07:44:08 +000075# if defined (SPARC) || defined (SPARC64)
Wichert Akkerman00a82ee2001-03-28 20:29:17 +000076# define fpq kernel_fpq
77# define fq kernel_fq
78# define fpu kernel_fpu
Roland McGrath30ff45e2003-01-30 20:15:23 +000079# endif
80# include <asm/reg.h>
Roland McGrath6d1a65c2004-07-12 07:44:08 +000081# if defined (SPARC) || defined (SPARC64)
Wichert Akkerman00a82ee2001-03-28 20:29:17 +000082# undef fpq
83# undef fq
Roland McGratha39c5a12002-12-17 05:10:37 +000084# undef fpu
Roland McGrath30ff45e2003-01-30 20:15:23 +000085# endif
Roland McGrath6d1a65c2004-07-12 07:44:08 +000086#if defined (LINUX) && defined (SPARC64)
87# define r_pc r_tpc
88# undef PTRACE_GETREGS
89# define PTRACE_GETREGS PTRACE_GETREGS64
90# undef PTRACE_SETREGS
91# define PTRACE_SETREGS PTRACE_SETREGS64
92#endif /* LINUX && SPARC64 */
Wichert Akkerman00a82ee2001-03-28 20:29:17 +000093#endif /* HAVE_ASM_REG_H */
Roland McGrath30ff45e2003-01-30 20:15:23 +000094
Roland McGrath6d1a65c2004-07-12 07:44:08 +000095#if defined (SPARC) || defined (SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000096typedef struct {
Wichert Akkerman9ce1a631999-08-29 23:15:07 +000097 struct regs si_regs;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000098 int si_mask;
99} m_siginfo_t;
Roland McGrath576b7842007-11-04 00:00:00 +0000100#elif defined (MIPS)
101typedef struct {
102 struct pt_regs si_regs;
103 int si_mask;
104} m_siginfo_t;
Roland McGrath30ff45e2003-01-30 20:15:23 +0000105#elif defined HAVE_ASM_SIGCONTEXT_H
106#if !defined(IA64) && !defined(X86_64)
Wichert Akkerman00a82ee2001-03-28 20:29:17 +0000107#include <asm/sigcontext.h>
Roland McGrath30ff45e2003-01-30 20:15:23 +0000108#endif /* !IA64 && !X86_64 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000109#else /* !HAVE_ASM_SIGCONTEXT_H */
Roland McGrath0cbb4e42008-05-20 01:26:21 +0000110#if defined I386 && !defined HAVE_STRUCT_SIGCONTEXT_STRUCT
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000111struct sigcontext_struct {
112 unsigned short gs, __gsh;
113 unsigned short fs, __fsh;
114 unsigned short es, __esh;
115 unsigned short ds, __dsh;
116 unsigned long edi;
117 unsigned long esi;
118 unsigned long ebp;
119 unsigned long esp;
120 unsigned long ebx;
121 unsigned long edx;
122 unsigned long ecx;
123 unsigned long eax;
124 unsigned long trapno;
125 unsigned long err;
126 unsigned long eip;
127 unsigned short cs, __csh;
128 unsigned long eflags;
129 unsigned long esp_at_signal;
130 unsigned short ss, __ssh;
131 unsigned long i387;
132 unsigned long oldmask;
133 unsigned long cr2;
134};
135#else /* !I386 */
136#ifdef M68K
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000137struct sigcontext
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000138{
139 unsigned long sc_mask;
140 unsigned long sc_usp;
141 unsigned long sc_d0;
142 unsigned long sc_d1;
143 unsigned long sc_a0;
144 unsigned long sc_a1;
145 unsigned short sc_sr;
146 unsigned long sc_pc;
147 unsigned short sc_formatvec;
148};
149#endif /* M68K */
150#endif /* !I386 */
151#endif /* !HAVE_ASM_SIGCONTEXT_H */
152#ifndef NSIG
153#define NSIG 32
154#endif
155#ifdef ARM
156#undef NSIG
157#define NSIG 32
158#endif
159#endif /* LINUX */
160
Roland McGrathee36ce12004-09-04 03:53:10 +0000161const char *const signalent0[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000162#include "signalent.h"
163};
Roland McGrathee36ce12004-09-04 03:53:10 +0000164const int nsignals0 = sizeof signalent0 / sizeof signalent0[0];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000165
166#if SUPPORTED_PERSONALITIES >= 2
Roland McGrathee36ce12004-09-04 03:53:10 +0000167const char *const signalent1[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000168#include "signalent1.h"
169};
Roland McGrathee36ce12004-09-04 03:53:10 +0000170const int nsignals1 = sizeof signalent1 / sizeof signalent1[0];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000171#endif /* SUPPORTED_PERSONALITIES >= 2 */
172
173#if SUPPORTED_PERSONALITIES >= 3
Roland McGrathee36ce12004-09-04 03:53:10 +0000174const char *const signalent2[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000175#include "signalent2.h"
176};
Roland McGrathee36ce12004-09-04 03:53:10 +0000177const int nsignals2 = sizeof signalent2 / sizeof signalent2[0];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000178#endif /* SUPPORTED_PERSONALITIES >= 3 */
179
Roland McGrathee36ce12004-09-04 03:53:10 +0000180const char *const *signalent;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000181int nsignals;
182
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000183#if defined(SUNOS4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000184
Roland McGrathd9f816f2004-09-04 03:39:20 +0000185static const struct xlat sigvec_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000186 { SV_ONSTACK, "SV_ONSTACK" },
187 { SV_INTERRUPT, "SV_INTERRUPT" },
188 { SV_RESETHAND, "SV_RESETHAND" },
189 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
190 { 0, NULL },
191};
192
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000193#endif /* SUNOS4 || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000194
195#ifdef HAVE_SIGACTION
196
Roland McGrath063ae2d2005-02-02 04:16:54 +0000197#if defined LINUX && (defined I386 || defined X86_64)
Roland McGrath2638cb42002-12-15 23:58:41 +0000198/* The libc headers do not define this constant since it should only be
199 used by the implementation. So wwe define it here. */
200# ifndef SA_RESTORER
201# define SA_RESTORER 0x04000000
202# endif
203#endif
204
Roland McGrathd9f816f2004-09-04 03:39:20 +0000205static const struct xlat sigact_flags[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000206#ifdef SA_RESTORER
207 { SA_RESTORER, "SA_RESTORER" },
208#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000209#ifdef SA_STACK
210 { SA_STACK, "SA_STACK" },
211#endif
212#ifdef SA_RESTART
213 { SA_RESTART, "SA_RESTART" },
214#endif
215#ifdef SA_INTERRUPT
216 { SA_INTERRUPT, "SA_INTERRUPT" },
217#endif
Roland McGrath4fef51d2008-07-18 01:02:41 +0000218#ifdef SA_NODEFER
219 { SA_NODEFER, "SA_NODEFER" },
220#endif
221#if defined SA_NOMASK && SA_NODEFER != SA_NOMASK
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000222 { SA_NOMASK, "SA_NOMASK" },
223#endif
Roland McGrath4fef51d2008-07-18 01:02:41 +0000224#ifdef SA_RESETHAND
225 { SA_RESETHAND, "SA_RESETHAND" },
226#endif
227#if defined SA_ONESHOT && SA_ONESHOT != SA_RESETHAND
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000228 { SA_ONESHOT, "SA_ONESHOT" },
229#endif
230#ifdef SA_SIGINFO
231 { SA_SIGINFO, "SA_SIGINFO" },
232#endif
233#ifdef SA_RESETHAND
234 { SA_RESETHAND, "SA_RESETHAND" },
235#endif
236#ifdef SA_ONSTACK
237 { SA_ONSTACK, "SA_ONSTACK" },
238#endif
239#ifdef SA_NODEFER
240 { SA_NODEFER, "SA_NODEFER" },
241#endif
242#ifdef SA_NOCLDSTOP
243 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
244#endif
245#ifdef SA_NOCLDWAIT
246 { SA_NOCLDWAIT, "SA_NOCLDWAIT" },
247#endif
248#ifdef _SA_BSDCALL
249 { _SA_BSDCALL, "_SA_BSDCALL" },
250#endif
251 { 0, NULL },
252};
253
Roland McGrathd9f816f2004-09-04 03:39:20 +0000254static const struct xlat sigprocmaskcmds[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000255 { SIG_BLOCK, "SIG_BLOCK" },
256 { SIG_UNBLOCK, "SIG_UNBLOCK" },
257 { SIG_SETMASK, "SIG_SETMASK" },
258#ifdef SIG_SETMASK32
259 { SIG_SETMASK32,"SIG_SETMASK32" },
260#endif
261 { 0, NULL },
262};
263
264#endif /* HAVE_SIGACTION */
265
Nate Sammonsce780fc1999-03-29 23:23:13 +0000266/* Anonymous realtime signals. */
267/* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
268 constant. This is what we want. Otherwise, just use SIGRTMIN. */
269#ifdef SIGRTMIN
270#ifndef __SIGRTMIN
271#define __SIGRTMIN SIGRTMIN
272#define __SIGRTMAX SIGRTMAX /* likewise */
273#endif
274#endif
275
Roland McGrathee36ce12004-09-04 03:53:10 +0000276const char *
Nate Sammonsce780fc1999-03-29 23:23:13 +0000277signame(sig)
278int sig;
279{
280 static char buf[30];
Roland McGrathad81dce2005-05-09 07:40:30 +0000281 if (sig >= 0 && sig < nsignals) {
Nate Sammonsce780fc1999-03-29 23:23:13 +0000282 return signalent[sig];
283#ifdef SIGRTMIN
Nate Sammons3080aa41999-03-30 00:16:41 +0000284 } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000285 sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN));
Nate Sammonsce780fc1999-03-29 23:23:13 +0000286 return buf;
287#endif /* SIGRTMIN */
288 } else {
289 sprintf(buf, "%d", sig);
290 return buf;
291 }
292}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000293
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000294#ifndef UNIXWARE
Nate Sammons4a121431999-04-06 01:19:39 +0000295static void
296long_to_sigset(l, s)
297long l;
298sigset_t *s;
299{
300 sigemptyset(s);
301 *(long *)s = l;
302}
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000303#endif
Nate Sammons4a121431999-04-06 01:19:39 +0000304
305static int
306copy_sigset_len(tcp, addr, s, len)
307struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000308long addr;
Nate Sammons4a121431999-04-06 01:19:39 +0000309sigset_t *s;
310int len;
311{
312 if (len > sizeof(*s))
313 len = sizeof(*s);
314 sigemptyset(s);
315 if (umoven(tcp, addr, len, (char *)s) < 0)
316 return -1;
317 return 0;
318}
319
320#ifdef LINUX
321/* Original sigset is unsigned long */
322#define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long))
323#else
324#define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t))
325#endif
326
Dmitry V. Levinab9008b2007-01-11 22:05:04 +0000327static const char *
328sprintsigmask(const char *str, sigset_t *mask, int rt)
329/* set might include realtime sigs */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000330{
331 int i, nsigs;
Nate Sammons4a121431999-04-06 01:19:39 +0000332 int maxsigs;
Dmitry V. Levinab9008b2007-01-11 22:05:04 +0000333 char *format, *s;
Roland McGratha39c5a12002-12-17 05:10:37 +0000334 static char outstr[8 * sizeof(sigset_t) * 8];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000335
Dmitry V. Levinab9008b2007-01-11 22:05:04 +0000336 strcpy(outstr, str);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000337 s = outstr + strlen(outstr);
338 nsigs = 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000339 maxsigs = nsignals;
340#ifdef __SIGRTMAX
341 if (rt)
342 maxsigs = __SIGRTMAX; /* instead */
343#endif
344 for (i = 1; i < maxsigs; i++) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000345 if (sigismember(mask, i) == 1)
346 nsigs++;
347 }
348 if (nsigs >= nsignals * 2 / 3) {
349 *s++ = '~';
Nate Sammons4a121431999-04-06 01:19:39 +0000350 for (i = 1; i < maxsigs; i++) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000351 switch (sigismember(mask, i)) {
352 case 1:
353 sigdelset(mask, i);
354 break;
355 case 0:
356 sigaddset(mask, i);
357 break;
358 }
359 }
360 }
361 format = "%s";
362 *s++ = '[';
Nate Sammons4a121431999-04-06 01:19:39 +0000363 for (i = 1; i < maxsigs; i++) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000364 if (sigismember(mask, i) == 1) {
John Hughesbdf48f52001-03-06 15:08:09 +0000365 /* real-time signals on solaris don't have
366 * signalent entries
367 */
368 if (i < nsignals) {
369 sprintf(s, format, signalent[i] + 3);
370 }
Roland McGrath90b4cb52003-09-23 22:19:32 +0000371#ifdef SIGRTMIN
372 else if (i >= __SIGRTMIN && i <= __SIGRTMAX) {
373 char tsig[40];
374 sprintf(tsig, "RT_%u", i - __SIGRTMIN);
375 sprintf(s, format, tsig);
376 }
377#endif /* SIGRTMIN */
John Hughesbdf48f52001-03-06 15:08:09 +0000378 else {
379 char tsig[32];
380 sprintf(tsig, "%u", i);
381 sprintf(s, format, tsig);
382 }
383 s += strlen(s);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000384 format = " %s";
385 }
386 }
387 *s++ = ']';
388 *s = '\0';
389 return outstr;
390}
391
392static void
Nate Sammons4a121431999-04-06 01:19:39 +0000393printsigmask(mask, rt)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000394sigset_t *mask;
Nate Sammons4a121431999-04-06 01:19:39 +0000395int rt;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000396{
Nate Sammons4a121431999-04-06 01:19:39 +0000397 tprintf("%s", sprintsigmask("", mask, rt));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000398}
399
400void
401printsignal(nr)
402int nr;
403{
Nate Sammonsce780fc1999-03-29 23:23:13 +0000404 tprintf(signame(nr));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000405}
406
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000407void
408print_sigset(struct tcb *tcp, long addr, int rt)
409{
410 sigset_t ss;
411
412 if (!addr)
413 tprintf("NULL");
414 else if (copy_sigset(tcp, addr, &ss) < 0)
415 tprintf("%#lx", addr);
416 else
417 printsigmask(&ss, rt);
418}
419
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000420#ifdef LINUX
421
John Hughes58265892001-10-18 15:13:53 +0000422#ifndef ILL_ILLOPC
423#define ILL_ILLOPC 1 /* illegal opcode */
424#define ILL_ILLOPN 2 /* illegal operand */
425#define ILL_ILLADR 3 /* illegal addressing mode */
426#define ILL_ILLTRP 4 /* illegal trap */
427#define ILL_PRVOPC 5 /* privileged opcode */
428#define ILL_PRVREG 6 /* privileged register */
429#define ILL_COPROC 7 /* coprocessor error */
430#define ILL_BADSTK 8 /* internal stack error */
431#define FPE_INTDIV 1 /* integer divide by zero */
432#define FPE_INTOVF 2 /* integer overflow */
433#define FPE_FLTDIV 3 /* floating point divide by zero */
434#define FPE_FLTOVF 4 /* floating point overflow */
435#define FPE_FLTUND 5 /* floating point underflow */
436#define FPE_FLTRES 6 /* floating point inexact result */
437#define FPE_FLTINV 7 /* floating point invalid operation */
438#define FPE_FLTSUB 8 /* subscript out of range */
439#define SEGV_MAPERR 1 /* address not mapped to object */
440#define SEGV_ACCERR 2 /* invalid permissions for mapped object */
441#define BUS_ADRALN 1 /* invalid address alignment */
442#define BUS_ADRERR 2 /* non-existant physical address */
443#define BUS_OBJERR 3 /* object specific hardware error */
444#define TRAP_BRKPT 1 /* process breakpoint */
445#define TRAP_TRACE 2 /* process trace trap */
446#define CLD_EXITED 1 /* child has exited */
447#define CLD_KILLED 2 /* child was killed */
448#define CLD_DUMPED 3 /* child terminated abnormally */
449#define CLD_TRAPPED 4 /* traced child has trapped */
450#define CLD_STOPPED 5 /* child has stopped */
451#define CLD_CONTINUED 6 /* stopped child has continued */
452#define POLL_IN 1 /* data input available */
453#define POLL_OUT 2 /* output buffers available */
454#define POLL_MSG 3 /* input message available */
455#define POLL_ERR 4 /* i/o error */
456#define POLL_PRI 5 /* high priority input available */
457#define POLL_HUP 6 /* device disconnected */
458#define SI_USER 0 /* sent by kill, sigsend, raise */
459#define SI_QUEUE -1 /* sent by sigqueue */
460#define SI_TIMER -2 /* sent by timer expiration */
461#define SI_MESGQ -3 /* sent by real time mesq state change */
462#define SI_ASYNCIO -4 /* sent by AIO completion */
Roland McGrath941b7402003-05-23 00:29:02 +0000463#define SI_SIGIO -5 /* Sent by SIGIO */
464#define SI_TKILL -6 /* Sent by tkill */
John Hughes58265892001-10-18 15:13:53 +0000465#endif
466
467#if __GLIBC_MINOR__ < 1
468/* Type for data associated with a signal. */
469typedef union sigval
470{
471 int sival_int;
472 void *sival_ptr;
473} sigval_t;
474
475# define __SI_MAX_SIZE 128
476# define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
477
478typedef struct siginfo
479{
480 int si_signo; /* Signal number. */
481 int si_errno; /* If non-zero, an errno value associated with
482 this signal, as defined in <errno.h>. */
483 int si_code; /* Signal code. */
484
485 union
486 {
487 int _pad[__SI_PAD_SIZE];
488
489 /* kill(). */
490 struct
491 {
492 __pid_t si_pid; /* Sending process ID. */
493 __uid_t si_uid; /* Real user ID of sending process. */
494 } _kill;
495
496 /* POSIX.1b timers. */
497 struct
498 {
499 unsigned int _timer1;
500 unsigned int _timer2;
501 } _timer;
502
503 /* POSIX.1b signals. */
504 struct
505 {
506 __pid_t si_pid; /* Sending process ID. */
507 __uid_t si_uid; /* Real user ID of sending process. */
508 sigval_t si_sigval; /* Signal value. */
509 } _rt;
510
511 /* SIGCHLD. */
512 struct
513 {
514 __pid_t si_pid; /* Which child. */
515 int si_status; /* Exit value or signal. */
516 __clock_t si_utime;
517 __clock_t si_stime;
518 } _sigchld;
519
520 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
521 struct
522 {
523 void *si_addr; /* Faulting insn/memory ref. */
524 } _sigfault;
525
526 /* SIGPOLL. */
527 struct
528 {
529 int si_band; /* Band event for SIGPOLL. */
530 int si_fd;
531 } _sigpoll;
532 } _sifields;
533} siginfo_t;
534
535#define si_pid _sifields._kill.si_pid
536#define si_uid _sifields._kill.si_uid
537#define si_status _sifields._sigchld.si_status
538#define si_utime _sifields._sigchld.si_utime
539#define si_stime _sifields._sigchld.si_stime
540#define si_value _sifields._rt.si_sigval
541#define si_int _sifields._rt.si_sigval.sival_int
542#define si_ptr _sifields._rt.si_sigval.sival_ptr
543#define si_addr _sifields._sigfault.si_addr
544#define si_band _sifields._sigpoll.si_band
545#define si_fd _sifields._sigpoll.si_fd
546
547#endif
548
549#endif
550
551#if defined (SVR4) || defined (LINUX)
552
Roland McGrathd9f816f2004-09-04 03:39:20 +0000553static const struct xlat siginfo_codes[] = {
John Hughes58265892001-10-18 15:13:53 +0000554#ifdef SI_NOINFO
555 { SI_NOINFO, "SI_NOINFO" },
556#endif
557#ifdef SI_USER
558 { SI_USER, "SI_USER" },
559#endif
560#ifdef SI_LWP
561 { SI_LWP, "SI_LWP" },
562#endif
563#ifdef SI_QUEUE
564 { SI_QUEUE, "SI_QUEUE" },
565#endif
566#ifdef SI_TIMER
567 { SI_TIMER, "SI_TIMER" },
568#endif
569#ifdef SI_ASYNCIO
570 { SI_ASYNCIO, "SI_ASYNCIO" },
571#endif
572#ifdef SI_MESGQ
573 { SI_MESGQ, "SI_MESGQ" },
574#endif
Roland McGrath941b7402003-05-23 00:29:02 +0000575#ifdef SI_SIGIO
576 { SI_SIGIO, "SI_SIGIO" },
577#endif
578#ifdef SI_TKILL
579 { SI_TKILL, "SI_TKILL" },
580#endif
John Hughes58265892001-10-18 15:13:53 +0000581 { 0, NULL },
582};
583
Roland McGrathd9f816f2004-09-04 03:39:20 +0000584static const struct xlat sigill_codes[] = {
John Hughes58265892001-10-18 15:13:53 +0000585 { ILL_ILLOPC, "ILL_ILLOPC" },
586 { ILL_ILLOPN, "ILL_ILLOPN" },
587 { ILL_ILLADR, "ILL_ILLADR" },
588 { ILL_ILLTRP, "ILL_ILLTRP" },
589 { ILL_PRVOPC, "ILL_PRVOPC" },
590 { ILL_PRVREG, "ILL_PRVREG" },
591 { ILL_COPROC, "ILL_COPROC" },
592 { ILL_BADSTK, "ILL_BADSTK" },
593 { 0, NULL },
594};
595
Roland McGrathd9f816f2004-09-04 03:39:20 +0000596static const struct xlat sigfpe_codes[] = {
John Hughes58265892001-10-18 15:13:53 +0000597 { FPE_INTDIV, "FPE_INTDIV" },
598 { FPE_INTOVF, "FPE_INTOVF" },
599 { FPE_FLTDIV, "FPE_FLTDIV" },
600 { FPE_FLTOVF, "FPE_FLTOVF" },
601 { FPE_FLTUND, "FPE_FLTUND" },
602 { FPE_FLTRES, "FPE_FLTRES" },
603 { FPE_FLTINV, "FPE_FLTINV" },
604 { FPE_FLTSUB, "FPE_FLTSUB" },
605 { 0, NULL },
606};
607
Roland McGrathd9f816f2004-09-04 03:39:20 +0000608static const struct xlat sigtrap_codes[] = {
John Hughes58265892001-10-18 15:13:53 +0000609 { TRAP_BRKPT, "TRAP_BRKPT" },
610 { TRAP_TRACE, "TRAP_TRACE" },
611 { 0, NULL },
612};
613
Roland McGrathd9f816f2004-09-04 03:39:20 +0000614static const struct xlat sigchld_codes[] = {
John Hughes58265892001-10-18 15:13:53 +0000615 { CLD_EXITED, "CLD_EXITED" },
616 { CLD_KILLED, "CLD_KILLED" },
617 { CLD_DUMPED, "CLD_DUMPED" },
618 { CLD_TRAPPED, "CLD_TRAPPED" },
619 { CLD_STOPPED, "CLD_STOPPED" },
620 { CLD_CONTINUED,"CLD_CONTINUED" },
621 { 0, NULL },
622};
623
Roland McGrathd9f816f2004-09-04 03:39:20 +0000624static const struct xlat sigpoll_codes[] = {
John Hughes58265892001-10-18 15:13:53 +0000625 { POLL_IN, "POLL_IN" },
626 { POLL_OUT, "POLL_OUT" },
627 { POLL_MSG, "POLL_MSG" },
628 { POLL_ERR, "POLL_ERR" },
629 { POLL_PRI, "POLL_PRI" },
630 { POLL_HUP, "POLL_HUP" },
631 { 0, NULL },
632};
633
Roland McGrathd9f816f2004-09-04 03:39:20 +0000634static const struct xlat sigprof_codes[] = {
John Hughes58265892001-10-18 15:13:53 +0000635#ifdef PROF_SIG
636 { PROF_SIG, "PROF_SIG" },
637#endif
638 { 0, NULL },
639};
640
641#ifdef SIGEMT
Roland McGrathd9f816f2004-09-04 03:39:20 +0000642static const struct xlat sigemt_codes[] = {
John Hughes58265892001-10-18 15:13:53 +0000643#ifdef EMT_TAGOVF
644 { EMT_TAGOVF, "EMT_TAGOVF" },
645#endif
646 { 0, NULL },
647};
648#endif
649
Roland McGrathd9f816f2004-09-04 03:39:20 +0000650static const struct xlat sigsegv_codes[] = {
John Hughes58265892001-10-18 15:13:53 +0000651 { SEGV_MAPERR, "SEGV_MAPERR" },
652 { SEGV_ACCERR, "SEGV_ACCERR" },
653 { 0, NULL },
654};
655
Roland McGrathd9f816f2004-09-04 03:39:20 +0000656static const struct xlat sigbus_codes[] = {
John Hughes58265892001-10-18 15:13:53 +0000657 { BUS_ADRALN, "BUS_ADRALN" },
658 { BUS_ADRERR, "BUS_ADRERR" },
659 { BUS_OBJERR, "BUS_OBJERR" },
660 { 0, NULL },
661};
662
663void
664printsiginfo(sip, verbose)
665siginfo_t *sip;
666int verbose;
667{
Roland McGrathf9c49b22004-10-06 22:11:54 +0000668 const char *code;
John Hughes58265892001-10-18 15:13:53 +0000669
670 if (sip->si_signo == 0) {
671 tprintf ("{}");
672 return;
673 }
674 tprintf("{si_signo=");
675 printsignal(sip->si_signo);
676 code = xlookup(siginfo_codes, sip->si_code);
677 if (!code) {
678 switch (sip->si_signo) {
679 case SIGTRAP:
680 code = xlookup(sigtrap_codes, sip->si_code);
681 break;
682 case SIGCHLD:
683 code = xlookup(sigchld_codes, sip->si_code);
684 break;
685 case SIGPOLL:
686 code = xlookup(sigpoll_codes, sip->si_code);
687 break;
688 case SIGPROF:
689 code = xlookup(sigprof_codes, sip->si_code);
690 break;
691 case SIGILL:
692 code = xlookup(sigill_codes, sip->si_code);
693 break;
694#ifdef SIGEMT
695 case SIGEMT:
696 code = xlookup(sigemt_codes, sip->si_code);
697 break;
698#endif
699 case SIGFPE:
700 code = xlookup(sigfpe_codes, sip->si_code);
701 break;
702 case SIGSEGV:
703 code = xlookup(sigsegv_codes, sip->si_code);
704 break;
705 case SIGBUS:
706 code = xlookup(sigbus_codes, sip->si_code);
707 break;
708 }
709 }
710 if (code)
711 tprintf(", si_code=%s", code);
712 else
713 tprintf(", si_code=%#x", sip->si_code);
714#ifdef SI_NOINFO
715 if (sip->si_code != SI_NOINFO)
716#endif
717 {
718 if (sip->si_errno) {
719 if (sip->si_errno < 0 || sip->si_errno >= nerrnos)
720 tprintf(", si_errno=%d", sip->si_errno);
721 else
722 tprintf(", si_errno=%s",
723 errnoent[sip->si_errno]);
724 }
725#ifdef SI_FROMUSER
726 if (SI_FROMUSER(sip)) {
727 tprintf(", si_pid=%ld, si_uid=%ld",
728 sip->si_pid, sip->si_uid);
729#ifdef SI_QUEUE
730 switch (sip->si_code) {
731 case SI_QUEUE:
732#ifdef SI_TIMER
733 case SI_TIMER:
734#endif /* SI_QUEUE */
735 case SI_ASYNCIO:
736#ifdef SI_MESGQ
737 case SI_MESGQ:
738#endif /* SI_MESGQ */
739 tprintf(", si_value=%d",
740 sip->si_value.sival_int);
741 break;
742 }
743#endif /* SI_QUEUE */
744 }
745 else
746#endif /* SI_FROMUSER */
747 {
748 switch (sip->si_signo) {
749 case SIGCHLD:
750 tprintf(", si_pid=%ld, si_status=",
751 (long) sip->si_pid);
752 if (sip->si_code == CLD_EXITED)
753 tprintf("%d", sip->si_status);
754 else
755 printsignal(sip->si_status);
756#if LINUX
757 if (!verbose)
758 tprintf(", ...");
759 else
760 tprintf(", si_utime=%lu, si_stime=%lu",
761 sip->si_utime,
762 sip->si_stime);
763#endif
764 break;
765 case SIGILL: case SIGFPE:
766 case SIGSEGV: case SIGBUS:
767 tprintf(", si_addr=%#lx",
768 (unsigned long) sip->si_addr);
769 break;
770 case SIGPOLL:
771 switch (sip->si_code) {
772 case POLL_IN: case POLL_OUT: case POLL_MSG:
773 tprintf(", si_band=%ld",
774 (long) sip->si_band);
775 break;
776 }
777 break;
778#ifdef LINUX
779 default:
780 tprintf(", si_pid=%lu, si_uid=%lu, ",
781 (unsigned long) sip->si_pid,
782 (unsigned long) sip->si_uid);
783 if (!verbose)
784 tprintf("...");
785 else {
786 tprintf("si_value={int=%u, ptr=%#lx}",
787 sip->si_int,
788 (unsigned long) sip->si_ptr);
789 }
790#endif
Roland McGratha39c5a12002-12-17 05:10:37 +0000791
John Hughes58265892001-10-18 15:13:53 +0000792 }
793 }
794 }
795 tprintf("}");
796}
797
798#endif /* SVR4 || LINUX */
799
800#ifdef LINUX
801
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000802static void
803parse_sigset_t (const char *str, sigset_t *set)
804{
Roland McGrathc38feca2003-10-01 07:50:28 +0000805 const char *p;
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000806 unsigned int digit;
807 int i;
808
809 sigemptyset(set);
810
Roland McGrathc38feca2003-10-01 07:50:28 +0000811 p = strchr(str, '\n');
812 if (p == NULL)
813 p = strchr(str, '\0');
814 for (i = 0; p-- > str; i += 4) {
815 if (*p >= '0' && *p <= '9')
816 digit = *p - '0';
817 else if (*p >= 'a' && *p <= 'f')
Roland McGrath92f1d6d2004-08-31 07:03:20 +0000818 digit = *p - 'a' + 10;
Roland McGrathc38feca2003-10-01 07:50:28 +0000819 else if (*p >= 'A' && *p <= 'F')
Roland McGrath92f1d6d2004-08-31 07:03:20 +0000820 digit = *p - 'A' + 10;
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000821 else
Roland McGrathc38feca2003-10-01 07:50:28 +0000822 break;
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000823 if (digit & 1)
824 sigaddset(set, i + 1);
825 if (digit & 2)
826 sigaddset(set, i + 2);
827 if (digit & 4)
828 sigaddset(set, i + 3);
829 if (digit & 8)
830 sigaddset(set, i + 4);
831 }
832}
833
834#endif
835
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000836/*
837 * Check process TCP for the disposition of signal SIG.
838 * Return 1 if the process would somehow manage to survive signal SIG,
839 * else return 0. This routine will never be called with SIGKILL.
840 */
841int
842sigishandled(tcp, sig)
843struct tcb *tcp;
844int sig;
845{
846#ifdef LINUX
847 int sfd;
848 char sname[32];
Wichert Akkermand5c2dae2001-04-12 09:10:24 +0000849 char buf[2048];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000850 char *s;
851 int i;
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000852 sigset_t ignored, caught;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000853#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000854#ifdef SVR4
855 /*
856 * Since procfs doesn't interfere with wait I think it is safe
857 * to punt on this question. If not, the information is there.
858 */
859 return 1;
860#else /* !SVR4 */
861 switch (sig) {
862 case SIGCONT:
863 case SIGSTOP:
864 case SIGTSTP:
865 case SIGTTIN:
866 case SIGTTOU:
867 case SIGCHLD:
868 case SIGIO:
869#if defined(SIGURG) && SIGURG != SIGIO
870 case SIGURG:
871#endif
872 case SIGWINCH:
873 /* Gloria Gaynor says ... */
874 return 1;
875 default:
876 break;
877 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000878#endif /* !SVR4 */
Wichert Akkermand5c2dae2001-04-12 09:10:24 +0000879#ifdef LINUX
880
881 /* This is incredibly costly but it's worth it. */
882 /* NOTE: LinuxThreads internally uses SIGRTMIN, SIGRTMIN + 1 and
883 SIGRTMIN + 2, so we can't use the obsolete /proc/%d/stat which
884 doesn't handle real-time signals). */
885 sprintf(sname, "/proc/%d/status", tcp->pid);
886 if ((sfd = open(sname, O_RDONLY)) == -1) {
887 perror(sname);
888 return 1;
889 }
890 i = read(sfd, buf, sizeof(buf));
891 buf[i] = '\0';
892 close(sfd);
893 /*
894 * Skip the extraneous fields. We need to skip
895 * command name has any spaces in it. So be it.
896 */
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000897 s = strstr(buf, "SigIgn:\t");
Wichert Akkermand5c2dae2001-04-12 09:10:24 +0000898 if (!s)
899 {
900 fprintf(stderr, "/proc/pid/status format error\n");
901 return 1;
902 }
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000903 parse_sigset_t(s + 8, &ignored);
Wichert Akkermand5c2dae2001-04-12 09:10:24 +0000904
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000905 s = strstr(buf, "SigCgt:\t");
906 if (!s)
907 {
908 fprintf(stderr, "/proc/pid/status format error\n");
909 return 1;
910 }
911 parse_sigset_t(s + 8, &caught);
Wichert Akkermand5c2dae2001-04-12 09:10:24 +0000912
913#ifdef DEBUG
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000914 fprintf(stderr, "sigs: %016qx %016qx (sig=%d)\n",
915 *(long long *) &ignored, *(long long *) &caught, sig);
Wichert Akkermand5c2dae2001-04-12 09:10:24 +0000916#endif
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000917 if (sigismember(&ignored, sig) || sigismember(&caught, sig))
Wichert Akkermand5c2dae2001-04-12 09:10:24 +0000918 return 1;
919#endif /* LINUX */
920
921#ifdef SUNOS4
922 void (*u_signal)();
923
Denys Vlasenko932fc7d2008-12-16 18:18:40 +0000924 if (upeek(tcp, uoff(u_signal[0]) + sig*sizeof(u_signal),
Wichert Akkermand5c2dae2001-04-12 09:10:24 +0000925 (long *) &u_signal) < 0) {
926 return 0;
927 }
928 if (u_signal != SIG_DFL)
929 return 1;
930#endif /* SUNOS4 */
931
932 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000933}
934
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000935#if defined(SUNOS4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000936
937int
938sys_sigvec(tcp)
939struct tcb *tcp;
940{
941 struct sigvec sv;
942 long addr;
943
944 if (entering(tcp)) {
945 printsignal(tcp->u_arg[0]);
946 tprintf(", ");
947 addr = tcp->u_arg[1];
948 } else {
949 addr = tcp->u_arg[2];
950 }
951 if (addr == 0)
952 tprintf("NULL");
953 else if (!verbose(tcp))
954 tprintf("%#lx", addr);
955 else if (umove(tcp, addr, &sv) < 0)
956 tprintf("{...}");
957 else {
958 switch ((int) sv.sv_handler) {
959 case (int) SIG_ERR:
960 tprintf("{SIG_ERR}");
961 break;
962 case (int) SIG_DFL:
963 tprintf("{SIG_DFL}");
964 break;
965 case (int) SIG_IGN:
966 if (tcp->u_arg[0] == SIGTRAP) {
967 tcp->flags |= TCB_SIGTRAPPED;
968 kill(tcp->pid, SIGSTOP);
969 }
970 tprintf("{SIG_IGN}");
971 break;
972 case (int) SIG_HOLD:
973 if (tcp->u_arg[0] == SIGTRAP) {
974 tcp->flags |= TCB_SIGTRAPPED;
975 kill(tcp->pid, SIGSTOP);
976 }
977 tprintf("SIG_HOLD");
978 break;
979 default:
980 if (tcp->u_arg[0] == SIGTRAP) {
981 tcp->flags |= TCB_SIGTRAPPED;
982 kill(tcp->pid, SIGSTOP);
983 }
984 tprintf("{%#lx, ", (unsigned long) sv.sv_handler);
Nate Sammons4a121431999-04-06 01:19:39 +0000985 printsigmask(&sv.sv_mask, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000986 tprintf(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000987 printflags(sigvec_flags, sv.sv_flags, "SV_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000988 tprintf("}");
989 }
990 }
991 if (entering(tcp))
992 tprintf(", ");
993 return 0;
994}
995
996int
997sys_sigpause(tcp)
998struct tcb *tcp;
999{
1000 if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */
Nate Sammons4a121431999-04-06 01:19:39 +00001001 sigset_t sigm;
1002 long_to_sigset(tcp->u_arg[0], &sigm);
1003 printsigmask(&sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001004 }
1005 return 0;
1006}
1007
1008int
1009sys_sigstack(tcp)
1010struct tcb *tcp;
1011{
1012 struct sigstack ss;
1013 long addr;
1014
1015 if (entering(tcp))
1016 addr = tcp->u_arg[0];
1017 else
1018 addr = tcp->u_arg[1];
1019 if (addr == 0)
1020 tprintf("NULL");
1021 else if (umove(tcp, addr, &ss) < 0)
1022 tprintf("%#lx", addr);
1023 else {
1024 tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp);
1025 tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO");
1026 }
1027 if (entering(tcp))
1028 tprintf(", ");
1029 return 0;
1030}
1031
1032int
1033sys_sigcleanup(tcp)
1034struct tcb *tcp;
1035{
1036 return 0;
1037}
1038
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001039#endif /* SUNOS4 || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001040
1041#ifndef SVR4
1042
1043int
1044sys_sigsetmask(tcp)
1045struct tcb *tcp;
1046{
1047 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001048 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +00001049 long_to_sigset(tcp->u_arg[0], &sigm);
1050 printsigmask(&sigm, 0);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001051#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001052 if ((tcp->u_arg[0] & sigmask(SIGTRAP))) {
1053 /* Mark attempt to block SIGTRAP */
1054 tcp->flags |= TCB_SIGTRAPPED;
1055 /* Send unblockable signal */
1056 kill(tcp->pid, SIGSTOP);
1057 }
Roland McGratha39c5a12002-12-17 05:10:37 +00001058#endif /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001059 }
1060 else if (!syserror(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001061 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +00001062 long_to_sigset(tcp->u_rval, &sigm);
1063 tcp->auxstr = sprintsigmask("old mask ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001064
1065 return RVAL_HEX | RVAL_STR;
1066 }
1067 return 0;
1068}
1069
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +00001070#if defined(SUNOS4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001071int
1072sys_sigblock(tcp)
1073struct tcb *tcp;
1074{
1075 return sys_sigsetmask(tcp);
1076}
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +00001077#endif /* SUNOS4 || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001078
1079#endif /* !SVR4 */
1080
1081#ifdef HAVE_SIGACTION
1082
1083#ifdef LINUX
1084struct old_sigaction {
1085 __sighandler_t __sa_handler;
1086 unsigned long sa_mask;
1087 unsigned long sa_flags;
1088 void (*sa_restorer)(void);
1089};
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001090#define SA_HANDLER __sa_handler
1091#endif /* LINUX */
1092
Roland McGratha39c5a12002-12-17 05:10:37 +00001093#ifndef SA_HANDLER
1094#define SA_HANDLER sa_handler
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001095#endif
1096
1097int
1098sys_sigaction(tcp)
1099struct tcb *tcp;
1100{
1101 long addr;
Nate Sammons4a121431999-04-06 01:19:39 +00001102#ifdef LINUX
John Hughes1e4cb342001-03-06 09:25:46 +00001103 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001104 struct old_sigaction sa;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001105#else
1106 struct sigaction sa;
1107#endif
1108
1109
1110 if (entering(tcp)) {
1111 printsignal(tcp->u_arg[0]);
1112 tprintf(", ");
1113 addr = tcp->u_arg[1];
1114 } else
1115 addr = tcp->u_arg[2];
1116 if (addr == 0)
1117 tprintf("NULL");
1118 else if (!verbose(tcp))
1119 tprintf("%#lx", addr);
1120 else if (umove(tcp, addr, &sa) < 0)
1121 tprintf("{...}");
1122 else {
Roland McGrath5f206812008-08-20 01:59:40 +00001123 if (sa.SA_HANDLER == SIG_ERR)
1124 tprintf("{SIG_ERR, ");
1125 else if (sa.SA_HANDLER == SIG_DFL)
1126 tprintf("{SIG_DFL, ");
Denys Vlasenko73ce40e2008-12-17 17:22:03 +00001127 else if (sa.SA_HANDLER == SIG_IGN) {
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001128#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001129 if (tcp->u_arg[0] == SIGTRAP) {
1130 tcp->flags |= TCB_SIGTRAPPED;
1131 kill(tcp->pid, SIGSTOP);
1132 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001133#endif /* !USE_PROCFS */
Roland McGrath5f206812008-08-20 01:59:40 +00001134 tprintf("{SIG_IGN, ");
1135 }
1136 else {
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001137#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001138 if (tcp->u_arg[0] == SIGTRAP) {
1139 tcp->flags |= TCB_SIGTRAPPED;
1140 kill(tcp->pid, SIGSTOP);
1141 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001142#endif /* !USE_PROCFS */
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001143 tprintf("{%#lx, ", (long) sa.SA_HANDLER);
Wichert Akkerman48214be1999-11-26 09:55:42 +00001144#ifndef LINUX
1145 printsigmask (&sa.sa_mask, 0);
1146#else
Nate Sammons4a121431999-04-06 01:19:39 +00001147 long_to_sigset(sa.sa_mask, &sigset);
1148 printsigmask(&sigset, 0);
Wichert Akkerman48214be1999-11-26 09:55:42 +00001149#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001150 tprintf(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001151 printflags(sigact_flags, sa.sa_flags, "SA_???");
Roland McGrath2638cb42002-12-15 23:58:41 +00001152#ifdef SA_RESTORER
1153 if (sa.sa_flags & SA_RESTORER)
1154 tprintf(", %p", sa.sa_restorer);
1155#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001156 tprintf("}");
1157 }
1158 }
1159 if (entering(tcp))
1160 tprintf(", ");
1161#ifdef LINUX
1162 else
1163 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
1164#endif
1165 return 0;
1166}
1167
1168int
1169sys_signal(tcp)
1170struct tcb *tcp;
1171{
1172 if (entering(tcp)) {
1173 printsignal(tcp->u_arg[0]);
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001174 tprintf(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001175 switch (tcp->u_arg[1]) {
Jan Kratochvil1f942712008-08-06 21:38:52 +00001176 case (long) SIG_ERR:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001177 tprintf("SIG_ERR");
1178 break;
Jan Kratochvil1f942712008-08-06 21:38:52 +00001179 case (long) SIG_DFL:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001180 tprintf("SIG_DFL");
1181 break;
Jan Kratochvil1f942712008-08-06 21:38:52 +00001182 case (long) SIG_IGN:
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001183#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001184 if (tcp->u_arg[0] == SIGTRAP) {
1185 tcp->flags |= TCB_SIGTRAPPED;
1186 kill(tcp->pid, SIGSTOP);
1187 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001188#endif /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001189 tprintf("SIG_IGN");
1190 break;
1191 default:
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001192#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001193 if (tcp->u_arg[0] == SIGTRAP) {
1194 tcp->flags |= TCB_SIGTRAPPED;
1195 kill(tcp->pid, SIGSTOP);
1196 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001197#endif /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001198 tprintf("%#lx", tcp->u_arg[1]);
1199 }
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001200 return 0;
1201 }
Dmitry V. Levin21a75342008-09-03 01:22:18 +00001202 else if (!syserror(tcp)) {
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001203 switch (tcp->u_rval) {
Jan Kratochvil1f942712008-08-06 21:38:52 +00001204 case (long) SIG_ERR:
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001205 tcp->auxstr = "SIG_ERR"; break;
Jan Kratochvil1f942712008-08-06 21:38:52 +00001206 case (long) SIG_DFL:
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001207 tcp->auxstr = "SIG_DFL"; break;
Jan Kratochvil1f942712008-08-06 21:38:52 +00001208 case (long) SIG_IGN:
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001209 tcp->auxstr = "SIG_IGN"; break;
1210 default:
1211 tcp->auxstr = NULL;
1212 }
1213 return RVAL_HEX | RVAL_STR;
1214 }
Dmitry V. Levin21a75342008-09-03 01:22:18 +00001215 return 0;
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001216}
1217
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +00001218#ifdef SVR4
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001219int
1220sys_sighold(tcp)
1221struct tcb *tcp;
1222{
1223 if (entering(tcp)) {
1224 printsignal(tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001225 }
1226 return 0;
1227}
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +00001228#endif /* SVR4 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001229
1230#endif /* HAVE_SIGACTION */
1231
1232#ifdef LINUX
1233
1234int
1235sys_sigreturn(tcp)
1236struct tcb *tcp;
1237{
Roland McGrath0f87c492003-06-03 23:29:04 +00001238#ifdef ARM
1239 struct pt_regs regs;
1240 struct sigcontext_struct sc;
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001241
Roland McGrath0f87c492003-06-03 23:29:04 +00001242 if (entering(tcp)) {
1243 tcp->u_arg[0] = 0;
1244
1245 if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, (void *)&regs) == -1)
1246 return 0;
1247
1248 if (umove(tcp, regs.ARM_sp, &sc) < 0)
1249 return 0;
1250
1251 tcp->u_arg[0] = 1;
1252 tcp->u_arg[1] = sc.oldmask;
1253 } else {
1254 sigset_t sigm;
1255 long_to_sigset(tcp->u_arg[1], &sigm);
1256 tcp->u_rval = tcp->u_error = 0;
1257 if (tcp->u_arg[0] == 0)
1258 return 0;
1259 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1260 return RVAL_NONE | RVAL_STR;
1261 }
1262 return 0;
1263#elif defined(S390) || defined(S390X)
1264 long usp;
1265 struct sigcontext_struct sc;
1266
1267 if (entering(tcp)) {
1268 tcp->u_arg[0] = 0;
Denys Vlasenko932fc7d2008-12-16 18:18:40 +00001269 if (upeek(tcp,PT_GPR15,&usp)<0)
Roland McGrath0f87c492003-06-03 23:29:04 +00001270 return 0;
1271 if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0)
1272 return 0;
1273 tcp->u_arg[0] = 1;
1274 memcpy(&tcp->u_arg[1],&sc.oldmask[0],sizeof(sigset_t));
1275 } else {
1276 tcp->u_rval = tcp->u_error = 0;
1277 if (tcp->u_arg[0] == 0)
1278 return 0;
1279 tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1],0);
1280 return RVAL_NONE | RVAL_STR;
1281 }
1282 return 0;
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001283#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001284#ifdef I386
1285 long esp;
1286 struct sigcontext_struct sc;
1287
1288 if (entering(tcp)) {
1289 tcp->u_arg[0] = 0;
Denys Vlasenko932fc7d2008-12-16 18:18:40 +00001290 if (upeek(tcp, 4*UESP, &esp) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001291 return 0;
1292 if (umove(tcp, esp, &sc) < 0)
1293 return 0;
1294 tcp->u_arg[0] = 1;
1295 tcp->u_arg[1] = sc.oldmask;
1296 }
1297 else {
1298 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +00001299 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001300 tcp->u_rval = tcp->u_error = 0;
1301 if (tcp->u_arg[0] == 0)
1302 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +00001303 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001304 return RVAL_NONE | RVAL_STR;
1305 }
1306 return 0;
1307#else /* !I386 */
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001308#ifdef IA64
1309 struct sigcontext sc;
1310 long sp;
1311
1312 if (entering(tcp)) {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +00001313 /* offset of sigcontext in the kernel's sigframe structure: */
1314# define SIGFRAME_SC_OFFSET 0x90
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001315 tcp->u_arg[0] = 0;
Denys Vlasenko932fc7d2008-12-16 18:18:40 +00001316 if (upeek(tcp, PT_R12, &sp) < 0)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001317 return 0;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +00001318 if (umove(tcp, sp + 16 + SIGFRAME_SC_OFFSET, &sc) < 0)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001319 return 0;
1320 tcp->u_arg[0] = 1;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +00001321 memcpy(tcp->u_arg + 1, &sc.sc_mask, sizeof(sc.sc_mask));
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001322 }
1323 else {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +00001324 sigset_t sigm;
1325
1326 memcpy(&sigm, tcp->u_arg + 1, sizeof (sigm));
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001327 tcp->u_rval = tcp->u_error = 0;
1328 if (tcp->u_arg[0] == 0)
1329 return 0;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +00001330 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001331 return RVAL_NONE | RVAL_STR;
1332 }
1333 return 0;
1334#else /* !IA64 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001335#ifdef POWERPC
Roland McGrath0f87c492003-06-03 23:29:04 +00001336 long esp;
1337 struct sigcontext_struct sc;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001338
Roland McGrath0f87c492003-06-03 23:29:04 +00001339 if (entering(tcp)) {
1340 tcp->u_arg[0] = 0;
Denys Vlasenko932fc7d2008-12-16 18:18:40 +00001341 if (upeek(tcp, sizeof(unsigned long)*PT_R1, &esp) < 0)
Roland McGrath0f87c492003-06-03 23:29:04 +00001342 return 0;
1343 if (umove(tcp, esp, &sc) < 0)
1344 return 0;
1345 tcp->u_arg[0] = 1;
1346 tcp->u_arg[1] = sc.oldmask;
1347 }
1348 else {
1349 sigset_t sigm;
1350 long_to_sigset(tcp->u_arg[1], &sigm);
1351 tcp->u_rval = tcp->u_error = 0;
1352 if (tcp->u_arg[0] == 0)
1353 return 0;
1354 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1355 return RVAL_NONE | RVAL_STR;
1356 }
1357 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001358#else /* !POWERPC */
1359#ifdef M68K
1360 long usp;
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001361 struct sigcontext sc;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001362
1363 if (entering(tcp)) {
Roland McGrath0f87c492003-06-03 23:29:04 +00001364 tcp->u_arg[0] = 0;
Denys Vlasenko932fc7d2008-12-16 18:18:40 +00001365 if (upeek(tcp, 4*PT_USP, &usp) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001366 return 0;
Roland McGrath0f87c492003-06-03 23:29:04 +00001367 if (umove(tcp, usp, &sc) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001368 return 0;
Roland McGrath0f87c492003-06-03 23:29:04 +00001369 tcp->u_arg[0] = 1;
1370 tcp->u_arg[1] = sc.sc_mask;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001371 }
1372 else {
Roland McGrath0f87c492003-06-03 23:29:04 +00001373 sigset_t sigm;
1374 long_to_sigset(tcp->u_arg[1], &sigm);
1375 tcp->u_rval = tcp->u_error = 0;
1376 if (tcp->u_arg[0] == 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001377 return 0;
Roland McGrath0f87c492003-06-03 23:29:04 +00001378 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1379 return RVAL_NONE | RVAL_STR;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001380 }
1381 return 0;
1382#else /* !M68K */
1383#ifdef ALPHA
1384 long fp;
1385 struct sigcontext_struct sc;
1386
1387 if (entering(tcp)) {
Roland McGrath0f87c492003-06-03 23:29:04 +00001388 tcp->u_arg[0] = 0;
Denys Vlasenko932fc7d2008-12-16 18:18:40 +00001389 if (upeek(tcp, REG_FP, &fp) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001390 return 0;
Roland McGrath0f87c492003-06-03 23:29:04 +00001391 if (umove(tcp, fp, &sc) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001392 return 0;
Roland McGrath0f87c492003-06-03 23:29:04 +00001393 tcp->u_arg[0] = 1;
1394 tcp->u_arg[1] = sc.sc_mask;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001395 }
1396 else {
Roland McGrath0f87c492003-06-03 23:29:04 +00001397 sigset_t sigm;
1398 long_to_sigset(tcp->u_arg[1], &sigm);
1399 tcp->u_rval = tcp->u_error = 0;
1400 if (tcp->u_arg[0] == 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001401 return 0;
Roland McGrath0f87c492003-06-03 23:29:04 +00001402 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1403 return RVAL_NONE | RVAL_STR;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001404 }
1405 return 0;
1406#else
Roland McGrath6d1a65c2004-07-12 07:44:08 +00001407#if defined (SPARC) || defined (SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001408 long i1;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +00001409 struct regs regs;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001410 m_siginfo_t si;
1411
1412 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)&regs, 0) < 0) {
Roland McGrath0f87c492003-06-03 23:29:04 +00001413 perror("sigreturn: PTRACE_GETREGS ");
1414 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001415 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001416 if(entering(tcp)) {
1417 tcp->u_arg[0] = 0;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +00001418 i1 = regs.r_o1;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001419 if(umove(tcp, i1, &si) < 0) {
1420 perror("sigreturn: umove ");
1421 return 0;
1422 }
1423 tcp->u_arg[0] = 1;
1424 tcp->u_arg[1] = si.si_mask;
1425 } else {
1426 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +00001427 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001428 tcp->u_rval = tcp->u_error = 0;
1429 if(tcp->u_arg[0] == 0)
1430 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +00001431 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001432 return RVAL_NONE | RVAL_STR;
1433 }
1434 return 0;
Roland McGratha39c5a12002-12-17 05:10:37 +00001435#else
Roland McGrath542c2c62008-05-20 01:11:56 +00001436#if defined (LINUX_MIPSN32) || defined (LINUX_MIPSN64)
1437 /* This decodes rt_sigreturn. The 64-bit ABIs do not have
1438 sigreturn. */
1439 long sp;
1440 struct ucontext uc;
1441
1442 if(entering(tcp)) {
1443 tcp->u_arg[0] = 0;
Denys Vlasenko932fc7d2008-12-16 18:18:40 +00001444 if (upeek(tcp, REG_SP, &sp) < 0)
Roland McGrath542c2c62008-05-20 01:11:56 +00001445 return 0;
1446 /* There are six words followed by a 128-byte siginfo. */
1447 sp = sp + 6 * 4 + 128;
1448 if (umove(tcp, sp, &uc) < 0)
1449 return 0;
1450 tcp->u_arg[0] = 1;
1451 tcp->u_arg[1] = *(long *) &uc.uc_sigmask;
1452 } else {
1453 sigset_t sigm;
1454 long_to_sigset(tcp->u_arg[1], &sigm);
1455 tcp->u_rval = tcp->u_error = 0;
1456 if(tcp->u_arg[0] == 0)
1457 return 0;
1458 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1459 return RVAL_NONE | RVAL_STR;
1460 }
1461 return 0;
1462#else
Wichert Akkermanf90da011999-10-31 21:15:38 +00001463#ifdef MIPS
1464 long sp;
Roland McGrath576b7842007-11-04 00:00:00 +00001465 struct pt_regs regs;
1466 m_siginfo_t si;
Wichert Akkermanf90da011999-10-31 21:15:38 +00001467
Roland McGrath576b7842007-11-04 00:00:00 +00001468 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)&regs, 0) < 0) {
1469 perror("sigreturn: PTRACE_GETREGS ");
1470 return 0;
1471 }
Wichert Akkermanf90da011999-10-31 21:15:38 +00001472 if(entering(tcp)) {
1473 tcp->u_arg[0] = 0;
Roland McGrath576b7842007-11-04 00:00:00 +00001474 sp = regs.regs[29];
1475 if (umove(tcp, sp, &si) < 0)
Wichert Akkermanf90da011999-10-31 21:15:38 +00001476 tcp->u_arg[0] = 1;
Roland McGrath576b7842007-11-04 00:00:00 +00001477 tcp->u_arg[1] = si.si_mask;
Wichert Akkermanf90da011999-10-31 21:15:38 +00001478 } else {
Roland McGrath576b7842007-11-04 00:00:00 +00001479 sigset_t sigm;
1480 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkermanf90da011999-10-31 21:15:38 +00001481 tcp->u_rval = tcp->u_error = 0;
1482 if(tcp->u_arg[0] == 0)
Roland McGrath576b7842007-11-04 00:00:00 +00001483 return 0;
1484 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkermanf90da011999-10-31 21:15:38 +00001485 return RVAL_NONE | RVAL_STR;
1486 }
1487 return 0;
Wichert Akkermanc1652e22001-03-27 12:17:16 +00001488#else
Michal Ludvig0e035502002-09-23 15:41:01 +00001489#warning No sys_sigreturn() for this architecture
1490#warning (no problem, just a reminder :-)
Wichert Akkermanc1652e22001-03-27 12:17:16 +00001491 return 0;
Wichert Akkermanf90da011999-10-31 21:15:38 +00001492#endif /* MIPS */
Roland McGrath542c2c62008-05-20 01:11:56 +00001493#endif /* LINUX_MIPSN32 || LINUX_MIPSN64 */
Roland McGrath6d1a65c2004-07-12 07:44:08 +00001494#endif /* SPARC || SPARC64 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001495#endif /* ALPHA */
1496#endif /* !M68K */
1497#endif /* !POWERPC */
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001498#endif /* !IA64 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001499#endif /* !I386 */
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001500#endif /* S390 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001501}
1502
1503int
1504sys_siggetmask(tcp)
1505struct tcb *tcp;
1506{
1507 if (exiting(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001508 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +00001509 long_to_sigset(tcp->u_rval, &sigm);
1510 tcp->auxstr = sprintsigmask("mask ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001511 }
1512 return RVAL_HEX | RVAL_STR;
1513}
1514
1515int
1516sys_sigsuspend(tcp)
1517struct tcb *tcp;
1518{
1519 if (entering(tcp)) {
1520 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +00001521 long_to_sigset(tcp->u_arg[2], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001522#if 0
1523 /* first two are not really arguments, but print them anyway */
1524 /* nevermind, they are an anachronism now, too bad... */
1525 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
1526#endif
Nate Sammons4a121431999-04-06 01:19:39 +00001527 printsigmask(&sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001528 }
1529 return 0;
1530}
1531
1532#endif /* LINUX */
1533
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001534#if defined(SVR4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001535
1536int
1537sys_sigsuspend(tcp)
1538struct tcb *tcp;
1539{
1540 sigset_t sigset;
1541
1542 if (entering(tcp)) {
1543 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
1544 tprintf("[?]");
1545 else
Wichert Akkerman46956571999-11-26 10:12:59 +00001546 printsigmask(&sigset, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001547 }
1548 return 0;
1549}
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001550#ifndef FREEBSD
Roland McGrathd9f816f2004-09-04 03:39:20 +00001551static const struct xlat ucontext_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001552 { UC_SIGMASK, "UC_SIGMASK" },
1553 { UC_STACK, "UC_STACK" },
1554 { UC_CPU, "UC_CPU" },
1555#ifdef UC_FPU
1556 { UC_FPU, "UC_FPU" },
1557#endif
1558#ifdef UC_INTR
1559 { UC_INTR, "UC_INTR" },
1560#endif
1561 { 0, NULL },
1562};
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001563#endif /* !FREEBSD */
1564#endif /* SVR4 || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001565
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001566#if defined SVR4 || defined LINUX || defined FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001567#if defined LINUX && !defined SS_ONSTACK
1568#define SS_ONSTACK 1
1569#define SS_DISABLE 2
1570#if __GLIBC_MINOR__ == 0
1571typedef struct
1572{
1573 __ptr_t ss_sp;
1574 int ss_flags;
1575 size_t ss_size;
1576} stack_t;
1577#endif
1578#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001579#ifdef FREEBSD
1580#define stack_t struct sigaltstack
1581#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001582
Roland McGrathd9f816f2004-09-04 03:39:20 +00001583static const struct xlat sigaltstack_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001584 { SS_ONSTACK, "SS_ONSTACK" },
1585 { SS_DISABLE, "SS_DISABLE" },
1586 { 0, NULL },
1587};
1588#endif
1589
1590#ifdef SVR4
1591static void
1592printcontext(tcp, ucp)
1593struct tcb *tcp;
1594ucontext_t *ucp;
1595{
1596 tprintf("{");
1597 if (!abbrev(tcp)) {
1598 tprintf("uc_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +00001599 printflags(ucontext_flags, ucp->uc_flags, "UC_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001600 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
1601 }
1602 tprintf("uc_sigmask=");
John Hughes70c5e7a2001-05-15 15:09:14 +00001603 printsigmask(&ucp->uc_sigmask, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001604 if (!abbrev(tcp)) {
1605 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
1606 (unsigned long) ucp->uc_stack.ss_sp,
1607 ucp->uc_stack.ss_size);
Roland McGrathb2dee132005-06-01 19:02:36 +00001608 printflags(sigaltstack_flags, ucp->uc_stack.ss_flags, "SS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001609 tprintf("}");
1610 }
1611 tprintf(", ...}");
1612}
1613
1614int
1615sys_getcontext(tcp)
1616struct tcb *tcp;
1617{
1618 ucontext_t uc;
1619
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001620 if (exiting(tcp)) {
1621 if (tcp->u_error)
1622 tprintf("%#lx", tcp->u_arg[0]);
1623 else if (!tcp->u_arg[0])
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001624 tprintf("NULL");
1625 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1626 tprintf("{...}");
1627 else
1628 printcontext(tcp, &uc);
1629 }
1630 return 0;
1631}
1632
1633int
1634sys_setcontext(tcp)
1635struct tcb *tcp;
1636{
1637 ucontext_t uc;
1638
1639 if (entering(tcp)) {
1640 if (!tcp->u_arg[0])
1641 tprintf("NULL");
1642 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1643 tprintf("{...}");
1644 else
1645 printcontext(tcp, &uc);
1646 }
1647 else {
1648 tcp->u_rval = tcp->u_error = 0;
1649 if (tcp->u_arg[0] == 0)
1650 return 0;
1651 return RVAL_NONE;
1652 }
1653 return 0;
1654}
1655
1656#endif /* SVR4 */
1657
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001658#if defined(LINUX) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001659
1660static int
1661print_stack_t(tcp, addr)
1662struct tcb *tcp;
1663unsigned long addr;
1664{
1665 stack_t ss;
1666 if (umove(tcp, addr, &ss) < 0)
1667 return -1;
1668 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
Roland McGrathb2dee132005-06-01 19:02:36 +00001669 printflags(sigaltstack_flags, ss.ss_flags, "SS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001670 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
1671 return 0;
1672}
1673
1674int
1675sys_sigaltstack(tcp)
1676 struct tcb *tcp;
1677{
1678 if (entering(tcp)) {
1679 if (tcp->u_arg[0] == 0)
1680 tprintf("NULL");
1681 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
1682 return -1;
1683 }
1684 else {
1685 tprintf(", ");
1686 if (tcp->u_arg[1] == 0)
1687 tprintf("NULL");
1688 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
1689 return -1;
1690 }
1691 return 0;
1692}
1693#endif
1694
1695#ifdef HAVE_SIGACTION
1696
1697int
1698sys_sigprocmask(tcp)
1699struct tcb *tcp;
1700{
1701#ifdef ALPHA
1702 if (entering(tcp)) {
1703 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1704 tprintf(", ");
Nate Sammons4a121431999-04-06 01:19:39 +00001705 printsigmask(tcp->u_arg[1], 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001706 }
1707 else if (!syserror(tcp)) {
Nate Sammons4a121431999-04-06 01:19:39 +00001708 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001709 return RVAL_HEX | RVAL_STR;
1710 }
1711#else /* !ALPHA */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001712 if (entering(tcp)) {
1713#ifdef SVR4
1714 if (tcp->u_arg[0] == 0)
1715 tprintf("0");
1716 else
1717#endif /* SVR4 */
1718 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1719 tprintf(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001720 print_sigset(tcp, tcp->u_arg[1], 0);
1721 tprintf(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001722 }
1723 else {
1724 if (!tcp->u_arg[2])
1725 tprintf("NULL");
1726 else if (syserror(tcp))
1727 tprintf("%#lx", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001728 else
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001729 print_sigset(tcp, tcp->u_arg[2], 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001730 }
1731#endif /* !ALPHA */
1732 return 0;
1733}
1734
1735#endif /* HAVE_SIGACTION */
1736
1737int
1738sys_kill(tcp)
1739struct tcb *tcp;
1740{
1741 if (entering(tcp)) {
Roland McGrath4d7ed022008-05-20 01:43:09 +00001742 /*
1743 * Sign-extend a 32-bit value when that's what it is.
1744 */
1745 long pid = tcp->u_arg[0];
1746 if (personality_wordsize[current_personality] < sizeof pid)
1747 pid = (long) (int) pid;
1748 tprintf("%ld, %s", pid, signame(tcp->u_arg[1]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001749 }
1750 return 0;
1751}
1752
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +00001753#if defined(FREEBSD) || defined(SUNOS4)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001754int
1755sys_killpg(tcp)
1756struct tcb *tcp;
1757{
1758 return sys_kill(tcp);
1759}
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +00001760#endif /* FREEBSD || SUNOS4 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001761
Roland McGrath8ffc3522003-07-09 09:47:49 +00001762#ifdef LINUX
1763int
1764sys_tgkill(tcp)
1765 struct tcb *tcp;
1766{
1767 if (entering(tcp)) {
1768 tprintf("%ld, %ld, %s",
1769 tcp->u_arg[0], tcp->u_arg[1], signame(tcp->u_arg[2]));
1770 }
1771 return 0;
1772}
1773#endif
1774
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001775int
1776sys_sigpending(tcp)
1777struct tcb *tcp;
1778{
1779 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001780
1781 if (exiting(tcp)) {
1782 if (syserror(tcp))
1783 tprintf("%#lx", tcp->u_arg[0]);
Nate Sammons4a121431999-04-06 01:19:39 +00001784 else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001785 tprintf("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001786 else
Wichert Akkerman46956571999-11-26 10:12:59 +00001787 printsigmask(&sigset, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001788 }
1789 return 0;
1790}
1791
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +00001792#ifdef SVR4
John Hughes42162082001-10-18 14:48:26 +00001793int sys_sigwait(tcp)
1794struct tcb *tcp;
1795{
1796 sigset_t sigset;
1797
1798 if (entering(tcp)) {
1799 if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1800 tprintf("[?]");
1801 else
1802 printsigmask(&sigset, 0);
1803 }
1804 else {
1805 if (!syserror(tcp)) {
1806 tcp->auxstr = signalent[tcp->u_rval];
1807 return RVAL_DECIMAL | RVAL_STR;
1808 }
1809 }
1810 return 0;
1811}
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +00001812#endif /* SVR4 */
John Hughes42162082001-10-18 14:48:26 +00001813
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001814#ifdef LINUX
1815
1816 int
1817sys_rt_sigprocmask(tcp)
1818 struct tcb *tcp;
1819{
1820 sigset_t sigset;
1821
Nate Sammons4a121431999-04-06 01:19:39 +00001822 /* Note: arg[3] is the length of the sigset. */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001823 if (entering(tcp)) {
1824 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1825 tprintf(", ");
1826 if (!tcp->u_arg[1])
1827 tprintf("NULL, ");
Nate Sammons4a121431999-04-06 01:19:39 +00001828 else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001829 tprintf("%#lx, ", tcp->u_arg[1]);
1830 else {
Nate Sammons4a121431999-04-06 01:19:39 +00001831 printsigmask(&sigset, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001832 tprintf(", ");
1833 }
1834 }
1835 else {
1836 if (!tcp->u_arg[2])
1837
1838 tprintf("NULL");
1839 else if (syserror(tcp))
1840 tprintf("%#lx", tcp->u_arg[2]);
Nate Sammons4a121431999-04-06 01:19:39 +00001841 else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001842 tprintf("[?]");
1843 else
Nate Sammons4a121431999-04-06 01:19:39 +00001844 printsigmask(&sigset, 1);
Nate Sammonsdab325a1999-03-29 23:33:35 +00001845 tprintf(", %lu", tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001846 }
1847 return 0;
1848}
1849
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001850
1851/* Structure describing the action to be taken when a signal arrives. */
1852struct new_sigaction
1853{
1854 union
1855 {
1856 __sighandler_t __sa_handler;
1857 void (*__sa_sigaction) (int, siginfo_t *, void *);
1858 }
1859 __sigaction_handler;
1860 unsigned long sa_flags;
1861 void (*sa_restorer) (void);
1862 unsigned long int sa_mask[2];
1863};
1864
1865
Roland McGrath5f206812008-08-20 01:59:40 +00001866int
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001867sys_rt_sigaction(tcp)
1868 struct tcb *tcp;
1869{
1870 struct new_sigaction sa;
1871 sigset_t sigset;
1872 long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001873
1874 if (entering(tcp)) {
1875 printsignal(tcp->u_arg[0]);
1876 tprintf(", ");
1877 addr = tcp->u_arg[1];
1878 } else
1879 addr = tcp->u_arg[2];
1880 if (addr == 0)
1881 tprintf("NULL");
1882 else if (!verbose(tcp))
1883 tprintf("%#lx", addr);
1884 else if (umove(tcp, addr, &sa) < 0)
1885 tprintf("{...}");
1886 else {
Roland McGrath5f206812008-08-20 01:59:40 +00001887 if (sa.__sigaction_handler.__sa_handler == SIG_ERR)
1888 tprintf("{SIG_ERR, ");
1889 else if (sa.__sigaction_handler.__sa_handler == SIG_DFL)
1890 tprintf("{SIG_DFL, ");
Denys Vlasenko73ce40e2008-12-17 17:22:03 +00001891 else if (sa.__sigaction_handler.__sa_handler == SIG_IGN)
Roland McGrath5f206812008-08-20 01:59:40 +00001892 tprintf("{SIG_IGN, ");
1893 else
1894 tprintf("{%#lx, ",
1895 (long) sa.__sigaction_handler.__sa_handler);
1896 sigemptyset(&sigset);
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001897#ifdef LINUXSPARC
Roland McGrath5f206812008-08-20 01:59:40 +00001898 if (tcp->u_arg[4] <= sizeof(sigset))
1899 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001900#else
Roland McGrath5f206812008-08-20 01:59:40 +00001901 if (tcp->u_arg[3] <= sizeof(sigset))
1902 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001903#endif
Roland McGrath5f206812008-08-20 01:59:40 +00001904 else
1905 memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
1906 printsigmask(&sigset, 1);
1907 tprintf(", ");
1908 printflags(sigact_flags, sa.sa_flags, "SA_???");
Roland McGrath2638cb42002-12-15 23:58:41 +00001909#ifdef SA_RESTORER
Roland McGrath5f206812008-08-20 01:59:40 +00001910 if (sa.sa_flags & SA_RESTORER)
1911 tprintf(", %p", sa.sa_restorer);
Roland McGrath2638cb42002-12-15 23:58:41 +00001912#endif
Roland McGrath5f206812008-08-20 01:59:40 +00001913 tprintf("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001914 }
1915 if (entering(tcp))
1916 tprintf(", ");
1917 else
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001918#ifdef LINUXSPARC
1919 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
1920#elif defined(ALPHA)
1921 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
1922#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001923 tprintf(", %lu", addr = tcp->u_arg[3]);
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001924#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001925 return 0;
1926}
1927
1928 int
1929sys_rt_sigpending(tcp)
1930 struct tcb *tcp;
1931{
1932 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001933
1934 if (exiting(tcp)) {
1935 if (syserror(tcp))
1936 tprintf("%#lx", tcp->u_arg[0]);
Nate Sammons4a121431999-04-06 01:19:39 +00001937 else if (copy_sigset_len(tcp, tcp->u_arg[0],
1938 &sigset, tcp->u_arg[1]) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001939 tprintf("[?]");
1940 else
Wichert Akkerman46956571999-11-26 10:12:59 +00001941 printsigmask(&sigset, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001942 }
1943 return 0;
1944}
1945 int
1946sys_rt_sigsuspend(tcp)
1947 struct tcb *tcp;
1948{
1949 if (entering(tcp)) {
1950 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +00001951 if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0)
1952 tprintf("[?]");
1953 else
1954 printsigmask(&sigm, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001955 }
1956 return 0;
1957}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001958 int
1959sys_rt_sigqueueinfo(tcp)
1960 struct tcb *tcp;
1961{
1962 if (entering(tcp)) {
1963 siginfo_t si;
1964 tprintf("%lu, ", tcp->u_arg[0]);
1965 printsignal(tcp->u_arg[1]);
1966 tprintf(", ");
1967 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1968 tprintf("%#lx", tcp->u_arg[2]);
1969 else
John Hughes58265892001-10-18 15:13:53 +00001970 printsiginfo(&si, verbose (tcp));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001971 }
1972 return 0;
1973}
1974
1975int sys_rt_sigtimedwait(tcp)
1976 struct tcb *tcp;
1977{
1978 if (entering(tcp)) {
1979 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001980
Roland McGratha39c5a12002-12-17 05:10:37 +00001981 if (copy_sigset_len(tcp, tcp->u_arg[0],
Nate Sammons4a121431999-04-06 01:19:39 +00001982 &sigset, tcp->u_arg[3]) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001983 tprintf("[?]");
1984 else
Wichert Akkerman46956571999-11-26 10:12:59 +00001985 printsigmask(&sigset, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001986 tprintf(", ");
1987 }
1988 else {
1989 if (syserror(tcp))
1990 tprintf("%#lx", tcp->u_arg[0]);
1991 else {
1992 siginfo_t si;
1993 if (umove(tcp, tcp->u_arg[1], &si) < 0)
1994 tprintf("%#lx", tcp->u_arg[1]);
1995 else
John Hughes58265892001-10-18 15:13:53 +00001996 printsiginfo(&si, verbose (tcp));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001997 /* XXX For now */
1998 tprintf(", %#lx", tcp->u_arg[2]);
1999 tprintf(", %d", (int) tcp->u_arg[3]);
2000 }
2001 }
2002 return 0;
2003};
2004
Roland McGrath79dcd7a2006-01-12 22:34:50 +00002005int
2006sys_restart_syscall(tcp)
2007struct tcb *tcp;
2008{
2009 if (entering(tcp))
2010 tprintf("<... resuming interrupted call ...>");
2011 return 0;
2012}
2013
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002014extern const struct xlat open_mode_flags[];
2015
2016static int
2017do_signalfd(struct tcb *tcp, int flags_arg)
Roland McGrathf46ccd32007-08-02 01:15:59 +00002018{
2019 if (entering(tcp)) {
2020 tprintf("%ld, ", tcp->u_arg[0]);
2021 print_sigset(tcp, tcp->u_arg[1], 1);
2022 tprintf("%lu", tcp->u_arg[2]);
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002023 if (flags_arg >= 0) {
2024 tprintf(", ");
2025 printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
2026 }
Roland McGrathf46ccd32007-08-02 01:15:59 +00002027 }
2028 return 0;
2029}
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002030
2031int
2032sys_signalfd(struct tcb *tcp)
2033{
2034 return do_signalfd(tcp, -1);
2035}
2036
2037int
2038sys_signalfd4(struct tcb *tcp)
2039{
2040 return do_signalfd(tcp, 3);
2041}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002042#endif /* LINUX */