All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: f4bug@amsat.org, mads@ynddal.dk,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH  v1 05/10] gdbstub: move GDBState to shared internals header
Date: Fri, 16 Dec 2022 11:22:01 +0000	[thread overview]
Message-ID: <20221216112206.3171578-6-alex.bennee@linaro.org> (raw)
In-Reply-To: <20221216112206.3171578-1-alex.bennee@linaro.org>

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.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 gdbstub/internals.h | 53 +++++++++++++++++++++++++++++++++++++++++++++
 gdbstub/gdbstub.c   | 47 ++--------------------------------------
 2 files changed, 55 insertions(+), 45 deletions(-)

diff --git a/gdbstub/internals.h b/gdbstub/internals.h
index b444f24ef5..462a93e41c 100644
--- a/gdbstub/internals.h
+++ b/gdbstub/internals.h
@@ -9,6 +9,59 @@
 #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 GDBConnection GDBConnection;
+
+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;
+    GDBConnection *connection;
+    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 14ce911bf2..bc43aaf825 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,60 +324,19 @@ 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 {
+typedef struct GDBConnection {
     int fd;
     char *socket_path;
     int running_state;
 } GDBConnection;
 #else
-typedef struct {
+typedef struct GDBConnection {
     CharBackend chr;
     Chardev *mon_chr;
 } GDBConnection;
 #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;
-    GDBConnection *connection;
-    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.34.1



  parent reply	other threads:[~2022-12-16 11:23 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16 11:21 [PATCH v1 00/10] split user and system code in gdbstub Alex Bennée
2022-12-16 11:21 ` [PATCH v1 01/10] gdbstub/internals.h: clean up include guard Alex Bennée
2022-12-16 19:17   ` Richard Henderson
2022-12-16 11:21 ` [PATCH v1 02/10] gdbstub: fix-up copyright and license files Alex Bennée
2022-12-16 19:39   ` Richard Henderson
2022-12-16 11:21 ` [PATCH v1 03/10] gdbstub: Make syscall_complete/[gs]et_reg target-agnostic typedefs Alex Bennée
2022-12-16 11:22 ` [PATCH v1 04/10] gdbstub: split GDBConnection from main structure Alex Bennée
2022-12-16 15:29   ` Fabiano Rosas
2022-12-21 16:56     ` Alex Bennée
2022-12-16 20:11   ` Richard Henderson
2022-12-16 11:22 ` Alex Bennée [this message]
2022-12-16 20:02   ` [PATCH v1 05/10] gdbstub: move GDBState to shared internals header Richard Henderson
2022-12-16 11:22 ` [PATCH v1 06/10] includes: move tb_flush into its own header Alex Bennée
2022-12-16 20:01   ` Richard Henderson
2022-12-16 11:22 ` [PATCH v1 07/10] includes: add new gdbstub include directory Alex Bennée
2022-12-16 20:37   ` Richard Henderson
2022-12-16 11:22 ` [PATCH v1 08/10] gdbstub: move chunk of softmmu functionality to own file Alex Bennée
2022-12-16 15:52   ` Fabiano Rosas
2022-12-16 20:27   ` Richard Henderson
2022-12-16 11:22 ` [PATCH v1 09/10] gdbstub: move chunks of user code into own files Alex Bennée
2022-12-16 16:38   ` Fabiano Rosas
2022-12-16 11:22 ` [PATCH v1 10/10] gdbstub: retire exec/gdbstub.h Alex Bennée

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221216112206.3171578-6-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=f4bug@amsat.org \
    --cc=mads@ynddal.dk \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.