cleanup: make get_syscall_args.c files more readable

Make get_syscall_args.c files more self-contained.  While they are
still being included by syscall.c, the latter no longer defines
get_syscall_args function.

* linux/aarch64/get_syscall_args.c: Include "arm/get_syscall_args.c"
with get_syscall_args temporarily defined to arm_get_syscall_args.
(get_syscall_args): Define.
* linux/alpha/get_syscall_args.c (get_syscall_args): Define.
* linux/arc/get_syscall_args.c: Likewise.
* linux/arm/get_syscall_args.c: Likewise.
* linux/avr32/get_syscall_args.c: Likewise.
* linux/bfin/get_syscall_args.c: Likewise.
* linux/crisv10/get_syscall_args.c: Likewise.
* linux/hppa/get_syscall_args.c: Likewise.
* linux/i386/get_syscall_args.c: Likewise.
* linux/ia64/get_syscall_args.c: Likewise.
* linux/m68k/get_syscall_args.c: Likewise.
* linux/metag/get_syscall_args.c: Likewise.
* linux/microblaze/get_syscall_args.c: Likewise.
* linux/mips/get_syscall_args.c: Likewise.
* linux/nios2/get_syscall_args.c: Likewise.
* linux/or1k/get_syscall_args.c: Likewise.
* linux/powerpc/get_syscall_args.c: Likewise.
* linux/s390/get_syscall_args.c: Likewise.
* linux/sh/get_syscall_args.c: Likewise.
* linux/sh64/get_syscall_args.c: Likewise.
* linux/sparc/get_syscall_args.c: Likewise.
* linux/tile/get_syscall_args.c: Likewise.
* linux/x86_64/get_syscall_args.c: Likewise.
* linux/xtensa/get_syscall_args.c: Likewise.
* syscall.c (get_syscall_args): Remove.
Include "get_syscall_args.c" in file scope.

Requested-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
Дмитрий Левин 2015-11-30 00:57:14 +00:00
parent f51aec6abf
commit 64672a6526
25 changed files with 324 additions and 170 deletions

View File

@ -1,10 +1,18 @@
if (tcp->currpers == 1) {
#define get_syscall_args arm_get_syscall_args
#include "arm/get_syscall_args.c"
#undef get_syscall_args
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
if (tcp->currpers == 0)
return arm_get_syscall_args(tcp);
tcp->u_arg[0] = aarch64_regs.regs[0];
tcp->u_arg[1] = aarch64_regs.regs[1];
tcp->u_arg[2] = aarch64_regs.regs[2];
tcp->u_arg[3] = aarch64_regs.regs[3];
tcp->u_arg[4] = aarch64_regs.regs[4];
tcp->u_arg[5] = aarch64_regs.regs[5];
} else {
#include "arm/get_syscall_args.c"
return 1;
}

View File

@ -1,5 +1,11 @@
unsigned int i;
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, REG_A0+i, &tcp->u_arg[i]) < 0)
return -1;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, REG_A0+i, &tcp->u_arg[i]) < 0)
return -1;
return 1;
}

View File

@ -1,5 +1,11 @@
long *arc_args = &arc_regs.scratch.r0;
unsigned int i;
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
long *arc_args = &arc_regs.scratch.r0;
unsigned int i;
for (i = 0; i < MAX_ARGS; ++i)
tcp->u_arg[i] = *arc_args--;
for (i = 0; i < MAX_ARGS; ++i)
tcp->u_arg[i] = *arc_args--;
return 1;
}

View File

