
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. 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
command.
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);
For example the _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);
The architecture enumeration will identify the
unique BFD for this architecture (see Section 2.2.1). The init_func is called to create and return
the new struct gdbarch (see Section 2.3). The
tdep_dump_func is a function which will dump the
target specific details associated with this architecture (also
described in Section 2.3).
The call to gdbarch_register (see Section 2.2) specifies a function which will
define a struct gdbarch for a particular BFD architecture.
struct gdbarch gdbarch_init_func (struct gdbarch_info info,
struct gdbarch_list *arches);
For example, in the case of the OpenRISC 1000 architecture, the
initialization function is or1k_gdbarch_init.
