# endif
#endif
-static const struct xlat sigact_flags[] = {
-#ifdef SA_RESTORER
- XLAT(SA_RESTORER),
-#endif
-#ifdef SA_STACK
- XLAT(SA_STACK),
-#endif
-#ifdef SA_RESTART
- XLAT(SA_RESTART),
-#endif
-#ifdef SA_INTERRUPT
- XLAT(SA_INTERRUPT),
-#endif
-#ifdef SA_NODEFER
- XLAT(SA_NODEFER),
-#endif
-#if defined SA_NOMASK && SA_NODEFER != SA_NOMASK
- XLAT(SA_NOMASK),
-#endif
-#ifdef SA_RESETHAND
- XLAT(SA_RESETHAND),
-#endif
-#if defined SA_ONESHOT && SA_ONESHOT != SA_RESETHAND
- XLAT(SA_ONESHOT),
-#endif
-#ifdef SA_SIGINFO
- XLAT(SA_SIGINFO),
-#endif
-#ifdef SA_RESETHAND
- XLAT(SA_RESETHAND),
-#endif
-#ifdef SA_ONSTACK
- XLAT(SA_ONSTACK),
-#endif
-#ifdef SA_NODEFER
- XLAT(SA_NODEFER),
-#endif
-#ifdef SA_NOCLDSTOP
- XLAT(SA_NOCLDSTOP),
-#endif
-#ifdef SA_NOCLDWAIT
- XLAT(SA_NOCLDWAIT),
-#endif
-#ifdef _SA_BSDCALL
- XLAT(_SA_BSDCALL),
-#endif
-#ifdef SA_NOPTRACE
- XLAT(SA_NOPTRACE),
+/* Some arches define this in their headers, but don't actually have it,
+ so we have to delete the define. */
+#if defined(HPPA) || defined(IA64)
+# undef SA_RESTORER
#endif
- XLAT_END
-};
-static const struct xlat sigprocmaskcmds[] = {
- XLAT(SIG_BLOCK),
- XLAT(SIG_UNBLOCK),
- XLAT(SIG_SETMASK),
-#ifdef SIG_SETMASK32
- XLAT(SIG_SETMASK32),
-#endif
- XLAT_END
-};
+#include "xlat/sigact_flags.h"
+#include "xlat/sigprocmaskcmds.h"
#endif /* HAVE_SIGACTION */
*/
const char *
-signame(int sig)
+signame(const int sig)
{
- static char buf[sizeof("SIGRT_%d") + sizeof(int)*3];
+ static char buf[sizeof("SIGRT_%u") + sizeof(int)*3];
+
+ if (sig >= 0) {
+ const unsigned int s = sig;
- if (sig >= 0 && sig < nsignals)
- return signalent[sig];
+ if (s < nsignals)
+ return signalent[s];
#ifdef SIGRTMIN
- if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) {
- sprintf(buf, "SIGRT_%d", (int)(sig - __SIGRTMIN));
- return buf;
- }
+ if (s >= __SIGRTMIN && s <= __SIGRTMAX) {
+ sprintf(buf, "SIGRT_%u", s - __SIGRTMIN);
+ return buf;
+ }
#endif
+ }
sprintf(buf, "%d", sig);
return buf;
}
for (i = 0; (i = next_set_bit(mask, i, size * 32)) >= 0; ) {
++i;
*s++ = sep;
- if (i < nsignals) {
+ if ((unsigned) i < nsignals) {
s = stpcpy(s, signalent[i] + 3);
}
#ifdef SIGRTMIN
#define BUS_ADRALN 1 /* invalid address alignment */
#define BUS_ADRERR 2 /* non-existant physical address */
#define BUS_OBJERR 3 /* object specific hardware error */
+#define SYS_SECCOMP 1 /* seccomp triggered */
#define TRAP_BRKPT 1 /* process breakpoint */
#define TRAP_TRACE 2 /* process trace trap */
#define CLD_EXITED 1 /* child has exited */
#define SI_ASYNCIO -4 /* sent by AIO completion */
#define SI_SIGIO -5 /* sent by SIGIO */
#define SI_TKILL -6 /* sent by tkill */
+#define SI_DETHREAD -7 /* sent by execve killing subsidiary threads */
#define SI_ASYNCNL -60 /* sent by asynch name lookup completion */
#endif
# define SI_FROMUSER(sip) ((sip)->si_code <= 0)
#endif
-static const struct xlat siginfo_codes[] = {
-#ifdef SI_KERNEL
- XLAT(SI_KERNEL),
-#endif
-#ifdef SI_USER
- XLAT(SI_USER),
-#endif
-#ifdef SI_QUEUE
- XLAT(SI_QUEUE),
-#endif
-#ifdef SI_TIMER
- XLAT(SI_TIMER),
-#endif
-#ifdef SI_MESGQ
- XLAT(SI_MESGQ),
-#endif
-#ifdef SI_ASYNCIO
- XLAT(SI_ASYNCIO),
-#endif
-#ifdef SI_SIGIO
- XLAT(SI_SIGIO),
-#endif
-#ifdef SI_TKILL
- XLAT(SI_TKILL),
-#endif
-#ifdef SI_ASYNCNL
- XLAT(SI_ASYNCNL),
-#endif
-#ifdef SI_NOINFO
- XLAT(SI_NOINFO),
-#endif
-#ifdef SI_LWP
- XLAT(SI_LWP),
-#endif
- XLAT_END
-};
-
-static const struct xlat sigill_codes[] = {
- XLAT(ILL_ILLOPC),
- XLAT(ILL_ILLOPN),
- XLAT(ILL_ILLADR),
- XLAT(ILL_ILLTRP),
- XLAT(ILL_PRVOPC),
- XLAT(ILL_PRVREG),
- XLAT(ILL_COPROC),
- XLAT(ILL_BADSTK),
- XLAT_END
-};
-
-static const struct xlat sigfpe_codes[] = {
- XLAT(FPE_INTDIV),
- XLAT(FPE_INTOVF),
- XLAT(FPE_FLTDIV),
- XLAT(FPE_FLTOVF),
- XLAT(FPE_FLTUND),
- XLAT(FPE_FLTRES),
- XLAT(FPE_FLTINV),
- XLAT(FPE_FLTSUB),
- XLAT_END
-};
-
-static const struct xlat sigtrap_codes[] = {
- XLAT(TRAP_BRKPT),
- XLAT(TRAP_TRACE),
- XLAT_END
-};
-
-static const struct xlat sigchld_codes[] = {
- XLAT(CLD_EXITED),
- XLAT(CLD_KILLED),
- XLAT(CLD_DUMPED),
- XLAT(CLD_TRAPPED),
- XLAT(CLD_STOPPED),
- XLAT(CLD_CONTINUED),
- XLAT_END
-};
-
-static const struct xlat sigpoll_codes[] = {
- XLAT(POLL_IN),
- XLAT(POLL_OUT),
- XLAT(POLL_MSG),
- XLAT(POLL_ERR),
- XLAT(POLL_PRI),
- XLAT(POLL_HUP),
- XLAT_END
-};
-
-static const struct xlat sigprof_codes[] = {
-#ifdef PROF_SIG
- XLAT(PROF_SIG),
-#endif
- XLAT_END
-};
+#include "xlat/siginfo_codes.h"
+#include "xlat/sigill_codes.h"
+#include "xlat/sigfpe_codes.h"
+#include "xlat/sigtrap_codes.h"
+#include "xlat/sigchld_codes.h"
+#include "xlat/sigpoll_codes.h"
+#include "xlat/sigprof_codes.h"
#ifdef SIGEMT
-static const struct xlat sigemt_codes[] = {
-#ifdef EMT_TAGOVF
- XLAT(EMT_TAGOVF),
+#include "xlat/sigemt_codes.h"
#endif
- XLAT_END
-};
+
+#include "xlat/sigsegv_codes.h"
+#include "xlat/sigbus_codes.h"
+
+#ifndef SYS_SECCOMP
+# define SYS_SECCOMP 1
#endif
+#include "xlat/sigsys_codes.h"
-static const struct xlat sigsegv_codes[] = {
- XLAT(SEGV_MAPERR),
- XLAT(SEGV_ACCERR),
- XLAT_END
-};
+static void
+printsigsource(const siginfo_t *sip)
+{
+ tprintf(", si_pid=%lu, si_uid=%lu",
+ (unsigned long) sip->si_pid,
+ (unsigned long) sip->si_uid);
+}
-static const struct xlat sigbus_codes[] = {
- XLAT(BUS_ADRALN),
- XLAT(BUS_ADRERR),
- XLAT(BUS_OBJERR),
- XLAT_END
-};
+static void
+printsigval(const siginfo_t *sip, int verbose)
+{
+ if (!verbose)
+ tprints(", ...");
+ else
+ tprintf(", si_value={int=%u, ptr=%#lx}",
+ sip->si_int,
+ (unsigned long) sip->si_ptr);
+}
void
printsiginfo(siginfo_t *sip, int verbose)
case SIGBUS:
code = xlookup(sigbus_codes, sip->si_code);
break;
+ case SIGSYS:
+ code = xlookup(sigsys_codes, sip->si_code);
+ break;
}
}
if (code)
#endif
{
if (sip->si_errno) {
- if (sip->si_errno < 0 || sip->si_errno >= nerrnos)
+ if (sip->si_errno < 0 || (unsigned) sip->si_errno >= nerrnos)
tprintf(", si_errno=%d", sip->si_errno);
else
tprintf(", si_errno=%s",
}
#ifdef SI_FROMUSER
if (SI_FROMUSER(sip)) {
- tprintf(", si_pid=%lu, si_uid=%lu",
- (unsigned long) sip->si_pid,
- (unsigned long) sip->si_uid);
switch (sip->si_code) {
#ifdef SI_USER
case SI_USER:
+ printsigsource(sip);
break;
#endif
#ifdef SI_TKILL
case SI_TKILL:
+ printsigsource(sip);
break;
#endif
#ifdef SI_TIMER
case SI_TIMER:
- tprintf(", si_value=%d", sip->si_int);
+ tprintf(", si_timerid=%#x, si_overrun=%d",
+ sip->si_timerid, sip->si_overrun);
+ printsigval(sip, verbose);
break;
#endif
default:
- if (!sip->si_ptr)
- break;
- if (!verbose)
- tprints(", ...");
- else
- tprintf(", si_value={int=%u, ptr=%#lx}",
- sip->si_int,
- (unsigned long) sip->si_ptr);
+ printsigsource(sip);
+ if (sip->si_ptr)
+ printsigval(sip, verbose);
break;
}
}
{
switch (sip->si_signo) {
case SIGCHLD:
- tprintf(", si_pid=%ld, si_status=",
- (long) sip->si_pid);
+ printsigsource(sip);
+ tprints(", si_status=");
if (sip->si_code == CLD_EXITED)
tprintf("%d", sip->si_status);
else
break;
}
break;
+#ifdef HAVE_SIGINFO_T_SI_SYSCALL
+ case SIGSYS:
+ tprintf(", si_call_addr=%#lx, si_syscall=%d, si_arch=%u",
+ (unsigned long) sip->si_call_addr,
+ sip->si_syscall, sip->si_arch);
+ break;
+#endif
default:
if (sip->si_pid || sip->si_uid)
- tprintf(", si_pid=%lu, si_uid=%lu",
- (unsigned long) sip->si_pid,
- (unsigned long) sip->si_uid);
- if (!sip->si_ptr)
- break;
- if (!verbose)
- tprints(", ...");
- else {
- tprintf(", si_value={int=%u, ptr=%#lx}",
- sip->si_int,
- (unsigned long) sip->si_ptr);
- }
-
+ printsigsource(sip);
+ if (sip->si_ptr)
+ printsigval(sip, verbose);
}
}
}
void (*__sa_handler)(int);
unsigned long sa_mask;
unsigned long sa_flags;
- void (*sa_restorer)(void);
#endif /* !MIPS */
+#ifdef SA_RESTORER
+ void (*sa_restorer)(void);
+#endif
+};
+
+struct old_sigaction32 {
+ /* sa_handler may be a libc #define, need to use other name: */
+ uint32_t __sa_handler;
+ uint32_t sa_mask;
+ uint32_t sa_flags;
+#ifdef SA_RESTORER
+ uint32_t sa_restorer;
+#endif
};
static void
decode_old_sigaction(struct tcb *tcp, long addr)
{
struct old_sigaction sa;
+ int r;
if (!addr) {
tprints("NULL");
tprintf("%#lx", addr);
return;
}
- if (umove(tcp, addr, &sa) < 0) {
+
+#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
+ if (current_wordsize != sizeof(sa.__sa_handler) && current_wordsize == 4) {
+ struct old_sigaction32 sa32;
+ r = umove(tcp, addr, &sa32);
+ if (r >= 0) {
+ memset(&sa, 0, sizeof(sa));
+ sa.__sa_handler = (void*)(uintptr_t)sa32.__sa_handler;
+ sa.sa_flags = sa32.sa_flags;
+#ifdef SA_RESTORER
+ sa.sa_restorer = (void*)(uintptr_t)sa32.sa_restorer;
+#endif
+ sa.sa_mask = sa32.sa_mask;
+ }
+ } else
+#endif
+ {
+ r = umove(tcp, addr, &sa);
+ }
+ if (r < 0) {
tprints("{...}");
return;
}
#define SS_DISABLE 2
#endif
-static const struct xlat sigaltstack_flags[] = {
- XLAT(SS_ONSTACK),
- XLAT(SS_DISABLE),
- XLAT_END
-};
+#include "xlat/sigaltstack_flags.h"
static void
print_stack_t(struct tcb *tcp, unsigned long addr)
{
stack_t ss;
+ int r;
if (!addr) {
tprints("NULL");
- } else if (umove(tcp, addr, &ss) < 0) {
+ return;
+ }
+
+#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
+ if (current_wordsize != sizeof(ss.ss_sp) && current_wordsize == 4) {
+ struct {
+ uint32_t ss_sp;
+ int32_t ss_flags;
+ uint32_t ss_size;
+ } ss32;
+ r = umove(tcp, addr, &ss32);
+ if (r >= 0) {
+ memset(&ss, 0, sizeof(ss));
+ ss.ss_sp = (void*)(unsigned long) ss32.ss_sp;
+ ss.ss_flags = ss32.ss_flags;
+ ss.ss_size = (unsigned long) ss32.ss_size;
+ }
+ } else
+#endif
+ {
+ r = umove(tcp, addr, &ss);
+ }
+ if (r < 0) {
tprintf("%#lx", addr);
} else {
tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp);
#else
void (*__sa_handler)(int);
unsigned long sa_flags;
- void (*sa_restorer)(void);
#endif /* !MIPS */
+#ifdef SA_RESTORER
+ void (*sa_restorer)(void);
+#endif
/* Kernel treats sa_mask as an array of longs. */
unsigned long sa_mask[NSIG / sizeof(long) ? NSIG / sizeof(long) : 1];
};
{
uint32_t __sa_handler;
uint32_t sa_flags;
+#ifdef SA_RESTORER
uint32_t sa_restorer;
+#endif
uint32_t sa_mask[2 * (NSIG / sizeof(long) ? NSIG / sizeof(long) : 1)];
};
memset(&sa, 0, sizeof(sa));
sa.__sa_handler = (void*)(unsigned long)sa32.__sa_handler;
sa.sa_flags = sa32.sa_flags;
+#ifdef SA_RESTORER
sa.sa_restorer = (void*)(unsigned long)sa32.sa_restorer;
+#endif
/* Kernel treats sa_mask as an array of longs.
* For 32-bit process, "long" is uint32_t, thus, for example,
* 32th bit in sa_mask will end up as bit 0 in sa_mask[1].