[Qemu-devel] [PATCH] gdbstub: Fix handling of '!' packet with new infra

Ramiro Polla posted 1 patch 4 years, 8 months ago
Test checkpatch passed
Test s390x passed
Test asan passed
Test docker-mingw@fedora passed
Test FreeBSD passed
Test docker-clang@ubuntu passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20190805190901.14072-1-ramiro.polla@gmail.com
Maintainers: "Philippe Mathieu-Daudé" <philmd@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>
gdbstub.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[Qemu-devel] [PATCH] gdbstub: Fix handling of '!' packet with new infra
Posted by Ramiro Polla 4 years, 8 months ago
Since the '!' packet is not handled by the new infrastructure,
gdb_handle_packet() would call run_cmd_parser() with a NULL cmd_parser
value, which would lead to an unsupported packet ("$#00") being sent,
which could confuse the gdb client.

This also has a side-effect of speeding up the initial connection with
gdb.

Fixes: 3e2c12615b52 ("gdbstub: Implement deatch (D pkt) with new infra")
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
---
 gdbstub.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gdbstub.c b/gdbstub.c
index b470aec8ea..d051344488 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -2587,7 +2587,9 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
         break;
     }
 
-    run_cmd_parser(s, line_buf, cmd_parser);
+    if (cmd_parser) {
+        run_cmd_parser(s, line_buf, cmd_parser);
+    }
 
     return RS_IDLE;
 }
-- 
2.11.0


Re: [Qemu-devel] [PATCH] gdbstub: Fix handling of '!' packet with new infra
Posted by Alex Bennée 4 years, 8 months ago
Ramiro Polla <ramiro.polla@gmail.com> writes:

> Since the '!' packet is not handled by the new infrastructure,
> gdb_handle_packet() would call run_cmd_parser() with a NULL cmd_parser
> value, which would lead to an unsupported packet ("$#00") being sent,
> which could confuse the gdb client.
>
> This also has a side-effect of speeding up the initial connection with
> gdb.
>
> Fixes: 3e2c12615b52 ("gdbstub: Implement deatch (D pkt) with new infra")
> Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>

Queued to gdbstub/next, thanks.

> ---
>  gdbstub.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/gdbstub.c b/gdbstub.c
> index b470aec8ea..d051344488 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -2587,7 +2587,9 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
>          break;
>      }
>
> -    run_cmd_parser(s, line_buf, cmd_parser);
> +    if (cmd_parser) {
> +        run_cmd_parser(s, line_buf, cmd_parser);
> +    }
>
>      return RS_IDLE;
>  }


--
Alex Bennée