qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v1 0/1] Fix GDB semihosting
@ 2012-02-15 16:55 Meador Inge
  2012-02-15 16:55 ` [Qemu-devel] [PATCH v1 1/1] gdbserver: Keep VM state status replies from happening during a syscall Meador Inge
  2012-02-15 18:26 ` [Qemu-devel] [PATCH v1 0/1] Fix GDB semihosting Peter Maydell
  0 siblings, 2 replies; 9+ messages in thread
From: Meador Inge @ 2012-02-15 16:55 UTC (permalink / raw)
  To: qemu-devel

Hi All,

GDB semihosting support is broken in the current trunk.  When debugging a
basic "Hello, World" application via the QEMU GDB stub:

   $ qemu-system-arm -s -S -M integratorcp -cpu any --semihosting
     --monitor null --serial null -kernel hello

GDB (7.2.50) receives an interrupt before anything is printed:

   Program received signal SIGINT, Interrupt.

As an example, consider this processing of the 'isatty' syscall.
'gdb_do_syscall' gets executed while 'current_run_state == RUN_STATE_RUNNING'.
It then changes the VM and GDB server state with:

    s->state = RS_SYSCALL;
    vm_stop(RUN_STATE_DEBUG);
    s->state = RS_IDLE;

which leaves the GDB server state in 'RS_IDLE', but since the syscall
happens while in the TCG thread the 'RUN_STATE_DEBUG' stop does not
happen immediately.  This leads to the following course of events:

1. 'gdb_do_syscall' finishes up by sending a 'Fisatty,00000001' packet to the
   GDB client.
2. 'RUN_STATE_DEBUG' get pulled from the event queue.
3. 'gdb_vm_state_change' is invoked thus causing a 'T05thread:01;' reply
   to be sent back to the GDB client.
4. A payload of '+$F1#77+' comes in containing the syscall reply and the
   'T05' ACK.
5. '+$F1#77' is processed and 'gdb_handle_packet' transitions the
   state back 'RUN_STATE_RUNNING'.
6. 'gdb_read_byte' starts processing the remaining payload of '+',
   but the current state is 'RUN_STATE_RUNNING' so 'gdb_read_byte' issues
   a 'vm_stop(RUN_STATE_PAUSED)' which takes effect immediately.
7. 'gdb_vm_state_change' is invoked thus causing a 'T02thread:01;' reply
   to be sent back to the GDB client.
8. The GDB client interrupts and breaks the semihosting flow.

This patch fixes the problem be staying in the 'RS_SYSCALL' state until next
packet read comes in.  Therefore keeping any 'T' statuses from being sent
back to the GDB client while the syscall is still being processed.

Meador Inge (1):
  gdbserver: Keep VM state status replies from happening during a
    syscall

 gdbstub.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-02-17  2:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-15 16:55 [Qemu-devel] [PATCH v1 0/1] Fix GDB semihosting Meador Inge
2012-02-15 16:55 ` [Qemu-devel] [PATCH v1 1/1] gdbserver: Keep VM state status replies from happening during a syscall Meador Inge
2012-02-15 17:54   ` Blue Swirl
2012-02-15 17:55     ` Meador Inge
2012-02-15 18:26 ` [Qemu-devel] [PATCH v1 0/1] Fix GDB semihosting Peter Maydell
2012-02-15 20:14   ` Peter Maydell
2012-02-16 18:39     ` Meador Inge
2012-02-16 19:08       ` Peter Maydell
2012-02-17  2:35         ` Meador Inge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).