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.
44 #include <sys/ucontext.h>
49 #ifndef PTRACE_PEEKUSR
50 # define PTRACE_PEEKUSR PTRACE_PEEKUSER
52 #ifndef PTRACE_POKEUSR
53 # define PTRACE_POKEUSR PTRACE_POKEUSER
55 #elif defined(HAVE_LINUX_PTRACE_H)
57 # ifdef HAVE_STRUCT_IA64_FPREG
58 # define ia64_fpreg XXX_ia64_fpreg
60 # ifdef HAVE_STRUCT_PT_ALL_USER_REGS
61 # define pt_all_user_regs XXX_pt_all_user_regs
63 #include <linux/ptrace.h>
65 # undef pt_all_user_regs
72 # include <asm/ptrace_offsets.h>
75 #if defined (LINUX) && defined (SPARC64)
76 # undef PTRACE_GETREGS
77 # define PTRACE_GETREGS PTRACE_GETREGS64
78 # undef PTRACE_SETREGS
79 # define PTRACE_SETREGS PTRACE_SETREGS64
80 #endif /* LINUX && SPARC64 */
82 #if defined (SPARC) || defined (SPARC64) || defined (MIPS)
84 struct pt_regs si_regs;
87 #elif defined HAVE_ASM_SIGCONTEXT_H
88 #if !defined(IA64) && !defined(X86_64)
89 #include <asm/sigcontext.h>
90 #endif /* !IA64 && !X86_64 */
91 #else /* !HAVE_ASM_SIGCONTEXT_H */
92 #if defined I386 && !defined HAVE_STRUCT_SIGCONTEXT_STRUCT
93 struct sigcontext_struct {
94 unsigned short gs, __gsh;
95 unsigned short fs, __fsh;
96 unsigned short es, __esh;
97 unsigned short ds, __dsh;
106 unsigned long trapno;
109 unsigned short cs, __csh;
110 unsigned long eflags;
111 unsigned long esp_at_signal;
112 unsigned short ss, __ssh;
114 unsigned long oldmask;
118 #if defined M68K && !defined HAVE_STRUCT_SIGCONTEXT
121 unsigned long sc_mask;
122 unsigned long sc_usp;
127 unsigned short sc_sr;
129 unsigned short sc_formatvec;
133 #endif /* !HAVE_ASM_SIGCONTEXT_H */
143 const char *const signalent0[] = {
144 #include "signalent.h"
146 const int nsignals0 = sizeof signalent0 / sizeof signalent0[0];
148 #if SUPPORTED_PERSONALITIES >= 2
149 const char *const signalent1[] = {
150 #include "signalent1.h"
152 const int nsignals1 = sizeof signalent1 / sizeof signalent1[0];
153 #endif /* SUPPORTED_PERSONALITIES >= 2 */
155 #if SUPPORTED_PERSONALITIES >= 3
156 const char *const signalent2[] = {
157 #include "signalent2.h"
159 const int nsignals2 = sizeof signalent2 / sizeof signalent2[0];
160 #endif /* SUPPORTED_PERSONALITIES >= 3 */
162 const char *const *signalent;
165 #if defined(SUNOS4) || defined(FREEBSD)
167 static const struct xlat sigvec_flags[] = {
168 { SV_ONSTACK, "SV_ONSTACK" },
169 { SV_INTERRUPT, "SV_INTERRUPT" },
170 { SV_RESETHAND, "SV_RESETHAND" },
171 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
175 #endif /* SUNOS4 || FREEBSD */
177 #ifdef HAVE_SIGACTION
179 #if defined LINUX && (defined I386 || defined X86_64)
180 /* The libc headers do not define this constant since it should only be
181 used by the implementation. So wwe define it here. */
183 # define SA_RESTORER 0x04000000
187 static const struct xlat sigact_flags[] = {
189 { SA_RESTORER, "SA_RESTORER" },
192 { SA_STACK, "SA_STACK" },
195 { SA_RESTART, "SA_RESTART" },
198 { SA_INTERRUPT, "SA_INTERRUPT" },
201 { SA_NODEFER, "SA_NODEFER" },
203 #if defined SA_NOMASK && SA_NODEFER != SA_NOMASK
204 { SA_NOMASK, "SA_NOMASK" },
207 { SA_RESETHAND, "SA_RESETHAND" },
209 #if defined SA_ONESHOT && SA_ONESHOT != SA_RESETHAND
210 { SA_ONESHOT, "SA_ONESHOT" },
213 { SA_SIGINFO, "SA_SIGINFO" },
216 { SA_RESETHAND, "SA_RESETHAND" },
219 { SA_ONSTACK, "SA_ONSTACK" },
222 { SA_NODEFER, "SA_NODEFER" },
225 { SA_NOCLDSTOP, "SA_NOCLDSTOP" },
228 { SA_NOCLDWAIT, "SA_NOCLDWAIT" },
231 { _SA_BSDCALL, "_SA_BSDCALL" },
234 { SA_NOPTRACE, "SA_NOPTRACE" },
239 static const struct xlat sigprocmaskcmds[] = {
240 { SIG_BLOCK, "SIG_BLOCK" },
241 { SIG_UNBLOCK, "SIG_UNBLOCK" },
242 { SIG_SETMASK, "SIG_SETMASK" },
244 { SIG_SETMASK32,"SIG_SETMASK32" },
249 #endif /* HAVE_SIGACTION */
251 /* Anonymous realtime signals. */
252 /* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
253 constant. This is what we want. Otherwise, just use SIGRTMIN. */
256 #define __SIGRTMIN SIGRTMIN
257 #define __SIGRTMAX SIGRTMAX /* likewise */
266 if (sig >= 0 && sig < nsignals) {
267 return signalent[sig];
269 } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) {
270 sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN));
272 #endif /* SIGRTMIN */
274 sprintf(buf, "%d", sig);
291 copy_sigset_len(struct tcb *tcp, long addr, sigset_t *s, int len)
293 if (len > sizeof(*s))
296 if (umoven(tcp, addr, len, (char *)s) < 0)
302 /* Original sigset is unsigned long */
303 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long))
305 #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t))
309 sprintsigmask(const char *str, sigset_t *mask, int rt)
310 /* set might include realtime sigs */
316 static char outstr[8 * sizeof(sigset_t) * 8];
319 s = outstr + strlen(outstr);
324 maxsigs = __SIGRTMAX; /* instead */
326 for (i = 1; i < maxsigs; i++) {
327 if (sigismember(mask, i) == 1)
330 if (nsigs >= nsignals * 2 / 3) {
332 for (i = 1; i < maxsigs; i++) {
333 switch (sigismember(mask, i)) {
345 for (i = 1; i < maxsigs; i++) {
346 if (sigismember(mask, i) == 1) {
347 /* real-time signals on solaris don't have
351 sprintf(s, format, signalent[i] + 3);
354 else if (i >= __SIGRTMIN && i <= __SIGRTMAX) {
356 sprintf(tsig, "RT_%u", i - __SIGRTMIN);
357 sprintf(s, format, tsig);
359 #endif /* SIGRTMIN */
362 sprintf(tsig, "%u", i);
363 sprintf(s, format, tsig);
375 printsigmask(mask, rt)
379 tprintf("%s", sprintsigmask("", mask, rt));
386 tprintf("%s", signame(nr));
390 print_sigset(struct tcb *tcp, long addr, int rt)
396 else if (copy_sigset(tcp, addr, &ss) < 0)
397 tprintf("%#lx", addr);
399 printsigmask(&ss, rt);
405 #define ILL_ILLOPC 1 /* illegal opcode */
406 #define ILL_ILLOPN 2 /* illegal operand */
407 #define ILL_ILLADR 3 /* illegal addressing mode */
408 #define ILL_ILLTRP 4 /* illegal trap */
409 #define ILL_PRVOPC 5 /* privileged opcode */
410 #define ILL_PRVREG 6 /* privileged register */
411 #define ILL_COPROC 7 /* coprocessor error */
412 #define ILL_BADSTK 8 /* internal stack error */
413 #define FPE_INTDIV 1 /* integer divide by zero */
414 #define FPE_INTOVF 2 /* integer overflow */
415 #define FPE_FLTDIV 3 /* floating point divide by zero */
416 #define FPE_FLTOVF 4 /* floating point overflow */
417 #define FPE_FLTUND 5 /* floating point underflow */
418 #define FPE_FLTRES 6 /* floating point inexact result */
419 #define FPE_FLTINV 7 /* floating point invalid operation */
420 #define FPE_FLTSUB 8 /* subscript out of range */
421 #define SEGV_MAPERR 1 /* address not mapped to object */
422 #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
423 #define BUS_ADRALN 1 /* invalid address alignment */
424 #define BUS_ADRERR 2 /* non-existant physical address */
425 #define BUS_OBJERR 3 /* object specific hardware error */
426 #define TRAP_BRKPT 1 /* process breakpoint */
427 #define TRAP_TRACE 2 /* process trace trap */
428 #define CLD_EXITED 1 /* child has exited */
429 #define CLD_KILLED 2 /* child was killed */
430 #define CLD_DUMPED 3 /* child terminated abnormally */
431 #define CLD_TRAPPED 4 /* traced child has trapped */
432 #define CLD_STOPPED 5 /* child has stopped */
433 #define CLD_CONTINUED 6 /* stopped child has continued */
434 #define POLL_IN 1 /* data input available */
435 #define POLL_OUT 2 /* output buffers available */
436 #define POLL_MSG 3 /* input message available */
437 #define POLL_ERR 4 /* i/o error */
438 #define POLL_PRI 5 /* high priority input available */
439 #define POLL_HUP 6 /* device disconnected */
440 #define SI_KERNEL 0x80 /* sent by kernel */
441 #define SI_USER 0 /* sent by kill, sigsend, raise */
442 #define SI_QUEUE -1 /* sent by sigqueue */
443 #define SI_TIMER -2 /* sent by timer expiration */
444 #define SI_MESGQ -3 /* sent by real time mesq state change */
445 #define SI_ASYNCIO -4 /* sent by AIO completion */
446 #define SI_SIGIO -5 /* sent by SIGIO */
447 #define SI_TKILL -6 /* sent by tkill */
448 #define SI_ASYNCNL -60 /* sent by asynch name lookup completion */
450 #define SI_FROMUSER(sip) ((sip)->si_code <= 0)
454 #if __GLIBC_MINOR__ < 1
455 /* Type for data associated with a signal. */
462 # define __SI_MAX_SIZE 128
463 # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof(int)) - 3)
465 typedef struct siginfo
467 int si_signo; /* Signal number. */
468 int si_errno; /* If non-zero, an errno value associated with
469 this signal, as defined in <errno.h>. */
470 int si_code; /* Signal code. */
474 int _pad[__SI_PAD_SIZE];
479 __pid_t si_pid; /* Sending process ID. */
480 __uid_t si_uid; /* Real user ID of sending process. */
483 /* POSIX.1b timers. */
486 unsigned int _timer1;
487 unsigned int _timer2;
490 /* POSIX.1b signals. */
493 __pid_t si_pid; /* Sending process ID. */
494 __uid_t si_uid; /* Real user ID of sending process. */
495 sigval_t si_sigval; /* Signal value. */
501 __pid_t si_pid; /* Which child. */
502 int si_status; /* Exit value or signal. */
507 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
510 void *si_addr; /* Faulting insn/memory ref. */
516 int si_band; /* Band event for SIGPOLL. */
522 #define si_pid _sifields._kill.si_pid
523 #define si_uid _sifields._kill.si_uid
524 #define si_status _sifields._sigchld.si_status
525 #define si_utime _sifields._sigchld.si_utime
526 #define si_stime _sifields._sigchld.si_stime
527 #define si_value _sifields._rt.si_sigval
528 #define si_int _sifields._rt.si_sigval.sival_int
529 #define si_ptr _sifields._rt.si_sigval.sival_ptr
530 #define si_addr _sifields._sigfault.si_addr
531 #define si_band _sifields._sigpoll.si_band
532 #define si_fd _sifields._sigpoll.si_fd
538 #if defined (SVR4) || defined (LINUX)
540 static const struct xlat siginfo_codes[] = {
542 { SI_KERNEL, "SI_KERNEL" },
545 { SI_USER, "SI_USER" },
548 { SI_QUEUE, "SI_QUEUE" },
551 { SI_TIMER, "SI_TIMER" },
554 { SI_MESGQ, "SI_MESGQ" },
557 { SI_ASYNCIO, "SI_ASYNCIO" },
560 { SI_SIGIO, "SI_SIGIO" },
563 { SI_TKILL, "SI_TKILL" },
566 { SI_ASYNCNL, "SI_ASYNCNL" },
569 { SI_NOINFO, "SI_NOINFO" },
572 { SI_LWP, "SI_LWP" },
577 static const struct xlat sigill_codes[] = {
578 { ILL_ILLOPC, "ILL_ILLOPC" },
579 { ILL_ILLOPN, "ILL_ILLOPN" },
580 { ILL_ILLADR, "ILL_ILLADR" },
581 { ILL_ILLTRP, "ILL_ILLTRP" },
582 { ILL_PRVOPC, "ILL_PRVOPC" },
583 { ILL_PRVREG, "ILL_PRVREG" },
584 { ILL_COPROC, "ILL_COPROC" },
585 { ILL_BADSTK, "ILL_BADSTK" },
589 static const struct xlat sigfpe_codes[] = {
590 { FPE_INTDIV, "FPE_INTDIV" },
591 { FPE_INTOVF, "FPE_INTOVF" },
592 { FPE_FLTDIV, "FPE_FLTDIV" },
593 { FPE_FLTOVF, "FPE_FLTOVF" },
594 { FPE_FLTUND, "FPE_FLTUND" },
595 { FPE_FLTRES, "FPE_FLTRES" },
596 { FPE_FLTINV, "FPE_FLTINV" },
597 { FPE_FLTSUB, "FPE_FLTSUB" },
601 static const struct xlat sigtrap_codes[] = {
602 { TRAP_BRKPT, "TRAP_BRKPT" },
603 { TRAP_TRACE, "TRAP_TRACE" },
607 static const struct xlat sigchld_codes[] = {
608 { CLD_EXITED, "CLD_EXITED" },
609 { CLD_KILLED, "CLD_KILLED" },
610 { CLD_DUMPED, "CLD_DUMPED" },
611 { CLD_TRAPPED, "CLD_TRAPPED" },
612 { CLD_STOPPED, "CLD_STOPPED" },
613 { CLD_CONTINUED,"CLD_CONTINUED" },
617 static const struct xlat sigpoll_codes[] = {
618 { POLL_IN, "POLL_IN" },
619 { POLL_OUT, "POLL_OUT" },
620 { POLL_MSG, "POLL_MSG" },
621 { POLL_ERR, "POLL_ERR" },
622 { POLL_PRI, "POLL_PRI" },
623 { POLL_HUP, "POLL_HUP" },
627 static const struct xlat sigprof_codes[] = {
629 { PROF_SIG, "PROF_SIG" },
635 static const struct xlat sigemt_codes[] = {
637 { EMT_TAGOVF, "EMT_TAGOVF" },
643 static const struct xlat sigsegv_codes[] = {
644 { SEGV_MAPERR, "SEGV_MAPERR" },
645 { SEGV_ACCERR, "SEGV_ACCERR" },
649 static const struct xlat sigbus_codes[] = {
650 { BUS_ADRALN, "BUS_ADRALN" },
651 { BUS_ADRERR, "BUS_ADRERR" },
652 { BUS_OBJERR, "BUS_OBJERR" },
657 printsiginfo(siginfo_t *sip, int verbose)
661 if (sip->si_signo == 0) {
665 tprintf("{si_signo=");
666 printsignal(sip->si_signo);
667 code = xlookup(siginfo_codes, sip->si_code);
669 switch (sip->si_signo) {
671 code = xlookup(sigtrap_codes, sip->si_code);
674 code = xlookup(sigchld_codes, sip->si_code);
677 code = xlookup(sigpoll_codes, sip->si_code);
680 code = xlookup(sigprof_codes, sip->si_code);
683 code = xlookup(sigill_codes, sip->si_code);
687 code = xlookup(sigemt_codes, sip->si_code);
691 code = xlookup(sigfpe_codes, sip->si_code);
694 code = xlookup(sigsegv_codes, sip->si_code);
697 code = xlookup(sigbus_codes, sip->si_code);
702 tprintf(", si_code=%s", code);
704 tprintf(", si_code=%#x", sip->si_code);
706 if (sip->si_code != SI_NOINFO)
710 if (sip->si_errno < 0 || sip->si_errno >= nerrnos)
711 tprintf(", si_errno=%d", sip->si_errno);
713 tprintf(", si_errno=%s",
714 errnoent[sip->si_errno]);
717 if (SI_FROMUSER(sip)) {
718 tprintf(", si_pid=%lu, si_uid=%lu",
719 (unsigned long) sip->si_pid,
720 (unsigned long) sip->si_uid);
721 switch (sip->si_code) {
732 tprintf(", si_value=%d", sip->si_int);
742 tprintf(", si_value={int=%u, ptr=%#lx}",
744 (unsigned long) sip->si_ptr);
750 #endif /* SI_FROMUSER */
752 switch (sip->si_signo) {
754 tprintf(", si_pid=%ld, si_status=",
756 if (sip->si_code == CLD_EXITED)
757 tprintf("%d", sip->si_status);
759 printsignal(sip->si_status);
764 tprintf(", si_utime=%lu, si_stime=%lu",
769 case SIGILL: case SIGFPE:
770 case SIGSEGV: case SIGBUS:
771 tprintf(", si_addr=%#lx",
772 (unsigned long) sip->si_addr);
775 switch (sip->si_code) {
776 case POLL_IN: case POLL_OUT: case POLL_MSG:
777 tprintf(", si_band=%ld",
778 (long) sip->si_band);
784 if (sip->si_pid || sip->si_uid)
785 tprintf(", si_pid=%lu, si_uid=%lu",
786 (unsigned long) sip->si_pid,
787 (unsigned long) sip->si_uid);
793 tprintf(", si_value={int=%u, ptr=%#lx}",
795 (unsigned long) sip->si_ptr);
805 #endif /* SVR4 || LINUX */
810 parse_sigset_t(const char *str, sigset_t *set)
818 p = strchr(str, '\n');
820 p = strchr(str, '\0');
821 for (i = 0; p-- > str; i += 4) {
822 if (*p >= '0' && *p <= '9')
824 else if (*p >= 'a' && *p <= 'f')
825 digit = *p - 'a' + 10;
826 else if (*p >= 'A' && *p <= 'F')
827 digit = *p - 'A' + 10;
831 sigaddset(set, i + 1);
833 sigaddset(set, i + 2);
835 sigaddset(set, i + 3);
837 sigaddset(set, i + 4);
844 * Check process TCP for the disposition of signal SIG.
845 * Return 1 if the process would somehow manage to survive signal SIG,
846 * else return 0. This routine will never be called with SIGKILL.
849 sigishandled(struct tcb *tcp, int sig)
857 sigset_t ignored, caught;
861 * Since procfs doesn't interfere with wait I think it is safe
862 * to punt on this question. If not, the information is there.
874 #if defined(SIGURG) && SIGURG != SIGIO
878 /* Gloria Gaynor says ... */
886 /* This is incredibly costly but it's worth it. */
887 /* NOTE: LinuxThreads internally uses SIGRTMIN, SIGRTMIN + 1 and
888 SIGRTMIN + 2, so we can't use the obsolete /proc/%d/stat which
889 doesn't handle real-time signals). */
890 sprintf(sname, "/proc/%d/status", tcp->pid);
891 if ((sfd = open(sname, O_RDONLY)) == -1) {
895 i = read(sfd, buf, sizeof(buf));
899 * Skip the extraneous fields. We need to skip
900 * command name has any spaces in it. So be it.
902 s = strstr(buf, "SigIgn:\t");
905 fprintf(stderr, "/proc/pid/status format error\n");
908 parse_sigset_t(s + 8, &ignored);
910 s = strstr(buf, "SigCgt:\t");
913 fprintf(stderr, "/proc/pid/status format error\n");
916 parse_sigset_t(s + 8, &caught);
919 fprintf(stderr, "sigs: %016qx %016qx (sig=%d)\n",
920 *(long long *) &ignored, *(long long *) &caught, sig);
922 if (sigismember(&ignored, sig) || sigismember(&caught, sig))
929 if (upeek(tcp, uoff(u_signal[0]) + sig*sizeof(u_signal),
930 (long *) &u_signal) < 0) {
933 if (u_signal != SIG_DFL)
940 #if defined(SUNOS4) || defined(FREEBSD)
943 sys_sigvec(struct tcb *tcp)
949 printsignal(tcp->u_arg[0]);
951 addr = tcp->u_arg[1];
953 addr = tcp->u_arg[2];
957 else if (!verbose(tcp))
958 tprintf("%#lx", addr);
959 else if (umove(tcp, addr, &sv) < 0)
962 switch ((int) sv.sv_handler) {
964 tprintf("{SIG_ERR}");
967 tprintf("{SIG_DFL}");
970 if (tcp->u_arg[0] == SIGTRAP) {
971 tcp->flags |= TCB_SIGTRAPPED;
972 kill(tcp->pid, SIGSTOP);
974 tprintf("{SIG_IGN}");
977 if (tcp->u_arg[0] == SIGTRAP) {
978 tcp->flags |= TCB_SIGTRAPPED;
979 kill(tcp->pid, SIGSTOP);
984 if (tcp->u_arg[0] == SIGTRAP) {
985 tcp->flags |= TCB_SIGTRAPPED;
986 kill(tcp->pid, SIGSTOP);
988 tprintf("{%#lx, ", (unsigned long) sv.sv_handler);
989 printsigmask(&sv.sv_mask, 0);
991 printflags(sigvec_flags, sv.sv_flags, "SV_???");
1001 sys_sigpause(struct tcb *tcp)
1003 if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */
1005 long_to_sigset(tcp->u_arg[0], &sigm);
1006 printsigmask(&sigm, 0);
1012 sys_sigstack(struct tcb *tcp)
1018 addr = tcp->u_arg[0];
1020 addr = tcp->u_arg[1];
1023 else if (umove(tcp, addr, &ss) < 0)
1024 tprintf("%#lx", addr);
1026 tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp);
1027 tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO");
1035 sys_sigcleanup(struct tcb *tcp)
1040 #endif /* SUNOS4 || FREEBSD */
1045 sys_sigsetmask(struct tcb *tcp)
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)
1072 sys_sigblock(struct tcb *tcp)
1074 return sys_sigsetmask(tcp);
1076 #endif /* SUNOS4 || FREEBSD */
1080 #ifdef HAVE_SIGACTION
1083 struct old_sigaction {
1084 __sighandler_t __sa_handler;
1085 unsigned long sa_mask;
1086 unsigned long sa_flags;
1087 void (*sa_restorer)(void);
1089 #define SA_HANDLER __sa_handler
1093 #define SA_HANDLER sa_handler
1097 sys_sigaction(struct tcb *tcp)
1102 struct old_sigaction sa;
1104 struct sigaction sa;
1108 if (entering(tcp)) {
1109 printsignal(tcp->u_arg[0]);
1111 addr = tcp->u_arg[1];
1113 addr = tcp->u_arg[2];
1116 else if (!verbose(tcp))
1117 tprintf("%#lx", addr);
1118 else if (umove(tcp, addr, &sa) < 0)
1121 /* Architectures using function pointers, like
1122 * hppa, may need to manipulate the function pointer
1123 * to compute the result of a comparison. However,
1124 * the SA_HANDLER function pointer exists only in
1125 * the address space of the traced process, and can't
1126 * be manipulated by strace. In order to prevent the
1127 * compiler from generating code to manipulate
1128 * SA_HANDLER we cast the function pointers to long. */
1129 if ((long)sa.SA_HANDLER == (long)SIG_ERR)
1130 tprintf("{SIG_ERR, ");
1131 else if ((long)sa.SA_HANDLER == (long)SIG_DFL)
1132 tprintf("{SIG_DFL, ");
1133 else if ((long)sa.SA_HANDLER == (long)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("{SIG_IGN, ");
1144 if (tcp->u_arg[0] == SIGTRAP) {
1145 tcp->flags |= TCB_SIGTRAPPED;
1146 kill(tcp->pid, SIGSTOP);
1148 #endif /* !USE_PROCFS */
1149 tprintf("{%#lx, ", (long) sa.SA_HANDLER);
1151 printsigmask(&sa.sa_mask, 0);
1153 long_to_sigset(sa.sa_mask, &sigset);
1154 printsigmask(&sigset, 0);
1157 printflags(sigact_flags, sa.sa_flags, "SA_???");
1159 if (sa.sa_flags & SA_RESTORER)
1160 tprintf(", %p", sa.sa_restorer);
1169 tprintf(", %#lx", (unsigned long) sa.sa_restorer);
1175 sys_signal(struct tcb *tcp)
1177 if (entering(tcp)) {
1178 printsignal(tcp->u_arg[0]);
1180 switch (tcp->u_arg[1]) {
1181 case (long) SIG_ERR:
1184 case (long) SIG_DFL:
1187 case (long) SIG_IGN:
1189 if (tcp->u_arg[0] == SIGTRAP) {
1190 tcp->flags |= TCB_SIGTRAPPED;
1191 kill(tcp->pid, SIGSTOP);
1193 #endif /* !USE_PROCFS */
1198 if (tcp->u_arg[0] == SIGTRAP) {
1199 tcp->flags |= TCB_SIGTRAPPED;
1200 kill(tcp->pid, SIGSTOP);
1202 #endif /* !USE_PROCFS */
1203 tprintf("%#lx", tcp->u_arg[1]);
1207 else if (!syserror(tcp)) {
1208 switch (tcp->u_rval) {
1209 case (long) SIG_ERR:
1210 tcp->auxstr = "SIG_ERR"; break;
1211 case (long) SIG_DFL:
1212 tcp->auxstr = "SIG_DFL"; break;
1213 case (long) SIG_IGN:
1214 tcp->auxstr = "SIG_IGN"; break;
1218 return RVAL_HEX | RVAL_STR;
1225 sys_sighold(struct tcb *tcp)
1227 if (entering(tcp)) {
1228 printsignal(tcp->u_arg[0]);
1234 #endif /* HAVE_SIGACTION */
1239 sys_sigreturn(struct tcb *tcp)
1242 struct pt_regs regs;
1243 struct sigcontext_struct sc;
1245 if (entering(tcp)) {
1248 if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, (void *)®s) == -1)
1251 if (umove(tcp, regs.ARM_sp, &sc) < 0)
1255 tcp->u_arg[1] = sc.oldmask;
1258 long_to_sigset(tcp->u_arg[1], &sigm);
1259 tcp->u_rval = tcp->u_error = 0;
1260 if (tcp->u_arg[0] == 0)
1262 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1263 return RVAL_NONE | RVAL_STR;
1266 #elif defined(S390) || defined(S390X)
1268 struct sigcontext_struct sc;
1270 if (entering(tcp)) {
1272 if (upeek(tcp, PT_GPR15, &usp) < 0)
1274 if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0)
1277 memcpy(&tcp->u_arg[1], &sc.oldmask[0], sizeof(sigset_t));
1279 tcp->u_rval = tcp->u_error = 0;
1280 if (tcp->u_arg[0] == 0)
1282 tcp->auxstr = sprintsigmask("mask now ", (sigset_t *)&tcp->u_arg[1], 0);
1283 return RVAL_NONE | RVAL_STR;
1288 struct sigcontext_struct sc;
1290 if (entering(tcp)) {
1292 if (upeek(tcp, 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;
1310 struct sigcontext sc;
1313 if (entering(tcp)) {
1314 /* offset of sigcontext in the kernel's sigframe structure: */
1315 # define SIGFRAME_SC_OFFSET 0x90
1317 if (upeek(tcp, PT_R12, &sp) < 0)
1319 if (umove(tcp, sp + 16 + SIGFRAME_SC_OFFSET, &sc) < 0)
1322 memcpy(tcp->u_arg + 1, &sc.sc_mask, sizeof(sc.sc_mask));
1327 memcpy(&sigm, tcp->u_arg + 1, sizeof(sigm));
1328 tcp->u_rval = tcp->u_error = 0;
1329 if (tcp->u_arg[0] == 0)
1331 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1332 return RVAL_NONE | RVAL_STR;
1335 #elif defined(POWERPC)
1337 struct sigcontext_struct sc;
1339 if (entering(tcp)) {
1341 if (upeek(tcp, sizeof(unsigned long)*PT_R1, &esp) < 0)
1343 /* Skip dummy stack frame. */
1345 if (current_personality == 0)
1352 if (umove(tcp, esp, &sc) < 0)
1355 tcp->u_arg[1] = sc.oldmask;
1359 long_to_sigset(tcp->u_arg[1], &sigm);
1360 tcp->u_rval = tcp->u_error = 0;
1361 if (tcp->u_arg[0] == 0)
1363 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1364 return RVAL_NONE | RVAL_STR;
1369 struct sigcontext sc;
1371 if (entering(tcp)) {
1373 if (upeek(tcp, 4*PT_USP, &usp) < 0)
1375 if (umove(tcp, usp, &sc) < 0)
1378 tcp->u_arg[1] = sc.sc_mask;
1382 long_to_sigset(tcp->u_arg[1], &sigm);
1383 tcp->u_rval = tcp->u_error = 0;
1384 if (tcp->u_arg[0] == 0)
1386 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1387 return RVAL_NONE | RVAL_STR;
1390 #elif defined(ALPHA)
1392 struct sigcontext_struct sc;
1394 if (entering(tcp)) {
1396 if (upeek(tcp, REG_FP, &fp) < 0)
1398 if (umove(tcp, fp, &sc) < 0)
1401 tcp->u_arg[1] = sc.sc_mask;
1405 long_to_sigset(tcp->u_arg[1], &sigm);
1406 tcp->u_rval = tcp->u_error = 0;
1407 if (tcp->u_arg[0] == 0)
1409 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1410 return RVAL_NONE | RVAL_STR;
1413 #elif defined (SPARC) || defined (SPARC64)
1415 struct pt_regs regs;
1418 if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
1419 perror("sigreturn: PTRACE_GETREGS ");
1422 if (entering(tcp)) {
1424 i1 = regs.u_regs[U_REG_O1];
1425 if (umove(tcp, i1, &si) < 0) {
1426 perror("sigreturn: umove ");
1430 tcp->u_arg[1] = si.si_mask;
1433 long_to_sigset(tcp->u_arg[1], &sigm);
1434 tcp->u_rval = tcp->u_error = 0;
1435 if (tcp->u_arg[0] == 0)
1437 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1438 return RVAL_NONE | RVAL_STR;
1441 #elif defined (LINUX_MIPSN32) || defined (LINUX_MIPSN64)
1442 /* This decodes rt_sigreturn. The 64-bit ABIs do not have
1447 if (entering(tcp)) {
1449 if (upeek(tcp, REG_SP, &sp) < 0)
1451 /* There are six words followed by a 128-byte siginfo. */
1452 sp = sp + 6 * 4 + 128;
1453 if (umove(tcp, sp, &uc) < 0)
1456 tcp->u_arg[1] = *(long *) &uc.uc_sigmask;
1459 long_to_sigset(tcp->u_arg[1], &sigm);
1460 tcp->u_rval = tcp->u_error = 0;
1461 if (tcp->u_arg[0] == 0)
1463 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1464 return RVAL_NONE | RVAL_STR;
1469 struct pt_regs regs;
1472 if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
1473 perror("sigreturn: PTRACE_GETREGS ");
1476 if (entering(tcp)) {
1479 if (umove(tcp, sp, &si) < 0)
1481 tcp->u_arg[1] = si.si_mask;
1484 long_to_sigset(tcp->u_arg[1], &sigm);
1485 tcp->u_rval = tcp->u_error = 0;
1486 if (tcp->u_arg[0] == 0)
1488 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1489 return RVAL_NONE | RVAL_STR;
1492 #elif defined(CRISV10) || defined(CRISV32)
1493 struct sigcontext sc;
1495 if (entering(tcp)) {
1496 long regs[PT_MAX+1];
1500 if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, (long)regs) < 0) {
1501 perror("sigreturn: PTRACE_GETREGS");
1504 if (umove(tcp, regs[PT_USP], &sc) < 0)
1507 tcp->u_arg[1] = sc.oldmask;
1510 long_to_sigset(tcp->u_arg[1], &sigm);
1511 tcp->u_rval = tcp->u_error = 0;
1513 if (tcp->u_arg[0] == 0)
1515 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1516 return RVAL_NONE | RVAL_STR;
1523 /* offset of ucontext in the kernel's sigframe structure */
1524 # define SIGFRAME_UC_OFFSET C_ABI_SAVE_AREA_SIZE + sizeof(struct siginfo)
1526 if (entering(tcp)) {
1528 if (upeek(tcp, PTREGS_OFFSET_SP, &sp) < 0)
1530 if (umove(tcp, sp + SIGFRAME_UC_OFFSET, &uc) < 0)
1533 memcpy(tcp->u_arg + 1, &uc.uc_sigmask, sizeof(uc.uc_sigmask));
1538 memcpy(&sigm, tcp->u_arg + 1, sizeof(sigm));
1539 tcp->u_rval = tcp->u_error = 0;
1540 if (tcp->u_arg[0] == 0)
1542 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1543 return RVAL_NONE | RVAL_STR;
1546 #elif defined(MICROBLAZE)
1547 struct sigcontext sc;
1549 /* TODO: Verify that this is correct... */
1550 if (entering(tcp)) {
1555 /* Read r1, the stack pointer. */
1556 if (upeek(tcp, 1 * 4, &sp) < 0)
1558 if (umove(tcp, sp, &sc) < 0)
1561 tcp->u_arg[1] = sc.oldmask;
1564 long_to_sigset(tcp->u_arg[1], &sigm);
1565 tcp->u_rval = tcp->u_error = 0;
1566 if (tcp->u_arg[0] == 0)
1568 tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
1569 return RVAL_NONE | RVAL_STR;
1573 #warning No sys_sigreturn() for this architecture
1574 #warning (no problem, just a reminder :-)
1580 sys_siggetmask(struct tcb *tcp)
1584 long_to_sigset(tcp->u_rval, &sigm);
1585 tcp->auxstr = sprintsigmask("mask ", &sigm, 0);
1587 return RVAL_HEX | RVAL_STR;
1591 sys_sigsuspend(struct tcb *tcp)
1593 if (entering(tcp)) {
1595 long_to_sigset(tcp->u_arg[2], &sigm);
1596 printsigmask(&sigm, 0);
1603 #if defined(SVR4) || defined(FREEBSD)
1606 sys_sigsuspend(struct tcb *tcp)
1610 if (entering(tcp)) {
1611 if (umove(tcp, tcp->u_arg[0], &sigset) < 0)
1614 printsigmask(&sigset, 0);
1619 static const struct xlat ucontext_flags[] = {
1620 { UC_SIGMASK, "UC_SIGMASK" },
1621 { UC_STACK, "UC_STACK" },
1622 { UC_CPU, "UC_CPU" },
1624 { UC_FPU, "UC_FPU" },
1627 { UC_INTR, "UC_INTR" },
1631 #endif /* !FREEBSD */
1632 #endif /* SVR4 || FREEBSD */
1634 #if defined SVR4 || defined LINUX || defined FREEBSD
1635 #if defined LINUX && !defined SS_ONSTACK
1636 #define SS_ONSTACK 1
1637 #define SS_DISABLE 2
1638 #if __GLIBC_MINOR__ == 0
1648 #define stack_t struct sigaltstack
1651 static const struct xlat sigaltstack_flags[] = {
1652 { SS_ONSTACK, "SS_ONSTACK" },
1653 { SS_DISABLE, "SS_DISABLE" },
1660 printcontext(struct tcb *tcp, ucontext_t *ucp)
1664 tprintf("uc_flags=");
1665 printflags(ucontext_flags, ucp->uc_flags, "UC_???");
1666 tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link);
1668 tprintf("uc_sigmask=");
1669 printsigmask(&ucp->uc_sigmask, 0);
1671 tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=",
1672 (unsigned long) ucp->uc_stack.ss_sp,
1673 ucp->uc_stack.ss_size);
1674 printflags(sigaltstack_flags, ucp->uc_stack.ss_flags, "SS_???");
1681 sys_getcontext(struct tcb *tcp)
1687 tprintf("%#lx", tcp->u_arg[0]);
1688 else if (!tcp->u_arg[0])
1690 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1693 printcontext(tcp, &uc);
1699 sys_setcontext(struct tcb *tcp)
1703 if (entering(tcp)) {
1706 else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
1709 printcontext(tcp, &uc);
1712 tcp->u_rval = tcp->u_error = 0;
1713 if (tcp->u_arg[0] == 0)
1722 #if defined(LINUX) || defined(FREEBSD)
1725 print_stack_t(struct tcb *tcp, unsigned long addr)
1728 if (umove(tcp, addr, &ss) < 0)
1730 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
1731 printflags(sigaltstack_flags, ss.ss_flags, "SS_???");
1732 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
1737 sys_sigaltstack(struct tcb *tcp)
1739 if (entering(tcp)) {
1740 if (tcp->u_arg[0] == 0)
1742 else if (print_stack_t(tcp, tcp->u_arg[0]) < 0)
1747 if (tcp->u_arg[1] == 0)
1749 else if (print_stack_t(tcp, tcp->u_arg[1]) < 0)
1756 #ifdef HAVE_SIGACTION
1759 sys_sigprocmask(struct tcb *tcp)
1762 if (entering(tcp)) {
1763 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1765 printsigmask(tcp->u_arg[1], 0);
1767 else if (!syserror(tcp)) {
1768 tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0);
1769 return RVAL_HEX | RVAL_STR;
1772 if (entering(tcp)) {
1774 if (tcp->u_arg[0] == 0)
1778 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1780 print_sigset(tcp, tcp->u_arg[1], 0);
1786 else if (syserror(tcp))
1787 tprintf("%#lx", tcp->u_arg[2]);
1789 print_sigset(tcp, tcp->u_arg[2], 0);
1795 #endif /* HAVE_SIGACTION */
1798 sys_kill(struct tcb *tcp)
1800 if (entering(tcp)) {
1802 * Sign-extend a 32-bit value when that's what it is.
1804 long pid = tcp->u_arg[0];
1805 if (personality_wordsize[current_personality] < sizeof pid)
1806 pid = (long) (int) pid;
1807 tprintf("%ld, %s", pid, signame(tcp->u_arg[1]));
1812 #if defined(FREEBSD) || defined(SUNOS4)
1814 sys_killpg(struct tcb *tcp)
1816 return sys_kill(tcp);
1818 #endif /* FREEBSD || SUNOS4 */
1822 sys_tgkill(struct tcb *tcp)
1824 if (entering(tcp)) {
1825 tprintf("%ld, %ld, %s",
1826 tcp->u_arg[0], tcp->u_arg[1], signame(tcp->u_arg[2]));
1833 sys_sigpending(struct tcb *tcp)
1839 tprintf("%#lx", tcp->u_arg[0]);
1840 else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1843 printsigmask(&sigset, 0);
1849 int sys_sigwait(struct tcb *tcp)
1853 if (entering(tcp)) {
1854 if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0)
1857 printsigmask(&sigset, 0);
1860 if (!syserror(tcp)) {
1861 tcp->auxstr = signalent[tcp->u_rval];
1862 return RVAL_DECIMAL | RVAL_STR;
1872 sys_rt_sigprocmask(struct tcb *tcp)
1876 /* Note: arg[3] is the length of the sigset. */
1877 if (entering(tcp)) {
1878 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1882 else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0)
1883 tprintf("%#lx, ", tcp->u_arg[1]);
1885 printsigmask(&sigset, 1);
1893 else if (syserror(tcp))
1894 tprintf("%#lx", tcp->u_arg[2]);
1895 else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0)
1898 printsigmask(&sigset, 1);
1899 tprintf(", %lu", tcp->u_arg[3]);
1905 /* Structure describing the action to be taken when a signal arrives. */
1906 struct new_sigaction
1908 __sighandler_t __sa_handler;
1909 unsigned long sa_flags;
1910 void (*sa_restorer) (void);
1911 /* Kernel treats sa_mask as an array of longs. */
1912 unsigned long sa_mask[NSIG / sizeof(long) ? NSIG / sizeof(long) : 1];
1914 /* Same for i386-on-x86_64 and similar cases */
1915 struct new_sigaction32
1917 uint32_t __sa_handler;
1919 uint32_t sa_restorer;
1920 uint32_t sa_mask[2 * (NSIG / sizeof(long) ? NSIG / sizeof(long) : 1)];
1925 sys_rt_sigaction(struct tcb *tcp)
1927 struct new_sigaction sa;
1932 if (entering(tcp)) {
1933 printsignal(tcp->u_arg[0]);
1935 addr = tcp->u_arg[1];
1937 addr = tcp->u_arg[2];
1943 if (!verbose(tcp)) {
1944 tprintf("%#lx", addr);
1947 #if SUPPORTED_PERSONALITIES > 1
1948 if (personality_wordsize[current_personality] != sizeof(sa.sa_flags)
1949 && personality_wordsize[current_personality] == 4
1951 struct new_sigaction32 sa32;
1952 r = umove(tcp, addr, &sa32);
1954 memset(&sa, 0, sizeof(sa));
1955 sa.__sa_handler = (void*)(unsigned long)sa32.__sa_handler;
1956 sa.sa_flags = sa32.sa_flags;
1957 sa.sa_restorer = (void*)(unsigned long)sa32.sa_restorer;
1958 /* Kernel treats sa_mask as an array of longs.
1959 * For 32-bit process, "long" is uint32_t, thus, for example,
1960 * 32th bit in sa_mask will end up as bit 0 in sa_mask[1].
1961 * But for (64-bit) kernel, 32th bit in sa_mask is
1962 * 32th bit in 0th (64-bit) long!
1963 * For little-endian, it's the same.
1964 * For big-endian, we swap 32-bit words.
1966 sa.sa_mask[0] = sa32.sa_mask[0] + ((long)(sa32.sa_mask[1]) << 32);
1971 r = umove(tcp, addr, &sa);
1977 /* Architectures using function pointers, like
1978 * hppa, may need to manipulate the function pointer
1979 * to compute the result of a comparison. However,
1980 * the SA_HANDLER function pointer exists only in
1981 * the address space of the traced process, and can't
1982 * be manipulated by strace. In order to prevent the
1983 * compiler from generating code to manipulate
1984 * SA_HANDLER we cast the function pointers to long. */
1985 if ((long)sa.__sa_handler == (long)SIG_ERR)
1986 tprintf("{SIG_ERR, ");
1987 else if ((long)sa.__sa_handler == (long)SIG_DFL)
1988 tprintf("{SIG_DFL, ");
1989 else if ((long)sa.__sa_handler == (long)SIG_IGN)
1990 tprintf("{SIG_IGN, ");
1992 tprintf("{%#lx, ", (long) sa.__sa_handler);
1993 /* Questionable code below.
1994 * Kernel won't handle sys_rt_sigaction
1995 * with wrong sigset size (just returns EINVAL)
1996 * therefore tcp->u_arg[3(4)] _must_ be NSIG / 8 here,
1997 * and we always use smaller memcpy. */
1998 sigemptyset(&sigset);
2000 if (tcp->u_arg[4] <= sizeof(sigset))
2001 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
2003 if (tcp->u_arg[3] <= sizeof(sigset))
2004 memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
2007 memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
2008 printsigmask(&sigset, 1);
2010 printflags(sigact_flags, sa.sa_flags, "SA_???");
2012 if (sa.sa_flags & SA_RESTORER)
2013 tprintf(", %p", sa.sa_restorer);
2022 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
2023 #elif defined(ALPHA)
2024 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
2026 tprintf(", %lu", tcp->u_arg[3]);
2032 sys_rt_sigpending(struct tcb *tcp)
2038 tprintf("%#lx", tcp->u_arg[0]);
2039 else if (copy_sigset_len(tcp, tcp->u_arg[0],
2040 &sigset, tcp->u_arg[1]) < 0)
2043 printsigmask(&sigset, 1);
2049 sys_rt_sigsuspend(struct tcb *tcp)
2051 if (entering(tcp)) {
2053 if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0)
2056 printsigmask(&sigm, 1);
2062 sys_rt_sigqueueinfo(struct tcb *tcp)
2064 if (entering(tcp)) {
2066 tprintf("%lu, ", tcp->u_arg[0]);
2067 printsignal(tcp->u_arg[1]);
2069 if (umove(tcp, tcp->u_arg[2], &si) < 0)
2070 tprintf("%#lx", tcp->u_arg[2]);
2072 printsiginfo(&si, verbose(tcp));
2077 int sys_rt_sigtimedwait(struct tcb *tcp)
2079 if (entering(tcp)) {
2082 if (copy_sigset_len(tcp, tcp->u_arg[0],
2083 &sigset, tcp->u_arg[3]) < 0)
2086 printsigmask(&sigset, 1);
2088 /* This is the only "return" parameter, */
2089 if (tcp->u_arg[1] != 0)
2091 /* ... if it's NULL, can decode all on entry */
2094 else if (tcp->u_arg[1] != 0) {
2095 /* syscall exit, and u_arg[1] wasn't NULL */
2097 tprintf("%#lx, ", tcp->u_arg[1]);
2100 if (umove(tcp, tcp->u_arg[1], &si) < 0)
2101 tprintf("%#lx, ", tcp->u_arg[1]);
2103 printsiginfo(&si, verbose(tcp));
2109 /* syscall exit, and u_arg[1] was NULL */
2112 print_timespec(tcp, tcp->u_arg[2]);
2113 tprintf(", %d", (int) tcp->u_arg[3]);
2118 sys_restart_syscall(struct tcb *tcp)
2121 tprintf("<... resuming interrupted call ...>");
2126 do_signalfd(struct tcb *tcp, int flags_arg)
2128 if (entering(tcp)) {
2129 printfd(tcp, tcp->u_arg[0]);
2131 print_sigset(tcp, tcp->u_arg[1], 1);
2132 tprintf(", %lu", tcp->u_arg[2]);
2133 if (flags_arg >= 0) {
2135 printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
2142 sys_signalfd(struct tcb *tcp)
2144 return do_signalfd(tcp, -1);
2148 sys_signalfd4(struct tcb *tcp)
2150 return do_signalfd(tcp, 3);