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 */
149 #if defined(SUNOS4) || defined(FREEBSD)
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" },
159 #endif /* SUNOS4 || FREEBSD */
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 ... */
432 #if defined(SUNOS4) || defined(FREEBSD)
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");
537 #endif /* SUNOS4 || FREEBSD */
547 long_to_sigset(tcp->u_arg[0], &sigm);
548 printsigmask(&sigm, 0);
550 if ((tcp->u_arg[0] & sigmask(SIGTRAP))) {
551 /* Mark attempt to block SIGTRAP */
552 tcp->flags |= TCB_SIGTRAPPED;
553 /* Send unblockable signal */
554 kill(tcp->pid, SIGSTOP);
556 #endif /* !USE_PROCFS */
558 else if (!syserror(tcp)) {
560 long_to_sigset(tcp->u_rval, &sigm);
561 tcp->auxstr = sprintsigmask("old mask ", &sigm, 0);
563 return RVAL_HEX | RVAL_STR;
572 return sys_sigsetmask(tcp);
577 #ifdef HAVE_SIGACTION
580 struct old_sigaction {
581 __sighandler_t __sa_handler;
582 unsigned long sa_mask;
583 unsigned long sa_flags;
584 void (*sa_restorer)(void);
586 #define SA_HANDLER __sa_handler
590 #define SA_HANDLER sa_handler
600 struct old_sigaction sa;
607 printsignal(tcp->u_arg[0]);
609 addr = tcp->u_arg[1];
611 addr = tcp->u_arg[2];
614 else if (!verbose(tcp))
615 tprintf("%#lx", addr);
616 else if (umove(tcp, addr, &sa) < 0)
619 switch ((long) sa.SA_HANDLER) {
621 tprintf("{SIG_ERR}");
624 tprintf("{SIG_DFL}");
628 if (tcp->u_arg[0] == SIGTRAP) {
629 tcp->flags |= TCB_SIGTRAPPED;
630 kill(tcp->pid, SIGSTOP);
632 #endif /* !USE_PROCFS */
633 tprintf("{SIG_IGN}");
637 if (tcp->u_arg[0] == SIGTRAP) {
638 tcp->flags |= TCB_SIGTRAPPED;
639 kill(tcp->pid, SIGSTOP);
641 #endif /* !USE_PROCFS */
642 tprintf("{%#lx, ", (long) sa.SA_HANDLER);
644 printsigmask (&sa.sa_mask, 0);
646 long_to_sigset(sa.sa_mask, &sigset);
647 printsigmask(&sigset, 0);
650 if (!printflags(sigact_flags, sa.sa_flags))
659 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
669 printsignal(tcp->u_arg[0]);
671 switch (tcp->u_arg[1]) {
680 if (tcp->u_arg[0] == SIGTRAP) {
681 tcp->flags |= TCB_SIGTRAPPED;
682 kill(tcp->pid, SIGSTOP);
684 #endif /* !USE_PROCFS */
689 if (tcp->u_arg[0] == SIGTRAP) {
690 tcp->flags |= TCB_SIGTRAPPED;
691 kill(tcp->pid, SIGSTOP);
693 #endif /* !USE_PROCFS */
694 tprintf("%#lx", tcp->u_arg[1]);
699 switch (tcp->u_rval) {
701 tcp->auxstr = "SIG_ERR"; break;
703 tcp->auxstr = "SIG_DFL"; break;
705 tcp->auxstr = "SIG_IGN"; break;
709 return RVAL_HEX | RVAL_STR;
718 printsignal(tcp->u_arg[0]);
723 #endif /* HAVE_SIGACTION */
733 struct sigcontext_struct sc;
737 if (upeek(tcp->pid,PT_GPR15,&usp)<0)
739 if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0)
742 memcpy(&tcp->u_arg[1],&sc.oldmask[0],sizeof(sigset_t));
744 tcp->u_rval = tcp->u_error = 0;
745 if (tcp->u_arg[0] == 0)
747 tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1]);
748 return RVAL_NONE | RVAL_STR;
754 struct sigcontext_struct sc;
758 if (upeek(tcp->pid, 4*UESP, &esp) < 0)
760 if (umove(tcp, esp, &sc) < 0)
763 tcp->u_arg[1] = sc.oldmask;
767 long_to_sigset(tcp->u_arg[1], &sigm);
768 tcp->u_rval = tcp->u_error = 0;
769 if (tcp->u_arg[0] == 0)
771 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
772 return RVAL_NONE | RVAL_STR;
777 struct sigcontext sc;
781 /* offset of sigcontext in the kernel's sigframe structure: */
782 # define SIGFRAME_SC_OFFSET 0x90
784 if (upeek(tcp->pid, PT_R12, &sp) < 0)
786 if (umove(tcp, sp + 16 + SIGFRAME_SC_OFFSET, &sc) < 0)
789 memcpy(tcp->u_arg + 1, &sc.sc_mask, sizeof(sc.sc_mask));
794 memcpy(&sigm, tcp->u_arg + 1, sizeof (sigm));
795 tcp->u_rval = tcp->u_error = 0;
796 if (tcp->u_arg[0] == 0)
798 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
799 return RVAL_NONE | RVAL_STR;
805 struct sigcontext_struct sc;
809 if (upeek(tcp->pid, 4*PT_R1, &esp) < 0)
811 if (umove(tcp, esp, &sc) < 0)
814 tcp->u_arg[1] = sc.oldmask;
818 long_to_sigset(tcp->u_arg[1], &sigm);
819 tcp->u_rval = tcp->u_error = 0;
820 if (tcp->u_arg[0] == 0)
822 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
823 return RVAL_NONE | RVAL_STR;
829 struct sigcontext sc;
833 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
835 if (umove(tcp, usp, &sc) < 0)
838 tcp->u_arg[1] = sc.sc_mask;
842 long_to_sigset(tcp->u_arg[1], &sigm);
843 tcp->u_rval = tcp->u_error = 0;
844 if (tcp->u_arg[0] == 0)
846 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
847 return RVAL_NONE | RVAL_STR;
853 struct sigcontext_struct sc;
857 if (upeek(tcp->pid, REG_FP, &fp) < 0)
859 if (umove(tcp, fp, &sc) < 0)
862 tcp->u_arg[1] = sc.sc_mask;
866 long_to_sigset(tcp->u_arg[1], &sigm);
867 tcp->u_rval = tcp->u_error = 0;
868 if (tcp->u_arg[0] == 0)
870 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
871 return RVAL_NONE | RVAL_STR;
880 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
881 perror("sigreturn: PTRACE_GETREGS ");
887 if(umove(tcp, i1, &si) < 0) {
888 perror("sigreturn: umove ");
892 tcp->u_arg[1] = si.si_mask;
895 long_to_sigset(tcp->u_arg[1], &sigm);
896 tcp->u_rval = tcp->u_error = 0;
897 if(tcp->u_arg[0] == 0)
899 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
900 return RVAL_NONE | RVAL_STR;
906 struct sigcontext sc;
910 if (upeek(tcp->pid, REG_SP, &sp) < 0)
912 if (umove(tcp, sp, &sc) < 0)
915 tcp->u_arg[1] = sc.sc_sigset;
917 tcp->u_rval = tcp->u_error = 0;
918 if(tcp->u_arg[0] == 0)
920 tcp->auxstr = sprintsigmask("mask now ", tcp->u_arg[1]);
921 return RVAL_NONE | RVAL_STR;
928 #endif /* !POWERPC */
940 long_to_sigset(tcp->u_rval, &sigm);
941 tcp->auxstr = sprintsigmask("mask ", &sigm, 0);
943 return RVAL_HEX | RVAL_STR;
952 long_to_sigset(tcp->u_arg[2], &sigm);
954 /* first two are not really arguments, but print them anyway */
955 /* nevermind, they are an anachronism now, too bad... */
956 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
958 printsigmask(&sigm, 0);
965 #if defined(SVR4) || defined(FREEBSD)
974 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
977 printsigmask(&sigset, 0);
982 static struct xlat ucontext_flags[] = {
983 { UC_SIGMASK, "UC_SIGMASK" },
984 { UC_STACK, "UC_STACK" },
985 { UC_CPU, "UC_CPU" },
987 { UC_FPU, "UC_FPU" },
990 { UC_INTR, "UC_INTR" },
994 #endif /* !FREEBSD */
995 #endif /* SVR4 || FREEBSD */
997 #if defined SVR4 || defined LINUX || defined FREEBSD
998 #if defined LINUX && !defined SS_ONSTACK
1000 #define SS_DISABLE 2
1001 #if __GLIBC_MINOR__ == 0
1011 #define stack_t struct sigaltstack
1014 static struct xlat sigaltstack_flags[] = {
1015 { SS_ONSTACK, "SS_ONSTACK" },
1016 { SS_DISABLE, "SS_DISABLE" },
1023 printcontext(tcp, ucp)
1029 tprintf("uc_flags=");
1030 if (!printflags(ucontext_flags, ucp->uc_flags))
1032 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
1034 tprintf("uc_sigmask=");
1035 printsigmask(ucp->uc_sigmask, 0);
1037 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
1038 (unsigned long) ucp->uc_stack.ss_sp,
1039 ucp->uc_stack.ss_size);
1040 if (!printflags(sigaltstack_flags, ucp->uc_stack.ss_flags))
1055 tprintf("%#lx", tcp->u_arg[0]);
1056 else if (!tcp->u_arg[0])
1058 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1061 printcontext(tcp, &uc);
1072 if (entering(tcp)) {
1075 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1078 printcontext(tcp, &uc);
1081 tcp->u_rval = tcp->u_error = 0;
1082 if (tcp->u_arg[0] == 0)
1091 #if defined(LINUX) || defined(FREEBSD)
1094 print_stack_t(tcp, addr)
1099 if (umove(tcp, addr, &ss) < 0)
1101 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
1102 if (!printflags(sigaltstack_flags, ss.ss_flags))
1104 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
1109 sys_sigaltstack(tcp)
1112 if (entering(tcp)) {
1113 if (tcp->u_arg[0] == 0)
1115 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
1120 if (tcp->u_arg[1] == 0)
1122 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
1129 #ifdef HAVE_SIGACTION
1132 sys_sigprocmask(tcp)
1136 if (entering(tcp)) {
1137 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1139 printsigmask(tcp->u_arg[1], 0);
1141 else if (!syserror(tcp)) {
1142 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0);
1143 return RVAL_HEX | RVAL_STR;
1148 if (entering(tcp)) {
1150 if (tcp->u_arg[0] == 0)
1154 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1158 else if (copy_sigset(tcp, tcp->u_arg[1], &sigset) < 0)
1159 tprintf("%#lx, ", tcp->u_arg[1]);
1161 printsigmask(&sigset, 0);
1168 else if (syserror(tcp))
1169 tprintf("%#lx", tcp->u_arg[2]);
1170 else if (copy_sigset(tcp, tcp->u_arg[2], &sigset) < 0)
1173 printsigmask(&sigset, 0);
1179 #endif /* HAVE_SIGACTION */
1185 if (entering(tcp)) {
1186 tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1]));
1195 return sys_kill(tcp);
1206 tprintf("%#lx", tcp->u_arg[0]);
1207 else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1210 printsigmask(&sigset, 0);
1218 sys_rt_sigprocmask(tcp)
1223 /* Note: arg[3] is the length of the sigset. */
1224 if (entering(tcp)) {
1225 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1229 else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0)
1230 tprintf("%#lx, ", tcp->u_arg[1]);
1232 printsigmask(&sigset, 1);
1240 else if (syserror(tcp))
1241 tprintf("%#lx", tcp->u_arg[2]);
1242 else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0)
1245 printsigmask(&sigset, 1);
1246 tprintf(", %lu", tcp->u_arg[3]);
1251 #if __GLIBC_MINOR__ < 1
1252 /* Type for data associated with a signal. */
1253 typedef union sigval
1259 # define __SI_MAX_SIZE 128
1260 # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
1262 typedef struct siginfo
1264 int si_signo; /* Signal number. */
1265 int si_errno; /* If non-zero, an errno value associated with
1266 this signal, as defined in <errno.h>. */
1267 int si_code; /* Signal code. */
1271 int _pad[__SI_PAD_SIZE];
1276 __pid_t si_pid; /* Sending process ID. */
1277 __uid_t si_uid; /* Real user ID of sending process. */
1280 /* POSIX.1b timers. */
1283 unsigned int _timer1;
1284 unsigned int _timer2;
1287 /* POSIX.1b signals. */
1290 __pid_t si_pid; /* Sending process ID. */
1291 __uid_t si_uid; /* Real user ID of sending process. */
1292 sigval_t si_sigval; /* Signal value. */
1298 __pid_t si_pid; /* Which child. */
1299 int si_status; /* Exit value or signal. */
1304 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
1307 void *si_addr; /* Faulting insn/memory ref. */
1313 int si_band; /* Band event for SIGPOLL. */
1320 /* Structure describing the action to be taken when a signal arrives. */
1321 struct new_sigaction
1325 __sighandler_t __sa_handler;
1326 void (*__sa_sigaction) (int, siginfo_t *, void *);
1328 __sigaction_handler;
1329 unsigned long sa_flags;
1330 void (*sa_restorer) (void);
1331 unsigned long int sa_mask[2];
1336 sys_rt_sigaction(tcp)
1339 struct new_sigaction sa;
1343 if (entering(tcp)) {
1344 printsignal(tcp->u_arg[0]);
1346 addr = tcp->u_arg[1];
1348 addr = tcp->u_arg[2];
1351 else if (!verbose(tcp))
1352 tprintf("%#lx", addr);
1353 else if (umove(tcp, addr, &sa) < 0)
1356 switch ((long) sa.__sigaction_handler.__sa_handler) {
1357 case (long) SIG_ERR:
1358 tprintf("{SIG_ERR}");
1360 case (long) SIG_DFL:
1361 tprintf("{SIG_DFL}");
1363 case (long) SIG_IGN:
1364 tprintf("{SIG_IGN}");
1368 (long) sa.__sigaction_handler.__sa_handler);
1369 sigemptyset(&sigset);
1371 if (tcp->u_arg[4] <= sizeof(sigset))
1372 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
1374 if (tcp->u_arg[3] <= sizeof(sigset))
1375 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
1378 memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
1379 printsigmask(&sigset, 1);
1381 if (!printflags(sigact_flags, sa.sa_flags))
1390 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
1391 #elif defined(ALPHA)
1392 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
1394 tprintf(", %lu", addr = tcp->u_arg[3]);
1400 sys_rt_sigpending(tcp)
1407 tprintf("%#lx", tcp->u_arg[0]);
1408 else if (copy_sigset_len(tcp, tcp->u_arg[0],
1409 &sigset, tcp->u_arg[1]) < 0)
1412 printsigmask(&sigset, 1);
1417 sys_rt_sigsuspend(tcp)
1420 if (entering(tcp)) {
1422 if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0)
1425 printsigmask(&sigm, 1);
1430 #define ILL_ILLOPC 1 /* illegal opcode */
1431 #define ILL_ILLOPN 2 /* illegal operand */
1432 #define ILL_ILLADR 3 /* illegal addressing mode */
1433 #define ILL_ILLTRP 4 /* illegal trap */
1434 #define ILL_PRVOPC 5 /* privileged opcode */
1435 #define ILL_PRVREG 6 /* privileged register */
1436 #define ILL_COPROC 7 /* coprocessor error */
1437 #define ILL_BADSTK 8 /* internal stack error */
1438 #define FPE_INTDIV 1 /* integer divide by zero */
1439 #define FPE_INTOVF 2 /* integer overflow */
1440 #define FPE_FLTDIV 3 /* floating point divide by zero */
1441 #define FPE_FLTOVF 4 /* floating point overflow */
1442 #define FPE_FLTUND 5 /* floating point underflow */
1443 #define FPE_FLTRES 6 /* floating point inexact result */
1444 #define FPE_FLTINV 7 /* floating point invalid operation */
1445 #define FPE_FLTSUB 8 /* subscript out of range */
1446 #define SEGV_MAPERR 1 /* address not mapped to object */
1447 #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
1448 #define BUS_ADRALN 1 /* invalid address alignment */
1449 #define BUS_ADRERR 2 /* non-existant physical address */
1450 #define BUS_OBJERR 3 /* object specific hardware error */
1451 #define TRAP_BRKPT 1 /* process breakpoint */
1452 #define TRAP_TRACE 2 /* process trace trap */
1453 #define CLD_EXITED 1 /* child has exited */
1454 #define CLD_KILLED 2 /* child was killed */
1455 #define CLD_DUMPED 3 /* child terminated abnormally */
1456 #define CLD_TRAPPED 4 /* traced child has trapped */
1457 #define CLD_STOPPED 5 /* child has stopped */
1458 #define CLD_CONTINUED 6 /* stopped child has continued */
1459 #define POLL_IN 1 /* data input available */
1460 #define POLL_OUT 2 /* output buffers available */
1461 #define POLL_MSG 3 /* input message available */
1462 #define POLL_ERR 4 /* i/o error */
1463 #define POLL_PRI 5 /* high priority input available */
1464 #define POLL_HUP 6 /* device disconnected */
1465 #define SI_USER 0 /* sent by kill, sigsend, raise */
1466 #define SI_QUEUE -1 /* sent by sigqueue */
1467 #define SI_TIMER -2 /* sent by timer expiration */
1468 #define SI_MESGQ -3 /* sent by real time mesq state change */
1469 #define SI_ASYNCIO -4 /* sent by AIO completion */
1484 static struct xlat sigill_flags[] = {
1485 {ILL_ILLOPC, "ILL_ILLOPC"},
1486 {ILL_ILLOPN, "ILL_ILLOPN"},
1487 {ILL_ILLADR, "ILL_ILLADR"},
1488 {ILL_ILLTRP, "ILL_ILLTRP"},
1489 {ILL_PRVOPC, "ILL_PRVOPC"},
1490 {ILL_PRVREG, "ILL_PRVREG"},
1491 {ILL_COPROC, "ILL_COPROC"},
1492 {ILL_BADSTK, "ILL_BADSTK"},
1496 static struct xlat sigfpe_flags[] = {
1497 {FPE_INTDIV, "FPE_INTDIV"},
1498 {FPE_INTOVF, "FPE_INTOVF"},
1499 {FPE_FLTDIV, "FPE_FLTDIV"},
1500 {FPE_FLTOVF, "FPE_FLTOVF"},
1501 {FPE_FLTUND, "FPE_FLTUND"},
1502 {FPE_FLTRES, "FPE_FLTRES"},
1503 {FPE_FLTINV, "FPE_FLTINV"},
1504 {FPE_FLTSUB, "FPE_FLTSUB"},
1508 static struct xlat sigsegv_flags[] = {
1509 {SEGV_MAPERR, "SEGV_MAPERR"},
1510 {SEGV_ACCERR, "SEGV_ACCERR"},
1514 static struct xlat sigbus_flags[] = {
1515 {BUS_ADRALN, "BUS_ADRALN"},
1516 {BUS_ADRERR, "BUS_ADRERR"},
1517 {BUS_OBJERR, "BUS_OBJERR"},
1521 static struct xlat sigtrap_flags[] = {
1522 {TRAP_BRKPT, "TRAP_BRKPT"},
1523 {TRAP_TRACE, "TRAP_TRACE"},
1527 static struct xlat sigchld_flags[] = {
1528 {CLD_EXITED, "CLD_EXITED"},
1529 {CLD_KILLED, "CLD_KILLED"},
1530 {CLD_DUMPED, "CLD_DUMPED"},
1531 {CLD_TRAPPED, "CLD_TRAPPED"},
1532 {CLD_STOPPED, "CLD_STOPPED"},
1533 {CLD_CONTINUED, "CLD_CONTINUED"},
1537 static struct xlat sigpoll_flags[] = {
1538 {POLL_IN, "POLL_IN"},
1539 {POLL_OUT, "POLL_OUT"},
1540 {POLL_MSG, "POLL_MSG"},
1541 {POLL_ERR, "POLL_ERR"},
1542 {POLL_PRI, "POLL_PRI"},
1543 {POLL_HUP, "POLL_HUP"},
1547 static struct xlat siginfo_flags[] = {
1548 {SI_USER, "SI_USER"},
1549 {SI_QUEUE, "SI_QUEUE"},
1550 {SI_TIMER, "SI_TIMER"},
1551 {SI_MESGQ, "SI_MESGQ"},
1552 {SI_ASYNCIO, "SI_ASYNCIO"},
1557 printsiginfo(tcp, si)
1561 tprintf("{si_signo=");
1562 printsignal(si->si_signo);
1563 tprintf(", si_errno=%d, si_code=", si->si_errno);
1564 switch(si->si_signo)
1567 if (!printflags(sigill_flags, si->si_code))
1568 tprintf("%d /* ILL_??? */", si->si_code);
1569 tprintf(", si_addr=%lx",
1570 (unsigned long) si->_sifields._sigfault.si_addr);
1573 if (!printflags(sigfpe_flags, si->si_code))
1574 tprintf("%d /* FPE_??? */", si->si_code);
1575 tprintf(", si_addr=%lx",
1576 (unsigned long) si->_sifields._sigfault.si_addr);
1579 if (!printflags(sigsegv_flags, si->si_code))
1580 tprintf("%d /* SEGV_??? */", si->si_code);
1581 tprintf(", si_addr=%lx",
1582 (unsigned long) si->_sifields._sigfault.si_addr);
1585 if (!printflags(sigbus_flags, si->si_code))
1586 tprintf("%d /* BUS_??? */", si->si_code);
1587 tprintf(", si_addr=%lx",
1588 (unsigned long) si->_sifields._sigfault.si_addr);
1591 if (!printflags(sigtrap_flags, si->si_code))
1592 tprintf("%d /* TRAP_??? */", si->si_code);
1595 if (!printflags(sigchld_flags, si->si_code))
1596 tprintf("%d /* CLD_??? */", si->si_code);
1600 tprintf(", si_pid=%d, si_uid=%d, si_status=%d, si_utime=%lu, si_stime=%lu",
1601 si->_sifields._kill.si_pid,
1602 si->_sifields._kill.si_uid,
1603 si->_sifields._sigchld.si_status,
1604 si->_sifields._sigchld.si_utime,
1605 si->_sifields._sigchld.si_stime);
1608 if (!printflags(sigpoll_flags, si->si_code))
1609 tprintf("%d /* POLL_??? */", si->si_code);
1610 if (si->si_code == POLL_IN
1611 || si->si_code == POLL_OUT
1612 || si->si_code == POLL_MSG)
1613 tprintf(", si_bind=%lu, si_fd=%d",
1614 (unsigned long) si->_sifields._sigpoll.si_band,
1615 si->_sifields._sigpoll.si_fd);
1618 if (!printflags(siginfo_flags, si->si_code))
1619 tprintf("%d /* SI_??? */", si->si_code);
1620 tprintf(", si_pid=%lu, si_uid=%lu, si_value={",
1621 (unsigned long) si->_sifields._rt.si_pid,
1622 (unsigned long) si->_sifields._rt.si_uid);
1626 tprintf("sival_int=%u, sival_ptr=%#lx",
1627 si->_sifields._rt.si_sigval.sival_int,
1628 (unsigned long) si->_sifields._rt.si_sigval.sival_ptr);
1637 sys_rt_sigqueueinfo(tcp)
1640 if (entering(tcp)) {
1642 tprintf("%lu, ", tcp->u_arg[0]);
1643 printsignal(tcp->u_arg[1]);
1645 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1646 tprintf("%#lx", tcp->u_arg[2]);
1653 int sys_rt_sigtimedwait(tcp)
1656 if (entering(tcp)) {
1659 if (copy_sigset_len(tcp, tcp->u_arg[0],
1660 &sigset, tcp->u_arg[3]) < 0)
1663 printsigmask(&sigset, 1);
1668 tprintf("%#lx", tcp->u_arg[0]);
1671 if (umove(tcp, tcp->u_arg[1], &si) < 0)
1672 tprintf("%#lx", tcp->u_arg[1]);
1676 tprintf(", %#lx", tcp->u_arg[2]);
1677 tprintf(", %d", (int) tcp->u_arg[3]);