12.2 Adding Target Described Register Support
A target description must either have no registers or a complete set—this avoids complexity in trying to merge standard registers with the target defined registers. It is the architecture's responsibility to validate that a description with registers has everything it needs. To keep architecture code simple, the same mechanism is used to assign fixed internal register numbers to standard registers.
tdesc_has_registers returns 1, the description contains
registers. The architecture's
gdbarch_init routine should:
tdesc_data_allocto allocate storage, early, before searching for a matching gdbarch or allocating a new one.
tdesc_find_featureto locate standard features by name.
tdesc_numbered_register_choicesto locate the expected registers in the standard features.
NULLif a required feature is missing, or if any standard feature is missing expected registers. This will produce a warning that the description was incomplete.
- Free the allocated data before returning, unless
set_gdbarch_num_regsas usual, with a number higher than any fixed number passed to
tdesc_use_registersafter creating a new gdbarch, before returning it.
tdesc_use_registers has been called, the architecture's
routines will not be called; that information will be taken from
the target description.
num_regs may be increased to account
for any additional registers in the description.
Pseudo-registers require some extra care:
tdesc_numbered_registerallows the architecture to give constant register numbers to standard architectural registers, e.g. as an
enumin arch-tdep.h. But because pseudo-registers are always numbered above
num_regs, which may be increased by the description, constant numbers can not be used for pseudos. They must be numbered relative to
- The description will not describe pseudo-registers, so the
architecture must call
set_tdesc_pseudo_register_reggroup_pto supply routines describing pseudo registers. These routines will be passed internal register numbers, so the same routines used for the gdbarch equivalents are usually suitable.