[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 05/24] gdbstub: move GDBState to shared internals header
From: |
Alex Bennée |
Subject: |
[PATCH v3 05/24] gdbstub: move GDBState to shared internals header |
Date: |
Tue, 21 Feb 2023 22:52:08 +0000 |
We are about to split softmmu and user mode helpers into different
files. To facilitate this we will need to share access to the GDBState
between those files.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
v3
- as we split user/system state earlier we can remove the #define hack
---
gdbstub/internals.h | 50 +++++++++++++++++++++++++++++++++++++++++++++
gdbstub/gdbstub.c | 42 -------------------------------------
2 files changed, 50 insertions(+), 42 deletions(-)
diff --git a/gdbstub/internals.h b/gdbstub/internals.h
index b444f24ef5..de56328a2c 100644
--- a/gdbstub/internals.h
+++ b/gdbstub/internals.h
@@ -9,6 +9,56 @@
#ifndef GDBSTUB_INTERNALS_H
#define GDBSTUB_INTERNALS_H
+#define MAX_PACKET_LENGTH 4096
+
+/*
+ * Shared structures and definitions
+ */
+
+typedef struct GDBProcess {
+ uint32_t pid;
+ bool attached;
+
+ char target_xml[1024];
+} GDBProcess;
+
+enum RSState {
+ RS_INACTIVE,
+ RS_IDLE,
+ RS_GETLINE,
+ RS_GETLINE_ESC,
+ RS_GETLINE_RLE,
+ RS_CHKSUM1,
+ RS_CHKSUM2,
+};
+
+typedef struct GDBState {
+ bool init; /* have we been initialised? */
+ CPUState *c_cpu; /* current CPU for step/continue ops */
+ CPUState *g_cpu; /* current CPU for other ops */
+ CPUState *query_cpu; /* for q{f|s}ThreadInfo */
+ enum RSState state; /* parsing state */
+ char line_buf[MAX_PACKET_LENGTH];
+ int line_buf_index;
+ int line_sum; /* running checksum */
+ int line_csum; /* checksum at the end of the packet */
+ GByteArray *last_packet;
+ int signal;
+ bool multiprocess;
+ GDBProcess *processes;
+ int process_num;
+ char syscall_buf[256];
+ gdb_syscall_complete_cb current_syscall_cb;
+ GString *str_buf;
+ GByteArray *mem_buf;
+ int sstep_flags;
+ int supported_sstep_flags;
+} GDBState;
+
+/*
+ * Break/Watch point support - there is an implementation for softmmu
+ * and user mode.
+ */
bool gdb_supports_guest_debug(void);
int gdb_breakpoint_insert(CPUState *cs, int type, hwaddr addr, hwaddr len);
int gdb_breakpoint_remove(CPUState *cs, int type, hwaddr addr, hwaddr len);
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index 86564adeba..f419425cb0 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -41,8 +41,6 @@
#include "hw/boards.h"
#endif
-#define MAX_PACKET_LENGTH 4096
-
#include "qemu/sockets.h"
#include "sysemu/hw_accel.h"
#include "sysemu/runstate.h"
@@ -326,23 +324,6 @@ typedef struct GDBRegisterState {
struct GDBRegisterState *next;
} GDBRegisterState;
-typedef struct GDBProcess {
- uint32_t pid;
- bool attached;
-
- char target_xml[1024];
-} GDBProcess;
-
-enum RSState {
- RS_INACTIVE,
- RS_IDLE,
- RS_GETLINE,
- RS_GETLINE_ESC,
- RS_GETLINE_RLE,
- RS_CHKSUM1,
- RS_CHKSUM2,
-};
-
#ifdef CONFIG_USER_ONLY
typedef struct {
int fd;
@@ -358,29 +339,6 @@ typedef struct {
static GDBSystemState gdbserver_system_state;
#endif
-typedef struct GDBState {
- bool init; /* have we been initialised? */
- CPUState *c_cpu; /* current CPU for step/continue ops */
- CPUState *g_cpu; /* current CPU for other ops */
- CPUState *query_cpu; /* for q{f|s}ThreadInfo */
- enum RSState state; /* parsing state */
- char line_buf[MAX_PACKET_LENGTH];
- int line_buf_index;
- int line_sum; /* running checksum */
- int line_csum; /* checksum at the end of the packet */
- GByteArray *last_packet;
- int signal;
- bool multiprocess;
- GDBProcess *processes;
- int process_num;
- char syscall_buf[256];
- gdb_syscall_complete_cb current_syscall_cb;
- GString *str_buf;
- GByteArray *mem_buf;
- int sstep_flags;
- int supported_sstep_flags;
-} GDBState;
-
static GDBState gdbserver_state;
static void init_gdbserver_state(void)
--
2.39.1
- [PATCH v3 00/24] gdbstub: re-organise to for better compilation behaviour, Alex Bennée, 2023/02/21
- [PATCH v3 01/24] gdbstub/internals.h: clean up include guard, Alex Bennée, 2023/02/21
- [PATCH v3 03/24] gdbstub: Make syscall_complete/[gs]et_reg target-agnostic typedefs, Alex Bennée, 2023/02/21
- [PATCH v3 02/24] gdbstub: fix-up copyright and license files, Alex Bennée, 2023/02/21
- [PATCH v3 04/24] gdbstub: define separate user/system structures, Alex Bennée, 2023/02/21
- [PATCH v3 05/24] gdbstub: move GDBState to shared internals header,
Alex Bennée <=
- [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