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 /* real-time signals on solaris don't have
323 sprintf(s, format, signalent[i] + 3);
327 sprintf(tsig, "%u", i);
328 sprintf(s, format, tsig);
340 printsigmask(mask, rt)
344 tprintf("%s", sprintsigmask("", mask, rt));
351 tprintf(signame(nr));
355 * Check process TCP for the disposition of signal SIG.
356 * Return 1 if the process would somehow manage to survive signal SIG,
357 * else return 0. This routine will never be called with SIGKILL.
360 sigishandled(tcp, sig)
370 unsigned int signalled, blocked, ignored, caught;
372 /* This is incredibly costly but it's worth it. */
373 sprintf(sname, "/proc/%d/stat", tcp->pid);
374 if ((sfd = open(sname, O_RDONLY)) == -1) {
378 i = read(sfd, buf, 1024);
382 * Skip the extraneous fields. This loses if the
383 * command name has any spaces in it. So be it.
385 for (i = 0, s = buf; i < 30; i++) {
386 while (*++s != ' ') {
391 if (sscanf(s, "%u%u%u%u",
392 &signalled, &blocked, &ignored, &caught) != 4) {
393 fprintf(stderr, "/proc/pid/stat format error\n");
397 fprintf(stderr, "sigs: %08x %08x %08x %08x\n",
398 signalled, blocked, ignored, caught);
400 if ((ignored & sigmask(sig)) || (caught & sigmask(sig)))
407 if (upeek(tcp->pid, uoff(u_signal[0]) + sig*sizeof(u_signal),
408 (long *) &u_signal) < 0) {
411 if (u_signal != SIG_DFL)
417 * Since procfs doesn't interfere with wait I think it is safe
418 * to punt on this question. If not, the information is there.
430 #if defined(SIGURG) && SIGURG != SIGIO
434 /* Gloria Gaynor says ... */
443 #if defined(SUNOS4) || defined(FREEBSD)
453 printsignal(tcp->u_arg[0]);
455 addr = tcp->u_arg[1];
457 addr = tcp->u_arg[2];
461 else if (!verbose(tcp))
462 tprintf("%#lx", addr);
463 else if (umove(tcp, addr, &sv) < 0)
466 switch ((int) sv.sv_handler) {
468 tprintf("{SIG_ERR}");
471 tprintf("{SIG_DFL}");
474 if (tcp->u_arg[0] == SIGTRAP) {
475 tcp->flags |= TCB_SIGTRAPPED;
476 kill(tcp->pid, SIGSTOP);
478 tprintf("{SIG_IGN}");
481 if (tcp->u_arg[0] == SIGTRAP) {
482 tcp->flags |= TCB_SIGTRAPPED;
483 kill(tcp->pid, SIGSTOP);
488 if (tcp->u_arg[0] == SIGTRAP) {
489 tcp->flags |= TCB_SIGTRAPPED;
490 kill(tcp->pid, SIGSTOP);
492 tprintf("{%#lx, ", (unsigned long) sv.sv_handler);
493 printsigmask(&sv.sv_mask, 0);
495 if (!printflags(sigvec_flags, sv.sv_flags))
509 if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */
511 long_to_sigset(tcp->u_arg[0], &sigm);
512 printsigmask(&sigm, 0);
525 addr = tcp->u_arg[0];
527 addr = tcp->u_arg[1];
530 else if (umove(tcp, addr, &ss) < 0)
531 tprintf("%#lx", addr);
533 tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp);
534 tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO");
548 #endif /* SUNOS4 || FREEBSD */
558 long_to_sigset(tcp->u_arg[0], &sigm);
559 printsigmask(&sigm, 0);
561 if ((tcp->u_arg[0] & sigmask(SIGTRAP))) {
562 /* Mark attempt to block SIGTRAP */
563 tcp->flags |= TCB_SIGTRAPPED;
564 /* Send unblockable signal */
565 kill(tcp->pid, SIGSTOP);
567 #endif /* !USE_PROCFS */
569 else if (!syserror(tcp)) {
571 long_to_sigset(tcp->u_rval, &sigm);
572 tcp->auxstr = sprintsigmask("old mask ", &sigm, 0);
574 return RVAL_HEX | RVAL_STR;
583 return sys_sigsetmask(tcp);
588 #ifdef HAVE_SIGACTION
591 struct old_sigaction {
592 __sighandler_t __sa_handler;
593 unsigned long sa_mask;
594 unsigned long sa_flags;
595 void (*sa_restorer)(void);
597 #define SA_HANDLER __sa_handler
601 #define SA_HANDLER sa_handler
611 struct old_sigaction sa;
618 printsignal(tcp->u_arg[0]);
620 addr = tcp->u_arg[1];
622 addr = tcp->u_arg[2];
625 else if (!verbose(tcp))
626 tprintf("%#lx", addr);
627 else if (umove(tcp, addr, &sa) < 0)
630 switch ((long) sa.SA_HANDLER) {
632 tprintf("{SIG_ERR}");
635 tprintf("{SIG_DFL}");
639 if (tcp->u_arg[0] == SIGTRAP) {
640 tcp->flags |= TCB_SIGTRAPPED;
641 kill(tcp->pid, SIGSTOP);
643 #endif /* !USE_PROCFS */
644 tprintf("{SIG_IGN}");
648 if (tcp->u_arg[0] == SIGTRAP) {
649 tcp->flags |= TCB_SIGTRAPPED;
650 kill(tcp->pid, SIGSTOP);
652 #endif /* !USE_PROCFS */
653 tprintf("{%#lx, ", (long) sa.SA_HANDLER);
655 printsigmask (&sa.sa_mask, 0);
657 long_to_sigset(sa.sa_mask, &sigset);
658 printsigmask(&sigset, 0);
661 if (!printflags(sigact_flags, sa.sa_flags))
670 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
680 printsignal(tcp->u_arg[0]);
682 switch (tcp->u_arg[1]) {
691 if (tcp->u_arg[0] == SIGTRAP) {
692 tcp->flags |= TCB_SIGTRAPPED;
693 kill(tcp->pid, SIGSTOP);
695 #endif /* !USE_PROCFS */
700 if (tcp->u_arg[0] == SIGTRAP) {
701 tcp->flags |= TCB_SIGTRAPPED;
702 kill(tcp->pid, SIGSTOP);
704 #endif /* !USE_PROCFS */
705 tprintf("%#lx", tcp->u_arg[1]);
710 switch (tcp->u_rval) {
712 tcp->auxstr = "SIG_ERR"; break;
714 tcp->auxstr = "SIG_DFL"; break;
716 tcp->auxstr = "SIG_IGN"; break;
720 return RVAL_HEX | RVAL_STR;
729 printsignal(tcp->u_arg[0]);
734 #endif /* HAVE_SIGACTION */
744 struct sigcontext_struct sc;
748 if (upeek(tcp->pid,PT_GPR15,&usp)<0)
750 if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0)
753 memcpy(&tcp->u_arg[1],&sc.oldmask[0],sizeof(sigset_t));
755 tcp->u_rval = tcp->u_error = 0;
756 if (tcp->u_arg[0] == 0)
758 tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1]);
759 return RVAL_NONE | RVAL_STR;
765 struct sigcontext_struct sc;
769 if (upeek(tcp->pid, 4*UESP, &esp) < 0)
771 if (umove(tcp, esp, &sc) < 0)
774 tcp->u_arg[1] = sc.oldmask;
778 long_to_sigset(tcp->u_arg[1], &sigm);
779 tcp->u_rval = tcp->u_error = 0;
780 if (tcp->u_arg[0] == 0)
782 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
783 return RVAL_NONE | RVAL_STR;
788 struct sigcontext sc;
792 /* offset of sigcontext in the kernel's sigframe structure: */
793 # define SIGFRAME_SC_OFFSET 0x90
795 if (upeek(tcp->pid, PT_R12, &sp) < 0)
797 if (umove(tcp, sp + 16 + SIGFRAME_SC_OFFSET, &sc) < 0)
800 memcpy(tcp->u_arg + 1, &sc.sc_mask, sizeof(sc.sc_mask));
805 memcpy(&sigm, tcp->u_arg + 1, sizeof (sigm));
806 tcp->u_rval = tcp->u_error = 0;
807 if (tcp->u_arg[0] == 0)
809 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
810 return RVAL_NONE | RVAL_STR;
816 struct sigcontext_struct sc;
820 if (upeek(tcp->pid, 4*PT_R1, &esp) < 0)
822 if (umove(tcp, esp, &sc) < 0)
825 tcp->u_arg[1] = sc.oldmask;
829 long_to_sigset(tcp->u_arg[1], &sigm);
830 tcp->u_rval = tcp->u_error = 0;
831 if (tcp->u_arg[0] == 0)
833 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
834 return RVAL_NONE | RVAL_STR;
840 struct sigcontext sc;
844 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
846 if (umove(tcp, usp, &sc) < 0)
849 tcp->u_arg[1] = sc.sc_mask;
853 long_to_sigset(tcp->u_arg[1], &sigm);
854 tcp->u_rval = tcp->u_error = 0;
855 if (tcp->u_arg[0] == 0)
857 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
858 return RVAL_NONE | RVAL_STR;
864 struct sigcontext_struct sc;
868 if (upeek(tcp->pid, REG_FP, &fp) < 0)
870 if (umove(tcp, fp, &sc) < 0)
873 tcp->u_arg[1] = sc.sc_mask;
877 long_to_sigset(tcp->u_arg[1], &sigm);
878 tcp->u_rval = tcp->u_error = 0;
879 if (tcp->u_arg[0] == 0)
881 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
882 return RVAL_NONE | RVAL_STR;
891 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
892 perror("sigreturn: PTRACE_GETREGS ");
898 if(umove(tcp, i1, &si) < 0) {
899 perror("sigreturn: umove ");
903 tcp->u_arg[1] = si.si_mask;
906 long_to_sigset(tcp->u_arg[1], &sigm);
907 tcp->u_rval = tcp->u_error = 0;
908 if(tcp->u_arg[0] == 0)
910 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
911 return RVAL_NONE | RVAL_STR;
917 struct sigcontext sc;
921 if (upeek(tcp->pid, REG_SP, &sp) < 0)
923 if (umove(tcp, sp, &sc) < 0)
926 tcp->u_arg[1] = sc.sc_sigset;
928 tcp->u_rval = tcp->u_error = 0;
929 if(tcp->u_arg[0] == 0)
931 tcp->auxstr = sprintsigmask("mask now ", tcp->u_arg[1]);
932 return RVAL_NONE | RVAL_STR;
939 #endif /* !POWERPC */
951 long_to_sigset(tcp->u_rval, &sigm);
952 tcp->auxstr = sprintsigmask("mask ", &sigm, 0);
954 return RVAL_HEX | RVAL_STR;
963 long_to_sigset(tcp->u_arg[2], &sigm);
965 /* first two are not really arguments, but print them anyway */
966 /* nevermind, they are an anachronism now, too bad... */
967 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
969 printsigmask(&sigm, 0);
976 #if defined(SVR4) || defined(FREEBSD)
985 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
988 printsigmask(&sigset, 0);
993 static struct xlat ucontext_flags[] = {
994 { UC_SIGMASK, "UC_SIGMASK" },
995 { UC_STACK, "UC_STACK" },
996 { UC_CPU, "UC_CPU" },
998 { UC_FPU, "UC_FPU" },
1001 { UC_INTR, "UC_INTR" },
1005 #endif /* !FREEBSD */
1006 #endif /* SVR4 || FREEBSD */
1008 #if defined SVR4 || defined LINUX || defined FREEBSD
1009 #if defined LINUX && !defined SS_ONSTACK
1010 #define SS_ONSTACK 1
1011 #define SS_DISABLE 2
1012 #if __GLIBC_MINOR__ == 0
1022 #define stack_t struct sigaltstack
1025 static struct xlat sigaltstack_flags[] = {
1026 { SS_ONSTACK, "SS_ONSTACK" },
1027 { SS_DISABLE, "SS_DISABLE" },
1034 printcontext(tcp, ucp)
1040 tprintf("uc_flags=");
1041 if (!printflags(ucontext_flags, ucp->uc_flags))
1043 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
1045 tprintf("uc_sigmask=");
1046 printsigmask(ucp->uc_sigmask, 0);
1048 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
1049 (unsigned long) ucp->uc_stack.ss_sp,
1050 ucp->uc_stack.ss_size);
1051 if (!printflags(sigaltstack_flags, ucp->uc_stack.ss_flags))
1066 tprintf("%#lx", tcp->u_arg[0]);
1067 else if (!tcp->u_arg[0])
1069 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1072 printcontext(tcp, &uc);
1083 if (entering(tcp)) {
1086 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1089 printcontext(tcp, &uc);
1092 tcp->u_rval = tcp->u_error = 0;
1093 if (tcp->u_arg[0] == 0)
1102 #if defined(LINUX) || defined(FREEBSD)
1105 print_stack_t(tcp, addr)
1110 if (umove(tcp, addr, &ss) < 0)
1112 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
1113 if (!printflags(sigaltstack_flags, ss.ss_flags))
1115 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
1120 sys_sigaltstack(tcp)
1123 if (entering(tcp)) {
1124 if (tcp->u_arg[0] == 0)
1126 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
1131 if (tcp->u_arg[1] == 0)
1133 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
1140 #ifdef HAVE_SIGACTION
1143 sys_sigprocmask(tcp)
1147 if (entering(tcp)) {
1148 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1150 printsigmask(tcp->u_arg[1], 0);
1152 else if (!syserror(tcp)) {
1153 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0);
1154 return RVAL_HEX | RVAL_STR;
1159 if (entering(tcp)) {
1161 if (tcp->u_arg[0] == 0)
1165 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1169 else if (copy_sigset(tcp, tcp->u_arg[1], &sigset) < 0)
1170 tprintf("%#lx, ", tcp->u_arg[1]);
1172 printsigmask(&sigset, 0);
1179 else if (syserror(tcp))
1180 tprintf("%#lx", tcp->u_arg[2]);
1181 else if (copy_sigset(tcp, tcp->u_arg[2], &sigset) < 0)
1184 printsigmask(&sigset, 0);
1190 #endif /* HAVE_SIGACTION */
1196 if (entering(tcp)) {
1197 tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1]));
1206 return sys_kill(tcp);
1217 tprintf("%#lx", tcp->u_arg[0]);
1218 else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1221 printsigmask(&sigset, 0);
1229 sys_rt_sigprocmask(tcp)
1234 /* Note: arg[3] is the length of the sigset. */
1235 if (entering(tcp)) {
1236 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1240 else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0)
1241 tprintf("%#lx, ", tcp->u_arg[1]);
1243 printsigmask(&sigset, 1);
1251 else if (syserror(tcp))
1252 tprintf("%#lx", tcp->u_arg[2]);
1253 else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0)
1256 printsigmask(&sigset, 1);
1257 tprintf(", %lu", tcp->u_arg[3]);
1262 #if __GLIBC_MINOR__ < 1
1263 /* Type for data associated with a signal. */
1264 typedef union sigval
1270 # define __SI_MAX_SIZE 128
1271 # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
1273 typedef struct siginfo
1275 int si_signo; /* Signal number. */
1276 int si_errno; /* If non-zero, an errno value associated with
1277 this signal, as defined in <errno.h>. */
1278 int si_code; /* Signal code. */
1282 int _pad[__SI_PAD_SIZE];
1287 __pid_t si_pid; /* Sending process ID. */
1288 __uid_t si_uid; /* Real user ID of sending process. */
1291 /* POSIX.1b timers. */
1294 unsigned int _timer1;
1295 unsigned int _timer2;
1298 /* POSIX.1b signals. */
1301 __pid_t si_pid; /* Sending process ID. */
1302 __uid_t si_uid; /* Real user ID of sending process. */
1303 sigval_t si_sigval; /* Signal value. */
1309 __pid_t si_pid; /* Which child. */
1310 int si_status; /* Exit value or signal. */
1315 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
1318 void *si_addr; /* Faulting insn/memory ref. */
1324 int si_band; /* Band event for SIGPOLL. */
1331 /* Structure describing the action to be taken when a signal arrives. */
1332 struct new_sigaction
1336 __sighandler_t __sa_handler;
1337 void (*__sa_sigaction) (int, siginfo_t *, void *);
1339 __sigaction_handler;
1340 unsigned long sa_flags;
1341 void (*sa_restorer) (void);
1342 unsigned long int sa_mask[2];
1347 sys_rt_sigaction(tcp)
1350 struct new_sigaction sa;
1354 if (entering(tcp)) {
1355 printsignal(tcp->u_arg[0]);
1357 addr = tcp->u_arg[1];
1359 addr = tcp->u_arg[2];
1362 else if (!verbose(tcp))
1363 tprintf("%#lx", addr);
1364 else if (umove(tcp, addr, &sa) < 0)
1367 switch ((long) sa.__sigaction_handler.__sa_handler) {
1368 case (long) SIG_ERR:
1369 tprintf("{SIG_ERR}");
1371 case (long) SIG_DFL:
1372 tprintf("{SIG_DFL}");
1374 case (long) SIG_IGN:
1375 tprintf("{SIG_IGN}");
1379 (long) sa.__sigaction_handler.__sa_handler);
1380 sigemptyset(&sigset);
1382 if (tcp->u_arg[4] <= sizeof(sigset))
1383 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
1385 if (tcp->u_arg[3] <= sizeof(sigset))
1386 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
1389 memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
1390 printsigmask(&sigset, 1);
1392 if (!printflags(sigact_flags, sa.sa_flags))
1401 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
1402 #elif defined(ALPHA)
1403 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
1405 tprintf(", %lu", addr = tcp->u_arg[3]);
1411 sys_rt_sigpending(tcp)
1418 tprintf("%#lx", tcp->u_arg[0]);
1419 else if (copy_sigset_len(tcp, tcp->u_arg[0],
1420 &sigset, tcp->u_arg[1]) < 0)
1423 printsigmask(&sigset, 1);
1428 sys_rt_sigsuspend(tcp)
1431 if (entering(tcp)) {
1433 if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0)
1436 printsigmask(&sigm, 1);
1441 #define ILL_ILLOPC 1 /* illegal opcode */
1442 #define ILL_ILLOPN 2 /* illegal operand */
1443 #define ILL_ILLADR 3 /* illegal addressing mode */
1444 #define ILL_ILLTRP 4 /* illegal trap */
1445 #define ILL_PRVOPC 5 /* privileged opcode */
1446 #define ILL_PRVREG 6 /* privileged register */
1447 #define ILL_COPROC 7 /* coprocessor error */
1448 #define ILL_BADSTK 8 /* internal stack error */
1449 #define FPE_INTDIV 1 /* integer divide by zero */
1450 #define FPE_INTOVF 2 /* integer overflow */
1451 #define FPE_FLTDIV 3 /* floating point divide by zero */
1452 #define FPE_FLTOVF 4 /* floating point overflow */
1453 #define FPE_FLTUND 5 /* floating point underflow */
1454 #define FPE_FLTRES 6 /* floating point inexact result */
1455 #define FPE_FLTINV 7 /* floating point invalid operation */
1456 #define FPE_FLTSUB 8 /* subscript out of range */
1457 #define SEGV_MAPERR 1 /* address not mapped to object */
1458 #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
1459 #define BUS_ADRALN 1 /* invalid address alignment */
1460 #define BUS_ADRERR 2 /* non-existant physical address */
1461 #define BUS_OBJERR 3 /* object specific hardware error */
1462 #define TRAP_BRKPT 1 /* process breakpoint */
1463 #define TRAP_TRACE 2 /* process trace trap */
1464 #define CLD_EXITED 1 /* child has exited */
1465 #define CLD_KILLED 2 /* child was killed */
1466 #define CLD_DUMPED 3 /* child terminated abnormally */
1467 #define CLD_TRAPPED 4 /* traced child has trapped */
1468 #define CLD_STOPPED 5 /* child has stopped */
1469 #define CLD_CONTINUED 6 /* stopped child has continued */
1470 #define POLL_IN 1 /* data input available */
1471 #define POLL_OUT 2 /* output buffers available */
1472 #define POLL_MSG 3 /* input message available */
1473 #define POLL_ERR 4 /* i/o error */
1474 #define POLL_PRI 5 /* high priority input available */
1475 #define POLL_HUP 6 /* device disconnected */
1476 #define SI_USER 0 /* sent by kill, sigsend, raise */
1477 #define SI_QUEUE -1 /* sent by sigqueue */
1478 #define SI_TIMER -2 /* sent by timer expiration */
1479 #define SI_MESGQ -3 /* sent by real time mesq state change */
1480 #define SI_ASYNCIO -4 /* sent by AIO completion */
1495 static struct xlat sigill_flags[] = {
1496 {ILL_ILLOPC, "ILL_ILLOPC"},
1497 {ILL_ILLOPN, "ILL_ILLOPN"},
1498 {ILL_ILLADR, "ILL_ILLADR"},
1499 {ILL_ILLTRP, "ILL_ILLTRP"},
1500 {ILL_PRVOPC, "ILL_PRVOPC"},
1501 {ILL_PRVREG, "ILL_PRVREG"},
1502 {ILL_COPROC, "ILL_COPROC"},
1503 {ILL_BADSTK, "ILL_BADSTK"},
1507 static struct xlat sigfpe_flags[] = {
1508 {FPE_INTDIV, "FPE_INTDIV"},
1509 {FPE_INTOVF, "FPE_INTOVF"},
1510 {FPE_FLTDIV, "FPE_FLTDIV"},
1511 {FPE_FLTOVF, "FPE_FLTOVF"},
1512 {FPE_FLTUND, "FPE_FLTUND"},
1513 {FPE_FLTRES, "FPE_FLTRES"},
1514 {FPE_FLTINV, "FPE_FLTINV"},
1515 {FPE_FLTSUB, "FPE_FLTSUB"},
1519 static struct xlat sigsegv_flags[] = {
1520 {SEGV_MAPERR, "SEGV_MAPERR"},
1521 {SEGV_ACCERR, "SEGV_ACCERR"},
1525 static struct xlat sigbus_flags[] = {
1526 {BUS_ADRALN, "BUS_ADRALN"},
1527 {BUS_ADRERR, "BUS_ADRERR"},
1528 {BUS_OBJERR, "BUS_OBJERR"},
1532 static struct xlat sigtrap_flags[] = {
1533 {TRAP_BRKPT, "TRAP_BRKPT"},
1534 {TRAP_TRACE, "TRAP_TRACE"},
1538 static struct xlat sigchld_flags[] = {
1539 {CLD_EXITED, "CLD_EXITED"},
1540 {CLD_KILLED, "CLD_KILLED"},
1541 {CLD_DUMPED, "CLD_DUMPED"},
1542 {CLD_TRAPPED, "CLD_TRAPPED"},
1543 {CLD_STOPPED, "CLD_STOPPED"},
1544 {CLD_CONTINUED, "CLD_CONTINUED"},
1548 static struct xlat sigpoll_flags[] = {
1549 {POLL_IN, "POLL_IN"},
1550 {POLL_OUT, "POLL_OUT"},
1551 {POLL_MSG, "POLL_MSG"},
1552 {POLL_ERR, "POLL_ERR"},
1553 {POLL_PRI, "POLL_PRI"},
1554 {POLL_HUP, "POLL_HUP"},
1558 static struct xlat siginfo_flags[] = {
1559 {SI_USER, "SI_USER"},
1560 {SI_QUEUE, "SI_QUEUE"},
1561 {SI_TIMER, "SI_TIMER"},
1562 {SI_MESGQ, "SI_MESGQ"},
1563 {SI_ASYNCIO, "SI_ASYNCIO"},
1568 printsiginfo(tcp, si)
1572 tprintf("{si_signo=");
1573 printsignal(si->si_signo);
1574 tprintf(", si_errno=%d, si_code=", si->si_errno);
1575 switch(si->si_signo)
1578 if (!printflags(sigill_flags, si->si_code))
1579 tprintf("%d /* ILL_??? */", si->si_code);
1580 tprintf(", si_addr=%lx",
1581 (unsigned long) si->_sifields._sigfault.si_addr);
1584 if (!printflags(sigfpe_flags, si->si_code))
1585 tprintf("%d /* FPE_??? */", si->si_code);
1586 tprintf(", si_addr=%lx",
1587 (unsigned long) si->_sifields._sigfault.si_addr);
1590 if (!printflags(sigsegv_flags, si->si_code))
1591 tprintf("%d /* SEGV_??? */", si->si_code);
1592 tprintf(", si_addr=%lx",
1593 (unsigned long) si->_sifields._sigfault.si_addr);
1596 if (!printflags(sigbus_flags, si->si_code))
1597 tprintf("%d /* BUS_??? */", si->si_code);
1598 tprintf(", si_addr=%lx",
1599 (unsigned long) si->_sifields._sigfault.si_addr);
1602 if (!printflags(sigtrap_flags, si->si_code))
1603 tprintf("%d /* TRAP_??? */", si->si_code);
1606 if (!printflags(sigchld_flags, si->si_code))
1607 tprintf("%d /* CLD_??? */", si->si_code);
1611 tprintf(", si_pid=%d, si_uid=%d, si_status=%d, si_utime=%lu, si_stime=%lu",
1612 si->_sifields._kill.si_pid,
1613 si->_sifields._kill.si_uid,
1614 si->_sifields._sigchld.si_status,
1615 si->_sifields._sigchld.si_utime,
1616 si->_sifields._sigchld.si_stime);
1619 if (!printflags(sigpoll_flags, si->si_code))
1620 tprintf("%d /* POLL_??? */", si->si_code);
1621 if (si->si_code == POLL_IN
1622 || si->si_code == POLL_OUT
1623 || si->si_code == POLL_MSG)
1624 tprintf(", si_bind=%lu, si_fd=%d",
1625 (unsigned long) si->_sifields._sigpoll.si_band,
1626 si->_sifields._sigpoll.si_fd);
1629 if (!printflags(siginfo_flags, si->si_code))
1630 tprintf("%d /* SI_??? */", si->si_code);
1631 tprintf(", si_pid=%lu, si_uid=%lu, si_value={",
1632 (unsigned long) si->_sifields._rt.si_pid,
1633 (unsigned long) si->_sifields._rt.si_uid);
1637 tprintf("sival_int=%u, sival_ptr=%#lx",
1638 si->_sifields._rt.si_sigval.sival_int,
1639 (unsigned long) si->_sifields._rt.si_sigval.sival_ptr);
1648 sys_rt_sigqueueinfo(tcp)
1651 if (entering(tcp)) {
1653 tprintf("%lu, ", tcp->u_arg[0]);
1654 printsignal(tcp->u_arg[1]);
1656 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1657 tprintf("%#lx", tcp->u_arg[2]);
1664 int sys_rt_sigtimedwait(tcp)
1667 if (entering(tcp)) {
1670 if (copy_sigset_len(tcp, tcp->u_arg[0],
1671 &sigset, tcp->u_arg[3]) < 0)
1674 printsigmask(&sigset, 1);
1679 tprintf("%#lx", tcp->u_arg[0]);
1682 if (umove(tcp, tcp->u_arg[1], &si) < 0)
1683 tprintf("%#lx", tcp->u_arg[1]);
1687 tprintf(", %#lx", tcp->u_arg[2]);
1688 tprintf(", %d", (int) tcp->u_arg[3]);