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 HAVE_LINUX_PTRACE_H
44 #include <linux/ptrace.h>
49 #ifndef PTRACE_PEEKUSR
50 # define PTRACE_PEEKUSR PTRACE_PEEKUSER
52 #ifndef PTRACE_POKEUSR
53 # define PTRACE_POKEUSR PTRACE_POKEUSER
59 #ifdef HAVE_ASM_SIGCONTEXT_H
60 #include <asm/sigcontext.h>
68 #else /* !HAVE_ASM_SIGCONTEXT_H */
70 struct sigcontext_struct {
71 unsigned short gs, __gsh;
72 unsigned short fs, __fsh;
73 unsigned short es, __esh;
74 unsigned short ds, __dsh;
86 unsigned short cs, __csh;
88 unsigned long esp_at_signal;
89 unsigned short ss, __ssh;
91 unsigned long oldmask;
98 unsigned long sc_mask;
104 unsigned short sc_sr;
106 unsigned short sc_formatvec;
110 #endif /* !HAVE_ASM_SIGCONTEXT_H */
120 char *signalent0[] = {
121 #include "signalent.h"
123 int nsignals0 = sizeof signalent0 / sizeof signalent0[0];
125 #if SUPPORTED_PERSONALITIES >= 2
126 char *signalent1[] = {
127 #include "signalent1.h"
129 int nsignals1 = sizeof signalent1 / sizeof signalent1[0];
130 #endif /* SUPPORTED_PERSONALITIES >= 2 */
132 #if SUPPORTED_PERSONALITIES >= 3
133 char *signalent2[] = {
134 #include "signalent2.h"
136 int nsignals2 = sizeof signalent2 / sizeof signalent2[0];
137 #endif /* SUPPORTED_PERSONALITIES >= 3 */
144 static struct xlat sigvec_flags[] = {
145 { SV_ONSTACK, "SV_ONSTACK" },
146 { SV_INTERRUPT, "SV_INTERRUPT" },
147 { SV_RESETHAND, "SV_RESETHAND" },
148 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
154 #ifdef HAVE_SIGACTION
156 static struct xlat sigact_flags[] = {
158 { SA_STACK, "SA_STACK" },
161 { SA_RESTART, "SA_RESTART" },
164 { SA_INTERRUPT, "SA_INTERRUPT" },
167 { SA_NOMASK, "SA_NOMASK" },
170 { SA_ONESHOT, "SA_ONESHOT" },
173 { SA_SIGINFO, "SA_SIGINFO" },
176 { SA_RESETHAND, "SA_RESETHAND" },
179 { SA_ONSTACK, "SA_ONSTACK" },
182 { SA_NODEFER, "SA_NODEFER" },
185 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
188 { SA_NOCLDWAIT, "SA_NOCLDWAIT" },
191 { _SA_BSDCALL, "_SA_BSDCALL" },
196 static struct xlat sigprocmaskcmds[] = {
197 { SIG_BLOCK, "SIG_BLOCK" },
198 { SIG_UNBLOCK, "SIG_UNBLOCK" },
199 { SIG_SETMASK, "SIG_SETMASK" },
201 { SIG_SETMASK32,"SIG_SETMASK32" },
206 #endif /* HAVE_SIGACTION */
208 /* Anonymous realtime signals. */
209 /* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
210 constant. This is what we want. Otherwise, just use SIGRTMIN. */
213 #define __SIGRTMIN SIGRTMIN
214 #define __SIGRTMAX SIGRTMAX /* likewise */
223 if (sig < nsignals) {
224 return signalent[sig];
226 } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) {
227 sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN));
229 #endif /* SIGRTMIN */
231 sprintf(buf, "%d", sig);
248 copy_sigset_len(tcp, addr, s, len)
254 if (len > sizeof(*s))
257 if (umoven(tcp, addr, len, (char *)s) < 0)
263 /* Original sigset is unsigned long */
264 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long))
266 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t))
270 sprintsigmask(s, mask, rt)
273 int rt; /* set might include realtime sigs */
278 static char outstr[256];
281 s = outstr + strlen(outstr);
286 maxsigs = __SIGRTMAX; /* instead */
288 for (i = 1; i < maxsigs; i++) {
289 if (sigismember(mask, i) == 1)
292 if (nsigs >= nsignals * 2 / 3) {
294 for (i = 1; i < maxsigs; i++) {
295 switch (sigismember(mask, i)) {
307 for (i = 1; i < maxsigs; i++) {
308 if (sigismember(mask, i) == 1) {
309 sprintf(s, format, signame(i) + 3); s += strlen(s);
319 printsigmask(mask, rt)
323 tprintf("%s", sprintsigmask("", mask, rt));
330 tprintf(signame(nr));
334 * Check process TCP for the disposition of signal SIG.
335 * Return 1 if the process would somehow manage to survive signal SIG,
336 * else return 0. This routine will never be called with SIGKILL.
339 sigishandled(tcp, sig)
349 unsigned int signalled, blocked, ignored, caught;
351 /* This is incredibly costly but it's worth it. */
352 sprintf(sname, "/proc/%d/stat", tcp->pid);
353 if ((sfd = open(sname, O_RDONLY)) == -1) {
357 i = read(sfd, buf, 1024);
361 * Skip the extraneous fields. This loses if the
362 * command name has any spaces in it. So be it.
364 for (i = 0, s = buf; i < 30; i++) {
365 while (*++s != ' ') {
370 if (sscanf(s, "%u%u%u%u",
371 &signalled, &blocked, &ignored, &caught) != 4) {
372 fprintf(stderr, "/proc/pid/stat format error\n");
376 fprintf(stderr, "sigs: %08x %08x %08x %08x\n",
377 signalled, blocked, ignored, caught);
379 if ((ignored & sigmask(sig)) || (caught & sigmask(sig)))
386 if (upeek(tcp->pid, uoff(u_signal[0]) + sig*sizeof(u_signal),
387 (long *) &u_signal) < 0) {
390 if (u_signal != SIG_DFL)
396 * Since procfs doesn't interfere with wait I think it is safe
397 * to punt on this question. If not, the information is there.
409 #if defined(SIGURG) && SIGURG != SIGIO
413 /* Gloria Gaynor says ... */
432 printsignal(tcp->u_arg[0]);
434 addr = tcp->u_arg[1];
436 addr = tcp->u_arg[2];
440 else if (!verbose(tcp))
441 tprintf("%#lx", addr);
442 else if (umove(tcp, addr, &sv) < 0)
445 switch ((int) sv.sv_handler) {
447 tprintf("{SIG_ERR}");
450 tprintf("{SIG_DFL}");
453 if (tcp->u_arg[0] == SIGTRAP) {
454 tcp->flags |= TCB_SIGTRAPPED;
455 kill(tcp->pid, SIGSTOP);
457 tprintf("{SIG_IGN}");
460 if (tcp->u_arg[0] == SIGTRAP) {
461 tcp->flags |= TCB_SIGTRAPPED;
462 kill(tcp->pid, SIGSTOP);
467 if (tcp->u_arg[0] == SIGTRAP) {
468 tcp->flags |= TCB_SIGTRAPPED;
469 kill(tcp->pid, SIGSTOP);
471 tprintf("{%#lx, ", (unsigned long) sv.sv_handler);
472 printsigmask(&sv.sv_mask, 0);
474 if (!printflags(sigvec_flags, sv.sv_flags))
488 if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */
490 long_to_sigset(tcp->u_arg[0], &sigm);
491 printsigmask(&sigm, 0);
504 addr = tcp->u_arg[0];
506 addr = tcp->u_arg[1];
509 else if (umove(tcp, addr, &ss) < 0)
510 tprintf("%#lx", addr);
512 tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp);
513 tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO");
537 long_to_sigset(tcp->u_arg[0], &sigm);
538 printsigmask(&sigm, 0);
539 if ((tcp->u_arg[0] & sigmask(SIGTRAP))) {
540 /* Mark attempt to block SIGTRAP */
541 tcp->flags |= TCB_SIGTRAPPED;
542 /* Send unblockable signal */
543 kill(tcp->pid, SIGSTOP);
546 else if (!syserror(tcp)) {
548 long_to_sigset(tcp->u_rval, &sigm);
549 tcp->auxstr = sprintsigmask("old mask ", &sigm, 0);
551 return RVAL_HEX | RVAL_STR;
560 return sys_sigsetmask(tcp);
565 #ifdef HAVE_SIGACTION
568 struct old_sigaction {
569 __sighandler_t __sa_handler;
570 unsigned long sa_mask;
571 unsigned long sa_flags;
572 void (*sa_restorer)(void);
574 #define SA_HANDLER __sa_handler
578 #define SA_HANDLER sa_handler
588 struct old_sigaction sa;
595 printsignal(tcp->u_arg[0]);
597 addr = tcp->u_arg[1];
599 addr = tcp->u_arg[2];
602 else if (!verbose(tcp))
603 tprintf("%#lx", addr);
604 else if (umove(tcp, addr, &sa) < 0)
607 switch ((long) sa.SA_HANDLER) {
609 tprintf("{SIG_ERR}");
612 tprintf("{SIG_DFL}");
616 if (tcp->u_arg[0] == SIGTRAP) {
617 tcp->flags |= TCB_SIGTRAPPED;
618 kill(tcp->pid, SIGSTOP);
621 tprintf("{SIG_IGN}");
625 if (tcp->u_arg[0] == SIGTRAP) {
626 tcp->flags |= TCB_SIGTRAPPED;
627 kill(tcp->pid, SIGSTOP);
630 tprintf("{%#lx, ", (long) sa.SA_HANDLER);
631 long_to_sigset(sa.sa_mask, &sigset);
632 printsigmask(&sigset, 0);
634 if (!printflags(sigact_flags, sa.sa_flags))
643 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
653 printsignal(tcp->u_arg[0]);
654 switch (tcp->u_arg[1]) {
663 if (tcp->u_arg[0] == SIGTRAP) {
664 tcp->flags |= TCB_SIGTRAPPED;
665 kill(tcp->pid, SIGSTOP);
672 if (tcp->u_arg[0] == SIGTRAP) {
673 tcp->flags |= TCB_SIGTRAPPED;
674 kill(tcp->pid, SIGSTOP);
677 tprintf("%#lx", tcp->u_arg[1]);
683 #endif /* HAVE_SIGACTION */
693 struct sigcontext_struct sc;
697 if (upeek(tcp->pid, 4*UESP, &esp) < 0)
699 if (umove(tcp, esp, &sc) < 0)
702 tcp->u_arg[1] = sc.oldmask;
706 long_to_sigset(tcp->u_arg[1], &sigm);
707 tcp->u_rval = tcp->u_error = 0;
708 if (tcp->u_arg[0] == 0)
710 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
711 return RVAL_NONE | RVAL_STR;
717 struct sigcontext_struct sc;
721 if (upeek(tcp->pid, 4*PT_R1, &esp) < 0)
723 if (umove(tcp, esp, &sc) < 0)
726 tcp->u_arg[1] = sc.oldmask;
730 long_to_sigset(tcp->u_arg[1], &sigm);
731 tcp->u_rval = tcp->u_error = 0;
732 if (tcp->u_arg[0] == 0)
734 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
735 return RVAL_NONE | RVAL_STR;
741 struct sigcontext sc;
745 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
747 if (umove(tcp, usp, &sc) < 0)
750 tcp->u_arg[1] = sc.sc_mask;
754 long_to_sigset(tcp->u_arg[1], &sigm);
755 tcp->u_rval = tcp->u_error = 0;
756 if (tcp->u_arg[0] == 0)
758 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
759 return RVAL_NONE | RVAL_STR;
765 struct sigcontext_struct sc;
769 if (upeek(tcp->pid, REG_FP, &fp) < 0)
771 if (umove(tcp, fp, &sc) < 0)
774 tcp->u_arg[1] = sc.sc_mask;
778 long_to_sigset(tcp->u_arg[1], &sigm);
779 tcp->u_rval = tcp->u_error = 0;
780 if (tcp->u_arg[0] == 0)
782 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
783 return RVAL_NONE | RVAL_STR;
792 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
793 perror("sigreturn: PTRACE_GETREGS ");
799 if(umove(tcp, i1, &si) < 0) {
800 perror("sigreturn: umove ");
804 tcp->u_arg[1] = si.si_mask;
807 long_to_sigset(tcp->u_arg[1], &sigm);
808 tcp->u_rval = tcp->u_error = 0;
809 if(tcp->u_arg[0] == 0)
811 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
812 return RVAL_NONE | RVAL_STR;
818 #endif /* !POWERPC */
828 long_to_sigset(tcp->u_rval, &sigm);
829 tcp->auxstr = sprintsigmask("mask ", &sigm, 0);
831 return RVAL_HEX | RVAL_STR;
840 long_to_sigset(tcp->u_arg[2], &sigm);
842 /* first two are not really arguments, but print them anyway */
843 /* nevermind, they are an anachronism now, too bad... */
844 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
846 printsigmask(&sigm, 0);
862 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
865 printsigmask(sigset, 0);
869 static struct xlat ucontext_flags[] = {
870 { UC_SIGMASK, "UC_SIGMASK" },
871 { UC_STACK, "UC_STACK" },
872 { UC_CPU, "UC_CPU" },
874 { UC_FPU, "UC_FPU" },
877 { UC_INTR, "UC_INTR" },
884 #if defined SVR4 || defined LINUX
885 #if defined LINUX && !defined SS_ONSTACK
888 #if __GLIBC_MINOR__ == 0
898 static struct xlat sigaltstack_flags[] = {
899 { SS_ONSTACK, "SS_ONSTACK" },
900 { SS_DISABLE, "SS_DISABLE" },
907 printcontext(tcp, ucp)
913 tprintf("uc_flags=");
914 if (!printflags(ucontext_flags, ucp->uc_flags))
916 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
918 tprintf("uc_sigmask=");
919 printsigmask(ucp->uc_sigmask, 0);
921 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
922 (unsigned long) ucp->uc_stack.ss_sp,
923 ucp->uc_stack.ss_size);
924 if (!printflags(sigaltstack_flags, ucp->uc_stack.ss_flags))
940 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
943 printcontext(tcp, &uc);
957 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
960 printcontext(tcp, &uc);
963 tcp->u_rval = tcp->u_error = 0;
964 if (tcp->u_arg[0] == 0)
976 print_stack_t(tcp, addr)
981 if (umove(tcp, addr, &ss) < 0)
983 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
984 if (!printflags(sigaltstack_flags, ss.ss_flags))
986 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
995 if (tcp->u_arg[0] == 0)
997 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
1002 if (tcp->u_arg[1] == 0)
1004 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
1011 #ifdef HAVE_SIGACTION
1014 sys_sigprocmask(tcp)
1018 if (entering(tcp)) {
1019 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1021 printsigmask(tcp->u_arg[1], 0);
1023 else if (!syserror(tcp)) {
1024 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0);
1025 return RVAL_HEX | RVAL_STR;
1030 if (entering(tcp)) {
1032 if (tcp->u_arg[0] == 0)
1036 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1040 else if (copy_sigset(tcp, tcp->u_arg[1], &sigset) < 0)
1041 tprintf("%#lx, ", tcp->u_arg[1]);
1043 printsigmask(&sigset, 0);
1050 else if (syserror(tcp))
1051 tprintf("%#lx", tcp->u_arg[2]);
1052 else if (copy_sigset(tcp, tcp->u_arg[2], &sigset) < 0)
1055 printsigmask(&sigset, 0);
1061 #endif /* HAVE_SIGACTION */
1067 if (entering(tcp)) {
1068 tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1]));
1077 return sys_kill(tcp);
1088 tprintf("%#lx", tcp->u_arg[0]);
1089 else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1092 printsigmask(sigset, 0);
1100 sys_rt_sigprocmask(tcp)
1105 /* Note: arg[3] is the length of the sigset. */
1106 if (entering(tcp)) {
1107 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1111 else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0)
1112 tprintf("%#lx, ", tcp->u_arg[1]);
1114 printsigmask(&sigset, 1);
1122 else if (syserror(tcp))
1123 tprintf("%#lx", tcp->u_arg[2]);
1124 else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0)
1127 printsigmask(&sigset, 1);
1128 tprintf(", %lu", tcp->u_arg[3]);
1133 #if __GLIBC_MINOR__ < 1
1134 /* Type for data associated with a signal. */
1135 typedef union sigval
1141 # define __SI_MAX_SIZE 128
1142 # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
1144 typedef struct siginfo
1146 int si_signo; /* Signal number. */
1147 int si_errno; /* If non-zero, an errno value associated with
1148 this signal, as defined in <errno.h>. */
1149 int si_code; /* Signal code. */
1153 int _pad[__SI_PAD_SIZE];
1158 __pid_t si_pid; /* Sending process ID. */
1159 __uid_t si_uid; /* Real user ID of sending process. */
1162 /* POSIX.1b timers. */
1165 unsigned int _timer1;
1166 unsigned int _timer2;
1169 /* POSIX.1b signals. */
1172 __pid_t si_pid; /* Sending process ID. */
1173 __uid_t si_uid; /* Real user ID of sending process. */
1174 sigval_t si_sigval; /* Signal value. */
1180 __pid_t si_pid; /* Which child. */
1181 int si_status; /* Exit value or signal. */
1186 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
1189 void *si_addr; /* Faulting insn/memory ref. */
1195 int si_band; /* Band event for SIGPOLL. */
1202 /* Structure describing the action to be taken when a signal arrives. */
1203 struct new_sigaction
1207 __sighandler_t __sa_handler;
1208 void (*__sa_sigaction) (int, siginfo_t *, void *);
1210 __sigaction_handler;
1211 unsigned long sa_flags;
1212 void (*sa_restorer) (void);
1213 unsigned long int sa_mask[2];
1218 sys_rt_sigaction(tcp)
1221 struct new_sigaction sa;
1225 if (entering(tcp)) {
1226 printsignal(tcp->u_arg[0]);
1228 addr = tcp->u_arg[1];
1230 addr = tcp->u_arg[2];
1233 else if (!verbose(tcp))
1234 tprintf("%#lx", addr);
1235 else if (umove(tcp, addr, &sa) < 0)
1238 switch ((long) sa.__sigaction_handler.__sa_handler) {
1239 case (long) SIG_ERR:
1240 tprintf("{SIG_ERR}");
1242 case (long) SIG_DFL:
1243 tprintf("{SIG_DFL}");
1245 case (long) SIG_IGN:
1246 tprintf("{SIG_IGN}");
1250 (long) sa.__sigaction_handler.__sa_handler);
1251 sigemptyset(&sigset);
1253 if (tcp->u_arg[4] <= sizeof(sigset))
1254 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
1256 if (tcp->u_arg[3] <= sizeof(sigset))
1257 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
1260 memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
1261 printsigmask(&sigset, 1);
1263 if (!printflags(sigact_flags, sa.sa_flags))
1272 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
1273 #elif defined(ALPHA)
1274 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
1276 tprintf(", %lu", addr = tcp->u_arg[3]);
1282 sys_rt_sigpending(tcp)
1289 tprintf("%#lx", tcp->u_arg[0]);
1290 else if (copy_sigset_len(tcp, tcp->u_arg[0],
1291 &sigset, tcp->u_arg[1]) < 0)
1294 printsigmask(sigset, 1);
1299 sys_rt_sigsuspend(tcp)
1302 if (entering(tcp)) {
1304 if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0)
1307 printsigmask(&sigm, 1);
1312 #define ILL_ILLOPC 1 /* illegal opcode */
1313 #define ILL_ILLOPN 2 /* illegal operand */
1314 #define ILL_ILLADR 3 /* illegal addressing mode */
1315 #define ILL_ILLTRP 4 /* illegal trap */
1316 #define ILL_PRVOPC 5 /* privileged opcode */
1317 #define ILL_PRVREG 6 /* privileged register */
1318 #define ILL_COPROC 7 /* coprocessor error */
1319 #define ILL_BADSTK 8 /* internal stack error */
1320 #define FPE_INTDIV 1 /* integer divide by zero */
1321 #define FPE_INTOVF 2 /* integer overflow */
1322 #define FPE_FLTDIV 3 /* floating point divide by zero */
1323 #define FPE_FLTOVF 4 /* floating point overflow */
1324 #define FPE_FLTUND 5 /* floating point underflow */
1325 #define FPE_FLTRES 6 /* floating point inexact result */
1326 #define FPE_FLTINV 7 /* floating point invalid operation */
1327 #define FPE_FLTSUB 8 /* subscript out of range */
1328 #define SEGV_MAPERR 1 /* address not mapped to object */
1329 #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
1330 #define BUS_ADRALN 1 /* invalid address alignment */
1331 #define BUS_ADRERR 2 /* non-existant physical address */
1332 #define BUS_OBJERR 3 /* object specific hardware error */
1333 #define TRAP_BRKPT 1 /* process breakpoint */
1334 #define TRAP_TRACE 2 /* process trace trap */
1335 #define CLD_EXITED 1 /* child has exited */
1336 #define CLD_KILLED 2 /* child was killed */
1337 #define CLD_DUMPED 3 /* child terminated abnormally */
1338 #define CLD_TRAPPED 4 /* traced child has trapped */
1339 #define CLD_STOPPED 5 /* child has stopped */
1340 #define CLD_CONTINUED 6 /* stopped child has continued */
1341 #define POLL_IN 1 /* data input available */
1342 #define POLL_OUT 2 /* output buffers available */
1343 #define POLL_MSG 3 /* input message available */
1344 #define POLL_ERR 4 /* i/o error */
1345 #define POLL_PRI 5 /* high priority input available */
1346 #define POLL_HUP 6 /* device disconnected */
1347 #define SI_USER 0 /* sent by kill, sigsend, raise */
1348 #define SI_QUEUE -1 /* sent by sigqueue */
1349 #define SI_TIMER -2 /* sent by timer expiration */
1350 #define SI_MESGQ -3 /* sent by real time mesq state change */
1351 #define SI_ASYNCIO -4 /* sent by AIO completion */
1366 static struct xlat sigill_flags[] = {
1367 {ILL_ILLOPC, "ILL_ILLOPC"},
1368 {ILL_ILLOPN, "ILL_ILLOPN"},
1369 {ILL_ILLADR, "ILL_ILLADR"},
1370 {ILL_ILLTRP, "ILL_ILLTRP"},
1371 {ILL_PRVOPC, "ILL_PRVOPC"},
1372 {ILL_PRVREG, "ILL_PRVREG"},
1373 {ILL_COPROC, "ILL_COPROC"},
1374 {ILL_BADSTK, "ILL_BADSTK"},
1378 static struct xlat sigfpe_flags[] = {
1379 {FPE_INTDIV, "FPE_INTDIV"},
1380 {FPE_INTOVF, "FPE_INTOVF"},
1381 {FPE_FLTDIV, "FPE_FLTDIV"},
1382 {FPE_FLTOVF, "FPE_FLTOVF"},
1383 {FPE_FLTUND, "FPE_FLTUND"},
1384 {FPE_FLTRES, "FPE_FLTRES"},
1385 {FPE_FLTINV, "FPE_FLTINV"},
1386 {FPE_FLTSUB, "FPE_FLTSUB"},
1390 static struct xlat sigsegv_flags[] = {
1391 {SEGV_MAPERR, "SEGV_MAPERR"},
1392 {SEGV_ACCERR, "SEGV_ACCERR"},
1396 static struct xlat sigbus_flags[] = {
1397 {BUS_ADRALN, "BUS_ADRALN"},
1398 {BUS_ADRERR, "BUS_ADRERR"},
1399 {BUS_OBJERR, "BUS_OBJERR"},
1403 static struct xlat sigtrap_flags[] = {
1404 {TRAP_BRKPT, "TRAP_BRKPT"},
1405 {TRAP_TRACE, "TRAP_TRACE"},
1409 static struct xlat sigchld_flags[] = {
1410 {CLD_EXITED, "CLD_EXITED"},
1411 {CLD_KILLED, "CLD_KILLED"},
1412 {CLD_DUMPED, "CLD_DUMPED"},
1413 {CLD_TRAPPED, "CLD_TRAPPED"},
1414 {CLD_STOPPED, "CLD_STOPPED"},
1415 {CLD_CONTINUED, "CLD_CONTINUED"},
1419 static struct xlat sigpoll_flags[] = {
1420 {POLL_IN, "POLL_IN"},
1421 {POLL_OUT, "POLL_OUT"},
1422 {POLL_MSG, "POLL_MSG"},
1423 {POLL_ERR, "POLL_ERR"},
1424 {POLL_PRI, "POLL_PRI"},
1425 {POLL_HUP, "POLL_HUP"},
1429 static struct xlat siginfo_flags[] = {
1430 {SI_USER, "SI_USER"},
1431 {SI_QUEUE, "SI_QUEUE"},
1432 {SI_TIMER, "SI_TIMER"},
1433 {SI_MESGQ, "SI_MESGQ"},
1434 {SI_ASYNCIO, "SI_ASYNCIO"},
1439 printsiginfo(tcp, si)
1443 tprintf("{si_signo=");
1444 printsignal(si->si_signo);
1445 tprintf(", si_errno=%d, si_code=", si->si_errno);
1446 switch(si->si_signo)
1449 if (!printflags(sigill_flags, si->si_code))
1450 tprintf("%d /* ILL_??? */", si->si_code);
1451 tprintf(", si_addr=%lx",
1452 (unsigned long) si->_sifields._sigfault.si_addr);
1455 if (!printflags(sigfpe_flags, si->si_code))
1456 tprintf("%d /* FPE_??? */", si->si_code);
1457 tprintf(", si_addr=%lx",
1458 (unsigned long) si->_sifields._sigfault.si_addr);
1461 if (!printflags(sigsegv_flags, si->si_code))
1462 tprintf("%d /* SEGV_??? */", si->si_code);
1463 tprintf(", si_addr=%lx",
1464 (unsigned long) si->_sifields._sigfault.si_addr);
1467 if (!printflags(sigbus_flags, si->si_code))
1468 tprintf("%d /* BUS_??? */", si->si_code);
1469 tprintf(", si_addr=%lx",
1470 (unsigned long) si->_sifields._sigfault.si_addr);
1473 if (!printflags(sigtrap_flags, si->si_code))
1474 tprintf("%d /* TRAP_??? */", si->si_code);
1477 if (!printflags(sigchld_flags, si->si_code))
1478 tprintf("%d /* CLD_??? */", si->si_code);
1482 tprintf(", si_pid=%d, si_uid=%d, si_status=%d, si_utime=%lu, si_stime=%lu",
1483 si->_sifields._kill.si_pid,
1484 si->_sifields._kill.si_uid,
1485 si->_sifields._sigchld.si_status,
1486 si->_sifields._sigchld.si_utime,
1487 si->_sifields._sigchld.si_stime);
1490 if (!printflags(sigpoll_flags, si->si_code))
1491 tprintf("%d /* POLL_??? */", si->si_code);
1492 if (si->si_code == POLL_IN
1493 || si->si_code == POLL_OUT
1494 || si->si_code == POLL_MSG)
1495 tprintf(", si_bind=%lu, si_fd=%d",
1496 (unsigned long) si->_sifields._sigpoll.si_band,
1497 si->_sifields._sigpoll.si_fd);
1500 if (!printflags(siginfo_flags, si->si_code))
1501 tprintf("%d /* SI_??? */", si->si_code);
1502 tprintf(", si_pid=%lu, si_uid=%lu, si_value={",
1503 (unsigned long) si->_sifields._rt.si_pid,
1504 (unsigned long) si->_sifields._rt.si_uid);
1508 tprintf("sival_int=%u, sival_ptr=%#lx",
1509 si->_sifields._rt.si_sigval.sival_int,
1510 (unsigned long) si->_sifields._rt.si_sigval.sival_ptr);
1519 sys_rt_sigqueueinfo(tcp)
1522 if (entering(tcp)) {
1524 tprintf("%lu, ", tcp->u_arg[0]);
1525 printsignal(tcp->u_arg[1]);
1527 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1528 tprintf("%#lx", tcp->u_arg[2]);
1535 int sys_rt_sigtimedwait(tcp)
1538 if (entering(tcp)) {
1541 if (copy_sigset_len(tcp, tcp->u_arg[0],
1542 &sigset, tcp->u_arg[3]) < 0)
1545 printsigmask(sigset, 1);
1550 tprintf("%#lx", tcp->u_arg[0]);
1553 if (umove(tcp, tcp->u_arg[1], &si) < 0)
1554 tprintf("%#lx", tcp->u_arg[1]);
1558 tprintf(", %#lx", tcp->u_arg[2]);
1559 tprintf(", %d", (int) tcp->u_arg[3]);