summaryrefslogtreecommitdiff
path: root/gdb/features/riscv/rebuild-csr-xml.sh
blob: e21aaba6afff71c259282ca639b4d185037e92c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /bin/bash

RISCV_OPC_FILE=$1
RISCV_FEATURE_DIR=$2

function gen_csr_xml ()
{
    bitsize=$1

    cat <<EOF
<?xml version="1.0"?>
<!-- Copyright (C) 2018-2020 Free Software Foundation, Inc.

     Copying and distribution of this file, with or without modification,
     are permitted in any medium without royalty provided the copyright
     notice and this notice are preserved.  -->

<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.riscv.csr">
EOF

    grep "^DECLARE_CSR(" ${RISCV_OPC_FILE} \
        | sed -e "s!DECLARE_CSR(\(.*\), .*!  <reg name=\"\1\" bitsize=\"$bitsize\"/>!"

    echo "</feature>"
}

gen_csr_xml 32 > ${RISCV_FEATURE_DIR}/32bit-csr.xml
gen_csr_xml 64 > ${RISCV_FEATURE_DIR}/64bit-csr.xml