@ -1,6 +1,12 @@
tcp->u_arg[0] = arm_regs.uregs[0];
tcp->u_arg[1] = arm_regs.uregs[1];
tcp->u_arg[2] = arm_regs.uregs[2];
tcp->u_arg[3] = arm_regs.uregs[3];
tcp->u_arg[4] = arm_regs.uregs[4];
tcp->u_arg[5] = arm_regs.uregs[5];
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
tcp->u_arg[0] = arm_regs.uregs[0];
tcp->u_arg[1] = arm_regs.uregs[1];
tcp->u_arg[2] = arm_regs.uregs[2];
tcp->u_arg[3] = arm_regs.uregs[3];
tcp->u_arg[4] = arm_regs.uregs[4];
tcp->u_arg[5] = arm_regs.uregs[5];
return 1;
}

View File

@ -1,6 +1,12 @@
tcp->u_arg[0] = avr32_regs.r12;
tcp->u_arg[1] = avr32_regs.r11;
tcp->u_arg[2] = avr32_regs.r10;
tcp->u_arg[3] = avr32_regs.r9;
tcp->u_arg[4] = avr32_regs.r5;
tcp->u_arg[5] = avr32_regs.r3;
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
tcp->u_arg[0] = avr32_regs.r12;
tcp->u_arg[1] = avr32_regs.r11;
tcp->u_arg[2] = avr32_regs.r10;
tcp->u_arg[3] = avr32_regs.r9;
tcp->u_arg[4] = avr32_regs.r5;
tcp->u_arg[5] = avr32_regs.r3;
return 1;
}

View File

@ -1,6 +1,13 @@
static const int argreg[MAX_ARGS] = { PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5 };
unsigned int i;
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
static const int argreg[MAX_ARGS] =
{ PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5 };
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, argreg[i], &tcp->u_arg[i]) < 0)
return -1;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, argreg[i], &tcp->u_arg[i]) < 0)
return -1;
return 1;
}

View File

@ -1,9 +1,15 @@
static const int crisregs[MAX_ARGS] = {
4*PT_ORIG_R10, 4*PT_R11, 4*PT_R12,
4*PT_R13 , 4*PT_MOF, 4*PT_SRP
};
unsigned int i;
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
static const int crisregs[MAX_ARGS] = {
4*PT_ORIG_R10, 4*PT_R11, 4*PT_R12,
4*PT_R13 , 4*PT_MOF, 4*PT_SRP
};
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, crisregs[i], &tcp->u_arg[i]) < 0)
return -1;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, crisregs[i], &tcp->u_arg[i]) < 0)
return -1;
return 1;
}

View File

@ -1,5 +1,11 @@
unsigned int i;
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, PT_GR26-4*i, &tcp->u_arg[i]) < 0)
return -1;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, PT_GR26-4*i, &tcp->u_arg[i]) < 0)
return -1;
return 1;
}

View File

@ -1,6 +1,12 @@
tcp->u_arg[0] = i386_regs.ebx;
tcp->u_arg[1] = i386_regs.ecx;
tcp->u_arg[2] = i386_regs.edx;
tcp->u_arg[3] = i386_regs.esi;
tcp->u_arg[4] = i386_regs.edi;
tcp->u_arg[5] = i386_regs.ebp;
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
tcp->u_arg[0] = i386_regs.ebx;
tcp->u_arg[1] = i386_regs.ecx;
tcp->u_arg[2] = i386_regs.edx;
tcp->u_arg[3] = i386_regs.esi;
tcp->u_arg[4] = i386_regs.edi;
tcp->u_arg[5] = i386_regs.ebp;
return 1;
}

View File

