summary refs log tree commit diff stats
path: root/target/openrisc/gdbstub.c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@linaro.org>2025-01-21 12:12:05 +0100
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2025-03-06 15:46:17 +0100
commit46a2cfc448931aeeb86bd721fa64e48ec0594299 (patch)
tree2479ae7b321d1177767dc811e1fa6bcec8915534 /target/openrisc/gdbstub.c
parent82c4d8a3b4e390dbb2601e11e07d291e760def7f (diff)
downloadfocaccia-qemu-46a2cfc448931aeeb86bd721fa64e48ec0594299.tar.gz
focaccia-qemu-46a2cfc448931aeeb86bd721fa64e48ec0594299.zip
gdbstub: Clarify no more than @gdb_num_core_regs can be accessed
Both CPUClass::gdb_read_register() and CPUClass::gdb_write_register()
handlers are called from common gdbstub code, and won't be called with
register index over CPUClass::gdb_num_core_regs:

  int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg)
  {
      CPUClass *cc = CPU_GET_CLASS(cpu);

      if (reg < cc->gdb_num_core_regs) {
          return cc->gdb_read_register(cpu, buf, reg);
      }
      ...
  }

  static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg)
  {
      CPUClass *cc = CPU_GET_CLASS(cpu);

      if (reg < cc->gdb_num_core_regs) {
          return cc->gdb_write_register(cpu, mem_buf, reg);
      }
      ...
  }

Clarify that in CPUClass docstring, and remove unreachable code on
the microblaze and openrisc implementations.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20250122093028.52416-3-philmd@linaro.org>
Diffstat (limited to 'target/openrisc/gdbstub.c')
-rw-r--r--target/openrisc/gdbstub.c5
1 files changed, 0 insertions, 5 deletions
diff --git a/target/openrisc/gdbstub.c b/target/openrisc/gdbstub.c
index c2a77d5d4d..45bba80d87 100644
--- a/target/openrisc/gdbstub.c
+++ b/target/openrisc/gdbstub.c
@@ -47,14 +47,9 @@ int openrisc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
 
 int openrisc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
 {
-    CPUClass *cc = CPU_GET_CLASS(cs);
     CPUOpenRISCState *env = cpu_env(cs);
     uint32_t tmp;
 
-    if (n > cc->gdb_num_core_regs) {
-        return 0;
-    }
-
     tmp = ldl_p(mem_buf);
 
     if (n < 32) {