gdbarch_register
is called for BFD type
bfd_arch_or32
with the initialization function
or1k_gdbarch_init
and the target specific dump
function, or1k_dump_tdep
.
Future implementations may make additional calls to use the same function to create a 64-bit version of the architecture.
gdbarch_init
receives the struct gdbarch_info
created from the BFD entries and the list of existing
architectures. That list is first checked, using
gdbarch_list_lookup_by_info
to see if there is
already an architecture defined suitable for the given
struct gdbarch_info and if so it is returned.
Otherwise a new struct gdbarch is created. For that the target
dependencies are saved in an OpenRISC 1000 specific
struct gdbarch_tdep, defined in
or1k-tdep.h
.
struct gdbarch_tdep { unsigned int num_matchpoints; unsigned int num_gpr_regs; int bytes_per_word; int bytes_per_address; };
This is information beyond that which is held in the struct gdbarch. By using this structure, the GDB implementation for OpenRISC 1000 can be made flexible enough to deal with both 32 and 64-bit implementations and with variable numbers of registers and matchpoints.
Caution | |
---|---|
Although this flexibility is built in to the code, the current implementation has only been tested with 32-bit OpenRISC 32 registers. |
The new architecture is then created by
gdbarch_alloc
, passing in the struct gdbarch_info
and the struct gdbarch_tdep. The
struct gdbarch is populated using the various
set_gdbarch_
functions, and OpenRISC 1000 Frame
sniffers are associated with the architecture.
When creating a new struct gdbarch a function must be provided to dump
the target specific definitions in struct gdbarch_tdep to a file. This is
provided in or1k_dump_tdep
. It is passed a
pointer to the struct gdbarch and a file handle and simply writes out the
fields in the struct gdbarch_tdep with suitable explanatory text.