[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 07/24] gdbstub: move fromhex/tohex routines to internals
From: |
Alex Bennée |
Subject: |
[PATCH v3 07/24] gdbstub: move fromhex/tohex routines to internals |
Date: |
Tue, 21 Feb 2023 22:52:10 +0000 |
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>
---
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 de56328a2c..6be05fac9f 100644
--- a/gdbstub/internals.h
+++ b/gdbstub/internals.h
@@ -55,6 +55,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 d8bf90361e..4407706aa3 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.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 02/24] gdbstub: fix-up copyright and license files, 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 05/24] gdbstub: move GDBState to shared internals header, Alex Bennée, 2023/02/21
- [PATCH v3 04/24] gdbstub: define separate user/system structures, Alex Bennée, 2023/02/21
- [PATCH v3 06/24] includes: move tb_flush into its own header, Alex Bennée, 2023/02/21
- [PATCH v3 11/24] gdbstub: rationalise signal mapping in softmmu, Alex Bennée, 2023/02/21
- [PATCH v3 07/24] gdbstub: move fromhex/tohex routines to internals,
Alex Bennée <=
- [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 13/24] gdbstub: specialise handle_query_attached, 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 23/24] include: split target_long definition from cpu-defs, Alex Bennée, 2023/02/21
- [PATCH v3 15/24] gdbstub: introduce gdb_get_max_cpus, 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 20/24] gdbstub: move syscall handling to new file, 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 17/24] gdbstub: fix address type of gdb_set_cpu_pc, Alex Bennée, 2023/02/21