在qemu自己搞debug server, 支持单步地方:
1)qemu的设计是只支持gdb debug server的, 就是说你在qemu里要搞一个debug server, 你要在原先的gdbstubs里:
void gdb_set_stop_cpu(CPUArchState *env){ if (gdbserver_state!=NULL){ // peter gdbserver_state->c_cpu = env; gdbserver_state->g_cpu = env; } }
就算qemu知道你没有用到gdb, 它也是会call gdb_set_stop_cpu(), 那么qemu就会死掉
2) 在gkd_vm_state_change()里当VM是running, 一定要return, 否则VM不会停, 因为env->singlestep_enabled也会被cpu_single_step(cpu, 0);重设成0.
static void gkd_vm_state_change(void *opaque, int running, RunState state) { printf("gkd_vm_state_change, state=%d\n", state); if (running) { return; } CPUArchState *cpu = first_cpu;//find_cpu(1); switch (state) { case RUN_STATE_DEBUG: tb_flush(cpu); break; } cpu_single_step(cpu, 0); }