Skip to content
Snippets Groups Projects
Commit bf19bdb8 authored by Richard Henderson's avatar Richard Henderson Committed by Laurent Vivier
Browse files

linux-user/mips: Improve do_break


Rename to do_tr_or_bp, as per the kernel function.
Add a 'trap' argument, akin to the kernel's si_code, but clearer.
The return value is always 0, so change the return value to void.
Use force_sig and force_sig_fault.

Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
Message-Id: <20220107213243.212806-15-richard.henderson@linaro.org>
Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
parent 0b25c4a1
No related branches found
No related tags found
No related merge requests found
...@@ -40,29 +40,25 @@ enum { ...@@ -40,29 +40,25 @@ enum {
BRK_DIVZERO = 7 BRK_DIVZERO = 7
}; };
static int do_break(CPUMIPSState *env, target_siginfo_t *info, static void do_tr_or_bp(CPUMIPSState *env, unsigned int code, bool trap)
unsigned int code)
{ {
int ret = -1; target_ulong pc = env->active_tc.PC;
switch (code) { switch (code) {
case BRK_OVERFLOW: case BRK_OVERFLOW:
force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTOVF, pc);
break;
case BRK_DIVZERO: case BRK_DIVZERO:
info->si_signo = TARGET_SIGFPE; force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTDIV, pc);
info->si_errno = 0;
info->si_code = (code == BRK_OVERFLOW) ? FPE_INTOVF : FPE_INTDIV;
queue_signal(env, info->si_signo, QEMU_SI_FAULT, &*info);
ret = 0;
break; break;
default: default:
info->si_signo = TARGET_SIGTRAP; if (trap) {
info->si_errno = 0; force_sig(TARGET_SIGTRAP);
queue_signal(env, info->si_signo, QEMU_SI_FAULT, &*info); } else {
ret = 0; force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, pc);
}
break; break;
} }
return ret;
} }
void cpu_loop(CPUMIPSState *env) void cpu_loop(CPUMIPSState *env)
...@@ -205,6 +201,13 @@ done_syscall: ...@@ -205,6 +201,13 @@ done_syscall:
abi_ulong trap_instr; abi_ulong trap_instr;
unsigned int code; unsigned int code;
/*
* FIXME: It would be better to decode the trap number
* during translate, and store it in error_code while
* raising the exception. We should not be re-reading
* the opcode here.
*/
if (env->hflags & MIPS_HFLAG_M16) { if (env->hflags & MIPS_HFLAG_M16) {
if (env->insn_flags & ASE_MICROMIPS) { if (env->insn_flags & ASE_MICROMIPS) {
/* microMIPS mode */ /* microMIPS mode */
...@@ -257,9 +260,7 @@ done_syscall: ...@@ -257,9 +260,7 @@ done_syscall:
} }
} }
if (do_break(env, &info, code) != 0) { do_tr_or_bp(env, code, false);
goto error;
}
} }
break; break;
case EXCP_TRAP: case EXCP_TRAP:
...@@ -267,6 +268,13 @@ done_syscall: ...@@ -267,6 +268,13 @@ done_syscall:
abi_ulong trap_instr; abi_ulong trap_instr;
unsigned int code = 0; unsigned int code = 0;
/*
* FIXME: It would be better to decode the trap number
* during translate, and store it in error_code while
* raising the exception. We should not be re-reading
* the opcode here.
*/
if (env->hflags & MIPS_HFLAG_M16) { if (env->hflags & MIPS_HFLAG_M16) {
/* microMIPS mode */ /* microMIPS mode */
abi_ulong instr[2]; abi_ulong instr[2];
...@@ -293,9 +301,7 @@ done_syscall: ...@@ -293,9 +301,7 @@ done_syscall:
} }
} }
if (do_break(env, &info, code) != 0) { do_tr_or_bp(env, code, true);
goto error;
}
} }
break; break;
case EXCP_ATOMIC: case EXCP_ATOMIC:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment