From: Mike Frysinger Date: Mon, 21 Jun 2021 03:50:35 +0000 (-0400) Subject: sim: syscall: handle killing the sim itself X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2f631626f1d8a354d3c5f9d2fce15b47d05d1455;p=binutils-gdb.git sim: syscall: handle killing the sim itself If code tries to send a signal to itself, the callback layer ignores it and forces the caller to handle it. This allows the sim to turn that into an engine halt rather than actually killing the sim. --- diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index c32e7475a80..18d37bd17c6 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,7 @@ +2021-06-23 Mike Frysinger + + * sim-syscall.c (sim_syscall_multi): Handle CB_SYS_kill. + 2021-06-23 Mike Frysinger * callback.c (os_kill): New function. diff --git a/sim/common/sim-syscall.c b/sim/common/sim-syscall.c index be3ff8f82e2..f24d761ee8f 100644 --- a/sim/common/sim-syscall.c +++ b/sim/common/sim-syscall.c @@ -97,8 +97,20 @@ sim_syscall_multi (SIM_CPU *cpu, int func, long arg1, long arg2, long arg3, TRACE_SYSCALL (cpu, "%s[%i](%#lx, %#lx, %#lx) = %li", syscall, func, arg1, arg2, arg3, sc.result); - if (cb_target_to_host_syscall (cb, func) == CB_SYS_exit) - sim_engine_halt (sd, cpu, NULL, sim_pc_get (cpu), sim_exited, arg1); + /* Handle syscalls that affect engine behavior. */ + switch (cb_target_to_host_syscall (cb, func)) + { + case CB_SYS_exit: + sim_engine_halt (sd, cpu, NULL, sim_pc_get (cpu), sim_exited, arg1); + break; + + case CB_SYS_kill: + /* TODO: Need to translate target signal to sim signal, but the sim + doesn't yet have such a mapping layer. */ + if (arg1 == (*cb->getpid) (cb)) + sim_engine_halt (sd, cpu, NULL, sim_pc_get (cpu), sim_signalled, arg2); + break; + } *result = sc.result; *result2 = sc.result2;