All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH  v1 0/6] gdbstub (auxv, tests, cleanup)
@ 2020-12-14 15:30 Alex Bennée
  2020-12-14 15:30 ` [PATCH v1 1/6] test/guest-debug: echo QEMU command as well Alex Bennée
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Alex Bennée @ 2020-12-14 15:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Bennée

Hi,

I realised I had a pending gdbstub fix in my trees and then
immediately ran into a bunch of minor niggles after looking at a gdb
failure Peter ran into. The upshot is I've just hard gated the gdb
tests to a more-recent than most distros version of gdb which
hopefully involves less faff. I also did a bit of clean-up to the
handling of cleaning up while I was at it. 

Please review.

Alex Bennée (5):
  test/guest-debug: echo QEMU command as well
  configure: gate our use of GDB to 8.3.1 or above
  gdbstub: drop CPUEnv from gdb_exit()
  gdbstub: drop gdbserver_cleanup in favour of gdb_exit
  gdbstub: ensure we clean-up when terminated

Lirong Yuan (1):
  gdbstub: add support to Xfer:auxv:read: packet

 configure                                     |  7 +-
 include/exec/gdbstub.h                        | 14 +++-
 bsd-user/syscall.c                            |  6 +-
 gdbstub.c                                     | 65 ++++++++++++++++---
 linux-user/exit.c                             |  2 +-
 softmmu/vl.c                                  |  2 +-
 target/arm/arm-semi.c                         |  2 +-
 target/m68k/m68k-semi.c                       |  2 +-
 target/nios2/nios2-semi.c                     |  2 +-
 MAINTAINERS                                   |  1 +
 tests/guest-debug/run-test.py                 |  1 +
 tests/tcg/multiarch/Makefile.target           |  9 ++-
 .../multiarch/gdbstub/test-qxfer-auxv-read.py | 57 ++++++++++++++++
 13 files changed, 148 insertions(+), 22 deletions(-)
 create mode 100644 tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py

-- 
2.20.1



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

* [PATCH  v1 1/6] test/guest-debug: echo QEMU command as well
  2020-12-14 15:30 [PATCH v1 0/6] gdbstub (auxv, tests, cleanup) Alex Bennée
@ 2020-12-14 15:30 ` Alex Bennée
  2020-12-14 15:30 ` [PATCH v1 2/6] configure: gate our use of GDB to 8.3.1 or above Alex Bennée
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Alex Bennée @ 2020-12-14 15:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Bennée

This helps with debugging.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/guest-debug/run-test.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py
index 71c5569054..0c4f5c3808 100755
--- a/tests/guest-debug/run-test.py
+++ b/tests/guest-debug/run-test.py
@@ -53,6 +53,7 @@ if __name__ == '__main__':
         cmd = "%s %s -g %s %s" % (args.qemu, args.qargs, socket_name,
                                   args.binary)
 
+    print("QEMU CMD: %s" % (cmd))
     inferior = subprocess.Popen(shlex.split(cmd))
 
     # Now launch gdb with our test and collect the result
-- 
2.20.1



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

* [PATCH  v1 2/6] configure: gate our use of GDB to 8.3.1 or above
  2020-12-14 15:30 [PATCH v1 0/6] gdbstub (auxv, tests, cleanup) Alex Bennée
  2020-12-14 15:30 ` [PATCH v1 1/6] test/guest-debug: echo QEMU command as well Alex Bennée
