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>
48 #ifndef PTRACE_PEEKUSR
49 # define PTRACE_PEEKUSR PTRACE_PEEKUSER
51 #ifndef PTRACE_POKEUSR
52 # define PTRACE_POKEUSR PTRACE_POKEUSER
54 #elif defined(HAVE_LINUX_PTRACE_H)
56 #include <linux/ptrace.h>
63 # include <asm/ptrace_offsets.h>
66 #ifdef HAVE_ASM_SIGCONTEXT_H
67 #include <asm/sigcontext.h>
75 #else /* !HAVE_ASM_SIGCONTEXT_H */
77 struct sigcontext_struct {
78 unsigned short gs, __gsh;
79 unsigned short fs, __fsh;
80 unsigned short es, __esh;
81 unsigned short ds, __dsh;
93 unsigned short cs, __csh;
95 unsigned long esp_at_signal;
96 unsigned short ss, __ssh;
98 unsigned long oldmask;
105 unsigned long sc_mask;
106 unsigned long sc_usp;
111 unsigned short sc_sr;
113 unsigned short sc_formatvec;
117 #endif /* !HAVE_ASM_SIGCONTEXT_H */
127 char *signalent0[] = {
128 #include "signalent.h"
130 int nsignals0 = sizeof signalent0 / sizeof signalent0[0];
132 #if SUPPORTED_PERSONALITIES >= 2
133 char *signalent1[] = {
134 #include "signalent1.h"
136 int nsignals1 = sizeof signalent1 / sizeof signalent1[0];
137 #endif /* SUPPORTED_PERSONALITIES >= 2 */
139 #if SUPPORTED_PERSONALITIES >= 3
140 char *signalent2[] = {
141 #include "signalent2.h"
143 int nsignals2 = sizeof signalent2 / sizeof signalent2[0];
144 #endif /* SUPPORTED_PERSONALITIES >= 3 */
151 static struct xlat sigvec_flags[] = {
152 { SV_ONSTACK, "SV_ONSTACK" },
153 { SV_INTERRUPT, "SV_INTERRUPT" },
154 { SV_RESETHAND, "SV_RESETHAND" },
155 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
161 #ifdef HAVE_SIGACTION
163 static struct xlat sigact_flags[] = {
165 { SA_RESTORER, "SA_RESTORER" },
168 { SA_STACK, "SA_STACK" },
171 { SA_RESTART, "SA_RESTART" },
174 { SA_INTERRUPT, "SA_INTERRUPT" },
177 { SA_NOMASK, "SA_NOMASK" },
180 { SA_ONESHOT, "SA_ONESHOT" },
183 { SA_SIGINFO, "SA_SIGINFO" },
186 { SA_RESETHAND, "SA_RESETHAND" },
189 { SA_ONSTACK, "SA_ONSTACK" },
192 { SA_NODEFER, "SA_NODEFER" },
195 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
198 { SA_NOCLDWAIT, "SA_NOCLDWAIT" },
201 { _SA_BSDCALL, "_SA_BSDCALL" },
206 static struct xlat sigprocmaskcmds[] = {
207 { SIG_BLOCK, "SIG_BLOCK" },
208 { SIG_UNBLOCK, "SIG_UNBLOCK" },
209 { SIG_SETMASK, "SIG_SETMASK" },
211 { SIG_SETMASK32,"SIG_SETMASK32" },
216 #endif /* HAVE_SIGACTION */
218 /* Anonymous realtime signals. */
219 /* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
220 constant. This is what we want. Otherwise, just use SIGRTMIN. */
223 #define __SIGRTMIN SIGRTMIN
224 #define __SIGRTMAX SIGRTMAX /* likewise */
233 if (sig < nsignals) {
234 return signalent[sig];
236 } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) {
237 sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN));
239 #endif /* SIGRTMIN */
241 sprintf(buf, "%d", sig);
258 copy_sigset_len(tcp, addr, s, len)
264 if (len > sizeof(*s))
267 if (umoven(tcp, addr, len, (char *)s) < 0)
273 /* Original sigset is unsigned long */
274 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long))
276 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t))
280 sprintsigmask(s, mask, rt)
283 int rt; /* set might include realtime sigs */
288 static char outstr[256];
291 s = outstr + strlen(outstr);
296 maxsigs = __SIGRTMAX; /* instead */
298 for (i = 1; i < maxsigs; i++) {
299 if (sigismember(mask, i) == 1)
302 if (nsigs >= nsignals * 2 / 3) {
304 for (i = 1; i < maxsigs; i++) {
305 switch (sigismember(mask, i)) {
317 for (i = 1; i < maxsigs; i++) {
318 if (sigismember(mask, i) == 1) {
319 sprintf(s, format, signame(i) + 3); s += strlen(s);
329 printsigmask(mask, rt)
333 tprintf("%s", sprintsigmask("", mask, rt));
340 tprintf(signame(nr));
344 * Check process TCP for the disposition of signal SIG.
345 * Return 1 if the process would somehow manage to survive signal SIG,
346 * else return 0. This routine will never be called with SIGKILL.
349 sigishandled(tcp, sig)
359 unsigned int signalled, blocked, ignored, caught;
361 /* This is incredibly costly but it's worth it. */
362 sprintf(sname, "/proc/%d/stat", tcp->pid);
363 if ((sfd = open(sname, O_RDONLY)) == -1) {
367 i = read(sfd, buf, 1024);
371 * Skip the extraneous fields. This loses if the
372 * command name has any spaces in it. So be it.
374 for (i = 0, s = buf; i < 30; i++) {
375 while (*++s != ' ') {
380 if (sscanf(s, "%u%u%u%u",
381 &signalled, &blocked, &ignored, &caught) != 4) {
382 fprintf(stderr, "/proc/pid/stat format error\n");
386 fprintf(stderr, "sigs: %08x %08x %08x %08x\n",
387 signalled, blocked, ignored, caught);
389 if ((ignored & sigmask(sig)) || (caught & sigmask(sig)))
396 if (upeek(tcp->pid, uoff(u_signal[0]) + sig*sizeof(u_signal),
397 (long *) &u_signal) < 0) {
400 if (u_signal != SIG_DFL)
406 * Since procfs doesn't interfere with wait I think it is safe
407 * to punt on this question. If not, the information is there.
419 #if defined(SIGURG) && SIGURG != SIGIO
423 /* Gloria Gaynor says ... */
442 printsignal(tcp->u_arg[0]);
444 addr = tcp->u_arg[1];
446 addr = tcp->u_arg[2];
450 else if (!verbose(tcp))
451 tprintf("%#lx", addr);
452 else if (umove(tcp, addr, &sv) < 0)
455 switch ((int) sv.sv_handler) {
457 tprintf("{SIG_ERR}");
460 tprintf("{SIG_DFL}");
463 if (tcp->u_arg[0] == SIGTRAP) {
464 tcp->flags |= TCB_SIGTRAPPED;
465 kill(tcp->pid, SIGSTOP);
467 tprintf("{SIG_IGN}");
470 if (tcp->u_arg[0] == SIGTRAP) {
471 tcp->flags |= TCB_SIGTRAPPED;
472 kill(tcp->pid, SIGSTOP);
477 if (tcp->u_arg[0] == SIGTRAP) {
478 tcp->flags |= TCB_SIGTRAPPED;
479 kill(tcp->pid, SIGSTOP);
481 tprintf("{%#lx, ", (unsigned long) sv.sv_handler);
482 printsigmask(&sv.sv_mask, 0);
484 if (!printflags(sigvec_flags, sv.sv_flags))
498 if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */
500 long_to_sigset(tcp->u_arg[0], &sigm);
501 printsigmask(&sigm, 0);
514 addr = tcp->u_arg[0];
516 addr = tcp->u_arg[1];
519 else if (umove(tcp, addr, &ss) < 0)
520 tprintf("%#lx", addr);
522 tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp);
523 tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO");
547 long_to_sigset(tcp->u_arg[0], &sigm);
548 printsigmask(&sigm, 0);
549 if ((tcp->u_arg[0] & sigmask(SIGTRAP))) {
550 /* Mark attempt to block SIGTRAP */
551 tcp->flags |= TCB_SIGTRAPPED;
552 /* Send unblockable signal */
553 kill(tcp->pid, SIGSTOP);
556 else if (!syserror(tcp)) {
558 long_to_sigset(tcp->u_rval, &sigm);
559 tcp->auxstr = sprintsigmask("old mask ", &sigm, 0);
561 return RVAL_HEX | RVAL_STR;
570 return sys_sigsetmask(tcp);
575 #ifdef HAVE_SIGACTION
578 struct old_sigaction {
579 __sighandler_t __sa_handler;
580 unsigned long sa_mask;
581 unsigned long sa_flags;
582 void (*sa_restorer)(void);
584 #define SA_HANDLER __sa_handler
588 #define SA_HANDLER sa_handler
598 struct old_sigaction sa;
605 printsignal(tcp->u_arg[0]);
607 addr = tcp->u_arg[1];
609 addr = tcp->u_arg[2];
612 else if (!verbose(tcp))
613 tprintf("%#lx", addr);
614 else if (umove(tcp, addr, &sa) < 0)
617 switch ((long) sa.SA_HANDLER) {
619 tprintf("{SIG_ERR}");
622 tprintf("{SIG_DFL}");
626 if (tcp->u_arg[0] == SIGTRAP) {
627 tcp->flags |= TCB_SIGTRAPPED;
628 kill(tcp->pid, SIGSTOP);
631 tprintf("{SIG_IGN}");
635 if (tcp->u_arg[0] == SIGTRAP) {
636 tcp->flags |= TCB_SIGTRAPPED;
637 kill(tcp->pid, SIGSTOP);
640 tprintf("{%#lx, ", (long) sa.SA_HANDLER);
642 printsigmask (&sa.sa_mask, 0);
644 long_to_sigset(sa.sa_mask, &sigset);
645 printsigmask(&sigset, 0);
648 if (!printflags(sigact_flags, sa.sa_flags))
657 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
667 printsignal(tcp->u_arg[0]);
668 switch (tcp->u_arg[1]) {
677 if (tcp->u_arg[0] == SIGTRAP) {
678 tcp->flags |= TCB_SIGTRAPPED;
679 kill(tcp->pid, SIGSTOP);
686 if (tcp->u_arg[0] == SIGTRAP) {
687 tcp->flags |= TCB_SIGTRAPPED;
688 kill(tcp->pid, SIGSTOP);
691 tprintf("%#lx", tcp->u_arg[1]);
697 #endif /* HAVE_SIGACTION */
707 struct sigcontext_struct sc;
711 if (upeek(tcp->pid,PT_GPR15,&usp)<0)
713 if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0)
716 memcpy(&tcp->u_arg[1],&sc.oldmask[0],sizeof(sigset_t));
718 tcp->u_rval = tcp->u_error = 0;
719 if (tcp->u_arg[0] == 0)
721 tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1]);
722 return RVAL_NONE | RVAL_STR;
728 struct sigcontext_struct sc;
732 if (upeek(tcp->pid, 4*UESP, &esp) < 0)
734 if (umove(tcp, esp, &sc) < 0)
737 tcp->u_arg[1] = sc.oldmask;
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;
751 struct sigcontext sc;
756 if (upeek(tcp->pid, PT_R12, &sp) < 0)
758 if (umove(tcp, sp + 16, &sc) < 0)
761 memcpy(tcp->u_arg + 1, &sc.sc_mask, sizeof(tcp->u_arg[1]));
764 tcp->u_rval = tcp->u_error = 0;
765 if (tcp->u_arg[0] == 0)
767 tcp->auxstr = sprintsigmask("mask now ", tcp->u_arg[1]);
768 return RVAL_NONE | RVAL_STR;
774 struct sigcontext_struct sc;
778 if (upeek(tcp->pid, 4*PT_R1, &esp) < 0)
780 if (umove(tcp, esp, &sc) < 0)
783 tcp->u_arg[1] = sc.oldmask;
787 long_to_sigset(tcp->u_arg[1], &sigm);
788 tcp->u_rval = tcp->u_error = 0;
789 if (tcp->u_arg[0] == 0)
791 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
792 return RVAL_NONE | RVAL_STR;
798 struct sigcontext sc;
802 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
804 if (umove(tcp, usp, &sc) < 0)
807 tcp->u_arg[1] = sc.sc_mask;
811 long_to_sigset(tcp->u_arg[1], &sigm);
812 tcp->u_rval = tcp->u_error = 0;
813 if (tcp->u_arg[0] == 0)
815 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
816 return RVAL_NONE | RVAL_STR;
822 struct sigcontext_struct sc;
826 if (upeek(tcp->pid, REG_FP, &fp) < 0)
828 if (umove(tcp, fp, &sc) < 0)
831 tcp->u_arg[1] = sc.sc_mask;
835 long_to_sigset(tcp->u_arg[1], &sigm);
836 tcp->u_rval = tcp->u_error = 0;
837 if (tcp->u_arg[0] == 0)
839 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
840 return RVAL_NONE | RVAL_STR;
849 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
850 perror("sigreturn: PTRACE_GETREGS ");
856 if(umove(tcp, i1, &si) < 0) {
857 perror("sigreturn: umove ");
861 tcp->u_arg[1] = si.si_mask;
864 long_to_sigset(tcp->u_arg[1], &sigm);
865 tcp->u_rval = tcp->u_error = 0;
866 if(tcp->u_arg[0] == 0)
868 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
869 return RVAL_NONE | RVAL_STR;
875 struct sigcontext sc;
879 if (upeek(tcp->pid, REG_SP, &sp) < 0)
881 if (umove(tcp, sp, &sc) < 0)
884 tcp->u_arg[1] = sc.sc_sigset;
886 tcp->u_rval = tcp->u_error = 0;
887 if(tcp->u_arg[0] == 0)
889 tcp->auxstr = sprintsigmask("mask now ", tcp->u_arg[1]);
890 return RVAL_NONE | RVAL_STR;
897 #endif /* !POWERPC */
909 long_to_sigset(tcp->u_rval, &sigm);
910 tcp->auxstr = sprintsigmask("mask ", &sigm, 0);
912 return RVAL_HEX | RVAL_STR;
921 long_to_sigset(tcp->u_arg[2], &sigm);
923 /* first two are not really arguments, but print them anyway */
924 /* nevermind, they are an anachronism now, too bad... */
925 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
927 printsigmask(&sigm, 0);
943 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
946 printsigmask(&sigset, 0);
950 static struct xlat ucontext_flags[] = {
951 { UC_SIGMASK, "UC_SIGMASK" },
952 { UC_STACK, "UC_STACK" },
953 { UC_CPU, "UC_CPU" },
955 { UC_FPU, "UC_FPU" },
958 { UC_INTR, "UC_INTR" },
965 #if defined SVR4 || defined LINUX
966 #if defined LINUX && !defined SS_ONSTACK
969 #if __GLIBC_MINOR__ == 0
979 static struct xlat sigaltstack_flags[] = {
980 { SS_ONSTACK, "SS_ONSTACK" },
981 { SS_DISABLE, "SS_DISABLE" },
988 printcontext(tcp, ucp)
994 tprintf("uc_flags=");
995 if (!printflags(ucontext_flags, ucp->uc_flags))
997 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
999 tprintf("uc_sigmask=");
1000 printsigmask(ucp->uc_sigmask, 0);
1002 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
1003 (unsigned long) ucp->uc_stack.ss_sp,
1004 ucp->uc_stack.ss_size);
1005 if (!printflags(sigaltstack_flags, ucp->uc_stack.ss_flags))
1018 if (entering(tcp)) {
1021 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1024 printcontext(tcp, &uc);
1035 if (entering(tcp)) {
1038 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1041 printcontext(tcp, &uc);
1044 tcp->u_rval = tcp->u_error = 0;
1045 if (tcp->u_arg[0] == 0)
1057 print_stack_t(tcp, addr)
1062 if (umove(tcp, addr, &ss) < 0)
1064 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
1065 if (!printflags(sigaltstack_flags, ss.ss_flags))
1067 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
1072 sys_sigaltstack(tcp)
1075 if (entering(tcp)) {
1076 if (tcp->u_arg[0] == 0)
1078 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
1083 if (tcp->u_arg[1] == 0)
1085 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
1092 #ifdef HAVE_SIGACTION
1095 sys_sigprocmask(tcp)
1099 if (entering(tcp)) {
1100 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1102 printsigmask(tcp->u_arg[1], 0);
1104 else if (!syserror(tcp)) {
1105 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0);
1106 return RVAL_HEX | RVAL_STR;
1111 if (entering(tcp)) {
1113 if (tcp->u_arg[0] == 0)
1117 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1121 else if (copy_sigset(tcp, tcp->u_arg[1], &sigset) < 0)
1122 tprintf("%#lx, ", tcp->u_arg[1]);
1124 printsigmask(&sigset, 0);
1131 else if (syserror(tcp))
1132 tprintf("%#lx", tcp->u_arg[2]);
1133 else if (copy_sigset(tcp, tcp->u_arg[2], &sigset) < 0)
1136 printsigmask(&sigset, 0);
1142 #endif /* HAVE_SIGACTION */
1148 if (entering(tcp)) {
1149 tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1]));
1158 return sys_kill(tcp);
1169 tprintf("%#lx", tcp->u_arg[0]);
1170 else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1173 printsigmask(&sigset, 0);
1181 sys_rt_sigprocmask(tcp)
1186 /* Note: arg[3] is the length of the sigset. */
1187 if (entering(tcp)) {
1188 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1192 else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0)
1193 tprintf("%#lx, ", tcp->u_arg[1]);
1195 printsigmask(&sigset, 1);
1203 else if (syserror(tcp))
1204 tprintf("%#lx", tcp->u_arg[2]);
1205 else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0)
1208 printsigmask(&sigset, 1);
1209 tprintf(", %lu", tcp->u_arg[3]);
1214 #if __GLIBC_MINOR__ < 1
1215 /* Type for data associated with a signal. */
1216 typedef union sigval
1222 # define __SI_MAX_SIZE 128
1223 # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
1225 typedef struct siginfo
1227 int si_signo; /* Signal number. */
1228 int si_errno; /* If non-zero, an errno value associated with
1229 this signal, as defined in <errno.h>. */
1230 int si_code; /* Signal code. */
1234 int _pad[__SI_PAD_SIZE];
1239 __pid_t si_pid; /* Sending process ID. */
1240 __uid_t si_uid; /* Real user ID of sending process. */
1243 /* POSIX.1b timers. */
1246 unsigned int _timer1;
1247 unsigned int _timer2;
1250 /* POSIX.1b signals. */
1253 __pid_t si_pid; /* Sending process ID. */
1254 __uid_t si_uid; /* Real user ID of sending process. */
1255 sigval_t si_sigval; /* Signal value. */
1261 __pid_t si_pid; /* Which child. */
1262 int si_status; /* Exit value or signal. */
1267 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
1270 void *si_addr; /* Faulting insn/memory ref. */
1276 int si_band; /* Band event for SIGPOLL. */
1283 /* Structure describing the action to be taken when a signal arrives. */
1284 struct new_sigaction
1288 __sighandler_t __sa_handler;
1289 void (*__sa_sigaction) (int, siginfo_t *, void *);
1291 __sigaction_handler;
1292 unsigned long sa_flags;
1293 void (*sa_restorer) (void);
1294 unsigned long int sa_mask[2];
1299 sys_rt_sigaction(tcp)
1302 struct new_sigaction sa;
1306 if (entering(tcp)) {
1307 printsignal(tcp->u_arg[0]);
1309 addr = tcp->u_arg[1];
1311 addr = tcp->u_arg[2];
1314 else if (!verbose(tcp))
1315 tprintf("%#lx", addr);
1316 else if (umove(tcp, addr, &sa) < 0)
1319 switch ((long) sa.__sigaction_handler.__sa_handler) {
1320 case (long) SIG_ERR:
1321 tprintf("{SIG_ERR}");
1323 case (long) SIG_DFL:
1324 tprintf("{SIG_DFL}");
1326 case (long) SIG_IGN:
1327 tprintf("{SIG_IGN}");
1331 (long) sa.__sigaction_handler.__sa_handler);
1332 sigemptyset(&sigset);
1334 if (tcp->u_arg[4] <= sizeof(sigset))
1335 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
1337 if (tcp->u_arg[3] <= sizeof(sigset))
1338 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
1341 memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
1342 printsigmask(&sigset, 1);
1344 if (!printflags(sigact_flags, sa.sa_flags))
1353 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
1354 #elif defined(ALPHA)
1355 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
1357 tprintf(", %lu", addr = tcp->u_arg[3]);
1363 sys_rt_sigpending(tcp)
1370 tprintf("%#lx", tcp->u_arg[0]);
1371 else if (copy_sigset_len(tcp, tcp->u_arg[0],
1372 &sigset, tcp->u_arg[1]) < 0)
1375 printsigmask(&sigset, 1);
1380 sys_rt_sigsuspend(tcp)
1383 if (entering(tcp)) {
1385 if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0)
1388 printsigmask(&sigm, 1);
1393 #define ILL_ILLOPC 1 /* illegal opcode */
1394 #define ILL_ILLOPN 2 /* illegal operand */
1395 #define ILL_ILLADR 3 /* illegal addressing mode */
1396 #define ILL_ILLTRP 4 /* illegal trap */
1397 #define ILL_PRVOPC 5 /* privileged opcode */
1398 #define ILL_PRVREG 6 /* privileged register */
1399 #define ILL_COPROC 7 /* coprocessor error */
1400 #define ILL_BADSTK 8 /* internal stack error */
1401 #define FPE_INTDIV 1 /* integer divide by zero */
1402 #define FPE_INTOVF 2 /* integer overflow */
1403 #define FPE_FLTDIV 3 /* floating point divide by zero */
1404 #define FPE_FLTOVF 4 /* floating point overflow */
1405 #define FPE_FLTUND 5 /* floating point underflow */
1406 #define FPE_FLTRES 6 /* floating point inexact result */
1407 #define FPE_FLTINV 7 /* floating point invalid operation */
1408 #define FPE_FLTSUB 8 /* subscript out of range */
1409 #define SEGV_MAPERR 1 /* address not mapped to object */
1410 #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
1411 #define BUS_ADRALN 1 /* invalid address alignment */
1412 #define BUS_ADRERR 2 /* non-existant physical address */
1413 #define BUS_OBJERR 3 /* object specific hardware error */
1414 #define TRAP_BRKPT 1 /* process breakpoint */
1415 #define TRAP_TRACE 2 /* process trace trap */
1416 #define CLD_EXITED 1 /* child has exited */
1417 #define CLD_KILLED 2 /* child was killed */
1418 #define CLD_DUMPED 3 /* child terminated abnormally */
1419 #define CLD_TRAPPED 4 /* traced child has trapped */
1420 #define CLD_STOPPED 5 /* child has stopped */
1421 #define CLD_CONTINUED 6 /* stopped child has continued */
1422 #define POLL_IN 1 /* data input available */
1423 #define POLL_OUT 2 /* output buffers available */
1424 #define POLL_MSG 3 /* input message available */
1425 #define POLL_ERR 4 /* i/o error */
1426 #define POLL_PRI 5 /* high priority input available */
1427 #define POLL_HUP 6 /* device disconnected */
1428 #define SI_USER 0 /* sent by kill, sigsend, raise */
1429 #define SI_QUEUE -1 /* sent by sigqueue */
1430 #define SI_TIMER -2 /* sent by timer expiration */
1431 #define SI_MESGQ -3 /* sent by real time mesq state change */
1432 #define SI_ASYNCIO -4 /* sent by AIO completion */
1447 static struct xlat sigill_flags[] = {
1448 {ILL_ILLOPC, "ILL_ILLOPC"},
1449 {ILL_ILLOPN, "ILL_ILLOPN"},
1450 {ILL_ILLADR, "ILL_ILLADR"},
1451 {ILL_ILLTRP, "ILL_ILLTRP"},
1452 {ILL_PRVOPC, "ILL_PRVOPC"},
1453 {ILL_PRVREG, "ILL_PRVREG"},
1454 {ILL_COPROC, "ILL_COPROC"},
1455 {ILL_BADSTK, "ILL_BADSTK"},
1459 static struct xlat sigfpe_flags[] = {
1460 {FPE_INTDIV, "FPE_INTDIV"},
1461 {FPE_INTOVF, "FPE_INTOVF"},
1462 {FPE_FLTDIV, "FPE_FLTDIV"},
1463 {FPE_FLTOVF, "FPE_FLTOVF"},
1464 {FPE_FLTUND, "FPE_FLTUND"},
1465 {FPE_FLTRES, "FPE_FLTRES"},
1466 {FPE_FLTINV, "FPE_FLTINV"},
1467 {FPE_FLTSUB, "FPE_FLTSUB"},
1471 static struct xlat sigsegv_flags[] = {
1472 {SEGV_MAPERR, "SEGV_MAPERR"},
1473 {SEGV_ACCERR, "SEGV_ACCERR"},
1477 static struct xlat sigbus_flags[] = {
1478 {BUS_ADRALN, "BUS_ADRALN"},
1479 {BUS_ADRERR, "BUS_ADRERR"},
1480 {BUS_OBJERR, "BUS_OBJERR"},
1484 static struct xlat sigtrap_flags[] = {
1485 {TRAP_BRKPT, "TRAP_BRKPT"},
1486 {TRAP_TRACE, "TRAP_TRACE"},
1490 static struct xlat sigchld_flags[] = {
1491 {CLD_EXITED, "CLD_EXITED"},
1492 {CLD_KILLED, "CLD_KILLED"},
1493 {CLD_DUMPED, "CLD_DUMPED"},
1494 {CLD_TRAPPED, "CLD_TRAPPED"},
1495 {CLD_STOPPED, "CLD_STOPPED"},
1496 {CLD_CONTINUED, "CLD_CONTINUED"},
1500 static struct xlat sigpoll_flags[] = {
1501 {POLL_IN, "POLL_IN"},
1502 {POLL_OUT, "POLL_OUT"},
1503 {POLL_MSG, "POLL_MSG"},
1504 {POLL_ERR, "POLL_ERR"},
1505 {POLL_PRI, "POLL_PRI"},
1506 {POLL_HUP, "POLL_HUP"},
1510 static struct xlat siginfo_flags[] = {
1511 {SI_USER, "SI_USER"},
1512 {SI_QUEUE, "SI_QUEUE"},
1513 {SI_TIMER, "SI_TIMER"},
1514 {SI_MESGQ, "SI_MESGQ"},
1515 {SI_ASYNCIO, "SI_ASYNCIO"},
1520 printsiginfo(tcp, si)
1524 tprintf("{si_signo=");
1525 printsignal(si->si_signo);
1526 tprintf(", si_errno=%d, si_code=", si->si_errno);
1527 switch(si->si_signo)
1530 if (!printflags(sigill_flags, si->si_code))
1531 tprintf("%d /* ILL_??? */", si->si_code);
1532 tprintf(", si_addr=%lx",
1533 (unsigned long) si->_sifields._sigfault.si_addr);
1536 if (!printflags(sigfpe_flags, si->si_code))
1537 tprintf("%d /* FPE_??? */", si->si_code);
1538 tprintf(", si_addr=%lx",
1539 (unsigned long) si->_sifields._sigfault.si_addr);
1542 if (!printflags(sigsegv_flags, si->si_code))
1543 tprintf("%d /* SEGV_??? */", si->si_code);
1544 tprintf(", si_addr=%lx",
1545 (unsigned long) si->_sifields._sigfault.si_addr);
1548 if (!printflags(sigbus_flags, si->si_code))
1549 tprintf("%d /* BUS_??? */", si->si_code);
1550 tprintf(", si_addr=%lx",
1551 (unsigned long) si->_sifields._sigfault.si_addr);
1554 if (!printflags(sigtrap_flags, si->si_code))
1555 tprintf("%d /* TRAP_??? */", si->si_code);
1558 if (!printflags(sigchld_flags, si->si_code))
1559 tprintf("%d /* CLD_??? */", si->si_code);
1563 tprintf(", si_pid=%d, si_uid=%d, si_status=%d, si_utime=%lu, si_stime=%lu",
1564 si->_sifields._kill.si_pid,
1565 si->_sifields._kill.si_uid,
1566 si->_sifields._sigchld.si_status,
1567 si->_sifields._sigchld.si_utime,
1568 si->_sifields._sigchld.si_stime);
1571 if (!printflags(sigpoll_flags, si->si_code))
1572 tprintf("%d /* POLL_??? */", si->si_code);
1573 if (si->si_code == POLL_IN
1574 || si->si_code == POLL_OUT
1575 || si->si_code == POLL_MSG)
1576 tprintf(", si_bind=%lu, si_fd=%d",
1577 (unsigned long) si->_sifields._sigpoll.si_band,
1578 si->_sifields._sigpoll.si_fd);
1581 if (!printflags(siginfo_flags, si->si_code))
1582 tprintf("%d /* SI_??? */", si->si_code);
1583 tprintf(", si_pid=%lu, si_uid=%lu, si_value={",
1584 (unsigned long) si->_sifields._rt.si_pid,
1585 (unsigned long) si->_sifields._rt.si_uid);
1589 tprintf("sival_int=%u, sival_ptr=%#lx",
1590 si->_sifields._rt.si_sigval.sival_int,
1591 (unsigned long) si->_sifields._rt.si_sigval.sival_ptr);
1600 sys_rt_sigqueueinfo(tcp)
1603 if (entering(tcp)) {
1605 tprintf("%lu, ", tcp->u_arg[0]);
1606 printsignal(tcp->u_arg[1]);
1608 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1609 tprintf("%#lx", tcp->u_arg[2]);
1616 int sys_rt_sigtimedwait(tcp)
1619 if (entering(tcp)) {
1622 if (copy_sigset_len(tcp, tcp->u_arg[0],
1623 &sigset, tcp->u_arg[3]) < 0)
1626 printsigmask(&sigset, 1);
1631 tprintf("%#lx", tcp->u_arg[0]);
1634 if (umove(tcp, tcp->u_arg[1], &si) < 0)
1635 tprintf("%#lx", tcp->u_arg[1]);
1639 tprintf(", %#lx", tcp->u_arg[2]);
1640 tprintf(", %d", (int) tcp->u_arg[3]);