From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, "Alex Bennée" <alex.bennee@linaro.org>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PULL 08/30] gdbstub: move fromhex/tohex routines to internals
Date: Tue, 7 Mar 2023 21:21:17 +0000 [thread overview]
Message-ID: <20230307212139.883112-9-alex.bennee@linaro.org> (raw)
In-Reply-To: <20230307212139.883112-1-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>
Message-Id: <20230303025805.625589-9-richard.henderson@linaro.org>
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.39.2
next prev parent reply other threads:[~2023-03-07 21:25 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-07 21:21 [PULL 00/30] gdbstub refactor for smaller build Alex Bennée
2023-03-07 21:21 ` [PULL 01/30] gdbstub/internals.h: clean up include guard Alex Bennée
2023-03-07 21:21 ` [PULL 02/30] gdbstub: fix-up copyright and license files Alex Bennée
2023-03-07 21:21 ` [PULL 03/30] gdbstub: Make syscall_complete/[gs]et_reg target-agnostic typedefs Alex Bennée
2023-03-07 21:21 ` [PULL 04/30] gdbstub: clean-up indent on gdb_exit Alex Bennée
2023-03-07 21:21 ` [PULL 05/30] gdbstub: define separate user/system structures Alex Bennée
2023-03-07 21:21 ` [PULL 06/30] gdbstub: move GDBState to shared internals header Alex Bennée
2023-03-07 21:21 ` [PULL 07/30] includes: move tb_flush into its own header Alex Bennée
2023-03-07 21:21 ` Alex Bennée [this message]
2023-03-07 21:21 ` [PULL 09/30] gdbstub: make various helpers visible to the rest of the module Alex Bennée
2023-03-07 21:21 ` [PULL 10/30] gdbstub: move chunk of softmmu functionality to own file Alex Bennée
2023-03-07 21:21 ` [PULL 11/30] gdbstub: move chunks of user code into own files Alex Bennée
2023-03-07 21:21 ` [PULL 12/30] gdbstub: rationalise signal mapping in softmmu Alex Bennée
2023-03-07 21:21 ` [PULL 13/30] gdbstub: abstract target specific details from gdb_put_packet_binary Alex Bennée
2023-03-07 21:21 ` [PULL 14/30] gdbstub: specialise handle_query_attached Alex Bennée
2023-03-07 21:21 ` [PULL 15/30] gdbstub: specialise target_memory_rw_debug Alex Bennée
2023-03-07 21:21 ` [PULL 16/30] gdbstub: introduce gdb_get_max_cpus Alex Bennée
2023-03-07 21:21 ` [PULL 17/30] gdbstub: specialise stub_can_reverse Alex Bennée
2023-03-07 21:21 ` [PULL 18/30] gdbstub: fix address type of gdb_set_cpu_pc Alex Bennée
2023-03-07 21:21 ` [PULL 19/30] gdbstub: don't use target_ulong while handling registers Alex Bennée
2023-03-07 21:21 ` [PULL 20/30] gdbstub: move register helpers into standalone include Alex Bennée
2023-03-07 21:21 ` [PULL 21/30] gdbstub: move syscall handling to new file Alex Bennée
2023-03-07 21:21 ` [PULL 22/30] gdbstub: only compile gdbstub twice for whole build Alex Bennée
2023-03-23 10:05 ` Philippe Mathieu-Daudé
2023-03-29 16:04 ` Philippe Mathieu-Daudé
2023-03-07 21:21 ` [PULL 23/30] testing: probe gdb for supported architectures ahead of time Alex Bennée
2023-03-07 21:21 ` [PULL 24/30] include: split target_long definition from cpu-defs Alex Bennée
2023-03-07 21:21 ` [PULL 25/30] gdbstub: split out softmmu/user specifics for syscall handling Alex Bennée
2023-03-07 21:21 ` [PULL 26/30] gdbstub: Remove gdb_do_syscallv Alex Bennée
2023-03-07 21:21 ` [PULL 27/30] gdbstub: Adjust gdb_do_syscall to only use uint32_t and uint64_t Alex Bennée
2023-03-07 21:21 ` [PULL 28/30] stubs: split semihosting_get_target from system only stubs Alex Bennée
2023-03-07 21:21 ` [PULL 29/30] gdbstub: Build syscall.c once Alex Bennée
2023-03-07 21:21 ` [PULL 30/30] gdbstub: move update guest debug to accel ops Alex Bennée
2023-03-09 21:50 ` [PULL 00/30] gdbstub refactor for smaller build Peter Maydell
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=20230307212139.883112-9-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).