Services - tools - models - for embedded software development
Embecosm divider strip
Prev  Next

2.3.  GDB Architecture Specification

2.3.1. Looking up an Existing Architecture
2.3.2. Creating a New Architecture
2.3.3. Specifying the Hardware Data Representation
2.3.4. Specifying the Hardware Architecture and ABI
2.3.5. Specifying the Register Architecture
2.3.6. Specifying Frame Handling

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.

[Tip]Tip

By convention all target specific functions and global variables in GDB begin with a string unique to that architecture. This helps to avoid namespace pollution when using C. Thus all the MIPS specific functions begin mips_, the ARM specific functions begin arm_ etc.

For the OpenRISC 1000 all target specific functions and global variables begin with or1k_.

Embecosm divider strip