target/riscv: Allow debugger to access user timer and counter CSRs
authorBin Meng <bmeng@tinylab.org>
Tue, 28 Feb 2023 13:45:30 +0000 (21:45 +0800)
committerPalmer Dabbelt <palmer@rivosinc.com>
Thu, 2 Mar 2023 00:40:21 +0000 (16:40 -0800)
At present user timer and counter CSRs are not reported in the
CSR XML hence gdb cannot access them.

Fix it by adding a debugger check in their predicate() routine.

Signed-off-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
Message-ID: <20230228104035.1879882-14-bmeng@tinylab.org>
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
target/riscv/csr.c

index 7284fd8a0d12908e6b62f46cb14b5436bfc90b66..10ae5df5e61baca1761b57af939a31a76a2e9d17 100644 (file)
@@ -131,6 +131,10 @@ static RISCVException ctr(CPURISCVState *env, int csrno)
 
 skip_ext_pmu_check:
 
+    if (env->debugger) {
+        return RISCV_EXCP_NONE;
+    }
+
     if (env->priv < PRV_M && !get_field(env->mcounteren, ctr_mask)) {
         return RISCV_EXCP_ILLEGAL_INST;
     }