@ 2020-12-14 15:30 ` Alex Bennée
  2020-12-14 15:47   ` Peter Maydell
  2020-12-14 15:30 ` [PATCH v1 3/6] gdbstub: add support to Xfer:auxv:read: packet Alex Bennée
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Alex Bennée @ 2020-12-14 15:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Bennée

Certain earlier versions of GDB have (possibly distro) derived issues
when running against multiarch guests. Also given the problem of
clashing ports it is preferable to use socket comms rather than TCP
ports for testing.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 configure | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 11f5878a59..f6347382e9 100755
--- a/configure
+++ b/configure
@@ -6721,8 +6721,11 @@ if test "$plugins" = "yes" ; then
     fi
 fi
 
-if test -n "$gdb_bin" ; then
-    echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
+if test -n "$gdb_bin"; then
+    gdb_version=$($gdb_bin --version | head -n 1)
+    if version_ge ${gdb_version##* } 8.3.1; then
+        echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
+    fi
 fi
 
 if test "$secret_keyring" = "yes" ; then
-- 
2.20.1



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

* [PATCH  v1 3/6] gdbstub: add support to Xfer:auxv:read: packet
  2020-12-14 15:30 [PATCH v1 0/6] gdbstub (auxv, tests, cleanup) Alex Bennée
  2020-12-14 15:30 ` [PATCH v1 1/6] test/guest-debug: echo QEMU command as well Alex Bennée
  2020-12-14 15:30 ` [PATCH v1 2/6] configure: gate our use of GDB to 8.3.1 or above Alex Bennée
@ 2020-12-14 15:30 ` Alex Bennée
  2020-12-16 19:54   ` Richard Henderson
  2020-12-14 15:30 ` [PATCH v1 4/6] gdbstub: drop CPUEnv from gdb_exit() Alex Bennée
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Alex Bennée @ 2020-12-14 15:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Alex Bennée, Lirong Yuan

From: Lirong Yuan <yuanzi@google.com>

This allows gdb to access the target’s auxiliary vector,
which can be helpful for telling system libraries important details
about the hardware, operating system, and process.

Signed-off-by: Lirong Yuan <yuanzi@google.com>
[AJB: minor tweaks to test case, update MAINTAINERS]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200730193932.3654677-1-yuanzi@google.com>
---
 gdbstub.c                                     | 54 ++++++++++++++++++
 MAINTAINERS                                   |  1 +
 tests/tcg/multiarch/Makefile.target           |  9 ++-
 .../multiarch/gdbstub/test-qxfer-auxv-read.py | 57 +++++++++++++++++++
 4 files changed, 120 insertions(+), 1 deletion(-)
 create mode 100644 tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py

diff --git a/gdbstub.c b/gdbstub.c
index f19f98ab1a..ec8daa002b 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -2172,6 +2172,12 @@ static void handle_query_supported(GdbCmdContext *gdb_ctx, void *user_ctx)
             ";ReverseStep+;ReverseContinue+");
     }
 
+#ifdef CONFIG_USER_ONLY
+    if (gdbserver_state.c_cpu->opaque) {
+        g_string_append(gdbserver_state.str_buf, ";qXfer:auxv:read+");
+    }
+#endif
+
     if (gdb_ctx->num_params &&
         strstr(gdb_ctx->params[0].data, "multiprocess+")) {
         gdbserver_state.multiprocess = true;
@@ -2233,6 +2239,46 @@ static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_ctx)
                       gdbserver_state.str_buf->len, true);
 }
 
