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]);
669 switch (tcp->u_arg[1]) {
678 if (tcp->u_arg[0] == SIGTRAP) {
679 tcp->flags |= TCB_SIGTRAPPED;
680 kill(tcp->pid, SIGSTOP);
687 if (tcp->u_arg[0] == SIGTRAP) {
688 tcp->flags |= TCB_SIGTRAPPED;
689 kill(tcp->pid, SIGSTOP);
692 tprintf("%#lx", tcp->u_arg[1]);
697 switch (tcp->u_rval) {
699 tcp->auxstr = "SIG_ERR"; break;
701 tcp->auxstr = "SIG_DFL"; break;
703 tcp->auxstr = "SIG_IGN"; break;
707 return RVAL_HEX | RVAL_STR;
716 printsignal(tcp->u_arg[0]);
721 #endif /* HAVE_SIGACTION */
731 struct sigcontext_struct sc;
735 if (upeek(tcp->pid,PT_GPR15,&usp)<0)
737 if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0)
740 memcpy(&tcp->u_arg[1],&sc.oldmask[0],sizeof(sigset_t));
742 tcp->u_rval = tcp->u_error = 0;
743 if (tcp->u_arg[0] == 0)
745 tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1]);
746 return RVAL_NONE | RVAL_STR;
752 struct sigcontext_struct sc;
756 if (upeek(tcp->pid, 4*UESP, &esp) < 0)
758 if (umove(tcp, esp, &sc) < 0)
761 tcp->u_arg[1] = sc.oldmask;
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;
775 struct sigcontext sc;
779 /* offset of sigcontext in the kernel's sigframe structure: */
780 # define SIGFRAME_SC_OFFSET 0x90
782 if (upeek(tcp->pid, PT_R12, &sp) < 0)
784 if (umove(tcp, sp + 16 + SIGFRAME_SC_OFFSET, &sc) < 0)
787 memcpy(tcp->u_arg + 1, &sc.sc_mask, sizeof(sc.sc_mask));
792 memcpy(&sigm, tcp->u_arg + 1, sizeof (sigm));
793 tcp->u_rval = tcp->u_error = 0;
794 if (tcp->u_arg[0] == 0)
796 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
797 return RVAL_NONE | RVAL_STR;
803 struct sigcontext_struct sc;
807 if (upeek(tcp->pid, 4*PT_R1, &esp) < 0)
809 if (umove(tcp, esp, &sc) < 0)
812 tcp->u_arg[1] = sc.oldmask;
816 long_to_sigset(tcp->u_arg[1], &sigm);
817 tcp->u_rval = tcp->u_error = 0;
818 if (tcp->u_arg[0] == 0)
820 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
821 return RVAL_NONE | RVAL_STR;
827 struct sigcontext sc;
831 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
833 if (umove(tcp, usp, &sc) < 0)
836 tcp->u_arg[1] = sc.sc_mask;
840 long_to_sigset(tcp->u_arg[1], &sigm);
841 tcp->u_rval = tcp->u_error = 0;
842 if (tcp->u_arg[0] == 0)
844 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
845 return RVAL_NONE | RVAL_STR;
851 struct sigcontext_struct sc;
855 if (upeek(tcp->pid, REG_FP, &fp) < 0)
857 if (umove(tcp, fp, &sc) < 0)
860 tcp->u_arg[1] = sc.sc_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;
878 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
879 perror("sigreturn: PTRACE_GETREGS ");
885 if(umove(tcp, i1, &si) < 0) {
886 perror("sigreturn: umove ");
890 tcp->u_arg[1] = si.si_mask;
893 long_to_sigset(tcp->u_arg[1], &sigm);
894 tcp->u_rval = tcp->u_error = 0;
895 if(tcp->u_arg[0] == 0)
897 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
898 return RVAL_NONE | RVAL_STR;
904 struct sigcontext sc;
908 if (upeek(tcp->pid, REG_SP, &sp) < 0)
910 if (umove(tcp, sp, &sc) < 0)
913 tcp->u_arg[1] = sc.sc_sigset;
915 tcp->u_rval = tcp->u_error = 0;
916 if(tcp->u_arg[0] == 0)
918 tcp->auxstr = sprintsigmask("mask now ", tcp->u_arg[1]);
919 return RVAL_NONE | RVAL_STR;
926 #endif /* !POWERPC */
938 long_to_sigset(tcp->u_rval, &sigm);
939 tcp->auxstr = sprintsigmask("mask ", &sigm, 0);
941 return RVAL_HEX | RVAL_STR;
950 long_to_sigset(tcp->u_arg[2], &sigm);
952 /* first two are not really arguments, but print them anyway */
953 /* nevermind, they are an anachronism now, too bad... */
954 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
956 printsigmask(&sigm, 0);
972 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
975 printsigmask(&sigset, 0);
979 static struct xlat ucontext_flags[] = {
980 { UC_SIGMASK, "UC_SIGMASK" },
981 { UC_STACK, "UC_STACK" },
982 { UC_CPU, "UC_CPU" },
984 { UC_FPU, "UC_FPU" },
987 { UC_INTR, "UC_INTR" },
994 #if defined SVR4 || defined LINUX
995 #if defined LINUX && !defined SS_ONSTACK
998 #if __GLIBC_MINOR__ == 0
1008 static struct xlat sigaltstack_flags[] = {
1009 { SS_ONSTACK, "SS_ONSTACK" },
1010 { SS_DISABLE, "SS_DISABLE" },
1017 printcontext(tcp, ucp)
1023 tprintf("uc_flags=");
1024 if (!printflags(ucontext_flags, ucp->uc_flags))
1026 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
1028 tprintf("uc_sigmask=");
1029 printsigmask(ucp->uc_sigmask, 0);
1031 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
1032 (unsigned long) ucp->uc_stack.ss_sp,
1033 ucp->uc_stack.ss_size);
1034 if (!printflags(sigaltstack_flags, ucp->uc_stack.ss_flags))
1049 tprintf("%#lx", tcp->u_arg[0]);
1050 else if (!tcp->u_arg[0])
1052 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1055 printcontext(tcp, &uc);
1066 if (entering(tcp)) {
1069 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1072 printcontext(tcp, &uc);
1075 tcp->u_rval = tcp->u_error = 0;
1076 if (tcp->u_arg[0] == 0)
1088 print_stack_t(tcp, addr)
1093 if (umove(tcp, addr, &ss) < 0)
1095 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
1096 if (!printflags(sigaltstack_flags, ss.ss_flags))
1098 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
1103 sys_sigaltstack(tcp)
1106 if (entering(tcp)) {
1107 if (tcp->u_arg[0] == 0)
1109 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
1114 if (tcp->u_arg[1] == 0)
1116 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
1123 #ifdef HAVE_SIGACTION
1126 sys_sigprocmask(tcp)
1130 if (entering(tcp)) {
1131 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1133 printsigmask(tcp->u_arg[1], 0);
1135 else if (!syserror(tcp)) {
1136 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0);
1137 return RVAL_HEX | RVAL_STR;
1142 if (entering(tcp)) {
1144 if (tcp->u_arg[0] == 0)
1148 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1152 else if (copy_sigset(tcp, tcp->u_arg[1], &sigset) < 0)
1153 tprintf("%#lx, ", tcp->u_arg[1]);
1155 printsigmask(&sigset, 0);
1162 else if (syserror(tcp))
1163 tprintf("%#lx", tcp->u_arg[2]);
1164 else if (copy_sigset(tcp, tcp->u_arg[2], &sigset) < 0)
1167 printsigmask(&sigset, 0);
1173 #endif /* HAVE_SIGACTION */
1179 if (entering(tcp)) {
1180 tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1]));
1189 return sys_kill(tcp);
1200 tprintf("%#lx", tcp->u_arg[0]);
1201 else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1204 printsigmask(&sigset, 0);
1212 sys_rt_sigprocmask(tcp)
1217 /* Note: arg[3] is the length of the sigset. */
1218 if (entering(tcp)) {
1219 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1223 else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0)
1224 tprintf("%#lx, ", tcp->u_arg[1]);
1226 printsigmask(&sigset, 1);
1234 else if (syserror(tcp))
1235 tprintf("%#lx", tcp->u_arg[2]);
1236 else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0)
1239 printsigmask(&sigset, 1);
1240 tprintf(", %lu", tcp->u_arg[3]);
1245 #if __GLIBC_MINOR__ < 1
1246 /* Type for data associated with a signal. */
1247 typedef union sigval
1253 # define __SI_MAX_SIZE 128
1254 # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
1256 typedef struct siginfo
1258 int si_signo; /* Signal number. */
1259 int si_errno; /* If non-zero, an errno value associated with
1260 this signal, as defined in <errno.h>. */
1261 int si_code; /* Signal code. */
1265 int _pad[__SI_PAD_SIZE];
1270 __pid_t si_pid; /* Sending process ID. */
1271 __uid_t si_uid; /* Real user ID of sending process. */
1274 /* POSIX.1b timers. */
1277 unsigned int _timer1;
1278 unsigned int _timer2;
1281 /* POSIX.1b signals. */
1284 __pid_t si_pid; /* Sending process ID. */
1285 __uid_t si_uid; /* Real user ID of sending process. */
1286 sigval_t si_sigval; /* Signal value. */
1292 __pid_t si_pid; /* Which child. */
1293 int si_status; /* Exit value or signal. */
1298 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
1301 void *si_addr; /* Faulting insn/memory ref. */
1307 int si_band; /* Band event for SIGPOLL. */
1314 /* Structure describing the action to be taken when a signal arrives. */
1315 struct new_sigaction
1319 __sighandler_t __sa_handler;
1320 void (*__sa_sigaction) (int, siginfo_t *, void *);
1322 __sigaction_handler;
1323 unsigned long sa_flags;
1324 void (*sa_restorer) (void);
1325 unsigned long int sa_mask[2];
1330 sys_rt_sigaction(tcp)
1333 struct new_sigaction sa;
1337 if (entering(tcp)) {
1338 printsignal(tcp->u_arg[0]);
1340 addr = tcp->u_arg[1];
1342 addr = tcp->u_arg[2];
1345 else if (!verbose(tcp))
1346 tprintf("%#lx", addr);
1347 else if (umove(tcp, addr, &sa) < 0)
1350 switch ((long) sa.__sigaction_handler.__sa_handler) {
1351 case (long) SIG_ERR:
1352 tprintf("{SIG_ERR}");
1354 case (long) SIG_DFL:
1355 tprintf("{SIG_DFL}");
1357 case (long) SIG_IGN:
1358 tprintf("{SIG_IGN}");
1362 (long) sa.__sigaction_handler.__sa_handler);
1363 sigemptyset(&sigset);
1365 if (tcp->u_arg[4] <= sizeof(sigset))
1366 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
1368 if (tcp->u_arg[3] <= sizeof(sigset))
1369 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
1372 memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
1373 printsigmask(&sigset, 1);
1375 if (!printflags(sigact_flags, sa.sa_flags))
1384 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
1385 #elif defined(ALPHA)
1386 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
1388 tprintf(", %lu", addr = tcp->u_arg[3]);
1394 sys_rt_sigpending(tcp)
1401 tprintf("%#lx", tcp->u_arg[0]);
1402 else if (copy_sigset_len(tcp, tcp->u_arg[0],
1403 &sigset, tcp->u_arg[1]) < 0)
1406 printsigmask(&sigset, 1);
1411 sys_rt_sigsuspend(tcp)
1414 if (entering(tcp)) {
1416 if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0)
1419 printsigmask(&sigm, 1);
1424 #define ILL_ILLOPC 1 /* illegal opcode */
1425 #define ILL_ILLOPN 2 /* illegal operand */
1426 #define ILL_ILLADR 3 /* illegal addressing mode */
1427 #define ILL_ILLTRP 4 /* illegal trap */
1428 #define ILL_PRVOPC 5 /* privileged opcode */
1429 #define ILL_PRVREG 6 /* privileged register */
1430 #define ILL_COPROC 7 /* coprocessor error */
1431 #define ILL_BADSTK 8 /* internal stack error */
1432 #define FPE_INTDIV 1 /* integer divide by zero */
1433 #define FPE_INTOVF 2 /* integer overflow */
1434 #define FPE_FLTDIV 3 /* floating point divide by zero */
1435 #define FPE_FLTOVF 4 /* floating point overflow */
1436 #define FPE_FLTUND 5 /* floating point underflow */
1437 #define FPE_FLTRES 6 /* floating point inexact result */
1438 #define FPE_FLTINV 7 /* floating point invalid operation */
1439 #define FPE_FLTSUB 8 /* subscript out of range */
1440 #define SEGV_MAPERR 1 /* address not mapped to object */
1441 #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
1442 #define BUS_ADRALN 1 /* invalid address alignment */
1443 #define BUS_ADRERR 2 /* non-existant physical address */
1444 #define BUS_OBJERR 3 /* object specific hardware error */
1445 #define TRAP_BRKPT 1 /* process breakpoint */
1446 #define TRAP_TRACE 2 /* process trace trap */
1447 #define CLD_EXITED 1 /* child has exited */
1448 #define CLD_KILLED 2 /* child was killed */
1449 #define CLD_DUMPED 3 /* child terminated abnormally */
1450 #define CLD_TRAPPED 4 /* traced child has trapped */
1451 #define CLD_STOPPED 5 /* child has stopped */
1452 #define CLD_CONTINUED 6 /* stopped child has continued */
1453 #define POLL_IN 1 /* data input available */
1454 #define POLL_OUT 2 /* output buffers available */
1455 #define POLL_MSG 3 /* input message available */
1456 #define POLL_ERR 4 /* i/o error */
1457 #define POLL_PRI 5 /* high priority input available */
1458 #define POLL_HUP 6 /* device disconnected */
1459 #define SI_USER 0 /* sent by kill, sigsend, raise */
1460 #define SI_QUEUE -1 /* sent by sigqueue */
1461 #define SI_TIMER -2 /* sent by timer expiration */
1462 #define SI_MESGQ -3 /* sent by real time mesq state change */
1463 #define SI_ASYNCIO -4 /* sent by AIO completion */
1478 static struct xlat sigill_flags[] = {
1479 {ILL_ILLOPC, "ILL_ILLOPC"},
1480 {ILL_ILLOPN, "ILL_ILLOPN"},
1481 {ILL_ILLADR, "ILL_ILLADR"},
1482 {ILL_ILLTRP, "ILL_ILLTRP"},
1483 {ILL_PRVOPC, "ILL_PRVOPC"},
1484 {ILL_PRVREG, "ILL_PRVREG"},
1485 {ILL_COPROC, "ILL_COPROC"},
1486 {ILL_BADSTK, "ILL_BADSTK"},
1490 static struct xlat sigfpe_flags[] = {
1491 {FPE_INTDIV, "FPE_INTDIV"},
1492 {FPE_INTOVF, "FPE_INTOVF"},
1493 {FPE_FLTDIV, "FPE_FLTDIV"},
1494 {FPE_FLTOVF, "FPE_FLTOVF"},
1495 {FPE_FLTUND, "FPE_FLTUND"},
1496 {FPE_FLTRES, "FPE_FLTRES"},
1497 {FPE_FLTINV, "FPE_FLTINV"},
1498 {FPE_FLTSUB, "FPE_FLTSUB"},
1502 static struct xlat sigsegv_flags[] = {
1503 {SEGV_MAPERR, "SEGV_MAPERR"},
1504 {SEGV_ACCERR, "SEGV_ACCERR"},
1508 static struct xlat sigbus_flags[] = {
1509 {BUS_ADRALN, "BUS_ADRALN"},
1510 {BUS_ADRERR, "BUS_ADRERR"},
1511 {BUS_OBJERR, "BUS_OBJERR"},
1515 static struct xlat sigtrap_flags[] = {
1516 {TRAP_BRKPT, "TRAP_BRKPT"},
1517 {TRAP_TRACE, "TRAP_TRACE"},
1521 static struct xlat sigchld_flags[] = {
1522 {CLD_EXITED, "CLD_EXITED"},
1523 {CLD_KILLED, "CLD_KILLED"},
1524 {CLD_DUMPED, "CLD_DUMPED"},
1525 {CLD_TRAPPED, "CLD_TRAPPED"},
1526 {CLD_STOPPED, "CLD_STOPPED"},
1527 {CLD_CONTINUED, "CLD_CONTINUED"},
1531 static struct xlat sigpoll_flags[] = {
1532 {POLL_IN, "POLL_IN"},
1533 {POLL_OUT, "POLL_OUT"},
1534 {POLL_MSG, "POLL_MSG"},
1535 {POLL_ERR, "POLL_ERR"},
1536 {POLL_PRI, "POLL_PRI"},
1537 {POLL_HUP, "POLL_HUP"},
1541 static struct xlat siginfo_flags[] = {
1542 {SI_USER, "SI_USER"},
1543 {SI_QUEUE, "SI_QUEUE"},
1544 {SI_TIMER, "SI_TIMER"},
1545 {SI_MESGQ, "SI_MESGQ"},
1546 {SI_ASYNCIO, "SI_ASYNCIO"},
1551 printsiginfo(tcp, si)
1555 tprintf("{si_signo=");
1556 printsignal(si->si_signo);
1557 tprintf(", si_errno=%d, si_code=", si->si_errno);
1558 switch(si->si_signo)
1561 if (!printflags(sigill_flags, si->si_code))
1562 tprintf("%d /* ILL_??? */", si->si_code);
1563 tprintf(", si_addr=%lx",
1564 (unsigned long) si->_sifields._sigfault.si_addr);
1567 if (!printflags(sigfpe_flags, si->si_code))
1568 tprintf("%d /* FPE_??? */", si->si_code);
1569 tprintf(", si_addr=%lx",
1570 (unsigned long) si->_sifields._sigfault.si_addr);
1573 if (!printflags(sigsegv_flags, si->si_code))
1574 tprintf("%d /* SEGV_??? */", si->si_code);
1575 tprintf(", si_addr=%lx",
1576 (unsigned long) si->_sifields._sigfault.si_addr);
1579 if (!printflags(sigbus_flags, si->si_code))
1580 tprintf("%d /* BUS_??? */", si->si_code);
1581 tprintf(", si_addr=%lx",
1582 (unsigned long) si->_sifields._sigfault.si_addr);
1585 if (!printflags(sigtrap_flags, si->si_code))
1586 tprintf("%d /* TRAP_??? */", si->si_code);
1589 if (!printflags(sigchld_flags, si->si_code))
1590 tprintf("%d /* CLD_??? */", si->si_code);
1594 tprintf(", si_pid=%d, si_uid=%d, si_status=%d, si_utime=%lu, si_stime=%lu",
1595 si->_sifields._kill.si_pid,
1596 si->_sifields._kill.si_uid,
1597 si->_sifields._sigchld.si_status,
1598 si->_sifields._sigchld.si_utime,
1599 si->_sifields._sigchld.si_stime);
1602 if (!printflags(sigpoll_flags, si->si_code))
1603 tprintf("%d /* POLL_??? */", si->si_code);
1604 if (si->si_code == POLL_IN
1605 || si->si_code == POLL_OUT
1606 || si->si_code == POLL_MSG)
1607 tprintf(", si_bind=%lu, si_fd=%d",
1608 (unsigned long) si->_sifields._sigpoll.si_band,
1609 si->_sifields._sigpoll.si_fd);
1612 if (!printflags(siginfo_flags, si->si_code))
1613 tprintf("%d /* SI_??? */", si->si_code);
1614 tprintf(", si_pid=%lu, si_uid=%lu, si_value={",
1615 (unsigned long) si->_sifields._rt.si_pid,
1616 (unsigned long) si->_sifields._rt.si_uid);
1620 tprintf("sival_int=%u, sival_ptr=%#lx",
1621 si->_sifields._rt.si_sigval.sival_int,
1622 (unsigned long) si->_sifields._rt.si_sigval.sival_ptr);
1631 sys_rt_sigqueueinfo(tcp)
1634 if (entering(tcp)) {
1636 tprintf("%lu, ", tcp->u_arg[0]);
1637 printsignal(tcp->u_arg[1]);
1639 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1640 tprintf("%#lx", tcp->u_arg[2]);
1647 int sys_rt_sigtimedwait(tcp)
1650 if (entering(tcp)) {
1653 if (copy_sigset_len(tcp, tcp->u_arg[0],
1654 &sigset, tcp->u_arg[3]) < 0)
1657 printsigmask(&sigset, 1);
1662 tprintf("%#lx", tcp->u_arg[0]);
1665 if (umove(tcp, tcp->u_arg[1], &si) < 0)
1666 tprintf("%#lx", tcp->u_arg[1]);
1670 tprintf(", %#lx", tcp->u_arg[2]);
1671 tprintf(", %d", (int) tcp->u_arg[3]);