Target descriptions implementation
Before GDB connects to a new target, or runs a new program on an existing target, it discards any existing target description and reverts to a default gdbarch. Then, after connecting, it looks for a new target description by calling target_find_description.
A description may come from a user specified file (XML), the remote qXfer:features:read packet (also XML), or from any custom to_read_description routine in the target vector. For instance, the remote target supports guessing which target description to use based on the size of the g packet (see the definition of register_remote_g_packet_guess in remote.h and the implementation of remote_read_description in remote.c). As an example, this is used to determine whether a MIPS target is 32-bit or 64-bit.
If any target description is found, GDB creates a new gdbarch incorporating the description by calling gdbarch_update_p. Any <architecture> element is handled first, to determine which architecture's gdbarch initialization routine is called to create the new architecture. Then the initialization routine is called, and has a chance to adjust the constructed architecture based on the contents of the target description. For instance, it can recognize any properties set by a to_read_description routine. Also see Adding target described register support.