gdbstub/helpers: Convert gdb_get_regl() macro to inlined helper
Rather than checking TARGET_LONG_BITS at build time, check target_long_bits() at runtime. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20260219191955.83815-38-philmd@linaro.org>
Philippe Mathieu-Daudé committed
Feb 17, 2026 at 17:28 UTC
4ebb5ba5514befe146f77666173a8a8bd98c4727
1 file changed
+14
-8
include/gdbstub/helpers.h
+14
-8
@@ -88,6 +88,20 @@ static inline int gdb_get_zeroes(GByteArray *array, size_t len)
88
return len;
89
}
90
91
+/**
92
+ * gdb_get_regl: append @val in @buf using 32 or 64-bit, depending on target
93
+ *
94
+ * This function is legacy and deprecated, thus should not be used in new code.
95
+ */
96
+static inline int gdb_get_regl(GByteArray *buf, uint64_t val)
97
+{
98
+ if (target_long_bits() == 64) {
99
+ return gdb_get_reg64(buf, val);
100
+ } else {
101
+ return gdb_get_reg32(buf, val);
102
+ }
103
+}
104
+
105
/**
106
* gdb_get_reg_ptr: get pointer to start of last element
107
* @len: length of element
@@ -101,12 +115,4 @@ static inline uint8_t *gdb_get_reg_ptr(GByteArray *buf, int len)
115
return buf->data + buf->len - len;
116
}
117
104
-#ifdef COMPILING_PER_TARGET
105
-#if TARGET_LONG_BITS == 64
106
-#define gdb_get_regl(buf, val) gdb_get_reg64(buf, val)
107
-#else
108
-#define gdb_get_regl(buf, val) gdb_get_reg32(buf, val)
109
-#endif
110
-#endif /* COMPILING_PER_TARGET */
111
-
118
#endif /* _GDBSTUB_HELPERS_H_ */