binutils-gdb/gdb/features
Andrew Burgess b5ffee3181 gdb/riscv: Add target description support
This commit adds target description support for riscv.

I've used the split feature approach for specifying the architectural
features, and the CSR feature is auto-generated from the riscv-opc.h
header file.

If the target doesn't provide a suitable target description then GDB
will build one by looking at the bfd headers.

This commit does not implement target description creation for the
Linux or FreeBSD native targets, both of these will need to add
read_description methods into their respective target classes, which
probe the target features, and then call
riscv_create_target_description to build a suitable target
description.  Until this is done Linux and FreeBSD will get the same
default target description based on the bfd that bare-metal targets
get.

I've only added feature descriptions for 32 and 64 bit registers, 128
bit registers (for RISC-V) are not supported in the reset of GDB yet.

This commit removes the special reading of the MISA register in order
to establish the target features, this was only used for figuring out
the f-register size, and even that wasn't done consistently.  We now
rely on the target to tell us what size of registers it has (or look
in the BFD as a last resort).  The result of this is that we should
now support RV64 targets with 32-bit float, though I have not
extensively tested this combination yet.

	* Makefile.in (ALL_TARGET_OBS): Add arch/riscv.o.
	(HFILES_NO_SRCDIR): Add arch/riscv.h.
	* arch/riscv.c: New file.
	* arch/riscv.h: New file.
	* configure.tgt: Add cpu_obs list of riscv, move riscv-tdep.o into
	this list, and add arch/riscv.o.
	* features/Makefile: Add riscv features.
	* features/riscv/32bit-cpu.c: New file.
	* features/riscv/32bit-cpu.xml: New file.
	* features/riscv/32bit-csr.c: New file.
	* features/riscv/32bit-csr.xml: New file.
	* features/riscv/32bit-fpu.c: New file.
	* features/riscv/32bit-fpu.xml: New file.
	* features/riscv/64bit-cpu.c: New file.
	* features/riscv/64bit-cpu.xml: New file.
	* features/riscv/64bit-csr.c: New file.
	* features/riscv/64bit-csr.xml: New file.
	* features/riscv/64bit-fpu.c: New file.
	* features/riscv/64bit-fpu.xml: New file.
	* features/riscv/rebuild-csr-xml.sh: New file.
	* riscv-tdep.c: Add 'arch/riscv.h' include.
	(riscv_gdb_reg_names): Delete.
	(csr_reggroup): New global.
	(struct riscv_register_alias): Delete.
	(struct riscv_register_feature): New structure.
	(riscv_register_aliases): Delete.
	(riscv_xreg_feature): New global.
	(riscv_freg_feature): New global.
	(riscv_virtual_feature): New global.
	(riscv_csr_feature): New global.
	(riscv_create_csr_aliases): New function.
	(riscv_read_misa_reg): Delete.
	(riscv_has_feature): Delete.
	(riscv_isa_xlen): Simplify, just return cached xlen.
	(riscv_isa_flen): Simplify, just return cached flen.
	(riscv_has_fp_abi): Update for changes in struct gdbarch_tdep.
	(riscv_register_name): Update to make use of tdesc_register_name.
	Look up xreg and freg names in the new globals riscv_xreg_feature
	and riscv_freg_feature.  Don't supply csr aliases here.
	(riscv_fpreg_q_type): Delete.
	(riscv_register_type): Use tdesc_register_type in almost all
	cases, override the returned type in a few specific cases only.
	(riscv_print_one_register_info): Handle errors reading registers.
	(riscv_register_reggroup_p): Use tdesc_register_in_reggroup_p for
	registers that are otherwise unknown to GDB.  Also check the
	csr_reggroup.
	(riscv_print_registers_info): Remove assert about upper register
	number, and use gdbarch_register_reggroup_p instead of
	short-cutting.
	(riscv_find_default_target_description): New function.
	(riscv_check_tdesc_feature): New function.
	(riscv_add_reggroups): New function.
	(riscv_setup_register_aliases): New function.
	(riscv_init_reggroups): New function.
	(_initialize_riscv_tdep): Add calls to setup CSR aliases, and
	setup register groups.  Register new riscv debug variable.
	* riscv-tdep.h: Add 'arch/riscv.h' include.
	(struct gdbarch_tdep): Remove abi union, and add
	riscv_gdbarch_features field.  Remove cached quad floating point
	type, and provide initialisation for double type field.
	* target-descriptions.c (maint_print_c_tdesc_cmd): Add riscv to
	the list of targets using the feature based target descriptions.
	* NEWS: Mention target description support.

gdb/doc/ChangeLog:

	* gdb.texinfo (Standard Target Features): Add RISC-V Features
	sub-section.
