#### 11.2.3 Creating a New Architecture

If no architecture is found, then a new architecture must be created, by calling `gdbarch_alloc` using the supplied `struct gdbarch_info` and any additional custom target specific information in a `struct gdbarch_tdep`. The prototype for `gdbarch_alloc` is:

         struct gdbarch *gdbarch_alloc (const struct gdbarch_info *info,
                                        struct gdbarch_tdep       *tdep);

The newly created struct gdbarch must then be populated. Although there are default values, in most cases they are not what is required.

For each element, X, there is are a pair of corresponding accessor functions, one to set the value of that element, `set_gdbarch_`X, the second to either get the value of an element (if it is a variable) or to apply the element (if it is a function), `gdbarch_`X. Note that both accessor functions take a pointer to the `struct gdbarch` as first argument. Populating the new `gdbarch` should use the `set_gdbarch` functions.

The following sections identify the main elements that should be set in this way. This is not the complete list, but represents the functions and elements that must commonly be specified for a new architecture. Many of the functions and variables are described in the header file `gdbarch.h`.

This is the main work in defining a new architecture. Implementing the set of functions to populate the `struct gdbarch`.

`struct gdbarch_tdep` is not defined within gdb—it is up to the user to define this struct if it is needed to hold custom target information that is not covered by the standard `struct gdbarch`. For example with the OpenRISC 1000 architecture it is used to hold the number of matchpoints available in the target (along with other information).

If there is no additional target specific information, it can be set to `NULL`.