aboutsummaryrefslogtreecommitdiff
path: root/gdb/features
diff options
context:
space:
mode:
authorNelson Chu <nelson.chu@sifive.com>2020-02-12 02:18:49 -0800
committerJim Wilson <jimw@sifive.com>2020-02-20 16:49:09 -0800
commitbd0cf5a6bae180f65f3b9298619d1bd695abcdd8 (patch)
treea9573166927fdbd4f0b702bd2207fe3a7e6f3d72 /gdb/features
parent10a95fcc1f8fb621dfc82b1097336cc58a3574f5 (diff)
downloadgdb-bd0cf5a6bae180f65f3b9298619d1bd695abcdd8.zip
gdb-bd0cf5a6bae180f65f3b9298619d1bd695abcdd8.tar.gz
gdb-bd0cf5a6bae180f65f3b9298619d1bd695abcdd8.tar.bz2
RISC-V: Support the ISA-dependent CSR checking.
According to the riscv privilege spec, some CSR are only valid when rv32 or the specific extension is set. We extend the DECLARE_CSR and DECLARE_CSR_ALIAS to record more informaton we need, and then check whether the CSR is valid according to these information. We report warning message when the CSR is invalid, so we have a choice between error and warning by --fatal-warnings option. Also, a --no-warn/-W option is used to turn the warnings off, if people don't want the warnings. gas/ * config/tc-riscv.c (enum riscv_csr_class): New enum. Used to decide whether or not this CSR is legal in the current ISA string. (struct riscv_csr_extra): New structure to hold all extra information of CSR. (riscv_init_csr_hash): New function. According to the DECLARE_CSR and DECLARE_CSR_ALIAS, insert CSR extra information into csr_extra_hash. Call hash_reg_name to insert CSR address into reg_names_hash. (md_begin): Call riscv_init_csr_hashes for each DECLARE_CSR. (reg_csr_lookup_internal, riscv_csr_class_check): New functions. Decide whether the CSR is valid according to the csr_extra_hash. (init_opcode_hash): Update 'if (hash_error != NULL)' as hash_error is not a boolean. This is same as riscv_init_csr_hash, so keep the consistent usage. * testsuite/gas/riscv/csr-dw-regnums.d: Add -march=rv32if option. * testsuite/gas/riscv/priv-reg.d: Add f-ext by -march option. * testsuite/gas/riscv/priv-reg-fail-fext.d: New testcase. The source file is `priv-reg.s`, and the ISA is rv32i without f-ext, so the f-ext CSR are not allowed. * testsuite/gas/riscv/priv-reg-fail-fext.l: Likewise. * testsuite/gas/riscv/priv-reg-fail-rv32-only.d: New testcase. The source file is `priv-reg.s`, and the ISA is rv64if, so the rv32-only CSR are not allowed. * testsuite/gas/riscv/priv-reg-fail-rv32-only.l: Likewise. include/ * opcode/riscv-opc.h: Extend DECLARE_CSR and DECLARE_CSR_ALIAS to record riscv_csr_class. opcodes/ * riscv-dis.c (print_insn_args): Updated since the DECLARE_CSR is changed. gdb/ * riscv-tdep.c: Updated since the DECLARE_CSR is changed. * riscv-tdep.h: Likewise. * features/riscv/rebuild-csr-xml.sh: Generate the 64bit-csr.xml without rv32-only CSR. * features/riscv/64bit-csr.xml: Regernated. binutils/ * dwarf.c: Updated since the DECLARE_CSR is changed.
Diffstat (limited to 'gdb/features')
-rw-r--r--gdb/features/riscv/64bit-csr.xml65
-rwxr-xr-xgdb/features/riscv/rebuild-csr-xml.sh10
2 files changed, 9 insertions, 66 deletions
diff --git a/gdb/features/riscv/64bit-csr.xml b/gdb/features/riscv/64bit-csr.xml
index cf15a7f..8ec0ffe 100644
--- a/gdb/features/riscv/64bit-csr.xml
+++ b/gdb/features/riscv/64bit-csr.xml
@@ -50,38 +50,6 @@
<reg name="hpmcounter29" bitsize="64"/>
<reg name="hpmcounter30" bitsize="64"/>
<reg name="hpmcounter31" bitsize="64"/>
- <reg name="cycleh" bitsize="64"/>
- <reg name="timeh" bitsize="64"/>
- <reg name="instreth" bitsize="64"/>
- <reg name="hpmcounter3h" bitsize="64"/>
- <reg name="hpmcounter4h" bitsize="64"/>
- <reg name="hpmcounter5h" bitsize="64"/>
- <reg name="hpmcounter6h" bitsize="64"/>
- <reg name="hpmcounter7h" bitsize="64"/>
- <reg name="hpmcounter8h" bitsize="64"/>
- <reg name="hpmcounter9h" bitsize="64"/>
- <reg name="hpmcounter10h" bitsize="64"/>
- <reg name="hpmcounter11h" bitsize="64"/>
- <reg name="hpmcounter12h" bitsize="64"/>
- <reg name="hpmcounter13h" bitsize="64"/>
- <reg name="hpmcounter14h" bitsize="64"/>
- <reg name="hpmcounter15h" bitsize="64"/>
- <reg name="hpmcounter16h" bitsize="64"/>
- <reg name="hpmcounter17h" bitsize="64"/>
- <reg name="hpmcounter18h" bitsize="64"/>
- <reg name="hpmcounter19h" bitsize="64"/>
- <reg name="hpmcounter20h" bitsize="64"/>
- <reg name="hpmcounter21h" bitsize="64"/>
- <reg name="hpmcounter22h" bitsize="64"/>
- <reg name="hpmcounter23h" bitsize="64"/>
- <reg name="hpmcounter24h" bitsize="64"/>
- <reg name="hpmcounter25h" bitsize="64"/>
- <reg name="hpmcounter26h" bitsize="64"/>
- <reg name="hpmcounter27h" bitsize="64"/>
- <reg name="hpmcounter28h" bitsize="64"/>
- <reg name="hpmcounter29h" bitsize="64"/>
- <reg name="hpmcounter30h" bitsize="64"/>
- <reg name="hpmcounter31h" bitsize="64"/>
<reg name="sstatus" bitsize="64"/>
<reg name="sedeleg" bitsize="64"/>
<reg name="sideleg" bitsize="64"/>
@@ -111,9 +79,7 @@
<reg name="mtval" bitsize="64"/>
<reg name="mip" bitsize="64"/>
<reg name="pmpcfg0" bitsize="64"/>
- <reg name="pmpcfg1" bitsize="64"/>
<reg name="pmpcfg2" bitsize="64"/>
- <reg name="pmpcfg3" bitsize="64"/>
<reg name="pmpaddr0" bitsize="64"/>
<reg name="pmpaddr1" bitsize="64"/>
<reg name="pmpaddr2" bitsize="64"/>
@@ -161,37 +127,6 @@
<reg name="mhpmcounter29" bitsize="64"/>
<reg name="mhpmcounter30" bitsize="64"/>
<reg name="mhpmcounter31" bitsize="64"/>
- <reg name="mcycleh" bitsize="64"/>
- <reg name="minstreth" bitsize="64"/>
- <reg name="mhpmcounter3h" bitsize="64"/>
- <reg name="mhpmcounter4h" bitsize="64"/>
- <reg name="mhpmcounter5h" bitsize="64"/>
- <reg name="mhpmcounter6h" bitsize="64"/>
- <reg name="mhpmcounter7h" bitsize="64"/>
- <reg name="mhpmcounter8h" bitsize="64"/>
- <reg name="mhpmcounter9h" bitsize="64"/>
- <reg name="mhpmcounter10h" bitsize="64"/>
- <reg name="mhpmcounter11h" bitsize="64"/>
- <reg name="mhpmcounter12h" bitsize="64"/>
- <reg name="mhpmcounter13h" bitsize="64"/>
- <reg name="mhpmcounter14h" bitsize="64"/>
- <reg name="mhpmcounter15h" bitsize="64"/>
- <reg name="mhpmcounter16h" bitsize="64"/>
- <reg name="mhpmcounter17h" bitsize="64"/>
- <reg name="mhpmcounter18h" bitsize="64"/>
- <reg name="mhpmcounter19h" bitsize="64"/>
- <reg name="mhpmcounter20h" bitsize="64"/>
- <reg name="mhpmcounter21h" bitsize="64"/>
- <reg name="mhpmcounter22h" bitsize="64"/>
- <reg name="mhpmcounter23h" bitsize="64"/>
- <reg name="mhpmcounter24h" bitsize="64"/>
- <reg name="mhpmcounter25h" bitsize="64"/>
- <reg name="mhpmcounter26h" bitsize="64"/>
- <reg name="mhpmcounter27h" bitsize="64"/>
- <reg name="mhpmcounter28h" bitsize="64"/>
- <reg name="mhpmcounter29h" bitsize="64"/>
- <reg name="mhpmcounter30h" bitsize="64"/>
- <reg name="mhpmcounter31h" bitsize="64"/>
<reg name="mhpmevent3" bitsize="64"/>
<reg name="mhpmevent4" bitsize="64"/>
<reg name="mhpmevent5" bitsize="64"/>
diff --git a/gdb/features/riscv/rebuild-csr-xml.sh b/gdb/features/riscv/rebuild-csr-xml.sh
index e21aaba..1adb180 100755
--- a/gdb/features/riscv/rebuild-csr-xml.sh
+++ b/gdb/features/riscv/rebuild-csr-xml.sh
@@ -19,10 +19,18 @@ function gen_csr_xml ()
<feature name="org.gnu.gdb.riscv.csr">
EOF
+if [ "$bitsize" = "64" ]; then
grep "^DECLARE_CSR(" ${RISCV_OPC_FILE} \
- | sed -e "s!DECLARE_CSR(\(.*\), .*! <reg name=\"\1\" bitsize=\"$bitsize\"/>!"
+ | sed /CSR_CLASS_.*_32/d \
+ | sed -e "s!DECLARE_CSR(\(.*\), .*, .*! <reg name=\"\1\" bitsize=\"$bitsize\"/>!"
echo "</feature>"
+else
+ grep "^DECLARE_CSR(" ${RISCV_OPC_FILE} \
+ | sed -e "s!DECLARE_CSR(\(.*\), .*, .*! <reg name=\"\1\" bitsize=\"$bitsize\"/>!"
+
+ echo "</feature>"
+fi
}
gen_csr_xml 32 > ${RISCV_FEATURE_DIR}/32bit-csr.xml