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>
68 # define fpq kernel_fpq
70 # define fpu kernel_fpu
79 #endif /* HAVE_ASM_REG_H */
80 #ifdef HAVE_ASM_SIGCONTEXT_H
87 #include <asm/sigcontext.h>
89 #else /* !HAVE_ASM_SIGCONTEXT_H */
91 struct sigcontext_struct {
92 unsigned short gs, __gsh;
93 unsigned short fs, __fsh;
94 unsigned short es, __esh;
95 unsigned short ds, __dsh;
104 unsigned long trapno;
107 unsigned short cs, __csh;
108 unsigned long eflags;
109 unsigned long esp_at_signal;
110 unsigned short ss, __ssh;
112 unsigned long oldmask;
119 unsigned long sc_mask;
120 unsigned long sc_usp;
125 unsigned short sc_sr;
127 unsigned short sc_formatvec;
131 #endif /* !HAVE_ASM_SIGCONTEXT_H */
141 char *signalent0[] = {
142 #include "signalent.h"
144 int nsignals0 = sizeof signalent0 / sizeof signalent0[0];
146 #if SUPPORTED_PERSONALITIES >= 2
147 char *signalent1[] = {
148 #include "signalent1.h"
150 int nsignals1 = sizeof signalent1 / sizeof signalent1[0];
151 #endif /* SUPPORTED_PERSONALITIES >= 2 */
153 #if SUPPORTED_PERSONALITIES >= 3
154 char *signalent2[] = {
155 #include "signalent2.h"
157 int nsignals2 = sizeof signalent2 / sizeof signalent2[0];
158 #endif /* SUPPORTED_PERSONALITIES >= 3 */
163 #if defined(SUNOS4) || defined(FREEBSD)
165 static struct xlat sigvec_flags[] = {
166 { SV_ONSTACK, "SV_ONSTACK" },
167 { SV_INTERRUPT, "SV_INTERRUPT" },
168 { SV_RESETHAND, "SV_RESETHAND" },
169 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
173 #endif /* SUNOS4 || FREEBSD */
175 #ifdef HAVE_SIGACTION
177 static struct xlat sigact_flags[] = {
179 { SA_RESTORER, "SA_RESTORER" },
182 { SA_STACK, "SA_STACK" },
185 { SA_RESTART, "SA_RESTART" },
188 { SA_INTERRUPT, "SA_INTERRUPT" },
191 { SA_NOMASK, "SA_NOMASK" },
194 { SA_ONESHOT, "SA_ONESHOT" },
197 { SA_SIGINFO, "SA_SIGINFO" },
200 { SA_RESETHAND, "SA_RESETHAND" },
203 { SA_ONSTACK, "SA_ONSTACK" },
206 { SA_NODEFER, "SA_NODEFER" },
209 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
212 { SA_NOCLDWAIT, "SA_NOCLDWAIT" },
215 { _SA_BSDCALL, "_SA_BSDCALL" },
220 static struct xlat sigprocmaskcmds[] = {
221 { SIG_BLOCK, "SIG_BLOCK" },
222 { SIG_UNBLOCK, "SIG_UNBLOCK" },
223 { SIG_SETMASK, "SIG_SETMASK" },
225 { SIG_SETMASK32,"SIG_SETMASK32" },
230 #endif /* HAVE_SIGACTION */
232 /* Anonymous realtime signals. */
233 /* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
234 constant. This is what we want. Otherwise, just use SIGRTMIN. */
237 #define __SIGRTMIN SIGRTMIN
238 #define __SIGRTMAX SIGRTMAX /* likewise */
247 if (sig < nsignals) {
248 return signalent[sig];
250 } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) {
251 sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN));
253 #endif /* SIGRTMIN */
255 sprintf(buf, "%d", sig);
272 copy_sigset_len(tcp, addr, s, len)
278 if (len > sizeof(*s))
281 if (umoven(tcp, addr, len, (char *)s) < 0)
287 /* Original sigset is unsigned long */
288 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long))
290 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t))
294 sprintsigmask(s, mask, rt)
297 int rt; /* set might include realtime sigs */
302 static char outstr[256];
305 s = outstr + strlen(outstr);
310 maxsigs = __SIGRTMAX; /* instead */
312 for (i = 1; i < maxsigs; i++) {
313 if (sigismember(mask, i) == 1)
316 if (nsigs >= nsignals * 2 / 3) {
318 for (i = 1; i < maxsigs; i++) {
319 switch (sigismember(mask, i)) {
331 for (i = 1; i < maxsigs; i++) {
332 if (sigismember(mask, i) == 1) {
333 /* real-time signals on solaris don't have
337 sprintf(s, format, signalent[i] + 3);
341 sprintf(tsig, "%u", i);
342 sprintf(s, format, tsig);
354 printsigmask(mask, rt)
358 tprintf("%s", sprintsigmask("", mask, rt));
365 tprintf(signame(nr));
371 parse_sigset_t (const char *str, sigset_t *set)
378 for (i = _NSIG - 4; i >= 0; i -= 4, ++str) {
380 digit = (*str - 'a') + 10;
384 sigaddset(set, i + 1);
386 sigaddset(set, i + 2);
388 sigaddset(set, i + 3);
390 sigaddset(set, i + 4);
397 * Check process TCP for the disposition of signal SIG.
398 * Return 1 if the process would somehow manage to survive signal SIG,
399 * else return 0. This routine will never be called with SIGKILL.
402 sigishandled(tcp, sig)
412 sigset_t ignored, caught;
416 * Since procfs doesn't interfere with wait I think it is safe
417 * to punt on this question. If not, the information is there.
429 #if defined(SIGURG) && SIGURG != SIGIO
433 /* Gloria Gaynor says ... */
441 /* This is incredibly costly but it's worth it. */
442 /* NOTE: LinuxThreads internally uses SIGRTMIN, SIGRTMIN + 1 and
443 SIGRTMIN + 2, so we can't use the obsolete /proc/%d/stat which
444 doesn't handle real-time signals). */
445 sprintf(sname, "/proc/%d/status", tcp->pid);
446 if ((sfd = open(sname, O_RDONLY)) == -1) {
450 i = read(sfd, buf, sizeof(buf));
454 * Skip the extraneous fields. We need to skip
455 * command name has any spaces in it. So be it.
457 s = strstr(buf, "SigIgn:\t");
460 fprintf(stderr, "/proc/pid/status format error\n");
463 parse_sigset_t(s + 8, &ignored);
465 s = strstr(buf, "SigCgt:\t");
468 fprintf(stderr, "/proc/pid/status format error\n");
471 parse_sigset_t(s + 8, &caught);
474 fprintf(stderr, "sigs: %016qx %016qx (sig=%d)\n",
475 *(long long *) &ignored, *(long long *) &caught, sig);
477 if (sigismember(&ignored, sig) || sigismember(&caught, sig))
484 if (upeek(tcp->pid, uoff(u_signal[0]) + sig*sizeof(u_signal),
485 (long *) &u_signal) < 0) {
488 if (u_signal != SIG_DFL)
495 #if defined(SUNOS4) || defined(FREEBSD)
505 printsignal(tcp->u_arg[0]);
507 addr = tcp->u_arg[1];
509 addr = tcp->u_arg[2];
513 else if (!verbose(tcp))
514 tprintf("%#lx", addr);
515 else if (umove(tcp, addr, &sv) < 0)
518 switch ((int) sv.sv_handler) {
520 tprintf("{SIG_ERR}");
523 tprintf("{SIG_DFL}");
526 if (tcp->u_arg[0] == SIGTRAP) {
527 tcp->flags |= TCB_SIGTRAPPED;
528 kill(tcp->pid, SIGSTOP);
530 tprintf("{SIG_IGN}");
533 if (tcp->u_arg[0] == SIGTRAP) {
534 tcp->flags |= TCB_SIGTRAPPED;
535 kill(tcp->pid, SIGSTOP);
540 if (tcp->u_arg[0] == SIGTRAP) {
541 tcp->flags |= TCB_SIGTRAPPED;
542 kill(tcp->pid, SIGSTOP);
544 tprintf("{%#lx, ", (unsigned long) sv.sv_handler);
545 printsigmask(&sv.sv_mask, 0);
547 if (!printflags(sigvec_flags, sv.sv_flags))
561 if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */
563 long_to_sigset(tcp->u_arg[0], &sigm);
564 printsigmask(&sigm, 0);
577 addr = tcp->u_arg[0];
579 addr = tcp->u_arg[1];
582 else if (umove(tcp, addr, &ss) < 0)
583 tprintf("%#lx", addr);
585 tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp);
586 tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO");
600 #endif /* SUNOS4 || FREEBSD */
610 long_to_sigset(tcp->u_arg[0], &sigm);
611 printsigmask(&sigm, 0);
613 if ((tcp->u_arg[0] & sigmask(SIGTRAP))) {
614 /* Mark attempt to block SIGTRAP */
615 tcp->flags |= TCB_SIGTRAPPED;
616 /* Send unblockable signal */
617 kill(tcp->pid, SIGSTOP);
619 #endif /* !USE_PROCFS */
621 else if (!syserror(tcp)) {
623 long_to_sigset(tcp->u_rval, &sigm);
624 tcp->auxstr = sprintsigmask("old mask ", &sigm, 0);
626 return RVAL_HEX | RVAL_STR;
635 return sys_sigsetmask(tcp);
640 #ifdef HAVE_SIGACTION
643 struct old_sigaction {
644 __sighandler_t __sa_handler;
645 unsigned long sa_mask;
646 unsigned long sa_flags;
647 void (*sa_restorer)(void);
649 #define SA_HANDLER __sa_handler
653 #define SA_HANDLER sa_handler
663 struct old_sigaction sa;
670 printsignal(tcp->u_arg[0]);
672 addr = tcp->u_arg[1];
674 addr = tcp->u_arg[2];
677 else if (!verbose(tcp))
678 tprintf("%#lx", addr);
679 else if (umove(tcp, addr, &sa) < 0)
682 switch ((long) sa.SA_HANDLER) {
684 tprintf("{SIG_ERR}");
687 tprintf("{SIG_DFL}");
691 if (tcp->u_arg[0] == SIGTRAP) {
692 tcp->flags |= TCB_SIGTRAPPED;
693 kill(tcp->pid, SIGSTOP);
695 #endif /* !USE_PROCFS */
696 tprintf("{SIG_IGN}");
700 if (tcp->u_arg[0] == SIGTRAP) {
701 tcp->flags |= TCB_SIGTRAPPED;
702 kill(tcp->pid, SIGSTOP);
704 #endif /* !USE_PROCFS */
705 tprintf("{%#lx, ", (long) sa.SA_HANDLER);
707 printsigmask (&sa.sa_mask, 0);
709 long_to_sigset(sa.sa_mask, &sigset);
710 printsigmask(&sigset, 0);
713 if (!printflags(sigact_flags, sa.sa_flags))
722 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
732 printsignal(tcp->u_arg[0]);
734 switch (tcp->u_arg[1]) {
743 if (tcp->u_arg[0] == SIGTRAP) {
744 tcp->flags |= TCB_SIGTRAPPED;
745 kill(tcp->pid, SIGSTOP);
747 #endif /* !USE_PROCFS */
752 if (tcp->u_arg[0] == SIGTRAP) {
753 tcp->flags |= TCB_SIGTRAPPED;
754 kill(tcp->pid, SIGSTOP);
756 #endif /* !USE_PROCFS */
757 tprintf("%#lx", tcp->u_arg[1]);
762 switch (tcp->u_rval) {
764 tcp->auxstr = "SIG_ERR"; break;
766 tcp->auxstr = "SIG_DFL"; break;
768 tcp->auxstr = "SIG_IGN"; break;
772 return RVAL_HEX | RVAL_STR;
781 printsignal(tcp->u_arg[0]);
786 #endif /* HAVE_SIGACTION */
796 struct sigcontext_struct sc;
800 if (upeek(tcp->pid,PT_GPR15,&usp)<0)
802 if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0)
805 memcpy(&tcp->u_arg[1],&sc.oldmask[0],sizeof(sigset_t));
807 tcp->u_rval = tcp->u_error = 0;
808 if (tcp->u_arg[0] == 0)
810 tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1]);
811 return RVAL_NONE | RVAL_STR;
817 struct sigcontext_struct sc;
821 if (upeek(tcp->pid, 4*UESP, &esp) < 0)
823 if (umove(tcp, esp, &sc) < 0)
826 tcp->u_arg[1] = sc.oldmask;
830 long_to_sigset(tcp->u_arg[1], &sigm);
831 tcp->u_rval = tcp->u_error = 0;
832 if (tcp->u_arg[0] == 0)
834 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
835 return RVAL_NONE | RVAL_STR;
840 struct sigcontext sc;
844 /* offset of sigcontext in the kernel's sigframe structure: */
845 # define SIGFRAME_SC_OFFSET 0x90
847 if (upeek(tcp->pid, PT_R12, &sp) < 0)
849 if (umove(tcp, sp + 16 + SIGFRAME_SC_OFFSET, &sc) < 0)
852 memcpy(tcp->u_arg + 1, &sc.sc_mask, sizeof(sc.sc_mask));
857 memcpy(&sigm, tcp->u_arg + 1, sizeof (sigm));
858 tcp->u_rval = tcp->u_error = 0;
859 if (tcp->u_arg[0] == 0)
861 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
862 return RVAL_NONE | RVAL_STR;
868 struct sigcontext_struct sc;
872 if (upeek(tcp->pid, 4*PT_R1, &esp) < 0)
874 if (umove(tcp, esp, &sc) < 0)
877 tcp->u_arg[1] = sc.oldmask;
881 long_to_sigset(tcp->u_arg[1], &sigm);
882 tcp->u_rval = tcp->u_error = 0;
883 if (tcp->u_arg[0] == 0)
885 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
886 return RVAL_NONE | RVAL_STR;
892 struct sigcontext sc;
896 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
898 if (umove(tcp, usp, &sc) < 0)
901 tcp->u_arg[1] = sc.sc_mask;
905 long_to_sigset(tcp->u_arg[1], &sigm);
906 tcp->u_rval = tcp->u_error = 0;
907 if (tcp->u_arg[0] == 0)
909 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
910 return RVAL_NONE | RVAL_STR;
916 struct sigcontext_struct sc;
920 if (upeek(tcp->pid, REG_FP, &fp) < 0)
922 if (umove(tcp, fp, &sc) < 0)
925 tcp->u_arg[1] = sc.sc_mask;
929 long_to_sigset(tcp->u_arg[1], &sigm);
930 tcp->u_rval = tcp->u_error = 0;
931 if (tcp->u_arg[0] == 0)
933 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
934 return RVAL_NONE | RVAL_STR;
943 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
944 perror("sigreturn: PTRACE_GETREGS ");
950 if(umove(tcp, i1, &si) < 0) {
951 perror("sigreturn: umove ");
955 tcp->u_arg[1] = si.si_mask;
958 long_to_sigset(tcp->u_arg[1], &sigm);
959 tcp->u_rval = tcp->u_error = 0;
960 if(tcp->u_arg[0] == 0)
962 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
963 return RVAL_NONE | RVAL_STR;
969 struct sigcontext sc;
973 if (upeek(tcp->pid, REG_SP, &sp) < 0)
975 if (umove(tcp, sp, &sc) < 0)
978 tcp->u_arg[1] = sc.sc_sigset;
980 tcp->u_rval = tcp->u_error = 0;
981 if(tcp->u_arg[0] == 0)
983 tcp->auxstr = sprintsigmask("mask now ", tcp->u_arg[1]);
984 return RVAL_NONE | RVAL_STR;
989 #warning NO sys_sigreturn DECODE FOR HPPA
996 #endif /* !POWERPC */
1008 long_to_sigset(tcp->u_rval, &sigm);
1009 tcp->auxstr = sprintsigmask("mask ", &sigm, 0);
1011 return RVAL_HEX | RVAL_STR;
1018 if (entering(tcp)) {
1020 long_to_sigset(tcp->u_arg[2], &sigm);
1022 /* first two are not really arguments, but print them anyway */
1023 /* nevermind, they are an anachronism now, too bad... */
1024 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
1026 printsigmask(&sigm, 0);
1033 #if defined(SVR4) || defined(FREEBSD)
1041 if (entering(tcp)) {
1042 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
1045 printsigmask(&sigset, 0);
1050 static struct xlat ucontext_flags[] = {
1051 { UC_SIGMASK, "UC_SIGMASK" },
1052 { UC_STACK, "UC_STACK" },
1053 { UC_CPU, "UC_CPU" },
1055 { UC_FPU, "UC_FPU" },
1058 { UC_INTR, "UC_INTR" },
1062 #endif /* !FREEBSD */
1063 #endif /* SVR4 || FREEBSD */
1065 #if defined SVR4 || defined LINUX || defined FREEBSD
1066 #if defined LINUX && !defined SS_ONSTACK
1067 #define SS_ONSTACK 1
1068 #define SS_DISABLE 2
1069 #if __GLIBC_MINOR__ == 0
1079 #define stack_t struct sigaltstack
1082 static struct xlat sigaltstack_flags[] = {
1083 { SS_ONSTACK, "SS_ONSTACK" },
1084 { SS_DISABLE, "SS_DISABLE" },
1091 printcontext(tcp, ucp)
1097 tprintf("uc_flags=");
1098 if (!printflags(ucontext_flags, ucp->uc_flags))
1100 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
1102 tprintf("uc_sigmask=");
1103 printsigmask(&ucp->uc_sigmask, 0);
1105 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
1106 (unsigned long) ucp->uc_stack.ss_sp,
1107 ucp->uc_stack.ss_size);
1108 if (!printflags(sigaltstack_flags, ucp->uc_stack.ss_flags))
1123 tprintf("%#lx", tcp->u_arg[0]);
1124 else if (!tcp->u_arg[0])
1126 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1129 printcontext(tcp, &uc);
1140 if (entering(tcp)) {
1143 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1146 printcontext(tcp, &uc);
1149 tcp->u_rval = tcp->u_error = 0;
1150 if (tcp->u_arg[0] == 0)
1159 #if defined(LINUX) || defined(FREEBSD)
1162 print_stack_t(tcp, addr)
1167 if (umove(tcp, addr, &ss) < 0)
1169 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
1170 if (!printflags(sigaltstack_flags, ss.ss_flags))
1172 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
1177 sys_sigaltstack(tcp)
1180 if (entering(tcp)) {
1181 if (tcp->u_arg[0] == 0)
1183 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
1188 if (tcp->u_arg[1] == 0)
1190 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
1197 #ifdef HAVE_SIGACTION
1200 sys_sigprocmask(tcp)
1204 if (entering(tcp)) {
1205 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1207 printsigmask(tcp->u_arg[1], 0);
1209 else if (!syserror(tcp)) {
1210 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0);
1211 return RVAL_HEX | RVAL_STR;
1216 if (entering(tcp)) {
1218 if (tcp->u_arg[0] == 0)
1222 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1226 else if (copy_sigset(tcp, tcp->u_arg[1], &sigset) < 0)
1227 tprintf("%#lx, ", tcp->u_arg[1]);
1229 printsigmask(&sigset, 0);
1236 else if (syserror(tcp))
1237 tprintf("%#lx", tcp->u_arg[2]);
1238 else if (copy_sigset(tcp, tcp->u_arg[2], &sigset) < 0)
1241 printsigmask(&sigset, 0);
1247 #endif /* HAVE_SIGACTION */
1253 if (entering(tcp)) {
1254 tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1]));
1263 return sys_kill(tcp);
1274 tprintf("%#lx", tcp->u_arg[0]);
1275 else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1278 printsigmask(&sigset, 0);
1283 int sys_sigwait(tcp)
1288 if (entering(tcp)) {
1289 if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1292 printsigmask(&sigset, 0);
1295 if (!syserror(tcp)) {
1296 tcp->auxstr = signalent[tcp->u_rval];
1297 return RVAL_DECIMAL | RVAL_STR;
1306 sys_rt_sigprocmask(tcp)
1311 /* Note: arg[3] is the length of the sigset. */
1312 if (entering(tcp)) {
1313 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1317 else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0)
1318 tprintf("%#lx, ", tcp->u_arg[1]);
1320 printsigmask(&sigset, 1);
1328 else if (syserror(tcp))
1329 tprintf("%#lx", tcp->u_arg[2]);
1330 else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0)
1333 printsigmask(&sigset, 1);
1334 tprintf(", %lu", tcp->u_arg[3]);
1339 #if __GLIBC_MINOR__ < 1
1340 /* Type for data associated with a signal. */
1341 typedef union sigval
1347 # define __SI_MAX_SIZE 128
1348 # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
1350 typedef struct siginfo
1352 int si_signo; /* Signal number. */
1353 int si_errno; /* If non-zero, an errno value associated with
1354 this signal, as defined in <errno.h>. */
1355 int si_code; /* Signal code. */
1359 int _pad[__SI_PAD_SIZE];
1364 __pid_t si_pid; /* Sending process ID. */
1365 __uid_t si_uid; /* Real user ID of sending process. */
1368 /* POSIX.1b timers. */
1371 unsigned int _timer1;
1372 unsigned int _timer2;
1375 /* POSIX.1b signals. */
1378 __pid_t si_pid; /* Sending process ID. */
1379 __uid_t si_uid; /* Real user ID of sending process. */
1380 sigval_t si_sigval; /* Signal value. */
1386 __pid_t si_pid; /* Which child. */
1387 int si_status; /* Exit value or signal. */
1392 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
1395 void *si_addr; /* Faulting insn/memory ref. */
1401 int si_band; /* Band event for SIGPOLL. */
1408 /* Structure describing the action to be taken when a signal arrives. */
1409 struct new_sigaction
1413 __sighandler_t __sa_handler;
1414 void (*__sa_sigaction) (int, siginfo_t *, void *);
1416 __sigaction_handler;
1417 unsigned long sa_flags;
1418 void (*sa_restorer) (void);
1419 unsigned long int sa_mask[2];
1424 sys_rt_sigaction(tcp)
1427 struct new_sigaction sa;
1431 if (entering(tcp)) {
1432 printsignal(tcp->u_arg[0]);
1434 addr = tcp->u_arg[1];
1436 addr = tcp->u_arg[2];
1439 else if (!verbose(tcp))
1440 tprintf("%#lx", addr);
1441 else if (umove(tcp, addr, &sa) < 0)
1444 switch ((long) sa.__sigaction_handler.__sa_handler) {
1445 case (long) SIG_ERR:
1446 tprintf("{SIG_ERR}");
1448 case (long) SIG_DFL:
1449 tprintf("{SIG_DFL}");
1451 case (long) SIG_IGN:
1452 tprintf("{SIG_IGN}");
1456 (long) sa.__sigaction_handler.__sa_handler);
1457 sigemptyset(&sigset);
1459 if (tcp->u_arg[4] <= sizeof(sigset))
1460 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
1462 if (tcp->u_arg[3] <= sizeof(sigset))
1463 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
1466 memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
1467 printsigmask(&sigset, 1);
1469 if (!printflags(sigact_flags, sa.sa_flags))
1478 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
1479 #elif defined(ALPHA)
1480 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
1482 tprintf(", %lu", addr = tcp->u_arg[3]);
1488 sys_rt_sigpending(tcp)
1495 tprintf("%#lx", tcp->u_arg[0]);
1496 else if (copy_sigset_len(tcp, tcp->u_arg[0],
1497 &sigset, tcp->u_arg[1]) < 0)
1500 printsigmask(&sigset, 1);
1505 sys_rt_sigsuspend(tcp)
1508 if (entering(tcp)) {
1510 if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0)
1513 printsigmask(&sigm, 1);
1518 #define ILL_ILLOPC 1 /* illegal opcode */
1519 #define ILL_ILLOPN 2 /* illegal operand */
1520 #define ILL_ILLADR 3 /* illegal addressing mode */
1521 #define ILL_ILLTRP 4 /* illegal trap */
1522 #define ILL_PRVOPC 5 /* privileged opcode */
1523 #define ILL_PRVREG 6 /* privileged register */
1524 #define ILL_COPROC 7 /* coprocessor error */
1525 #define ILL_BADSTK 8 /* internal stack error */
1526 #define FPE_INTDIV 1 /* integer divide by zero */
1527 #define FPE_INTOVF 2 /* integer overflow */
1528 #define FPE_FLTDIV 3 /* floating point divide by zero */
1529 #define FPE_FLTOVF 4 /* floating point overflow */
1530 #define FPE_FLTUND 5 /* floating point underflow */
1531 #define FPE_FLTRES 6 /* floating point inexact result */
1532 #define FPE_FLTINV 7 /* floating point invalid operation */
1533 #define FPE_FLTSUB 8 /* subscript out of range */
1534 #define SEGV_MAPERR 1 /* address not mapped to object */
1535 #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
1536 #define BUS_ADRALN 1 /* invalid address alignment */
1537 #define BUS_ADRERR 2 /* non-existant physical address */
1538 #define BUS_OBJERR 3 /* object specific hardware error */
1539 #define TRAP_BRKPT 1 /* process breakpoint */
1540 #define TRAP_TRACE 2 /* process trace trap */
1541 #define CLD_EXITED 1 /* child has exited */
1542 #define CLD_KILLED 2 /* child was killed */
1543 #define CLD_DUMPED 3 /* child terminated abnormally */
1544 #define CLD_TRAPPED 4 /* traced child has trapped */
1545 #define CLD_STOPPED 5 /* child has stopped */
1546 #define CLD_CONTINUED 6 /* stopped child has continued */
1547 #define POLL_IN 1 /* data input available */
1548 #define POLL_OUT 2 /* output buffers available */
1549 #define POLL_MSG 3 /* input message available */
1550 #define POLL_ERR 4 /* i/o error */
1551 #define POLL_PRI 5 /* high priority input available */
1552 #define POLL_HUP 6 /* device disconnected */
1553 #define SI_USER 0 /* sent by kill, sigsend, raise */
1554 #define SI_QUEUE -1 /* sent by sigqueue */
1555 #define SI_TIMER -2 /* sent by timer expiration */
1556 #define SI_MESGQ -3 /* sent by real time mesq state change */
1557 #define SI_ASYNCIO -4 /* sent by AIO completion */
1572 static struct xlat sigill_flags[] = {
1573 {ILL_ILLOPC, "ILL_ILLOPC"},
1574 {ILL_ILLOPN, "ILL_ILLOPN"},
1575 {ILL_ILLADR, "ILL_ILLADR"},
1576 {ILL_ILLTRP, "ILL_ILLTRP"},
1577 {ILL_PRVOPC, "ILL_PRVOPC"},
1578 {ILL_PRVREG, "ILL_PRVREG"},
1579 {ILL_COPROC, "ILL_COPROC"},
1580 {ILL_BADSTK, "ILL_BADSTK"},
1584 static struct xlat sigfpe_flags[] = {
1585 {FPE_INTDIV, "FPE_INTDIV"},
1586 {FPE_INTOVF, "FPE_INTOVF"},
1587 {FPE_FLTDIV, "FPE_FLTDIV"},
1588 {FPE_FLTOVF, "FPE_FLTOVF"},
1589 {FPE_FLTUND, "FPE_FLTUND"},
1590 {FPE_FLTRES, "FPE_FLTRES"},
1591 {FPE_FLTINV, "FPE_FLTINV"},
1592 {FPE_FLTSUB, "FPE_FLTSUB"},
1596 static struct xlat sigsegv_flags[] = {
1597 {SEGV_MAPERR, "SEGV_MAPERR"},
1598 {SEGV_ACCERR, "SEGV_ACCERR"},
1602 static struct xlat sigbus_flags[] = {
1603 {BUS_ADRALN, "BUS_ADRALN"},
1604 {BUS_ADRERR, "BUS_ADRERR"},
1605 {BUS_OBJERR, "BUS_OBJERR"},
1609 static struct xlat sigtrap_flags[] = {
1610 {TRAP_BRKPT, "TRAP_BRKPT"},
1611 {TRAP_TRACE, "TRAP_TRACE"},
1615 static struct xlat sigchld_flags[] = {
1616 {CLD_EXITED, "CLD_EXITED"},
1617 {CLD_KILLED, "CLD_KILLED"},
1618 {CLD_DUMPED, "CLD_DUMPED"},
1619 {CLD_TRAPPED, "CLD_TRAPPED"},
1620 {CLD_STOPPED, "CLD_STOPPED"},
1621 {CLD_CONTINUED, "CLD_CONTINUED"},
1625 static struct xlat sigpoll_flags[] = {
1626 {POLL_IN, "POLL_IN"},
1627 {POLL_OUT, "POLL_OUT"},
1628 {POLL_MSG, "POLL_MSG"},
1629 {POLL_ERR, "POLL_ERR"},
1630 {POLL_PRI, "POLL_PRI"},
1631 {POLL_HUP, "POLL_HUP"},
1635 static struct xlat siginfo_flags[] = {
1636 {SI_USER, "SI_USER"},
1637 {SI_QUEUE, "SI_QUEUE"},
1638 {SI_TIMER, "SI_TIMER"},
1639 {SI_MESGQ, "SI_MESGQ"},
1640 {SI_ASYNCIO, "SI_ASYNCIO"},
1645 printsiginfo(tcp, si)
1649 tprintf("{si_signo=");
1650 printsignal(si->si_signo);
1651 tprintf(", si_errno=%d, si_code=", si->si_errno);
1652 switch(si->si_signo)
1655 if (!printflags(sigill_flags, si->si_code))
1656 tprintf("%d /* ILL_??? */", si->si_code);
1657 tprintf(", si_addr=%lx",
1658 (unsigned long) si->_sifields._sigfault.si_addr);
1661 if (!printflags(sigfpe_flags, si->si_code))
1662 tprintf("%d /* FPE_??? */", si->si_code);
1663 tprintf(", si_addr=%lx",
1664 (unsigned long) si->_sifields._sigfault.si_addr);
1667 if (!printflags(sigsegv_flags, si->si_code))
1668 tprintf("%d /* SEGV_??? */", si->si_code);
1669 tprintf(", si_addr=%lx",
1670 (unsigned long) si->_sifields._sigfault.si_addr);
1673 if (!printflags(sigbus_flags, si->si_code))
1674 tprintf("%d /* BUS_??? */", si->si_code);
1675 tprintf(", si_addr=%lx",
1676 (unsigned long) si->_sifields._sigfault.si_addr);
1679 if (!printflags(sigtrap_flags, si->si_code))
1680 tprintf("%d /* TRAP_??? */", si->si_code);
1683 if (!printflags(sigchld_flags, si->si_code))
1684 tprintf("%d /* CLD_??? */", si->si_code);
1688 tprintf(", si_pid=%d, si_uid=%d, si_status=%d, si_utime=%lu, si_stime=%lu",
1689 si->_sifields._kill.si_pid,
1690 si->_sifields._kill.si_uid,
1691 si->_sifields._sigchld.si_status,
1692 si->_sifields._sigchld.si_utime,
1693 si->_sifields._sigchld.si_stime);
1696 if (!printflags(sigpoll_flags, si->si_code))
1697 tprintf("%d /* POLL_??? */", si->si_code);
1698 if (si->si_code == POLL_IN
1699 || si->si_code == POLL_OUT
1700 || si->si_code == POLL_MSG)
1701 tprintf(", si_bind=%lu, si_fd=%d",
1702 (unsigned long) si->_sifields._sigpoll.si_band,
1703 si->_sifields._sigpoll.si_fd);
1706 if (!printflags(siginfo_flags, si->si_code))
1707 tprintf("%d /* SI_??? */", si->si_code);
1708 tprintf(", si_pid=%lu, si_uid=%lu, si_value={",
1709 (unsigned long) si->_sifields._rt.si_pid,
1710 (unsigned long) si->_sifields._rt.si_uid);
1714 tprintf("sival_int=%u, sival_ptr=%#lx",
1715 si->_sifields._rt.si_sigval.sival_int,
1716 (unsigned long) si->_sifields._rt.si_sigval.sival_ptr);
1725 sys_rt_sigqueueinfo(tcp)
1728 if (entering(tcp)) {
1730 tprintf("%lu, ", tcp->u_arg[0]);
1731 printsignal(tcp->u_arg[1]);
1733 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1734 tprintf("%#lx", tcp->u_arg[2]);
1741 int sys_rt_sigtimedwait(tcp)
1744 if (entering(tcp)) {
1747 if (copy_sigset_len(tcp, tcp->u_arg[0],
1748 &sigset, tcp->u_arg[3]) < 0)
1751 printsigmask(&sigset, 1);
1756 tprintf("%#lx", tcp->u_arg[0]);
1759 if (umove(tcp, tcp->u_arg[1], &si) < 0)
1760 tprintf("%#lx", tcp->u_arg[1]);
1764 tprintf(", %#lx", tcp->u_arg[2]);
1765 tprintf(", %d", (int) tcp->u_arg[3]);