qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH V3] gdbstub: Fix handler for 'F' packet
@ 2019-08-27 22:33 Sandra Loosemore
  2019-08-28  3:12 ` Richard Henderson
  2019-08-28  8:51 ` Alex Bennée
  0 siblings, 2 replies; 3+ messages in thread
From: Sandra Loosemore @ 2019-08-27 22:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Alex Bennée, Jon Doron

Handling of the 'F' packet has been broken since commit
4b20fab101b9e2d0fb47454209637a17fc7a13d5, which converted it to use
the new packet parsing infrastructure.  Per the GDB RSP specification

https://sourceware.org/gdb/current/onlinedocs/gdb/The-F-Reply-Packet.html

the second parameter may be omitted, but the rewritten implementation
was failing to recognize this case.  The result was that QEMU was
repeatedly resending the fileio request and ignoring GDB's replies of
successful completion.  This patch restores the behavior of the
previous code in allowing the errno parameter to be omitted and
passing 0 to the callback in that case.

Signed-off-by: Sandra Loosemore <sandra@codesourcery.com>
---
 gdbstub.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gdbstub.c b/gdbstub.c
index b92ba59..3e8bcd0 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1820,11 +1820,15 @@ static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx)
 
 static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx)
 {
-    if (gdb_ctx->num_params >= 2 && gdb_ctx->s->current_syscall_cb) {
+    if (gdb_ctx->num_params >= 1 && gdb_ctx->s->current_syscall_cb) {
         target_ulong ret, err;
 
         ret = (target_ulong)gdb_ctx->params[0].val_ull;
-        err = (target_ulong)gdb_ctx->params[1].val_ull;
+        if (gdb_ctx->num_params >= 2) {
+            err = (target_ulong)gdb_ctx->params[1].val_ull;
+        } else {
+            err = 0;
+        }
         gdb_ctx->s->current_syscall_cb(gdb_ctx->s->c_cpu, ret, err);
         gdb_ctx->s->current_syscall_cb = NULL;
     }
-- 
2.8.1



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

* Re: [Qemu-devel] [PATCH V3] gdbstub: Fix handler for 'F' packet
  2019-08-27 22:33 [Qemu-devel] [PATCH V3] gdbstub: Fix handler for 'F' packet Sandra Loosemore
@ 2019-08-28  3:12 ` Richard Henderson
  2019-08-28  8:51 ` Alex Bennée
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2019-08-28  3:12 UTC (permalink / raw)
  To: Sandra Loosemore, qemu-devel
  Cc: Alex Bennée, Philippe Mathieu-Daudé, Jon Doron

On 8/27/19 3:33 PM, Sandra Loosemore wrote:
> Handling of the 'F' packet has been broken since commit
> 4b20fab101b9e2d0fb47454209637a17fc7a13d5, which converted it to use
> the new packet parsing infrastructure.  Per the GDB RSP specification
> 
> https://sourceware.org/gdb/current/onlinedocs/gdb/The-F-Reply-Packet.html
> 
> the second parameter may be omitted, but the rewritten implementation
> was failing to recognize this case.  The result was that QEMU was
> repeatedly resending the fileio request and ignoring GDB's replies of
> successful completion.  This patch restores the behavior of the
> previous code in allowing the errno parameter to be omitted and
> passing 0 to the callback in that case.
> 
> Signed-off-by: Sandra Loosemore <sandra@codesourcery.com>
> ---
>  gdbstub.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~



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

* Re: [Qemu-devel] [PATCH V3] gdbstub: Fix handler for 'F' packet
  2019-08-27 22:33 [Qemu-devel] [PATCH V3] gdbstub: Fix handler for 'F' packet Sandra Loosemore
  2019-08-28  3:12 ` Richard Henderson
@ 2019-08-28  8:51 ` Alex Bennée
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Bennée @ 2019-08-28  8:51 UTC (permalink / raw)
  To: Sandra Loosemore; +Cc: Philippe Mathieu-Daudé, qemu-devel, Jon Doron


Sandra Loosemore <sandra@codesourcery.com> writes:

> Handling of the 'F' packet has been broken since commit
> 4b20fab101b9e2d0fb47454209637a17fc7a13d5, which converted it to use
> the new packet parsing infrastructure.  Per the GDB RSP specification
>
> https://sourceware.org/gdb/current/onlinedocs/gdb/The-F-Reply-Packet.html
>
> the second parameter may be omitted, but the rewritten implementation
> was failing to recognize this case.  The result was that QEMU was
> repeatedly resending the fileio request and ignoring GDB's replies of
> successful completion.  This patch restores the behavior of the
> previous code in allowing the errno parameter to be omitted and
> passing 0 to the callback in that case.
>
> Signed-off-by: Sandra Loosemore <sandra@codesourcery.com>

Queued to gdbstub/next, thanks.

> ---
>  gdbstub.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/gdbstub.c b/gdbstub.c
> index b92ba59..3e8bcd0 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -1820,11 +1820,15 @@ static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx)
>
>  static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx)
>  {
> -    if (gdb_ctx->num_params >= 2 && gdb_ctx->s->current_syscall_cb) {
> +    if (gdb_ctx->num_params >= 1 && gdb_ctx->s->current_syscall_cb) {
>          target_ulong ret, err;
>
>          ret = (target_ulong)gdb_ctx->params[0].val_ull;
> -        err = (target_ulong)gdb_ctx->params[1].val_ull;
> +        if (gdb_ctx->num_params >= 2) {
> +            err = (target_ulong)gdb_ctx->params[1].val_ull;
> +        } else {
> +            err = 0;
> +        }
>          gdb_ctx->s->current_syscall_cb(gdb_ctx->s->c_cpu, ret, err);
>          gdb_ctx->s->current_syscall_cb = NULL;
>      }


--
Alex Bennée


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

end of thread, other threads:[~2019-08-28  8:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-27 22:33 [Qemu-devel] [PATCH V3] gdbstub: Fix handler for 'F' packet Sandra Loosemore
2019-08-28  3:12 ` Richard Henderson
2019-08-28  8:51 ` Alex Bennée

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).