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>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 #include <sys/ucontext.h>
42 #if defined(linux) && !defined(__GLIBC__)
43 #include <linux/ptrace.h>
48 # define PTRACE_PEEKUSR PTRACE_PEEKUSER
49 # define PTRACE_POKEUSR PTRACE_POKEUSER
54 #ifdef HAVE_ASM_SIGCONTEXT_H
55 #include <asm/sigcontext.h>
58 struct pt_regs si_regs;
62 #else /* !HAVE_ASM_SIGCONTEXT_H */
64 struct sigcontext_struct {
65 unsigned short gs, __gsh;
66 unsigned short fs, __fsh;
67 unsigned short es, __esh;
68 unsigned short ds, __dsh;
80 unsigned short cs, __csh;
82 unsigned long esp_at_signal;
83 unsigned short ss, __ssh;
85 unsigned long oldmask;
92 unsigned long sc_mask;
100 unsigned short sc_formatvec;
104 #endif /* !HAVE_ASM_SIGCONTEXT_H */
114 char *signalent0[] = {
115 #include "signalent.h"
117 int nsignals0 = sizeof signalent0 / sizeof signalent0[0];
119 #if SUPPORTED_PERSONALITIES >= 2
120 char *signalent1[] = {
121 #include "signalent1.h"
123 int nsignals1 = sizeof signalent1 / sizeof signalent1[0];
124 #endif /* SUPPORTED_PERSONALITIES >= 2 */
126 #if SUPPORTED_PERSONALITIES >= 3
127 char *signalent2[] = {
128 #include "signalent2.h"
130 int nsignals2 = sizeof signalent2 / sizeof signalent2[0];
131 #endif /* SUPPORTED_PERSONALITIES >= 3 */
138 static struct xlat sigvec_flags[] = {
139 { SV_ONSTACK, "SV_ONSTACK" },
140 { SV_INTERRUPT, "SV_INTERRUPT" },
141 { SV_RESETHAND, "SV_RESETHAND" },
142 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
148 #ifdef HAVE_SIGACTION
150 static struct xlat sigact_flags[] = {
152 { SA_STACK, "SA_STACK" },
155 { SA_RESTART, "SA_RESTART" },
158 { SA_INTERRUPT, "SA_INTERRUPT" },
161 { SA_NOMASK, "SA_NOMASK" },
164 { SA_ONESHOT, "SA_ONESHOT" },
167 { SA_SIGINFO, "SA_SIGINFO" },
170 { SA_RESETHAND, "SA_RESETHAND" },
173 { SA_ONSTACK, "SA_ONSTACK" },
176 { SA_NODEFER, "SA_NODEFER" },
179 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
182 { SA_NOCLDWAIT, "SA_NOCLDWAIT" },
185 { _SA_BSDCALL, "_SA_BSDCALL" },
190 static struct xlat sigprocmaskcmds[] = {
191 { SIG_BLOCK, "SIG_BLOCK" },
192 { SIG_UNBLOCK, "SIG_UNBLOCK" },
193 { SIG_SETMASK, "SIG_SETMASK" },
195 { SIG_SETMASK32,"SIG_SETMASK32" },
200 #endif /* HAVE_SIGACTION */
202 /* Anonymous realtime signals. */
203 /* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
204 constant. This is what we want. Otherwise, just use SIGRTMIN. */
207 #define __SIGRTMIN SIGRTMIN
208 #define __SIGRTMAX SIGRTMAX /* likewise */
217 if (sig < nsignals) {
218 return signalent[sig];
220 } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) {
221 sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN));
223 #endif /* SIGRTMIN */
225 sprintf(buf, "%d", sig);
240 copy_sigset_len(tcp, addr, s, len)
246 if (len > sizeof(*s))
249 if (umoven(tcp, addr, len, (char *)s) < 0)
255 /* Original sigset is unsigned long */
256 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long))
258 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t))
262 sprintsigmask(s, mask, rt)
265 int rt; /* set might include realtime sigs */
270 static char outstr[256];
273 s = outstr + strlen(outstr);
278 maxsigs = __SIGRTMAX; /* instead */
280 for (i = 1; i < maxsigs; i++) {
281 if (sigismember(mask, i) == 1)
284 if (nsigs >= nsignals * 2 / 3) {
286 for (i = 1; i < maxsigs; i++) {
287 switch (sigismember(mask, i)) {
299 for (i = 1; i < maxsigs; i++) {
300 if (sigismember(mask, i) == 1) {
301 sprintf(s, format, signame(i) + 3); s += strlen(s);
311 printsigmask(mask, rt)
315 tprintf("%s", sprintsigmask("", mask, rt));
322 tprintf(signame(nr));
326 * Check process TCP for the disposition of signal SIG.
327 * Return 1 if the process would somehow manage to survive signal SIG,
328 * else return 0. This routine will never be called with SIGKILL.
331 sigishandled(tcp, sig)
341 unsigned int signalled, blocked, ignored, caught;
343 /* This is incredibly costly but it's worth it. */
344 sprintf(sname, "/proc/%d/stat", tcp->pid);
345 if ((sfd = open(sname, O_RDONLY)) == -1) {
349 i = read(sfd, buf, 1024);
353 * Skip the extraneous fields. This loses if the
354 * command name has any spaces in it. So be it.
356 for (i = 0, s = buf; i < 30; i++) {
357 while (*++s != ' ') {
362 if (sscanf(s, "%u%u%u%u",
363 &signalled, &blocked, &ignored, &caught) != 4) {
364 fprintf(stderr, "/proc/pid/stat format error\n");
368 fprintf(stderr, "sigs: %08x %08x %08x %08x\n",
369 signalled, blocked, ignored, caught);
371 if ((ignored & sigmask(sig)) || (caught & sigmask(sig)))
378 if (upeek(tcp->pid, uoff(u_signal[0]) + sig*sizeof(u_signal),
379 (long *) &u_signal) < 0) {
382 if (u_signal != SIG_DFL)
388 * Since procfs doesn't interfere with wait I think it is safe
389 * to punt on this question. If not, the information is there.
401 #if defined(SIGURG) && SIGURG != SIGIO
405 /* Gloria Gaynor says ... */
424 printsignal(tcp->u_arg[0]);
426 addr = tcp->u_arg[1];
428 addr = tcp->u_arg[2];
432 else if (!verbose(tcp))
433 tprintf("%#lx", addr);
434 else if (umove(tcp, addr, &sv) < 0)
437 switch ((int) sv.sv_handler) {
439 tprintf("{SIG_ERR}");
442 tprintf("{SIG_DFL}");
445 if (tcp->u_arg[0] == SIGTRAP) {
446 tcp->flags |= TCB_SIGTRAPPED;
447 kill(tcp->pid, SIGSTOP);
449 tprintf("{SIG_IGN}");
452 if (tcp->u_arg[0] == SIGTRAP) {
453 tcp->flags |= TCB_SIGTRAPPED;
454 kill(tcp->pid, SIGSTOP);
459 if (tcp->u_arg[0] == SIGTRAP) {
460 tcp->flags |= TCB_SIGTRAPPED;
461 kill(tcp->pid, SIGSTOP);
463 tprintf("{%#lx, ", (unsigned long) sv.sv_handler);
464 printsigmask(&sv.sv_mask, 0);
466 if (!printflags(sigvec_flags, sv.sv_flags))
480 if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */
482 long_to_sigset(tcp->u_arg[0], &sigm);
483 printsigmask(&sigm, 0);
496 addr = tcp->u_arg[0];
498 addr = tcp->u_arg[1];
501 else if (umove(tcp, addr, &ss) < 0)
502 tprintf("%#lx", addr);
504 tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp);
505 tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO");
529 long_to_sigset(tcp->u_arg[0], &sigm);
530 printsigmask(&sigm, 0);
531 if ((tcp->u_arg[0] & sigmask(SIGTRAP))) {
532 /* Mark attempt to block SIGTRAP */
533 tcp->flags |= TCB_SIGTRAPPED;
534 /* Send unblockable signal */
535 kill(tcp->pid, SIGSTOP);
538 else if (!syserror(tcp)) {
540 long_to_sigset(tcp->u_rval, &sigm);
541 tcp->auxstr = sprintsigmask("old mask ", &sigm, 0);
543 return RVAL_HEX | RVAL_STR;
552 return sys_sigsetmask(tcp);
557 #ifdef HAVE_SIGACTION
560 struct old_sigaction {
561 __sighandler_t __sa_handler;
562 unsigned long sa_mask;
563 unsigned long sa_flags;
564 void (*sa_restorer)(void);
566 #define SA_HANDLER __sa_handler
570 #define SA_HANDLER sa_handler
580 struct old_sigaction sa;
587 printsignal(tcp->u_arg[0]);
589 addr = tcp->u_arg[1];
591 addr = tcp->u_arg[2];
594 else if (!verbose(tcp))
595 tprintf("%#lx", addr);
596 else if (umove(tcp, addr, &sa) < 0)
599 switch ((long) sa.SA_HANDLER) {
601 tprintf("{SIG_ERR}");
604 tprintf("{SIG_DFL}");
608 if (tcp->u_arg[0] == SIGTRAP) {
609 tcp->flags |= TCB_SIGTRAPPED;
610 kill(tcp->pid, SIGSTOP);
613 tprintf("{SIG_IGN}");
617 if (tcp->u_arg[0] == SIGTRAP) {
618 tcp->flags |= TCB_SIGTRAPPED;
619 kill(tcp->pid, SIGSTOP);
622 tprintf("{%#lx, ", (long) sa.SA_HANDLER);
623 long_to_sigset(sa.sa_mask, &sigset);
624 printsigmask(&sigset, 0);
626 if (!printflags(sigact_flags, sa.sa_flags))
635 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
645 printsignal(tcp->u_arg[0]);
646 switch (tcp->u_arg[1]) {
655 if (tcp->u_arg[0] == SIGTRAP) {
656 tcp->flags |= TCB_SIGTRAPPED;
657 kill(tcp->pid, SIGSTOP);
664 if (tcp->u_arg[0] == SIGTRAP) {
665 tcp->flags |= TCB_SIGTRAPPED;
666 kill(tcp->pid, SIGSTOP);
669 tprintf("%#lx", tcp->u_arg[1]);
675 #endif /* HAVE_SIGACTION */
685 struct sigcontext_struct sc;
689 if (upeek(tcp->pid, 4*UESP, &esp) < 0)
691 if (umove(tcp, esp, &sc) < 0)
694 tcp->u_arg[1] = sc.oldmask;
698 long_to_sigset(tcp->u_arg[1], &sigm);
699 tcp->u_rval = tcp->u_error = 0;
700 if (tcp->u_arg[0] == 0)
702 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
703 return RVAL_NONE | RVAL_STR;
709 struct sigcontext_struct sc;
713 if (upeek(tcp->pid, 4*PT_R1, &esp) < 0)
715 if (umove(tcp, esp, &sc) < 0)
718 tcp->u_arg[1] = sc.oldmask;
722 long_to_sigset(tcp->u_arg[1], &sigm);
723 tcp->u_rval = tcp->u_error = 0;
724 if (tcp->u_arg[0] == 0)
726 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
727 return RVAL_NONE | RVAL_STR;
733 struct sigcontext sc;
737 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
739 if (umove(tcp, usp, &sc) < 0)
742 tcp->u_arg[1] = sc.sc_mask;
746 long_to_sigset(tcp->u_arg[1], &sigm);
747 tcp->u_rval = tcp->u_error = 0;
748 if (tcp->u_arg[0] == 0)
750 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
751 return RVAL_NONE | RVAL_STR;
757 struct sigcontext_struct sc;
761 if (upeek(tcp->pid, REG_FP, &fp) < 0)
763 if (umove(tcp, fp, &sc) < 0)
766 tcp->u_arg[1] = sc.sc_mask;
770 long_to_sigset(tcp->u_arg[1], &sigm);
771 tcp->u_rval = tcp->u_error = 0;
772 if (tcp->u_arg[0] == 0)
774 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
775 return RVAL_NONE | RVAL_STR;
784 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
785 perror("sigreturn: PTRACE_GETREGS ");
788 memmove (®s.u_regs [1], ®s.u_regs [0],
789 sizeof (regs.u_regs) - sizeof (regs.u_regs [0]));
792 i1 = regs.u_regs[UREG_I1];
793 if(umove(tcp, i1, &si) < 0) {
794 perror("sigreturn: umove ");
798 tcp->u_arg[1] = si.si_mask;
801 long_to_sigset(tcp->u_arg[1], &sigm);
802 tcp->u_rval = tcp->u_error = 0;
803 if(tcp->u_arg[0] == 0)
805 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
806 return RVAL_NONE | RVAL_STR;
812 #endif /* !POWERPC */
822 long_to_sigset(tcp->u_rval, &sigm);
823 tcp->auxstr = sprintsigmask("mask ", &sigm, 0);
825 return RVAL_HEX | RVAL_STR;
834 long_to_sigset(tcp->u_arg[2], &sigm);
836 /* first two are not really arguments, but print them anyway */
837 /* nevermind, they are an anachronism now, too bad... */
838 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
840 printsigmask(&sigm, 0);
856 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
859 printsigmask(sigset, 0);
863 static struct xlat ucontext_flags[] = {
864 { UC_SIGMASK, "UC_SIGMASK" },
865 { UC_STACK, "UC_STACK" },
866 { UC_CPU, "UC_CPU" },
868 { UC_FPU, "UC_FPU" },
871 { UC_INTR, "UC_INTR" },
878 #if defined SVR4 || defined LINUX
879 #if defined LINUX && !defined SS_ONSTACK
882 #if __GLIBC_MINOR__ == 0
892 static struct xlat sigaltstack_flags[] = {
893 { SS_ONSTACK, "SS_ONSTACK" },
894 { SS_DISABLE, "SS_DISABLE" },
901 printcontext(tcp, ucp)
907 tprintf("uc_flags=");
908 if (!printflags(ucontext_flags, ucp->uc_flags))
910 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
912 tprintf("uc_sigmask=");
913 printsigmask(ucp->uc_sigmask, 0);
915 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
916 (unsigned long) ucp->uc_stack.ss_sp,
917 ucp->uc_stack.ss_size);
918 if (!printflags(sigaltstack_flags, ucp->uc_stack.ss_flags))
934 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
937 printcontext(tcp, &uc);
951 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
954 printcontext(tcp, &uc);
957 tcp->u_rval = tcp->u_error = 0;
958 if (tcp->u_arg[0] == 0)
970 print_stack_t(tcp, addr)
975 if (umove(tcp, addr, &ss) < 0)
977 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
978 if (!printflags(sigaltstack_flags, ss.ss_flags))
980 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
989 if (tcp->u_arg[0] == 0)
991 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
996 if (tcp->u_arg[1] == 0)
998 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
1005 #ifdef HAVE_SIGACTION
1008 sys_sigprocmask(tcp)
1012 if (entering(tcp)) {
1013 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1015 printsigmask(tcp->u_arg[1], 0);
1017 else if (!syserror(tcp)) {
1018 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0);
1019 return RVAL_HEX | RVAL_STR;
1024 if (entering(tcp)) {
1026 if (tcp->u_arg[0] == 0)
1030 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1034 else if (copy_sigset(tcp, tcp->u_arg[1], &sigset) < 0)
1035 tprintf("%#lx, ", tcp->u_arg[1]);
1037 printsigmask(&sigset, 0);
1044 else if (syserror(tcp))
1045 tprintf("%#lx", tcp->u_arg[2]);
1046 else if (copy_sigset(tcp, tcp->u_arg[2], &sigset) < 0)
1049 printsigmask(&sigset, 0);
1055 #endif /* HAVE_SIGACTION */
1061 if (entering(tcp)) {
1062 tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1]));
1071 return sys_kill(tcp);
1082 tprintf("%#lx", tcp->u_arg[0]);
1083 else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1086 printsigmask(sigset, 0);
1094 sys_rt_sigprocmask(tcp)
1099 /* Note: arg[3] is the length of the sigset. */
1100 if (entering(tcp)) {
1101 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1105 else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0)
1106 tprintf("%#lx, ", tcp->u_arg[1]);
1108 printsigmask(&sigset, 1);
1116 else if (syserror(tcp))
1117 tprintf("%#lx", tcp->u_arg[2]);
1118 else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0)
1121 printsigmask(&sigset, 1);
1122 tprintf(", %lu", tcp->u_arg[3]);
1127 #if __GLIBC_MINOR__ < 1
1128 /* Type for data associated with a signal. */
1129 typedef union sigval
1135 # define __SI_MAX_SIZE 128
1136 # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
1138 typedef struct siginfo
1140 int si_signo; /* Signal number. */
1141 int si_errno; /* If non-zero, an errno value associated with
1142 this signal, as defined in <errno.h>. */
1143 int si_code; /* Signal code. */
1147 int _pad[__SI_PAD_SIZE];
1152 __pid_t si_pid; /* Sending process ID. */
1153 __uid_t si_uid; /* Real user ID of sending process. */
1156 /* POSIX.1b timers. */
1159 unsigned int _timer1;
1160 unsigned int _timer2;
1163 /* POSIX.1b signals. */
1166 __pid_t si_pid; /* Sending process ID. */
1167 __uid_t si_uid; /* Real user ID of sending process. */
1168 sigval_t si_sigval; /* Signal value. */
1174 __pid_t si_pid; /* Which child. */
1175 int si_status; /* Exit value or signal. */
1180 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
1183 void *si_addr; /* Faulting insn/memory ref. */
1189 int si_band; /* Band event for SIGPOLL. */
1196 /* Structure describing the action to be taken when a signal arrives. */
1197 struct new_sigaction
1201 __sighandler_t __sa_handler;
1202 void (*__sa_sigaction) (int, siginfo_t *, void *);
1204 __sigaction_handler;
1205 unsigned long sa_flags;
1206 void (*sa_restorer) (void);
1207 unsigned long int sa_mask[2];
1212 sys_rt_sigaction(tcp)
1215 struct new_sigaction sa;
1219 if (entering(tcp)) {
1220 printsignal(tcp->u_arg[0]);
1222 addr = tcp->u_arg[1];
1224 addr = tcp->u_arg[2];
1227 else if (!verbose(tcp))
1228 tprintf("%#lx", addr);
1229 else if (umove(tcp, addr, &sa) < 0)
1232 switch ((long) sa.__sigaction_handler.__sa_handler) {
1233 case (long) SIG_ERR:
1234 tprintf("{SIG_ERR}");
1236 case (long) SIG_DFL:
1237 tprintf("{SIG_DFL}");
1239 case (long) SIG_IGN:
1240 tprintf("{SIG_IGN}");
1244 (long) sa.__sigaction_handler.__sa_handler);
1245 sigemptyset(&sigset);
1247 if (tcp->u_arg[4] <= sizeof(sigset))
1248 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
1250 if (tcp->u_arg[3] <= sizeof(sigset))
1251 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
1254 memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
1255 printsigmask(&sigset, 1);
1257 if (!printflags(sigact_flags, sa.sa_flags))
1266 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
1267 #elif defined(ALPHA)
1268 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
1270 tprintf(", %lu", addr = tcp->u_arg[3]);
1276 sys_rt_sigpending(tcp)
1283 tprintf("%#lx", tcp->u_arg[0]);
1284 else if (copy_sigset_len(tcp, tcp->u_arg[0],
1285 &sigset, tcp->u_arg[1]) < 0)
1288 printsigmask(sigset, 1);
1293 sys_rt_sigsuspend(tcp)
1296 if (entering(tcp)) {
1298 if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0)
1301 printsigmask(&sigm, 1);
1306 #define ILL_ILLOPC 1 /* illegal opcode */
1307 #define ILL_ILLOPN 2 /* illegal operand */
1308 #define ILL_ILLADR 3 /* illegal addressing mode */
1309 #define ILL_ILLTRP 4 /* illegal trap */
1310 #define ILL_PRVOPC 5 /* privileged opcode */
1311 #define ILL_PRVREG 6 /* privileged register */
1312 #define ILL_COPROC 7 /* coprocessor error */
1313 #define ILL_BADSTK 8 /* internal stack error */
1314 #define FPE_INTDIV 1 /* integer divide by zero */
1315 #define FPE_INTOVF 2 /* integer overflow */
1316 #define FPE_FLTDIV 3 /* floating point divide by zero */
1317 #define FPE_FLTOVF 4 /* floating point overflow */
1318 #define FPE_FLTUND 5 /* floating point underflow */
1319 #define FPE_FLTRES 6 /* floating point inexact result */
1320 #define FPE_FLTINV 7 /* floating point invalid operation */
1321 #define FPE_FLTSUB 8 /* subscript out of range */
1322 #define SEGV_MAPERR 1 /* address not mapped to object */
1323 #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
1324 #define BUS_ADRALN 1 /* invalid address alignment */
1325 #define BUS_ADRERR 2 /* non-existant physical address */
1326 #define BUS_OBJERR 3 /* object specific hardware error */
1327 #define TRAP_BRKPT 1 /* process breakpoint */
1328 #define TRAP_TRACE 2 /* process trace trap */
1329 #define CLD_EXITED 1 /* child has exited */
1330 #define CLD_KILLED 2 /* child was killed */
1331 #define CLD_DUMPED 3 /* child terminated abnormally */
1332 #define CLD_TRAPPED 4 /* traced child has trapped */
1333 #define CLD_STOPPED 5 /* child has stopped */
1334 #define CLD_CONTINUED 6 /* stopped child has continued */
1335 #define POLL_IN 1 /* data input available */
1336 #define POLL_OUT 2 /* output buffers available */
1337 #define POLL_MSG 3 /* input message available */
1338 #define POLL_ERR 4 /* i/o error */
1339 #define POLL_PRI 5 /* high priority input available */
1340 #define POLL_HUP 6 /* device disconnected */
1341 #define SI_USER 0 /* sent by kill, sigsend, raise */
1342 #define SI_QUEUE -1 /* sent by sigqueue */
1343 #define SI_TIMER -2 /* sent by timer expiration */
1344 #define SI_MESGQ -3 /* sent by real time mesq state change */
1345 #define SI_ASYNCIO -4 /* sent by AIO completion */
1360 static struct xlat sigill_flags[] = {
1361 {ILL_ILLOPC, "ILL_ILLOPC"},
1362 {ILL_ILLOPN, "ILL_ILLOPN"},
1363 {ILL_ILLADR, "ILL_ILLADR"},
1364 {ILL_ILLTRP, "ILL_ILLTRP"},
1365 {ILL_PRVOPC, "ILL_PRVOPC"},
1366 {ILL_PRVREG, "ILL_PRVREG"},
1367 {ILL_COPROC, "ILL_COPROC"},
1368 {ILL_BADSTK, "ILL_BADSTK"},
1372 static struct xlat sigfpe_flags[] = {
1373 {FPE_INTDIV, "FPE_INTDIV"},
1374 {FPE_INTOVF, "FPE_INTOVF"},
1375 {FPE_FLTDIV, "FPE_FLTDIV"},
1376 {FPE_FLTOVF, "FPE_FLTOVF"},
1377 {FPE_FLTUND, "FPE_FLTUND"},
1378 {FPE_FLTRES, "FPE_FLTRES"},
1379 {FPE_FLTINV, "FPE_FLTINV"},
1380 {FPE_FLTSUB, "FPE_FLTSUB"},
1384 static struct xlat sigsegv_flags[] = {
1385 {SEGV_MAPERR, "SEGV_MAPERR"},
1386 {SEGV_ACCERR, "SEGV_ACCERR"},
1390 static struct xlat sigbus_flags[] = {
1391 {BUS_ADRALN, "BUS_ADRALN"},
1392 {BUS_ADRERR, "BUS_ADRERR"},
1393 {BUS_OBJERR, "BUS_OBJERR"},
1397 static struct xlat sigtrap_flags[] = {
1398 {TRAP_BRKPT, "TRAP_BRKPT"},
1399 {TRAP_TRACE, "TRAP_TRACE"},
1403 static struct xlat sigchld_flags[] = {
1404 {CLD_EXITED, "CLD_EXITED"},
1405 {CLD_KILLED, "CLD_KILLED"},
1406 {CLD_DUMPED, "CLD_DUMPED"},
1407 {CLD_TRAPPED, "CLD_TRAPPED"},
1408 {CLD_STOPPED, "CLD_STOPPED"},
1409 {CLD_CONTINUED, "CLD_CONTINUED"},
1413 static struct xlat sigpoll_flags[] = {
1414 {POLL_IN, "POLL_IN"},
1415 {POLL_OUT, "POLL_OUT"},
1416 {POLL_MSG, "POLL_MSG"},
1417 {POLL_ERR, "POLL_ERR"},
1418 {POLL_PRI, "POLL_PRI"},
1419 {POLL_HUP, "POLL_HUP"},
1423 static struct xlat siginfo_flags[] = {
1424 {SI_USER, "SI_USER"},
1425 {SI_QUEUE, "SI_QUEUE"},
1426 {SI_TIMER, "SI_TIMER"},
1427 {SI_MESGQ, "SI_MESGQ"},
1428 {SI_ASYNCIO, "SI_ASYNCIO"},
1433 printsiginfo(tcp, si)
1437 tprintf("{si_signo=");
1438 printsignal(si->si_signo);
1439 tprintf(", si_errno=%d, si_code=", si->si_errno);
1440 switch(si->si_signo)
1443 if (!printflags(sigill_flags, si->si_code))
1444 tprintf("%d /* ILL_??? */", si->si_code);
1445 tprintf(", si_addr=%lx",
1446 (unsigned long) si->_sifields._sigfault.si_addr);
1449 if (!printflags(sigfpe_flags, si->si_code))
1450 tprintf("%d /* FPE_??? */", si->si_code);
1451 tprintf(", si_addr=%lx",
1452 (unsigned long) si->_sifields._sigfault.si_addr);
1455 if (!printflags(sigsegv_flags, si->si_code))
1456 tprintf("%d /* SEGV_??? */", si->si_code);
1457 tprintf(", si_addr=%lx",
1458 (unsigned long) si->_sifields._sigfault.si_addr);
1461 if (!printflags(sigbus_flags, si->si_code))
1462 tprintf("%d /* BUS_??? */", si->si_code);
1463 tprintf(", si_addr=%lx",
1464 (unsigned long) si->_sifields._sigfault.si_addr);
1467 if (!printflags(sigtrap_flags, si->si_code))
1468 tprintf("%d /* TRAP_??? */", si->si_code);
1471 if (!printflags(sigchld_flags, si->si_code))
1472 tprintf("%d /* CLD_??? */", si->si_code);
1476 tprintf(", si_pid=%d, si_uid=%d, si_status=%d, si_utime=%lu, si_stime=%lu",
1477 si->_sifields._kill.si_pid,
1478 si->_sifields._kill.si_uid,
1479 si->_sifields._sigchld.si_status,
1480 si->_sifields._sigchld.si_utime,
1481 si->_sifields._sigchld.si_stime);
1484 if (!printflags(sigpoll_flags, si->si_code))
1485 tprintf("%d /* POLL_??? */", si->si_code);
1486 if (si->si_code == POLL_IN
1487 || si->si_code == POLL_OUT
1488 || si->si_code == POLL_MSG)
1489 tprintf(", si_bind=%lu, si_fd=%d",
1490 (unsigned long) si->_sifields._sigpoll.si_band,
1491 si->_sifields._sigpoll.si_fd);
1494 if (!printflags(siginfo_flags, si->si_code))
1495 tprintf("%d /* SI_??? */", si->si_code);
1496 tprintf(", si_pid=%lu, si_uid=%lu, si_value={",
1497 (unsigned long) si->_sifields._rt.si_pid,
1498 (unsigned long) si->_sifields._rt.si_uid);
1502 tprintf("sival_int=%u, sival_ptr=%#lx",
1503 si->_sifields._rt.si_sigval.sival_int,
1504 (unsigned long) si->_sifields._rt.si_sigval.sival_ptr);
1513 sys_rt_sigqueueinfo(tcp)
1516 if (entering(tcp)) {
1518 tprintf("%lu, ", tcp->u_arg[0]);
1519 printsignal(tcp->u_arg[1]);
1521 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1522 tprintf("%#lx", tcp->u_arg[2]);
1529 int sys_rt_sigtimedwait(tcp)
1532 if (entering(tcp)) {
1535 if (copy_sigset_len(tcp, tcp->u_arg[0],
1536 &sigset, tcp->u_arg[3]) < 0)
1539 printsigmask(sigset, 1);
1544 tprintf("%#lx", tcp->u_arg[0]);
1547 if (umove(tcp, tcp->u_arg[1], &si) < 0)
1548 tprintf("%#lx", tcp->u_arg[1]);
1552 tprintf(", %#lx", tcp->u_arg[2]);
1553 tprintf(", %d", (int) tcp->u_arg[3]);