+#ifdef CONFIG_USER_ONLY
+static void handle_query_xfer_auxv(GdbCmdContext *gdb_ctx, void *user_ctx)
+{
+    TaskState *ts;
+    unsigned long offset, len, saved_auxv, auxv_len;
+    const char *mem;
+
+    if (gdb_ctx->num_params < 2) {
+        put_packet("E22");
+        return;
+    }
+
+    offset = gdb_ctx->params[0].val_ul;
+    len = gdb_ctx->params[1].val_ul;
+    ts = gdbserver_state.c_cpu->opaque;
+    saved_auxv = ts->info->saved_auxv;
+    auxv_len = ts->info->auxv_len;
+    mem = (const char *)(saved_auxv + offset);
+    if (offset > auxv_len) {
+        put_packet("E00");
+        return;
+    }
+
+    if (len > (MAX_PACKET_LENGTH - 5) / 2) {
+        len = (MAX_PACKET_LENGTH - 5) / 2;
+    }
+
+    if (len < auxv_len - offset) {
+        g_string_assign(gdbserver_state.str_buf, "m");
+        memtox(gdbserver_state.str_buf, mem, len);
+    } else {
+        g_string_assign(gdbserver_state.str_buf, "l");
+        memtox(gdbserver_state.str_buf, mem, auxv_len - offset);
+    }
+
+    put_packet_binary(gdbserver_state.str_buf->str,
+                      gdbserver_state.str_buf->len, true);
+}
+#endif
+
 static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx)
 {
     put_packet(GDB_ATTACHED);
@@ -2338,6 +2384,14 @@ static GdbCmdParseEntry gdb_gen_query_table[] = {
         .cmd_startswith = 1,
         .schema = "s:l,l0"
     },
+#ifdef CONFIG_USER_ONLY
+    {
+        .handler = handle_query_xfer_auxv,
+        .cmd = "Xfer:auxv:read::",
+        .cmd_startswith = 1,
+        .schema = "l,l0"
+    },
+#endif
     {
         .handler = handle_query_attached,
         .cmd = "Attached:",
diff --git a/MAINTAINERS b/MAINTAINERS
index a83416d54c..9dedc37be4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2295,6 +2295,7 @@ R: Philippe Mathieu-Daudé <philmd@redhat.com>
 S: Maintained
 F: gdbstub*
 F: gdb-xml/
+F: tests/tcg/multiarch/gdbstub/
 
 Memory API
 M: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target
index cb49cc9ccb..c8cdb1e04d 100644
--- a/tests/tcg/multiarch/Makefile.target
+++ b/tests/tcg/multiarch/Makefile.target
@@ -54,7 +54,14 @@ run-gdbstub-sha1: sha1
 		--bin $< --test $(MULTIARCH_SRC)/gdbstub/sha1.py, \
 	"basic gdbstub support")
 
-EXTRA_RUNS += run-gdbstub-sha1
+run-gdbstub-qxfer-auxv-read: sha1
+	$(call run-test, $@, $(GDB_SCRIPT) \
+		--gdb $(HAVE_GDB_BIN) \
+		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
+		--bin $< --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-auxv-read.py, \
+	"basic gdbstub qXfer:auxv:read support")
+
+EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read
 endif
 
 
diff --git a/tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py b/tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py
new file mode 100644
index 0000000000..d91e8fdf19
--- /dev/null
+++ b/tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py
@@ -0,0 +1,57 @@
+from __future__ import print_function
+#
+# Test auxiliary vector is loaded via gdbstub
+#
+# This is launched via tests/guest-debug/run-test.py
+#
+
+import gdb
+import sys
+
+failcount = 0
+
+def report(cond, msg):
+    "Report success/fail of test"
+    if cond:
+        print ("PASS: %s" % (msg))
+    else:
+        print ("FAIL: %s" % (msg))
+        global failcount
+        failcount += 1
+
+def run_test():
+    "Run through the tests one by one"
+
+    auxv = gdb.execute("info auxv", False, True)
+    report(isinstance(auxv, str), "Fetched auxv from inferior")
+    report(auxv.find("sha1"), "Found test binary name in auxv")
+
+#
+# This runs as the script it sourced (via -x, via run-test.py)
+#
+try:
+    inferior = gdb.selected_inferior()
+    arch = inferior.architecture()
+    print("ATTACHED: %s" % arch.name())
+except (gdb.error, AttributeError):
+    print("SKIPPING (not connected)", file=sys.stderr)
+    exit(0)
+
+if gdb.parse_and_eval('$pc') == 0:
+    print("SKIP: PC not set")
+    exit(0)
+
+try:
+    # These are not very useful in scripts
+    gdb.execute("set pagination off")
+    gdb.execute("set confirm off")
+
+    # Run the actual tests
+    run_test()
+except (gdb.error):
+    print ("GDB Exception: %s" % (sys.exc_info()[0]))
+    failcount += 1
+    pass
+
+print("All tests complete: %d failures" % failcount)
+exit(failcount)
-- 
2.20.1



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

* [PATCH  v1 4/6] gdbstub: drop CPUEnv from gdb_exit()
  2020-12-14 15:30 [PATCH v1 0/6] gdbstub (auxv, tests, cleanup) Alex Bennée
                   ` (2 preceding siblings ...)
  2020-12-14 15:30 ` [PATCH v1 3/6] gdbstub: add support to Xfer:auxv:read: packet Alex Bennée
@ 2020-12-14 15:30 ` Alex Bennée
  2020-12-16 19:55   ` Richard Henderson
  2020-12-14 15:30 ` [PATCH v1 5/6] gdbstub: drop gdbserver_cleanup in favour of gdb_exit Alex Bennée
  2020-12-14 15:30 ` [PATCH v1 6/6] gdbstub: ensure we clean-up when terminated Alex Bennée
  5 siblings, 1 reply; 14+ messages in thread
From: Alex Bennée @ 2020-12-14 15:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marek Vasut, Peter Maydell, Alex Bennée, Chris Wulff,
	Laurent Vivier, open list:ARM TCG CPUs,
	Philippe Mathieu-Daudé

gdb_exit() has never needed anything from env and I doubt we are going
to start now.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 include/exec/gdbstub.h    | 2 +-
 bsd-user/syscall.c        | 6 +++---
 gdbstub.c                 | 2 +-
 linux-user/exit.c         | 2 +-
 target/arm/arm-semi.c     | 2 +-
 target/m68k/m68k-semi.c   | 2 +-
 target/nios2/nios2-semi.c | 2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h
index 94d8f83e92..492db0f512 100644
--- a/include/exec/gdbstub.h
+++ b/include/exec/gdbstub.h
@@ -46,7 +46,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);
 void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va);
 int use_gdb_syscalls(void);
 void gdb_set_stop_cpu(CPUState *cpu);
