diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2015-11-30 00:57:14 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2015-11-30 00:57:14 +0000 |
commit | 64672a6526f041b3c35bf1d801a8f3f5457eca51 (patch) | |
tree | 506303c748a39a1336d3baedb6c29a1de227449d /linux | |
parent | f51aec6abfad5dae5f3dd77365c2f8275e37437d (diff) | |
download | strace-64672a6526f041b3c35bf1d801a8f3f5457eca51.tar.gz |
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>
Diffstat (limited to 'linux')
24 files changed, 324 insertions, 163 deletions
diff --git a/linux/aarch64/get_syscall_args.c b/linux/aarch64/get_syscall_args.c index 41ce8b448..b92130130 100644 --- a/linux/aarch64/get_syscall_args.c +++ b/linux/aarch64/get_syscall_args.c @@ -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; } diff --git a/linux/alpha/get_syscall_args.c b/linux/alpha/get_syscall_args.c index 7f7d493a7..a3857263d 100644 --- a/linux/alpha/get_syscall_args.c +++ b/linux/alpha/get_syscall_args.c @@ -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; +} diff --git a/linux/arc/get_syscall_args.c b/linux/arc/get_syscall_args.c index bb003c8d5..4d6ace5c3 100644 --- a/linux/arc/get_syscall_args.c +++ b/linux/arc/get_syscall_args.c @@ -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; +} diff --git a/linux/arm/get_syscall_args.c b/linux/arm/get_syscall_args.c index 1bd4faf20..6be175019 100644 --- a/linux/arm/get_syscall_args.c +++ b/linux/arm/get_syscall_args.c @@ -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; +} diff --git a/linux/avr32/get_syscall_args.c b/linux/avr32/get_syscall_args.c index 2e3cd3b6e..e8c41198b 100644 --- a/linux/avr32/get_syscall_args.c +++ b/linux/avr32/get_syscall_args.c @@ -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; +} diff --git a/linux/bfin/get_syscall_args.c b/linux/bfin/get_syscall_args.c index ac6e6cd2c..13d58bd7e 100644 --- a/linux/bfin/get_syscall_args.c +++ b/linux/bfin/get_syscall_args.c @@ -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; +} diff --git a/linux/crisv10/get_syscall_args.c b/linux/crisv10/get_syscall_args.c index 66b5ac7e2..bdd05746e 100644 --- a/linux/crisv10/get_syscall_args.c +++ b/linux/crisv10/get_syscall_args.c @@ -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; +} diff --git a/linux/hppa/get_syscall_args.c b/linux/hppa/get_syscall_args.c index 117b68b91..2258ea87c 100644 --- a/linux/hppa/get_syscall_args.c +++ b/linux/hppa/get_syscall_args.c @@ -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; +} diff --git a/linux/i386/get_syscall_args.c b/linux/i386/get_syscall_args.c index 30cce6a45..d5de1d959 100644 --- a/linux/i386/get_syscall_args.c +++ b/linux/i386/get_syscall_args.c @@ -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; +} diff --git a/linux/ia64/get_syscall_args.c b/linux/ia64/get_syscall_args.c index 95273965d..2295d08dc 100644 --- a/linux/ia64/get_syscall_args.c +++ b/linux/ia64/get_syscall_args.c @@ -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; } diff --git a/linux/m68k/get_syscall_args.c b/linux/m68k/get_syscall_args.c index bdffcb1d9..bc69a1957 100644 --- a/linux/m68k/get_syscall_args.c +++ b/linux/m68k/get_syscall_args.c @@ -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; +} diff --git a/linux/metag/get_syscall_args.c b/linux/metag/get_syscall_args.c index 269f4eb8e..b7c10f45f 100644 --- a/linux/metag/get_syscall_args.c +++ b/linux/metag/get_syscall_args.c @@ -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; +} diff --git a/linux/microblaze/get_syscall_args.c b/linux/microblaze/get_syscall_args.c index 373911c1c..830c8c321 100644 --- a/linux/microblaze/get_syscall_args.c +++ b/linux/microblaze/get_syscall_args.c @@ -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; +} diff --git a/linux/mips/get_syscall_args.c b/linux/mips/get_syscall_args.c index 4e4a22b77..a20be8dee 100644 --- a/linux/mips/get_syscall_args.c +++ b/linux/mips/get_syscall_args.c @@ -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; +} diff --git a/linux/nios2/get_syscall_args.c b/linux/nios2/get_syscall_args.c index d12c2f7e2..707f594a6 100644 --- a/linux/nios2/get_syscall_args.c +++ b/linux/nios2/get_syscall_args.c @@ -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; +} diff --git a/linux/or1k/get_syscall_args.c b/linux/or1k/get_syscall_args.c index 751cba05b..b72e01f09 100644 --- a/linux/or1k/get_syscall_args.c +++ b/linux/or1k/get_syscall_args.c @@ -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; +} diff --git a/linux/powerpc/get_syscall_args.c b/linux/powerpc/get_syscall_args.c index 237cf77fe..66bcae31f 100644 --- a/linux/powerpc/get_syscall_args.c +++ b/linux/powerpc/get_syscall_args.c @@ -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; +} diff --git a/linux/s390/get_syscall_args.c b/linux/s390/get_syscall_args.c index 85f258511..ebf6c6c4a 100644 --- a/linux/s390/get_syscall_args.c +++ b/linux/s390/get_syscall_args.c @@ -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; +} diff --git a/linux/sh/get_syscall_args.c b/linux/sh/get_syscall_args.c index 7c94f4885..0b6c8819d 100644 --- a/linux/sh/get_syscall_args.c +++ b/linux/sh/get_syscall_args.c @@ -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; +} diff --git a/linux/sh64/get_syscall_args.c b/linux/sh64/get_syscall_args.c index dcc8967ac..3970df8f7 100644 --- a/linux/sh64/get_syscall_args.c +++ b/linux/sh64/get_syscall_args.c @@ -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; +} diff --git a/linux/sparc/get_syscall_args.c b/linux/sparc/get_syscall_args.c index 14bce8f95..57b5488e4 100644 --- a/linux/sparc/get_syscall_args.c +++ b/linux/sparc/get_syscall_args.c @@ -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; +} diff --git a/linux/tile/get_syscall_args.c b/linux/tile/get_syscall_args.c index 33371d5c4..b2043d394 100644 --- a/linux/tile/get_syscall_args.c +++ b/linux/tile/get_syscall_args.c @@ -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; +} diff --git a/linux/x86_64/get_syscall_args.c b/linux/x86_64/get_syscall_args.c index 0ccecdf07..fa591fb63 100644 --- a/linux/x86_64/get_syscall_args.c +++ b/linux/x86_64/get_syscall_args.c @@ -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; } diff --git a/linux/xtensa/get_syscall_args.c b/linux/xtensa/get_syscall_args.c index dca8788e9..a9c933a9f 100644 --- a/linux/xtensa/get_syscall_args.c +++ b/linux/xtensa/get_syscall_args.c @@ -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; +} |