qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Stopping the VM due to an illegal instruct ion [was: QOM CP


From: Michael Walle
Subject: [Qemu-devel] Stopping the VM due to an illegal instruct ion [was: QOM CPUState, part 13: Emptying CPU_COMMON ]
Date: Fri, 20 Sep 2013 19:07:29 +0200
User-agent: Roundcube Webmail/0.7.2


Hi,

Am 2013-09-17 20:46, schrieb Richard Henderson:
On 09/17/2013 10:46 AM, Michael Walle wrote:
Am Montag, 9. September 2013, 18:47:21 schrieb Peter Maydell:
For lm32 you might consider raising EXCP_BREAKPOINT;
then if you have a gdb connected to the debug stub
the developer will get dropped into the debugger for
the offending insn and can look at it.

Are you sure, this will drop to the debugger? I guess the target cpu jumps to
the exception vector.

He meant EXCP_DEBUG, I think.

It will never affect the target cpu at all, of course, that would be useless
for debugging.  Issuing it will exit the cpu loop.

If the debugger is attached, all of the expected things should happen.

Otherwise, it appears as if we'll still have set cpu->stopped, and
we'll fail to run anymore instructions.  Even without the debugger
you ought to be able to poke around with the monitor to see what's
going on.


Raising EXCP_DEBUG results in a segmentation fault if qemu is not started with the -s option, because there is not gdbserver_state:

[Switching to Thread 0xb4b2eb70 (LWP 20930)]
0x081c88fa in gdb_set_stop_cpu (cpu=0x8730f88) at /home/mw/repo/qemu/gdbstub.c:1187
1187        gdbserver_state->c_cpu = cpu;
(gdb) bt
#0 0x081c88fa in gdb_set_stop_cpu (cpu=0x8730f88) at /home/mw/repo/qemu/gdbstub.c:1187
#1  0x081995f2 in cpu_handle_guest_debug (cpu=0x8730f88)
    at /home/mw/repo/qemu/cpus.c:485
#2  0x0819ad7f in tcg_exec_all () at /home/mw/repo/qemu/cpus.c:1218
#3  0x0819a283 in qemu_tcg_cpu_thread_fn (arg=0x8730f88)
    at /home/mw/repo/qemu/cpus.c:882
#4 0xb7dd7c39 in start_thread () from /lib/i386-linux-gnu/i686/cmov/libpthread.so.0
#5  0xb7d4478e in clone () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
(gdb) p gdbserver_state
$1 = (GDBState *) 0x0
(gdb)


I then tried to raise EXCP_HALTED and setting cs->stopped and the runstate manually:


void HELPER(ill)(CPULM32State *env)
{
#ifndef CONFIG_USER_ONLY
    CPUState *cs = CPU(lm32_env_get_cpu(env));
    fprintf(stderr, "VM paused due to illegal instruction. "
            "Connect a debugger or switch to the monitor console "
            "to find out more.\n");
    qemu_system_vmstop_request(RUN_STATE_PAUSED);
    cs->stopped = true;
    raise_exception(env, EXCP_HALTED);
#endif
}

The above works as expected, but i don't know if that is the right way to do it.

btw, what is the difference between cs->stopped and cs->halted?

--
michael



reply via email to

[Prev in Thread] Current Thread [Next in Thread]