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
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 */
202 sprintsigmask(s, mask)
208 static char outstr[256];
211 s = outstr + strlen(outstr);
213 for (i = 1; i <= nsignals; i++) {
214 if (sigismember(mask, i) == 1)
217 if (nsigs >= nsignals * 2 / 3) {
219 for (i = 1; i <= nsignals; i++) {
220 switch (sigismember(mask, i)) {
232 for (i = 1; i <= nsignals; i++) {
233 if (sigismember(mask, i) == 1) {
234 sprintf(s, format, signalent[i] + 3); s += strlen(s);
247 tprintf("%s", sprintsigmask("", mask));
254 if (nr > 0 && nr < nsignals)
255 tprintf("%s", signalent[nr]);
261 * Check process TCP for the disposition of signal SIG.
262 * Return 1 if the process would somehow manage to survive signal SIG,
263 * else return 0. This routine will never be called with SIGKILL.
266 sigishandled(tcp, sig)
276 int signalled, blocked, ignored, caught;
278 /* This is incredibly costly but it's worth it. */
279 sprintf(sname, "/proc/%d/stat", tcp->pid);
280 if ((sfd = open(sname, O_RDONLY)) == -1) {
284 i = read(sfd, buf, 1024);
288 * Skip the extraneous fields. This loses if the
289 * command name has any spaces in it. So be it.
291 for (i = 0, s = buf; i < 30; i++) {
292 while (*++s != ' ') {
297 if (sscanf(s, "%d%d%d%d",
298 &signalled, &blocked, &ignored, &caught) != 4) {
299 fprintf(stderr, "/proc/pid/stat format error\n");
303 fprintf(stderr, "sigs: %08x %08x %08x %08x\n",
304 signalled, blocked, ignored, caught);
306 if ((ignored & sigmask(sig)) || (caught & sigmask(sig)))
313 if (upeek(tcp->pid, uoff(u_signal[0]) + sig*sizeof(u_signal),
314 (long *) &u_signal) < 0) {
317 if (u_signal != SIG_DFL)
323 * Since procfs doesn't interfere with wait I think it is safe
324 * to punt on this question. If not, the information is there.
336 #if defined(SIGURG) && SIGURG != SIGIO
340 /* Gloria Gaynor says ... */
359 printsignal(tcp->u_arg[0]);
361 addr = tcp->u_arg[1];
363 addr = tcp->u_arg[2];
367 else if (!verbose(tcp))
368 tprintf("%#lx", addr);
369 else if (umove(tcp, addr, &sv) < 0)
372 switch ((int) sv.sv_handler) {
374 tprintf("{SIG_ERR}");
377 tprintf("{SIG_DFL}");
380 if (tcp->u_arg[0] == SIGTRAP) {
381 tcp->flags |= TCB_SIGTRAPPED;
382 kill(tcp->pid, SIGSTOP);
384 tprintf("{SIG_IGN}");
387 if (tcp->u_arg[0] == SIGTRAP) {
388 tcp->flags |= TCB_SIGTRAPPED;
389 kill(tcp->pid, SIGSTOP);
394 if (tcp->u_arg[0] == SIGTRAP) {
395 tcp->flags |= TCB_SIGTRAPPED;
396 kill(tcp->pid, SIGSTOP);
398 tprintf("{%#lx, ", (unsigned long) sv.sv_handler);
399 printsigmask(&sv.sv_mask);
401 if (!printflags(sigvec_flags, sv.sv_flags))
415 if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */
416 sigset_t sigm = tcp->u_arg[0];
430 addr = tcp->u_arg[0];
432 addr = tcp->u_arg[1];
435 else if (umove(tcp, addr, &ss) < 0)
436 tprintf("%#lx", addr);
438 tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp);
439 tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO");
465 sigm.__val[0] = tcp->u_arg[0];
467 sigset_t sigm = tcp->u_arg[0];
470 if ((tcp->u_arg[0] & sigmask(SIGTRAP))) {
471 /* Mark attempt to block SIGTRAP */
472 tcp->flags |= TCB_SIGTRAPPED;
473 /* Send unblockable signal */
474 kill(tcp->pid, SIGSTOP);
477 else if (!syserror(tcp)) {
481 sigm.__val[0] = tcp->u_rval;
483 sigset_t sigm = tcp->u_rval;
485 tcp->auxstr = sprintsigmask("old mask ", &sigm);
487 return RVAL_HEX | RVAL_STR;
496 return sys_sigsetmask(tcp);
501 #ifdef HAVE_SIGACTION
504 struct old_sigaction {
505 __sighandler_t __sa_handler;
506 unsigned long sa_mask;
507 unsigned long sa_flags;
508 void (*sa_restorer)(void);
519 struct old_sigaction sa;
520 sigemptyset(&sigset);
527 printsignal(tcp->u_arg[0]);
529 addr = tcp->u_arg[1];
531 addr = tcp->u_arg[2];
534 else if (!verbose(tcp))
535 tprintf("%#lx", addr);
536 else if (umove(tcp, addr, &sa) < 0)
539 switch ((long) sa.__sa_handler) {
541 tprintf("{SIG_ERR}");
544 tprintf("{SIG_DFL}");
548 if (tcp->u_arg[0] == SIGTRAP) {
549 tcp->flags |= TCB_SIGTRAPPED;
550 kill(tcp->pid, SIGSTOP);
553 tprintf("{SIG_IGN}");
557 if (tcp->u_arg[0] == SIGTRAP) {
558 tcp->flags |= TCB_SIGTRAPPED;
559 kill(tcp->pid, SIGSTOP);
562 tprintf("{%#lx, ", (long) sa.__sa_handler);
564 sigset.__val[0] = sa.sa_mask;
565 printsigmask(&sigset);
567 printsigmask(&sa.sa_mask);
570 if (!printflags(sigact_flags, sa.sa_flags))
579 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
589 printsignal(tcp->u_arg[0]);
590 switch (tcp->u_arg[1]) {
599 if (tcp->u_arg[0] == SIGTRAP) {
600 tcp->flags |= TCB_SIGTRAPPED;
601 kill(tcp->pid, SIGSTOP);
608 if (tcp->u_arg[0] == SIGTRAP) {
609 tcp->flags |= TCB_SIGTRAPPED;
610 kill(tcp->pid, SIGSTOP);
613 tprintf("%#lx", tcp->u_arg[1]);
619 #endif /* HAVE_SIGACTION */
629 struct sigcontext_struct sc;
633 if (upeek(tcp->pid, 4*UESP, &esp) < 0)
635 if (umove(tcp, esp, &sc) < 0)
638 tcp->u_arg[1] = sc.oldmask;
643 sigm.__val[0] = tcp->u_arg[1];
644 tcp->u_rval = tcp->u_error = 0;
645 if (tcp->u_arg[0] == 0)
647 tcp->auxstr = sprintsigmask("mask now ", &sigm);
648 return RVAL_NONE | RVAL_STR;
654 struct sigcontext_struct sc;
658 if (upeek(tcp->pid, 4*PT_R1, &esp) < 0)
660 if (umove(tcp, esp, &sc) < 0)
663 tcp->u_arg[1] = sc.oldmask;
668 sigm.__val[0] = tcp->u_arg[1];
669 tcp->u_rval = tcp->u_error = 0;
670 if (tcp->u_arg[0] == 0)
672 tcp->auxstr = sprintsigmask("mask now ", &sigm);
673 return RVAL_NONE | RVAL_STR;
679 struct sigcontext_struct sc;
683 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
685 if (umove(tcp, usp, &sc) < 0)
688 tcp->u_arg[1] = sc.sc_mask;
693 sigm.__val[0] = tcp->u_arg[1];
694 tcp->u_rval = tcp->u_error = 0;
695 if (tcp->u_arg[0] == 0)
697 tcp->auxstr = sprintsigmask("mask now ", &sigm);
698 return RVAL_NONE | RVAL_STR;
704 struct sigcontext_struct sc;
708 if (upeek(tcp->pid, REG_FP, &fp) < 0)
710 if (umove(tcp, fp, &sc) < 0)
713 tcp->u_arg[1] = sc.sc_mask;
718 sigm.__val[0] = tcp->u_arg[1];
719 tcp->u_rval = tcp->u_error = 0;
720 if (tcp->u_arg[0] == 0)
722 tcp->auxstr = sprintsigmask("mask now ", &sigm);
723 return RVAL_NONE | RVAL_STR;
732 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
733 perror("sigreturn: PTRACE_GETREGS ");
736 memmove (®s.u_regs [1], ®s.u_regs [0],
737 sizeof (regs.u_regs) - sizeof (regs.u_regs [0]));
740 i1 = regs.u_regs[UREG_I1];
741 if(umove(tcp, i1, &si) < 0) {
742 perror("sigreturn: umove ");
746 tcp->u_arg[1] = si.si_mask;
750 sigm.__val[0] = tcp->u_arg[1];
751 tcp->u_rval = tcp->u_error = 0;
752 if(tcp->u_arg[0] == 0)
754 tcp->auxstr = sprintsigmask("mask now ", &sigm);
755 return RVAL_NONE | RVAL_STR;
761 #endif /* !POWERPC */
773 sigm.__val[0] = tcp->u_rval;
775 sigset_t sigm = tcp->u_rval;
777 tcp->auxstr = sprintsigmask("mask ", &sigm);
779 return RVAL_HEX | RVAL_STR;
789 sigm.__val[0] = tcp->u_arg[2];
791 /* first two are not really arguments, but print them anyway */
792 /* nevermind, they are an anachronism now, too bad... */
793 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
811 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
814 printsigmask(sigset);
818 static struct xlat ucontext_flags[] = {
819 { UC_SIGMASK, "UC_SIGMASK" },
820 { UC_STACK, "UC_STACK" },
821 { UC_CPU, "UC_CPU" },
823 { UC_FPU, "UC_FPU" },
826 { UC_INTR, "UC_INTR" },
833 #if defined SVR4 || defined LINUX
834 #if defined LINUX && !defined SS_ONSTACK
837 #if __GLIBC_MINOR__ == 0
847 static struct xlat sigaltstack_flags[] = {
848 { SS_ONSTACK, "SS_ONSTACK" },
849 { SS_DISABLE, "SS_DISABLE" },
856 printcontext(tcp, ucp)
862 tprintf("uc_flags=");
863 if (!printflags(ucontext_flags, ucp->uc_flags))
865 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
867 tprintf("uc_sigmask=");
868 printsigmask(ucp->uc_sigmask);
870 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
871 (unsigned long) ucp->uc_stack.ss_sp,
872 ucp->uc_stack.ss_size);
873 if (!printflags(sigaltstack_flags, ucp->uc_stack.ss_flags))
889 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
892 printcontext(tcp, &uc);
906 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
909 printcontext(tcp, &uc);
912 tcp->u_rval = tcp->u_error = 0;
913 if (tcp->u_arg[0] == 0)
925 print_stack_t(tcp, addr)
930 if (umove(tcp, addr, &ss) < 0)
932 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
933 if (!printflags(sigaltstack_flags, ss.ss_flags))
935 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
944 if (tcp->u_arg[0] == 0)
946 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
951 if (tcp->u_arg[1] == 0)
953 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
960 #ifdef HAVE_SIGACTION
968 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
970 printsigmask(tcp->u_arg[1]);
972 else if (!syserror(tcp)) {
973 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval);
974 return RVAL_HEX | RVAL_STR;
979 sigemptyset(&sigset);
984 if (tcp->u_arg[0] == 0)
988 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
993 else if (umoven(tcp, tcp->u_arg[1], 4, (char *) &sigset.__val[0]) < 0)
994 tprintf("%#lx, ", tcp->u_arg[1]);
996 else if (umove(tcp, tcp->u_arg[1], &sigset) < 0)
997 tprintf("%#lx, ", tcp->u_arg[1]);
1000 printsigmask(&sigset);
1007 else if (syserror(tcp))
1008 tprintf("%#lx", tcp->u_arg[2]);
1010 else if (umoven(tcp, tcp->u_arg[2], 4, (char *) &sigset.__val[0]) < 0)
1013 else if (umove(tcp, tcp->u_arg[2], &sigset) < 0)
1017 printsigmask(&sigset);
1023 #endif /* HAVE_SIGACTION */
1029 if (entering(tcp)) {
1030 long sig = tcp->u_arg[1];
1032 if (sig >= 0 && sig < NSIG)
1033 tprintf("%ld, %s", tcp->u_arg[0], signalent[sig]);
1035 tprintf("%ld, %ld", tcp->u_arg[0], sig);
1044 return sys_kill(tcp);
1053 sigemptyset(&sigset);
1058 tprintf("%#lx", tcp->u_arg[0]);
1060 else if (umoven(tcp, tcp->u_arg[0], 4, (char *) &sigset.__val[0]) < 0)
1063 else if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
1067 printsigmask(sigset);
1075 sys_rt_sigprocmask(tcp)
1080 if (entering(tcp)) {
1081 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1085 else if (umove(tcp, tcp->u_arg[1], &sigset) < 0)
1086 tprintf("%#lx, ", tcp->u_arg[1]);
1088 printsigmask(&sigset);
1096 else if (syserror(tcp))
1097 tprintf("%#lx", tcp->u_arg[2]);
1098 else if (umove(tcp, tcp->u_arg[2], &sigset) < 0)
1101 printsigmask(&sigset);
1102 tprintf(", %lu", tcp->u_arg[4]);
1107 #if __GLIBC_MINOR__ < 1
1108 /* Type for data associated with a signal. */
1109 typedef union sigval
1115 # define __SI_MAX_SIZE 128
1116 # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
1118 typedef struct siginfo
1120 int si_signo; /* Signal number. */
1121 int si_errno; /* If non-zero, an errno value associated with
1122 this signal, as defined in <errno.h>. */
1123 int si_code; /* Signal code. */
1127 int _pad[__SI_PAD_SIZE];
1132 __pid_t si_pid; /* Sending process ID. */
1133 __uid_t si_uid; /* Real user ID of sending process. */
1136 /* POSIX.1b timers. */
1139 unsigned int _timer1;
1140 unsigned int _timer2;
1143 /* POSIX.1b signals. */
1146 __pid_t si_pid; /* Sending process ID. */
1147 __uid_t si_uid; /* Real user ID of sending process. */
1148 sigval_t si_sigval; /* Signal value. */
1154 __pid_t si_pid; /* Which child. */
1155 int si_status; /* Exit value or signal. */
1160 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
1163 void *si_addr; /* Faulting insn/memory ref. */
1169 int si_band; /* Band event for SIGPOLL. */
1176 /* Structure describing the action to be taken when a signal arrives. */
1177 struct new_sigaction
1181 __sighandler_t __sa_handler;
1182 void (*__sa_sigaction) (int, siginfo_t *, void *);
1184 __sigaction_handler;
1185 unsigned long sa_flags;
1186 void (*sa_restorer) (void);
1187 unsigned long int sa_mask[2];
1192 sys_rt_sigaction(tcp)
1195 struct new_sigaction sa;
1198 sigemptyset(&sigset);
1200 if (entering(tcp)) {
1201 printsignal(tcp->u_arg[0]);
1203 addr = tcp->u_arg[1];
1205 addr = tcp->u_arg[2];
1208 else if (!verbose(tcp))
1209 tprintf("%#lx", addr);
1210 else if (umove(tcp, addr, &sa) < 0)
1213 switch ((long) sa.__sigaction_handler.__sa_handler) {
1214 case (long) SIG_ERR:
1215 tprintf("{SIG_ERR}");
1217 case (long) SIG_DFL:
1218 tprintf("{SIG_DFL}");
1220 case (long) SIG_IGN:
1221 tprintf("{SIG_IGN}");
1225 (long) sa.__sigaction_handler.__sa_handler);
1226 sigset.__val[0] = sa.sa_mask[0];
1227 sigset.__val[1] = sa.sa_mask[1];
1228 printsigmask(&sigset);
1230 if (!printflags(sigact_flags, sa.sa_flags))
1238 tprintf(", %lu", addr = tcp->u_arg[3]);
1243 sys_rt_sigpending(tcp)
1247 sigemptyset(&sigset);
1251 tprintf("%#lx", tcp->u_arg[0]);
1252 else if (umoven(tcp, tcp->u_arg[0], tcp->u_arg[1],
1253 (char *) &sigset.__val[0]) < 0)
1256 printsigmask(sigset);
1261 sys_rt_sigsuspend(tcp)
1264 if (entering(tcp)) {
1267 umoven(tcp, tcp->u_arg[0], tcp->u_arg[1], (char *) &sigm);
1268 printsigmask(&sigm);
1273 #define ILL_ILLOPC 1 /* illegal opcode */
1274 #define ILL_ILLOPN 2 /* illegal operand */
1275 #define ILL_ILLADR 3 /* illegal addressing mode */
1276 #define ILL_ILLTRP 4 /* illegal trap */
1277 #define ILL_PRVOPC 5 /* privileged opcode */
1278 #define ILL_PRVREG 6 /* privileged register */
1279 #define ILL_COPROC 7 /* coprocessor error */
1280 #define ILL_BADSTK 8 /* internal stack error */
1281 #define FPE_INTDIV 1 /* integer divide by zero */
1282 #define FPE_INTOVF 2 /* integer overflow */
1283 #define FPE_FLTDIV 3 /* floating point divide by zero */
1284 #define FPE_FLTOVF 4 /* floating point overflow */
1285 #define FPE_FLTUND 5 /* floating point underflow */
1286 #define FPE_FLTRES 6 /* floating point inexact result */
1287 #define FPE_FLTINV 7 /* floating point invalid operation */
1288 #define FPE_FLTSUB 8 /* subscript out of range */
1289 #define SEGV_MAPERR 1 /* address not mapped to object */
1290 #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
1291 #define BUS_ADRALN 1 /* invalid address alignment */
1292 #define BUS_ADRERR 2 /* non-existant physical address */
1293 #define BUS_OBJERR 3 /* object specific hardware error */
1294 #define TRAP_BRKPT 1 /* process breakpoint */
1295 #define TRAP_TRACE 2 /* process trace trap */
1296 #define CLD_EXITED 1 /* child has exited */
1297 #define CLD_KILLED 2 /* child was killed */
1298 #define CLD_DUMPED 3 /* child terminated abnormally */
1299 #define CLD_TRAPPED 4 /* traced child has trapped */
1300 #define CLD_STOPPED 5 /* child has stopped */
1301 #define CLD_CONTINUED 6 /* stopped child has continued */
1302 #define POLL_IN 1 /* data input available */
1303 #define POLL_OUT 2 /* output buffers available */
1304 #define POLL_MSG 3 /* input message available */
1305 #define POLL_ERR 4 /* i/o error */
1306 #define POLL_PRI 5 /* high priority input available */
1307 #define POLL_HUP 6 /* device disconnected */
1308 #define SI_USER 0 /* sent by kill, sigsend, raise */
1309 #define SI_QUEUE -1 /* sent by sigqueue */
1310 #define SI_TIMER -2 /* sent by timer expiration */
1311 #define SI_MESGQ -3 /* sent by real time mesq state change */
1312 #define SI_ASYNCIO -4 /* sent by AIO completion */
1327 static struct xlat sigill_flags[] = {
1328 {ILL_ILLOPC, "ILL_ILLOPC"},
1329 {ILL_ILLOPN, "ILL_ILLOPN"},
1330 {ILL_ILLADR, "ILL_ILLADR"},
1331 {ILL_ILLTRP, "ILL_ILLTRP"},
1332 {ILL_PRVOPC, "ILL_PRVOPC"},
1333 {ILL_PRVREG, "ILL_PRVREG"},
1334 {ILL_COPROC, "ILL_COPROC"},
1335 {ILL_BADSTK, "ILL_BADSTK"},
1339 static struct xlat sigfpe_flags[] = {
1340 {FPE_INTDIV, "FPE_INTDIV"},
1341 {FPE_INTOVF, "FPE_INTOVF"},
1342 {FPE_FLTDIV, "FPE_FLTDIV"},
1343 {FPE_FLTOVF, "FPE_FLTOVF"},
1344 {FPE_FLTUND, "FPE_FLTUND"},
1345 {FPE_FLTRES, "FPE_FLTRES"},
1346 {FPE_FLTINV, "FPE_FLTINV"},
1347 {FPE_FLTSUB, "FPE_FLTSUB"},
1351 static struct xlat sigsegv_flags[] = {
1352 {SEGV_MAPERR, "SEGV_MAPERR"},
1353 {SEGV_ACCERR, "SEGV_ACCERR"},
1357 static struct xlat sigbus_flags[] = {
1358 {BUS_ADRALN, "BUS_ADRALN"},
1359 {BUS_ADRERR, "BUS_ADRERR"},
1360 {BUS_OBJERR, "BUS_OBJERR"},
1364 static struct xlat sigtrap_flags[] = {
1365 {TRAP_BRKPT, "TRAP_BRKPT"},
1366 {TRAP_TRACE, "TRAP_TRACE"},
1370 static struct xlat sigchld_flags[] = {
1371 {CLD_EXITED, "CLD_EXITED"},
1372 {CLD_KILLED, "CLD_KILLED"},
1373 {CLD_DUMPED, "CLD_DUMPED"},
1374 {CLD_TRAPPED, "CLD_TRAPPED"},
1375 {CLD_STOPPED, "CLD_STOPPED"},
1376 {CLD_CONTINUED, "CLD_CONTINUED"},
1380 static struct xlat sigpoll_flags[] = {
1381 {POLL_IN, "POLL_IN"},
1382 {POLL_OUT, "POLL_OUT"},
1383 {POLL_MSG, "POLL_MSG"},
1384 {POLL_ERR, "POLL_ERR"},
1385 {POLL_PRI, "POLL_PRI"},
1386 {POLL_HUP, "POLL_HUP"},
1390 static struct xlat siginfo_flags[] = {
1391 {SI_USER, "SI_USER"},
1392 {SI_QUEUE, "SI_QUEUE"},
1393 {SI_TIMER, "SI_TIMER"},
1394 {SI_MESGQ, "SI_MESGQ"},
1395 {SI_ASYNCIO, "SI_ASYNCIO"},
1400 printsiginfo(tcp, si)
1404 tprintf("{si_signo=");
1405 printsignal(si->si_signo);
1406 tprintf(", si_errno=%d, si_code=", si->si_errno);
1407 switch(si->si_signo)
1410 if (!printflags(sigill_flags, si->si_code))
1411 tprintf("%d /* ILL_??? */", si->si_code);
1412 tprintf(", si_addr=%lx",
1413 (unsigned long) si->_sifields._sigfault.si_addr);
1416 if (!printflags(sigfpe_flags, si->si_code))
1417 tprintf("%d /* FPE_??? */", si->si_code);
1418 tprintf(", si_addr=%lx",
1419 (unsigned long) si->_sifields._sigfault.si_addr);
1422 if (!printflags(sigsegv_flags, si->si_code))
1423 tprintf("%d /* SEGV_??? */", si->si_code);
1424 tprintf(", si_addr=%lx",
1425 (unsigned long) si->_sifields._sigfault.si_addr);
1428 if (!printflags(sigbus_flags, si->si_code))
1429 tprintf("%d /* BUS_??? */", si->si_code);
1430 tprintf(", si_addr=%lx",
1431 (unsigned long) si->_sifields._sigfault.si_addr);
1434 if (!printflags(sigtrap_flags, si->si_code))
1435 tprintf("%d /* TRAP_??? */", si->si_code);
1438 if (!printflags(sigchld_flags, si->si_code))
1439 tprintf("%d /* CLD_??? */", si->si_code);
1443 tprintf(", si_pid=%d, si_uid=%d, si_status=%d, si_utime=%lu, si_stime=%lu",
1444 si->_sifields._kill.si_pid,
1445 si->_sifields._kill.si_uid,
1446 si->_sifields._sigchld.si_status,
1447 si->_sifields._sigchld.si_utime,
1448 si->_sifields._sigchld.si_stime);
1451 if (!printflags(sigpoll_flags, si->si_code))
1452 tprintf("%d /* POLL_??? */", si->si_code);
1453 if (si->si_code == POLL_IN
1454 || si->si_code == POLL_OUT
1455 || si->si_code == POLL_MSG)
1456 tprintf(", si_bind=%lu, si_fd=%d",
1457 (unsigned long) si->_sifields._sigpoll.si_band,
1458 si->_sifields._sigpoll.si_fd);
1461 if (!printflags(siginfo_flags, si->si_code))
1462 tprintf("%d /* SI_??? */", si->si_code);
1463 tprintf(", si_pid=%lu, si_uid=%lu, si_value={",
1464 (unsigned long) si->_sifields._rt.si_pid,
1465 (unsigned long) si->_sifields._rt.si_uid);
1469 tprintf("sival_int=%u, sival_ptr=%#lx",
1470 si->_sifields._rt.si_sigval.sival_int,
1471 (unsigned long) si->_sifields._rt.si_sigval.sival_ptr);
1480 sys_rt_sigqueueinfo(tcp)
1483 if (entering(tcp)) {
1485 tprintf("%lu, ", tcp->u_arg[0]);
1486 printsignal(tcp->u_arg[1]);
1488 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1489 tprintf("%#lx", tcp->u_arg[2]);
1496 int sys_rt_sigtimedwait(tcp)
1499 if (entering(tcp)) {
1501 sigemptyset(&sigset);
1503 if (umoven(tcp, tcp->u_arg[0], tcp->u_arg[3],
1504 (char *) &sigset.__val[0]) < 0)
1507 printsigmask(sigset);
1512 tprintf("%#lx", tcp->u_arg[0]);
1515 if (umove(tcp, tcp->u_arg[1], &si) < 0)
1516 tprintf("%#lx", tcp->u_arg[1]);
1520 tprintf(", %#lx", tcp->u_arg[2]);
1521 tprintf(", %d", (int) tcp->u_arg[3]);