#define MA MAX_ARGS
#define SI STACKTRACE_INVALIDATE_CACHE
#define SE STACKTRACE_CAPTURE_ON_ENTER
+#define CST COMPAT_SYSCALL_TYPES
#define SEN(syscall_name) SEN_ ## syscall_name, SYS_FUNC_NAME(sys_ ## syscall_name)
#undef MA
#undef SI
#undef SE
+#undef CST
/*
* `ioctlent[012].h' files are automatically generated by the auxiliary
};
# endif
+# ifndef current_klongsize
+unsigned current_klongsize;
+static const int personality_klongsize[SUPPORTED_PERSONALITIES] = {
+ PERSONALITY0_KLONGSIZE,
+ PERSONALITY1_KLONGSIZE,
+# if SUPPORTED_PERSONALITIES > 2
+ PERSONALITY2_KLONGSIZE,
+# endif
+};
+# endif
+
void
set_personality(int personality)
{
# ifndef current_wordsize
current_wordsize = personality_wordsize[personality];
# endif
+# ifndef current_klongsize
+ current_klongsize = personality_klongsize[personality];
+# endif
}
static void
if (call < 1 || call >= SYS_socket_nsubcalls)
return;
- const unsigned long scno = SYS_socket_subcall + call;
+ const kernel_scno_t scno = SYS_socket_subcall + call;
const unsigned int nargs = sysent[scno].nargs;
uint64_t buf[nargs];
case SEN_pwritev:
case SEN_pwritev2:
case SEN_vmsplice:
- dumpiov(tcp, tcp->u_arg[2], tcp->u_arg[1]);
+ dumpiov_upto(tcp, tcp->u_arg[2], tcp->u_arg[1], -1);
break;
case SEN_sendmsg:
- dumpiov_in_msghdr(tcp, tcp->u_arg[1], -1UL);
+ dumpiov_in_msghdr(tcp, tcp->u_arg[1], -1);
break;
case SEN_sendmmsg:
dumpiov_in_mmsghdr(tcp, tcp->u_arg[1]);
* Shuffle syscall numbers so that we don't have huge gaps in syscall table.
* The shuffling should be an involution: shuffle_scno(shuffle_scno(n)) == n.
*/
-#if defined(ARM) || defined(AARCH64) /* So far only 32-bit ARM needs this */
-static long
-shuffle_scno(unsigned long scno)
+static kernel_scno_t
+shuffle_scno(kernel_scno_t scno)
{
+#if defined(ARM) || defined(AARCH64) /* So far only 32-bit ARM needs this */
if (scno < ARM_FIRST_SHUFFLED_SYSCALL)
return scno;
if (scno == 0x000ffff0)
return ARM_FIRST_SHUFFLED_SYSCALL;
-#define ARM_SECOND_SHUFFLED_SYSCALL (ARM_FIRST_SHUFFLED_SYSCALL + 1)
+# define ARM_SECOND_SHUFFLED_SYSCALL (ARM_FIRST_SHUFFLED_SYSCALL + 1)
/*
* Is it ARM specific syscall?
* Swap [0x000f0000, 0x000f0000 + LAST_SPECIAL] range
if (scno <= ARM_SECOND_SHUFFLED_SYSCALL + ARM_LAST_SPECIAL_SYSCALL) {
return scno + 0x000f0000 - ARM_SECOND_SHUFFLED_SYSCALL;
}
+#endif /* ARM || AARCH64 */
return scno;
}
-#else
-# define shuffle_scno(scno) ((long)(scno))
-#endif
const char *
err_name(unsigned long err)
static int get_syscall_args(struct tcb *);
static int get_syscall_result(struct tcb *);
static int arch_get_scno(struct tcb *tcp);
-static int arch_set_scno(struct tcb *, long);
+static int arch_set_scno(struct tcb *, kernel_scno_t);
static void get_error(struct tcb *, const bool);
static int arch_set_error(struct tcb *);
if (syscall_fault_injected(tcp))
tprints(" (INJECTED)");
} else {
- tprintf("= %#lx", tcp->u_rval);
+ tprintf("= %#" PRI_krx, tcp->u_rval);
}
}
else if (!(sys_res & RVAL_NONE) && u_error) {
switch (sys_res & RVAL_MASK) {
case RVAL_HEX:
#if SUPPORTED_PERSONALITIES > 1
- if (current_wordsize < sizeof(long))
+ if (current_wordsize < sizeof(tcp->u_rval))
tprintf("= %#x",
(unsigned int) tcp->u_rval);
else
#endif
- tprintf("= %#lx", tcp->u_rval);
+ tprintf("= %#" PRI_krx, tcp->u_rval);
break;
case RVAL_OCTAL:
tprints("= ");
break;
case RVAL_UDECIMAL:
#if SUPPORTED_PERSONALITIES > 1
- if (current_wordsize < sizeof(long))
+ if (current_wordsize < sizeof(tcp->u_rval))
tprintf("= %u",
(unsigned int) tcp->u_rval);
else
#endif
- tprintf("= %lu", tcp->u_rval);
+ tprintf("= %" PRI_kru, tcp->u_rval);
break;
case RVAL_DECIMAL:
- tprintf("= %ld", tcp->u_rval);
+ tprintf("= %" PRI_krd, tcp->u_rval);
break;
case RVAL_FD:
if (show_fd_path) {
printfd(tcp, tcp->u_rval);
}
else
- tprintf("= %ld", tcp->u_rval);
+ tprintf("= %" PRI_krd, tcp->u_rval);
break;
#if HAVE_STRUCT_TCB_EXT_ARG
/*
/* Linux kernel defines MAX_ERRNO to 4095. */
kernel_ulong_t max = -(kernel_long_t) 4095;
-#if defined X86_64 || defined X32
- /*
- * current_wordsize is 4 for x32 personality
- * but truncation _must not_ be done in it, so
- * check current_personality instead.
- */
- if (current_personality == 1) {
+#ifndef current_klongsize
+ if (current_klongsize < sizeof(val)) {
val = (uint32_t) val;
max = (uint32_t) max;
}
-#elif SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
- if (current_wordsize < sizeof(val)) {
- val = (uint32_t) val;
- max = (uint32_t) max;
- }
-#endif
+#endif /* !current_klongsize */
return val >= max;
}
#if defined ARCH_PC_REG
# define ARCH_GET_PC 0
#elif defined ARCH_PC_PEEK_ADDR
- long pc;
+ kernel_ureg_t pc;
# define ARCH_PC_REG pc
# define ARCH_GET_PC upeek(tcp->pid, ARCH_PC_PEEK_ADDR, &pc)
#else
tprints(current_wordsize == 4 ? "[????????] "
: "[????????????????] ");
else
- tprintf(current_wordsize == 4 ? "[%08lx] " : "[%016lx] ",
- (unsigned long) ARCH_PC_REG);
+ tprintf(current_wordsize == 4
+ ? "[%08" PRI_krx "] " : "[%016" PRI_krx "] ",
+ (kernel_ureg_t) ARCH_PC_REG);
}
#include "getregs_old.h"
struct sysent_buf {
struct tcb *tcp;
struct_sysent ent;
- char buf[sizeof("syscall_%lu") + sizeof(long) * 3];
+ char buf[sizeof("syscall_%lu") + sizeof(kernel_scno_t) * 3];
};
static void
s->ent.sen = SEN_printargs;
s->ent.sys_func = printargs;
s->ent.sys_name = s->buf;
- sprintf(s->buf, "syscall_%lu", shuffle_scno(tcp->scno));
+ sprintf(s->buf, "syscall_%" PRI_kru, shuffle_scno(tcp->scno));
tcp->s_ent = &s->ent;
tcp->qual_flg = QUAL_RAW | DEFAULT_QUAL_FLAGS;
set_tcb_priv_data(tcp, s, free_sysent_buf);
if (debug_flag)
- error_msg("pid %d invalid syscall %ld", tcp->pid, tcp->scno);
+ error_msg("pid %d invalid syscall %" PRI_krd,
+ tcp->pid, tcp->scno);
}
return 1;
}
#endif
const char *
-syscall_name(long scno)
+syscall_name(kernel_scno_t scno)
{
#if defined X32_PERSONALITY_NUMBER && defined __X32_SYSCALL_BIT
if (current_personality == X32_PERSONALITY_NUMBER)