41d647ce67
This extends fault injection syntax with :retval= option. When :retval=VALUE is specified, the syscall number is replaced by -1 and a bogus success VALUE is returned to the callee. * defs.h (fault_opts): Remove err field, add rval field. (MAX_ERRNO_VALUE, FAULT_OPTS_RVAL_DEFAULT, FAULT_OPTS_RVAL_DISABLE): New macros. * qualify.c (parse_fault_token): Handle retval= token. (qualify_fault): Update fault_opts initialization after the move from struct fault_opts.err to struct fault_opts.rval. * syscall.c (arch_set_success): New prototype. (inject_syscall_fault_entering): Check opts->rval instead of opts->err. (update_syscall_fault_exiting): Implement retval injection. * strace.1: Update the section on fault injection. * NEWS: Mention retval= option. * linux/aarch64/set_error.c (arch_set_success): New function. * linux/alpha/set_error.c: Likewise. * linux/arc/set_error.c: Likewise. * linux/arm/set_error.c: Likewise. * linux/avr32/set_error.c: Likewise. * linux/bfin/set_error.c: Likewise. * linux/crisv10/set_error.c: Likewise. * linux/hppa/set_error.c: Likewise. * linux/i386/set_error.c: Likewise. * linux/ia64/set_error.c: Likewise. * linux/m68k/set_error.c: Likewise. * linux/metag/set_error.c: Likewise. * linux/microblaze/set_error.c: Likewise. * linux/mips/set_error.c: Likewise. * linux/nios2/set_error.c: Likewise. * linux/or1k/set_error.c: Likewise. * linux/powerpc/set_error.c: Likewise. * linux/riscv/set_error.c: Likewise. * linux/s390/set_error.c: Likewise. * linux/sh/set_error.c: Likewise. * linux/sh64/set_error.c: Likewise. * linux/sparc/set_error.c: Likewise. * linux/sparc64/set_error.c: Likewise. * linux/tile/set_error.c: Likewise. * linux/x86_64/set_error.c: Likewise. * linux/xtensa/set_error.c: Likewise. Closes: https://github.com/strace/strace/issues/3
16 lines
247 B
C
16 lines
247 B
C
static int
|
|
arch_set_error(struct tcb *tcp)
|
|
{
|
|
mips_REG_V0 = tcp->u_error;
|
|
mips_REG_A3 = -1;
|
|
return set_regs(tcp->pid);
|
|
}
|
|
|
|
static int
|
|
arch_set_success(struct tcb *tcp)
|
|
{
|
|
mips_REG_V0 = tcp->u_rval;
|
|
mips_REG_A3 = 0;
|
|
return set_regs(tcp->pid);
|
|
}
|