@ -1,22 +1,29 @@
if (!ia64_ia32mode) {
unsigned long *rbs_end =
(unsigned long *) ia64_regs.ar[PT_AUR_BSP];
unsigned long sof = (ia64_regs.cfm >> 0) & 0x7f;
unsigned long sol = (ia64_regs.cfm >> 7) & 0x7f;
unsigned long *out0 = ia64_rse_skip_regs(rbs_end, -sof + sol);
unsigned int i;
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
if (!ia64_ia32mode) {
unsigned long *rbs_end =
(unsigned long *) ia64_regs.ar[PT_AUR_BSP];
unsigned long sof = (ia64_regs.cfm >> 0) & 0x7f;
unsigned long sol = (ia64_regs.cfm >> 7) & 0x7f;
unsigned long *out0 = ia64_rse_skip_regs(rbs_end, -sof + sol);
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i) {
if (umoven(tcp, (unsigned long) ia64_rse_skip_regs(out0, i),
sizeof(long), &tcp->u_arg[i]) < 0)
return -1;
for (i = 0; i < tcp->s_ent->nargs; ++i) {
if (umoven(tcp,
(unsigned long) ia64_rse_skip_regs(out0, i),
sizeof(long), &tcp->u_arg[i]) < 0)
return -1;
}
} else {
/* truncate away IVE sign-extension */
tcp->u_arg[0] = 0xffffffff & ia64_regs.gr[11]; /* EBX */
tcp->u_arg[1] = 0xffffffff & ia64_regs.gr[ 9]; /* ECX */
tcp->u_arg[2] = 0xffffffff & ia64_regs.gr[10]; /* EDX */
tcp->u_arg[3] = 0xffffffff & ia64_regs.gr[14]; /* ESI */
tcp->u_arg[4] = 0xffffffff & ia64_regs.gr[15]; /* EDI */
tcp->u_arg[5] = 0xffffffff & ia64_regs.gr[13]; /* EBP */
}
} else {
/* truncate away IVE sign-extension */
tcp->u_arg[0] = 0xffffffff & ia64_regs.gr[11]; /* EBX */
tcp->u_arg[1] = 0xffffffff & ia64_regs.gr[ 9]; /* ECX */
tcp->u_arg[2] = 0xffffffff & ia64_regs.gr[10]; /* EDX */
tcp->u_arg[3] = 0xffffffff & ia64_regs.gr[14]; /* ESI */
tcp->u_arg[4] = 0xffffffff & ia64_regs.gr[15]; /* EDI */
tcp->u_arg[5] = 0xffffffff & ia64_regs.gr[13]; /* EBP */
return 1;
}

View File

@ -1,5 +1,11 @@
unsigned int i;
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, (i < 5 ? i : i + 2)*4, &tcp->u_arg[i]) < 0)
return -1;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, (i < 5 ? i : i + 2)*4, &tcp->u_arg[i]) < 0)
return -1;
return 1;
}

View File

@ -1,5 +1,12 @@
unsigned int i;
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
unsigned int i;
for (i = 0; i < MAX_ARGS; i++)
/* arguments go backwards from D1Ar1 (D1.3) */
tcp->u_arg[i] = ((unsigned long *)&metag_regs.dx[3][1])[-i];
for (i = 0; i < MAX_ARGS; i++) {
/* arguments go backwards from D1Ar1 (D1.3) */
tcp->u_arg[i] = ((unsigned long *)&metag_regs.dx[3][1])[-i];
}
return 1;
}

View File

@ -1,5 +1,11 @@
unsigned int i;
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, (5 + i) * 4, &tcp->u_arg[i]) < 0)
return -1;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, (5 + i) * 4, &tcp->u_arg[i]) < 0)
return -1;
return 1;
}

View File

@ -1,3 +1,7 @@
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
#if defined LINUX_MIPSN64
tcp->u_arg[0] = mips_REG_A0;
tcp->u_arg[1] = mips_REG_A1;
@ -18,10 +22,13 @@
tcp->u_arg[2] = mips_REG_A2;
tcp->u_arg[3] = mips_REG_A3;
if (tcp->s_ent->nargs > 4) {
umoven(tcp, mips_REG_SP + 4 * 4,
(tcp->s_ent->nargs - 4) * sizeof(tcp->u_arg[0]),
&tcp->u_arg[4]);
if (umoven(tcp, mips_REG_SP + 4 * 4,
(tcp->s_ent->nargs - 4) * sizeof(tcp->u_arg[0]),
&tcp->u_arg[4]) < 0)
return -1;
}
#else
# error unsupported mips abi
#endif
return 1;
}

