(Thanks to Jan for comments on the last patch) Qemu has a command named singlestep, which reduces the translated code block to be only one instruction. However, there is one flaw when this command is triggered via monitor interface: we do not flush all the current TBs, so we will miss single-step on already translated code. This patch fixes the problem by flushing all the TB to force new code generation.
Signed-off-by: Jun Koi <junkoi2...@gmail.com> diff --git a/monitor.c b/monitor.c index 5659991..948b861 100644 --- a/monitor.c +++ b/monitor.c @@ -1190,8 +1190,14 @@ static void do_log(Monitor *mon, const QDict *qdict) static void do_singlestep(Monitor *mon, const QDict *qdict) { const char *option = qdict_get_try_str(qdict, "option"); + CPUState *env; + if (!option || !strcmp(option, "on")) { singlestep = 1; + /* flush all the TBs to force new code generation */ + for (env = first_cpu; env != NULL; env = env->next_cpu) { + tb_flush(env); + } } else if (!strcmp(option, "off")) { singlestep = 0; } else {