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_NODEFER, "SA_NODEFER" },
221 #if defined SA_NOMASK && SA_NODEFER != SA_NOMASK
222 { SA_NOMASK, "SA_NOMASK" },
225 { SA_RESETHAND, "SA_RESETHAND" },
227 #if defined SA_ONESHOT && SA_ONESHOT != SA_RESETHAND
228 { SA_ONESHOT, "SA_ONESHOT" },
231 { SA_SIGINFO, "SA_SIGINFO" },
234 { SA_RESETHAND, "SA_RESETHAND" },
237 { SA_ONSTACK, "SA_ONSTACK" },
240 { SA_NODEFER, "SA_NODEFER" },
243 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
246 { SA_NOCLDWAIT, "SA_NOCLDWAIT" },
249 { _SA_BSDCALL, "_SA_BSDCALL" },
254 static const struct xlat sigprocmaskcmds[] = {
255 { SIG_BLOCK, "SIG_BLOCK" },
256 { SIG_UNBLOCK, "SIG_UNBLOCK" },
257 { SIG_SETMASK, "SIG_SETMASK" },
259 { SIG_SETMASK32,"SIG_SETMASK32" },
264 #endif /* HAVE_SIGACTION */
266 /* Anonymous realtime signals. */
267 /* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
268 constant. This is what we want. Otherwise, just use SIGRTMIN. */
271 #define __SIGRTMIN SIGRTMIN
272 #define __SIGRTMAX SIGRTMAX /* likewise */
281 if (sig >= 0 && sig < nsignals) {
282 return signalent[sig];
284 } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) {
285 sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN));
287 #endif /* SIGRTMIN */
289 sprintf(buf, "%d", sig);
306 copy_sigset_len(tcp, addr, s, len)
312 if (len > sizeof(*s))
315 if (umoven(tcp, addr, len, (char *)s) < 0)
321 /* Original sigset is unsigned long */
322 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long))
324 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t))
328 sprintsigmask(const char *str, sigset_t *mask, int rt)
329 /* set might include realtime sigs */
334 static char outstr[8 * sizeof(sigset_t) * 8];
337 s = outstr + strlen(outstr);
342 maxsigs = __SIGRTMAX; /* instead */
344 for (i = 1; i < maxsigs; i++) {
345 if (sigismember(mask, i) == 1)
348 if (nsigs >= nsignals * 2 / 3) {
350 for (i = 1; i < maxsigs; i++) {
351 switch (sigismember(mask, i)) {
363 for (i = 1; i < maxsigs; i++) {
364 if (sigismember(mask, i) == 1) {
365 /* real-time signals on solaris don't have
369 sprintf(s, format, signalent[i] + 3);
372 else if (i >= __SIGRTMIN && i <= __SIGRTMAX) {
374 sprintf(tsig, "RT_%u", i - __SIGRTMIN);
375 sprintf(s, format, tsig);
377 #endif /* SIGRTMIN */
380 sprintf(tsig, "%u", i);
381 sprintf(s, format, tsig);
393 printsigmask(mask, rt)
397 tprintf("%s", sprintsigmask("", mask, rt));
404 tprintf(signame(nr));
408 print_sigset(struct tcb *tcp, long addr, int rt)
414 else if (copy_sigset(tcp, addr, &ss) < 0)
415 tprintf("%#lx", addr);
417 printsigmask(&ss, rt);
423 #define ILL_ILLOPC 1 /* illegal opcode */
424 #define ILL_ILLOPN 2 /* illegal operand */
425 #define ILL_ILLADR 3 /* illegal addressing mode */
426 #define ILL_ILLTRP 4 /* illegal trap */
427 #define ILL_PRVOPC 5 /* privileged opcode */
428 #define ILL_PRVREG 6 /* privileged register */
429 #define ILL_COPROC 7 /* coprocessor error */
430 #define ILL_BADSTK 8 /* internal stack error */
431 #define FPE_INTDIV 1 /* integer divide by zero */
432 #define FPE_INTOVF 2 /* integer overflow */
433 #define FPE_FLTDIV 3 /* floating point divide by zero */
434 #define FPE_FLTOVF 4 /* floating point overflow */
435 #define FPE_FLTUND 5 /* floating point underflow */
436 #define FPE_FLTRES 6 /* floating point inexact result */
437 #define FPE_FLTINV 7 /* floating point invalid operation */
438 #define FPE_FLTSUB 8 /* subscript out of range */
439 #define SEGV_MAPERR 1 /* address not mapped to object */
440 #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
441 #define BUS_ADRALN 1 /* invalid address alignment */
442 #define BUS_ADRERR 2 /* non-existant physical address */
443 #define BUS_OBJERR 3 /* object specific hardware error */
444 #define TRAP_BRKPT 1 /* process breakpoint */
445 #define TRAP_TRACE 2 /* process trace trap */
446 #define CLD_EXITED 1 /* child has exited */
447 #define CLD_KILLED 2 /* child was killed */
448 #define CLD_DUMPED 3 /* child terminated abnormally */
449 #define CLD_TRAPPED 4 /* traced child has trapped */
450 #define CLD_STOPPED 5 /* child has stopped */
451 #define CLD_CONTINUED 6 /* stopped child has continued */
452 #define POLL_IN 1 /* data input available */
453 #define POLL_OUT 2 /* output buffers available */
454 #define POLL_MSG 3 /* input message available */
455 #define POLL_ERR 4 /* i/o error */
456 #define POLL_PRI 5 /* high priority input available */
457 #define POLL_HUP 6 /* device disconnected */
458 #define SI_USER 0 /* sent by kill, sigsend, raise */
459 #define SI_QUEUE -1 /* sent by sigqueue */
460 #define SI_TIMER -2 /* sent by timer expiration */
461 #define SI_MESGQ -3 /* sent by real time mesq state change */
462 #define SI_ASYNCIO -4 /* sent by AIO completion */
463 #define SI_SIGIO -5 /* Sent by SIGIO */
464 #define SI_TKILL -6 /* Sent by tkill */
467 #if __GLIBC_MINOR__ < 1
468 /* Type for data associated with a signal. */
475 # define __SI_MAX_SIZE 128
476 # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
478 typedef struct siginfo
480 int si_signo; /* Signal number. */
481 int si_errno; /* If non-zero, an errno value associated with
482 this signal, as defined in <errno.h>. */
483 int si_code; /* Signal code. */
487 int _pad[__SI_PAD_SIZE];
492 __pid_t si_pid; /* Sending process ID. */
493 __uid_t si_uid; /* Real user ID of sending process. */
496 /* POSIX.1b timers. */
499 unsigned int _timer1;
500 unsigned int _timer2;
503 /* POSIX.1b signals. */
506 __pid_t si_pid; /* Sending process ID. */
507 __uid_t si_uid; /* Real user ID of sending process. */
508 sigval_t si_sigval; /* Signal value. */
514 __pid_t si_pid; /* Which child. */
515 int si_status; /* Exit value or signal. */
520 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
523 void *si_addr; /* Faulting insn/memory ref. */
529 int si_band; /* Band event for SIGPOLL. */
535 #define si_pid _sifields._kill.si_pid
536 #define si_uid _sifields._kill.si_uid
537 #define si_status _sifields._sigchld.si_status
538 #define si_utime _sifields._sigchld.si_utime
539 #define si_stime _sifields._sigchld.si_stime
540 #define si_value _sifields._rt.si_sigval
541 #define si_int _sifields._rt.si_sigval.sival_int
542 #define si_ptr _sifields._rt.si_sigval.sival_ptr
543 #define si_addr _sifields._sigfault.si_addr
544 #define si_band _sifields._sigpoll.si_band
545 #define si_fd _sifields._sigpoll.si_fd
551 #if defined (SVR4) || defined (LINUX)
553 static const struct xlat siginfo_codes[] = {
555 { SI_NOINFO, "SI_NOINFO" },
558 { SI_USER, "SI_USER" },
561 { SI_LWP, "SI_LWP" },
564 { SI_QUEUE, "SI_QUEUE" },
567 { SI_TIMER, "SI_TIMER" },
570 { SI_ASYNCIO, "SI_ASYNCIO" },
573 { SI_MESGQ, "SI_MESGQ" },
576 { SI_SIGIO, "SI_SIGIO" },
579 { SI_TKILL, "SI_TKILL" },
584 static const struct xlat sigill_codes[] = {
585 { ILL_ILLOPC, "ILL_ILLOPC" },
586 { ILL_ILLOPN, "ILL_ILLOPN" },
587 { ILL_ILLADR, "ILL_ILLADR" },
588 { ILL_ILLTRP, "ILL_ILLTRP" },
589 { ILL_PRVOPC, "ILL_PRVOPC" },
590 { ILL_PRVREG, "ILL_PRVREG" },
591 { ILL_COPROC, "ILL_COPROC" },
592 { ILL_BADSTK, "ILL_BADSTK" },
596 static const struct xlat sigfpe_codes[] = {
597 { FPE_INTDIV, "FPE_INTDIV" },
598 { FPE_INTOVF, "FPE_INTOVF" },
599 { FPE_FLTDIV, "FPE_FLTDIV" },
600 { FPE_FLTOVF, "FPE_FLTOVF" },
601 { FPE_FLTUND, "FPE_FLTUND" },
602 { FPE_FLTRES, "FPE_FLTRES" },
603 { FPE_FLTINV, "FPE_FLTINV" },
604 { FPE_FLTSUB, "FPE_FLTSUB" },
608 static const struct xlat sigtrap_codes[] = {
609 { TRAP_BRKPT, "TRAP_BRKPT" },
610 { TRAP_TRACE, "TRAP_TRACE" },
614 static const struct xlat sigchld_codes[] = {
615 { CLD_EXITED, "CLD_EXITED" },
616 { CLD_KILLED, "CLD_KILLED" },
617 { CLD_DUMPED, "CLD_DUMPED" },
618 { CLD_TRAPPED, "CLD_TRAPPED" },
619 { CLD_STOPPED, "CLD_STOPPED" },
620 { CLD_CONTINUED,"CLD_CONTINUED" },
624 static const struct xlat sigpoll_codes[] = {
625 { POLL_IN, "POLL_IN" },
626 { POLL_OUT, "POLL_OUT" },
627 { POLL_MSG, "POLL_MSG" },
628 { POLL_ERR, "POLL_ERR" },
629 { POLL_PRI, "POLL_PRI" },
630 { POLL_HUP, "POLL_HUP" },
634 static const struct xlat sigprof_codes[] = {
636 { PROF_SIG, "PROF_SIG" },
642 static const struct xlat sigemt_codes[] = {
644 { EMT_TAGOVF, "EMT_TAGOVF" },
650 static const struct xlat sigsegv_codes[] = {
651 { SEGV_MAPERR, "SEGV_MAPERR" },
652 { SEGV_ACCERR, "SEGV_ACCERR" },
656 static const struct xlat sigbus_codes[] = {
657 { BUS_ADRALN, "BUS_ADRALN" },
658 { BUS_ADRERR, "BUS_ADRERR" },
659 { BUS_OBJERR, "BUS_OBJERR" },
664 printsiginfo(sip, verbose)
670 if (sip->si_signo == 0) {
674 tprintf("{si_signo=");
675 printsignal(sip->si_signo);
676 code = xlookup(siginfo_codes, sip->si_code);
678 switch (sip->si_signo) {
680 code = xlookup(sigtrap_codes, sip->si_code);
683 code = xlookup(sigchld_codes, sip->si_code);
686 code = xlookup(sigpoll_codes, sip->si_code);
689 code = xlookup(sigprof_codes, sip->si_code);
692 code = xlookup(sigill_codes, sip->si_code);
696 code = xlookup(sigemt_codes, sip->si_code);
700 code = xlookup(sigfpe_codes, sip->si_code);
703 code = xlookup(sigsegv_codes, sip->si_code);
706 code = xlookup(sigbus_codes, sip->si_code);
711 tprintf(", si_code=%s", code);
713 tprintf(", si_code=%#x", sip->si_code);
715 if (sip->si_code != SI_NOINFO)
719 if (sip->si_errno < 0 || sip->si_errno >= nerrnos)
720 tprintf(", si_errno=%d", sip->si_errno);
722 tprintf(", si_errno=%s",
723 errnoent[sip->si_errno]);
726 if (SI_FROMUSER(sip)) {
727 tprintf(", si_pid=%ld, si_uid=%ld",
728 sip->si_pid, sip->si_uid);
730 switch (sip->si_code) {
734 #endif /* SI_QUEUE */
738 #endif /* SI_MESGQ */
739 tprintf(", si_value=%d",
740 sip->si_value.sival_int);
743 #endif /* SI_QUEUE */
746 #endif /* SI_FROMUSER */
748 switch (sip->si_signo) {
750 tprintf(", si_pid=%ld, si_status=",
752 if (sip->si_code == CLD_EXITED)
753 tprintf("%d", sip->si_status);
755 printsignal(sip->si_status);
760 tprintf(", si_utime=%lu, si_stime=%lu",
765 case SIGILL: case SIGFPE:
766 case SIGSEGV: case SIGBUS:
767 tprintf(", si_addr=%#lx",
768 (unsigned long) sip->si_addr);
771 switch (sip->si_code) {
772 case POLL_IN: case POLL_OUT: case POLL_MSG:
773 tprintf(", si_band=%ld",
774 (long) sip->si_band);
780 tprintf(", si_pid=%lu, si_uid=%lu, ",
781 (unsigned long) sip->si_pid,
782 (unsigned long) sip->si_uid);
786 tprintf("si_value={int=%u, ptr=%#lx}",
788 (unsigned long) sip->si_ptr);
798 #endif /* SVR4 || LINUX */
803 parse_sigset_t (const char *str, sigset_t *set)
811 p = strchr(str, '\n');
813 p = strchr(str, '\0');
814 for (i = 0; p-- > str; i += 4) {
815 if (*p >= '0' && *p <= '9')
817 else if (*p >= 'a' && *p <= 'f')
818 digit = *p - 'a' + 10;
819 else if (*p >= 'A' && *p <= 'F')
820 digit = *p - 'A' + 10;
824 sigaddset(set, i + 1);
826 sigaddset(set, i + 2);
828 sigaddset(set, i + 3);
830 sigaddset(set, i + 4);
837 * Check process TCP for the disposition of signal SIG.
838 * Return 1 if the process would somehow manage to survive signal SIG,
839 * else return 0. This routine will never be called with SIGKILL.
842 sigishandled(tcp, sig)
852 sigset_t ignored, caught;
856 * Since procfs doesn't interfere with wait I think it is safe
857 * to punt on this question. If not, the information is there.
869 #if defined(SIGURG) && SIGURG != SIGIO
873 /* Gloria Gaynor says ... */
881 /* This is incredibly costly but it's worth it. */
882 /* NOTE: LinuxThreads internally uses SIGRTMIN, SIGRTMIN + 1 and
883 SIGRTMIN + 2, so we can't use the obsolete /proc/%d/stat which
884 doesn't handle real-time signals). */
885 sprintf(sname, "/proc/%d/status", tcp->pid);
886 if ((sfd = open(sname, O_RDONLY)) == -1) {
890 i = read(sfd, buf, sizeof(buf));
894 * Skip the extraneous fields. We need to skip
895 * command name has any spaces in it. So be it.
897 s = strstr(buf, "SigIgn:\t");
900 fprintf(stderr, "/proc/pid/status format error\n");
903 parse_sigset_t(s + 8, &ignored);
905 s = strstr(buf, "SigCgt:\t");
908 fprintf(stderr, "/proc/pid/status format error\n");
911 parse_sigset_t(s + 8, &caught);
914 fprintf(stderr, "sigs: %016qx %016qx (sig=%d)\n",
915 *(long long *) &ignored, *(long long *) &caught, sig);
917 if (sigismember(&ignored, sig) || sigismember(&caught, sig))
924 if (upeek(tcp->pid, uoff(u_signal[0]) + sig*sizeof(u_signal),
925 (long *) &u_signal) < 0) {
928 if (u_signal != SIG_DFL)
935 #if defined(SUNOS4) || defined(FREEBSD)
945 printsignal(tcp->u_arg[0]);
947 addr = tcp->u_arg[1];
949 addr = tcp->u_arg[2];
953 else if (!verbose(tcp))
954 tprintf("%#lx", addr);
955 else if (umove(tcp, addr, &sv) < 0)
958 switch ((int) sv.sv_handler) {
960 tprintf("{SIG_ERR}");
963 tprintf("{SIG_DFL}");
966 if (tcp->u_arg[0] == SIGTRAP) {
967 tcp->flags |= TCB_SIGTRAPPED;
968 kill(tcp->pid, SIGSTOP);
970 tprintf("{SIG_IGN}");
973 if (tcp->u_arg[0] == SIGTRAP) {
974 tcp->flags |= TCB_SIGTRAPPED;
975 kill(tcp->pid, SIGSTOP);
980 if (tcp->u_arg[0] == SIGTRAP) {
981 tcp->flags |= TCB_SIGTRAPPED;
982 kill(tcp->pid, SIGSTOP);
984 tprintf("{%#lx, ", (unsigned long) sv.sv_handler);
985 printsigmask(&sv.sv_mask, 0);
987 printflags(sigvec_flags, sv.sv_flags, "SV_???");
1000 if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */
1002 long_to_sigset(tcp->u_arg[0], &sigm);
1003 printsigmask(&sigm, 0);
1016 addr = tcp->u_arg[0];
1018 addr = tcp->u_arg[1];
1021 else if (umove(tcp, addr, &ss) < 0)
1022 tprintf("%#lx", addr);
1024 tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp);
1025 tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO");
1039 #endif /* SUNOS4 || FREEBSD */
1047 if (entering(tcp)) {
1049 long_to_sigset(tcp->u_arg[0], &sigm);
1050 printsigmask(&sigm, 0);
1052 if ((tcp->u_arg[0] & sigmask(SIGTRAP))) {
1053 /* Mark attempt to block SIGTRAP */
1054 tcp->flags |= TCB_SIGTRAPPED;
1055 /* Send unblockable signal */
1056 kill(tcp->pid, SIGSTOP);
1058 #endif /* !USE_PROCFS */
1060 else if (!syserror(tcp)) {
1062 long_to_sigset(tcp->u_rval, &sigm);
1063 tcp->auxstr = sprintsigmask("old mask ", &sigm, 0);
1065 return RVAL_HEX | RVAL_STR;
1070 #if defined(SUNOS4) || defined(FREEBSD)
1075 return sys_sigsetmask(tcp);
1077 #endif /* SUNOS4 || FREEBSD */
1081 #ifdef HAVE_SIGACTION
1084 struct old_sigaction {
1085 __sighandler_t __sa_handler;
1086 unsigned long sa_mask;
1087 unsigned long sa_flags;
1088 void (*sa_restorer)(void);
1090 #define SA_HANDLER __sa_handler
1094 #define SA_HANDLER sa_handler
1104 struct old_sigaction sa;
1106 struct sigaction sa;
1110 if (entering(tcp)) {
1111 printsignal(tcp->u_arg[0]);
1113 addr = tcp->u_arg[1];
1115 addr = tcp->u_arg[2];
1118 else if (!verbose(tcp))
1119 tprintf("%#lx", addr);
1120 else if (umove(tcp, addr, &sa) < 0)
1123 switch ((long) sa.SA_HANDLER) {
1124 case (long) SIG_ERR:
1125 tprintf("{SIG_ERR}");
1127 case (long) SIG_DFL:
1128 tprintf("{SIG_DFL}");
1130 case (long) SIG_IGN:
1132 if (tcp->u_arg[0] == SIGTRAP) {
1133 tcp->flags |= TCB_SIGTRAPPED;
1134 kill(tcp->pid, SIGSTOP);
1136 #endif /* !USE_PROCFS */
1137 tprintf("{SIG_IGN}");
1141 if (tcp->u_arg[0] == SIGTRAP) {
1142 tcp->flags |= TCB_SIGTRAPPED;
1143 kill(tcp->pid, SIGSTOP);
1145 #endif /* !USE_PROCFS */
1146 tprintf("{%#lx, ", (long) sa.SA_HANDLER);
1148 printsigmask (&sa.sa_mask, 0);
1150 long_to_sigset(sa.sa_mask, &sigset);
1151 printsigmask(&sigset, 0);
1154 printflags(sigact_flags, sa.sa_flags, "SA_???");
1156 if (sa.sa_flags & SA_RESTORER)
1157 tprintf(", %p", sa.sa_restorer);
1166 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
1175 if (entering(tcp)) {
1176 printsignal(tcp->u_arg[0]);
1178 switch (tcp->u_arg[1]) {
1187 if (tcp->u_arg[0] == SIGTRAP) {
1188 tcp->flags |= TCB_SIGTRAPPED;
1189 kill(tcp->pid, SIGSTOP);
1191 #endif /* !USE_PROCFS */
1196 if (tcp->u_arg[0] == SIGTRAP) {
1197 tcp->flags |= TCB_SIGTRAPPED;
1198 kill(tcp->pid, SIGSTOP);
1200 #endif /* !USE_PROCFS */
1201 tprintf("%#lx", tcp->u_arg[1]);
1206 switch (tcp->u_rval) {
1208 tcp->auxstr = "SIG_ERR"; break;
1210 tcp->auxstr = "SIG_DFL"; break;
1212 tcp->auxstr = "SIG_IGN"; break;
1216 return RVAL_HEX | RVAL_STR;
1225 if (entering(tcp)) {
1226 printsignal(tcp->u_arg[0]);
1232 #endif /* HAVE_SIGACTION */
1241 struct pt_regs regs;
1242 struct sigcontext_struct sc;
1244 if (entering(tcp)) {
1247 if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, (void *)®s) == -1)
1250 if (umove(tcp, regs.ARM_sp, &sc) < 0)
1254 tcp->u_arg[1] = sc.oldmask;
1257 long_to_sigset(tcp->u_arg[1], &sigm);
1258 tcp->u_rval = tcp->u_error = 0;
1259 if (tcp->u_arg[0] == 0)
1261 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1262 return RVAL_NONE | RVAL_STR;
1265 #elif defined(S390) || defined(S390X)
1267 struct sigcontext_struct sc;
1269 if (entering(tcp)) {
1271 if (upeek(tcp->pid,PT_GPR15,&usp)<0)
1273 if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0)
1276 memcpy(&tcp->u_arg[1],&sc.oldmask[0],sizeof(sigset_t));
1278 tcp->u_rval = tcp->u_error = 0;
1279 if (tcp->u_arg[0] == 0)
1281 tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1],0);
1282 return RVAL_NONE | RVAL_STR;
1288 struct sigcontext_struct sc;
1290 if (entering(tcp)) {
1292 if (upeek(tcp->pid, 4*UESP, &esp) < 0)
1294 if (umove(tcp, esp, &sc) < 0)
1297 tcp->u_arg[1] = sc.oldmask;
1301 long_to_sigset(tcp->u_arg[1], &sigm);
1302 tcp->u_rval = tcp->u_error = 0;
1303 if (tcp->u_arg[0] == 0)
1305 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1306 return RVAL_NONE | RVAL_STR;
1311 struct sigcontext sc;
1314 if (entering(tcp)) {
1315 /* offset of sigcontext in the kernel's sigframe structure: */
1316 # define SIGFRAME_SC_OFFSET 0x90
1318 if (upeek(tcp->pid, PT_R12, &sp) < 0)
1320 if (umove(tcp, sp + 16 + SIGFRAME_SC_OFFSET, &sc) < 0)
1323 memcpy(tcp->u_arg + 1, &sc.sc_mask, sizeof(sc.sc_mask));
1328 memcpy(&sigm, tcp->u_arg + 1, sizeof (sigm));
1329 tcp->u_rval = tcp->u_error = 0;
1330 if (tcp->u_arg[0] == 0)
1332 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1333 return RVAL_NONE | RVAL_STR;
1339 struct sigcontext_struct sc;
1341 if (entering(tcp)) {
1343 if (upeek(tcp->pid, sizeof(unsigned long)*PT_R1, &esp) < 0)
1345 if (umove(tcp, esp, &sc) < 0)
1348 tcp->u_arg[1] = sc.oldmask;
1352 long_to_sigset(tcp->u_arg[1], &sigm);
1353 tcp->u_rval = tcp->u_error = 0;
1354 if (tcp->u_arg[0] == 0)
1356 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1357 return RVAL_NONE | RVAL_STR;
1360 #else /* !POWERPC */
1363 struct sigcontext sc;
1365 if (entering(tcp)) {
1367 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
1369 if (umove(tcp, usp, &sc) < 0)
1372 tcp->u_arg[1] = sc.sc_mask;
1376 long_to_sigset(tcp->u_arg[1], &sigm);
1377 tcp->u_rval = tcp->u_error = 0;
1378 if (tcp->u_arg[0] == 0)
1380 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1381 return RVAL_NONE | RVAL_STR;
1387 struct sigcontext_struct sc;
1389 if (entering(tcp)) {
1391 if (upeek(tcp->pid, REG_FP, &fp) < 0)
1393 if (umove(tcp, fp, &sc) < 0)
1396 tcp->u_arg[1] = sc.sc_mask;
1400 long_to_sigset(tcp->u_arg[1], &sigm);
1401 tcp->u_rval = tcp->u_error = 0;
1402 if (tcp->u_arg[0] == 0)
1404 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1405 return RVAL_NONE | RVAL_STR;
1409 #if defined (SPARC) || defined (SPARC64)
1414 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
1415 perror("sigreturn: PTRACE_GETREGS ");
1421 if(umove(tcp, i1, &si) < 0) {
1422 perror("sigreturn: umove ");
1426 tcp->u_arg[1] = si.si_mask;
1429 long_to_sigset(tcp->u_arg[1], &sigm);
1430 tcp->u_rval = tcp->u_error = 0;
1431 if(tcp->u_arg[0] == 0)
1433 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1434 return RVAL_NONE | RVAL_STR;
1438 #if defined (LINUX_MIPSN32) || defined (LINUX_MIPSN64)
1439 /* This decodes rt_sigreturn. The 64-bit ABIs do not have
1446 if (upeek(tcp->pid, REG_SP, &sp) < 0)
1448 /* There are six words followed by a 128-byte siginfo. */
1449 sp = sp + 6 * 4 + 128;
1450 if (umove(tcp, sp, &uc) < 0)
1453 tcp->u_arg[1] = *(long *) &uc.uc_sigmask;
1456 long_to_sigset(tcp->u_arg[1], &sigm);
1457 tcp->u_rval = tcp->u_error = 0;
1458 if(tcp->u_arg[0] == 0)
1460 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1461 return RVAL_NONE | RVAL_STR;
1467 struct pt_regs regs;
1470 if(ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
1471 perror("sigreturn: PTRACE_GETREGS ");
1477 if (umove(tcp, sp, &si) < 0)
1479 tcp->u_arg[1] = si.si_mask;
1482 long_to_sigset(tcp->u_arg[1], &sigm);
1483 tcp->u_rval = tcp->u_error = 0;
1484 if(tcp->u_arg[0] == 0)
1486 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1487 return RVAL_NONE | RVAL_STR;
1491 #warning No sys_sigreturn() for this architecture
1492 #warning (no problem, just a reminder :-)
1495 #endif /* LINUX_MIPSN32 || LINUX_MIPSN64 */
1496 #endif /* SPARC || SPARC64 */
1499 #endif /* !POWERPC */
1511 long_to_sigset(tcp->u_rval, &sigm);
1512 tcp->auxstr = sprintsigmask("mask ", &sigm, 0);
1514 return RVAL_HEX | RVAL_STR;
1521 if (entering(tcp)) {
1523 long_to_sigset(tcp->u_arg[2], &sigm);
1525 /* first two are not really arguments, but print them anyway */
1526 /* nevermind, they are an anachronism now, too bad... */
1527 tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
1529 printsigmask(&sigm, 0);
1536 #if defined(SVR4) || defined(FREEBSD)
1544 if (entering(tcp)) {
1545 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
1548 printsigmask(&sigset, 0);
1553 static const struct xlat ucontext_flags[] = {
1554 { UC_SIGMASK, "UC_SIGMASK" },
1555 { UC_STACK, "UC_STACK" },
1556 { UC_CPU, "UC_CPU" },
1558 { UC_FPU, "UC_FPU" },
1561 { UC_INTR, "UC_INTR" },
1565 #endif /* !FREEBSD */
1566 #endif /* SVR4 || FREEBSD */
1568 #if defined SVR4 || defined LINUX || defined FREEBSD
1569 #if defined LINUX && !defined SS_ONSTACK
1570 #define SS_ONSTACK 1
1571 #define SS_DISABLE 2
1572 #if __GLIBC_MINOR__ == 0
1582 #define stack_t struct sigaltstack
1585 static const struct xlat sigaltstack_flags[] = {
1586 { SS_ONSTACK, "SS_ONSTACK" },
1587 { SS_DISABLE, "SS_DISABLE" },
1594 printcontext(tcp, ucp)
1600 tprintf("uc_flags=");
1601 printflags(ucontext_flags, ucp->uc_flags, "UC_???");
1602 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
1604 tprintf("uc_sigmask=");
1605 printsigmask(&ucp->uc_sigmask, 0);
1607 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
1608 (unsigned long) ucp->uc_stack.ss_sp,
1609 ucp->uc_stack.ss_size);
1610 printflags(sigaltstack_flags, ucp->uc_stack.ss_flags, "SS_???");
1624 tprintf("%#lx", tcp->u_arg[0]);
1625 else if (!tcp->u_arg[0])
1627 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1630 printcontext(tcp, &uc);
1641 if (entering(tcp)) {
1644 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1647 printcontext(tcp, &uc);
1650 tcp->u_rval = tcp->u_error = 0;
1651 if (tcp->u_arg[0] == 0)
1660 #if defined(LINUX) || defined(FREEBSD)
1663 print_stack_t(tcp, addr)
1668 if (umove(tcp, addr, &ss) < 0)
1670 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
1671 printflags(sigaltstack_flags, ss.ss_flags, "SS_???");
1672 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
1677 sys_sigaltstack(tcp)
1680 if (entering(tcp)) {
1681 if (tcp->u_arg[0] == 0)
1683 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
1688 if (tcp->u_arg[1] == 0)
1690 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
1697 #ifdef HAVE_SIGACTION
1700 sys_sigprocmask(tcp)
1704 if (entering(tcp)) {
1705 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1707 printsigmask(tcp->u_arg[1], 0);
1709 else if (!syserror(tcp)) {
1710 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0);
1711 return RVAL_HEX | RVAL_STR;
1714 if (entering(tcp)) {
1716 if (tcp->u_arg[0] == 0)
1720 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1722 print_sigset(tcp, tcp->u_arg[1], 0);
1728 else if (syserror(tcp))
1729 tprintf("%#lx", tcp->u_arg[2]);
1731 print_sigset(tcp, tcp->u_arg[2], 0);
1737 #endif /* HAVE_SIGACTION */
1743 if (entering(tcp)) {
1745 * Sign-extend a 32-bit value when that's what it is.
1747 long pid = tcp->u_arg[0];
1748 if (personality_wordsize[current_personality] < sizeof pid)
1749 pid = (long) (int) pid;
1750 tprintf("%ld, %s", pid, signame(tcp->u_arg[1]));
1755 #if defined(FREEBSD) || defined(SUNOS4)
1760 return sys_kill(tcp);
1762 #endif /* FREEBSD || SUNOS4 */
1769 if (entering(tcp)) {
1770 tprintf("%ld, %ld, %s",
1771 tcp->u_arg[0], tcp->u_arg[1], signame(tcp->u_arg[2]));
1785 tprintf("%#lx", tcp->u_arg[0]);
1786 else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1789 printsigmask(&sigset, 0);
1795 int sys_sigwait(tcp)
1800 if (entering(tcp)) {
1801 if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1804 printsigmask(&sigset, 0);
1807 if (!syserror(tcp)) {
1808 tcp->auxstr = signalent[tcp->u_rval];
1809 return RVAL_DECIMAL | RVAL_STR;
1819 sys_rt_sigprocmask(tcp)
1824 /* Note: arg[3] is the length of the sigset. */
1825 if (entering(tcp)) {
1826 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1830 else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0)
1831 tprintf("%#lx, ", tcp->u_arg[1]);
1833 printsigmask(&sigset, 1);
1841 else if (syserror(tcp))
1842 tprintf("%#lx", tcp->u_arg[2]);
1843 else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0)
1846 printsigmask(&sigset, 1);
1847 tprintf(", %lu", tcp->u_arg[3]);
1853 /* Structure describing the action to be taken when a signal arrives. */
1854 struct new_sigaction
1858 __sighandler_t __sa_handler;
1859 void (*__sa_sigaction) (int, siginfo_t *, void *);
1861 __sigaction_handler;
1862 unsigned long sa_flags;
1863 void (*sa_restorer) (void);
1864 unsigned long int sa_mask[2];
1869 sys_rt_sigaction(tcp)
1872 struct new_sigaction sa;
1876 if (entering(tcp)) {
1877 printsignal(tcp->u_arg[0]);
1879 addr = tcp->u_arg[1];
1881 addr = tcp->u_arg[2];
1884 else if (!verbose(tcp))
1885 tprintf("%#lx", addr);
1886 else if (umove(tcp, addr, &sa) < 0)
1889 switch ((long) sa.__sigaction_handler.__sa_handler) {
1890 case (long) SIG_ERR:
1891 tprintf("{SIG_ERR}");
1893 case (long) SIG_DFL:
1894 tprintf("{SIG_DFL}");
1896 case (long) SIG_IGN:
1897 tprintf("{SIG_IGN}");
1901 (long) sa.__sigaction_handler.__sa_handler);
1902 sigemptyset(&sigset);
1904 if (tcp->u_arg[4] <= sizeof(sigset))
1905 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
1907 if (tcp->u_arg[3] <= sizeof(sigset))
1908 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
1911 memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
1912 printsigmask(&sigset, 1);
1914 printflags(sigact_flags, sa.sa_flags, "SA_???");
1916 if (sa.sa_flags & SA_RESTORER)
1917 tprintf(", %p", sa.sa_restorer);
1926 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
1927 #elif defined(ALPHA)
1928 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
1930 tprintf(", %lu", addr = tcp->u_arg[3]);
1936 sys_rt_sigpending(tcp)
1943 tprintf("%#lx", tcp->u_arg[0]);
1944 else if (copy_sigset_len(tcp, tcp->u_arg[0],
1945 &sigset, tcp->u_arg[1]) < 0)
1948 printsigmask(&sigset, 1);
1953 sys_rt_sigsuspend(tcp)
1956 if (entering(tcp)) {
1958 if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0)
1961 printsigmask(&sigm, 1);
1966 sys_rt_sigqueueinfo(tcp)
1969 if (entering(tcp)) {
1971 tprintf("%lu, ", tcp->u_arg[0]);
1972 printsignal(tcp->u_arg[1]);
1974 if (umove(tcp, tcp->u_arg[2], &si) < 0)
1975 tprintf("%#lx", tcp->u_arg[2]);
1977 printsiginfo(&si, verbose (tcp));
1982 int sys_rt_sigtimedwait(tcp)
1985 if (entering(tcp)) {
1988 if (copy_sigset_len(tcp, tcp->u_arg[0],
1989 &sigset, tcp->u_arg[3]) < 0)
1992 printsigmask(&sigset, 1);
1997 tprintf("%#lx", tcp->u_arg[0]);
2000 if (umove(tcp, tcp->u_arg[1], &si) < 0)
2001 tprintf("%#lx", tcp->u_arg[1]);
2003 printsiginfo(&si, verbose (tcp));
2005 tprintf(", %#lx", tcp->u_arg[2]);
2006 tprintf(", %d", (int) tcp->u_arg[3]);
2013 sys_restart_syscall(tcp)
2017 tprintf("<... resuming interrupted call ...>");
2025 if (entering(tcp)) {
2026 tprintf("%ld, ", tcp->u_arg[0]);
2027 print_sigset(tcp, tcp->u_arg[1], 1);
2028 tprintf("%lu", tcp->u_arg[2]);