Skip to content

Commit

Permalink
fix expose_csr for CSR from lower address space
Browse files Browse the repository at this point in the history
csrs with custom names are expected to be lazy-initialized by
init_custom_csr_names.  However, if the exposed CSR was in lower address
space the custom name could be re-written by the default one.
  • Loading branch information
aap-sc committed Jan 30, 2025
1 parent 5de7310 commit dc9f9be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/target/riscv/riscv_reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ static const char * const default_reg_names[GDB_REGNO_COUNT] = {
[GDB_REGNO_T5] = "t5",
[GDB_REGNO_T6] = "t6",
[GDB_REGNO_PC] = "pc",
[GDB_REGNO_CSR0] = "csr0",
[GDB_REGNO_PRIV] = "priv",
[GDB_REGNO_FT0] = "ft0",
[GDB_REGNO_FT1] = "ft1",
Expand Down Expand Up @@ -196,7 +195,8 @@ const char *riscv_reg_gdb_regno_name(const struct target *target, enum gdb_regno
}
if (regno >= GDB_REGNO_CSR0 && regno <= GDB_REGNO_CSR4095) {
init_custom_csr_names(target);
info->reg_names[regno] = init_reg_name_with_prefix("csr", regno - GDB_REGNO_CSR0);
if (!info->reg_names[regno])
info->reg_names[regno] = init_reg_name_with_prefix("csr", regno - GDB_REGNO_CSR0);
return info->reg_names[regno];
}
assert(!"Encountered uninitialized entry in reg_names table");
Expand Down

0 comments on commit dc9f9be

Please sign in to comment.