-void gdb_exit(CPUArchState *, int);
+void gdb_exit(int);
 #ifdef CONFIG_USER_ONLY
 /**
  * gdb_handlesig: yield control to gdb
diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
index d38ec7a162..adc3d21b54 100644
--- a/bsd-user/syscall.c
+++ b/bsd-user/syscall.c
@@ -333,7 +333,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
 #ifdef CONFIG_GPROF
         _mcleanup();
 #endif
-        gdb_exit(cpu_env, arg1);
+        gdb_exit(arg1);
         qemu_plugin_atexit_cb();
         /* XXX: should free thread stack and CPU env */
         _exit(arg1);
@@ -435,7 +435,7 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1,
 #ifdef CONFIG_GPROF
         _mcleanup();
 #endif
-        gdb_exit(cpu_env, arg1);
+        gdb_exit(arg1);
         qemu_plugin_atexit_cb();
         /* XXX: should free thread stack and CPU env */
         _exit(arg1);
@@ -514,7 +514,7 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
 #ifdef CONFIG_GPROF
         _mcleanup();
 #endif
-        gdb_exit(cpu_env, arg1);
+        gdb_exit(arg1);
         qemu_plugin_atexit_cb();
         /* XXX: should free thread stack and CPU env */
         _exit(arg1);
diff --git a/gdbstub.c b/gdbstub.c
index ec8daa002b..f6566c7b82 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -3068,7 +3068,7 @@ static void gdb_read_byte(uint8_t ch)
 }
 
 /* Tell the remote gdb that the process has exited.  */
-void gdb_exit(CPUArchState *env, int code)
+void gdb_exit(int code)
 {
   char buf[4];
 
diff --git a/linux-user/exit.c b/linux-user/exit.c
index 1594015444..70b344048c 100644
--- a/linux-user/exit.c
+++ b/linux-user/exit.c
@@ -34,6 +34,6 @@ void preexit_cleanup(CPUArchState *env, int code)
 #ifdef CONFIG_GCOV
         __gcov_dump();
 #endif
-        gdb_exit(env, code);
+        gdb_exit(code);
         qemu_plugin_atexit_cb();
 }
diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c
index c892e0e674..5d5654bec0 100644
--- a/target/arm/arm-semi.c
+++ b/target/arm/arm-semi.c
@@ -1100,7 +1100,7 @@ target_ulong do_arm_semihosting(CPUARMState *env)
              */
             ret = (args == ADP_Stopped_ApplicationExit) ? 0 : 1;
         }
-        gdb_exit(env, ret);
+        gdb_exit(ret);
         exit(ret);
     case TARGET_SYS_SYNCCACHE:
         /*
diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c
index 8e5fbfc8fa..6230a789b6 100644
--- a/target/m68k/m68k-semi.c
+++ b/target/m68k/m68k-semi.c
@@ -194,7 +194,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
     args = env->dregs[1];
     switch (nr) {
     case HOSTED_EXIT:
-        gdb_exit(env, env->dregs[0]);
+        gdb_exit(env->dregs[0]);
         exit(env->dregs[0]);
     case HOSTED_OPEN:
         GET_ARG(0);
diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c
index d7a80dd303..e508b2fafc 100644
--- a/target/nios2/nios2-semi.c
+++ b/target/nios2/nios2-semi.c
@@ -215,7 +215,7 @@ void do_nios2_semihosting(CPUNios2State *env)
     args = env->regs[R_ARG1];
     switch (nr) {
     case HOSTED_EXIT:
-        gdb_exit(env, env->regs[R_ARG0]);
+        gdb_exit(env->regs[R_ARG0]);
         exit(env->regs[R_ARG0]);
     case HOSTED_OPEN:
         GET_ARG(0);
-- 
2.20.1



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

* [PATCH v1 5/6] gdbstub: drop gdbserver_cleanup in favour of gdb_exit
  2020-12-14 15:30 [PATCH v1 0/6] gdbstub (auxv, tests, cleanup) Alex Bennée
                   ` (3 preceding siblings ...)
  2020-12-14 15:30 ` [PATCH v1 4/6] gdbstub: drop CPUEnv from gdb_exit() Alex Bennée
@ 2020-12-14 15:30 ` Alex Bennée
  2020-12-16 19:56   ` Richard Henderson
  2020-12-14 15:30 ` [PATCH v1 6/6] gdbstub: ensure we clean-up when terminated Alex Bennée
  5 siblings, 1 reply; 14+ messages in thread
From: Alex Bennée @ 2020-12-14 15:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Alex Bennée, Paolo Bonzini

Despite it's name it didn't actually clean-up so let us document
gdb_exit() better and use that.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 include/exec/gdbstub.h | 14 +++++++++++---
 gdbstub.c              |  7 -------
 softmmu/vl.c           |  2 +-
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h
index 492db0f512..ff0b7bc45e 100644
--- a/include/exec/gdbstub.h
+++ b/include/exec/gdbstub.h
@@ -46,7 +46,17 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);
 void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va);
 int use_gdb_syscalls(void);
 void gdb_set_stop_cpu(CPUState *cpu);
-void gdb_exit(int);
+
+/**
+ * gdb_exit: exit gdb session, reporting inferior status
+ * @code: exit code reported
+ *
+ * This closes the session and sends a final packet to GDB reporting
+ * the exit status of the program. It also cleans up any connections
+ * detritus before returning.
+ */
+void gdb_exit(int code);
+
 #ifdef CONFIG_USER_ONLY
 /**
  * gdb_handlesig: yield control to gdb
@@ -187,8 +197,6 @@ static inline uint8_t * gdb_get_reg_ptr(GByteArray *buf, int len)
  */
 int gdbserver_start(const char *port_or_device);
 