2018-11-21 13:09:50 +00:00
..
arm Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
i386 Remove xml file references from target descriptions 2018-04-18 20:49:37 +01:00
riscv gdb/riscv: Add target description support 2018-11-21 13:09:50 +00:00
rs6000 [PowerPC] Add support for HTM registers 2018-10-26 10:23:01 -03:00
sparc Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
aarch64-core.c Remove xml file references from target descriptions 2018-04-18 20:49:37 +01:00
aarch64-core.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
aarch64-fpu.c Remove xml file references from target descriptions 2018-04-18 20:49:37 +01:00
aarch64-fpu.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
aarch64-sve.c Use uint64_t for SVE VQ 2018-06-04 10:50:59 +01:00
aarch64.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
arc-arcompact.c Do not emit "field_type" var if not needed on "maint print c-tdesc" 2017-12-21 18:21:45 -05:00
arc-arcompact.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
arc-v2.c Do not emit "field_type" var if not needed on "maint print c-tdesc" 2017-12-21 18:21:45 -05:00
arc-v2.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
btrace-conf.dtd Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
btrace.dtd Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
feature_to_c.sh Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
gdb-target.dtd Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
gdbserver-regs.xsl
library-list-aix.dtd Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
library-list-svr4.dtd Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
library-list.dtd Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
m68k-core.xml
Makefile gdb/riscv: Add target description support 2018-11-21 13:09:50 +00:00
microblaze-core.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
microblaze-stack-protect.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
microblaze-with-stack-protect.c
microblaze-with-stack-protect.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
microblaze.c
microblaze.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
mips64-cp0.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
mips64-cpu.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
mips64-dsp-linux.c
mips64-dsp-linux.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
mips64-dsp.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
mips64-fpu.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
mips64-linux.c
mips64-linux.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
mips-cp0.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
mips-cpu.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
mips-dsp-linux.c
mips-dsp-linux.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
mips-dsp.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
mips-fpu.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
mips-linux.c
mips-linux.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
nds32-core.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
nds32-fpu.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
nds32-system.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
nds32.c
nds32.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
nios2-cpu.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
nios2-linux.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
nios2.c
nios2.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
number-regs.xsl
or1k-core.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
or1k.c Do not emit "field_type" var if not needed on "maint print c-tdesc" 2017-12-21 18:21:45 -05:00
or1k.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
osdata.dtd Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-acr.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-core32.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-core64.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-fpr.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-gs-linux64.c Do not emit "field_type" var if not needed on "maint print c-tdesc" 2017-12-21 18:21:45 -05:00
s390-gs-linux64.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-gs.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-gsbc.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-linux32.c
s390-linux32.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-linux32v1.c
s390-linux32v1.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-linux32v2.c
s390-linux32v2.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-linux64.c
s390-linux64.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-linux64v1.c
s390-linux64v1.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-linux64v2.c
s390-linux64v2.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-tdb.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-te-linux64.c
s390-te-linux64.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-tevx-linux64.c Do not emit "field_type" var if not needed on "maint print c-tdesc" 2017-12-21 18:21:45 -05:00
s390-tevx-linux64.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-vx-linux64.c Do not emit "field_type" var if not needed on "maint print c-tdesc" 2017-12-21 18:21:45 -05:00
s390-vx-linux64.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390-vx.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390x-core64.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390x-gs-linux64.c Do not emit "field_type" var if not needed on "maint print c-tdesc" 2017-12-21 18:21:45 -05:00
s390x-gs-linux64.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390x-linux64.c
s390x-linux64.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390x-linux64v1.c
s390x-linux64v1.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390x-linux64v2.c
s390x-linux64v2.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390x-te-linux64.c
s390x-te-linux64.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390x-tevx-linux64.c Do not emit "field_type" var if not needed on "maint print c-tdesc" 2017-12-21 18:21:45 -05:00
s390x-tevx-linux64.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
s390x-vx-linux64.c Do not emit "field_type" var if not needed on "maint print c-tdesc" 2017-12-21 18:21:45 -05:00
s390x-vx-linux64.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
sort-regs.xsl
threads.dtd Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
tic6x-c6xp.c Remove xml file references from target descriptions 2018-04-18 20:49:37 +01:00
tic6x-c6xp.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
tic6x-c62x-linux.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
tic6x-c64x-linux.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
tic6x-c64xp-linux.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
tic6x-core.c Remove xml file references from target descriptions 2018-04-18 20:49:37 +01:00
tic6x-core.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
tic6x-gp.c Remove xml file references from target descriptions 2018-04-18 20:49:37 +01:00
tic6x-gp.xml Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
traceframe-info.dtd Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
xinclude.dtd Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00