qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [Bug 1364501] [NEW] Gdb hangs when trying to single-ste


From: Peter Maydell
Subject: Re: [Qemu-devel] [Bug 1364501] [NEW] Gdb hangs when trying to single-step after an invalid instruction
Date: Tue, 2 Sep 2014 19:49:25 +0100

On 2 September 2014 17:38, martin <address@hidden> wrote:
> Public bug reported:
>
> When using Gdb to remote-debug a program and manually setting its PC to
> point to an address containing an invalid instruction and then doing a
> single step, Qemu will never return control to the remote Gdb.
>
> For instance, let's say address 0x114 contains an invalid instruction.
> On the remote Gdb, we'd do:
>
> (gdb) set $pc = 0x114
> (gdb) stepi
>
> After doing that we won't get the (gdb) prompt unless we do a Ctrl-C. If
> we do so we'll be left at 0x114 instead of going towards the exception
> handler as we should. This happens with stepi, step and next. If instead
> of single-stepping we used continue, the program will proceed into the
> exception handler as it should.
>
> The reason this is happening is that when Qemu realizes it's about to
> translate an instruction it doesn't recognize it'll generate a call to
> helper_exception_with_syndrome(), which will register the exception and
> then call cpu_loop_exit(). At the same time, because we're doing a
> single-step, Qemu will also generate a call to
> helper_exception_internal() passing it an EXCP_DEBUG, which lets the
> system know it'll give control back to the remote debugger, and it also
> ends with a call to cpu_loop_exit(). However, because the syndrome
> exception calls cpu_loop_exit() first, the call to the internal
> exception won't be reached and Qemu will be stuck in a loop without
> returning control to the remote debugger.

Just to check, does your system image include a valid handler
for the undef exception? I'm wondering if we really never return
control in all cases, or only if we get stuck in an infinite loop
of exceptions beacuse the exception handler's first instruction
causes an exception which causes an exception which...

> What makes this a bit tricky to fix is that we must call cpu_loop_exit()
> at the end of helper_exception_with_syndrome(), otherwise the target
> exception will go undetected and its handler won't be excecuted.

I suspect there are actually more general issues with the interaction
of single-stepping with exceptions. See also
https://bugs.launchpad.net/qemu/+bug/757702 which is a report
that singlestepping an invalid instruction stops on the insn after
the first one in the UNDEF handler rather than before it.

thanks
-- PMM



reply via email to

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