-void gdbserver_cleanup(void);
-
 /**
  * gdb_has_xml:
  * This is an ugly hack to cope with both new and old gdb.
diff --git a/gdbstub.c b/gdbstub.c
index f6566c7b82..7172f063a1 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -3547,13 +3547,6 @@ int gdbserver_start(const char *device)
     return 0;
 }
 
-void gdbserver_cleanup(void)
-{
-    if (gdbserver_state.init) {
-        put_packet("W00");
-    }
-}
-
 static void register_types(void)
 {
     type_register_static(&char_gdb_type_info);
diff --git a/softmmu/vl.c b/softmmu/vl.c
index e6e0ad5a92..0694a1d602 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -4509,7 +4509,7 @@ void qemu_init(int argc, char **argv, char **envp)
 
 void qemu_cleanup(void)
 {
-    gdbserver_cleanup();
+    gdb_exit(0);
 
     /*
      * cleaning up the migration object cancels any existing migration
-- 
2.20.1



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

* [PATCH  v1 6/6] gdbstub: ensure we clean-up when terminated
  2020-12-14 15:30 [PATCH v1 0/6] gdbstub (auxv, tests, cleanup) Alex Bennée
                   ` (4 preceding siblings ...)
  2020-12-14 15:30 ` [PATCH v1 5/6] gdbstub: drop gdbserver_cleanup in favour of gdb_exit Alex Bennée
@ 2020-12-14 15:30 ` Alex Bennée
  2020-12-16 19:56   ` Richard Henderson
  5 siblings, 1 reply; 14+ messages in thread
From: Alex Bennée @ 2020-12-14 15:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Alex Bennée

If you kill the inferior from GDB we end up leaving our socket lying
around. Fix this by calling gdb_exit() first.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 gdbstub.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gdbstub.c b/gdbstub.c
index 7172f063a1..61fe2360e3 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1978,6 +1978,7 @@ static void handle_v_kill(GdbCmdContext *gdb_ctx, void *user_ctx)
     /* Kill the target */
     put_packet("OK");
     error_report("QEMU: Terminated via GDBstub");
+    gdb_exit(0);
     exit(0);
 }
 
@@ -2539,6 +2540,7 @@ static int gdb_handle_packet(const char *line_buf)
     case 'k':
         /* Kill the target */
         error_report("QEMU: Terminated via GDBstub");
