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.
40 #elif defined(HAVE_LINUX_PTRACE_H)
41 # undef PTRACE_SYSCALL
42 # ifdef HAVE_STRUCT_IA64_FPREG
43 # define ia64_fpreg XXX_ia64_fpreg
45 # ifdef HAVE_STRUCT_PT_ALL_USER_REGS
46 # define pt_all_user_regs XXX_pt_all_user_regs
48 # ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS
49 # define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args
51 # include <linux/ptrace.h>
52 # undef ptrace_peeksiginfo_args
54 # undef pt_all_user_regs
58 # include <asm/ptrace_offsets.h>
61 #if defined(SPARC) || defined(SPARC64) || defined(MIPS)
63 struct pt_regs si_regs;
66 #elif defined HAVE_ASM_SIGCONTEXT_H
67 # if !defined(IA64) && !defined(X86_64) && !defined(X32)
68 # include <asm/sigcontext.h>
70 #else /* !HAVE_ASM_SIGCONTEXT_H */
71 # if defined M68K && !defined HAVE_STRUCT_SIGCONTEXT
73 unsigned long sc_mask;
81 unsigned short sc_formatvec;
84 #endif /* !HAVE_ASM_SIGCONTEXT_H */
87 # warning: NSIG is not defined, using 32
95 /* The libc headers do not define this constant since it should only be
96 used by the implementation. So we define it here. */
98 # ifdef ASM_SA_RESTORER
99 # define SA_RESTORER ASM_SA_RESTORER
103 /* Some arches define this in their headers, but don't actually have it,
104 so we have to delete the define. */
105 #if defined(HPPA) || defined(IA64)
109 #include "xlat/sigact_flags.h"
110 #include "xlat/sigprocmaskcmds.h"
112 #endif /* HAVE_SIGACTION */
114 /* Anonymous realtime signals. */
115 /* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
116 constant. This is what we want. Otherwise, just use SIGRTMIN. */
119 #define __SIGRTMIN SIGRTMIN
120 #define __SIGRTMAX SIGRTMAX /* likewise */
124 /* Note on the size of sigset_t:
126 * In glibc, sigset_t is an array with space for 1024 bits (!),
127 * even though all arches supported by Linux have only 64 signals
128 * except MIPS, which has 128. IOW, it is 128 bytes long.
130 * In-kernel sigset_t is sized correctly (it is either 64 or 128 bit long).
131 * However, some old syscall return only 32 lower bits (one word).
132 * Example: sys_sigpending vs sys_rt_sigpending.
134 * Be aware of this fact when you try to
135 * memcpy(&tcp->u_arg[1], &something, sizeof(sigset_t))
136 * - sizeof(sigset_t) is much bigger than you think,
137 * it may overflow tcp->u_arg[] array, and it may try to copy more data
138 * than is really available in <something>.
140 * umoven(tcp, addr, sizeof(sigset_t), &sigset)
141 * may be a bad idea: it'll try to read much more data than needed
142 * to fetch a sigset_t.
143 * Use (NSIG / 8) as a size instead.
147 signame(const int sig)
149 static char buf[sizeof("SIGRT_%u") + sizeof(int)*3];
152 const unsigned int s = sig;
157 if (s >= __SIGRTMIN && s <= __SIGRTMAX) {
158 sprintf(buf, "SIGRT_%u", s - __SIGRTMIN);
163 sprintf(buf, "%d", sig);
168 popcount32(const uint32_t *a, unsigned int size)
170 unsigned int count = 0;
172 for (; size; ++a, --size) {
175 #ifdef HAVE___BUILTIN_POPCOUNT
176 count += __builtin_popcount(x);
187 sprintsigmask_n(const char *prefix, const void *sig_mask, unsigned int bytes)
190 * The maximum number of signal names to be printed is NSIG * 2 / 3.
191 * Most of signal names have length 7,
192 * average length of signal names is less than 7.
193 * The length of prefix string does not exceed 16.
195 static char outstr[128 + 8 * (NSIG * 2 / 3)];
198 const uint32_t *mask;
199 uint32_t inverted_mask[NSIG / 32];
204 s = stpcpy(outstr, prefix);
207 /* length of signal mask in 4-byte words */
208 size = (bytes >= NSIG / 8) ? NSIG / 32 : (bytes + 3) / 4;
210 /* check whether 2/3 or more bits are set */
211 if (popcount32(mask, size) >= size * 32 * 2 / 3) {
212 /* show those signals that are NOT in the mask */
214 for (j = 0; j < size; ++j)
215 inverted_mask[j] = ~mask[j];
216 mask = inverted_mask;
221 for (i = 0; (i = next_set_bit(mask, i, size * 32)) >= 0; ) {
224 if ((unsigned) i < nsignals) {
225 s = stpcpy(s, signalent[i] + 3);
228 else if (i >= __SIGRTMIN && i <= __SIGRTMAX) {
229 s += sprintf(s, "RT_%u", i - __SIGRTMIN);
233 s += sprintf(s, "%u", i);
244 #define tprintsigmask_addr(prefix, mask) \
245 tprints(sprintsigmask_n((prefix), (mask), sizeof(mask)))
247 #define sprintsigmask_val(prefix, mask) \
248 sprintsigmask_n((prefix), &(mask), sizeof(mask))
250 #define tprintsigmask_val(prefix, mask) \
251 tprints(sprintsigmask_n((prefix), &(mask), sizeof(mask)))
256 tprints(signame(nr));
260 print_sigset_addr_len(struct tcb *tcp, long addr, long len)
268 /* Here len is usually equals NSIG / 8 or current_wordsize.
269 * But we code this defensively:
273 tprintf("%#lx", addr);
279 len = (len + 3) & ~3;
281 if (umoven(tcp, addr, len, mask) < 0)
283 tprints(sprintsigmask_n("", mask, len));
287 #define ILL_ILLOPC 1 /* illegal opcode */
288 #define ILL_ILLOPN 2 /* illegal operand */
289 #define ILL_ILLADR 3 /* illegal addressing mode */
290 #define ILL_ILLTRP 4 /* illegal trap */
291 #define ILL_PRVOPC 5 /* privileged opcode */
292 #define ILL_PRVREG 6 /* privileged register */
293 #define ILL_COPROC 7 /* coprocessor error */
294 #define ILL_BADSTK 8 /* internal stack error */
295 #define FPE_INTDIV 1 /* integer divide by zero */
296 #define FPE_INTOVF 2 /* integer overflow */
297 #define FPE_FLTDIV 3 /* floating point divide by zero */
298 #define FPE_FLTOVF 4 /* floating point overflow */
299 #define FPE_FLTUND 5 /* floating point underflow */
300 #define FPE_FLTRES 6 /* floating point inexact result */
301 #define FPE_FLTINV 7 /* floating point invalid operation */
302 #define FPE_FLTSUB 8 /* subscript out of range */
303 #define SEGV_MAPERR 1 /* address not mapped to object */
304 #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
305 #define BUS_ADRALN 1 /* invalid address alignment */
306 #define BUS_ADRERR 2 /* non-existant physical address */
307 #define BUS_OBJERR 3 /* object specific hardware error */
308 #define SYS_SECCOMP 1 /* seccomp triggered */
309 #define TRAP_BRKPT 1 /* process breakpoint */
310 #define TRAP_TRACE 2 /* process trace trap */
311 #define CLD_EXITED 1 /* child has exited */
312 #define CLD_KILLED 2 /* child was killed */
313 #define CLD_DUMPED 3 /* child terminated abnormally */
314 #define CLD_TRAPPED 4 /* traced child has trapped */
315 #define CLD_STOPPED 5 /* child has stopped */
316 #define CLD_CONTINUED 6 /* stopped child has continued */
317 #define POLL_IN 1 /* data input available */
318 #define POLL_OUT 2 /* output buffers available */
319 #define POLL_MSG 3 /* input message available */
320 #define POLL_ERR 4 /* i/o error */
321 #define POLL_PRI 5 /* high priority input available */
322 #define POLL_HUP 6 /* device disconnected */
323 #define SI_KERNEL 0x80 /* sent by kernel */
324 #define SI_USER 0 /* sent by kill, sigsend, raise */
325 #define SI_QUEUE -1 /* sent by sigqueue */
326 #define SI_TIMER -2 /* sent by timer expiration */
327 #define SI_MESGQ -3 /* sent by real time mesq state change */
328 #define SI_ASYNCIO -4 /* sent by AIO completion */
329 #define SI_SIGIO -5 /* sent by SIGIO */
330 #define SI_TKILL -6 /* sent by tkill */
331 #define SI_DETHREAD -7 /* sent by execve killing subsidiary threads */
332 #define SI_ASYNCNL -60 /* sent by asynch name lookup completion */
336 # define SI_FROMUSER(sip) ((sip)->si_code <= 0)
339 #include "xlat/siginfo_codes.h"
340 #include "xlat/sigill_codes.h"
341 #include "xlat/sigfpe_codes.h"
342 #include "xlat/sigtrap_codes.h"
343 #include "xlat/sigchld_codes.h"
344 #include "xlat/sigpoll_codes.h"
345 #include "xlat/sigprof_codes.h"
348 #include "xlat/sigemt_codes.h"
351 #include "xlat/sigsegv_codes.h"
352 #include "xlat/sigbus_codes.h"
355 # define SYS_SECCOMP 1
357 #include "xlat/sigsys_codes.h"
360 printsigsource(const siginfo_t *sip)
362 tprintf(", si_pid=%lu, si_uid=%lu",
363 (unsigned long) sip->si_pid,
364 (unsigned long) sip->si_uid);
368 printsigval(const siginfo_t *sip, int verbose)
373 tprintf(", si_value={int=%u, ptr=%#lx}",
375 (unsigned long) sip->si_ptr);
379 printsiginfo(siginfo_t *sip, int verbose)
383 if (sip->si_signo == 0) {
387 tprints("{si_signo=");
388 printsignal(sip->si_signo);
389 code = xlookup(siginfo_codes, sip->si_code);
391 switch (sip->si_signo) {
393 code = xlookup(sigtrap_codes, sip->si_code);
396 code = xlookup(sigchld_codes, sip->si_code);
399 code = xlookup(sigpoll_codes, sip->si_code);
402 code = xlookup(sigprof_codes, sip->si_code);
405 code = xlookup(sigill_codes, sip->si_code);
409 code = xlookup(sigemt_codes, sip->si_code);
413 code = xlookup(sigfpe_codes, sip->si_code);
416 code = xlookup(sigsegv_codes, sip->si_code);
419 code = xlookup(sigbus_codes, sip->si_code);
422 code = xlookup(sigsys_codes, sip->si_code);
427 tprintf(", si_code=%s", code);
429 tprintf(", si_code=%#x", sip->si_code);
431 if (sip->si_code != SI_NOINFO)
435 if (sip->si_errno < 0 || (unsigned) sip->si_errno >= nerrnos)
436 tprintf(", si_errno=%d", sip->si_errno);
438 tprintf(", si_errno=%s",
439 errnoent[sip->si_errno]);
442 if (SI_FROMUSER(sip)) {
443 switch (sip->si_code) {
456 tprintf(", si_timerid=%#x, si_overrun=%d",
457 sip->si_timerid, sip->si_overrun);
458 printsigval(sip, verbose);
464 printsigval(sip, verbose);
469 #endif /* SI_FROMUSER */
471 switch (sip->si_signo) {
474 tprints(", si_status=");
475 if (sip->si_code == CLD_EXITED)
476 tprintf("%d", sip->si_status);
478 printsignal(sip->si_status);
482 tprintf(", si_utime=%llu, si_stime=%llu",
483 (unsigned long long) sip->si_utime,
484 (unsigned long long) sip->si_stime);
486 case SIGILL: case SIGFPE:
487 case SIGSEGV: case SIGBUS:
488 tprintf(", si_addr=%#lx",
489 (unsigned long) sip->si_addr);
492 switch (sip->si_code) {
493 case POLL_IN: case POLL_OUT: case POLL_MSG:
494 tprintf(", si_band=%ld",
495 (long) sip->si_band);
499 #ifdef HAVE_SIGINFO_T_SI_SYSCALL
501 tprintf(", si_call_addr=%#lx, si_syscall=%d, si_arch=%u",
502 (unsigned long) sip->si_call_addr,
503 sip->si_syscall, sip->si_arch);
507 if (sip->si_pid || sip->si_uid)
510 printsigval(sip, verbose);
518 printsiginfo_at(struct tcb *tcp, long addr)
526 tprintf("%#lx", addr);
529 if (umove(tcp, addr, &si) < 0) {
533 printsiginfo(&si, verbose(tcp));
537 sys_sigsetmask(struct tcb *tcp)
540 tprintsigmask_val("", tcp->u_arg[0]);
542 else if (!syserror(tcp)) {
543 tcp->auxstr = sprintsigmask_val("old mask ", tcp->u_rval);
544 return RVAL_HEX | RVAL_STR;
549 #ifdef HAVE_SIGACTION
551 struct old_sigaction {
552 /* sa_handler may be a libc #define, need to use other name: */
554 unsigned int sa_flags;
555 void (*__sa_handler)(int);
556 /* Kernel treats sa_mask as an array of longs. */
557 unsigned long sa_mask[NSIG / sizeof(long) ? NSIG / sizeof(long) : 1];
559 void (*__sa_handler)(int);
560 unsigned long sa_mask;
561 unsigned long sa_flags;
562 void (*sa_restorer)(void);
566 struct old_sigaction32 {
567 /* sa_handler may be a libc #define, need to use other name: */
568 uint32_t __sa_handler;
571 uint32_t sa_restorer;
575 decode_old_sigaction(struct tcb *tcp, long addr)
577 struct old_sigaction sa;
584 if (!verbose(tcp) || (exiting(tcp) && syserror(tcp))) {
585 tprintf("%#lx", addr);
589 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
590 if (current_wordsize != sizeof(sa.__sa_handler) && current_wordsize == 4) {
591 struct old_sigaction32 sa32;
592 r = umove(tcp, addr, &sa32);
594 memset(&sa, 0, sizeof(sa));
595 sa.__sa_handler = (void*)(uintptr_t)sa32.__sa_handler;
596 sa.sa_flags = sa32.sa_flags;
597 sa.sa_restorer = (void*)(uintptr_t)sa32.sa_restorer;
598 sa.sa_mask = sa32.sa_mask;
603 r = umove(tcp, addr, &sa);
610 /* Architectures using function pointers, like
611 * hppa, may need to manipulate the function pointer
612 * to compute the result of a comparison. However,
613 * the __sa_handler function pointer exists only in
614 * the address space of the traced process, and can't
615 * be manipulated by strace. In order to prevent the
616 * compiler from generating code to manipulate
617 * __sa_handler we cast the function pointers to long. */
618 if ((long)sa.__sa_handler == (long)SIG_ERR)
619 tprints("{SIG_ERR, ");
620 else if ((long)sa.__sa_handler == (long)SIG_DFL)
621 tprints("{SIG_DFL, ");
622 else if ((long)sa.__sa_handler == (long)SIG_IGN)
623 tprints("{SIG_IGN, ");
625 tprintf("{%#lx, ", (long) sa.__sa_handler);
627 tprintsigmask_addr("", sa.sa_mask);
629 tprintsigmask_val("", sa.sa_mask);
632 printflags(sigact_flags, sa.sa_flags, "SA_???");
634 if (sa.sa_flags & SA_RESTORER)
635 tprintf(", %p", sa.sa_restorer);
641 sys_sigaction(struct tcb *tcp)
644 printsignal(tcp->u_arg[0]);
646 decode_old_sigaction(tcp, tcp->u_arg[1]);
649 decode_old_sigaction(tcp, tcp->u_arg[2]);
654 sys_signal(struct tcb *tcp)
657 printsignal(tcp->u_arg[0]);
659 switch (tcp->u_arg[1]) {
670 tprintf("%#lx", tcp->u_arg[1]);
674 else if (!syserror(tcp)) {
675 switch (tcp->u_rval) {
677 tcp->auxstr = "SIG_ERR"; break;
679 tcp->auxstr = "SIG_DFL"; break;
681 tcp->auxstr = "SIG_IGN"; break;
685 return RVAL_HEX | RVAL_STR;
690 #endif /* HAVE_SIGACTION */
693 sys_sigreturn(struct tcb *tcp)
697 struct arm_sigcontext {
698 unsigned long trap_no;
699 unsigned long error_code;
700 unsigned long oldmask;
701 unsigned long arm_r0;
702 unsigned long arm_r1;
703 unsigned long arm_r2;
704 unsigned long arm_r3;
705 unsigned long arm_r4;
706 unsigned long arm_r5;
707 unsigned long arm_r6;
708 unsigned long arm_r7;
709 unsigned long arm_r8;
710 unsigned long arm_r9;
711 unsigned long arm_r10;
712 unsigned long arm_fp;
713 unsigned long arm_ip;
714 unsigned long arm_sp;
715 unsigned long arm_lr;
716 unsigned long arm_pc;
717 unsigned long arm_cpsr;
718 unsigned long fault_address;
720 struct arm_ucontext {
721 unsigned long uc_flags;
722 unsigned long uc_link; /* struct ucontext* */
723 /* The next three members comprise stack_t struct: */
724 unsigned long ss_sp; /* void* */
725 unsigned long ss_flags; /* int */
726 unsigned long ss_size; /* size_t */
727 struct arm_sigcontext sc;
728 /* These two members are sigset_t: */
729 unsigned long uc_sigmask[2];
730 /* more fields follow, which we aren't interested in */
732 struct arm_ucontext uc;
733 if (umove(tcp, arm_regs.ARM_sp, &uc) < 0)
736 * Kernel fills out uc.sc.oldmask too when it sets up signal stack,
737 * but for sigmask restore, sigreturn syscall uses uc.uc_sigmask instead.
739 tprintsigmask_addr(") (mask ", uc.uc_sigmask);
741 #elif defined(S390) || defined(S390X)
744 struct sigcontext sc;
745 if (upeek(tcp->pid, PT_GPR15, &usp) < 0)
747 if (umove(tcp, usp + __SIGNAL_FRAMESIZE, &sc) < 0)
749 tprintsigmask_addr(") (mask ", sc.oldmask);
751 #elif defined(I386) || defined(X86_64)
753 if (current_personality == 0) /* 64-bit */
757 struct i386_sigcontext_struct {
775 uint32_t esp_at_signal;
781 struct i386_fpstate {
789 uint8_t st[8][10]; /* 8*10 bytes: FP regs */
792 uint32_t fxsr_env[6];
795 uint8_t stx[8][16]; /* 8*16 bytes: FP regs, each padded to 16 bytes */
796 uint8_t xmm[8][16]; /* 8 XMM regs */
797 uint32_t padding1[44];
798 uint32_t padding2[12]; /* union with struct _fpx_sw_bytes */
801 struct i386_sigcontext_struct sc;
802 struct i386_fpstate fp;
803 uint32_t extramask[1];
805 /* On i386, sc is followed on stack by struct fpstate
806 * and after it an additional u32 extramask[1] which holds
807 * upper half of the mask.
810 if (umove(tcp, *i386_esp_ptr, &signal_stack) < 0)
812 sigmask[0] = signal_stack.sc.oldmask;
813 sigmask[1] = signal_stack.extramask[0];
814 tprintsigmask_addr(") (mask ", sigmask);
818 struct sigcontext sc;
820 /* offset of sigcontext in the kernel's sigframe structure: */
821 # define SIGFRAME_SC_OFFSET 0x90
822 if (upeek(tcp->pid, PT_R12, &sp) < 0)
824 if (umove(tcp, sp + 16 + SIGFRAME_SC_OFFSET, &sc) < 0)
826 tprintsigmask_val(") (mask ", sc.sc_mask);
828 #elif defined(POWERPC)
831 struct sigcontext sc;
833 esp = ppc_regs.gpr[1];
835 /* Skip dummy stack frame. */
837 if (current_personality == 0)
844 if (umove(tcp, esp, &sc) < 0)
846 tprintsigmask_val(") (mask ", sc.oldmask);
851 struct sigcontext sc;
852 if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
854 if (umove(tcp, usp, &sc) < 0)
856 tprintsigmask_val(") (mask ", sc.sc_mask);
861 struct sigcontext sc;
862 if (upeek(tcp->pid, REG_FP, &fp) < 0)
864 if (umove(tcp, fp, &sc) < 0)
866 tprintsigmask_val(") (mask ", sc.sc_mask);
868 #elif defined(SPARC) || defined(SPARC64)
872 i1 = sparc_regs.u_regs[U_REG_O1];
873 if (umove(tcp, i1, &si) < 0) {
874 perror_msg("sigreturn: umove");
877 tprintsigmask_val(") (mask ", si.si_mask);
879 #elif defined(LINUX_MIPSN32) || defined(LINUX_MIPSN64)
880 /* This decodes rt_sigreturn. The 64-bit ABIs do not have
885 if (upeek(tcp->pid, REG_SP, &sp) < 0)
887 /* There are six words followed by a 128-byte siginfo. */
888 sp = sp + 6 * 4 + 128;
889 if (umove(tcp, sp, &uc) < 0)
891 tprintsigmask_val(") (mask ", uc.uc_sigmask);
898 if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
899 perror_msg("sigreturn: PTRACE_GETREGS");
903 if (umove(tcp, sp, &si) < 0)
905 tprintsigmask_val(") (mask ", si.si_mask);
907 #elif defined(CRISV10) || defined(CRISV32)
909 struct sigcontext sc;
911 if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, (long)regs) < 0) {
912 perror_msg("sigreturn: PTRACE_GETREGS");
915 if (umove(tcp, regs[PT_USP], &sc) < 0)
917 tprintsigmask_val(") (mask ", sc.oldmask);
923 /* offset of ucontext in the kernel's sigframe structure */
924 # define SIGFRAME_UC_OFFSET C_ABI_SAVE_AREA_SIZE + sizeof(siginfo_t)
925 if (umove(tcp, tile_regs.sp + SIGFRAME_UC_OFFSET, &uc) < 0)
927 tprintsigmask_val(") (mask ", uc.uc_sigmask);
929 #elif defined(MICROBLAZE)
930 /* TODO: Verify that this is correct... */
932 struct sigcontext sc;
934 /* Read r1, the stack pointer. */
935 if (upeek(tcp->pid, 1 * 4, &sp) < 0)
937 if (umove(tcp, sp, &sc) < 0)
939 tprintsigmask_val(") (mask ", sc.oldmask);
941 #elif defined(XTENSA)
942 /* Xtensa only has rt_sys_sigreturn */
944 /* ARC syscall ABI only supports rt_sys_sigreturn */
946 # warning No sys_sigreturn() for this architecture
947 # warning (no problem, just a reminder :-)
953 sys_siggetmask(struct tcb *tcp)
956 tcp->auxstr = sprintsigmask_val("mask ", tcp->u_rval);
958 return RVAL_HEX | RVAL_STR;
962 sys_sigsuspend(struct tcb *tcp)
965 tprintsigmask_val("", tcp->u_arg[2]);
970 #if !defined SS_ONSTACK
975 #include "xlat/sigaltstack_flags.h"
978 print_stack_t(struct tcb *tcp, unsigned long addr)
988 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
989 if (current_wordsize != sizeof(ss.ss_sp) && current_wordsize == 4) {
995 r = umove(tcp, addr, &ss32);
997 memset(&ss, 0, sizeof(ss));
998 ss.ss_sp = (void*)(unsigned long) ss32.ss_sp;
999 ss.ss_flags = ss32.ss_flags;
1000 ss.ss_size = (unsigned long) ss32.ss_size;
1005 r = umove(tcp, addr, &ss);
1008 tprintf("%#lx", addr);
1010 tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
1011 printflags(sigaltstack_flags, ss.ss_flags, "SS_???");
1012 tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size);
1017 sys_sigaltstack(struct tcb *tcp)
1019 if (entering(tcp)) {
1020 print_stack_t(tcp, tcp->u_arg[0]);
1024 print_stack_t(tcp, tcp->u_arg[1]);
1029 #ifdef HAVE_SIGACTION
1031 /* "Old" sigprocmask, which operates with word-sized signal masks */
1033 sys_sigprocmask(struct tcb *tcp)
1036 if (entering(tcp)) {
1038 * Alpha/OSF is different: it doesn't pass in two pointers,
1039 * but rather passes in the new bitmask as an argument and
1040 * then returns the old bitmask. This "works" because we
1041 * only have 64 signals to worry about. If you want more,
1042 * use of the rt_sigprocmask syscall is required.
1044 * old = osf_sigprocmask(how, new);
1046 * ret = sigprocmask(how, &new, &old, ...);
1048 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1049 tprintsigmask_val(", ", tcp->u_arg[1]);
1051 else if (!syserror(tcp)) {
1052 tcp->auxstr = sprintsigmask_val("old mask ", tcp->u_rval);
1053 return RVAL_HEX | RVAL_STR;
1056 if (entering(tcp)) {
1057 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1059 print_sigset_addr_len(tcp, tcp->u_arg[1], current_wordsize);
1064 tprintf("%#lx", tcp->u_arg[2]);
1066 print_sigset_addr_len(tcp, tcp->u_arg[2], current_wordsize);
1068 # endif /* !ALPHA */
1072 #endif /* HAVE_SIGACTION */
1075 sys_kill(struct tcb *tcp)
1077 if (entering(tcp)) {
1079 widen_to_long(tcp->u_arg[0]),
1080 signame(tcp->u_arg[1])
1087 sys_tgkill(struct tcb *tcp)
1089 if (entering(tcp)) {
1090 tprintf("%ld, %ld, %s",
1091 widen_to_long(tcp->u_arg[0]),
1092 widen_to_long(tcp->u_arg[1]),
1093 signame(tcp->u_arg[2])
1100 sys_sigpending(struct tcb *tcp)
1104 tprintf("%#lx", tcp->u_arg[0]);
1106 print_sigset_addr_len(tcp, tcp->u_arg[0], current_wordsize);
1112 sys_rt_sigprocmask(struct tcb *tcp)
1114 /* Note: arg[3] is the length of the sigset. Kernel requires NSIG / 8 */
1115 if (entering(tcp)) {
1116 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
1118 print_sigset_addr_len(tcp, tcp->u_arg[1], tcp->u_arg[3]);
1123 tprintf("%#lx", tcp->u_arg[2]);
1125 print_sigset_addr_len(tcp, tcp->u_arg[2], tcp->u_arg[3]);
1126 tprintf(", %lu", tcp->u_arg[3]);
1131 /* Structure describing the action to be taken when a signal arrives. */
1132 struct new_sigaction
1134 /* sa_handler may be a libc #define, need to use other name: */
1136 unsigned int sa_flags;
1137 void (*__sa_handler)(int);
1139 void (*__sa_handler)(int);
1140 unsigned long sa_flags;
1141 # if !defined(ALPHA) && !defined(HPPA) && !defined(IA64)
1142 void (*sa_restorer)(void);
1143 # endif /* !ALPHA && !HPPA && !IA64 */
1145 /* Kernel treats sa_mask as an array of longs. */
1146 unsigned long sa_mask[NSIG / sizeof(long) ? NSIG / sizeof(long) : 1];
1148 /* Same for i386-on-x86_64 and similar cases */
1149 struct new_sigaction32
1151 uint32_t __sa_handler;
1153 uint32_t sa_restorer;
1154 uint32_t sa_mask[2 * (NSIG / sizeof(long) ? NSIG / sizeof(long) : 1)];
1158 decode_new_sigaction(struct tcb *tcp, long addr)
1160 struct new_sigaction sa;
1167 if (!verbose(tcp) || (exiting(tcp) && syserror(tcp))) {
1168 tprintf("%#lx", addr);
1171 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
1172 if (current_wordsize != sizeof(sa.sa_flags) && current_wordsize == 4) {
1173 struct new_sigaction32 sa32;
1174 r = umove(tcp, addr, &sa32);
1176 memset(&sa, 0, sizeof(sa));
1177 sa.__sa_handler = (void*)(unsigned long)sa32.__sa_handler;
1178 sa.sa_flags = sa32.sa_flags;
1179 sa.sa_restorer = (void*)(unsigned long)sa32.sa_restorer;
1180 /* Kernel treats sa_mask as an array of longs.
1181 * For 32-bit process, "long" is uint32_t, thus, for example,
1182 * 32th bit in sa_mask will end up as bit 0 in sa_mask[1].
1183 * But for (64-bit) kernel, 32th bit in sa_mask is
1184 * 32th bit in 0th (64-bit) long!
1185 * For little-endian, it's the same.
1186 * For big-endian, we swap 32-bit words.
1188 sa.sa_mask[0] = sa32.sa_mask[0] + ((long)(sa32.sa_mask[1]) << 32);
1193 r = umove(tcp, addr, &sa);
1199 /* Architectures using function pointers, like
1200 * hppa, may need to manipulate the function pointer
1201 * to compute the result of a comparison. However,
1202 * the __sa_handler function pointer exists only in
1203 * the address space of the traced process, and can't
1204 * be manipulated by strace. In order to prevent the
1205 * compiler from generating code to manipulate
1206 * __sa_handler we cast the function pointers to long. */
1207 if ((long)sa.__sa_handler == (long)SIG_ERR)
1208 tprints("{SIG_ERR, ");
1209 else if ((long)sa.__sa_handler == (long)SIG_DFL)
1210 tprints("{SIG_DFL, ");
1211 else if ((long)sa.__sa_handler == (long)SIG_IGN)
1212 tprints("{SIG_IGN, ");
1214 tprintf("{%#lx, ", (long) sa.__sa_handler);
1216 * Sigset size is in tcp->u_arg[4] (SPARC)
1217 * or in tcp->u_arg[3] (all other),
1218 * but kernel won't handle sys_rt_sigaction
1219 * with wrong sigset size (just returns EINVAL instead).
1220 * We just fetch the right size, which is NSIG / 8.
1222 tprintsigmask_val("", sa.sa_mask);
1225 printflags(sigact_flags, sa.sa_flags, "SA_???");
1227 if (sa.sa_flags & SA_RESTORER)
1228 tprintf(", %p", sa.sa_restorer);
1234 sys_rt_sigaction(struct tcb *tcp)
1236 if (entering(tcp)) {
1237 printsignal(tcp->u_arg[0]);
1239 decode_new_sigaction(tcp, tcp->u_arg[1]);
1242 decode_new_sigaction(tcp, tcp->u_arg[2]);
1243 #if defined(SPARC) || defined(SPARC64)
1244 tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
1245 #elif defined(ALPHA)
1246 tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
1248 tprintf(", %lu", tcp->u_arg[3]);
1255 sys_rt_sigpending(struct tcb *tcp)
1259 * One of the few syscalls where sigset size (arg[1])
1260 * is allowed to be <= NSIG / 8, not strictly ==.
1261 * This allows non-rt sigpending() syscall
1262 * to reuse rt_sigpending() code in kernel.
1265 tprintf("%#lx", tcp->u_arg[0]);
1267 print_sigset_addr_len(tcp, tcp->u_arg[0], tcp->u_arg[1]);
1268 tprintf(", %lu", tcp->u_arg[1]);
1274 sys_rt_sigsuspend(struct tcb *tcp)
1276 if (entering(tcp)) {
1277 /* NB: kernel requires arg[1] == NSIG / 8 */
1278 print_sigset_addr_len(tcp, tcp->u_arg[0], tcp->u_arg[1]);
1279 tprintf(", %lu", tcp->u_arg[1]);
1285 print_sigqueueinfo(struct tcb *tcp, int sig, unsigned long uinfo)
1289 printsiginfo_at(tcp, uinfo);
1293 sys_rt_sigqueueinfo(struct tcb *tcp)
1295 if (entering(tcp)) {
1296 tprintf("%lu, ", tcp->u_arg[0]);
1297 print_sigqueueinfo(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1303 sys_rt_tgsigqueueinfo(struct tcb *tcp)
1305 if (entering(tcp)) {
1306 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
1307 print_sigqueueinfo(tcp, tcp->u_arg[2], tcp->u_arg[3]);
1312 int sys_rt_sigtimedwait(struct tcb *tcp)
1314 /* NB: kernel requires arg[3] == NSIG / 8 */
1315 if (entering(tcp)) {
1316 print_sigset_addr_len(tcp, tcp->u_arg[0], tcp->u_arg[3]);
1318 /* This is the only "return" parameter, */
1319 if (tcp->u_arg[1] != 0)
1321 /* ... if it's NULL, can decode all on entry */
1324 else if (tcp->u_arg[1] != 0) {
1325 /* syscall exit, and u_arg[1] wasn't NULL */
1326 printsiginfo_at(tcp, tcp->u_arg[1]);
1330 /* syscall exit, and u_arg[1] was NULL */
1333 print_timespec(tcp, tcp->u_arg[2]);
1334 tprintf(", %lu", tcp->u_arg[3]);
1339 sys_restart_syscall(struct tcb *tcp)
1342 tprints("<... resuming interrupted call ...>");
1347 do_signalfd(struct tcb *tcp, int flags_arg)
1349 /* NB: kernel requires arg[2] == NSIG / 8 */
1350 if (entering(tcp)) {
1351 printfd(tcp, tcp->u_arg[0]);
1353 print_sigset_addr_len(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1354 tprintf(", %lu", tcp->u_arg[2]);
1355 if (flags_arg >= 0) {
1357 printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
1364 sys_signalfd(struct tcb *tcp)
1366 return do_signalfd(tcp, -1);
1370 sys_signalfd4(struct tcb *tcp)
1372 return do_signalfd(tcp, 3);