Support nested uc_emu_start calls

This commit is contained in:
2021-11-16 21:07:03 +01:00
parent 43c643d4af
commit 247ffbe0e8
5 changed files with 54 additions and 2 deletions

View File

@@ -40,7 +40,7 @@ void cpu_loop_exit(CPUState *cpu)
tb_exec_unlock(cpu->uc->tcg_ctx);
/* Undo the setting in cpu_tb_exec. */
cpu->can_do_io = 1;
siglongjmp(cpu->jmp_env, 1);
siglongjmp(cpu->uc->jmp_bufs[cpu->uc->nested_level - 1], 1);
}
void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc)

View File

@@ -551,8 +551,10 @@ int cpu_exec(struct uc_struct *uc, CPUState *cpu)
*/
// init_delay_params(&sc, cpu);
// Unicorn: We would like to support nested uc_emu_start calls.
/* prepare setjmp context for exception handling */
if (sigsetjmp(cpu->jmp_env, 0) != 0) {
// if (sigsetjmp(cpu->jmp_env, 0) != 0) {
if (sigsetjmp(uc->jmp_bufs[uc->nested_level - 1], 0) != 0) {
#if defined(__clang__) || !QEMU_GNUC_PREREQ(4, 6)
/* Some compilers wrongly smash all local variables after
* siglongjmp. There were bug reports for gcc 4.5.0 and clang.