frame_unwind_append_sniffer (gdbarch, mips_stub_frame_sniffer); frame_unwind_append_sniffer (gdbarch, mips_mdebug_frame_sniffer); frame_unwind_append_sniffer (gdbarch, mips_insn16_frame_sniffer); frame_unwind_append_sniffer (gdbarch, mips_insn32_frame_sniffer); frame_base_append_sniffer (gdbarch, mips_stub_frame_base_sniffer); frame_base_append_sniffer (gdbarch, mips_mdebug_frame_base_sniffer); frame_base_append_sniffer (gdbarch, mips_insn16_frame_base_sniffer); frame_base_append_sniffer (gdbarch, mips_insn32_frame_base_sniffer);
mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches){  struct gdbarch *gdbarch;  struct gdbarch_tdep *tdep;  int elf_flags;  enum mips_abi mips_abi, found_abi, wanted_abi;  int num_regs;  enum mips_fpu_type fpu_type;  /* First of all, extract the elf_flags, if available.  */  if (info.abfd && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)    elf_flags = elf_elfheader (info.abfd)->e_flags;  else if (arches != NULL)    elf_flags = gdbarch_tdep (arches->gdbarch)->elf_flags;  else    elf_flags = 0;  if (gdbarch_debug)    fprintf_unfiltered (gdb_stdlog,			"mips_gdbarch_init: elf_flags = 0x%08x\n", elf_flags);  /* Check ELF_FLAGS to see if it specifies the ABI being used.  */  switch ((elf_flags & EF_MIPS_ABI))    {    case E_MIPS_ABI_O32:      found_abi = MIPS_ABI_O32;      break;    case E_MIPS_ABI_O64:      found_abi = MIPS_ABI_O64;      break;    case E_MIPS_ABI_EABI32:      found_abi = MIPS_ABI_EABI32;      break;    case E_MIPS_ABI_EABI64:      found_abi = MIPS_ABI_EABI64;      break;    default:      if ((elf_flags & EF_MIPS_ABI2))	found_abi = MIPS_ABI_N32;      else	found_abi = MIPS_ABI_UNKNOWN;      break;    }  /* GCC creates a pseudo-section whose name describes the ABI.  */  if (found_abi == MIPS_ABI_UNKNOWN && info.abfd != NULL)    bfd_map_over_sections (info.abfd, mips_find_abi_section, &found_abi);  /* If we have no usefu BFD information, use the ABI from the last     MIPS architecture (if there is one).  */  if (found_abi == MIPS_ABI_UNKNOWN && info.abfd == NULL && arches != NULL)    found_abi = gdbarch_tdep (arches->gdbarch)->found_abi;  /* Try the architecture for any hint of the correct ABI.  */  if (found_abi == MIPS_ABI_UNKNOWN      && info.bfd_arch_info != NULL      && info.bfd_arch_info->arch == bfd_arch_mips)    {      switch (info.bfd_arch_info->mach)	{	case bfd_mach_mips3900:	  found_abi = MIPS_ABI_EABI32;	  break;	case bfd_mach_mips4100:	case bfd_mach_mips5000:	  found_abi = MIPS_ABI_EABI64;	  break;	case bfd_mach_mips8000:	case bfd_mach_mips10000:	  /* On Irix, ELF64 executables use the N64 ABI.  The	     pseudo-sections which describe the ABI aren't present	     on IRIX.  (Even for executables created by gcc.)  */	  if (bfd_get_flavour (info.abfd) == bfd_target_elf_flavour	      && elf_elfheader (info.abfd)->e_ident[EI_CLASS] == ELFCLASS64)	    found_abi = MIPS_ABI_N64;	  else	    found_abi = MIPS_ABI_N32;	  break;	}    }  if (gdbarch_debug)    fprintf_unfiltered (gdb_stdlog, "mips_gdbarch_init: found_abi = %d\n",			found_abi);  /* What has the user specified from the command line?  */  wanted_abi = global_mips_abi ();  if (gdbarch_debug)    fprintf_unfiltered (gdb_stdlog, "mips_gdbarch_init: wanted_abi = %d\n",			wanted_abi);  /* Now that we have found what the ABI for this binary would be,     check whether the user is overriding it.  */  if (wanted_abi != MIPS_ABI_UNKNOWN)    mips_abi = wanted_abi;  else if (found_abi != MIPS_ABI_UNKNOWN)    mips_abi = found_abi;  else    mips_abi = MIPS_ABI_O32;  if (gdbarch_debug)    fprintf_unfiltered (gdb_stdlog, "mips_gdbarch_init: mips_abi = %d\n",			mips_abi);  /* Also used when doing an architecture lookup.  */  if (gdbarch_debug)    fprintf_unfiltered (gdb_stdlog,			"mips_gdbarch_init: mips64_transfers_32bit_regs_p = %d\n",			mips64_transfers_32bit_regs_p);  /* Determine the MIPS FPU type.  */  if (!mips_fpu_type_auto)    fpu_type = mips_fpu_type;  else if (info.bfd_arch_info != NULL	   && info.bfd_arch_info->arch == bfd_arch_mips)    switch (info.bfd_arch_info->mach)      {      case bfd_mach_mips3900:      case bfd_mach_mips4100:      case bfd_mach_mips4111:	fpu_type = MIPS_FPU_NONE;	break;      case bfd_mach_mips4650:	fpu_type = MIPS_FPU_SINGLE;	break;      default:	fpu_type = MIPS_FPU_DOUBLE;	break;      }  else if (arches != NULL)    fpu_type = gdbarch_tdep (arches->gdbarch)->mips_fpu_type;  else    fpu_type = MIPS_FPU_DOUBLE;  if (gdbarch_debug)    fprintf_unfiltered (gdb_stdlog,			"mips_gdbarch_init: fpu_type = %d\n", fpu_type);  /* try to find a pre-existing architecture */  for (arches = gdbarch_list_lookup_by_info (arches, &info);       arches != NULL;       arches = gdbarch_list_lookup_by_info (arches->next, &info))    {      /* MIPS needs to be pedantic about which ABI the object is         using.  */      if (gdbarch_tdep (arches->gdbarch)->elf_flags != elf_flags)	continue;      if (gdbarch_tdep (arches->gdbarch)->mips_abi != mips_abi)	continue;      /* Need to be pedantic about which register virtual size is         used.  */      if (gdbarch_tdep (arches->gdbarch)->mips64_transfers_32bit_regs_p	  != mips64_transfers_32bit_regs_p)	continue;      /* Be pedantic about which FPU is selected.  */      if (gdbarch_tdep (arches->gdbarch)->mips_fpu_type != fpu_type)	continue;      return arches->gdbarch;    }  /* Need a new architecture.  Fill in a target specific vector.  */  tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));  gdbarch = gdbarch_alloc (&info, tdep);  tdep->elf_flags = elf_flags;  tdep->mips64_transfers_32bit_regs_p = mips64_transfers_32bit_regs_p;  tdep->found_abi = found_abi;  tdep->mips_abi = mips_abi;  tdep->mips_fpu_type = fpu_type;  /* Initially set everything according to the default ABI/ISA.  */  set_gdbarch_short_bit (gdbarch, 16);  set_gdbarch_int_bit (gdbarch, 32);  set_gdbarch_float_bit (gdbarch, 32);  set_gdbarch_double_bit (gdbarch, 64);  set_gdbarch_long_double_bit (gdbarch, 64);  set_gdbarch_register_reggroup_p (gdbarch, mips_register_reggroup_p);  set_gdbarch_pseudo_register_read (gdbarch, mips_pseudo_register_read);  set_gdbarch_pseudo_register_write (gdbarch, mips_pseudo_register_write);  set_gdbarch_elf_make_msymbol_special (gdbarch,					mips_elf_make_msymbol_special);  /* Fill in the OS dependant register numbers and names.  */  {    const char **reg_names;    struct mips_regnum *regnum = GDBARCH_OBSTACK_ZALLOC (gdbarch,							 struct mips_regnum);    if (info.osabi == GDB_OSABI_IRIX)      {	regnum->fp0 = 32;	regnum->pc = 64;	regnum->cause = 65;	regnum->badvaddr = 66;	regnum->hi = 67;	regnum->lo = 68;	regnum->fp_control_status = 69;	regnum->fp_implementation_revision = 70;	num_regs = 71;	reg_names = mips_irix_reg_names;      }    else      {	regnum->lo = MIPS_EMBED_LO_REGNUM;	regnum->hi = MIPS_EMBED_HI_REGNUM;	regnum->badvaddr = MIPS_EMBED_BADVADDR_REGNUM;	regnum->cause = MIPS_EMBED_CAUSE_REGNUM;	regnum->pc = MIPS_EMBED_PC_REGNUM;	regnum->fp0 = MIPS_EMBED_FP0_REGNUM;	regnum->fp_control_status = 70;	regnum->fp_implementation_revision = 71;	num_regs = 90;	if (info.bfd_arch_info != NULL	    && info.bfd_arch_info->mach == bfd_mach_mips3900)	  reg_names = mips_tx39_reg_names;	else	  reg_names = mips_generic_reg_names;      }    /* FIXME: cagney/2003-11-15: For MIPS, hasn't PC_REGNUM been       replaced by read_pc?  */    set_gdbarch_pc_regnum (gdbarch, regnum->pc);    set_gdbarch_fp0_regnum (gdbarch, regnum->fp0);    set_gdbarch_num_regs (gdbarch, num_regs);    set_gdbarch_num_pseudo_regs (gdbarch, num_regs);    set_gdbarch_register_name (gdbarch, mips_register_name);    tdep->mips_processor_reg_names = reg_names;    tdep->regnum = regnum;  }  switch (mips_abi)    {    case MIPS_ABI_O32:      set_gdbarch_push_dummy_call (gdbarch, mips_o32_push_dummy_call);      set_gdbarch_return_value (gdbarch, mips_o32_return_value);      tdep->mips_default_saved_regsize = 4;      tdep->mips_default_stack_argsize = 4;      tdep->mips_fp_register_double = 0;      tdep->mips_last_arg_regnum = A0_REGNUM + 4 - 1;      tdep->mips_last_fp_arg_regnum = tdep->regnum->fp0 + 12 + 4 - 1;      tdep->default_mask_address_p = 0;      set_gdbarch_long_bit (gdbarch, 32);      set_gdbarch_ptr_bit (gdbarch, 32);      set_gdbarch_long_long_bit (gdbarch, 64);      break;    case MIPS_ABI_O64:      set_gdbarch_push_dummy_call (gdbarch, mips_o64_push_dummy_call);      set_gdbarch_deprecated_store_return_value (gdbarch,						 mips_o64_store_return_value);      set_gdbarch_deprecated_extract_return_value (gdbarch,						   mips_o64_extract_return_value);      tdep->mips_default_saved_regsize = 8;      tdep->mips_default_stack_argsize = 8;      tdep->mips_fp_register_double = 1;      tdep->mips_last_arg_regnum = A0_REGNUM + 4 - 1;      tdep->mips_last_fp_arg_regnum = tdep->regnum->fp0 + 12 + 4 - 1;      tdep->default_mask_address_p = 0;      set_gdbarch_long_bit (gdbarch, 32);      set_gdbarch_ptr_bit (gdbarch, 32);      set_gdbarch_long_long_bit (gdbarch, 64);      set_gdbarch_use_struct_convention (gdbarch,					 always_use_struct_convention);      break;    case MIPS_ABI_EABI32:      set_gdbarch_push_dummy_call (gdbarch, mips_eabi_push_dummy_call);      set_gdbarch_deprecated_store_return_value (gdbarch,						 mips_eabi_store_return_value);      set_gdbarch_deprecated_extract_return_value (gdbarch,						   mips_eabi_extract_return_value);      tdep->mips_default_saved_regsize = 4;      tdep->mips_default_stack_argsize = 4;      tdep->mips_fp_register_double = 0;      tdep->mips_last_arg_regnum = A0_REGNUM + 8 - 1;      tdep->mips_last_fp_arg_regnum = tdep->regnum->fp0 + 12 + 8 - 1;      tdep->default_mask_address_p = 0;      set_gdbarch_long_bit (gdbarch, 32);      set_gdbarch_ptr_bit (gdbarch, 32);      set_gdbarch_long_long_bit (gdbarch, 64);      set_gdbarch_deprecated_reg_struct_has_addr	(gdbarch, mips_eabi_reg_struct_has_addr);      set_gdbarch_use_struct_convention (gdbarch,					 mips_eabi_use_struct_convention);      break;    case MIPS_ABI_EABI64:      set_gdbarch_push_dummy_call (gdbarch, mips_eabi_push_dummy_call);      set_gdbarch_deprecated_store_return_value (gdbarch,						 mips_eabi_store_return_value);      set_gdbarch_deprecated_extract_return_value (gdbarch,						   mips_eabi_extract_return_value);      tdep->mips_default_saved_regsize = 8;      tdep->mips_default_stack_argsize = 8;      tdep->mips_fp_register_double = 1;      tdep->mips_last_arg_regnum = A0_REGNUM + 8 - 1;      tdep->mips_last_fp_arg_regnum = tdep->regnum->fp0 + 12 + 8 - 1;      tdep->default_mask_address_p = 0;      set_gdbarch_long_bit (gdbarch, 64);      set_gdbarch_ptr_bit (gdbarch, 64);      set_gdbarch_long_long_bit (gdbarch, 64);      set_gdbarch_deprecated_reg_struct_has_addr	(gdbarch, mips_eabi_reg_struct_has_addr);      set_gdbarch_use_struct_convention (gdbarch,					 mips_eabi_use_struct_convention);      break;    case MIPS_ABI_N32:      set_gdbarch_push_dummy_call (gdbarch, mips_n32n64_push_dummy_call);      set_gdbarch_return_value (gdbarch, mips_n32n64_return_value);      tdep->mips_default_saved_regsize = 8;      tdep->mips_default_stack_argsize = 8;      tdep->mips_fp_register_double = 1;      tdep->mips_last_arg_regnum = A0_REGNUM + 8 - 1;      tdep->mips_last_fp_arg_regnum = tdep->regnum->fp0 + 12 + 8 - 1;      tdep->default_mask_address_p = 0;      set_gdbarch_long_bit (gdbarch, 32);      set_gdbarch_ptr_bit (gdbarch, 32);      set_gdbarch_long_long_bit (gdbarch, 64);      break;    case MIPS_ABI_N64:      set_gdbarch_push_dummy_call (gdbarch, mips_n32n64_push_dummy_call);      set_gdbarch_return_value (gdbarch, mips_n32n64_return_value);      tdep->mips_default_saved_regsize = 8;      tdep->mips_default_stack_argsize = 8;      tdep->mips_fp_register_double = 1;      tdep->mips_last_arg_regnum = A0_REGNUM + 8 - 1;      tdep->mips_last_fp_arg_regnum = tdep->regnum->fp0 + 12 + 8 - 1;      tdep->default_mask_address_p = 0;      set_gdbarch_long_bit (gdbarch, 64);      set_gdbarch_ptr_bit (gdbarch, 64);      set_gdbarch_long_long_bit (gdbarch, 64);      break;    default:      internal_error (__FILE__, __LINE__, "unknown ABI in switch");    }  /* FIXME: jlarmour/2000-04-07: There *is* a flag EF_MIPS_32BIT_MODE     that could indicate -gp32 BUT gas/config/tc-mips.c contains the     comment:     ``We deliberately don't allow "-gp32" to set the MIPS_32BITMODE     flag in object files because to do so would make it impossible to     link with libraries compiled without "-gp32".  This is     unnecessarily restrictive.     We could solve this problem by adding "-gp32" multilibs to gcc,     but to set this flag before gcc is built with such multilibs will     break too many systems.''     But even more unhelpfully, the default linker output target for     mips64-elf is elf32-bigmips, and has EF_MIPS_32BIT_MODE set, even     for 64-bit programs - you need to change the ABI to change this,     and not all gcc targets support that currently.  Therefore using     this flag to detect 32-bit mode would do the wrong thing given     the current gcc - it would make GDB treat these 64-bit programs     as 32-bit programs by default.  */  set_gdbarch_read_pc (gdbarch, mips_read_pc);  set_gdbarch_write_pc (gdbarch, mips_write_pc);  set_gdbarch_read_sp (gdbarch, mips_read_sp);  /* Add/remove bits from an address.  The MIPS needs be careful to     ensure that all 32 bit addresses are sign extended to 64 bits.  */  set_gdbarch_addr_bits_remove (gdbarch, mips_addr_bits_remove);  /* Unwind the frame.  */  set_gdbarch_unwind_pc (gdbarch, mips_unwind_pc);  frame_unwind_append_sniffer (gdbarch, mips_mdebug_frame_sniffer);  set_gdbarch_unwind_dummy_id (gdbarch, mips_unwind_dummy_id);  frame_base_append_sniffer (gdbarch, mips_mdebug_frame_base_sniffer);  /* Map debug register numbers onto internal register numbers.  */  set_gdbarch_stab_reg_to_regnum (gdbarch, mips_stab_reg_to_regnum);  set_gdbarch_ecoff_reg_to_regnum (gdbarch,				   mips_dwarf_dwarf2_ecoff_reg_to_regnum);  set_gdbarch_dwarf_reg_to_regnum (gdbarch,				   mips_dwarf_dwarf2_ecoff_reg_to_regnum);  set_gdbarch_dwarf2_reg_to_regnum (gdbarch,				    mips_dwarf_dwarf2_ecoff_reg_to_regnum);  set_gdbarch_register_sim_regno (gdbarch, mips_register_sim_regno);  /* MIPS version of CALL_DUMMY */  /* NOTE: cagney/2003-08-05: Eventually call dummy location will be     replaced by a command, and all targets will default to on stack     (regardless of the stack's execute status).  */  set_gdbarch_call_dummy_location (gdbarch, AT_SYMBOL);  set_gdbarch_frame_align (gdbarch, mips_frame_align);  set_gdbarch_convert_register_p (gdbarch, mips_convert_register_p);  set_gdbarch_register_to_value (gdbarch, mips_register_to_value);  set_gdbarch_value_to_register (gdbarch, mips_value_to_register);  set_gdbarch_inner_than (gdbarch, core_addr_lessthan);  set_gdbarch_breakpoint_from_pc (gdbarch, mips_breakpoint_from_pc);  set_gdbarch_skip_prologue (gdbarch, mips_skip_prologue);  set_gdbarch_pointer_to_address (gdbarch, signed_pointer_to_address);  set_gdbarch_address_to_pointer (gdbarch, address_to_signed_pointer);  set_gdbarch_integer_to_address (gdbarch, mips_integer_to_address);  set_gdbarch_register_type (gdbarch, mips_register_type);  set_gdbarch_print_registers_info (gdbarch, mips_print_registers_info);  set_gdbarch_pc_in_sigtramp (gdbarch, mips_pc_in_sigtramp);  set_gdbarch_print_insn (gdbarch, gdb_print_insn_mips);  /* FIXME: cagney/2003-08-29: The macros HAVE_STEPPABLE_WATCHPOINT,     HAVE_NONSTEPPABLE_WATCHPOINT, and HAVE_CONTINUABLE_WATCHPOINT     need to all be folded into the target vector.  Since they are     being used as guards for STOPPED_BY_WATCHPOINT, why not have     STOPPED_BY_WATCHPOINT return the type of watchpoint that the code     is sitting on?  */  set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 1);  set_gdbarch_skip_trampoline_code (gdbarch, mips_skip_stub);  /* NOTE drow/2004-02-11: We overload the core solib trampoline code     to support MIPS16.  This is a bad thing.  Make sure not to do it     if we have an OS ABI that actually supports shared libraries, since     shared library support is more important.  If we have an OS someday     that supports both shared libraries and MIPS16, we'll have to find     a better place for these.  */  if (info.osabi == GDB_OSABI_UNKNOWN)    {      set_gdbarch_in_solib_call_trampoline (gdbarch, mips_in_call_stub);      set_gdbarch_in_solib_return_trampoline (gdbarch, mips_in_return_stub);    }  /* Hook in OS ABI-specific overrides, if they have been registered.  */  gdbarch_init_osabi (info, gdbarch);  return gdbarch;}