View File

@ -1,6 +1,12 @@
tcp->u_arg[0] = nios2_regs.regs[4];
tcp->u_arg[1] = nios2_regs.regs[5];
tcp->u_arg[2] = nios2_regs.regs[6];
tcp->u_arg[3] = nios2_regs.regs[7];
tcp->u_arg[4] = nios2_regs.regs[8];
tcp->u_arg[5] = nios2_regs.regs[9];
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
tcp->u_arg[0] = nios2_regs.regs[4];
tcp->u_arg[1] = nios2_regs.regs[5];
tcp->u_arg[2] = nios2_regs.regs[6];
tcp->u_arg[3] = nios2_regs.regs[7];
tcp->u_arg[4] = nios2_regs.regs[8];
tcp->u_arg[5] = nios2_regs.regs[9];
return 1;
}

View File

@ -1,6 +1,12 @@
tcp->u_arg[0] = or1k_regs.gpr[3 + 0];
tcp->u_arg[1] = or1k_regs.gpr[3 + 1];
tcp->u_arg[2] = or1k_regs.gpr[3 + 2];
tcp->u_arg[3] = or1k_regs.gpr[3 + 3];
tcp->u_arg[4] = or1k_regs.gpr[3 + 4];
tcp->u_arg[5] = or1k_regs.gpr[3 + 5];
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
tcp->u_arg[0] = or1k_regs.gpr[3 + 0];
tcp->u_arg[1] = or1k_regs.gpr[3 + 1];
tcp->u_arg[2] = or1k_regs.gpr[3 + 2];
tcp->u_arg[3] = or1k_regs.gpr[3 + 3];
tcp->u_arg[4] = or1k_regs.gpr[3 + 4];
tcp->u_arg[5] = or1k_regs.gpr[3 + 5];
return 1;
}

View File

@ -1,6 +1,12 @@
tcp->u_arg[0] = ppc_regs.orig_gpr3;
tcp->u_arg[1] = ppc_regs.gpr[4];
tcp->u_arg[2] = ppc_regs.gpr[5];
tcp->u_arg[3] = ppc_regs.gpr[6];
tcp->u_arg[4] = ppc_regs.gpr[7];
tcp->u_arg[5] = ppc_regs.gpr[8];
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
tcp->u_arg[0] = ppc_regs.orig_gpr3;
tcp->u_arg[1] = ppc_regs.gpr[4];
tcp->u_arg[2] = ppc_regs.gpr[5];
tcp->u_arg[3] = ppc_regs.gpr[6];
tcp->u_arg[4] = ppc_regs.gpr[7];
tcp->u_arg[5] = ppc_regs.gpr[8];
return 1;
}

View File

@ -1,6 +1,12 @@
tcp->u_arg[0] = s390_regset.orig_gpr2;
tcp->u_arg[1] = s390_regset.gprs[3];
tcp->u_arg[2] = s390_regset.gprs[4];
tcp->u_arg[3] = s390_regset.gprs[5];
tcp->u_arg[4] = s390_regset.gprs[6];
tcp->u_arg[5] = s390_regset.gprs[7];
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
tcp->u_arg[0] = s390_regset.orig_gpr2;
tcp->u_arg[1] = s390_regset.gprs[3];
tcp->u_arg[2] = s390_regset.gprs[4];
tcp->u_arg[3] = s390_regset.gprs[5];
tcp->u_arg[4] = s390_regset.gprs[6];
tcp->u_arg[5] = s390_regset.gprs[7];
return 1;
}

View File

