binutils-gdb/gdb/arch
Andrew Burgess 634494366c gdb/riscv: Create each unique target description only once
GDB relies on the fact that if two target descriptions have the same
contents, then they will be the same object instance (having the same
address).  One place where this is a requirement is in
GDBARCH_LIST_LOOKUP_BY_INFO which is used to find previously created
gdbarch objects.

In GDBARCH_LIST_LOOKUP_BY_INFO a pointer comparison is made on the
gdbarch's target description, if the pointers are different then it is
assumed the gdbarches have different, non-compatible target
descriptions.

Previously we would create duplicate target descriptions in the belief
that RISCV_GDBARCH_INIT would spot this duplication and discard the
second instance.  However, this was incorrect, and instead we ended up
creating duplicate gdbarch objects.

With this commit every unique feature set will create one and only one
target description, the feature set and resulting target description
is then cached so that the same target description object can be
returned later.

Many other target avoid this problem by creating a small number of
named target descriptions, and returning one of these.  However, we
currently have 8 possible target descriptions (32 vs 64 bit for x-reg
and f-reg, and h/w or s/w float abi) and creating each of these just
to avoid a dynamic cache seems pointless.

gdb/ChangeLog:

	* arch/riscv.h (riscv_gdbarch_features::hash): New method.
	* arch/riscv.c (struct riscv_gdbarch_features_hasher): New.
	(riscv_tdesc_cache): New global.
	(riscv_create_target_description): Look in the cache before
	creating a new target description.
2018-11-30 18:13:43 +00:00
..
aarch64-insn.c
aarch64-insn.h
aarch64.c Use uint64_t for SVE VQ 2018-06-04 10:50:59 +01:00
aarch64.h Aarch64: Move pseudo defines to header 2018-10-01 14:00:14 +01:00
amd64.c x86_64-windows GDB crash due to fs_base/gs_base registers 2018-06-29 15:05:20 -07:00
amd64.h x86_64-windows GDB crash due to fs_base/gs_base registers 2018-06-29 15:05:20 -07:00
arm-get-next-pcs.c Simple -Wshadow=local fixes 2018-10-04 22:51:45 -06:00
arm-get-next-pcs.h
arm-linux.c
arm-linux.h
arm.c Fix "fall through" comments 2018-05-04 22:04:46 -06:00
arm.h
i386.c
i386.h
ppc-linux-common.c [PowerPC] Add support for HTM registers 2018-10-26 10:23:01 -03:00
ppc-linux-common.h [PowerPC] Add support for HTM registers 2018-10-26 10:23:01 -03:00
ppc-linux-tdesc.h [PowerPC] Add support for HTM registers 2018-10-26 10:23:01 -03:00
riscv.c gdb/riscv: Create each unique target description only once 2018-11-30 18:13:43 +00:00
riscv.h gdb/riscv: Create each unique target description only once 2018-11-30 18:13:43 +00:00
tic6x.c
tic6x.h
xtensa.h