[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4.5 08/29] gdbstub: move fromhex/tohex routines to internals
From: |
Richard Henderson |
Subject: |
[PATCH v4.5 08/29] gdbstub: move fromhex/tohex routines to internals |
Date: |
Thu, 2 Mar 2023 18:57:44 -0800 |
From: Alex Bennée <alex.bennee@linaro.org>
These will be needed from multiple places in the code. They are
declared as inline so move to the header and fix up to modern coding
style.
The only other place that messes with hex stuff at the moment is the
URI handling in utils but that would be more code churn so leave for
now.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20230302190846.2593720-9-alex.bennee@linaro.org>
---
gdbstub/internals.h | 27 +++++++++++++++++++++++++++
gdbstub/gdbstub.c | 20 --------------------
2 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/gdbstub/internals.h b/gdbstub/internals.h
index 32daaf73a3..b4620f99c4 100644
--- a/gdbstub/internals.h
+++ b/gdbstub/internals.h
@@ -57,6 +57,33 @@ typedef struct GDBState {
int supported_sstep_flags;
} GDBState;
+
+/*
+ * 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';
+ }
+}
+
/*
* Break/Watch point support - there is an implementation for softmmu
* and user mode.
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index abb1777e73..ba46ed73b3 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -546,26 +546,6 @@ static void put_buffer(const uint8_t *buf, int len)
#endif
}
-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';
-}
-
/* writes 2*len+1 bytes in buf */
static void memtohex(GString *buf, const uint8_t *mem, int len)
{
--
2.34.1
- [PATCH v4.5 00/29] gdbstub/next: re-organise and split build, Richard Henderson, 2023/03/02
- [PATCH v4.5 01/29] gdbstub/internals.h: clean up include guard, Richard Henderson, 2023/03/02
- [PATCH v4.5 02/29] gdbstub: fix-up copyright and license files, Richard Henderson, 2023/03/02
- [PATCH v4.5 05/29] gdbstub: define separate user/system structures, Richard Henderson, 2023/03/02
- [PATCH v4.5 06/29] gdbstub: move GDBState to shared internals header, Richard Henderson, 2023/03/02
- [PATCH v4.5 08/29] gdbstub: move fromhex/tohex routines to internals,
Richard Henderson <=
- [PATCH v4.5 09/29] gdbstub: make various helpers visible to the rest of the module, Richard Henderson, 2023/03/02
- [PATCH v4.5 10/29] gdbstub: move chunk of softmmu functionality to own file, Richard Henderson, 2023/03/02
- [PATCH v4.5 12/29] gdbstub: rationalise signal mapping in softmmu, Richard Henderson, 2023/03/02
- [PATCH v4.5 11/29] gdbstub: move chunks of user code into own files, Richard Henderson, 2023/03/02
- [PATCH v4.5 03/29] gdbstub: Make syscall_complete/[gs]et_reg target-agnostic typedefs, Richard Henderson, 2023/03/02
- [PATCH v4.5 04/29] gdbstub: clean-up indent on gdb_exit, Richard Henderson, 2023/03/02
- [PATCH v4.5 16/29] gdbstub: introduce gdb_get_max_cpus, Richard Henderson, 2023/03/02
- [PATCH v4.5 13/29] gdbstub: abstract target specific details from gdb_put_packet_binary, Richard Henderson, 2023/03/02
- [PATCH v4.5 14/29] gdbstub: specialise handle_query_attached, Richard Henderson, 2023/03/02
- [PATCH v4.5 15/29] gdbstub: specialise target_memory_rw_debug, Richard Henderson, 2023/03/02