gdbstub: riscv: fix the fflags registers
PATCH 1/1 gdbstub: riscv: fix the fflags registers
While debugging an application with GDB the following might happen:
(gdb) return
Make xxx return now? (y or n) y
Could not fetch register "fflags"; remote failure reply 'E14'
This is because riscv_gdb_get_fpu calls riscv_csrrw_debug with a wrong csr number (8). It should use the csr_register_map in order to reach the riscv_cpu_get_fflags callback.
--- target/riscv/gdbstub.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
target/riscv/gdbstub.c +4 -2
@@ -313,7 +313,8 @@ static int riscv_gdb_get_fpu(CPURISCVState *env, uint8_t *mem_buf, int n)* register 33, so we recalculate the map index. * This also works for CSR_FRM and CSR_FCSR. */ - result =riscv_csrrw_debug (env, n -33 +8 , &val,0 ,0 ); + result =riscv_csrrw_debug (env, n -33 + csr_register_map[8 ], &val, +0 ,0 );if (result ==0 ) {return gdb_get_regl (mem_buf, val); }
@@ -335,7 +336,8 @@ static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t *mem_buf, int n)* register 33, so we recalculate the map index. * This also works for CSR_FRM and CSR_FCSR. */ - result =riscv_csrrw_debug (env, n -33 +8 ,NULL , val,-1 ); + result =riscv_csrrw_debug (env, n -33 + csr_register_map[8 ],NULL , + val,-1 );if (result ==0 ) {return sizeof (target_ulong); }
Signature · 1 line
1.8.3.1
Quoted 30 lines · On Tue, 10 Sep 2019 01:15:41 PDT (-0700), [email protected] wrote:
While debugging an application with GDB the following might happen:
(gdb) return
Make xxx return now? (y or n) y
Could not fetch register "fflags"; remote failure reply 'E14'This is because
riscv_gdb_get_fpucallsriscv_csrrw_debugwith a wrong csr number (8). It should use thecsr_register_mapin order to reach theriscv_cpu_get_fflagscallback.Signed-off-by KONRAD Frederic <[email protected]>--- target/riscv/gdbstub.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)target/riscv/gdbstub.c +2
-1@@ -313,7 +313,8 @@ static int riscv_gdb_get_fpu(CPURISCVState *env, uint8_t *mem_buf, int n)* register 33, so we recalculate the map index. * This also works for CSR_FRM and CSR_FCSR. */ - result =riscv_csrrw_debug (env, n -33 +8 , &val,0 ,0 ); + result =riscv_csrrw_debug (env, n -33 + csr_register_map[8 ], &val, +0 ,0 );if (result ==0 ) {return gdb_get_regl (mem_buf, val); }
target/riscv/gdbstub.c static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t *mem_buf, int n) · line 343
Quoted 9 lines
target/riscv/gdbstub.c +2
-1@@ -335,7 +336,8 @@ static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t *mem_buf, int n)* register 33, so we recalculate the map index. * This also works for CSR_FRM and CSR_FCSR. */ - result =riscv_csrrw_debug (env, n -33 +8 ,NULL , val,-1 ); + result =riscv_csrrw_debug (env, n -33 + csr_register_map[8 ],NULL , + val,-1 );if (result ==0 ) {return sizeof (target_ulong); }
I just tagged a fixed version of my PR, but I'll include this in the next one.
Quoted 7 lines · KONRAD Frederic
While debugging an application with GDB the following might happen:
(gdb) return
Make xxx return now? (y or n) y
Could not fetch register "fflags"; remote failure reply 'E14'
Quoted 5 lines
This is because
riscv_gdb_get_fpucallsriscv_csrrw_debugwith a wrong csr number (8). It should use thecsr_register_mapin order to reach theriscv_cpu_get_fflagscallback.Signed-off-by KONRAD Frederic <[email protected]>
Alistair
Quoted 32 lines
--- target/riscv/gdbstub.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)target/riscv/gdbstub.c +4
-3@@ -313,7 +313,8 @@ static int riscv_gdb_get_fpu(CPURISCVState *env, uint8_t *mem_buf, int n)* register 33, so we recalculate the map index. * This also works for CSR_FRM and CSR_FCSR. */ - result =riscv_csrrw_debug (env, n -33 +8 , &val,0 ,0 ); + result =riscv_csrrw_debug (env, n -33 + csr_register_map[8 ], &val, +0 ,0 );if (result ==0 ) {return gdb_get_regl (mem_buf, val); }@@ -335,7 +336,8 @@ static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t *mem_buf, int n)* register 33, so we recalculate the map index. * This also works for CSR_FRM and CSR_FCSR. */ - result =riscv_csrrw_debug (env, n -33 +8 ,NULL , val,-1 ); + result =riscv_csrrw_debug (env, n -33 + csr_register_map[8 ],NULL , + val,-1 );if (result ==0 ) {return sizeof (target_ulong); } --1.8.3.1