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.
37 #if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 && (defined(I386) || defined(M68K))
42 #include <sys/ucontext.h>
47 #include <linux/ptrace.h>
49 #ifdef HAVE_ASM_SIGCONTEXT_H
50 #include <asm/sigcontext.h>
53 struct pt_regs si_regs;
57 #else /* !HAVE_ASM_SIGCONTEXT_H */
59 struct sigcontext_struct {
60 unsigned short gs, __gsh;
61 unsigned short fs, __fsh;
62 unsigned short es, __esh;
63 unsigned short ds, __dsh;
75 unsigned short cs, __csh;
77 unsigned long esp_at_signal;
78 unsigned short ss, __ssh;
80 unsigned long oldmask;
87 unsigned long sc_mask;
95 unsigned short sc_formatvec;
99 #endif /* !HAVE_ASM_SIGCONTEXT_H */
109 char *signalent0[] = {
110 #include "signalent.h"
112 int nsignals0 = sizeof signalent0 / sizeof signalent0[0];
114 #if SUPPORTED_PERSONALITIES >= 2
115 char *signalent1[] = {
116 #include "signalent1.h"
118 int nsignals1 = sizeof signalent1 / sizeof signalent1[0];
119 #endif /* SUPPORTED_PERSONALITIES >= 2 */
121 #if SUPPORTED_PERSONALITIES >= 3
122 char *signalent2[] = {
123 #include "signalent2.h"
125 int nsignals2 = sizeof signalent2 / sizeof signalent2[0];
126 #endif /* SUPPORTED_PERSONALITIES >= 3 */
133 static struct xlat sigvec_flags[] = {
134 { SV_ONSTACK, "SV_ONSTACK" },
135 { SV_INTERRUPT, "SV_INTERRUPT" },
136 { SV_RESETHAND, "SV_RESETHAND" },
137 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
143 #ifdef HAVE_SIGACTION
145 static struct xlat sigact_flags[] = {
147 { SA_STACK, "SA_STACK" },
150 { SA_RESTART, "SA_RESTART" },
153 { SA_INTERRUPT, "SA_INTERRUPT" },
156 { SA_NOMASK, "SA_NOMASK" },
159 { SA_ONESHOT, "SA_ONESHOT" },
162 { SA_SIGINFO, "SA_SIGINFO" },
165 { SA_RESETHAND, "SA_RESETHAND" },
168 { SA_ONSTACK, "SA_ONSTACK" },
171 { SA_NODEFER, "SA_NODEFER" },
174 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
177 { SA_NOCLDWAIT, "SA_NOCLDWAIT" },
180 { _SA_BSDCALL, "_SA_BSDCALL" },
185 static struct xlat sigprocmaskcmds[] = {
186 { SIG_BLOCK, "SIG_BLOCK" },
187 { SIG_UNBLOCK, "SIG_UNBLOCK" },
188 { SIG_SETMASK, "SIG_SETMASK" },
190 { SIG_SETMASK32,"SIG_SETMASK32" },
195 #endif /* HAVE_SIGACTION */
197 /* Anonymous realtime signals. */
198 /* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
199 constant. This is what we want. Otherwise, just use SIGRTMIN. */
202 #define __SIGRTMIN SIGRTMIN
203 #define __SIGRTMAX SIGRTMAX /* likewise */
212 if (sig < nsignals) {
213 return signalent[sig];
215 } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) {
216 sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN));
218 #endif /* SIGRTMIN */
220 sprintf(buf, "%d", sig);
235 copy_sigset_len(tcp, addr, s, len)
241 if (len > sizeof(*s))
244 if (umoven(tcp, addr, len, (char *)s) < 0)
250 /* Original sigset is unsigned long */
251 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long))
253 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t))
257 sprintsigmask(s, mask, rt)
260 int rt; /* set might include realtime sigs */
265 static char outstr[256];
268 s = outstr + strlen(outstr);
273 maxsigs = __SIGRTMAX; /* instead */
275 for (i = 1; i < maxsigs; i++) {
276 if (sigismember(mask, i) == 1)
279 if (nsigs >= nsignals * 2 / 3) {
281 for (i = 1; i < maxsigs; i++) {
282 switch (sigismember(mask, i)) {
294 for (i = 1; i < maxsigs; i++) {
295 if (sigismember(mask, i) == 1) {
296 sprintf(s, format, signame(i) + 3); s += strlen(s);
306 printsigmask(mask, rt)
310 tprintf("%s", sprintsigmask("", mask, rt));
317 tprintf(signame(nr));
321 * Check process TCP for the disposition of signal SIG.
322 * Return 1 if the process would somehow manage to survive signal SIG,
323 * else return 0. This routine will never be called with SIGKILL.
326 sigishandled(tcp, sig)
336 unsigned int signalled, blocked, ignored, caught;
338 /* This is incredibly costly but it's worth it. */
339 sprintf(sname, "/proc/%d/stat", tcp->pid);
340 if ((sfd = open(sname, O_RDONLY)) == -1) {
344 i = read(sfd, buf, 1024);
348 * Skip the extraneous fields. This loses if the
349 * command name has any spaces in it. So be it.
351 for (i = 0, s = buf; i < 30; i++) {
352 while (*++s != ' ') {
357 if (sscanf(s, "%u%u%u%u",
358 &signalled, &blocked, &ignored, &caught) != 4) {
359 fprintf(stderr, "/proc/pid/stat format error\n");
363 fprintf(stderr, "sigs: %08x %08x %08x %08x\n",
364 signalled, blocked, ignored, caught);
366 if ((ignored & sigmask(sig)) || (caught & sigmask(sig)))
373 if (upeek(tcp->pid, uoff(u_signal[0]) + sig*sizeof(u_signal),
374 (long *) &u_signal) < 0) {
377 if (u_signal != SIG_DFL)
383 * Since procfs doesn't interfere with wait I think it is safe
384 * to punt on this question. If not, the information is there.
396 #if defined(SIGURG) && SIGURG != SIGIO
400 /* Gloria Gaynor says ... */
419 printsignal(tcp->u_arg[0]);
421 addr = tcp->u_arg[1];
423 addr = tcp->u_arg[2];
427 else if (!verbose(tcp))
428 tprintf("%#lx", addr);
429 else if (umove(tcp, addr, &sv) < 0)
432 switch ((int) sv.sv_handler) {
434 tprintf("{SIG_ERR}");
437 tprintf("{SIG_DFL}");
440 if (tcp->u_arg[0] == SIGTRAP) {
441 tcp->flags |= TCB_SIGTRAPPED;
442 kill(tcp->pid, SIGSTOP);
444 tprintf("{SIG_IGN}");
447 if (tcp->u_arg[0] == SIGTRAP) {
448 tcp->flags |= TCB_SIGTRAPPED;
449 kill(tcp->pid, SIGSTOP);
454 if (tcp->u_arg[0] == SIGTRAP) {
455 tcp->flags |= TCB_SIGTRAPPED;
456 kill(tcp->pid, SIGSTOP);
458 tprintf("{%#lx, ", (unsigned long) sv.sv_handler);
459 printsigmask(&sv.sv_mask, 0);
461 if (!printflags(sigvec_flags, sv.sv_flags))
475 if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */
477 long_to_sigset(tcp->u_arg[0], &sigm);
478 printsigmask(&sigm, 0);
491 addr = tcp->u_arg[0];
493 addr = tcp->u_arg[1];
496 else if (umove(tcp, addr, &ss) < 0)
497 tprintf("%#lx", addr);
499 tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp);
500 tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO");
524 long_to_sigset(tcp->u_arg[0], &sigm);
525 printsigmask(&sigm, 0);
526 if ((tcp->u_arg[0] & sigmask(SIGTRAP))) {
527 /* Mark attempt to block SIGTRAP */
528 tcp->flags |= TCB_SIGTRAPPED;
529 /* Send unblockable signal */
530 kill(tcp->pid, SIGSTOP);
533 else if (!syserror(tcp)) {
535 long_to_sigset(tcp->u_rval, &sigm);
536 tcp->auxstr = sprintsigmask("old mask ", &sigm, 0);
538 return RVAL_HEX | RVAL_STR;
547 return sys_sigsetmask(tcp);
552 #ifdef HAVE_SIGACTION
555 struct old_sigaction {
556 __sighandler_t __sa_handler;
557 unsigned long sa_mask;
558 unsigned long sa_flags;
559 void (*sa_restorer)(void);
561 #define SA_HANDLER __sa_handler
565 #define SA_HANDLER sa_handler
575 struct old_sigaction sa;
582 printsignal(tcp->u_arg[0]);
584 addr = tcp->u_arg[1];
586 addr = tcp->u_arg[2];
589 else if (!verbose(tcp))
590 tprintf("%#lx", addr);
591 else if (umove(tcp, addr, &sa) < 0)
594 switch ((long) sa.SA_HANDLER) {
596 tprintf("{SIG_ERR}");
599 tprintf("{SIG_DFL}");
603 if (tcp->u_arg[0] == SIGTRAP) {
604 tcp->flags |= TCB_SIGTRAPPED;
605 kill(tcp->pid, SIGSTOP);
608 tprintf("{SIG_IGN}");
612 if (tcp->u_arg[0] == SIGTRAP) {
613 tcp->flags |= TCB_SIGTRAPPED;
614 kill(tcp->pid, SIGSTOP);
617 tprintf("{%#lx, ", (long) sa.SA_HANDLER);
618 long_to_sigset(sa.sa_mask, &sigset);
619 printsigmask(&sigset, 0);
621 if (!printflags(sigact_flags, sa.sa_flags))
630 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
640 printsignal(tcp->u_arg[0]);
641 switch (tcp->u_arg[1]) {
650 if (tcp->u_arg[0] == SIGTRAP) {
651 tcp->flags |= TCB_SIGTRAPPED;
652 kill(tcp->pid, SIGSTOP);
659 if (tcp->u_arg[0] == SIGTRAP) {
660 tcp->flags |= TCB_SIGTRAPPED;
661 kill(tcp->pid, SIGSTOP);
664 tprintf("%#lx", tcp->u_arg[1]);
670 #endif /* HAVE_SIGACTION */
680 struct sigcontext_struct sc;
684 if (upeek(tcp->pid, 4*UESP, &esp) < 0)
686 if (umove(tcp, esp, &sc) < 0)
689 tcp->u_arg[1] = sc.oldmask;
693 long_to_sigset(tcp->u_arg[1], &sigm);
694 tcp->u_rval = tcp->u_error = 0;
695 if (tcp->u_arg[0] == 0)
697 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
698 return RVAL_NONE | RVAL_STR;
704 struct sigcontext_struct sc;
708 if (upeek(tcp->pid, 4*PT_R1, &esp) < 0)
710 if (umove(tcp, esp, &sc) < 0)
713 tcp->u_arg[1] = sc.oldmask;
717 long_to_sigset(tcp->u_arg[1], &sigm);
718 tcp->u_rval = tcp->u_error = 0;
719 if (tcp->u_arg[0] == 0)
721 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
722 return RVAL_NONE | RVAL_STR;
728 struct sigcontext sc;
732 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
734 if (umove(tcp, usp, &sc) < 0)
737 tcp->u_arg[1] = sc.sc_mask;
741 long_to_sigset(tcp->u_arg[1], &sigm);
742 tcp->u_rval = tcp->u_error = 0;
743 if (tcp->u_arg[0] == 0)
745 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
746 return RVAL_NONE | RVAL_STR;
752 struct sigcontext_struct sc;
756 if (upeek(tcp->pid, REG_FP, &fp) < 0)
758 if (umove(tcp, fp, &sc) < 0)
761 tcp->u_arg[1] = sc.sc_mask;
765 long_to_sigset(tcp->u_arg[1], &sigm);
766 tcp->u_rval = tcp->u_error = 0;
767 if (tcp->u_arg[0] == 0)
769 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
770 return RVAL_NONE | RVAL_STR;
779 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
780 perror("sigreturn: PTRACE_GETREGS ");
783 memmove (®s.u_regs [1], ®s.u_regs [0],
784 sizeof (regs.u_regs) - sizeof (regs.u_regs [0]));
787 i1 = regs.u_regs[UREG_I1];
788 if(umove(tcp, i1, &si) < 0) {
789 perror("sigreturn: umove ");
793 tcp->u_arg[1] = si.si_mask;
796 long_to_sigset(tcp->u_arg[1], &sigm);
797 tcp->u_rval = tcp->u_error = 0;
798 if(tcp->u_arg[0] == 0)
800 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
801 return RVAL_NONE | RVAL_STR;
807 #endif /* !POWERPC */
817 long_to_sigset(tcp->u_rval, &sigm);
818 tcp->auxstr = sprintsigmask("mask ", &sigm, 0);
820 return RVAL_HEX | RVAL_STR;
829 long_to_sigset(tcp->u_arg[2], &sigm);
831 /* first two are not really arguments, but print them anyway */
832 /* nevermind, they are an anachronism now, too bad... */
833 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
835 printsigmask(&sigm, 0);
851 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
854 printsigmask(sigset, 0);
858 static struct xlat ucontext_flags[] = {
859 { UC_SIGMASK, "UC_SIGMASK" },
860 { UC_STACK, "UC_STACK" },
861 { UC_CPU, "UC_CPU" },
863 { UC_FPU, "UC_FPU" },
866 { UC_INTR, "UC_INTR" },
873 #if defined SVR4 || defined LINUX
874 #if defined LINUX && !defined SS_ONSTACK
877 #if __GLIBC_MINOR__ == 0
887 static struct xlat sigaltstack_flags[] = {
888 { SS_ONSTACK, "SS_ONSTACK" },
889 { SS_DISABLE, "SS_DISABLE" },
896 printcontext(tcp, ucp)
902 tprintf("uc_flags=");
903 if (!printflags(ucontext_flags, ucp->uc_flags))
905 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
907 tprintf("uc_sigmask=");
908 printsigmask(ucp->uc_sigmask, 0);
910 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
911 (unsigned long) ucp->uc_stack.ss_sp,
912 ucp->uc_stack.ss_size);
913 if (!printflags(sigaltstack_flags, ucp->uc_stack.ss_flags))
929 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
932 printcontext(tcp, &uc);
946 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
949 printcontext(tcp, &uc);
952 tcp->u_rval = tcp->u_error = 0;
953 if (tcp->u_arg[0] == 0)
965 print_stack_t(tcp, addr)
970 if (umove(tcp, addr, &ss) < 0)
972 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
973 if (!printflags(sigaltstack_flags, ss.ss_flags))
975 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
984 if (tcp->u_arg[0] == 0)
986 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
991 if (tcp->u_arg[1] == 0)
993 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
1000 #ifdef HAVE_SIGACTION
1003 sys_sigprocmask(tcp)
1007 if (entering(tcp)) {
1008 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1010 printsigmask(tcp->u_arg[1], 0);
1012 else if (!syserror(tcp)) {
1013 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0);
1014 return RVAL_HEX | RVAL_STR;
1019 if (entering(tcp)) {
1021 if (tcp->u_arg[0] == 0)
1025 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1029 else if (copy_sigset(tcp, tcp->u_arg[1], &sigset) < 0)
1030 tprintf("%#lx, ", tcp->u_arg[1]);
1032 printsigmask(&sigset, 0);
1039 else if (syserror(tcp))
1040 tprintf("%#lx", tcp->u_arg[2]);
1041 else if (copy_sigset(tcp, tcp->u_arg[2], &sigset) < 0)
1044 printsigmask(&sigset, 0);
1050 #endif /* HAVE_SIGACTION */
1056 if (entering(tcp)) {
1057 tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1]));
1066 return sys_kill(tcp);
1077 tprintf("%#lx", tcp->u_arg[0]);
1078 else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1081 printsigmask(sigset, 0);
1089 sys_rt_sigprocmask(tcp)
1094 /* Note: arg[3] is the length of the sigset. */
1095 if (entering(tcp)) {
1096 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1100 else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0)
1101 tprintf("%#lx, ", tcp->u_arg[1]);
1103 printsigmask(&sigset, 1);
1111 else if (syserror(tcp))
1112 tprintf("%#lx", tcp->u_arg[2]);
1113 else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0)
1116 printsigmask(&sigset, 1);
1117 tprintf(", %lu", tcp->u_arg[3]);
1122 #if __GLIBC_MINOR__ < 1
1123 /* Type for data associated with a signal. */
1124 typedef union sigval
1130 # define __SI_MAX_SIZE 128
1131 # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
1133 typedef struct siginfo
1135 int si_signo; /* Signal number. */
1136 int si_errno; /* If non-zero, an errno value associated with
1137 this signal, as defined in <errno.h>. */
1138 int si_code; /* Signal code. */
1142 int _pad[__SI_PAD_SIZE];
1147 __pid_t si_pid; /* Sending process ID. */
1148 __uid_t si_uid; /* Real user ID of sending process. */
1151 /* POSIX.1b timers. */
1154 unsigned int _timer1;
1155 unsigned int _timer2;
1158 /* POSIX.1b signals. */
1161 __pid_t si_pid; /* Sending process ID. */
1162 __uid_t si_uid; /* Real user ID of sending process. */
1163 sigval_t si_sigval; /* Signal value. */
1169 __pid_t si_pid; /* Which child. */
1170 int si_status; /* Exit value or signal. */
1175 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
1178 void *si_addr; /* Faulting insn/memory ref. */
1184 int si_band; /* Band event for SIGPOLL. */
1191 /* Structure describing the action to be taken when a signal arrives. */
1192 struct new_sigaction
1196 __sighandler_t __sa_handler;
1197 void (*__sa_sigaction) (int, siginfo_t *, void *);
1199 __sigaction_handler;
1200 unsigned long sa_flags;
1201 void (*sa_restorer) (void);
1202 unsigned long int sa_mask[2];
1207 sys_rt_sigaction(tcp)
1210 struct new_sigaction sa;
1214 if (entering(tcp)) {
1215 printsignal(tcp->u_arg[0]);
1217 addr = tcp->u_arg[1];
1219 addr = tcp->u_arg[2];
1222 else if (!verbose(tcp))
1223 tprintf("%#lx", addr);
1224 else if (umove(tcp, addr, &sa) < 0)
1227 switch ((long) sa.__sigaction_handler.__sa_handler) {
1228 case (long) SIG_ERR:
1229 tprintf("{SIG_ERR}");
1231 case (long) SIG_DFL:
1232 tprintf("{SIG_DFL}");
1234 case (long) SIG_IGN:
1235 tprintf("{SIG_IGN}");
1239 (long) sa.__sigaction_handler.__sa_handler);
1240 sigemptyset(&sigset);
1242 if (tcp->u_arg[4] <= sizeof(sigset))
1243 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
1245 if (tcp->u_arg[3] <= sizeof(sigset))
1246 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
1249 memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
1250 printsigmask(&sigset, 1);
1252 if (!printflags(sigact_flags, sa.sa_flags))
1261 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
1262 #elif defined(ALPHA)
1263 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
1265 tprintf(", %lu", addr = tcp->u_arg[3]);
1271 sys_rt_sigpending(tcp)
1278 tprintf("%#lx", tcp->u_arg[0]);
1279 else if (copy_sigset_len(tcp, tcp->u_arg[0],
1280 &sigset, tcp->u_arg[1]) < 0)
1283 printsigmask(sigset, 1);
1288 sys_rt_sigsuspend(tcp)
1291 if (entering(tcp)) {
1293 if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0)
1296 printsigmask(&sigm, 1);
1301 #define ILL_ILLOPC 1 /* illegal opcode */
1302 #define ILL_ILLOPN 2 /* illegal operand */
1303 #define ILL_ILLADR 3 /* illegal addressing mode */
1304 #define ILL_ILLTRP 4 /* illegal trap */
1305 #define ILL_PRVOPC 5 /* privileged opcode */
1306 #define ILL_PRVREG 6 /* privileged register */
1307 #define ILL_COPROC 7 /* coprocessor error */
1308 #define ILL_BADSTK 8 /* internal stack error */
1309 #define FPE_INTDIV 1 /* integer divide by zero */
1310 #define FPE_INTOVF 2 /* integer overflow */
1311 #define FPE_FLTDIV 3 /* floating point divide by zero */
1312 #define FPE_FLTOVF 4 /* floating point overflow */
1313 #define FPE_FLTUND 5 /* floating point underflow */
1314 #define FPE_FLTRES 6 /* floating point inexact result */
1315 #define FPE_FLTINV 7 /* floating point invalid operation */
1316 #define FPE_FLTSUB 8 /* subscript out of range */
1317 #define SEGV_MAPERR 1 /* address not mapped to object */
1318 #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
1319 #define BUS_ADRALN 1 /* invalid address alignment */
1320 #define BUS_ADRERR 2 /* non-existant physical address */
1321 #define BUS_OBJERR 3 /* object specific hardware error */
1322 #define TRAP_BRKPT 1 /* process breakpoint */
1323 #define TRAP_TRACE 2 /* process trace trap */
1324 #define CLD_EXITED 1 /* child has exited */
1325 #define CLD_KILLED 2 /* child was killed */
1326 #define CLD_DUMPED 3 /* child terminated abnormally */
1327 #define CLD_TRAPPED 4 /* traced child has trapped */
1328 #define CLD_STOPPED 5 /* child has stopped */
1329 #define CLD_CONTINUED 6 /* stopped child has continued */
1330 #define POLL_IN 1 /* data input available */
1331 #define POLL_OUT 2 /* output buffers available */
1332 #define POLL_MSG 3 /* input message available */
1333 #define POLL_ERR 4 /* i/o error */
1334 #define POLL_PRI 5 /* high priority input available */
1335 #define POLL_HUP 6 /* device disconnected */
1336 #define SI_USER 0 /* sent by kill, sigsend, raise */
1337 #define SI_QUEUE -1 /* sent by sigqueue */
1338 #define SI_TIMER -2 /* sent by timer expiration */
1339 #define SI_MESGQ -3 /* sent by real time mesq state change */
1340 #define SI_ASYNCIO -4 /* sent by AIO completion */
1355 static struct xlat sigill_flags[] = {
1356 {ILL_ILLOPC, "ILL_ILLOPC"},
1357 {ILL_ILLOPN, "ILL_ILLOPN"},
1358 {ILL_ILLADR, "ILL_ILLADR"},
1359 {ILL_ILLTRP, "ILL_ILLTRP"},
1360 {ILL_PRVOPC, "ILL_PRVOPC"},
1361 {ILL_PRVREG, "ILL_PRVREG"},
1362 {ILL_COPROC, "ILL_COPROC"},
1363 {ILL_BADSTK, "ILL_BADSTK"},
1367 static struct xlat sigfpe_flags[] = {
1368 {FPE_INTDIV, "FPE_INTDIV"},
1369 {FPE_INTOVF, "FPE_INTOVF"},
1370 {FPE_FLTDIV, "FPE_FLTDIV"},
1371 {FPE_FLTOVF, "FPE_FLTOVF"},
1372 {FPE_FLTUND, "FPE_FLTUND"},
1373 {FPE_FLTRES, "FPE_FLTRES"},
1374 {FPE_FLTINV, "FPE_FLTINV"},
1375 {FPE_FLTSUB, "FPE_FLTSUB"},
1379 static struct xlat sigsegv_flags[] = {
1380 {SEGV_MAPERR, "SEGV_MAPERR"},
1381 {SEGV_ACCERR, "SEGV_ACCERR"},
1385 static struct xlat sigbus_flags[] = {
1386 {BUS_ADRALN, "BUS_ADRALN"},
1387 {BUS_ADRERR, "BUS_ADRERR"},
1388 {BUS_OBJERR, "BUS_OBJERR"},
1392 static struct xlat sigtrap_flags[] = {
1393 {TRAP_BRKPT, "TRAP_BRKPT"},
1394 {TRAP_TRACE, "TRAP_TRACE"},
1398 static struct xlat sigchld_flags[] = {
1399 {CLD_EXITED, "CLD_EXITED"},
1400 {CLD_KILLED, "CLD_KILLED"},
1401 {CLD_DUMPED, "CLD_DUMPED"},
1402 {CLD_TRAPPED, "CLD_TRAPPED"},
1403 {CLD_STOPPED, "CLD_STOPPED"},
1404 {CLD_CONTINUED, "CLD_CONTINUED"},
1408 static struct xlat sigpoll_flags[] = {
1409 {POLL_IN, "POLL_IN"},
1410 {POLL_OUT, "POLL_OUT"},
1411 {POLL_MSG, "POLL_MSG"},
1412 {POLL_ERR, "POLL_ERR"},
1413 {POLL_PRI, "POLL_PRI"},
1414 {POLL_HUP, "POLL_HUP"},
1418 static struct xlat siginfo_flags[] = {
1419 {SI_USER, "SI_USER"},
1420 {SI_QUEUE, "SI_QUEUE"},
1421 {SI_TIMER, "SI_TIMER"},
1422 {SI_MESGQ, "SI_MESGQ"},
1423 {SI_ASYNCIO, "SI_ASYNCIO"},
1428 printsiginfo(tcp, si)
1432 tprintf("{si_signo=");
1433 printsignal(si->si_signo);
1434 tprintf(", si_errno=%d, si_code=", si->si_errno);
1435 switch(si->si_signo)
1438 if (!printflags(sigill_flags, si->si_code))
1439 tprintf("%d /* ILL_??? */", si->si_code);
1440 tprintf(", si_addr=%lx",
1441 (unsigned long) si->_sifields._sigfault.si_addr);
1444 if (!printflags(sigfpe_flags, si->si_code))
1445 tprintf("%d /* FPE_??? */", si->si_code);
1446 tprintf(", si_addr=%lx",
1447 (unsigned long) si->_sifields._sigfault.si_addr);
1450 if (!printflags(sigsegv_flags, si->si_code))
1451 tprintf("%d /* SEGV_??? */", si->si_code);
1452 tprintf(", si_addr=%lx",
1453 (unsigned long) si->_sifields._sigfault.si_addr);
1456 if (!printflags(sigbus_flags, si->si_code))
1457 tprintf("%d /* BUS_??? */", si->si_code);
1458 tprintf(", si_addr=%lx",
1459 (unsigned long) si->_sifields._sigfault.si_addr);
1462 if (!printflags(sigtrap_flags, si->si_code))
1463 tprintf("%d /* TRAP_??? */", si->si_code);
1466 if (!printflags(sigchld_flags, si->si_code))
1467 tprintf("%d /* CLD_??? */", si->si_code);
1471 tprintf(", si_pid=%d, si_uid=%d, si_status=%d, si_utime=%lu, si_stime=%lu",
1472 si->_sifields._kill.si_pid,
1473 si->_sifields._kill.si_uid,
1474 si->_sifields._sigchld.si_status,
1475 si->_sifields._sigchld.si_utime,
1476 si->_sifields._sigchld.si_stime);
1479 if (!printflags(sigpoll_flags, si->si_code))
1480 tprintf("%d /* POLL_??? */", si->si_code);
1481 if (si->si_code == POLL_IN
1482 || si->si_code == POLL_OUT
1483 || si->si_code == POLL_MSG)
1484 tprintf(", si_bind=%lu, si_fd=%d",
1485 (unsigned long) si->_sifields._sigpoll.si_band,
1486 si->_sifields._sigpoll.si_fd);
1489 if (!printflags(siginfo_flags, si->si_code))
1490 tprintf("%d /* SI_??? */", si->si_code);
1491 tprintf(", si_pid=%lu, si_uid=%lu, si_value={",
1492 (unsigned long) si->_sifields._rt.si_pid,
1493 (unsigned long) si->_sifields._rt.si_uid);
1497 tprintf("sival_int=%u, sival_ptr=%#lx",
1498 si->_sifields._rt.si_sigval.sival_int,
1499 (unsigned long) si->_sifields._rt.si_sigval.sival_ptr);
1508 sys_rt_sigqueueinfo(tcp)
1511 if (entering(tcp)) {
1513 tprintf("%lu, ", tcp->u_arg[0]);
1514 printsignal(tcp->u_arg[1]);
1516 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1517 tprintf("%#lx", tcp->u_arg[2]);
1524 int sys_rt_sigtimedwait(tcp)
1527 if (entering(tcp)) {
1530 if (copy_sigset_len(tcp, tcp->u_arg[0],
1531 &sigset, tcp->u_arg[3]) < 0)
1534 printsigmask(sigset, 1);
1539 tprintf("%#lx", tcp->u_arg[0]);
1542 if (umove(tcp, tcp->u_arg[1], &si) < 0)
1543 tprintf("%#lx", tcp->u_arg[1]);
1547 tprintf(", %#lx", tcp->u_arg[2]);
1548 tprintf(", %d", (int) tcp->u_arg[3]);