@ -1,10 +1,19 @@
static const int syscall_regs[MAX_ARGS] = {
4 * (REG_REG0+4), 4 * (REG_REG0+5), 4 * (REG_REG0+6),
4 * (REG_REG0+7), 4 * (REG_REG0 ), 4 * (REG_REG0+1)
};
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
static const int syscall_regs[MAX_ARGS] = {
4 * (REG_REG0+4),
4 * (REG_REG0+5),
4 * (REG_REG0+6),
4 * (REG_REG0+7),
4 * (REG_REG0 ),
4 * (REG_REG0+1)
};
unsigned int i;
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, syscall_regs[i], &tcp->u_arg[i]) < 0)
return -1;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, syscall_regs[i], &tcp->u_arg[i]) < 0)
return -1;
return 1;
}

View File

@ -1,7 +1,14 @@
/* Registers used by SH5 Linux system calls for parameters */
static const int syscall_regs[MAX_ARGS] = { 2, 3, 4, 5, 6, 7 };
unsigned int i;
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
/* Registers used by SH5 Linux system calls for parameters */
static const int syscall_regs[MAX_ARGS] = { 2, 3, 4, 5, 6, 7 };
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, REG_GENERAL(syscall_regs[i]), &tcp->u_arg[i]) < 0)
return -1;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, REG_GENERAL(syscall_regs[i]),
&tcp->u_arg[i]) < 0)
return -1;
return 1;
}

View File

@ -1,6 +1,12 @@
tcp->u_arg[0] = sparc_regs.u_regs[U_REG_O0 + 0];
tcp->u_arg[1] = sparc_regs.u_regs[U_REG_O0 + 1];
tcp->u_arg[2] = sparc_regs.u_regs[U_REG_O0 + 2];
tcp->u_arg[3] = sparc_regs.u_regs[U_REG_O0 + 3];
tcp->u_arg[4] = sparc_regs.u_regs[U_REG_O0 + 4];
tcp->u_arg[5] = sparc_regs.u_regs[U_REG_O0 + 5];
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
tcp->u_arg[0] = sparc_regs.u_regs[U_REG_O0 + 0];
tcp->u_arg[1] = sparc_regs.u_regs[U_REG_O0 + 1];
tcp->u_arg[2] = sparc_regs.u_regs[U_REG_O0 + 2];
tcp->u_arg[3] = sparc_regs.u_regs[U_REG_O0 + 3];
tcp->u_arg[4] = sparc_regs.u_regs[U_REG_O0 + 4];
tcp->u_arg[5] = sparc_regs.u_regs[U_REG_O0 + 5];
return 1;
}

View File

@ -1,6 +1,12 @@
tcp->u_arg[0] = tile_regs.regs[0];
tcp->u_arg[1] = tile_regs.regs[1];
tcp->u_arg[2] = tile_regs.regs[2];
tcp->u_arg[3] = tile_regs.regs[3];
tcp->u_arg[4] = tile_regs.regs[4];
tcp->u_arg[5] = tile_regs.regs[5];
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
tcp->u_arg[0] = tile_regs.regs[0];
tcp->u_arg[1] = tile_regs.regs[1];
tcp->u_arg[2] = tile_regs.regs[2];
tcp->u_arg[3] = tile_regs.regs[3];
tcp->u_arg[4] = tile_regs.regs[4];
tcp->u_arg[5] = tile_regs.regs[5];
return 1;
}

View File

