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>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6 * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Linux for s390 port by D.J. Barrow
8 * <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com>
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 #include <sys/ucontext.h>
46 #if HAVE_LINUX_PTRACE_H
48 #include <linux/ptrace.h>
53 #ifndef PTRACE_PEEKUSR
54 # define PTRACE_PEEKUSR PTRACE_PEEKUSER
56 #ifndef PTRACE_POKEUSR
57 # define PTRACE_POKEUSR PTRACE_POKEUSER
64 # include <asm/ptrace_offsets.h>
67 #ifdef HAVE_ASM_SIGCONTEXT_H
68 #include <asm/sigcontext.h>
76 #else /* !HAVE_ASM_SIGCONTEXT_H */
78 struct sigcontext_struct {
79 unsigned short gs, __gsh;
80 unsigned short fs, __fsh;
81 unsigned short es, __esh;
82 unsigned short ds, __dsh;
94 unsigned short cs, __csh;
96 unsigned long esp_at_signal;
97 unsigned short ss, __ssh;
99 unsigned long oldmask;
106 unsigned long sc_mask;
107 unsigned long sc_usp;
112 unsigned short sc_sr;
114 unsigned short sc_formatvec;
118 #endif /* !HAVE_ASM_SIGCONTEXT_H */
128 char *signalent0[] = {
129 #include "signalent.h"
131 int nsignals0 = sizeof signalent0 / sizeof signalent0[0];
133 #if SUPPORTED_PERSONALITIES >= 2
134 char *signalent1[] = {
135 #include "signalent1.h"
137 int nsignals1 = sizeof signalent1 / sizeof signalent1[0];
138 #endif /* SUPPORTED_PERSONALITIES >= 2 */
140 #if SUPPORTED_PERSONALITIES >= 3
141 char *signalent2[] = {
142 #include "signalent2.h"
144 int nsignals2 = sizeof signalent2 / sizeof signalent2[0];
145 #endif /* SUPPORTED_PERSONALITIES >= 3 */
152 static struct xlat sigvec_flags[] = {
153 { SV_ONSTACK, "SV_ONSTACK" },
154 { SV_INTERRUPT, "SV_INTERRUPT" },
155 { SV_RESETHAND, "SV_RESETHAND" },
156 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
162 #ifdef HAVE_SIGACTION
164 static struct xlat sigact_flags[] = {
166 { SA_STACK, "SA_STACK" },
169 { SA_RESTART, "SA_RESTART" },
172 { SA_INTERRUPT, "SA_INTERRUPT" },
175 { SA_NOMASK, "SA_NOMASK" },
178 { SA_ONESHOT, "SA_ONESHOT" },
181 { SA_SIGINFO, "SA_SIGINFO" },
184 { SA_RESETHAND, "SA_RESETHAND" },
187 { SA_ONSTACK, "SA_ONSTACK" },
190 { SA_NODEFER, "SA_NODEFER" },
193 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
196 { SA_NOCLDWAIT, "SA_NOCLDWAIT" },
199 { _SA_BSDCALL, "_SA_BSDCALL" },
204 static struct xlat sigprocmaskcmds[] = {
205 { SIG_BLOCK, "SIG_BLOCK" },
206 { SIG_UNBLOCK, "SIG_UNBLOCK" },
207 { SIG_SETMASK, "SIG_SETMASK" },
209 { SIG_SETMASK32,"SIG_SETMASK32" },
214 #endif /* HAVE_SIGACTION */
216 /* Anonymous realtime signals. */
217 /* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
218 constant. This is what we want. Otherwise, just use SIGRTMIN. */
221 #define __SIGRTMIN SIGRTMIN
222 #define __SIGRTMAX SIGRTMAX /* likewise */
231 if (sig < nsignals) {
232 return signalent[sig];
234 } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) {
235 sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN));
237 #endif /* SIGRTMIN */
239 sprintf(buf, "%d", sig);
256 copy_sigset_len(tcp, addr, s, len)
262 if (len > sizeof(*s))
265 if (umoven(tcp, addr, len, (char *)s) < 0)
271 /* Original sigset is unsigned long */
272 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long))
274 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t))
278 sprintsigmask(s, mask, rt)
281 int rt; /* set might include realtime sigs */
286 static char outstr[256];
289 s = outstr + strlen(outstr);
294 maxsigs = __SIGRTMAX; /* instead */
296 for (i = 1; i < maxsigs; i++) {
297 if (sigismember(mask, i) == 1)
300 if (nsigs >= nsignals * 2 / 3) {
302 for (i = 1; i < maxsigs; i++) {
303 switch (sigismember(mask, i)) {
315 for (i = 1; i < maxsigs; i++) {
316 if (sigismember(mask, i) == 1) {
317 sprintf(s, format, signame(i) + 3); s += strlen(s);
327 printsigmask(mask, rt)
331 tprintf("%s", sprintsigmask("", mask, rt));
338 tprintf(signame(nr));
342 * Check process TCP for the disposition of signal SIG.
343 * Return 1 if the process would somehow manage to survive signal SIG,
344 * else return 0. This routine will never be called with SIGKILL.
347 sigishandled(tcp, sig)
357 unsigned int signalled, blocked, ignored, caught;
359 /* This is incredibly costly but it's worth it. */
360 sprintf(sname, "/proc/%d/stat", tcp->pid);
361 if ((sfd = open(sname, O_RDONLY)) == -1) {
365 i = read(sfd, buf, 1024);
369 * Skip the extraneous fields. This loses if the
370 * command name has any spaces in it. So be it.
372 for (i = 0, s = buf; i < 30; i++) {
373 while (*++s != ' ') {
378 if (sscanf(s, "%u%u%u%u",
379 &signalled, &blocked, &ignored, &caught) != 4) {
380 fprintf(stderr, "/proc/pid/stat format error\n");
384 fprintf(stderr, "sigs: %08x %08x %08x %08x\n",
385 signalled, blocked, ignored, caught);
387 if ((ignored & sigmask(sig)) || (caught & sigmask(sig)))
394 if (upeek(tcp->pid, uoff(u_signal[0]) + sig*sizeof(u_signal),
395 (long *) &u_signal) < 0) {
398 if (u_signal != SIG_DFL)
404 * Since procfs doesn't interfere with wait I think it is safe
405 * to punt on this question. If not, the information is there.
417 #if defined(SIGURG) && SIGURG != SIGIO
421 /* Gloria Gaynor says ... */
440 printsignal(tcp->u_arg[0]);
442 addr = tcp->u_arg[1];
444 addr = tcp->u_arg[2];
448 else if (!verbose(tcp))
449 tprintf("%#lx", addr);
450 else if (umove(tcp, addr, &sv) < 0)
453 switch ((int) sv.sv_handler) {
455 tprintf("{SIG_ERR}");
458 tprintf("{SIG_DFL}");
461 if (tcp->u_arg[0] == SIGTRAP) {
462 tcp->flags |= TCB_SIGTRAPPED;
463 kill(tcp->pid, SIGSTOP);
465 tprintf("{SIG_IGN}");
468 if (tcp->u_arg[0] == SIGTRAP) {
469 tcp->flags |= TCB_SIGTRAPPED;
470 kill(tcp->pid, SIGSTOP);
475 if (tcp->u_arg[0] == SIGTRAP) {
476 tcp->flags |= TCB_SIGTRAPPED;
477 kill(tcp->pid, SIGSTOP);
479 tprintf("{%#lx, ", (unsigned long) sv.sv_handler);
480 printsigmask(&sv.sv_mask, 0);
482 if (!printflags(sigvec_flags, sv.sv_flags))
496 if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */
498 long_to_sigset(tcp->u_arg[0], &sigm);
499 printsigmask(&sigm, 0);
512 addr = tcp->u_arg[0];
514 addr = tcp->u_arg[1];
517 else if (umove(tcp, addr, &ss) < 0)
518 tprintf("%#lx", addr);
520 tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp);
521 tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO");
545 long_to_sigset(tcp->u_arg[0], &sigm);
546 printsigmask(&sigm, 0);
547 if ((tcp->u_arg[0] & sigmask(SIGTRAP))) {
548 /* Mark attempt to block SIGTRAP */
549 tcp->flags |= TCB_SIGTRAPPED;
550 /* Send unblockable signal */
551 kill(tcp->pid, SIGSTOP);
554 else if (!syserror(tcp)) {
556 long_to_sigset(tcp->u_rval, &sigm);
557 tcp->auxstr = sprintsigmask("old mask ", &sigm, 0);
559 return RVAL_HEX | RVAL_STR;
568 return sys_sigsetmask(tcp);
573 #ifdef HAVE_SIGACTION
576 struct old_sigaction {
577 __sighandler_t __sa_handler;
578 unsigned long sa_mask;
579 unsigned long sa_flags;
580 void (*sa_restorer)(void);
582 #define SA_HANDLER __sa_handler
586 #define SA_HANDLER sa_handler
596 struct old_sigaction sa;
603 printsignal(tcp->u_arg[0]);
605 addr = tcp->u_arg[1];
607 addr = tcp->u_arg[2];
610 else if (!verbose(tcp))
611 tprintf("%#lx", addr);
612 else if (umove(tcp, addr, &sa) < 0)
615 switch ((long) sa.SA_HANDLER) {
617 tprintf("{SIG_ERR}");
620 tprintf("{SIG_DFL}");
624 if (tcp->u_arg[0] == SIGTRAP) {
625 tcp->flags |= TCB_SIGTRAPPED;
626 kill(tcp->pid, SIGSTOP);
629 tprintf("{SIG_IGN}");
633 if (tcp->u_arg[0] == SIGTRAP) {
634 tcp->flags |= TCB_SIGTRAPPED;
635 kill(tcp->pid, SIGSTOP);
638 tprintf("{%#lx, ", (long) sa.SA_HANDLER);
640 printsigmask (&sa.sa_mask, 0);
642 long_to_sigset(sa.sa_mask, &sigset);
643 printsigmask(&sigset, 0);
646 if (!printflags(sigact_flags, sa.sa_flags))
655 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
665 printsignal(tcp->u_arg[0]);
666 switch (tcp->u_arg[1]) {
675 if (tcp->u_arg[0] == SIGTRAP) {
676 tcp->flags |= TCB_SIGTRAPPED;
677 kill(tcp->pid, SIGSTOP);
684 if (tcp->u_arg[0] == SIGTRAP) {
685 tcp->flags |= TCB_SIGTRAPPED;
686 kill(tcp->pid, SIGSTOP);
689 tprintf("%#lx", tcp->u_arg[1]);
695 #endif /* HAVE_SIGACTION */
705 struct sigcontext_struct sc;
709 if (upeek(tcp->pid,PT_GPR15,&usp)<0)
711 if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0)
714 memcpy(&tcp->u_arg[1],&sc.oldmask[0],sizeof(sigset_t));
716 tcp->u_rval = tcp->u_error = 0;
717 if (tcp->u_arg[0] == 0)
719 tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1]);
720 return RVAL_NONE | RVAL_STR;
726 struct sigcontext_struct sc;
730 if (upeek(tcp->pid, 4*UESP, &esp) < 0)
732 if (umove(tcp, esp, &sc) < 0)
735 tcp->u_arg[1] = sc.oldmask;
739 long_to_sigset(tcp->u_arg[1], &sigm);
740 tcp->u_rval = tcp->u_error = 0;
741 if (tcp->u_arg[0] == 0)
743 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
744 return RVAL_NONE | RVAL_STR;
749 struct sigcontext sc;
754 if (upeek(tcp->pid, PT_R12, &sp) < 0)
756 if (umove(tcp, sp + 16, &sc) < 0)
759 memcpy(tcp->u_arg + 1, &sc.sc_mask, sizeof(tcp->u_arg[1]));
762 tcp->u_rval = tcp->u_error = 0;
763 if (tcp->u_arg[0] == 0)
765 tcp->auxstr = sprintsigmask("mask now ", tcp->u_arg[1]);
766 return RVAL_NONE | RVAL_STR;
772 struct sigcontext_struct sc;
776 if (upeek(tcp->pid, 4*PT_R1, &esp) < 0)
778 if (umove(tcp, esp, &sc) < 0)
781 tcp->u_arg[1] = sc.oldmask;
785 long_to_sigset(tcp->u_arg[1], &sigm);
786 tcp->u_rval = tcp->u_error = 0;
787 if (tcp->u_arg[0] == 0)
789 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
790 return RVAL_NONE | RVAL_STR;
796 struct sigcontext sc;
800 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
802 if (umove(tcp, usp, &sc) < 0)
805 tcp->u_arg[1] = sc.sc_mask;
809 long_to_sigset(tcp->u_arg[1], &sigm);
810 tcp->u_rval = tcp->u_error = 0;
811 if (tcp->u_arg[0] == 0)
813 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
814 return RVAL_NONE | RVAL_STR;
820 struct sigcontext_struct sc;
824 if (upeek(tcp->pid, REG_FP, &fp) < 0)
826 if (umove(tcp, fp, &sc) < 0)
829 tcp->u_arg[1] = sc.sc_mask;
833 long_to_sigset(tcp->u_arg[1], &sigm);
834 tcp->u_rval = tcp->u_error = 0;
835 if (tcp->u_arg[0] == 0)
837 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
838 return RVAL_NONE | RVAL_STR;
847 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
848 perror("sigreturn: PTRACE_GETREGS ");
854 if(umove(tcp, i1, &si) < 0) {
855 perror("sigreturn: umove ");
859 tcp->u_arg[1] = si.si_mask;
862 long_to_sigset(tcp->u_arg[1], &sigm);
863 tcp->u_rval = tcp->u_error = 0;
864 if(tcp->u_arg[0] == 0)
866 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
867 return RVAL_NONE | RVAL_STR;
873 struct sigcontext sc;
877 if (upeek(tcp->pid, REG_SP, &sp) < 0)
879 if (umove(tcp, sp, &sc) < 0)
882 tcp->u_arg[1] = sc.sc_sigset;
884 tcp->u_rval = tcp->u_error = 0;
885 if(tcp->u_arg[0] == 0)
887 tcp->auxstr = sprintsigmask("mask now ", tcp->u_arg[1]);
888 return RVAL_NONE | RVAL_STR;
895 #endif /* !POWERPC */
907 long_to_sigset(tcp->u_rval, &sigm);
908 tcp->auxstr = sprintsigmask("mask ", &sigm, 0);
910 return RVAL_HEX | RVAL_STR;
919 long_to_sigset(tcp->u_arg[2], &sigm);
921 /* first two are not really arguments, but print them anyway */
922 /* nevermind, they are an anachronism now, too bad... */
923 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
925 printsigmask(&sigm, 0);
941 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
944 printsigmask(&sigset, 0);
948 static struct xlat ucontext_flags[] = {
949 { UC_SIGMASK, "UC_SIGMASK" },
950 { UC_STACK, "UC_STACK" },
951 { UC_CPU, "UC_CPU" },
953 { UC_FPU, "UC_FPU" },
956 { UC_INTR, "UC_INTR" },
963 #if defined SVR4 || defined LINUX
964 #if defined LINUX && !defined SS_ONSTACK
967 #if __GLIBC_MINOR__ == 0
977 static struct xlat sigaltstack_flags[] = {
978 { SS_ONSTACK, "SS_ONSTACK" },
979 { SS_DISABLE, "SS_DISABLE" },
986 printcontext(tcp, ucp)
992 tprintf("uc_flags=");
993 if (!printflags(ucontext_flags, ucp->uc_flags))
995 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
997 tprintf("uc_sigmask=");
998 printsigmask(ucp->uc_sigmask, 0);
1000 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
1001 (unsigned long) ucp->uc_stack.ss_sp,
1002 ucp->uc_stack.ss_size);
1003 if (!printflags(sigaltstack_flags, ucp->uc_stack.ss_flags))
1016 if (entering(tcp)) {
1019 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1022 printcontext(tcp, &uc);
1033 if (entering(tcp)) {
1036 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1039 printcontext(tcp, &uc);
1042 tcp->u_rval = tcp->u_error = 0;
1043 if (tcp->u_arg[0] == 0)
1055 print_stack_t(tcp, addr)
1060 if (umove(tcp, addr, &ss) < 0)
1062 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
1063 if (!printflags(sigaltstack_flags, ss.ss_flags))
1065 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
1070 sys_sigaltstack(tcp)
1073 if (entering(tcp)) {
1074 if (tcp->u_arg[0] == 0)
1076 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
1081 if (tcp->u_arg[1] == 0)
1083 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
1090 #ifdef HAVE_SIGACTION
1093 sys_sigprocmask(tcp)
1097 if (entering(tcp)) {
1098 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1100 printsigmask(tcp->u_arg[1], 0);
1102 else if (!syserror(tcp)) {
1103 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0);
1104 return RVAL_HEX | RVAL_STR;
1109 if (entering(tcp)) {
1111 if (tcp->u_arg[0] == 0)
1115 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1119 else if (copy_sigset(tcp, tcp->u_arg[1], &sigset) < 0)
1120 tprintf("%#lx, ", tcp->u_arg[1]);
1122 printsigmask(&sigset, 0);
1129 else if (syserror(tcp))
1130 tprintf("%#lx", tcp->u_arg[2]);
1131 else if (copy_sigset(tcp, tcp->u_arg[2], &sigset) < 0)
1134 printsigmask(&sigset, 0);
1140 #endif /* HAVE_SIGACTION */
1146 if (entering(tcp)) {
1147 tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1]));
1156 return sys_kill(tcp);
1167 tprintf("%#lx", tcp->u_arg[0]);
1168 else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1171 printsigmask(&sigset, 0);
1179 sys_rt_sigprocmask(tcp)
1184 /* Note: arg[3] is the length of the sigset. */
1185 if (entering(tcp)) {
1186 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1190 else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0)
1191 tprintf("%#lx, ", tcp->u_arg[1]);
1193 printsigmask(&sigset, 1);
1201 else if (syserror(tcp))
1202 tprintf("%#lx", tcp->u_arg[2]);
1203 else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0)
1206 printsigmask(&sigset, 1);
1207 tprintf(", %lu", tcp->u_arg[3]);
1212 #if __GLIBC_MINOR__ < 1
1213 /* Type for data associated with a signal. */
1214 typedef union sigval
1220 # define __SI_MAX_SIZE 128
1221 # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
1223 typedef struct siginfo
1225 int si_signo; /* Signal number. */
1226 int si_errno; /* If non-zero, an errno value associated with
1227 this signal, as defined in <errno.h>. */
1228 int si_code; /* Signal code. */
1232 int _pad[__SI_PAD_SIZE];
1237 __pid_t si_pid; /* Sending process ID. */
1238 __uid_t si_uid; /* Real user ID of sending process. */
1241 /* POSIX.1b timers. */
1244 unsigned int _timer1;
1245 unsigned int _timer2;
1248 /* POSIX.1b signals. */
1251 __pid_t si_pid; /* Sending process ID. */
1252 __uid_t si_uid; /* Real user ID of sending process. */
1253 sigval_t si_sigval; /* Signal value. */
1259 __pid_t si_pid; /* Which child. */
1260 int si_status; /* Exit value or signal. */
1265 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
1268 void *si_addr; /* Faulting insn/memory ref. */
1274 int si_band; /* Band event for SIGPOLL. */
1281 /* Structure describing the action to be taken when a signal arrives. */
1282 struct new_sigaction
1286 __sighandler_t __sa_handler;
1287 void (*__sa_sigaction) (int, siginfo_t *, void *);
1289 __sigaction_handler;
1290 unsigned long sa_flags;
1291 void (*sa_restorer) (void);
1292 unsigned long int sa_mask[2];
1297 sys_rt_sigaction(tcp)
1300 struct new_sigaction sa;
1304 if (entering(tcp)) {
1305 printsignal(tcp->u_arg[0]);
1307 addr = tcp->u_arg[1];
1309 addr = tcp->u_arg[2];
1312 else if (!verbose(tcp))
1313 tprintf("%#lx", addr);
1314 else if (umove(tcp, addr, &sa) < 0)
1317 switch ((long) sa.__sigaction_handler.__sa_handler) {
1318 case (long) SIG_ERR:
1319 tprintf("{SIG_ERR}");
1321 case (long) SIG_DFL:
1322 tprintf("{SIG_DFL}");
1324 case (long) SIG_IGN:
1325 tprintf("{SIG_IGN}");
1329 (long) sa.__sigaction_handler.__sa_handler);
1330 sigemptyset(&sigset);
1332 if (tcp->u_arg[4] <= sizeof(sigset))
1333 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
1335 if (tcp->u_arg[3] <= sizeof(sigset))
1336 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
1339 memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
1340 printsigmask(&sigset, 1);
1342 if (!printflags(sigact_flags, sa.sa_flags))
1351 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
1352 #elif defined(ALPHA)
1353 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
1355 tprintf(", %lu", addr = tcp->u_arg[3]);
1361 sys_rt_sigpending(tcp)
1368 tprintf("%#lx", tcp->u_arg[0]);
1369 else if (copy_sigset_len(tcp, tcp->u_arg[0],
1370 &sigset, tcp->u_arg[1]) < 0)
1373 printsigmask(&sigset, 1);
1378 sys_rt_sigsuspend(tcp)
1381 if (entering(tcp)) {
1383 if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0)
1386 printsigmask(&sigm, 1);
1391 #define ILL_ILLOPC 1 /* illegal opcode */
1392 #define ILL_ILLOPN 2 /* illegal operand */
1393 #define ILL_ILLADR 3 /* illegal addressing mode */
1394 #define ILL_ILLTRP 4 /* illegal trap */
1395 #define ILL_PRVOPC 5 /* privileged opcode */
1396 #define ILL_PRVREG 6 /* privileged register */
1397 #define ILL_COPROC 7 /* coprocessor error */
1398 #define ILL_BADSTK 8 /* internal stack error */
1399 #define FPE_INTDIV 1 /* integer divide by zero */
1400 #define FPE_INTOVF 2 /* integer overflow */
1401 #define FPE_FLTDIV 3 /* floating point divide by zero */
1402 #define FPE_FLTOVF 4 /* floating point overflow */
1403 #define FPE_FLTUND 5 /* floating point underflow */
1404 #define FPE_FLTRES 6 /* floating point inexact result */
1405 #define FPE_FLTINV 7 /* floating point invalid operation */
1406 #define FPE_FLTSUB 8 /* subscript out of range */
1407 #define SEGV_MAPERR 1 /* address not mapped to object */
1408 #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
1409 #define BUS_ADRALN 1 /* invalid address alignment */
1410 #define BUS_ADRERR 2 /* non-existant physical address */
1411 #define BUS_OBJERR 3 /* object specific hardware error */
1412 #define TRAP_BRKPT 1 /* process breakpoint */
1413 #define TRAP_TRACE 2 /* process trace trap */
1414 #define CLD_EXITED 1 /* child has exited */
1415 #define CLD_KILLED 2 /* child was killed */
1416 #define CLD_DUMPED 3 /* child terminated abnormally */
1417 #define CLD_TRAPPED 4 /* traced child has trapped */
1418 #define CLD_STOPPED 5 /* child has stopped */
1419 #define CLD_CONTINUED 6 /* stopped child has continued */
1420 #define POLL_IN 1 /* data input available */
1421 #define POLL_OUT 2 /* output buffers available */
1422 #define POLL_MSG 3 /* input message available */
1423 #define POLL_ERR 4 /* i/o error */
1424 #define POLL_PRI 5 /* high priority input available */
1425 #define POLL_HUP 6 /* device disconnected */
1426 #define SI_USER 0 /* sent by kill, sigsend, raise */
1427 #define SI_QUEUE -1 /* sent by sigqueue */
1428 #define SI_TIMER -2 /* sent by timer expiration */
1429 #define SI_MESGQ -3 /* sent by real time mesq state change */
1430 #define SI_ASYNCIO -4 /* sent by AIO completion */
1445 static struct xlat sigill_flags[] = {
1446 {ILL_ILLOPC, "ILL_ILLOPC"},
1447 {ILL_ILLOPN, "ILL_ILLOPN"},
1448 {ILL_ILLADR, "ILL_ILLADR"},
1449 {ILL_ILLTRP, "ILL_ILLTRP"},
1450 {ILL_PRVOPC, "ILL_PRVOPC"},
1451 {ILL_PRVREG, "ILL_PRVREG"},
1452 {ILL_COPROC, "ILL_COPROC"},
1453 {ILL_BADSTK, "ILL_BADSTK"},
1457 static struct xlat sigfpe_flags[] = {
1458 {FPE_INTDIV, "FPE_INTDIV"},
1459 {FPE_INTOVF, "FPE_INTOVF"},
1460 {FPE_FLTDIV, "FPE_FLTDIV"},
1461 {FPE_FLTOVF, "FPE_FLTOVF"},
1462 {FPE_FLTUND, "FPE_FLTUND"},
1463 {FPE_FLTRES, "FPE_FLTRES"},
1464 {FPE_FLTINV, "FPE_FLTINV"},
1465 {FPE_FLTSUB, "FPE_FLTSUB"},
1469 static struct xlat sigsegv_flags[] = {
1470 {SEGV_MAPERR, "SEGV_MAPERR"},
1471 {SEGV_ACCERR, "SEGV_ACCERR"},
1475 static struct xlat sigbus_flags[] = {
1476 {BUS_ADRALN, "BUS_ADRALN"},
1477 {BUS_ADRERR, "BUS_ADRERR"},
1478 {BUS_OBJERR, "BUS_OBJERR"},
1482 static struct xlat sigtrap_flags[] = {
1483 {TRAP_BRKPT, "TRAP_BRKPT"},
1484 {TRAP_TRACE, "TRAP_TRACE"},
1488 static struct xlat sigchld_flags[] = {
1489 {CLD_EXITED, "CLD_EXITED"},
1490 {CLD_KILLED, "CLD_KILLED"},
1491 {CLD_DUMPED, "CLD_DUMPED"},
1492 {CLD_TRAPPED, "CLD_TRAPPED"},
1493 {CLD_STOPPED, "CLD_STOPPED"},
1494 {CLD_CONTINUED, "CLD_CONTINUED"},
1498 static struct xlat sigpoll_flags[] = {
1499 {POLL_IN, "POLL_IN"},
1500 {POLL_OUT, "POLL_OUT"},
1501 {POLL_MSG, "POLL_MSG"},
1502 {POLL_ERR, "POLL_ERR"},
1503 {POLL_PRI, "POLL_PRI"},
1504 {POLL_HUP, "POLL_HUP"},
1508 static struct xlat siginfo_flags[] = {
1509 {SI_USER, "SI_USER"},
1510 {SI_QUEUE, "SI_QUEUE"},
1511 {SI_TIMER, "SI_TIMER"},
1512 {SI_MESGQ, "SI_MESGQ"},
1513 {SI_ASYNCIO, "SI_ASYNCIO"},
1518 printsiginfo(tcp, si)
1522 tprintf("{si_signo=");
1523 printsignal(si->si_signo);
1524 tprintf(", si_errno=%d, si_code=", si->si_errno);
1525 switch(si->si_signo)
1528 if (!printflags(sigill_flags, si->si_code))
1529 tprintf("%d /* ILL_??? */", si->si_code);
1530 tprintf(", si_addr=%lx",
1531 (unsigned long) si->_sifields._sigfault.si_addr);
1534 if (!printflags(sigfpe_flags, si->si_code))
1535 tprintf("%d /* FPE_??? */", si->si_code);
1536 tprintf(", si_addr=%lx",
1537 (unsigned long) si->_sifields._sigfault.si_addr);
1540 if (!printflags(sigsegv_flags, si->si_code))
1541 tprintf("%d /* SEGV_??? */", si->si_code);
1542 tprintf(", si_addr=%lx",
1543 (unsigned long) si->_sifields._sigfault.si_addr);
1546 if (!printflags(sigbus_flags, si->si_code))
1547 tprintf("%d /* BUS_??? */", si->si_code);
1548 tprintf(", si_addr=%lx",
1549 (unsigned long) si->_sifields._sigfault.si_addr);
1552 if (!printflags(sigtrap_flags, si->si_code))
1553 tprintf("%d /* TRAP_??? */", si->si_code);
1556 if (!printflags(sigchld_flags, si->si_code))
1557 tprintf("%d /* CLD_??? */", si->si_code);
1561 tprintf(", si_pid=%d, si_uid=%d, si_status=%d, si_utime=%lu, si_stime=%lu",
1562 si->_sifields._kill.si_pid,
1563 si->_sifields._kill.si_uid,
1564 si->_sifields._sigchld.si_status,
1565 si->_sifields._sigchld.si_utime,
1566 si->_sifields._sigchld.si_stime);
1569 if (!printflags(sigpoll_flags, si->si_code))
1570 tprintf("%d /* POLL_??? */", si->si_code);
1571 if (si->si_code == POLL_IN
1572 || si->si_code == POLL_OUT
1573 || si->si_code == POLL_MSG)
1574 tprintf(", si_bind=%lu, si_fd=%d",
1575 (unsigned long) si->_sifields._sigpoll.si_band,
1576 si->_sifields._sigpoll.si_fd);
1579 if (!printflags(siginfo_flags, si->si_code))
1580 tprintf("%d /* SI_??? */", si->si_code);
1581 tprintf(", si_pid=%lu, si_uid=%lu, si_value={",
1582 (unsigned long) si->_sifields._rt.si_pid,
1583 (unsigned long) si->_sifields._rt.si_uid);
1587 tprintf("sival_int=%u, sival_ptr=%#lx",
1588 si->_sifields._rt.si_sigval.sival_int,
1589 (unsigned long) si->_sifields._rt.si_sigval.sival_ptr);
1598 sys_rt_sigqueueinfo(tcp)
1601 if (entering(tcp)) {
1603 tprintf("%lu, ", tcp->u_arg[0]);
1604 printsignal(tcp->u_arg[1]);
1606 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1607 tprintf("%#lx", tcp->u_arg[2]);
1614 int sys_rt_sigtimedwait(tcp)
1617 if (entering(tcp)) {
1620 if (copy_sigset_len(tcp, tcp->u_arg[0],
1621 &sigset, tcp->u_arg[3]) < 0)
1624 printsigmask(&sigset, 1);
1629 tprintf("%#lx", tcp->u_arg[0]);
1632 if (umove(tcp, tcp->u_arg[1], &si) < 0)
1633 tprintf("%#lx", tcp->u_arg[1]);
1637 tprintf(", %#lx", tcp->u_arg[2]);
1638 tprintf(", %d", (int) tcp->u_arg[3]);