From: Meador Inge <meadori@codesourcery.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v1 0/1] Fix GDB semihosting
Date: Wed, 15 Feb 2012 10:55:13 -0600 [thread overview]
Message-ID: <1329324914-12296-1-git-send-email-meadori@codesourcery.com> (raw)
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
next reply other threads:[~2012-02-15 16:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-15 16:55 Meador Inge [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1329324914-12296-1-git-send-email-meadori@codesourcery.com \
--to=meadori@codesourcery.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).