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 # ifdef HAVE_STRUCT_IA64_FPREG
57 # define ia64_fpreg XXX_ia64_fpreg
59 # ifdef HAVE_STRUCT_PT_ALL_USER_REGS
60 # define pt_all_user_regs XXX_pt_all_user_regs
62 #include <linux/ptrace.h>
64 # undef pt_all_user_regs
71 # include <asm/ptrace_offsets.h>
75 # if defined (SPARC) || defined (SPARC64)
76 # define fpq kernel_fpq
78 # define fpu kernel_fpu
81 # if defined (SPARC) || defined (SPARC64)
86 #if defined (LINUX) && defined (SPARC64)
88 # undef PTRACE_GETREGS
89 # define PTRACE_GETREGS PTRACE_GETREGS64
90 # undef PTRACE_SETREGS
91 # define PTRACE_SETREGS PTRACE_SETREGS64
92 #endif /* LINUX && SPARC64 */
93 #endif /* HAVE_ASM_REG_H */
95 #if defined (SPARC) || defined (SPARC64)
102 struct pt_regs si_regs;
105 #elif defined HAVE_ASM_SIGCONTEXT_H
106 #if !defined(IA64) && !defined(X86_64)
107 #include <asm/sigcontext.h>
108 #endif /* !IA64 && !X86_64 */
109 #else /* !HAVE_ASM_SIGCONTEXT_H */
110 #if defined I386 && !defined HAVE_STRUCT_SIGCONTEXT_STRUCT
111 struct sigcontext_struct {
112 unsigned short gs, __gsh;
113 unsigned short fs, __fsh;
114 unsigned short es, __esh;
115 unsigned short ds, __dsh;
124 unsigned long trapno;
127 unsigned short cs, __csh;
128 unsigned long eflags;
129 unsigned long esp_at_signal;
130 unsigned short ss, __ssh;
132 unsigned long oldmask;
139 unsigned long sc_mask;
140 unsigned long sc_usp;
145 unsigned short sc_sr;
147 unsigned short sc_formatvec;
151 #endif /* !HAVE_ASM_SIGCONTEXT_H */
161 const char *const signalent0[] = {
162 #include "signalent.h"
164 const int nsignals0 = sizeof signalent0 / sizeof signalent0[0];
166 #if SUPPORTED_PERSONALITIES >= 2
167 const char *const signalent1[] = {
168 #include "signalent1.h"
170 const int nsignals1 = sizeof signalent1 / sizeof signalent1[0];
171 #endif /* SUPPORTED_PERSONALITIES >= 2 */
173 #if SUPPORTED_PERSONALITIES >= 3
174 const char *const signalent2[] = {
175 #include "signalent2.h"
177 const int nsignals2 = sizeof signalent2 / sizeof signalent2[0];
178 #endif /* SUPPORTED_PERSONALITIES >= 3 */
180 const char *const *signalent;
183 #if defined(SUNOS4) || defined(FREEBSD)
185 static const struct xlat sigvec_flags[] = {
186 { SV_ONSTACK, "SV_ONSTACK" },
187 { SV_INTERRUPT, "SV_INTERRUPT" },
188 { SV_RESETHAND, "SV_RESETHAND" },
189 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
193 #endif /* SUNOS4 || FREEBSD */
195 #ifdef HAVE_SIGACTION
197 #if defined LINUX && (defined I386 || defined X86_64)
198 /* The libc headers do not define this constant since it should only be
199 used by the implementation. So wwe define it here. */
201 # define SA_RESTORER 0x04000000
205 static const struct xlat sigact_flags[] = {
207 { SA_RESTORER, "SA_RESTORER" },
210 { SA_STACK, "SA_STACK" },
213 { SA_RESTART, "SA_RESTART" },
216 { SA_INTERRUPT, "SA_INTERRUPT" },
219 { SA_NOMASK, "SA_NOMASK" },
222 { SA_ONESHOT, "SA_ONESHOT" },
225 { SA_SIGINFO, "SA_SIGINFO" },
228 { SA_RESETHAND, "SA_RESETHAND" },
231 { SA_ONSTACK, "SA_ONSTACK" },
234 { SA_NODEFER, "SA_NODEFER" },
237 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
240 { SA_NOCLDWAIT, "SA_NOCLDWAIT" },
243 { _SA_BSDCALL, "_SA_BSDCALL" },
248 static const struct xlat sigprocmaskcmds[] = {
249 { SIG_BLOCK, "SIG_BLOCK" },
250 { SIG_UNBLOCK, "SIG_UNBLOCK" },
251 { SIG_SETMASK, "SIG_SETMASK" },
253 { SIG_SETMASK32,"SIG_SETMASK32" },
258 #endif /* HAVE_SIGACTION */
260 /* Anonymous realtime signals. */
261 /* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
262 constant. This is what we want. Otherwise, just use SIGRTMIN. */
265 #define __SIGRTMIN SIGRTMIN
266 #define __SIGRTMAX SIGRTMAX /* likewise */
275 if (sig >= 0 && sig < nsignals) {
276 return signalent[sig];
278 } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) {
279 sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN));
281 #endif /* SIGRTMIN */
283 sprintf(buf, "%d", sig);
300 copy_sigset_len(tcp, addr, s, len)
306 if (len > sizeof(*s))
309 if (umoven(tcp, addr, len, (char *)s) < 0)
315 /* Original sigset is unsigned long */
316 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long))
318 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t))
322 sprintsigmask(const char *str, sigset_t *mask, int rt)
323 /* set might include realtime sigs */
328 static char outstr[8 * sizeof(sigset_t) * 8];
331 s = outstr + strlen(outstr);
336 maxsigs = __SIGRTMAX; /* instead */
338 for (i = 1; i < maxsigs; i++) {
339 if (sigismember(mask, i) == 1)
342 if (nsigs >= nsignals * 2 / 3) {
344 for (i = 1; i < maxsigs; i++) {
345 switch (sigismember(mask, i)) {
357 for (i = 1; i < maxsigs; i++) {
358 if (sigismember(mask, i) == 1) {
359 /* real-time signals on solaris don't have
363 sprintf(s, format, signalent[i] + 3);
366 else if (i >= __SIGRTMIN && i <= __SIGRTMAX) {
368 sprintf(tsig, "RT_%u", i - __SIGRTMIN);
369 sprintf(s, format, tsig);
371 #endif /* SIGRTMIN */
374 sprintf(tsig, "%u", i);
375 sprintf(s, format, tsig);
387 printsigmask(mask, rt)
391 tprintf("%s", sprintsigmask("", mask, rt));
398 tprintf(signame(nr));
402 print_sigset(struct tcb *tcp, long addr, int rt)
408 else if (copy_sigset(tcp, addr, &ss) < 0)
409 tprintf("%#lx", addr);
411 printsigmask(&ss, rt);
417 #define ILL_ILLOPC 1 /* illegal opcode */
418 #define ILL_ILLOPN 2 /* illegal operand */
419 #define ILL_ILLADR 3 /* illegal addressing mode */
420 #define ILL_ILLTRP 4 /* illegal trap */
421 #define ILL_PRVOPC 5 /* privileged opcode */
422 #define ILL_PRVREG 6 /* privileged register */
423 #define ILL_COPROC 7 /* coprocessor error */
424 #define ILL_BADSTK 8 /* internal stack error */
425 #define FPE_INTDIV 1 /* integer divide by zero */
426 #define FPE_INTOVF 2 /* integer overflow */
427 #define FPE_FLTDIV 3 /* floating point divide by zero */
428 #define FPE_FLTOVF 4 /* floating point overflow */
429 #define FPE_FLTUND 5 /* floating point underflow */
430 #define FPE_FLTRES 6 /* floating point inexact result */
431 #define FPE_FLTINV 7 /* floating point invalid operation */
432 #define FPE_FLTSUB 8 /* subscript out of range */
433 #define SEGV_MAPERR 1 /* address not mapped to object */
434 #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
435 #define BUS_ADRALN 1 /* invalid address alignment */
436 #define BUS_ADRERR 2 /* non-existant physical address */
437 #define BUS_OBJERR 3 /* object specific hardware error */
438 #define TRAP_BRKPT 1 /* process breakpoint */
439 #define TRAP_TRACE 2 /* process trace trap */
440 #define CLD_EXITED 1 /* child has exited */
441 #define CLD_KILLED 2 /* child was killed */
442 #define CLD_DUMPED 3 /* child terminated abnormally */
443 #define CLD_TRAPPED 4 /* traced child has trapped */
444 #define CLD_STOPPED 5 /* child has stopped */
445 #define CLD_CONTINUED 6 /* stopped child has continued */
446 #define POLL_IN 1 /* data input available */
447 #define POLL_OUT 2 /* output buffers available */
448 #define POLL_MSG 3 /* input message available */
449 #define POLL_ERR 4 /* i/o error */
450 #define POLL_PRI 5 /* high priority input available */
451 #define POLL_HUP 6 /* device disconnected */
452 #define SI_USER 0 /* sent by kill, sigsend, raise */
453 #define SI_QUEUE -1 /* sent by sigqueue */
454 #define SI_TIMER -2 /* sent by timer expiration */
455 #define SI_MESGQ -3 /* sent by real time mesq state change */
456 #define SI_ASYNCIO -4 /* sent by AIO completion */
457 #define SI_SIGIO -5 /* Sent by SIGIO */
458 #define SI_TKILL -6 /* Sent by tkill */
461 #if __GLIBC_MINOR__ < 1
462 /* Type for data associated with a signal. */
469 # define __SI_MAX_SIZE 128
470 # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
472 typedef struct siginfo
474 int si_signo; /* Signal number. */
475 int si_errno; /* If non-zero, an errno value associated with
476 this signal, as defined in <errno.h>. */
477 int si_code; /* Signal code. */
481 int _pad[__SI_PAD_SIZE];
486 __pid_t si_pid; /* Sending process ID. */
487 __uid_t si_uid; /* Real user ID of sending process. */
490 /* POSIX.1b timers. */
493 unsigned int _timer1;
494 unsigned int _timer2;
497 /* POSIX.1b signals. */
500 __pid_t si_pid; /* Sending process ID. */
501 __uid_t si_uid; /* Real user ID of sending process. */
502 sigval_t si_sigval; /* Signal value. */
508 __pid_t si_pid; /* Which child. */
509 int si_status; /* Exit value or signal. */
514 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
517 void *si_addr; /* Faulting insn/memory ref. */
523 int si_band; /* Band event for SIGPOLL. */
529 #define si_pid _sifields._kill.si_pid
530 #define si_uid _sifields._kill.si_uid
531 #define si_status _sifields._sigchld.si_status
532 #define si_utime _sifields._sigchld.si_utime
533 #define si_stime _sifields._sigchld.si_stime
534 #define si_value _sifields._rt.si_sigval
535 #define si_int _sifields._rt.si_sigval.sival_int
536 #define si_ptr _sifields._rt.si_sigval.sival_ptr
537 #define si_addr _sifields._sigfault.si_addr
538 #define si_band _sifields._sigpoll.si_band
539 #define si_fd _sifields._sigpoll.si_fd
545 #if defined (SVR4) || defined (LINUX)
547 static const struct xlat siginfo_codes[] = {
549 { SI_NOINFO, "SI_NOINFO" },
552 { SI_USER, "SI_USER" },
555 { SI_LWP, "SI_LWP" },
558 { SI_QUEUE, "SI_QUEUE" },
561 { SI_TIMER, "SI_TIMER" },
564 { SI_ASYNCIO, "SI_ASYNCIO" },
567 { SI_MESGQ, "SI_MESGQ" },
570 { SI_SIGIO, "SI_SIGIO" },
573 { SI_TKILL, "SI_TKILL" },
578 static const struct xlat sigill_codes[] = {
579 { ILL_ILLOPC, "ILL_ILLOPC" },
580 { ILL_ILLOPN, "ILL_ILLOPN" },
581 { ILL_ILLADR, "ILL_ILLADR" },
582 { ILL_ILLTRP, "ILL_ILLTRP" },
583 { ILL_PRVOPC, "ILL_PRVOPC" },
584 { ILL_PRVREG, "ILL_PRVREG" },
585 { ILL_COPROC, "ILL_COPROC" },
586 { ILL_BADSTK, "ILL_BADSTK" },
590 static const struct xlat sigfpe_codes[] = {
591 { FPE_INTDIV, "FPE_INTDIV" },
592 { FPE_INTOVF, "FPE_INTOVF" },
593 { FPE_FLTDIV, "FPE_FLTDIV" },
594 { FPE_FLTOVF, "FPE_FLTOVF" },
595 { FPE_FLTUND, "FPE_FLTUND" },
596 { FPE_FLTRES, "FPE_FLTRES" },
597 { FPE_FLTINV, "FPE_FLTINV" },
598 { FPE_FLTSUB, "FPE_FLTSUB" },
602 static const struct xlat sigtrap_codes[] = {
603 { TRAP_BRKPT, "TRAP_BRKPT" },
604 { TRAP_TRACE, "TRAP_TRACE" },
608 static const struct xlat sigchld_codes[] = {
609 { CLD_EXITED, "CLD_EXITED" },
610 { CLD_KILLED, "CLD_KILLED" },
611 { CLD_DUMPED, "CLD_DUMPED" },
612 { CLD_TRAPPED, "CLD_TRAPPED" },
613 { CLD_STOPPED, "CLD_STOPPED" },
614 { CLD_CONTINUED,"CLD_CONTINUED" },
618 static const struct xlat sigpoll_codes[] = {
619 { POLL_IN, "POLL_IN" },
620 { POLL_OUT, "POLL_OUT" },
621 { POLL_MSG, "POLL_MSG" },
622 { POLL_ERR, "POLL_ERR" },
623 { POLL_PRI, "POLL_PRI" },
624 { POLL_HUP, "POLL_HUP" },
628 static const struct xlat sigprof_codes[] = {
630 { PROF_SIG, "PROF_SIG" },
636 static const struct xlat sigemt_codes[] = {
638 { EMT_TAGOVF, "EMT_TAGOVF" },
644 static const struct xlat sigsegv_codes[] = {
645 { SEGV_MAPERR, "SEGV_MAPERR" },
646 { SEGV_ACCERR, "SEGV_ACCERR" },
650 static const struct xlat sigbus_codes[] = {
651 { BUS_ADRALN, "BUS_ADRALN" },
652 { BUS_ADRERR, "BUS_ADRERR" },
653 { BUS_OBJERR, "BUS_OBJERR" },
658 printsiginfo(sip, verbose)
664 if (sip->si_signo == 0) {
668 tprintf("{si_signo=");
669 printsignal(sip->si_signo);
670 code = xlookup(siginfo_codes, sip->si_code);
672 switch (sip->si_signo) {
674 code = xlookup(sigtrap_codes, sip->si_code);
677 code = xlookup(sigchld_codes, sip->si_code);
680 code = xlookup(sigpoll_codes, sip->si_code);
683 code = xlookup(sigprof_codes, sip->si_code);
686 code = xlookup(sigill_codes, sip->si_code);
690 code = xlookup(sigemt_codes, sip->si_code);
694 code = xlookup(sigfpe_codes, sip->si_code);
697 code = xlookup(sigsegv_codes, sip->si_code);
700 code = xlookup(sigbus_codes, sip->si_code);
705 tprintf(", si_code=%s", code);
707 tprintf(", si_code=%#x", sip->si_code);
709 if (sip->si_code != SI_NOINFO)
713 if (sip->si_errno < 0 || sip->si_errno >= nerrnos)
714 tprintf(", si_errno=%d", sip->si_errno);
716 tprintf(", si_errno=%s",
717 errnoent[sip->si_errno]);
720 if (SI_FROMUSER(sip)) {
721 tprintf(", si_pid=%ld, si_uid=%ld",
722 sip->si_pid, sip->si_uid);
724 switch (sip->si_code) {
728 #endif /* SI_QUEUE */
732 #endif /* SI_MESGQ */
733 tprintf(", si_value=%d",
734 sip->si_value.sival_int);
737 #endif /* SI_QUEUE */
740 #endif /* SI_FROMUSER */
742 switch (sip->si_signo) {
744 tprintf(", si_pid=%ld, si_status=",
746 if (sip->si_code == CLD_EXITED)
747 tprintf("%d", sip->si_status);
749 printsignal(sip->si_status);
754 tprintf(", si_utime=%lu, si_stime=%lu",
759 case SIGILL: case SIGFPE:
760 case SIGSEGV: case SIGBUS:
761 tprintf(", si_addr=%#lx",
762 (unsigned long) sip->si_addr);
765 switch (sip->si_code) {
766 case POLL_IN: case POLL_OUT: case POLL_MSG:
767 tprintf(", si_band=%ld",
768 (long) sip->si_band);
774 tprintf(", si_pid=%lu, si_uid=%lu, ",
775 (unsigned long) sip->si_pid,
776 (unsigned long) sip->si_uid);
780 tprintf("si_value={int=%u, ptr=%#lx}",
782 (unsigned long) sip->si_ptr);
792 #endif /* SVR4 || LINUX */
797 parse_sigset_t (const char *str, sigset_t *set)
805 p = strchr(str, '\n');
807 p = strchr(str, '\0');
808 for (i = 0; p-- > str; i += 4) {
809 if (*p >= '0' && *p <= '9')
811 else if (*p >= 'a' && *p <= 'f')
812 digit = *p - 'a' + 10;
813 else if (*p >= 'A' && *p <= 'F')
814 digit = *p - 'A' + 10;
818 sigaddset(set, i + 1);
820 sigaddset(set, i + 2);
822 sigaddset(set, i + 3);
824 sigaddset(set, i + 4);
831 * Check process TCP for the disposition of signal SIG.
832 * Return 1 if the process would somehow manage to survive signal SIG,
833 * else return 0. This routine will never be called with SIGKILL.
836 sigishandled(tcp, sig)
846 sigset_t ignored, caught;
850 * Since procfs doesn't interfere with wait I think it is safe
851 * to punt on this question. If not, the information is there.
863 #if defined(SIGURG) && SIGURG != SIGIO
867 /* Gloria Gaynor says ... */
875 /* This is incredibly costly but it's worth it. */
876 /* NOTE: LinuxThreads internally uses SIGRTMIN, SIGRTMIN + 1 and
877 SIGRTMIN + 2, so we can't use the obsolete /proc/%d/stat which
878 doesn't handle real-time signals). */
879 sprintf(sname, "/proc/%d/status", tcp->pid);
880 if ((sfd = open(sname, O_RDONLY)) == -1) {
884 i = read(sfd, buf, sizeof(buf));
888 * Skip the extraneous fields. We need to skip
889 * command name has any spaces in it. So be it.
891 s = strstr(buf, "SigIgn:\t");
894 fprintf(stderr, "/proc/pid/status format error\n");
897 parse_sigset_t(s + 8, &ignored);
899 s = strstr(buf, "SigCgt:\t");
902 fprintf(stderr, "/proc/pid/status format error\n");
905 parse_sigset_t(s + 8, &caught);
908 fprintf(stderr, "sigs: %016qx %016qx (sig=%d)\n",
909 *(long long *) &ignored, *(long long *) &caught, sig);
911 if (sigismember(&ignored, sig) || sigismember(&caught, sig))
918 if (upeek(tcp->pid, uoff(u_signal[0]) + sig*sizeof(u_signal),
919 (long *) &u_signal) < 0) {
922 if (u_signal != SIG_DFL)
929 #if defined(SUNOS4) || defined(FREEBSD)
939 printsignal(tcp->u_arg[0]);
941 addr = tcp->u_arg[1];
943 addr = tcp->u_arg[2];
947 else if (!verbose(tcp))
948 tprintf("%#lx", addr);
949 else if (umove(tcp, addr, &sv) < 0)
952 switch ((int) sv.sv_handler) {
954 tprintf("{SIG_ERR}");
957 tprintf("{SIG_DFL}");
960 if (tcp->u_arg[0] == SIGTRAP) {
961 tcp->flags |= TCB_SIGTRAPPED;
962 kill(tcp->pid, SIGSTOP);
964 tprintf("{SIG_IGN}");
967 if (tcp->u_arg[0] == SIGTRAP) {
968 tcp->flags |= TCB_SIGTRAPPED;
969 kill(tcp->pid, SIGSTOP);
974 if (tcp->u_arg[0] == SIGTRAP) {
975 tcp->flags |= TCB_SIGTRAPPED;
976 kill(tcp->pid, SIGSTOP);
978 tprintf("{%#lx, ", (unsigned long) sv.sv_handler);
979 printsigmask(&sv.sv_mask, 0);
981 printflags(sigvec_flags, sv.sv_flags, "SV_???");
994 if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */
996 long_to_sigset(tcp->u_arg[0], &sigm);
997 printsigmask(&sigm, 0);
1010 addr = tcp->u_arg[0];
1012 addr = tcp->u_arg[1];
1015 else if (umove(tcp, addr, &ss) < 0)
1016 tprintf("%#lx", addr);
1018 tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp);
1019 tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO");
1033 #endif /* SUNOS4 || FREEBSD */
1041 if (entering(tcp)) {
1043 long_to_sigset(tcp->u_arg[0], &sigm);
1044 printsigmask(&sigm, 0);
1046 if ((tcp->u_arg[0] & sigmask(SIGTRAP))) {
1047 /* Mark attempt to block SIGTRAP */
1048 tcp->flags |= TCB_SIGTRAPPED;
1049 /* Send unblockable signal */
1050 kill(tcp->pid, SIGSTOP);
1052 #endif /* !USE_PROCFS */
1054 else if (!syserror(tcp)) {
1056 long_to_sigset(tcp->u_rval, &sigm);
1057 tcp->auxstr = sprintsigmask("old mask ", &sigm, 0);
1059 return RVAL_HEX | RVAL_STR;
1064 #if defined(SUNOS4) || defined(FREEBSD)
1069 return sys_sigsetmask(tcp);
1071 #endif /* SUNOS4 || FREEBSD */
1075 #ifdef HAVE_SIGACTION
1078 struct old_sigaction {
1079 __sighandler_t __sa_handler;
1080 unsigned long sa_mask;
1081 unsigned long sa_flags;
1082 void (*sa_restorer)(void);
1084 #define SA_HANDLER __sa_handler
1088 #define SA_HANDLER sa_handler
1098 struct old_sigaction sa;
1100 struct sigaction sa;
1104 if (entering(tcp)) {
1105 printsignal(tcp->u_arg[0]);
1107 addr = tcp->u_arg[1];
1109 addr = tcp->u_arg[2];
1112 else if (!verbose(tcp))
1113 tprintf("%#lx", addr);
1114 else if (umove(tcp, addr, &sa) < 0)
1117 switch ((long) sa.SA_HANDLER) {
1118 case (long) SIG_ERR:
1119 tprintf("{SIG_ERR}");
1121 case (long) SIG_DFL:
1122 tprintf("{SIG_DFL}");
1124 case (long) SIG_IGN:
1126 if (tcp->u_arg[0] == SIGTRAP) {
1127 tcp->flags |= TCB_SIGTRAPPED;
1128 kill(tcp->pid, SIGSTOP);
1130 #endif /* !USE_PROCFS */
1131 tprintf("{SIG_IGN}");
1135 if (tcp->u_arg[0] == SIGTRAP) {
1136 tcp->flags |= TCB_SIGTRAPPED;
1137 kill(tcp->pid, SIGSTOP);
1139 #endif /* !USE_PROCFS */
1140 tprintf("{%#lx, ", (long) sa.SA_HANDLER);
1142 printsigmask (&sa.sa_mask, 0);
1144 long_to_sigset(sa.sa_mask, &sigset);
1145 printsigmask(&sigset, 0);
1148 printflags(sigact_flags, sa.sa_flags, "SA_???");
1150 if (sa.sa_flags & SA_RESTORER)
1151 tprintf(", %p", sa.sa_restorer);
1160 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
1169 if (entering(tcp)) {
1170 printsignal(tcp->u_arg[0]);
1172 switch (tcp->u_arg[1]) {
1181 if (tcp->u_arg[0] == SIGTRAP) {
1182 tcp->flags |= TCB_SIGTRAPPED;
1183 kill(tcp->pid, SIGSTOP);
1185 #endif /* !USE_PROCFS */
1190 if (tcp->u_arg[0] == SIGTRAP) {
1191 tcp->flags |= TCB_SIGTRAPPED;
1192 kill(tcp->pid, SIGSTOP);
1194 #endif /* !USE_PROCFS */
1195 tprintf("%#lx", tcp->u_arg[1]);
1200 switch (tcp->u_rval) {
1202 tcp->auxstr = "SIG_ERR"; break;
1204 tcp->auxstr = "SIG_DFL"; break;
1206 tcp->auxstr = "SIG_IGN"; break;
1210 return RVAL_HEX | RVAL_STR;
1219 if (entering(tcp)) {
1220 printsignal(tcp->u_arg[0]);
1226 #endif /* HAVE_SIGACTION */
1235 struct pt_regs regs;
1236 struct sigcontext_struct sc;
1238 if (entering(tcp)) {
1241 if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, (void *)®s) == -1)
1244 if (umove(tcp, regs.ARM_sp, &sc) < 0)
1248 tcp->u_arg[1] = sc.oldmask;
1251 long_to_sigset(tcp->u_arg[1], &sigm);
1252 tcp->u_rval = tcp->u_error = 0;
1253 if (tcp->u_arg[0] == 0)
1255 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1256 return RVAL_NONE | RVAL_STR;
1259 #elif defined(S390) || defined(S390X)
1261 struct sigcontext_struct sc;
1263 if (entering(tcp)) {
1265 if (upeek(tcp->pid,PT_GPR15,&usp)<0)
1267 if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0)
1270 memcpy(&tcp->u_arg[1],&sc.oldmask[0],sizeof(sigset_t));
1272 tcp->u_rval = tcp->u_error = 0;
1273 if (tcp->u_arg[0] == 0)
1275 tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1],0);
1276 return RVAL_NONE | RVAL_STR;
1282 struct sigcontext_struct sc;
1284 if (entering(tcp)) {
1286 if (upeek(tcp->pid, 4*UESP, &esp) < 0)
1288 if (umove(tcp, esp, &sc) < 0)
1291 tcp->u_arg[1] = sc.oldmask;
1295 long_to_sigset(tcp->u_arg[1], &sigm);
1296 tcp->u_rval = tcp->u_error = 0;
1297 if (tcp->u_arg[0] == 0)
1299 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1300 return RVAL_NONE | RVAL_STR;
1305 struct sigcontext sc;
1308 if (entering(tcp)) {
1309 /* offset of sigcontext in the kernel's sigframe structure: */
1310 # define SIGFRAME_SC_OFFSET 0x90
1312 if (upeek(tcp->pid, PT_R12, &sp) < 0)
1314 if (umove(tcp, sp + 16 + SIGFRAME_SC_OFFSET, &sc) < 0)
1317 memcpy(tcp->u_arg + 1, &sc.sc_mask, sizeof(sc.sc_mask));
1322 memcpy(&sigm, tcp->u_arg + 1, sizeof (sigm));
1323 tcp->u_rval = tcp->u_error = 0;
1324 if (tcp->u_arg[0] == 0)
1326 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1327 return RVAL_NONE | RVAL_STR;
1333 struct sigcontext_struct sc;
1335 if (entering(tcp)) {
1337 if (upeek(tcp->pid, sizeof(unsigned long)*PT_R1, &esp) < 0)
1339 if (umove(tcp, esp, &sc) < 0)
1342 tcp->u_arg[1] = sc.oldmask;
1346 long_to_sigset(tcp->u_arg[1], &sigm);
1347 tcp->u_rval = tcp->u_error = 0;
1348 if (tcp->u_arg[0] == 0)
1350 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1351 return RVAL_NONE | RVAL_STR;
1354 #else /* !POWERPC */
1357 struct sigcontext sc;
1359 if (entering(tcp)) {
1361 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
1363 if (umove(tcp, usp, &sc) < 0)
1366 tcp->u_arg[1] = sc.sc_mask;
1370 long_to_sigset(tcp->u_arg[1], &sigm);
1371 tcp->u_rval = tcp->u_error = 0;
1372 if (tcp->u_arg[0] == 0)
1374 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1375 return RVAL_NONE | RVAL_STR;
1381 struct sigcontext_struct sc;
1383 if (entering(tcp)) {
1385 if (upeek(tcp->pid, REG_FP, &fp) < 0)
1387 if (umove(tcp, fp, &sc) < 0)
1390 tcp->u_arg[1] = sc.sc_mask;
1394 long_to_sigset(tcp->u_arg[1], &sigm);
1395 tcp->u_rval = tcp->u_error = 0;
1396 if (tcp->u_arg[0] == 0)
1398 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1399 return RVAL_NONE | RVAL_STR;
1403 #if defined (SPARC) || defined (SPARC64)
1408 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
1409 perror("sigreturn: PTRACE_GETREGS ");
1415 if(umove(tcp, i1, &si) < 0) {
1416 perror("sigreturn: umove ");
1420 tcp->u_arg[1] = si.si_mask;
1423 long_to_sigset(tcp->u_arg[1], &sigm);
1424 tcp->u_rval = tcp->u_error = 0;
1425 if(tcp->u_arg[0] == 0)
1427 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1428 return RVAL_NONE | RVAL_STR;
1432 #if defined (LINUX_MIPSN32) || defined (LINUX_MIPSN64)
1433 /* This decodes rt_sigreturn. The 64-bit ABIs do not have
1440 if (upeek(tcp->pid, REG_SP, &sp) < 0)
1442 /* There are six words followed by a 128-byte siginfo. */
1443 sp = sp + 6 * 4 + 128;
1444 if (umove(tcp, sp, &uc) < 0)
1447 tcp->u_arg[1] = *(long *) &uc.uc_sigmask;
1450 long_to_sigset(tcp->u_arg[1], &sigm);
1451 tcp->u_rval = tcp->u_error = 0;
1452 if(tcp->u_arg[0] == 0)
1454 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1455 return RVAL_NONE | RVAL_STR;
1461 struct pt_regs regs;
1464 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
1465 perror("sigreturn: PTRACE_GETREGS ");
1471 if (umove(tcp, sp, &si) < 0)
1473 tcp->u_arg[1] = si.si_mask;
1476 long_to_sigset(tcp->u_arg[1], &sigm);
1477 tcp->u_rval = tcp->u_error = 0;
1478 if(tcp->u_arg[0] == 0)
1480 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1481 return RVAL_NONE | RVAL_STR;
1485 #warning No sys_sigreturn() for this architecture
1486 #warning (no problem, just a reminder :-)
1489 #endif /* LINUX_MIPSN32 || LINUX_MIPSN64 */
1490 #endif /* SPARC || SPARC64 */
1493 #endif /* !POWERPC */
1505 long_to_sigset(tcp->u_rval, &sigm);
1506 tcp->auxstr = sprintsigmask("mask ", &sigm, 0);
1508 return RVAL_HEX | RVAL_STR;
1515 if (entering(tcp)) {
1517 long_to_sigset(tcp->u_arg[2], &sigm);
1519 /* first two are not really arguments, but print them anyway */
1520 /* nevermind, they are an anachronism now, too bad... */
1521 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
1523 printsigmask(&sigm, 0);
1530 #if defined(SVR4) || defined(FREEBSD)
1538 if (entering(tcp)) {
1539 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
1542 printsigmask(&sigset, 0);
1547 static const struct xlat ucontext_flags[] = {
1548 { UC_SIGMASK, "UC_SIGMASK" },
1549 { UC_STACK, "UC_STACK" },
1550 { UC_CPU, "UC_CPU" },
1552 { UC_FPU, "UC_FPU" },
1555 { UC_INTR, "UC_INTR" },
1559 #endif /* !FREEBSD */
1560 #endif /* SVR4 || FREEBSD */
1562 #if defined SVR4 || defined LINUX || defined FREEBSD
1563 #if defined LINUX && !defined SS_ONSTACK
1564 #define SS_ONSTACK 1
1565 #define SS_DISABLE 2
1566 #if __GLIBC_MINOR__ == 0
1576 #define stack_t struct sigaltstack
1579 static const struct xlat sigaltstack_flags[] = {
1580 { SS_ONSTACK, "SS_ONSTACK" },
1581 { SS_DISABLE, "SS_DISABLE" },
1588 printcontext(tcp, ucp)
1594 tprintf("uc_flags=");
1595 printflags(ucontext_flags, ucp->uc_flags, "UC_???");
1596 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
1598 tprintf("uc_sigmask=");
1599 printsigmask(&ucp->uc_sigmask, 0);
1601 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
1602 (unsigned long) ucp->uc_stack.ss_sp,
1603 ucp->uc_stack.ss_size);
1604 printflags(sigaltstack_flags, ucp->uc_stack.ss_flags, "SS_???");
1618 tprintf("%#lx", tcp->u_arg[0]);
1619 else if (!tcp->u_arg[0])
1621 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1624 printcontext(tcp, &uc);
1635 if (entering(tcp)) {
1638 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1641 printcontext(tcp, &uc);
1644 tcp->u_rval = tcp->u_error = 0;
1645 if (tcp->u_arg[0] == 0)
1654 #if defined(LINUX) || defined(FREEBSD)
1657 print_stack_t(tcp, addr)
1662 if (umove(tcp, addr, &ss) < 0)
1664 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
1665 printflags(sigaltstack_flags, ss.ss_flags, "SS_???");
1666 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
1671 sys_sigaltstack(tcp)
1674 if (entering(tcp)) {
1675 if (tcp->u_arg[0] == 0)
1677 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
1682 if (tcp->u_arg[1] == 0)
1684 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
1691 #ifdef HAVE_SIGACTION
1694 sys_sigprocmask(tcp)
1698 if (entering(tcp)) {
1699 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1701 printsigmask(tcp->u_arg[1], 0);
1703 else if (!syserror(tcp)) {
1704 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0);
1705 return RVAL_HEX | RVAL_STR;
1708 if (entering(tcp)) {
1710 if (tcp->u_arg[0] == 0)
1714 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1716 print_sigset(tcp, tcp->u_arg[1], 0);
1722 else if (syserror(tcp))
1723 tprintf("%#lx", tcp->u_arg[2]);
1725 print_sigset(tcp, tcp->u_arg[2], 0);
1731 #endif /* HAVE_SIGACTION */
1737 if (entering(tcp)) {
1738 tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1]));
1743 #if defined(FREEBSD) || defined(SUNOS4)
1748 return sys_kill(tcp);
1750 #endif /* FREEBSD || SUNOS4 */
1757 if (entering(tcp)) {
1758 tprintf("%ld, %ld, %s",
1759 tcp->u_arg[0], tcp->u_arg[1], signame(tcp->u_arg[2]));
1773 tprintf("%#lx", tcp->u_arg[0]);
1774 else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1777 printsigmask(&sigset, 0);
1783 int sys_sigwait(tcp)
1788 if (entering(tcp)) {
1789 if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1792 printsigmask(&sigset, 0);
1795 if (!syserror(tcp)) {
1796 tcp->auxstr = signalent[tcp->u_rval];
1797 return RVAL_DECIMAL | RVAL_STR;
1807 sys_rt_sigprocmask(tcp)
1812 /* Note: arg[3] is the length of the sigset. */
1813 if (entering(tcp)) {
1814 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1818 else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0)
1819 tprintf("%#lx, ", tcp->u_arg[1]);
1821 printsigmask(&sigset, 1);
1829 else if (syserror(tcp))
1830 tprintf("%#lx", tcp->u_arg[2]);
1831 else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0)
1834 printsigmask(&sigset, 1);
1835 tprintf(", %lu", tcp->u_arg[3]);
1841 /* Structure describing the action to be taken when a signal arrives. */
1842 struct new_sigaction
1846 __sighandler_t __sa_handler;
1847 void (*__sa_sigaction) (int, siginfo_t *, void *);
1849 __sigaction_handler;
1850 unsigned long sa_flags;
1851 void (*sa_restorer) (void);
1852 unsigned long int sa_mask[2];
1857 sys_rt_sigaction(tcp)
1860 struct new_sigaction sa;
1864 if (entering(tcp)) {
1865 printsignal(tcp->u_arg[0]);
1867 addr = tcp->u_arg[1];
1869 addr = tcp->u_arg[2];
1872 else if (!verbose(tcp))
1873 tprintf("%#lx", addr);
1874 else if (umove(tcp, addr, &sa) < 0)
1877 switch ((long) sa.__sigaction_handler.__sa_handler) {
1878 case (long) SIG_ERR:
1879 tprintf("{SIG_ERR}");
1881 case (long) SIG_DFL:
1882 tprintf("{SIG_DFL}");
1884 case (long) SIG_IGN:
1885 tprintf("{SIG_IGN}");
1889 (long) sa.__sigaction_handler.__sa_handler);
1890 sigemptyset(&sigset);
1892 if (tcp->u_arg[4] <= sizeof(sigset))
1893 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
1895 if (tcp->u_arg[3] <= sizeof(sigset))
1896 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
1899 memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
1900 printsigmask(&sigset, 1);
1902 printflags(sigact_flags, sa.sa_flags, "SA_???");
1904 if (sa.sa_flags & SA_RESTORER)
1905 tprintf(", %p", sa.sa_restorer);
1914 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
1915 #elif defined(ALPHA)
1916 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
1918 tprintf(", %lu", addr = tcp->u_arg[3]);
1924 sys_rt_sigpending(tcp)
1931 tprintf("%#lx", tcp->u_arg[0]);
1932 else if (copy_sigset_len(tcp, tcp->u_arg[0],
1933 &sigset, tcp->u_arg[1]) < 0)
1936 printsigmask(&sigset, 1);
1941 sys_rt_sigsuspend(tcp)
1944 if (entering(tcp)) {
1946 if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0)
1949 printsigmask(&sigm, 1);
1954 sys_rt_sigqueueinfo(tcp)
1957 if (entering(tcp)) {
1959 tprintf("%lu, ", tcp->u_arg[0]);
1960 printsignal(tcp->u_arg[1]);
1962 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1963 tprintf("%#lx", tcp->u_arg[2]);
1965 printsiginfo(&si, verbose (tcp));
1970 int sys_rt_sigtimedwait(tcp)
1973 if (entering(tcp)) {
1976 if (copy_sigset_len(tcp, tcp->u_arg[0],
1977 &sigset, tcp->u_arg[3]) < 0)
1980 printsigmask(&sigset, 1);
1985 tprintf("%#lx", tcp->u_arg[0]);
1988 if (umove(tcp, tcp->u_arg[1], &si) < 0)
1989 tprintf("%#lx", tcp->u_arg[1]);
1991 printsiginfo(&si, verbose (tcp));
1993 tprintf(", %#lx", tcp->u_arg[2]);
1994 tprintf(", %d", (int) tcp->u_arg[3]);
2001 sys_restart_syscall(tcp)
2005 tprintf("<... resuming interrupted call ...>");
2013 if (entering(tcp)) {
2014 tprintf("%ld, ", tcp->u_arg[0]);
2015 print_sigset(tcp, tcp->u_arg[1], 1);
2016 tprintf("%lu", tcp->u_arg[2]);