[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 03/20] gdbstub: moving code so that it can be easier accessed
|
From: |
Nicolas Eder |
|
Subject: |
[PATCH v3 03/20] gdbstub: moving code so that it can be easier accessed from outside the gdbstub: fromhex and tohex functions moved to a cutils header. GDBRegisterState moved to gdbstub.h |
|
Date: |
Tue, 7 Nov 2023 14:03:06 +0100 |
---
gdbstub/gdbstub.c | 9 +--------
gdbstub/internals.h | 26 --------------------------
include/cutils.h | 30 ++++++++++++++++++++++++++++++
include/exec/gdbstub.h | 9 ++++++++-
4 files changed, 39 insertions(+), 35 deletions(-)
create mode 100644 include/cutils.h
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index 1e96a71c0c..c43ff89393 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -44,14 +44,7 @@
#include "exec/hwaddr.h"
#include "internals.h"
-
-typedef struct GDBRegisterState {
- int base_reg;
- int num_regs;
- gdb_get_reg_cb get_reg;
- gdb_set_reg_cb set_reg;
- const char *xml;
-} GDBRegisterState;
+#include "cutils.h"
GDBState gdbserver_state;
diff --git a/gdbstub/internals.h b/gdbstub/internals.h
index 465c24b36e..011e6f1858 100644
--- a/gdbstub/internals.h
+++ b/gdbstub/internals.h
@@ -74,32 +74,6 @@ typedef struct GDBState {
/* lives in main gdbstub.c */
extern GDBState gdbserver_state;
-/*
- * Inline utility function, convert from int to hex and back
- */
-
-static inline int fromhex(int v)
-{
- if (v >= '0' && v <= '9') {
- return v - '0';
- } else if (v >= 'A' && v <= 'F') {
- return v - 'A' + 10;
- } else if (v >= 'a' && v <= 'f') {
- return v - 'a' + 10;
- } else {
- return 0;
- }
-}
-
-static inline int tohex(int v)
-{
- if (v < 10) {
- return v + '0';
- } else {
- return v - 10 + 'a';
- }
-}
-
/*
* Connection helpers for both system and user backends
*/
diff --git a/include/cutils.h b/include/cutils.h
new file mode 100644
index 0000000000..a6b8dc3690
--- /dev/null
+++ b/include/cutils.h
@@ -0,0 +1,30 @@
+#ifndef CUTILS_H
+#define CUTILS_H
+
+/*
+ * Inline utility function, convert from int to hex and back
+ */
+
+static inline int fromhex(int v)
+{
+ if (v >= '0' && v <= '9') {
+ return v - '0';
+ } else if (v >= 'A' && v <= 'F') {
+ return v - 'A' + 10;
+ } else if (v >= 'a' && v <= 'f') {
+ return v - 'a' + 10;
+ } else {
+ return 0;
+ }
+}
+
+static inline int tohex(int v)
+{
+ if (v < 10) {
+ return v + '0';
+ } else {
+ return v - 10 + 'a';
+ }
+}
+
+#endif /* CUTILS_H */
diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h
index f696e29477..cb70ebd7b4 100644
--- a/include/exec/gdbstub.h
+++ b/include/exec/gdbstub.h
@@ -15,11 +15,18 @@ typedef struct GDBFeature {
const char *xml;
} GDBFeature;
-
/* Get or set a register. Returns the size of the register. */
typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg);
typedef int (*gdb_set_reg_cb)(CPUArchState *env, uint8_t *buf, int reg);
+typedef struct GDBRegisterState {
+ int base_reg;
+ int num_regs;
+ gdb_get_reg_cb get_reg;
+ gdb_set_reg_cb set_reg;
+ const char *xml;
+} GDBRegisterState;
+
/**
* gdb_register_coprocessor() - register a supplemental set of registers
* @cpu - the CPU associated with registers
--
2.34.1
- [PATCH v3 11/20] mcdstub: reset and trigger queries added, (continued)
- [PATCH v3 11/20] mcdstub: reset and trigger queries added, Nicolas Eder, 2023/11/07
- [PATCH v3 06/20] mcdstub: open/close server functions and trigger/reset data added. User for initial connection with an mcd client, Nicolas Eder, 2023/11/07
- [PATCH v3 12/20] mcdstub: missing parse_reg_xml function for parsing gdb register xml files added, Nicolas Eder, 2023/11/07
- [PATCH v3 13/20] mcdstub: added queries for memory spaces, register groups and registers, Nicolas Eder, 2023/11/07
- [PATCH v3 19/20] mcdstub: break/watchpoints added, Nicolas Eder, 2023/11/07
- [PATCH v3 14/20] mcdstub: missing handle_query_state function added, Nicolas Eder, 2023/11/07
- [PATCH v3 04/20] mcdstub: added header with defines specific to the mcd tcp packet communication, Nicolas Eder, 2023/11/07
- [PATCH v3 16/20] mcdstub: function construct for resets added, Nicolas Eder, 2023/11/07
- [PATCH v3 15/20] mcdstub: added go, break and step functionality and all corresponding functions, Nicolas Eder, 2023/11/07
- [PATCH v3 03/20] gdbstub: moving code so that it can be easier accessed from outside the gdbstub: fromhex and tohex functions moved to a cutils header. GDBRegisterState moved to gdbstub.h,
Nicolas Eder <=
- [PATCH v3 17/20] mcdstub: reading/writing registers added, Nicolas Eder, 2023/11/07
- Re: [PATCH v3 00/20] first version of mcdstub, Philippe Mathieu-Daudé, 2023/11/08
- Re: [PATCH v3 00/20] first version of mcdstub, Alex Bennée, 2023/11/29