blob: df6470422a18604abd846e7a60ed5243eca7da36 [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
56#include <linux/ptrace.h>
Wichert Akkerman15dea971999-10-06 13:06:34 +000057#endif
Wichert Akkerman36915a11999-07-13 15:45:02 +000058
Wichert Akkermanfaf72222000-02-19 23:59:03 +000059
Wichert Akkerman36915a11999-07-13 15:45:02 +000060#ifdef LINUX
61
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +000062#ifdef IA64
63# include <asm/ptrace_offsets.h>
64#endif /* !IA64 */
65
Wichert Akkerman00a82ee2001-03-28 20:29:17 +000066#if HAVE_ASM_REG_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000067#ifdef SPARC
Wichert Akkerman00a82ee2001-03-28 20:29:17 +000068# define fpq kernel_fpq
69# define fq kernel_fq
70# define fpu kernel_fpu
71#endif
Wichert Akkerman9ce1a631999-08-29 23:15:07 +000072#include <asm/reg.h>
Wichert Akkerman00a82ee2001-03-28 20:29:17 +000073#ifdef SPARC
74# undef fpq
75# undef fq
76# undef fpu
77#endif
78
79#endif /* HAVE_ASM_REG_H */
80#ifdef HAVE_ASM_SIGCONTEXT_H
81#ifdef SPARC
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000082typedef struct {
Wichert Akkerman9ce1a631999-08-29 23:15:07 +000083 struct regs si_regs;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000084 int si_mask;
85} m_siginfo_t;
Wichert Akkerman67e3e632001-08-19 11:43:17 +000086#elif !defined(IA64)
Wichert Akkerman00a82ee2001-03-28 20:29:17 +000087#include <asm/sigcontext.h>
88#endif /* SPARC */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000089#else /* !HAVE_ASM_SIGCONTEXT_H */
90#ifdef I386
91struct sigcontext_struct {
92 unsigned short gs, __gsh;
93 unsigned short fs, __fsh;
94 unsigned short es, __esh;
95 unsigned short ds, __dsh;
96 unsigned long edi;
97 unsigned long esi;
98 unsigned long ebp;
99 unsigned long esp;
100 unsigned long ebx;
101 unsigned long edx;
102 unsigned long ecx;
103 unsigned long eax;
104 unsigned long trapno;
105 unsigned long err;
106 unsigned long eip;
107 unsigned short cs, __csh;
108 unsigned long eflags;
109 unsigned long esp_at_signal;
110 unsigned short ss, __ssh;
111 unsigned long i387;
112 unsigned long oldmask;
113 unsigned long cr2;
114};
115#else /* !I386 */
116#ifdef M68K
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000117struct sigcontext
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000118{
119 unsigned long sc_mask;
120 unsigned long sc_usp;
121 unsigned long sc_d0;
122 unsigned long sc_d1;
123 unsigned long sc_a0;
124 unsigned long sc_a1;
125 unsigned short sc_sr;
126 unsigned long sc_pc;
127 unsigned short sc_formatvec;
128};
129#endif /* M68K */
130#endif /* !I386 */
131#endif /* !HAVE_ASM_SIGCONTEXT_H */
132#ifndef NSIG
133#define NSIG 32
134#endif
135#ifdef ARM
136#undef NSIG
137#define NSIG 32
138#endif
139#endif /* LINUX */
140
141char *signalent0[] = {
142#include "signalent.h"
143};
144int nsignals0 = sizeof signalent0 / sizeof signalent0[0];
145
146#if SUPPORTED_PERSONALITIES >= 2
147char *signalent1[] = {
148#include "signalent1.h"
149};
150int nsignals1 = sizeof signalent1 / sizeof signalent1[0];
151#endif /* SUPPORTED_PERSONALITIES >= 2 */
152
153#if SUPPORTED_PERSONALITIES >= 3
154char *signalent2[] = {
155#include "signalent2.h"
156};
157int nsignals2 = sizeof signalent2 / sizeof signalent2[0];
158#endif /* SUPPORTED_PERSONALITIES >= 3 */
159
160char **signalent;
161int nsignals;
162
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000163#if defined(SUNOS4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000164
165static struct xlat sigvec_flags[] = {
166 { SV_ONSTACK, "SV_ONSTACK" },
167 { SV_INTERRUPT, "SV_INTERRUPT" },
168 { SV_RESETHAND, "SV_RESETHAND" },
169 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
170 { 0, NULL },
171};
172
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000173#endif /* SUNOS4 || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000174
175#ifdef HAVE_SIGACTION
176
177static struct xlat sigact_flags[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000178#ifdef SA_RESTORER
179 { SA_RESTORER, "SA_RESTORER" },
180#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000181#ifdef SA_STACK
182 { SA_STACK, "SA_STACK" },
183#endif
184#ifdef SA_RESTART
185 { SA_RESTART, "SA_RESTART" },
186#endif
187#ifdef SA_INTERRUPT
188 { SA_INTERRUPT, "SA_INTERRUPT" },
189#endif
190#ifdef SA_NOMASK
191 { SA_NOMASK, "SA_NOMASK" },
192#endif
193#ifdef SA_ONESHOT
194 { SA_ONESHOT, "SA_ONESHOT" },
195#endif
196#ifdef SA_SIGINFO
197 { SA_SIGINFO, "SA_SIGINFO" },
198#endif
199#ifdef SA_RESETHAND
200 { SA_RESETHAND, "SA_RESETHAND" },
201#endif
202#ifdef SA_ONSTACK
203 { SA_ONSTACK, "SA_ONSTACK" },
204#endif
205#ifdef SA_NODEFER
206 { SA_NODEFER, "SA_NODEFER" },
207#endif
208#ifdef SA_NOCLDSTOP
209 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
210#endif
211#ifdef SA_NOCLDWAIT
212 { SA_NOCLDWAIT, "SA_NOCLDWAIT" },
213#endif
214#ifdef _SA_BSDCALL
215 { _SA_BSDCALL, "_SA_BSDCALL" },
216#endif
217 { 0, NULL },
218};
219
220static struct xlat sigprocmaskcmds[] = {
221 { SIG_BLOCK, "SIG_BLOCK" },
222 { SIG_UNBLOCK, "SIG_UNBLOCK" },
223 { SIG_SETMASK, "SIG_SETMASK" },
224#ifdef SIG_SETMASK32
225 { SIG_SETMASK32,"SIG_SETMASK32" },
226#endif
227 { 0, NULL },
228};
229
230#endif /* HAVE_SIGACTION */
231
Nate Sammonsce780fc1999-03-29 23:23:13 +0000232/* Anonymous realtime signals. */
233/* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
234 constant. This is what we want. Otherwise, just use SIGRTMIN. */
235#ifdef SIGRTMIN
236#ifndef __SIGRTMIN
237#define __SIGRTMIN SIGRTMIN
238#define __SIGRTMAX SIGRTMAX /* likewise */
239#endif
240#endif
241
242char *
243signame(sig)
244int sig;
245{
246 static char buf[30];
247 if (sig < nsignals) {
248 return signalent[sig];
249#ifdef SIGRTMIN
Nate Sammons3080aa41999-03-30 00:16:41 +0000250 } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000251 sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN));
Nate Sammonsce780fc1999-03-29 23:23:13 +0000252 return buf;
253#endif /* SIGRTMIN */
254 } else {
255 sprintf(buf, "%d", sig);
256 return buf;
257 }
258}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000259
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000260#ifndef UNIXWARE
Nate Sammons4a121431999-04-06 01:19:39 +0000261static void
262long_to_sigset(l, s)
263long l;
264sigset_t *s;
265{
266 sigemptyset(s);
267 *(long *)s = l;
268}
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000269#endif
Nate Sammons4a121431999-04-06 01:19:39 +0000270
271static int
272copy_sigset_len(tcp, addr, s, len)
273struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000274long addr;
Nate Sammons4a121431999-04-06 01:19:39 +0000275sigset_t *s;
276int len;
277{
278 if (len > sizeof(*s))
279 len = sizeof(*s);
280 sigemptyset(s);
281 if (umoven(tcp, addr, len, (char *)s) < 0)
282 return -1;
283 return 0;
284}
285
286#ifdef LINUX
287/* Original sigset is unsigned long */
288#define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long))
289#else
290#define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t))
291#endif
292
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000293static char *
Nate Sammons4a121431999-04-06 01:19:39 +0000294sprintsigmask(s, mask, rt)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000295char *s;
296sigset_t *mask;
Nate Sammons4a121431999-04-06 01:19:39 +0000297int rt; /* set might include realtime sigs */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000298{
299 int i, nsigs;
Nate Sammons4a121431999-04-06 01:19:39 +0000300 int maxsigs;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000301 char *format;
302 static char outstr[256];
303
304 strcpy(outstr, s);
305 s = outstr + strlen(outstr);
306 nsigs = 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000307 maxsigs = nsignals;
308#ifdef __SIGRTMAX
309 if (rt)
310 maxsigs = __SIGRTMAX; /* instead */
311#endif
312 for (i = 1; i < maxsigs; i++) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000313 if (sigismember(mask, i) == 1)
314 nsigs++;
315 }
316 if (nsigs >= nsignals * 2 / 3) {
317 *s++ = '~';
Nate Sammons4a121431999-04-06 01:19:39 +0000318 for (i = 1; i < maxsigs; i++) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000319 switch (sigismember(mask, i)) {
320 case 1:
321 sigdelset(mask, i);
322 break;
323 case 0:
324 sigaddset(mask, i);
325 break;
326 }
327 }
328 }
329 format = "%s";
330 *s++ = '[';
Nate Sammons4a121431999-04-06 01:19:39 +0000331 for (i = 1; i < maxsigs; i++) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000332 if (sigismember(mask, i) == 1) {
John Hughesbdf48f52001-03-06 15:08:09 +0000333 /* real-time signals on solaris don't have
334 * signalent entries
335 */
336 if (i < nsignals) {
337 sprintf(s, format, signalent[i] + 3);
338 }
339 else {
340 char tsig[32];
341 sprintf(tsig, "%u", i);
342 sprintf(s, format, tsig);
343 }
344 s += strlen(s);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000345 format = " %s";
346 }
347 }
348 *s++ = ']';
349 *s = '\0';
350 return outstr;
351}
352
353static void
Nate Sammons4a121431999-04-06 01:19:39 +0000354printsigmask(mask, rt)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000355sigset_t *mask;
Nate Sammons4a121431999-04-06 01:19:39 +0000356int rt;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000357{
Nate Sammons4a121431999-04-06 01:19:39 +0000358 tprintf("%s", sprintsigmask("", mask, rt));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000359}
360
361void
362printsignal(nr)
363int nr;
364{
Nate Sammonsce780fc1999-03-29 23:23:13 +0000365 tprintf(signame(nr));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000366}
367
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000368#ifdef LINUX
369
370static void
371parse_sigset_t (const char *str, sigset_t *set)
372{
373 unsigned int digit;
374 int i;
375
376 sigemptyset(set);
377
378 for (i = _NSIG - 4; i >= 0; i -= 4, ++str) {
379 if (*str >= 'a')
380 digit = (*str - 'a') + 10;
381 else
382 digit = *str - '0';
383 if (digit & 1)
384 sigaddset(set, i + 1);
385 if (digit & 2)
386 sigaddset(set, i + 2);
387 if (digit & 4)
388 sigaddset(set, i + 3);
389 if (digit & 8)
390 sigaddset(set, i + 4);
391 }
392}
393
394#endif
395
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000396/*
397 * Check process TCP for the disposition of signal SIG.
398 * Return 1 if the process would somehow manage to survive signal SIG,
399 * else return 0. This routine will never be called with SIGKILL.
400 */
401int
402sigishandled(tcp, sig)
403struct tcb *tcp;
404int sig;
405{
406#ifdef LINUX
407 int sfd;
408 char sname[32];
Wichert Akkermand5c2dae2001-04-12 09:10:24 +0000409 char buf[2048];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000410 char *s;
411 int i;
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000412 sigset_t ignored, caught;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000413#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000414#ifdef SVR4
415 /*
416 * Since procfs doesn't interfere with wait I think it is safe
417 * to punt on this question. If not, the information is there.
418 */
419 return 1;
420#else /* !SVR4 */
421 switch (sig) {
422 case SIGCONT:
423 case SIGSTOP:
424 case SIGTSTP:
425 case SIGTTIN:
426 case SIGTTOU:
427 case SIGCHLD:
428 case SIGIO:
429#if defined(SIGURG) && SIGURG != SIGIO
430 case SIGURG:
431#endif
432 case SIGWINCH:
433 /* Gloria Gaynor says ... */
434 return 1;
435 default:
436 break;
437 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000438#endif /* !SVR4 */
Wichert Akkermand5c2dae2001-04-12 09:10:24 +0000439#ifdef LINUX
440
441 /* This is incredibly costly but it's worth it. */
442 /* NOTE: LinuxThreads internally uses SIGRTMIN, SIGRTMIN + 1 and
443 SIGRTMIN + 2, so we can't use the obsolete /proc/%d/stat which
444 doesn't handle real-time signals). */
445 sprintf(sname, "/proc/%d/status", tcp->pid);
446 if ((sfd = open(sname, O_RDONLY)) == -1) {
447 perror(sname);
448 return 1;
449 }
450 i = read(sfd, buf, sizeof(buf));
451 buf[i] = '\0';
452 close(sfd);
453 /*
454 * Skip the extraneous fields. We need to skip
455 * command name has any spaces in it. So be it.
456 */
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000457 s = strstr(buf, "SigIgn:\t");
Wichert Akkermand5c2dae2001-04-12 09:10:24 +0000458 if (!s)
459 {
460 fprintf(stderr, "/proc/pid/status format error\n");
461 return 1;
462 }
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000463 parse_sigset_t(s + 8, &ignored);
Wichert Akkermand5c2dae2001-04-12 09:10:24 +0000464
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000465 s = strstr(buf, "SigCgt:\t");
466 if (!s)
467 {
468 fprintf(stderr, "/proc/pid/status format error\n");
469 return 1;
470 }
471 parse_sigset_t(s + 8, &caught);
Wichert Akkermand5c2dae2001-04-12 09:10:24 +0000472
473#ifdef DEBUG
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000474 fprintf(stderr, "sigs: %016qx %016qx (sig=%d)\n",
475 *(long long *) &ignored, *(long long *) &caught, sig);
Wichert Akkermand5c2dae2001-04-12 09:10:24 +0000476#endif
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000477 if (sigismember(&ignored, sig) || sigismember(&caught, sig))
Wichert Akkermand5c2dae2001-04-12 09:10:24 +0000478 return 1;
479#endif /* LINUX */
480
481#ifdef SUNOS4
482 void (*u_signal)();
483
484 if (upeek(tcp->pid, uoff(u_signal[0]) + sig*sizeof(u_signal),
485 (long *) &u_signal) < 0) {
486 return 0;
487 }
488 if (u_signal != SIG_DFL)
489 return 1;
490#endif /* SUNOS4 */
491
492 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000493}
494
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000495#if defined(SUNOS4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000496
497int
498sys_sigvec(tcp)
499struct tcb *tcp;
500{
501 struct sigvec sv;
502 long addr;
503
504 if (entering(tcp)) {
505 printsignal(tcp->u_arg[0]);
506 tprintf(", ");
507 addr = tcp->u_arg[1];
508 } else {
509 addr = tcp->u_arg[2];
510 }
511 if (addr == 0)
512 tprintf("NULL");
513 else if (!verbose(tcp))
514 tprintf("%#lx", addr);
515 else if (umove(tcp, addr, &sv) < 0)
516 tprintf("{...}");
517 else {
518 switch ((int) sv.sv_handler) {
519 case (int) SIG_ERR:
520 tprintf("{SIG_ERR}");
521 break;
522 case (int) SIG_DFL:
523 tprintf("{SIG_DFL}");
524 break;
525 case (int) SIG_IGN:
526 if (tcp->u_arg[0] == SIGTRAP) {
527 tcp->flags |= TCB_SIGTRAPPED;
528 kill(tcp->pid, SIGSTOP);
529 }
530 tprintf("{SIG_IGN}");
531 break;
532 case (int) SIG_HOLD:
533 if (tcp->u_arg[0] == SIGTRAP) {
534 tcp->flags |= TCB_SIGTRAPPED;
535 kill(tcp->pid, SIGSTOP);
536 }
537 tprintf("SIG_HOLD");
538 break;
539 default:
540 if (tcp->u_arg[0] == SIGTRAP) {
541 tcp->flags |= TCB_SIGTRAPPED;
542 kill(tcp->pid, SIGSTOP);
543 }
544 tprintf("{%#lx, ", (unsigned long) sv.sv_handler);
Nate Sammons4a121431999-04-06 01:19:39 +0000545 printsigmask(&sv.sv_mask, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000546 tprintf(", ");
547 if (!printflags(sigvec_flags, sv.sv_flags))
548 tprintf("0");
549 tprintf("}");
550 }
551 }
552 if (entering(tcp))
553 tprintf(", ");
554 return 0;
555}
556
557int
558sys_sigpause(tcp)
559struct tcb *tcp;
560{
561 if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */
Nate Sammons4a121431999-04-06 01:19:39 +0000562 sigset_t sigm;
563 long_to_sigset(tcp->u_arg[0], &sigm);
564 printsigmask(&sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000565 }
566 return 0;
567}
568
569int
570sys_sigstack(tcp)
571struct tcb *tcp;
572{
573 struct sigstack ss;
574 long addr;
575
576 if (entering(tcp))
577 addr = tcp->u_arg[0];
578 else
579 addr = tcp->u_arg[1];
580 if (addr == 0)
581 tprintf("NULL");
582 else if (umove(tcp, addr, &ss) < 0)
583 tprintf("%#lx", addr);
584 else {
585 tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp);
586 tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO");
587 }
588 if (entering(tcp))
589 tprintf(", ");
590 return 0;
591}
592
593int
594sys_sigcleanup(tcp)
595struct tcb *tcp;
596{
597 return 0;
598}
599
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000600#endif /* SUNOS4 || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000601
602#ifndef SVR4
603
604int
605sys_sigsetmask(tcp)
606struct tcb *tcp;
607{
608 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000609 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000610 long_to_sigset(tcp->u_arg[0], &sigm);
611 printsigmask(&sigm, 0);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000612#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000613 if ((tcp->u_arg[0] & sigmask(SIGTRAP))) {
614 /* Mark attempt to block SIGTRAP */
615 tcp->flags |= TCB_SIGTRAPPED;
616 /* Send unblockable signal */
617 kill(tcp->pid, SIGSTOP);
618 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000619#endif /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000620 }
621 else if (!syserror(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000622 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000623 long_to_sigset(tcp->u_rval, &sigm);
624 tcp->auxstr = sprintsigmask("old mask ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000625
626 return RVAL_HEX | RVAL_STR;
627 }
628 return 0;
629}
630
631int
632sys_sigblock(tcp)
633struct tcb *tcp;
634{
635 return sys_sigsetmask(tcp);
636}
637
638#endif /* !SVR4 */
639
640#ifdef HAVE_SIGACTION
641
642#ifdef LINUX
643struct old_sigaction {
644 __sighandler_t __sa_handler;
645 unsigned long sa_mask;
646 unsigned long sa_flags;
647 void (*sa_restorer)(void);
648};
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000649#define SA_HANDLER __sa_handler
650#endif /* LINUX */
651
652#ifndef SA_HANDLER
653#define SA_HANDLER sa_handler
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000654#endif
655
656int
657sys_sigaction(tcp)
658struct tcb *tcp;
659{
660 long addr;
Nate Sammons4a121431999-04-06 01:19:39 +0000661#ifdef LINUX
John Hughes1e4cb342001-03-06 09:25:46 +0000662 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000663 struct old_sigaction sa;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000664#else
665 struct sigaction sa;
666#endif
667
668
669 if (entering(tcp)) {
670 printsignal(tcp->u_arg[0]);
671 tprintf(", ");
672 addr = tcp->u_arg[1];
673 } else
674 addr = tcp->u_arg[2];
675 if (addr == 0)
676 tprintf("NULL");
677 else if (!verbose(tcp))
678 tprintf("%#lx", addr);
679 else if (umove(tcp, addr, &sa) < 0)
680 tprintf("{...}");
681 else {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000682 switch ((long) sa.SA_HANDLER) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000683 case (long) SIG_ERR:
684 tprintf("{SIG_ERR}");
685 break;
686 case (long) SIG_DFL:
687 tprintf("{SIG_DFL}");
688 break;
689 case (long) SIG_IGN:
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000690#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000691 if (tcp->u_arg[0] == SIGTRAP) {
692 tcp->flags |= TCB_SIGTRAPPED;
693 kill(tcp->pid, SIGSTOP);
694 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000695#endif /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000696 tprintf("{SIG_IGN}");
697 break;
698 default:
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000699#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000700 if (tcp->u_arg[0] == SIGTRAP) {
701 tcp->flags |= TCB_SIGTRAPPED;
702 kill(tcp->pid, SIGSTOP);
703 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000704#endif /* !USE_PROCFS */
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000705 tprintf("{%#lx, ", (long) sa.SA_HANDLER);
Wichert Akkerman48214be1999-11-26 09:55:42 +0000706#ifndef LINUX
707 printsigmask (&sa.sa_mask, 0);
708#else
Nate Sammons4a121431999-04-06 01:19:39 +0000709 long_to_sigset(sa.sa_mask, &sigset);
710 printsigmask(&sigset, 0);
Wichert Akkerman48214be1999-11-26 09:55:42 +0000711#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000712 tprintf(", ");
713 if (!printflags(sigact_flags, sa.sa_flags))
714 tprintf("0");
715 tprintf("}");
716 }
717 }
718 if (entering(tcp))
719 tprintf(", ");
720#ifdef LINUX
721 else
722 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
723#endif
724 return 0;
725}
726
727int
728sys_signal(tcp)
729struct tcb *tcp;
730{
731 if (entering(tcp)) {
732 printsignal(tcp->u_arg[0]);
Wichert Akkerman16a03d22000-08-10 02:14:04 +0000733 tprintf(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000734 switch (tcp->u_arg[1]) {
735 case (int) SIG_ERR:
736 tprintf("SIG_ERR");
737 break;
738 case (int) SIG_DFL:
739 tprintf("SIG_DFL");
740 break;
741 case (int) SIG_IGN:
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000742#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000743 if (tcp->u_arg[0] == SIGTRAP) {
744 tcp->flags |= TCB_SIGTRAPPED;
745 kill(tcp->pid, SIGSTOP);
746 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000747#endif /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000748 tprintf("SIG_IGN");
749 break;
750 default:
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000751#ifndef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000752 if (tcp->u_arg[0] == SIGTRAP) {
753 tcp->flags |= TCB_SIGTRAPPED;
754 kill(tcp->pid, SIGSTOP);
755 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000756#endif /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000757 tprintf("%#lx", tcp->u_arg[1]);
758 }
Wichert Akkerman16a03d22000-08-10 02:14:04 +0000759 return 0;
760 }
761 else {
762 switch (tcp->u_rval) {
763 case (int) SIG_ERR:
764 tcp->auxstr = "SIG_ERR"; break;
765 case (int) SIG_DFL:
766 tcp->auxstr = "SIG_DFL"; break;
767 case (int) SIG_IGN:
768 tcp->auxstr = "SIG_IGN"; break;
769 default:
770 tcp->auxstr = NULL;
771 }
772 return RVAL_HEX | RVAL_STR;
773 }
774}
775
776int
777sys_sighold(tcp)
778struct tcb *tcp;
779{
780 if (entering(tcp)) {
781 printsignal(tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000782 }
783 return 0;
784}
785
786#endif /* HAVE_SIGACTION */
787
788#ifdef LINUX
789
790int
791sys_sigreturn(tcp)
792struct tcb *tcp;
793{
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000794#ifdef S390
795 long usp;
796 struct sigcontext_struct sc;
797
798 if (entering(tcp)) {
799 tcp->u_arg[0] = 0;
800 if (upeek(tcp->pid,PT_GPR15,&usp)<0)
801 return 0;
802 if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0)
803 return 0;
804 tcp->u_arg[0] = 1;
805 memcpy(&tcp->u_arg[1],&sc.oldmask[0],sizeof(sigset_t));
806 } else {
807 tcp->u_rval = tcp->u_error = 0;
808 if (tcp->u_arg[0] == 0)
809 return 0;
810 tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1]);
811 return RVAL_NONE | RVAL_STR;
812 }
813 return 0;
814#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000815#ifdef I386
816 long esp;
817 struct sigcontext_struct sc;
818
819 if (entering(tcp)) {
820 tcp->u_arg[0] = 0;
821 if (upeek(tcp->pid, 4*UESP, &esp) < 0)
822 return 0;
823 if (umove(tcp, esp, &sc) < 0)
824 return 0;
825 tcp->u_arg[0] = 1;
826 tcp->u_arg[1] = sc.oldmask;
827 }
828 else {
829 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000830 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000831 tcp->u_rval = tcp->u_error = 0;
832 if (tcp->u_arg[0] == 0)
833 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000834 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000835 return RVAL_NONE | RVAL_STR;
836 }
837 return 0;
838#else /* !I386 */
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000839#ifdef IA64
840 struct sigcontext sc;
841 long sp;
842
843 if (entering(tcp)) {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000844 /* offset of sigcontext in the kernel's sigframe structure: */
845# define SIGFRAME_SC_OFFSET 0x90
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000846 tcp->u_arg[0] = 0;
847 if (upeek(tcp->pid, PT_R12, &sp) < 0)
848 return 0;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000849 if (umove(tcp, sp + 16 + SIGFRAME_SC_OFFSET, &sc) < 0)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000850 return 0;
851 tcp->u_arg[0] = 1;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000852 memcpy(tcp->u_arg + 1, &sc.sc_mask, sizeof(sc.sc_mask));
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000853 }
854 else {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000855 sigset_t sigm;
856
857 memcpy(&sigm, tcp->u_arg + 1, sizeof (sigm));
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000858 tcp->u_rval = tcp->u_error = 0;
859 if (tcp->u_arg[0] == 0)
860 return 0;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000861 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000862 return RVAL_NONE | RVAL_STR;
863 }
864 return 0;
865#else /* !IA64 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000866#ifdef POWERPC
867 long esp;
868 struct sigcontext_struct sc;
869
870 if (entering(tcp)) {
871 tcp->u_arg[0] = 0;
872 if (upeek(tcp->pid, 4*PT_R1, &esp) < 0)
873 return 0;
874 if (umove(tcp, esp, &sc) < 0)
875 return 0;
876 tcp->u_arg[0] = 1;
877 tcp->u_arg[1] = sc.oldmask;
878 }
879 else {
880 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000881 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000882 tcp->u_rval = tcp->u_error = 0;
883 if (tcp->u_arg[0] == 0)
884 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000885 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000886 return RVAL_NONE | RVAL_STR;
887 }
888 return 0;
889#else /* !POWERPC */
890#ifdef M68K
891 long usp;
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000892 struct sigcontext sc;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000893
894 if (entering(tcp)) {
895 tcp->u_arg[0] = 0;
896 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
897 return 0;
898 if (umove(tcp, usp, &sc) < 0)
899 return 0;
900 tcp->u_arg[0] = 1;
901 tcp->u_arg[1] = sc.sc_mask;
902 }
903 else {
904 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000905 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000906 tcp->u_rval = tcp->u_error = 0;
907 if (tcp->u_arg[0] == 0)
908 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000909 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000910 return RVAL_NONE | RVAL_STR;
911 }
912 return 0;
913#else /* !M68K */
914#ifdef ALPHA
915 long fp;
916 struct sigcontext_struct sc;
917
918 if (entering(tcp)) {
919 tcp->u_arg[0] = 0;
920 if (upeek(tcp->pid, REG_FP, &fp) < 0)
921 return 0;
922 if (umove(tcp, fp, &sc) < 0)
923 return 0;
924 tcp->u_arg[0] = 1;
925 tcp->u_arg[1] = sc.sc_mask;
926 }
927 else {
928 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000929 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000930 tcp->u_rval = tcp->u_error = 0;
931 if (tcp->u_arg[0] == 0)
932 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000933 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000934 return RVAL_NONE | RVAL_STR;
935 }
936 return 0;
937#else
938#ifdef SPARC
939 long i1;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000940 struct regs regs;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000941 m_siginfo_t si;
942
943 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)&regs, 0) < 0) {
944 perror("sigreturn: PTRACE_GETREGS ");
945 return 0;
946 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000947 if(entering(tcp)) {
948 tcp->u_arg[0] = 0;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000949 i1 = regs.r_o1;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000950 if(umove(tcp, i1, &si) < 0) {
951 perror("sigreturn: umove ");
952 return 0;
953 }
954 tcp->u_arg[0] = 1;
955 tcp->u_arg[1] = si.si_mask;
956 } else {
957 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +0000958 long_to_sigset(tcp->u_arg[1], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000959 tcp->u_rval = tcp->u_error = 0;
960 if(tcp->u_arg[0] == 0)
961 return 0;
Nate Sammons4a121431999-04-06 01:19:39 +0000962 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000963 return RVAL_NONE | RVAL_STR;
964 }
965 return 0;
Wichert Akkermanf90da011999-10-31 21:15:38 +0000966#else
967#ifdef MIPS
968 long sp;
969 struct sigcontext sc;
970
971 if(entering(tcp)) {
972 tcp->u_arg[0] = 0;
973 if (upeek(tcp->pid, REG_SP, &sp) < 0)
974 return 0;
975 if (umove(tcp, sp, &sc) < 0)
976 return 0;
977 tcp->u_arg[0] = 1;
978 tcp->u_arg[1] = sc.sc_sigset;
979 } else {
980 tcp->u_rval = tcp->u_error = 0;
981 if(tcp->u_arg[0] == 0)
982 return 0;
983 tcp->auxstr = sprintsigmask("mask now ", tcp->u_arg[1]);
984 return RVAL_NONE | RVAL_STR;
985 }
986 return 0;
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000987#else
988#ifdef HPPA
989#warning NO sys_sigreturn DECODE FOR HPPA
990 return 0;
991#endif /* HPPA */
Wichert Akkermanf90da011999-10-31 21:15:38 +0000992#endif /* MIPS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000993#endif /* SPARC */
994#endif /* ALPHA */
995#endif /* !M68K */
996#endif /* !POWERPC */
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000997#endif /* !IA64 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000998#endif /* !I386 */
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000999#endif /* S390 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001000}
1001
1002int
1003sys_siggetmask(tcp)
1004struct tcb *tcp;
1005{
1006 if (exiting(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001007 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +00001008 long_to_sigset(tcp->u_rval, &sigm);
1009 tcp->auxstr = sprintsigmask("mask ", &sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001010 }
1011 return RVAL_HEX | RVAL_STR;
1012}
1013
1014int
1015sys_sigsuspend(tcp)
1016struct tcb *tcp;
1017{
1018 if (entering(tcp)) {
1019 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +00001020 long_to_sigset(tcp->u_arg[2], &sigm);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001021#if 0
1022 /* first two are not really arguments, but print them anyway */
1023 /* nevermind, they are an anachronism now, too bad... */
1024 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
1025#endif
Nate Sammons4a121431999-04-06 01:19:39 +00001026 printsigmask(&sigm, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001027 }
1028 return 0;
1029}
1030
1031#endif /* LINUX */
1032
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001033#if defined(SVR4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001034
1035int
1036sys_sigsuspend(tcp)
1037struct tcb *tcp;
1038{
1039 sigset_t sigset;
1040
1041 if (entering(tcp)) {
1042 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
1043 tprintf("[?]");
1044 else
Wichert Akkerman46956571999-11-26 10:12:59 +00001045 printsigmask(&sigset, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001046 }
1047 return 0;
1048}
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001049#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001050static struct xlat ucontext_flags[] = {
1051 { UC_SIGMASK, "UC_SIGMASK" },
1052 { UC_STACK, "UC_STACK" },
1053 { UC_CPU, "UC_CPU" },
1054#ifdef UC_FPU
1055 { UC_FPU, "UC_FPU" },
1056#endif
1057#ifdef UC_INTR
1058 { UC_INTR, "UC_INTR" },
1059#endif
1060 { 0, NULL },
1061};
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001062#endif /* !FREEBSD */
1063#endif /* SVR4 || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001064
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001065#if defined SVR4 || defined LINUX || defined FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001066#if defined LINUX && !defined SS_ONSTACK
1067#define SS_ONSTACK 1
1068#define SS_DISABLE 2
1069#if __GLIBC_MINOR__ == 0
1070typedef struct
1071{
1072 __ptr_t ss_sp;
1073 int ss_flags;
1074 size_t ss_size;
1075} stack_t;
1076#endif
1077#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001078#ifdef FREEBSD
1079#define stack_t struct sigaltstack
1080#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001081
1082static struct xlat sigaltstack_flags[] = {
1083 { SS_ONSTACK, "SS_ONSTACK" },
1084 { SS_DISABLE, "SS_DISABLE" },
1085 { 0, NULL },
1086};
1087#endif
1088
1089#ifdef SVR4
1090static void
1091printcontext(tcp, ucp)
1092struct tcb *tcp;
1093ucontext_t *ucp;
1094{
1095 tprintf("{");
1096 if (!abbrev(tcp)) {
1097 tprintf("uc_flags=");
1098 if (!printflags(ucontext_flags, ucp->uc_flags))
1099 tprintf("0");
1100 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
1101 }
1102 tprintf("uc_sigmask=");
John Hughes70c5e7a2001-05-15 15:09:14 +00001103 printsigmask(&ucp->uc_sigmask, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001104 if (!abbrev(tcp)) {
1105 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
1106 (unsigned long) ucp->uc_stack.ss_sp,
1107 ucp->uc_stack.ss_size);
1108 if (!printflags(sigaltstack_flags, ucp->uc_stack.ss_flags))
1109 tprintf("0");
1110 tprintf("}");
1111 }
1112 tprintf(", ...}");
1113}
1114
1115int
1116sys_getcontext(tcp)
1117struct tcb *tcp;
1118{
1119 ucontext_t uc;
1120
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001121 if (exiting(tcp)) {
1122 if (tcp->u_error)
1123 tprintf("%#lx", tcp->u_arg[0]);
1124 else if (!tcp->u_arg[0])
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001125 tprintf("NULL");
1126 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1127 tprintf("{...}");
1128 else
1129 printcontext(tcp, &uc);
1130 }
1131 return 0;
1132}
1133
1134int
1135sys_setcontext(tcp)
1136struct tcb *tcp;
1137{
1138 ucontext_t uc;
1139
1140 if (entering(tcp)) {
1141 if (!tcp->u_arg[0])
1142 tprintf("NULL");
1143 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1144 tprintf("{...}");
1145 else
1146 printcontext(tcp, &uc);
1147 }
1148 else {
1149 tcp->u_rval = tcp->u_error = 0;
1150 if (tcp->u_arg[0] == 0)
1151 return 0;
1152 return RVAL_NONE;
1153 }
1154 return 0;
1155}
1156
1157#endif /* SVR4 */
1158
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001159#if defined(LINUX) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001160
1161static int
1162print_stack_t(tcp, addr)
1163struct tcb *tcp;
1164unsigned long addr;
1165{
1166 stack_t ss;
1167 if (umove(tcp, addr, &ss) < 0)
1168 return -1;
1169 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
1170 if (!printflags(sigaltstack_flags, ss.ss_flags))
1171 tprintf("0");
1172 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
1173 return 0;
1174}
1175
1176int
1177sys_sigaltstack(tcp)
1178 struct tcb *tcp;
1179{
1180 if (entering(tcp)) {
1181 if (tcp->u_arg[0] == 0)
1182 tprintf("NULL");
1183 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
1184 return -1;
1185 }
1186 else {
1187 tprintf(", ");
1188 if (tcp->u_arg[1] == 0)
1189 tprintf("NULL");
1190 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
1191 return -1;
1192 }
1193 return 0;
1194}
1195#endif
1196
1197#ifdef HAVE_SIGACTION
1198
1199int
1200sys_sigprocmask(tcp)
1201struct tcb *tcp;
1202{
1203#ifdef ALPHA
1204 if (entering(tcp)) {
1205 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1206 tprintf(", ");
Nate Sammons4a121431999-04-06 01:19:39 +00001207 printsigmask(tcp->u_arg[1], 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001208 }
1209 else if (!syserror(tcp)) {
Nate Sammons4a121431999-04-06 01:19:39 +00001210 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001211 return RVAL_HEX | RVAL_STR;
1212 }
1213#else /* !ALPHA */
1214 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001215
1216 if (entering(tcp)) {
1217#ifdef SVR4
1218 if (tcp->u_arg[0] == 0)
1219 tprintf("0");
1220 else
1221#endif /* SVR4 */
1222 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1223 tprintf(", ");
1224 if (!tcp->u_arg[1])
1225 tprintf("NULL, ");
Nate Sammons4a121431999-04-06 01:19:39 +00001226 else if (copy_sigset(tcp, tcp->u_arg[1], &sigset) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001227 tprintf("%#lx, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001228 else {
Nate Sammons4a121431999-04-06 01:19:39 +00001229 printsigmask(&sigset, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001230 tprintf(", ");
1231 }
1232 }
1233 else {
1234 if (!tcp->u_arg[2])
1235 tprintf("NULL");
1236 else if (syserror(tcp))
1237 tprintf("%#lx", tcp->u_arg[2]);
Nate Sammons4a121431999-04-06 01:19:39 +00001238 else if (copy_sigset(tcp, tcp->u_arg[2], &sigset) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001239 tprintf("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001240 else
Nate Sammons4a121431999-04-06 01:19:39 +00001241 printsigmask(&sigset, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001242 }
1243#endif /* !ALPHA */
1244 return 0;
1245}
1246
1247#endif /* HAVE_SIGACTION */
1248
1249int
1250sys_kill(tcp)
1251struct tcb *tcp;
1252{
1253 if (entering(tcp)) {
Nate Sammonsce780fc1999-03-29 23:23:13 +00001254 tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001255 }
1256 return 0;
1257}
1258
1259int
1260sys_killpg(tcp)
1261struct tcb *tcp;
1262{
1263 return sys_kill(tcp);
1264}
1265
1266int
1267sys_sigpending(tcp)
1268struct tcb *tcp;
1269{
1270 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001271
1272 if (exiting(tcp)) {
1273 if (syserror(tcp))
1274 tprintf("%#lx", tcp->u_arg[0]);
Nate Sammons4a121431999-04-06 01:19:39 +00001275 else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001276 tprintf("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001277 else
Wichert Akkerman46956571999-11-26 10:12:59 +00001278 printsigmask(&sigset, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001279 }
1280 return 0;
1281}
1282
John Hughes42162082001-10-18 14:48:26 +00001283int sys_sigwait(tcp)
1284struct tcb *tcp;
1285{
1286 sigset_t sigset;
1287
1288 if (entering(tcp)) {
1289 if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1290 tprintf("[?]");
1291 else
1292 printsigmask(&sigset, 0);
1293 }
1294 else {
1295 if (!syserror(tcp)) {
1296 tcp->auxstr = signalent[tcp->u_rval];
1297 return RVAL_DECIMAL | RVAL_STR;
1298 }
1299 }
1300 return 0;
1301}
1302
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001303#ifdef LINUX
1304
1305 int
1306sys_rt_sigprocmask(tcp)
1307 struct tcb *tcp;
1308{
1309 sigset_t sigset;
1310
Nate Sammons4a121431999-04-06 01:19:39 +00001311 /* Note: arg[3] is the length of the sigset. */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001312 if (entering(tcp)) {
1313 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1314 tprintf(", ");
1315 if (!tcp->u_arg[1])
1316 tprintf("NULL, ");
Nate Sammons4a121431999-04-06 01:19:39 +00001317 else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001318 tprintf("%#lx, ", tcp->u_arg[1]);
1319 else {
Nate Sammons4a121431999-04-06 01:19:39 +00001320 printsigmask(&sigset, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001321 tprintf(", ");
1322 }
1323 }
1324 else {
1325 if (!tcp->u_arg[2])
1326
1327 tprintf("NULL");
1328 else if (syserror(tcp))
1329 tprintf("%#lx", tcp->u_arg[2]);
Nate Sammons4a121431999-04-06 01:19:39 +00001330 else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001331 tprintf("[?]");
1332 else
Nate Sammons4a121431999-04-06 01:19:39 +00001333 printsigmask(&sigset, 1);
Nate Sammonsdab325a1999-03-29 23:33:35 +00001334 tprintf(", %lu", tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001335 }
1336 return 0;
1337}
1338
1339#if __GLIBC_MINOR__ < 1
1340/* Type for data associated with a signal. */
1341typedef union sigval
1342{
1343 int sival_int;
1344 void *sival_ptr;
1345} sigval_t;
1346
1347# define __SI_MAX_SIZE 128
1348# define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
1349
1350typedef struct siginfo
1351{
1352 int si_signo; /* Signal number. */
1353 int si_errno; /* If non-zero, an errno value associated with
1354 this signal, as defined in <errno.h>. */
1355 int si_code; /* Signal code. */
1356
1357 union
1358 {
1359 int _pad[__SI_PAD_SIZE];
1360
1361 /* kill(). */
1362 struct
1363 {
1364 __pid_t si_pid; /* Sending process ID. */
1365 __uid_t si_uid; /* Real user ID of sending process. */
1366 } _kill;
1367
1368 /* POSIX.1b timers. */
1369 struct
1370 {
1371 unsigned int _timer1;
1372 unsigned int _timer2;
1373 } _timer;
1374
1375 /* POSIX.1b signals. */
1376 struct
1377 {
1378 __pid_t si_pid; /* Sending process ID. */
1379 __uid_t si_uid; /* Real user ID of sending process. */
1380 sigval_t si_sigval; /* Signal value. */
1381 } _rt;
1382
1383 /* SIGCHLD. */
1384 struct
1385 {
1386 __pid_t si_pid; /* Which child. */
1387 int si_status; /* Exit value or signal. */
1388 __clock_t si_utime;
1389 __clock_t si_stime;
1390 } _sigchld;
1391
1392 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
1393 struct
1394 {
1395 void *si_addr; /* Faulting insn/memory ref. */
1396 } _sigfault;
1397
1398 /* SIGPOLL. */
1399 struct
1400 {
1401 int si_band; /* Band event for SIGPOLL. */
1402 int si_fd;
1403 } _sigpoll;
1404 } _sifields;
1405} siginfo_t;
1406#endif
1407
1408/* Structure describing the action to be taken when a signal arrives. */
1409struct new_sigaction
1410{
1411 union
1412 {
1413 __sighandler_t __sa_handler;
1414 void (*__sa_sigaction) (int, siginfo_t *, void *);
1415 }
1416 __sigaction_handler;
1417 unsigned long sa_flags;
1418 void (*sa_restorer) (void);
1419 unsigned long int sa_mask[2];
1420};
1421
1422
1423 int
1424sys_rt_sigaction(tcp)
1425 struct tcb *tcp;
1426{
1427 struct new_sigaction sa;
1428 sigset_t sigset;
1429 long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001430
1431 if (entering(tcp)) {
1432 printsignal(tcp->u_arg[0]);
1433 tprintf(", ");
1434 addr = tcp->u_arg[1];
1435 } else
1436 addr = tcp->u_arg[2];
1437 if (addr == 0)
1438 tprintf("NULL");
1439 else if (!verbose(tcp))
1440 tprintf("%#lx", addr);
1441 else if (umove(tcp, addr, &sa) < 0)
1442 tprintf("{...}");
1443 else {
1444 switch ((long) sa.__sigaction_handler.__sa_handler) {
1445 case (long) SIG_ERR:
1446 tprintf("{SIG_ERR}");
1447 break;
1448 case (long) SIG_DFL:
1449 tprintf("{SIG_DFL}");
1450 break;
1451 case (long) SIG_IGN:
1452 tprintf("{SIG_IGN}");
1453 break;
1454 default:
1455 tprintf("{%#lx, ",
1456 (long) sa.__sigaction_handler.__sa_handler);
Nate Sammons4a121431999-04-06 01:19:39 +00001457 sigemptyset(&sigset);
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001458#ifdef LINUXSPARC
1459 if (tcp->u_arg[4] <= sizeof(sigset))
1460 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
1461#else
Nate Sammons4a121431999-04-06 01:19:39 +00001462 if (tcp->u_arg[3] <= sizeof(sigset))
1463 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001464#endif
Nate Sammons4a121431999-04-06 01:19:39 +00001465 else
1466 memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
1467 printsigmask(&sigset, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001468 tprintf(", ");
1469 if (!printflags(sigact_flags, sa.sa_flags))
1470 tprintf("0");
1471 tprintf("}");
1472 }
1473 }
1474 if (entering(tcp))
1475 tprintf(", ");
1476 else
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001477#ifdef LINUXSPARC
1478 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
1479#elif defined(ALPHA)
1480 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
1481#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001482 tprintf(", %lu", addr = tcp->u_arg[3]);
Wichert Akkermandacfb6e1999-06-03 14:21:07 +00001483#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001484 return 0;
1485}
1486
1487 int
1488sys_rt_sigpending(tcp)
1489 struct tcb *tcp;
1490{
1491 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001492
1493 if (exiting(tcp)) {
1494 if (syserror(tcp))
1495 tprintf("%#lx", tcp->u_arg[0]);
Nate Sammons4a121431999-04-06 01:19:39 +00001496 else if (copy_sigset_len(tcp, tcp->u_arg[0],
1497 &sigset, tcp->u_arg[1]) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001498 tprintf("[?]");
1499 else
Wichert Akkerman46956571999-11-26 10:12:59 +00001500 printsigmask(&sigset, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001501 }
1502 return 0;
1503}
1504 int
1505sys_rt_sigsuspend(tcp)
1506 struct tcb *tcp;
1507{
1508 if (entering(tcp)) {
1509 sigset_t sigm;
Nate Sammons4a121431999-04-06 01:19:39 +00001510 if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0)
1511 tprintf("[?]");
1512 else
1513 printsigmask(&sigm, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001514 }
1515 return 0;
1516}
1517#ifndef ILL_ILLOPC
1518#define ILL_ILLOPC 1 /* illegal opcode */
1519#define ILL_ILLOPN 2 /* illegal operand */
1520#define ILL_ILLADR 3 /* illegal addressing mode */
1521#define ILL_ILLTRP 4 /* illegal trap */
1522#define ILL_PRVOPC 5 /* privileged opcode */
1523#define ILL_PRVREG 6 /* privileged register */
1524#define ILL_COPROC 7 /* coprocessor error */
1525#define ILL_BADSTK 8 /* internal stack error */
1526#define FPE_INTDIV 1 /* integer divide by zero */
1527#define FPE_INTOVF 2 /* integer overflow */
1528#define FPE_FLTDIV 3 /* floating point divide by zero */
1529#define FPE_FLTOVF 4 /* floating point overflow */
1530#define FPE_FLTUND 5 /* floating point underflow */
1531#define FPE_FLTRES 6 /* floating point inexact result */
1532#define FPE_FLTINV 7 /* floating point invalid operation */
1533#define FPE_FLTSUB 8 /* subscript out of range */
1534#define SEGV_MAPERR 1 /* address not mapped to object */
1535#define SEGV_ACCERR 2 /* invalid permissions for mapped object */
1536#define BUS_ADRALN 1 /* invalid address alignment */
1537#define BUS_ADRERR 2 /* non-existant physical address */
1538#define BUS_OBJERR 3 /* object specific hardware error */
1539#define TRAP_BRKPT 1 /* process breakpoint */
1540#define TRAP_TRACE 2 /* process trace trap */
1541#define CLD_EXITED 1 /* child has exited */
1542#define CLD_KILLED 2 /* child was killed */
1543#define CLD_DUMPED 3 /* child terminated abnormally */
1544#define CLD_TRAPPED 4 /* traced child has trapped */
1545#define CLD_STOPPED 5 /* child has stopped */
1546#define CLD_CONTINUED 6 /* stopped child has continued */
1547#define POLL_IN 1 /* data input available */
1548#define POLL_OUT 2 /* output buffers available */
1549#define POLL_MSG 3 /* input message available */
1550#define POLL_ERR 4 /* i/o error */
1551#define POLL_PRI 5 /* high priority input available */
1552#define POLL_HUP 6 /* device disconnected */
1553#define SI_USER 0 /* sent by kill, sigsend, raise */
1554#define SI_QUEUE -1 /* sent by sigqueue */
1555#define SI_TIMER -2 /* sent by timer expiration */
1556#define SI_MESGQ -3 /* sent by real time mesq state change */
1557#define SI_ASYNCIO -4 /* sent by AIO completion */
1558#else
1559#undef si_pid
1560#undef si_uid
1561#undef si_status
1562#undef si_utime
1563#undef si_stime
1564#undef si_value
1565#undef si_int
1566#undef si_ptr
1567#undef si_addr
1568#undef si_band
1569#undef si_fd
1570#endif
1571
1572static struct xlat sigill_flags[] = {
1573 {ILL_ILLOPC, "ILL_ILLOPC"},
1574 {ILL_ILLOPN, "ILL_ILLOPN"},
1575 {ILL_ILLADR, "ILL_ILLADR"},
1576 {ILL_ILLTRP, "ILL_ILLTRP"},
1577 {ILL_PRVOPC, "ILL_PRVOPC"},
1578 {ILL_PRVREG, "ILL_PRVREG"},
1579 {ILL_COPROC, "ILL_COPROC"},
1580 {ILL_BADSTK, "ILL_BADSTK"},
1581 {0, NULL}
1582};
1583
1584static struct xlat sigfpe_flags[] = {
1585 {FPE_INTDIV, "FPE_INTDIV"},
1586 {FPE_INTOVF, "FPE_INTOVF"},
1587 {FPE_FLTDIV, "FPE_FLTDIV"},
1588 {FPE_FLTOVF, "FPE_FLTOVF"},
1589 {FPE_FLTUND, "FPE_FLTUND"},
1590 {FPE_FLTRES, "FPE_FLTRES"},
1591 {FPE_FLTINV, "FPE_FLTINV"},
1592 {FPE_FLTSUB, "FPE_FLTSUB"},
1593 {0, NULL}
1594};
1595
1596static struct xlat sigsegv_flags[] = {
1597 {SEGV_MAPERR, "SEGV_MAPERR"},
1598 {SEGV_ACCERR, "SEGV_ACCERR"},
1599 {0, NULL}
1600};
1601
1602static struct xlat sigbus_flags[] = {
1603 {BUS_ADRALN, "BUS_ADRALN"},
1604 {BUS_ADRERR, "BUS_ADRERR"},
1605 {BUS_OBJERR, "BUS_OBJERR"},
1606 {0, NULL}
1607};
1608
1609static struct xlat sigtrap_flags[] = {
1610 {TRAP_BRKPT, "TRAP_BRKPT"},
1611 {TRAP_TRACE, "TRAP_TRACE"},
1612 {0, NULL}
1613};
1614
1615static struct xlat sigchld_flags[] = {
1616 {CLD_EXITED, "CLD_EXITED"},
1617 {CLD_KILLED, "CLD_KILLED"},
1618 {CLD_DUMPED, "CLD_DUMPED"},
1619 {CLD_TRAPPED, "CLD_TRAPPED"},
1620 {CLD_STOPPED, "CLD_STOPPED"},
1621 {CLD_CONTINUED, "CLD_CONTINUED"},
1622 {0, NULL}
1623};
1624
1625static struct xlat sigpoll_flags[] = {
1626 {POLL_IN, "POLL_IN"},
1627 {POLL_OUT, "POLL_OUT"},
1628 {POLL_MSG, "POLL_MSG"},
1629 {POLL_ERR, "POLL_ERR"},
1630 {POLL_PRI, "POLL_PRI"},
1631 {POLL_HUP, "POLL_HUP"},
1632 {0, NULL}
1633};
1634
1635static struct xlat siginfo_flags[] = {
1636 {SI_USER, "SI_USER"},
1637 {SI_QUEUE, "SI_QUEUE"},
1638 {SI_TIMER, "SI_TIMER"},
1639 {SI_MESGQ, "SI_MESGQ"},
1640 {SI_ASYNCIO, "SI_ASYNCIO"},
1641 {0, NULL}
1642};
1643
1644 static void
1645printsiginfo(tcp, si)
1646 struct tcb *tcp;
1647 siginfo_t *si;
1648{
1649 tprintf("{si_signo=");
1650 printsignal(si->si_signo);
1651 tprintf(", si_errno=%d, si_code=", si->si_errno);
1652 switch(si->si_signo)
1653 {
1654 case SIGILL:
1655 if (!printflags(sigill_flags, si->si_code))
1656 tprintf("%d /* ILL_??? */", si->si_code);
1657 tprintf(", si_addr=%lx",
1658 (unsigned long) si->_sifields._sigfault.si_addr);
1659 break;
1660 case SIGFPE:
1661 if (!printflags(sigfpe_flags, si->si_code))
1662 tprintf("%d /* FPE_??? */", si->si_code);
1663 tprintf(", si_addr=%lx",
1664 (unsigned long) si->_sifields._sigfault.si_addr);
1665 break;
1666 case SIGSEGV:
1667 if (!printflags(sigsegv_flags, si->si_code))
1668 tprintf("%d /* SEGV_??? */", si->si_code);
1669 tprintf(", si_addr=%lx",
1670 (unsigned long) si->_sifields._sigfault.si_addr);
1671 break;
1672 case SIGBUS:
1673 if (!printflags(sigbus_flags, si->si_code))
1674 tprintf("%d /* BUS_??? */", si->si_code);
1675 tprintf(", si_addr=%lx",
1676 (unsigned long) si->_sifields._sigfault.si_addr);
1677 break;
1678 case SIGTRAP:
1679 if (!printflags(sigtrap_flags, si->si_code))
1680 tprintf("%d /* TRAP_??? */", si->si_code);
1681 break;
1682 case SIGCHLD:
1683 if (!printflags(sigchld_flags, si->si_code))
1684 tprintf("%d /* CLD_??? */", si->si_code);
1685 if (!verbose(tcp))
1686 tprintf(", ...");
1687 else
1688 tprintf(", si_pid=%d, si_uid=%d, si_status=%d, si_utime=%lu, si_stime=%lu",
1689 si->_sifields._kill.si_pid,
1690 si->_sifields._kill.si_uid,
1691 si->_sifields._sigchld.si_status,
1692 si->_sifields._sigchld.si_utime,
1693 si->_sifields._sigchld.si_stime);
1694 break;
1695 case SIGPOLL:
1696 if (!printflags(sigpoll_flags, si->si_code))
1697 tprintf("%d /* POLL_??? */", si->si_code);
1698 if (si->si_code == POLL_IN
1699 || si->si_code == POLL_OUT
1700 || si->si_code == POLL_MSG)
1701 tprintf(", si_bind=%lu, si_fd=%d",
1702 (unsigned long) si->_sifields._sigpoll.si_band,
1703 si->_sifields._sigpoll.si_fd);
1704 break;
1705 default:
1706 if (!printflags(siginfo_flags, si->si_code))
1707 tprintf("%d /* SI_??? */", si->si_code);
1708 tprintf(", si_pid=%lu, si_uid=%lu, si_value={",
1709 (unsigned long) si->_sifields._rt.si_pid,
1710 (unsigned long) si->_sifields._rt.si_uid);
1711 if (!verbose(tcp))
1712 tprintf("...");
1713 else {
1714 tprintf("sival_int=%u, sival_ptr=%#lx",
1715 si->_sifields._rt.si_sigval.sival_int,
1716 (unsigned long) si->_sifields._rt.si_sigval.sival_ptr);
1717 }
1718 tprintf("}");
1719 break;
1720 }
1721 tprintf("}");
1722}
1723
1724 int
1725sys_rt_sigqueueinfo(tcp)
1726 struct tcb *tcp;
1727{
1728 if (entering(tcp)) {
1729 siginfo_t si;
1730 tprintf("%lu, ", tcp->u_arg[0]);
1731 printsignal(tcp->u_arg[1]);
1732 tprintf(", ");
1733 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1734 tprintf("%#lx", tcp->u_arg[2]);
1735 else
1736 printsiginfo(&si);
1737 }
1738 return 0;
1739}
1740
1741int sys_rt_sigtimedwait(tcp)
1742 struct tcb *tcp;
1743{
1744 if (entering(tcp)) {
1745 sigset_t sigset;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001746
Nate Sammons4a121431999-04-06 01:19:39 +00001747 if (copy_sigset_len(tcp, tcp->u_arg[0],
1748 &sigset, tcp->u_arg[3]) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001749 tprintf("[?]");
1750 else
Wichert Akkerman46956571999-11-26 10:12:59 +00001751 printsigmask(&sigset, 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001752 tprintf(", ");
1753 }
1754 else {
1755 if (syserror(tcp))
1756 tprintf("%#lx", tcp->u_arg[0]);
1757 else {
1758 siginfo_t si;
1759 if (umove(tcp, tcp->u_arg[1], &si) < 0)
1760 tprintf("%#lx", tcp->u_arg[1]);
1761 else
1762 printsiginfo(&si);
1763 /* XXX For now */
1764 tprintf(", %#lx", tcp->u_arg[2]);
1765 tprintf(", %d", (int) tcp->u_arg[3]);
1766 }
1767 }
1768 return 0;
1769};
1770
1771#endif /* LINUX */
1772