+        gdb_exit(0);
         exit(0);
     case 'D':
         {
-- 
2.20.1



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

* Re: [PATCH v1 2/6] configure: gate our use of GDB to 8.3.1 or above
  2020-12-14 15:30 ` [PATCH v1 2/6] configure: gate our use of GDB to 8.3.1 or above Alex Bennée
@ 2020-12-14 15:47   ` Peter Maydell
  2020-12-14 17:05     ` Alex Bennée
  0 siblings, 1 reply; 14+ messages in thread
From: Peter Maydell @ 2020-12-14 15:47 UTC (permalink / raw)
  To: Alex Bennée; +Cc: QEMU Developers

On Mon, 14 Dec 2020 at 15:36, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> Certain earlier versions of GDB have (possibly distro) derived issues
> when running against multiarch guests. Also given the problem of
> clashing ports it is preferable to use socket comms rather than TCP
> ports for testing.

What's a "multiarch guest" ?

Incidentally I think the problem I have been running into
with the Ubuntu gdb 8.1 is that it doesn't support registers
larger than 64 bytes, and if AArch64 QEMU is emulating SVE
then it tries to expose registers bigger than that to the
gdbstub.

thanks
-- PMM


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

* Re: [PATCH v1 2/6] configure: gate our use of GDB to 8.3.1 or above
  2020-12-14 15:47   ` Peter Maydell
@ 2020-12-14 17:05     ` Alex Bennée
  2020-12-14 17:14       ` Peter Maydell
  0 siblings, 1 reply; 14+ messages in thread
From: Alex Bennée @ 2020-12-14 17:05 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers


Peter Maydell <peter.maydell@linaro.org> writes:

> On Mon, 14 Dec 2020 at 15:36, Alex Bennée <alex.bennee@linaro.org> wrote:
>>
>> Certain earlier versions of GDB have (possibly distro) derived issues
>> when running against multiarch guests. Also given the problem of
>> clashing ports it is preferable to use socket comms rather than TCP
>> ports for testing.
>
> What's a "multiarch guest" ?

I guess non-native guest would be another way of saying it. There is
some hoop jumping to deal with the fact that some arches package up a
fully featured multiarch aware gdb and some package up the multiarch one
as a separate gdb-multiarch package.

> Incidentally I think the problem I have been running into
> with the Ubuntu gdb 8.1 is that it doesn't support registers
> larger than 64 bytes, and if AArch64 QEMU is emulating SVE
> then it tries to expose registers bigger than that to the
> gdbstub.

So this is a missing patch from Ubuntu's gdb?

We could just peg the sha1 test to cortex-a57 - your are likely not
getting the SVE tests running unless you have the compilers to build
them (or using docker).

>
> thanks
> -- PMM


-- 
Alex Bennée


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

* Re: [PATCH v1 2/6] configure: gate our use of GDB to 8.3.1 or above
  2020-12-14 17:05     ` Alex Bennée
@ 2020-12-14 17:14       ` Peter Maydell
  0 siblings, 0 replies; 14+ messages in thread
From: Peter Maydell @ 2020-12-14 17:14 UTC (permalink / raw)
  To: Alex Bennée; +Cc: QEMU Developers

On Mon, 14 Dec 2020 at 17:08, Alex Bennée <alex.bennee@linaro.org> wrote:
>
>
> Peter Maydell <peter.maydell@linaro.org> writes:
>
> > On Mon, 14 Dec 2020 at 15:36, Alex Bennée <alex.bennee@linaro.org> wrote:
> >>
> >> Certain earlier versions of GDB have (possibly distro) derived issues
> >> when running against multiarch guests. Also given the problem of
> >> clashing ports it is preferable to use socket comms rather than TCP
> >> ports for testing.
> >
> > What's a "multiarch guest" ?
>
> I guess non-native guest would be another way of saying it. There is
> some hoop jumping to deal with the fact that some arches package up a
> fully featured multiarch aware gdb and some package up the multiarch one
> as a separate gdb-multiarch package.
>
> > Incidentally I think the problem I have been running into
> > with the Ubuntu gdb 8.1 is that it doesn't support registers
> > larger than 64 bytes, and if AArch64 QEMU is emulating SVE
> > then it tries to expose registers bigger than that to the
> > gdbstub.
>
> So this is a missing patch from Ubuntu's gdb?

No, upstream 8.1 doesn't handle this either and crashes too.
I'm a bit surprised we haven't had user complaints, since
gdb+QEMU would have previously worked and then started to
crash gdb when we put in the SVE registers.

> We could just peg the sha1 test to cortex-a57 - your are likely not
> getting the SVE tests running unless you have the compilers to build
> them (or using docker).

Yeah, forcing a non-SVE CPU should allow the test to work with this gdb.

thanks
-- PMM


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

* Re: [PATCH v1 3/6] gdbstub: add support to Xfer:auxv:read: packet
  2020-12-14 15:30 ` [PATCH v1 3/6] gdbstub: add support to Xfer:auxv:read: packet Alex Bennée
@ 2020-12-16 19:54   ` Richard Henderson
  0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2020-12-16 19:54 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: Philippe Mathieu-Daudé, Lirong Yuan

On 12/14/20 9:30 AM, Alex Bennée wrote:
> From: Lirong Yuan <yuanzi@google.com>
> 
> This allows gdb to access the target’s auxiliary vector,
> which can be helpful for telling system libraries important details
> about the hardware, operating system, and process.
> 
> Signed-off-by: Lirong Yuan <yuanzi@google.com>
> [AJB: minor tweaks to test case, update MAINTAINERS]
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Message-Id: <20200730193932.3654677-1-yuanzi@google.com>
> ---
>  gdbstub.c                                     | 54 ++++++++++++++++++
>  MAINTAINERS                                   |  1 +
>  tests/tcg/multiarch/Makefile.target           |  9 ++-
>  .../multiarch/gdbstub/test-qxfer-auxv-read.py | 57 +++++++++++++++++++
>  4 files changed, 120 insertions(+), 1 deletion(-)
>  create mode 100644 tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py

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

r~


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

* Re: [PATCH v1 4/6] gdbstub: drop CPUEnv from gdb_exit()
  2020-12-14 15:30 ` [PATCH v1 4/6] gdbstub: drop CPUEnv from gdb_exit() Alex Bennée
@ 2020-12-16 19:55   ` Richard Henderson
  0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2020-12-16 19:55 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel
  Cc: Marek Vasut, Peter Maydell, Chris Wulff, Laurent Vivier,
	open list:ARM TCG CPUs, Philippe Mathieu-Daudé

On 12/14/20 9:30 AM, Alex Bennée wrote:
> gdb_exit() has never needed anything from env and I doubt we are going
> to start now.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  include/exec/gdbstub.h    | 2 +-
>  bsd-user/syscall.c        | 6 +++---
>  gdbstub.c                 | 2 +-
>  linux-user/exit.c         | 2 +-
>  target/arm/arm-semi.c     | 2 +-
>  target/m68k/m68k-semi.c   | 2 +-
>  target/nios2/nios2-semi.c | 2 +-
>  7 files changed, 9 insertions(+), 9 deletions(-)

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

r~


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

* Re: [PATCH v1 5/6] gdbstub: drop gdbserver_cleanup in favour of gdb_exit
  2020-12-14 15:30 ` [PATCH v1 5/6] gdbstub: drop gdbserver_cleanup in favour of gdb_exit Alex Bennée
@ 2020-12-16 19:56   ` Richard Henderson
  0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2020-12-16 19:56 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: Paolo Bonzini, Philippe Mathieu-Daudé

On 12/14/20 9:30 AM, Alex Bennée wrote:
> Despite it's name it didn't actually clean-up so let us document
> gdb_exit() better and use that.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  include/exec/gdbstub.h | 14 +++++++++++---
>  gdbstub.c              |  7 -------
>  softmmu/vl.c           |  2 +-
>  3 files changed, 12 insertions(+), 11 deletions(-)

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

r~


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

* Re: [PATCH v1 6/6] gdbstub: ensure we clean-up when terminated
  2020-12-14 15:30 ` [PATCH v1 6/6] gdbstub: ensure we clean-up when terminated Alex Bennée
@ 2020-12-16 19:56   ` Richard Henderson
  0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2020-12-16 19:56 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: Philippe Mathieu-Daudé

On 12/14/20 9:30 AM, Alex Bennée wrote:
> If you kill the inferior from GDB we end up leaving our socket lying
> around. Fix this by calling gdb_exit() first.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  gdbstub.c | 2 ++
>  1 file changed, 2 insertions(+)

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

r~


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

end of thread, other threads:[~2020-12-16 20:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14 15:30 [PATCH v1 0/6] gdbstub (auxv, tests, cleanup) Alex Bennée
2020-12-14 15:30 ` [PATCH v1 1/6] test/guest-debug: echo QEMU command as well Alex Bennée
2020-12-14 15:30 ` [PATCH v1 2/6] configure: gate our use of GDB to 8.3.1 or above Alex Bennée
2020-12-14 15:47   ` Peter Maydell
2020-12-14 17:05     ` Alex Bennée
2020-12-14 17:14       ` Peter Maydell
2020-12-14 15:30 ` [PATCH v1 3/6] gdbstub: add support to Xfer:auxv:read: packet Alex Bennée
2020-12-16 19:54   ` Richard Henderson
2020-12-14 15:30 ` [PATCH v1 4/6] gdbstub: drop CPUEnv from gdb_exit() Alex Bennée
2020-12-16 19:55   ` Richard Henderson
2020-12-14 15:30 ` [PATCH v1 5/6] gdbstub: drop gdbserver_cleanup in favour of gdb_exit Alex Bennée
2020-12-16 19:56   ` Richard Henderson
2020-12-14 15:30 ` [PATCH v1 6/6] gdbstub: ensure we clean-up when terminated Alex Bennée
2020-12-16 19:56   ` Richard Henderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.