Browse Source

target/i386: Expand 64-bit definitions when TARGET_LONG_BITS == 64

Where both gdb_read/write_register() functions check for
'TARGET_LONG_BITS == 64' we can expand the following definitions:

  ldtul_p() -> ldq_p()

  gdb_get_regl() -> gdb_get_reg64()

Do the same in i386_cpu_gdb_get_egprs(): check TARGET_LONG_BITS to
effectively inline gdb_get_regl().

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260219191955.83815-31-philmd@linaro.org>
master
Philippe Mathieu-Daudé 6 months ago
parent
commit
62b7f6df56
  1. 10
      target/i386/gdbstub.c

10
target/i386/gdbstub.c

@ -129,7 +129,7 @@ int x86_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
return gdb_get_reg64(mem_buf,
env->regs[gpr_map[n]] & 0xffffffffUL);
} else {
return gdb_get_regl(mem_buf, 0);
return gdb_get_reg64(mem_buf, 0);
}
} else {
return gdb_get_reg32(mem_buf, env->regs[gpr_map32[n]]);
@ -283,9 +283,9 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
if (n < CPU_NB_REGS) {
if (TARGET_LONG_BITS == 64) {
if (env->hflags & HF_CS64_MASK) {
env->regs[gpr_map[n]] = ldtul_p(mem_buf);
env->regs[gpr_map[n]] = ldq_p(mem_buf);
} else if (n < CPU_NB_REGS32) {
env->regs[gpr_map[n]] = ldtul_p(mem_buf) & 0xffffffffUL;
env->regs[gpr_map[n]] = ldq_p(mem_buf) & 0xffffffffUL;
}
return sizeof(target_ulong);
} else if (n < CPU_NB_REGS32) {
@ -449,8 +449,10 @@ static int i386_cpu_gdb_get_egprs(CPUState *cs, GByteArray *mem_buf, int n)
/* EGPRs can be only directly accessible in 64-bit mode. */
if (env->hflags & HF_CS64_MASK) {
return gdb_get_reg64(mem_buf, env->regs[gpr_map[n + CPU_NB_REGS]]);
} else if (TARGET_LONG_BITS == 64) {
return gdb_get_reg64(mem_buf, 0);
} else {
return gdb_get_regl(mem_buf, 0);
return gdb_get_reg32(mem_buf, 0);
}
}

Loading…
Cancel
Save