Next: , Previous: OS ABI Variant Handling, Up: Target Architecture Definition


9.2 Initializing a New Architecture

Each gdbarch is associated with a single bfd architecture, via a bfd_arch_arch constant. 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.

The initialization function has this type:

     static struct gdbarch *
     arch_gdbarch_init (struct gdbarch_info info,
                              struct gdbarch_list *arches)

The info argument contains parameters used to select the correct architecture, and arches is a list of architectures which have already been created with the same bfd_arch_arch value.

The initialization function should first make sure that info is acceptable, and return NULL if it is not. Then, it should search through arches for an exact match to info, and return one if found. Lastly, if no exact match was found, it should create a new architecture based on info and return it.

Only information in info should be used to choose the new architecture. Historically, info could be sparse, and defaults would be collected from the first element on arches. However, gdb now fills in info more thoroughly, so new gdbarch initialization functions should not take defaults from arches.