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.
34 /* ugly hack to make header file do what I want - davidw */
36 #undef __USE_POSIX199309
42 #if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 && (defined(I386) || defined(M68K))
47 #include <sys/ucontext.h>
51 #include <linux/ptrace.h>
52 #ifdef HAVE_ASM_SIGCONTEXT_H
53 #include <asm/sigcontext.h>
56 struct pt_regs si_regs;
60 #else /* !HAVE_ASM_SIGCONTEXT_H */
62 struct sigcontext_struct {
63 unsigned short gs, __gsh;
64 unsigned short fs, __fsh;
65 unsigned short es, __esh;
66 unsigned short ds, __dsh;
78 unsigned short cs, __csh;
80 unsigned long esp_at_signal;
81 unsigned short ss, __ssh;
83 unsigned long oldmask;
88 struct sigcontext_struct
90 unsigned long sc_mask;
98 unsigned short sc_formatvec;
102 #endif /* !HAVE_ASM_SIGCONTEXT_H */
112 char *signalent0[] = {
113 #include "signalent.h"
115 int nsignals0 = sizeof signalent0 / sizeof signalent0[0];
117 #if SUPPORTED_PERSONALITIES >= 2
118 char *signalent1[] = {
119 #include "signalent1.h"
121 int nsignals1 = sizeof signalent1 / sizeof signalent1[0];
122 #endif /* SUPPORTED_PERSONALITIES >= 2 */
124 #if SUPPORTED_PERSONALITIES >= 3
125 char *signalent2[] = {
126 #include "signalent2.h"
128 int nsignals2 = sizeof signalent2 / sizeof signalent2[0];
129 #endif /* SUPPORTED_PERSONALITIES >= 3 */
136 static struct xlat sigvec_flags[] = {
137 { SV_ONSTACK, "SV_ONSTACK" },
138 { SV_INTERRUPT, "SV_INTERRUPT" },
139 { SV_RESETHAND, "SV_RESETHAND" },
140 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
146 #ifdef HAVE_SIGACTION
148 static struct xlat sigact_flags[] = {
150 { SA_STACK, "SA_STACK" },
153 { SA_RESTART, "SA_RESTART" },
156 { SA_INTERRUPT, "SA_INTERRUPT" },
159 { SA_NOMASK, "SA_NOMASK" },
162 { SA_ONESHOT, "SA_ONESHOT" },
165 { SA_SIGINFO, "SA_SIGINFO" },
168 { SA_RESETHAND, "SA_RESETHAND" },
171 { SA_ONSTACK, "SA_ONSTACK" },
174 { SA_NODEFER, "SA_NODEFER" },
177 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
180 { SA_NOCLDWAIT, "SA_NOCLDWAIT" },
183 { _SA_BSDCALL, "_SA_BSDCALL" },
188 static struct xlat sigprocmaskcmds[] = {
189 { SIG_BLOCK, "SIG_BLOCK" },
190 { SIG_UNBLOCK, "SIG_UNBLOCK" },
191 { SIG_SETMASK, "SIG_SETMASK" },
193 { SIG_SETMASK32,"SIG_SETMASK32" },
198 #endif /* HAVE_SIGACTION */
200 /* Anonymous realtime signals. */
201 /* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
202 constant. This is what we want. Otherwise, just use SIGRTMIN. */
205 #define __SIGRTMIN SIGRTMIN
206 #define __SIGRTMAX SIGRTMAX /* likewise */
215 if (sig < nsignals) {
216 return signalent[sig];
218 } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) {
219 sprintf(buf, "SIGRT_%d", sig);
221 #endif /* SIGRTMIN */
223 sprintf(buf, "%d", sig);
229 sprintsigmask(s, mask)
235 static char outstr[256];
238 s = outstr + strlen(outstr);
240 for (i = 1; i < nsignals; i++) {
241 if (sigismember(mask, i) == 1)
244 if (nsigs >= nsignals * 2 / 3) {
246 for (i = 1; i < nsignals; i++) {
247 switch (sigismember(mask, i)) {
259 for (i = 1; i < nsignals; i++) {
260 if (sigismember(mask, i) == 1) {
261 sprintf(s, format, signame(i) + 3); s += strlen(s);
274 tprintf("%s", sprintsigmask("", mask));
281 tprintf(signame(nr));
285 * Check process TCP for the disposition of signal SIG.
286 * Return 1 if the process would somehow manage to survive signal SIG,
287 * else return 0. This routine will never be called with SIGKILL.
290 sigishandled(tcp, sig)
300 int signalled, blocked, ignored, caught;
302 /* This is incredibly costly but it's worth it. */
303 sprintf(sname, "/proc/%d/stat", tcp->pid);
304 if ((sfd = open(sname, O_RDONLY)) == -1) {
308 i = read(sfd, buf, 1024);
312 * Skip the extraneous fields. This loses if the
313 * command name has any spaces in it. So be it.
315 for (i = 0, s = buf; i < 30; i++) {
316 while (*++s != ' ') {
321 if (sscanf(s, "%d%d%d%d",
322 &signalled, &blocked, &ignored, &caught) != 4) {
323 fprintf(stderr, "/proc/pid/stat format error\n");
327 fprintf(stderr, "sigs: %08x %08x %08x %08x\n",
328 signalled, blocked, ignored, caught);
330 if ((ignored & sigmask(sig)) || (caught & sigmask(sig)))
337 if (upeek(tcp->pid, uoff(u_signal[0]) + sig*sizeof(u_signal),
338 (long *) &u_signal) < 0) {
341 if (u_signal != SIG_DFL)
347 * Since procfs doesn't interfere with wait I think it is safe
348 * to punt on this question. If not, the information is there.
360 #if defined(SIGURG) && SIGURG != SIGIO
364 /* Gloria Gaynor says ... */
383 printsignal(tcp->u_arg[0]);
385 addr = tcp->u_arg[1];
387 addr = tcp->u_arg[2];
391 else if (!verbose(tcp))
392 tprintf("%#lx", addr);
393 else if (umove(tcp, addr, &sv) < 0)
396 switch ((int) sv.sv_handler) {
398 tprintf("{SIG_ERR}");
401 tprintf("{SIG_DFL}");
404 if (tcp->u_arg[0] == SIGTRAP) {
405 tcp->flags |= TCB_SIGTRAPPED;
406 kill(tcp->pid, SIGSTOP);
408 tprintf("{SIG_IGN}");
411 if (tcp->u_arg[0] == SIGTRAP) {
412 tcp->flags |= TCB_SIGTRAPPED;
413 kill(tcp->pid, SIGSTOP);
418 if (tcp->u_arg[0] == SIGTRAP) {
419 tcp->flags |= TCB_SIGTRAPPED;
420 kill(tcp->pid, SIGSTOP);
422 tprintf("{%#lx, ", (unsigned long) sv.sv_handler);
423 printsigmask(&sv.sv_mask);
425 if (!printflags(sigvec_flags, sv.sv_flags))
439 if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */
440 sigset_t sigm = tcp->u_arg[0];
454 addr = tcp->u_arg[0];
456 addr = tcp->u_arg[1];
459 else if (umove(tcp, addr, &ss) < 0)
460 tprintf("%#lx", addr);
462 tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp);
463 tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO");
489 sigm.__val[0] = tcp->u_arg[0];
491 sigset_t sigm = tcp->u_arg[0];
494 if ((tcp->u_arg[0] & sigmask(SIGTRAP))) {
495 /* Mark attempt to block SIGTRAP */
496 tcp->flags |= TCB_SIGTRAPPED;
497 /* Send unblockable signal */
498 kill(tcp->pid, SIGSTOP);
501 else if (!syserror(tcp)) {
505 sigm.__val[0] = tcp->u_rval;
507 sigset_t sigm = tcp->u_rval;
509 tcp->auxstr = sprintsigmask("old mask ", &sigm);
511 return RVAL_HEX | RVAL_STR;
520 return sys_sigsetmask(tcp);
525 #ifdef HAVE_SIGACTION
528 struct old_sigaction {
529 __sighandler_t __sa_handler;
530 unsigned long sa_mask;
531 unsigned long sa_flags;
532 void (*sa_restorer)(void);
543 struct old_sigaction sa;
544 sigemptyset(&sigset);
551 printsignal(tcp->u_arg[0]);
553 addr = tcp->u_arg[1];
555 addr = tcp->u_arg[2];
558 else if (!verbose(tcp))
559 tprintf("%#lx", addr);
560 else if (umove(tcp, addr, &sa) < 0)
563 switch ((long) sa.__sa_handler) {
565 tprintf("{SIG_ERR}");
568 tprintf("{SIG_DFL}");
572 if (tcp->u_arg[0] == SIGTRAP) {
573 tcp->flags |= TCB_SIGTRAPPED;
574 kill(tcp->pid, SIGSTOP);
577 tprintf("{SIG_IGN}");
581 if (tcp->u_arg[0] == SIGTRAP) {
582 tcp->flags |= TCB_SIGTRAPPED;
583 kill(tcp->pid, SIGSTOP);
586 tprintf("{%#lx, ", (long) sa.__sa_handler);
588 sigset.__val[0] = sa.sa_mask;
589 printsigmask(&sigset);
591 printsigmask(&sa.sa_mask);
594 if (!printflags(sigact_flags, sa.sa_flags))
603 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
613 printsignal(tcp->u_arg[0]);
614 switch (tcp->u_arg[1]) {
623 if (tcp->u_arg[0] == SIGTRAP) {
624 tcp->flags |= TCB_SIGTRAPPED;
625 kill(tcp->pid, SIGSTOP);
632 if (tcp->u_arg[0] == SIGTRAP) {
633 tcp->flags |= TCB_SIGTRAPPED;
634 kill(tcp->pid, SIGSTOP);
637 tprintf("%#lx", tcp->u_arg[1]);
643 #endif /* HAVE_SIGACTION */
653 struct sigcontext_struct sc;
657 if (upeek(tcp->pid, 4*UESP, &esp) < 0)
659 if (umove(tcp, esp, &sc) < 0)
662 tcp->u_arg[1] = sc.oldmask;
667 sigm.__val[0] = tcp->u_arg[1];
668 tcp->u_rval = tcp->u_error = 0;
669 if (tcp->u_arg[0] == 0)
671 tcp->auxstr = sprintsigmask("mask now ", &sigm);
672 return RVAL_NONE | RVAL_STR;
678 struct sigcontext_struct sc;
682 if (upeek(tcp->pid, 4*PT_R1, &esp) < 0)
684 if (umove(tcp, esp, &sc) < 0)
687 tcp->u_arg[1] = sc.oldmask;
692 sigm.__val[0] = tcp->u_arg[1];
693 tcp->u_rval = tcp->u_error = 0;
694 if (tcp->u_arg[0] == 0)
696 tcp->auxstr = sprintsigmask("mask now ", &sigm);
697 return RVAL_NONE | RVAL_STR;
703 struct sigcontext_struct sc;
707 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
709 if (umove(tcp, usp, &sc) < 0)
712 tcp->u_arg[1] = sc.sc_mask;
717 sigm.__val[0] = tcp->u_arg[1];
718 tcp->u_rval = tcp->u_error = 0;
719 if (tcp->u_arg[0] == 0)
721 tcp->auxstr = sprintsigmask("mask now ", &sigm);
722 return RVAL_NONE | RVAL_STR;
728 struct sigcontext_struct sc;
732 if (upeek(tcp->pid, REG_FP, &fp) < 0)
734 if (umove(tcp, fp, &sc) < 0)
737 tcp->u_arg[1] = sc.sc_mask;
742 sigm.__val[0] = tcp->u_arg[1];
743 tcp->u_rval = tcp->u_error = 0;
744 if (tcp->u_arg[0] == 0)
746 tcp->auxstr = sprintsigmask("mask now ", &sigm);
747 return RVAL_NONE | RVAL_STR;
756 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
757 perror("sigreturn: PTRACE_GETREGS ");
760 memmove (®s.u_regs [1], ®s.u_regs [0],
761 sizeof (regs.u_regs) - sizeof (regs.u_regs [0]));
764 i1 = regs.u_regs[UREG_I1];
765 if(umove(tcp, i1, &si) < 0) {
766 perror("sigreturn: umove ");
770 tcp->u_arg[1] = si.si_mask;
774 sigm.__val[0] = tcp->u_arg[1];
775 tcp->u_rval = tcp->u_error = 0;
776 if(tcp->u_arg[0] == 0)
778 tcp->auxstr = sprintsigmask("mask now ", &sigm);
779 return RVAL_NONE | RVAL_STR;
785 #endif /* !POWERPC */
797 sigm.__val[0] = tcp->u_rval;
799 sigset_t sigm = tcp->u_rval;
801 tcp->auxstr = sprintsigmask("mask ", &sigm);
803 return RVAL_HEX | RVAL_STR;
813 sigm.__val[0] = tcp->u_arg[2];
815 /* first two are not really arguments, but print them anyway */
816 /* nevermind, they are an anachronism now, too bad... */
817 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
835 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
838 printsigmask(sigset);
842 static struct xlat ucontext_flags[] = {
843 { UC_SIGMASK, "UC_SIGMASK" },
844 { UC_STACK, "UC_STACK" },
845 { UC_CPU, "UC_CPU" },
847 { UC_FPU, "UC_FPU" },
850 { UC_INTR, "UC_INTR" },
857 #if defined SVR4 || defined LINUX
858 #if defined LINUX && !defined SS_ONSTACK
861 #if __GLIBC_MINOR__ == 0
871 static struct xlat sigaltstack_flags[] = {
872 { SS_ONSTACK, "SS_ONSTACK" },
873 { SS_DISABLE, "SS_DISABLE" },
880 printcontext(tcp, ucp)
886 tprintf("uc_flags=");
887 if (!printflags(ucontext_flags, ucp->uc_flags))
889 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
891 tprintf("uc_sigmask=");
892 printsigmask(ucp->uc_sigmask);
894 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
895 (unsigned long) ucp->uc_stack.ss_sp,
896 ucp->uc_stack.ss_size);
897 if (!printflags(sigaltstack_flags, ucp->uc_stack.ss_flags))
913 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
916 printcontext(tcp, &uc);
930 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
933 printcontext(tcp, &uc);
936 tcp->u_rval = tcp->u_error = 0;
937 if (tcp->u_arg[0] == 0)
949 print_stack_t(tcp, addr)
954 if (umove(tcp, addr, &ss) < 0)
956 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
957 if (!printflags(sigaltstack_flags, ss.ss_flags))
959 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
968 if (tcp->u_arg[0] == 0)
970 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
975 if (tcp->u_arg[1] == 0)
977 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
984 #ifdef HAVE_SIGACTION
992 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
994 printsigmask(tcp->u_arg[1]);
996 else if (!syserror(tcp)) {
997 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval);
998 return RVAL_HEX | RVAL_STR;
1003 sigemptyset(&sigset);
1006 if (entering(tcp)) {
1008 if (tcp->u_arg[0] == 0)
1012 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1017 else if (umoven(tcp, tcp->u_arg[1], 4, (char *) &sigset.__val[0]) < 0)
1018 tprintf("%#lx, ", tcp->u_arg[1]);
1020 else if (umove(tcp, tcp->u_arg[1], &sigset) < 0)
1021 tprintf("%#lx, ", tcp->u_arg[1]);
1024 printsigmask(&sigset);
1031 else if (syserror(tcp))
1032 tprintf("%#lx", tcp->u_arg[2]);
1034 else if (umoven(tcp, tcp->u_arg[2], 4, (char *) &sigset.__val[0]) < 0)
1037 else if (umove(tcp, tcp->u_arg[2], &sigset) < 0)
1041 printsigmask(&sigset);
1047 #endif /* HAVE_SIGACTION */
1053 if (entering(tcp)) {
1054 tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1]));
1063 return sys_kill(tcp);
1072 sigemptyset(&sigset);
1077 tprintf("%#lx", tcp->u_arg[0]);
1079 else if (umoven(tcp, tcp->u_arg[0], 4, (char *) &sigset.__val[0]) < 0)
1082 else if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
1086 printsigmask(sigset);
1094 sys_rt_sigprocmask(tcp)
1099 if (entering(tcp)) {
1100 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1104 else if (umove(tcp, tcp->u_arg[1], &sigset) < 0)
1105 tprintf("%#lx, ", tcp->u_arg[1]);
1107 printsigmask(&sigset);
1115 else if (syserror(tcp))
1116 tprintf("%#lx", tcp->u_arg[2]);
1117 else if (umove(tcp, tcp->u_arg[2], &sigset) < 0)
1120 printsigmask(&sigset);
1121 tprintf(", %lu", tcp->u_arg[3]);
1126 #if __GLIBC_MINOR__ < 1
1127 /* Type for data associated with a signal. */
1128 typedef union sigval
1134 # define __SI_MAX_SIZE 128
1135 # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
1137 typedef struct siginfo
1139 int si_signo; /* Signal number. */
1140 int si_errno; /* If non-zero, an errno value associated with
1141 this signal, as defined in <errno.h>. */
1142 int si_code; /* Signal code. */
1146 int _pad[__SI_PAD_SIZE];
1151 __pid_t si_pid; /* Sending process ID. */
1152 __uid_t si_uid; /* Real user ID of sending process. */
1155 /* POSIX.1b timers. */
1158 unsigned int _timer1;
1159 unsigned int _timer2;
1162 /* POSIX.1b signals. */
1165 __pid_t si_pid; /* Sending process ID. */
1166 __uid_t si_uid; /* Real user ID of sending process. */
1167 sigval_t si_sigval; /* Signal value. */
1173 __pid_t si_pid; /* Which child. */
1174 int si_status; /* Exit value or signal. */
1179 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
1182 void *si_addr; /* Faulting insn/memory ref. */
1188 int si_band; /* Band event for SIGPOLL. */
1195 /* Structure describing the action to be taken when a signal arrives. */
1196 struct new_sigaction
1200 __sighandler_t __sa_handler;
1201 void (*__sa_sigaction) (int, siginfo_t *, void *);
1203 __sigaction_handler;
1204 unsigned long sa_flags;
1205 void (*sa_restorer) (void);
1206 unsigned long int sa_mask[2];
1211 sys_rt_sigaction(tcp)
1214 struct new_sigaction sa;
1217 sigemptyset(&sigset);
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 sigset.__val[0] = sa.sa_mask[0];
1246 sigset.__val[1] = sa.sa_mask[1];
1247 printsigmask(&sigset);
1249 if (!printflags(sigact_flags, sa.sa_flags))
1257 tprintf(", %lu", addr = tcp->u_arg[3]);
1262 sys_rt_sigpending(tcp)
1266 sigemptyset(&sigset);
1270 tprintf("%#lx", tcp->u_arg[0]);
1271 else if (umoven(tcp, tcp->u_arg[0], tcp->u_arg[1],
1272 (char *) &sigset.__val[0]) < 0)
1275 printsigmask(sigset);
1280 sys_rt_sigsuspend(tcp)
1283 if (entering(tcp)) {
1286 umoven(tcp, tcp->u_arg[0], tcp->u_arg[1], (char *) &sigm);
1287 printsigmask(&sigm);
1292 #define ILL_ILLOPC 1 /* illegal opcode */
1293 #define ILL_ILLOPN 2 /* illegal operand */
1294 #define ILL_ILLADR 3 /* illegal addressing mode */
1295 #define ILL_ILLTRP 4 /* illegal trap */
1296 #define ILL_PRVOPC 5 /* privileged opcode */
1297 #define ILL_PRVREG 6 /* privileged register */
1298 #define ILL_COPROC 7 /* coprocessor error */
1299 #define ILL_BADSTK 8 /* internal stack error */
1300 #define FPE_INTDIV 1 /* integer divide by zero */
1301 #define FPE_INTOVF 2 /* integer overflow */
1302 #define FPE_FLTDIV 3 /* floating point divide by zero */
1303 #define FPE_FLTOVF 4 /* floating point overflow */
1304 #define FPE_FLTUND 5 /* floating point underflow */
1305 #define FPE_FLTRES 6 /* floating point inexact result */
1306 #define FPE_FLTINV 7 /* floating point invalid operation */
1307 #define FPE_FLTSUB 8 /* subscript out of range */
1308 #define SEGV_MAPERR 1 /* address not mapped to object */
1309 #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
1310 #define BUS_ADRALN 1 /* invalid address alignment */
1311 #define BUS_ADRERR 2 /* non-existant physical address */
1312 #define BUS_OBJERR 3 /* object specific hardware error */
1313 #define TRAP_BRKPT 1 /* process breakpoint */
1314 #define TRAP_TRACE 2 /* process trace trap */
1315 #define CLD_EXITED 1 /* child has exited */
1316 #define CLD_KILLED 2 /* child was killed */
1317 #define CLD_DUMPED 3 /* child terminated abnormally */
1318 #define CLD_TRAPPED 4 /* traced child has trapped */
1319 #define CLD_STOPPED 5 /* child has stopped */
1320 #define CLD_CONTINUED 6 /* stopped child has continued */
1321 #define POLL_IN 1 /* data input available */
1322 #define POLL_OUT 2 /* output buffers available */
1323 #define POLL_MSG 3 /* input message available */
1324 #define POLL_ERR 4 /* i/o error */
1325 #define POLL_PRI 5 /* high priority input available */
1326 #define POLL_HUP 6 /* device disconnected */
1327 #define SI_USER 0 /* sent by kill, sigsend, raise */
1328 #define SI_QUEUE -1 /* sent by sigqueue */
1329 #define SI_TIMER -2 /* sent by timer expiration */
1330 #define SI_MESGQ -3 /* sent by real time mesq state change */
1331 #define SI_ASYNCIO -4 /* sent by AIO completion */
1346 static struct xlat sigill_flags[] = {
1347 {ILL_ILLOPC, "ILL_ILLOPC"},
1348 {ILL_ILLOPN, "ILL_ILLOPN"},
1349 {ILL_ILLADR, "ILL_ILLADR"},
1350 {ILL_ILLTRP, "ILL_ILLTRP"},
1351 {ILL_PRVOPC, "ILL_PRVOPC"},
1352 {ILL_PRVREG, "ILL_PRVREG"},
1353 {ILL_COPROC, "ILL_COPROC"},
1354 {ILL_BADSTK, "ILL_BADSTK"},
1358 static struct xlat sigfpe_flags[] = {
1359 {FPE_INTDIV, "FPE_INTDIV"},
1360 {FPE_INTOVF, "FPE_INTOVF"},
1361 {FPE_FLTDIV, "FPE_FLTDIV"},
1362 {FPE_FLTOVF, "FPE_FLTOVF"},
1363 {FPE_FLTUND, "FPE_FLTUND"},
1364 {FPE_FLTRES, "FPE_FLTRES"},
1365 {FPE_FLTINV, "FPE_FLTINV"},
1366 {FPE_FLTSUB, "FPE_FLTSUB"},
1370 static struct xlat sigsegv_flags[] = {
1371 {SEGV_MAPERR, "SEGV_MAPERR"},
1372 {SEGV_ACCERR, "SEGV_ACCERR"},
1376 static struct xlat sigbus_flags[] = {
1377 {BUS_ADRALN, "BUS_ADRALN"},
1378 {BUS_ADRERR, "BUS_ADRERR"},
1379 {BUS_OBJERR, "BUS_OBJERR"},
1383 static struct xlat sigtrap_flags[] = {
1384 {TRAP_BRKPT, "TRAP_BRKPT"},
1385 {TRAP_TRACE, "TRAP_TRACE"},
1389 static struct xlat sigchld_flags[] = {
1390 {CLD_EXITED, "CLD_EXITED"},
1391 {CLD_KILLED, "CLD_KILLED"},
1392 {CLD_DUMPED, "CLD_DUMPED"},
1393 {CLD_TRAPPED, "CLD_TRAPPED"},
1394 {CLD_STOPPED, "CLD_STOPPED"},
1395 {CLD_CONTINUED, "CLD_CONTINUED"},
1399 static struct xlat sigpoll_flags[] = {
1400 {POLL_IN, "POLL_IN"},
1401 {POLL_OUT, "POLL_OUT"},
1402 {POLL_MSG, "POLL_MSG"},
1403 {POLL_ERR, "POLL_ERR"},
1404 {POLL_PRI, "POLL_PRI"},
1405 {POLL_HUP, "POLL_HUP"},
1409 static struct xlat siginfo_flags[] = {
1410 {SI_USER, "SI_USER"},
1411 {SI_QUEUE, "SI_QUEUE"},
1412 {SI_TIMER, "SI_TIMER"},
1413 {SI_MESGQ, "SI_MESGQ"},
1414 {SI_ASYNCIO, "SI_ASYNCIO"},
1419 printsiginfo(tcp, si)
1423 tprintf("{si_signo=");
1424 printsignal(si->si_signo);
1425 tprintf(", si_errno=%d, si_code=", si->si_errno);
1426 switch(si->si_signo)
1429 if (!printflags(sigill_flags, si->si_code))
1430 tprintf("%d /* ILL_??? */", si->si_code);
1431 tprintf(", si_addr=%lx",
1432 (unsigned long) si->_sifields._sigfault.si_addr);
1435 if (!printflags(sigfpe_flags, si->si_code))
1436 tprintf("%d /* FPE_??? */", si->si_code);
1437 tprintf(", si_addr=%lx",
1438 (unsigned long) si->_sifields._sigfault.si_addr);
1441 if (!printflags(sigsegv_flags, si->si_code))
1442 tprintf("%d /* SEGV_??? */", si->si_code);
1443 tprintf(", si_addr=%lx",
1444 (unsigned long) si->_sifields._sigfault.si_addr);
1447 if (!printflags(sigbus_flags, si->si_code))
1448 tprintf("%d /* BUS_??? */", si->si_code);
1449 tprintf(", si_addr=%lx",
1450 (unsigned long) si->_sifields._sigfault.si_addr);
1453 if (!printflags(sigtrap_flags, si->si_code))
1454 tprintf("%d /* TRAP_??? */", si->si_code);
1457 if (!printflags(sigchld_flags, si->si_code))
1458 tprintf("%d /* CLD_??? */", si->si_code);
1462 tprintf(", si_pid=%d, si_uid=%d, si_status=%d, si_utime=%lu, si_stime=%lu",
1463 si->_sifields._kill.si_pid,
1464 si->_sifields._kill.si_uid,
1465 si->_sifields._sigchld.si_status,
1466 si->_sifields._sigchld.si_utime,
1467 si->_sifields._sigchld.si_stime);
1470 if (!printflags(sigpoll_flags, si->si_code))
1471 tprintf("%d /* POLL_??? */", si->si_code);
1472 if (si->si_code == POLL_IN
1473 || si->si_code == POLL_OUT
1474 || si->si_code == POLL_MSG)
1475 tprintf(", si_bind=%lu, si_fd=%d",
1476 (unsigned long) si->_sifields._sigpoll.si_band,
1477 si->_sifields._sigpoll.si_fd);
1480 if (!printflags(siginfo_flags, si->si_code))
1481 tprintf("%d /* SI_??? */", si->si_code);
1482 tprintf(", si_pid=%lu, si_uid=%lu, si_value={",
1483 (unsigned long) si->_sifields._rt.si_pid,
1484 (unsigned long) si->_sifields._rt.si_uid);
1488 tprintf("sival_int=%u, sival_ptr=%#lx",
1489 si->_sifields._rt.si_sigval.sival_int,
1490 (unsigned long) si->_sifields._rt.si_sigval.sival_ptr);
1499 sys_rt_sigqueueinfo(tcp)
1502 if (entering(tcp)) {
1504 tprintf("%lu, ", tcp->u_arg[0]);
1505 printsignal(tcp->u_arg[1]);
1507 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1508 tprintf("%#lx", tcp->u_arg[2]);
1515 int sys_rt_sigtimedwait(tcp)
1518 if (entering(tcp)) {
1520 sigemptyset(&sigset);
1522 if (umoven(tcp, tcp->u_arg[0], tcp->u_arg[3],
1523 (char *) &sigset.__val[0]) < 0)
1526 printsigmask(sigset);
1531 tprintf("%#lx", tcp->u_arg[0]);
1534 if (umove(tcp, tcp->u_arg[1], &si) < 0)
1535 tprintf("%#lx", tcp->u_arg[1]);
1539 tprintf(", %#lx", tcp->u_arg[2]);
1540 tprintf(", %d", (int) tcp->u_arg[3]);