[PATCH 3/4] target/loongarch: Remove target_ulong use in gdb_write_register handler

Philippe Mathieu-Daudé posted 4 patches 4 months ago
Maintainers: Song Gao <gaosong@loongson.cn>, Bibo Mao <maobibo@loongson.cn>, Jiaxun Yang <jiaxun.yang@flygoat.com>
[PATCH 3/4] target/loongarch: Remove target_ulong use in gdb_write_register handler
Posted by Philippe Mathieu-Daudé 4 months ago
ldq_le_p() returns a uint64_t type, big enough to also hold
ldl_le_p() return value. If we were building for a 32-bit
LoongArch target, ldq_le_p() would not fit in target_ulong.
Better stick to plain uint64_t.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/loongarch/gdbstub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c
index 471eda28c73..23a5eecc20b 100644
--- a/target/loongarch/gdbstub.c
+++ b/target/loongarch/gdbstub.c
@@ -62,7 +62,7 @@ int loongarch_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
 int loongarch_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
 {
     CPULoongArchState *env = cpu_env(cs);
-    target_ulong tmp;
+    uint64_t tmp;
     int length = 0;
 
     if (n < 0 || n > 34) {
-- 
2.51.0


Re: [PATCH 3/4] target/loongarch: Remove target_ulong use in gdb_write_register handler
Posted by gaosong 3 months, 3 weeks ago
在 2025/10/10 上午4:19, Philippe Mathieu-Daudé 写道:
> ldq_le_p() returns a uint64_t type, big enough to also hold
> ldl_le_p() return value. If we were building for a 32-bit
> LoongArch target, ldq_le_p() would not fit in target_ulong.
> Better stick to plain uint64_t.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/loongarch/gdbstub.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
Signed-off-by: Song Gao <gaosong@loongson.cn>

Thanks.
Song Gao
> diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c
> index 471eda28c73..23a5eecc20b 100644
> --- a/target/loongarch/gdbstub.c
> +++ b/target/loongarch/gdbstub.c
> @@ -62,7 +62,7 @@ int loongarch_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
>   int loongarch_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
>   {
>       CPULoongArchState *env = cpu_env(cs);
> -    target_ulong tmp;
> +    uint64_t tmp;
>       int length = 0;
>   
>       if (n < 0 || n > 34) {


Re: [PATCH 3/4] target/loongarch: Remove target_ulong use in gdb_write_register handler
Posted by Richard Henderson 4 months ago
On 10/9/25 13:19, Philippe Mathieu-Daudé wrote:
> ldq_le_p() returns a uint64_t type, big enough to also hold
> ldl_le_p() return value. If we were building for a 32-bit
> LoongArch target, ldq_le_p() would not fit in target_ulong.
> Better stick to plain uint64_t.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/loongarch/gdbstub.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c
> index 471eda28c73..23a5eecc20b 100644
> --- a/target/loongarch/gdbstub.c
> +++ b/target/loongarch/gdbstub.c
> @@ -62,7 +62,7 @@ int loongarch_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
>   int loongarch_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
>   {
>       CPULoongArchState *env = cpu_env(cs);
> -    target_ulong tmp;
> +    uint64_t tmp;
>       int length = 0;
>   
>       if (n < 0 || n > 34) {

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~