mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
gdbstub: extend GByteArray to read register helpers
Instead of passing a pointer to memory now just extend the GByteArray to all the read register helpers. They can then safely append their data through the normal way. We don't bother with this abstraction for write registers as we have already ensured the buffer being copied from is the correct size. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Acked-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Damien Hedde <damien.hedde@greensocs.com> Message-Id: <20200316172155.971-15-alex.bennee@linaro.org>
This commit is contained in:
parent
b7b8756a9c
commit
a010bdbe71
41 changed files with 179 additions and 149 deletions
|
@ -293,7 +293,7 @@ extern const char * const riscv_excp_names[];
|
|||
extern const char * const riscv_intr_names[];
|
||||
|
||||
void riscv_cpu_do_interrupt(CPUState *cpu);
|
||||
int riscv_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg);
|
||||
int riscv_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
|
||||
int riscv_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
|
||||
bool riscv_cpu_exec_interrupt(CPUState *cs, int interrupt_request);
|
||||
bool riscv_cpu_fp_enabled(CPURISCVState *env);
|
||||
|
|
|
@ -270,7 +270,7 @@ static int csr_register_map[] = {
|
|||
CSR_MHCOUNTEREN,
|
||||
};
|
||||
|
||||
int riscv_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
|
||||
int riscv_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
|
||||
{
|
||||
RISCVCPU *cpu = RISCV_CPU(cs);
|
||||
CPURISCVState *env = &cpu->env;
|
||||
|
@ -301,14 +301,14 @@ int riscv_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int riscv_gdb_get_fpu(CPURISCVState *env, uint8_t *mem_buf, int n)
|
||||
static int riscv_gdb_get_fpu(CPURISCVState *env, GByteArray *buf, int n)
|
||||
{
|
||||
if (n < 32) {
|
||||
if (env->misa & RVD) {
|
||||
return gdb_get_reg64(mem_buf, env->fpr[n]);
|
||||
return gdb_get_reg64(buf, env->fpr[n]);
|
||||
}
|
||||
if (env->misa & RVF) {
|
||||
return gdb_get_reg32(mem_buf, env->fpr[n]);
|
||||
return gdb_get_reg32(buf, env->fpr[n]);
|
||||
}
|
||||
/* there is hole between ft11 and fflags in fpu.xml */
|
||||
} else if (n < 36 && n > 32) {
|
||||
|
@ -322,7 +322,7 @@ static int riscv_gdb_get_fpu(CPURISCVState *env, uint8_t *mem_buf, int n)
|
|||
result = riscv_csrrw_debug(env, n - 33 + csr_register_map[8], &val,
|
||||
0, 0);
|
||||
if (result == 0) {
|
||||
return gdb_get_regl(mem_buf, val);
|
||||
return gdb_get_regl(buf, val);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -351,7 +351,7 @@ static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t *mem_buf, int n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int riscv_gdb_get_csr(CPURISCVState *env, uint8_t *mem_buf, int n)
|
||||
static int riscv_gdb_get_csr(CPURISCVState *env, GByteArray *buf, int n)
|
||||
{
|
||||
if (n < ARRAY_SIZE(csr_register_map)) {
|
||||
target_ulong val = 0;
|
||||
|
@ -359,7 +359,7 @@ static int riscv_gdb_get_csr(CPURISCVState *env, uint8_t *mem_buf, int n)
|
|||
|
||||
result = riscv_csrrw_debug(env, csr_register_map[n], &val, 0, 0);
|
||||
if (result == 0) {
|
||||
return gdb_get_regl(mem_buf, val);
|
||||
return gdb_get_regl(buf, val);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -379,13 +379,13 @@ static int riscv_gdb_set_csr(CPURISCVState *env, uint8_t *mem_buf, int n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int riscv_gdb_get_virtual(CPURISCVState *cs, uint8_t *mem_buf, int n)
|
||||
static int riscv_gdb_get_virtual(CPURISCVState *cs, GByteArray *buf, int n)
|
||||
{
|
||||
if (n == 0) {
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
return gdb_get_regl(mem_buf, 0);
|
||||
return gdb_get_regl(buf, 0);
|
||||
#else
|
||||
return gdb_get_regl(mem_buf, cs->priv);
|
||||
return gdb_get_regl(buf, cs->priv);
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue