Each gdbarch is associated with a single bfd architecture,
via a bfd_arch_arch in the bfd_architecture
enumeration. The gdbarch is registered by a call to
register_gdbarch_init, usually from the file's
_initialize_filename routine, which will be automatically
called during gdb startup. The arguments are a bfd
architecture constant and an initialization function.
A gdb description for a new architecture, arch is created by
defining a global function _initialize_arch_tdep, by
convention in the source file arch-tdep.c. For example,
in the case of the OpenRISC 1000, this function is called
_initialize_or1k_tdep and is found in the file
or1k-tdep.c.
The resulting object files containing the implementation of the
_initialize_arch_tdep function are specified in the gdb
configure.tgt file, which includes a large case statement
pattern matching against the --target option of the
configure script. The new struct gdbarch is created
within the _initialize_arch_tdep function by calling
gdbarch_register:
void gdbarch_register (enum bfd_architecture architecture,
gdbarch_init_ftype *init_func,
gdbarch_dump_tdep_ftype *tdep_dump_func);
The architecture will identify the unique bfd to be
associated with this gdbarch. The init_func funciton is
called to create and return the new struct gdbarch. The
tdep_dump_func function will dump the target specific details
associated with this architecture.
For example the function _initialize_or1k_tdep creates its
architecture for 32-bit OpenRISC 1000 architectures by calling:
gdbarch_register (bfd_arch_or32, or1k_gdbarch_init, or1k_dump_tdep);