@ -1,29 +1,35 @@
if (x86_io.iov_len != sizeof(i386_regs)) {
/* x86-64 or x32 ABI */
tcp->u_arg[0] = x86_64_regs.rdi;
tcp->u_arg[1] = x86_64_regs.rsi;
tcp->u_arg[2] = x86_64_regs.rdx;
tcp->u_arg[3] = x86_64_regs.r10;
tcp->u_arg[4] = x86_64_regs.r8;
tcp->u_arg[5] = x86_64_regs.r9;
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
if (x86_io.iov_len != sizeof(i386_regs)) {
/* x86-64 or x32 ABI */
tcp->u_arg[0] = x86_64_regs.rdi;
tcp->u_arg[1] = x86_64_regs.rsi;
tcp->u_arg[2] = x86_64_regs.rdx;
tcp->u_arg[3] = x86_64_regs.r10;
tcp->u_arg[4] = x86_64_regs.r8;
tcp->u_arg[5] = x86_64_regs.r9;
#ifdef X32
tcp->ext_arg[0] = x86_64_regs.rdi;
tcp->ext_arg[1] = x86_64_regs.rsi;
tcp->ext_arg[2] = x86_64_regs.rdx;
tcp->ext_arg[3] = x86_64_regs.r10;
tcp->ext_arg[4] = x86_64_regs.r8;
tcp->ext_arg[5] = x86_64_regs.r9;
tcp->ext_arg[0] = x86_64_regs.rdi;
tcp->ext_arg[1] = x86_64_regs.rsi;
tcp->ext_arg[2] = x86_64_regs.rdx;
tcp->ext_arg[3] = x86_64_regs.r10;
tcp->ext_arg[4] = x86_64_regs.r8;
tcp->ext_arg[5] = x86_64_regs.r9;
#endif
} else {
/* i386 ABI */
/* Zero-extend from 32 bits */
/* Use widen_to_long(tcp->u_arg[N]) in syscall handlers
* if you need to use *sign-extended* parameter.
*/
tcp->u_arg[0] = (long)(uint32_t)i386_regs.ebx;
tcp->u_arg[1] = (long)(uint32_t)i386_regs.ecx;
tcp->u_arg[2] = (long)(uint32_t)i386_regs.edx;
tcp->u_arg[3] = (long)(uint32_t)i386_regs.esi;
tcp->u_arg[4] = (long)(uint32_t)i386_regs.edi;
tcp->u_arg[5] = (long)(uint32_t)i386_regs.ebp;
} else {
/* i386 ABI */
/* Zero-extend from 32 bits */
/* Use widen_to_long(tcp->u_arg[N]) in syscall handlers
* if you need to use *sign-extended* parameter.
*/
tcp->u_arg[0] = (long)(uint32_t)i386_regs.ebx;
tcp->u_arg[1] = (long)(uint32_t)i386_regs.ecx;
tcp->u_arg[2] = (long)(uint32_t)i386_regs.edx;
tcp->u_arg[3] = (long)(uint32_t)i386_regs.esi;
tcp->u_arg[4] = (long)(uint32_t)i386_regs.edi;
tcp->u_arg[5] = (long)(uint32_t)i386_regs.ebp;
}
return 1;
}

View File

@ -1,7 +1,20 @@
/* arg0: a6, arg1: a3, arg2: a4, arg3: a5, arg4: a8, arg5: a9 */
static const int xtensaregs[MAX_ARGS] = { 6, 3, 4, 5, 8, 9 };
unsigned int i;
/* Return -1 on error or 1 on success (never 0!). */
static int
get_syscall_args(struct tcb *tcp)
{
/* arg0: a6, arg1: a3, arg2: a4, arg3: a5, arg4: a8, arg5: a9 */
static const int xtensaregs[MAX_ARGS] = {
REG_A_BASE + 6,
REG_A_BASE + 3,
REG_A_BASE + 4,
REG_A_BASE + 5,
REG_A_BASE + 8,
REG_A_BASE + 9
};
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, REG_A_BASE + xtensaregs[i], &tcp->u_arg[i]) < 0)
return -1;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, xtensaregs[i], &tcp->u_arg[i]) < 0)
return -1;
return 1;
}

View File

@ -1337,14 +1337,7 @@ get_scno(struct tcb *tcp)
return 1;
}
/* Return -1 on error or 1 on success (never 0!) */
static int
get_syscall_args(struct tcb *tcp)
{
#include "get_syscall_args.c"
return 1;
}
#ifdef USE_GET_SYSCALL_RESULT_REGS
# include "get_syscall_result.c"
#endif