target/riscv: Generate the GDB XML file for CSR registers dynamically
commitb93777e1b4999b1f51f1fa3398f5d400f75a4aab
authorBin Meng <bin.meng@windriver.com>
Sat, 16 Jan 2021 05:41:22 +0000 (16 13:41 +0800)
committerAlistair Francis <alistair.francis@wdc.com>
Sat, 16 Jan 2021 18:57:21 +0000 (16 10:57 -0800)
tree71452fea528147d05e6a24d1303ec24ae88c7e19
parent8ceac5dc3d7ded3cc408255da09a7f0e52ae8416
target/riscv: Generate the GDB XML file for CSR registers dynamically

At present QEMU RISC-V uses a hardcoded XML to report the feature
"org.gnu.gdb.riscv.csr" [1]. There are two major issues with the
approach being used currently:

- The XML does not specify the "regnum" field of a CSR entry, hence
  consecutive numbers are used by the remote GDB client to access
  CSRs. In QEMU we have to maintain a map table to convert the GDB
  number to the hardware number which is error prone.
- The XML contains some CSRs that QEMU does not implement at all,
  which causes an "E14" response sent to remote GDB client.

Change to generate the CSR register list dynamically, based on the
availability presented in the CSR function table. This new approach
will reflect a correct list of CSRs that QEMU actually implements.

[1] https://sourceware.org/gdb/current/onlinedocs/gdb/RISC_002dV-Features.html#RISC_002dV-Features

Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-id: 20210116054123.5457-2-bmeng.cn@gmail.com
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
target/riscv/cpu.c
target/riscv/cpu.h
target/riscv/gdbstub.c