mirror of https://github.com/proxmox/mirror_qemu
linux-user: Clean up nios2 main loop signal handling
The nios2 main loop code's code does some odd things with gdb_handlesig() that no other target CPU does: it has some signals that are delivered to gdb and only to gdb. Stop doing this, and instead behave like all the other targets: * a trap instruction becomes a SIGTRAP * an unhandled exception type returned from cpu_exec() causes us to abort(), not to try to hand gdb a SIGILL This fixes in passing Coverity issue CID 1390853, which was a complaint that the old code failed to check the return value from gdb_handlesig(). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20181019174958.26616-3-peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> [lv: removed gdbsig unused variable] Signed-off-by: Laurent Vivier <laurent@vivier.eu>master
parent
b10089a14c
commit
9f214bd390
|
@ -26,13 +26,12 @@ void cpu_loop(CPUNios2State *env)
|
||||||
CPUState *cs = ENV_GET_CPU(env);
|
CPUState *cs = ENV_GET_CPU(env);
|
||||||
Nios2CPU *cpu = NIOS2_CPU(cs);
|
Nios2CPU *cpu = NIOS2_CPU(cs);
|
||||||
target_siginfo_t info;
|
target_siginfo_t info;
|
||||||
int trapnr, gdbsig, ret;
|
int trapnr, ret;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
cpu_exec_start(cs);
|
cpu_exec_start(cs);
|
||||||
trapnr = cpu_exec(cs);
|
trapnr = cpu_exec(cs);
|
||||||
cpu_exec_end(cs);
|
cpu_exec_end(cs);
|
||||||
gdbsig = 0;
|
|
||||||
|
|
||||||
switch (trapnr) {
|
switch (trapnr) {
|
||||||
case EXCP_INTERRUPT:
|
case EXCP_INTERRUPT:
|
||||||
|
@ -68,7 +67,10 @@ void cpu_loop(CPUNios2State *env)
|
||||||
env->regs[R_EA] = env->regs[R_PC] + 4;
|
env->regs[R_EA] = env->regs[R_PC] + 4;
|
||||||
env->regs[R_PC] = cpu->exception_addr;
|
env->regs[R_PC] = cpu->exception_addr;
|
||||||
|
|
||||||
gdbsig = TARGET_SIGTRAP;
|
info.si_signo = TARGET_SIGTRAP;
|
||||||
|
info.si_errno = 0;
|
||||||
|
info.si_code = TARGET_TRAP_BRKPT;
|
||||||
|
queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0xaa:
|
case 0xaa:
|
||||||
|
@ -106,14 +108,7 @@ kuser_fail:
|
||||||
default:
|
default:
|
||||||
EXCP_DUMP(env, "\nqemu: unhandled CPU exception %#x - aborting\n",
|
EXCP_DUMP(env, "\nqemu: unhandled CPU exception %#x - aborting\n",
|
||||||
trapnr);
|
trapnr);
|
||||||
gdbsig = TARGET_SIGILL;
|
abort();
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (gdbsig) {
|
|
||||||
gdb_handlesig(cs, gdbsig);
|
|
||||||
if (gdbsig != TARGET_SIGTRAP) {
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process_pending_signals(env);
|
process_pending_signals(env);
|
||||||
|
|
Loading…
Reference in New Issue