[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 12/24] gdbstub: abstract target specific details from gdb_put_
From: |
Alex Bennée |
Subject: |
[PATCH v3 12/24] gdbstub: abstract target specific details from gdb_put_packet_binary |
Date: |
Tue, 21 Feb 2023 22:52:15 +0000 |
We unfortunately handle the checking of packet acknowledgement
differently for user and softmmu modes. Abstract the user mode stuff
behind gdb_got_immediate_ack with a stub for softmmu.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
gdbstub/internals.h | 15 +++++++++++++++
gdbstub/gdbstub.c | 10 ++--------
gdbstub/softmmu.c | 8 ++++++++
gdbstub/user.c | 19 +++++++++++++++++++
4 files changed, 44 insertions(+), 8 deletions(-)
diff --git a/gdbstub/internals.h b/gdbstub/internals.h
index a3dd629ee8..3912d0de38 100644
--- a/gdbstub/internals.h
+++ b/gdbstub/internals.h
@@ -108,6 +108,21 @@ void gdb_memtohex(GString *buf, const uint8_t *mem, int
len);
void gdb_memtox(GString *buf, const char *mem, int len);
void gdb_read_byte(uint8_t ch);
+/*
+ * Packet acknowledgement - we handle this slightly differently
+ * between user and softmmu mode, mainly to deal with the differences
+ * between the flexible chardev and the direct fd approaches.
+ *
+ * We currently don't support a negotiated QStartNoAckMode
+ */
+
+/**
+ * gdb_got_immediate_ack() - check ok to continue
+ *
+ * Returns true to continue, false to re-transmit for user only, the
+ * softmmu stub always returns true.
+ */
+bool gdb_got_immediate_ack(void);
/* utility helpers */
CPUState *gdb_first_attached_cpu(void);
void gdb_append_thread_id(CPUState *cpu, GString *buf);
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index 4bf99783a6..76c24b7cb6 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -239,15 +239,9 @@ int gdb_put_packet_binary(const char *buf, int len, bool
dump)
gdb_put_buffer(gdbserver_state.last_packet->data,
gdbserver_state.last_packet->len);
-#ifdef CONFIG_USER_ONLY
- i = gdb_get_char();
- if (i < 0)
- return -1;
- if (i == '+')
+ if (gdb_got_immediate_ack()) {
break;
-#else
- break;
-#endif
+ }
}
return 0;
}
diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c
index 79674b8bea..0232e62ea4 100644
--- a/gdbstub/softmmu.c
+++ b/gdbstub/softmmu.c
@@ -55,6 +55,14 @@ int gdb_get_cpu_index(CPUState *cpu)
return cpu->cpu_index + 1;
}
+/*
+ * We check the status of the last message in the chardev receive code
+ */
+bool gdb_got_immediate_ack(void)
+{
+ return true;
+}
+
/*
* GDB Connection management. For system emulation we do all of this
* via our existing Chardev infrastructure which allows us to support
diff --git a/gdbstub/user.c b/gdbstub/user.c
index 1c9e070e57..33a0701cea 100644
--- a/gdbstub/user.c
+++ b/gdbstub/user.c
@@ -54,6 +54,25 @@ int gdb_get_char(void)
return ch;
}
+bool gdb_got_immediate_ack(void)
+{
+ int i;
+
+ i = gdb_get_char();
+ if (i < 0) {
+ /* no response, continue anyway */
+ return true;
+ }
+
+ if (i == '+') {
+ /* received correctly, continue */
+ return true;
+ }
+
+ /* anything else, including '-' then try again */
+ return false;
+}
+
void gdb_put_buffer(const uint8_t *buf, int len)
{
int ret;
--
2.39.1
- [PATCH v3 06/24] includes: move tb_flush into its own header, (continued)
- [PATCH v3 06/24] includes: move tb_flush into its own header, Alex Bennée, 2023/02/21
- [PATCH v3 07/24] gdbstub: move fromhex/tohex routines to internals, Alex Bennée, 2023/02/21
- [PATCH v3 11/24] gdbstub: rationalise signal mapping in softmmu, Alex Bennée, 2023/02/21
- [PATCH v3 08/24] gdbstub: make various helpers visible to the rest of the module, Alex Bennée, 2023/02/21
- [PATCH v3 09/24] gdbstub: move chunk of softmmu functionality to own file, Alex Bennée, 2023/02/21
- [PATCH v3 23/24] include: split target_long definition from cpu-defs, Alex Bennée, 2023/02/21
- [PATCH v3 24/24] gdbstub: split out softmmu/user specifics for syscall handling, Alex Bennée, 2023/02/21
- [PATCH v3 10/24] gdbstub: move chunks of user code into own files, Alex Bennée, 2023/02/21
- [PATCH v3 13/24] gdbstub: specialise handle_query_attached, Alex Bennée, 2023/02/21
- [PATCH v3 15/24] gdbstub: introduce gdb_get_max_cpus, Alex Bennée, 2023/02/21
- [PATCH v3 12/24] gdbstub: abstract target specific details from gdb_put_packet_binary,
Alex Bennée <=
- [PATCH v3 14/24] gdbstub: specialise target_memory_rw_debug, Alex Bennée, 2023/02/21
- [PATCH v3 18/24] gdbstub: don't use target_ulong while handling registers, Alex Bennée, 2023/02/21
- [PATCH v3 22/24] testing: probe gdb for supported architectures ahead of time, Alex Bennée, 2023/02/21
- [PATCH v3 20/24] gdbstub: move syscall handling to new file, Alex Bennée, 2023/02/21
- [PATCH v3 21/24] gdbstub: only compile gdbstub twice for whole build, Alex Bennée, 2023/02/21
- [PATCH v3 17/24] gdbstub: fix address type of gdb_set_cpu_pc, Alex Bennée, 2023/02/21
- [PATCH v3 19/24] gdbstub: move register helpers into standalone include, Alex Bennée, 2023/02/21
- [PATCH v3 16/24] gdbstub: specialise stub_can_reverse, Alex Bennée, 2023/02/21