This page was produced by an automated import process, and may have formatting errors; feel free to fix.

Looking Up an Existing Architecture

The initialization function has this prototype:

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.

The lookup is done using gdbarch_list_lookup_by_info. It is passed the list of existing architectures, arches, and the struct gdbarch_info, info, and returns the first matching architecture it finds, or NULL if none are found. If an architecture is found it can be returned as the result from the initialization function, otherwise a new struct gdbach will need to be created.

The struct gdbarch_info has the following components:

struct gdbarch_info
{
   const struct bfd_arch_info *bfd_arch_info;
   int                         byte_order;
   bfd                        *abfd;
   struct gdbarch_tdep_info   *tdep_info;
   enum gdb_osabi              osabi;
   const struct target_desc   *target_desc;
};

The bfd_arch_info member holds the key details about the architecture. The byte_order member is a value in an enumeration indicating the endianism. The abfd member is a pointer to the full BFD, the tdep_info member is additional custom target specific information, osabi identifies which (if any) of a number of operating specific ABIs are used by this architecture and the target_desc member is a set of name-value pairs with information about register usage in this target.

When the struct gdbarch initialization function is called, not all the fields are provided—only those which can be deduced from the BFD. The struct gdbarch_info, info is used as a look-up key with the list of existing architectures, arches to see if a suitable architecture already exists. The tdep_info, osabi and target_desc fields may be added before this lookup to refine the search.

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.

None: Internals Looking-Up-an-Existing-Architecture (last edited 2013-08-20 23:40:58 by StanShebs)

All content (C) 2008 Free Software Foundation. For terms of use, redistribution, and modification, please see the WikiLicense page.