15796c8dcSSimon Schubert /* Dynamic architecture support for GDB, the GNU debugger. 25796c8dcSSimon Schubert 35796c8dcSSimon Schubert Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 4*cf7f2e2dSJohn Marino 2008, 2009, 2010 Free Software Foundation, Inc. 55796c8dcSSimon Schubert 65796c8dcSSimon Schubert This file is part of GDB. 75796c8dcSSimon Schubert 85796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 95796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 105796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 115796c8dcSSimon Schubert (at your option) any later version. 125796c8dcSSimon Schubert 135796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 145796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 155796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 165796c8dcSSimon Schubert GNU General Public License for more details. 175796c8dcSSimon Schubert 185796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 195796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 205796c8dcSSimon Schubert 215796c8dcSSimon Schubert #include "defs.h" 225796c8dcSSimon Schubert 235796c8dcSSimon Schubert #include "arch-utils.h" 245796c8dcSSimon Schubert #include "buildsym.h" 255796c8dcSSimon Schubert #include "gdbcmd.h" 265796c8dcSSimon Schubert #include "inferior.h" /* enum CALL_DUMMY_LOCATION et.al. */ 275796c8dcSSimon Schubert #include "gdb_string.h" 285796c8dcSSimon Schubert #include "regcache.h" 295796c8dcSSimon Schubert #include "gdb_assert.h" 305796c8dcSSimon Schubert #include "sim-regno.h" 315796c8dcSSimon Schubert #include "gdbcore.h" 325796c8dcSSimon Schubert #include "osabi.h" 335796c8dcSSimon Schubert #include "target-descriptions.h" 345796c8dcSSimon Schubert #include "objfiles.h" 355796c8dcSSimon Schubert 365796c8dcSSimon Schubert #include "version.h" 375796c8dcSSimon Schubert 385796c8dcSSimon Schubert #include "floatformat.h" 395796c8dcSSimon Schubert 405796c8dcSSimon Schubert 415796c8dcSSimon Schubert struct displaced_step_closure * 425796c8dcSSimon Schubert simple_displaced_step_copy_insn (struct gdbarch *gdbarch, 435796c8dcSSimon Schubert CORE_ADDR from, CORE_ADDR to, 445796c8dcSSimon Schubert struct regcache *regs) 455796c8dcSSimon Schubert { 465796c8dcSSimon Schubert size_t len = gdbarch_max_insn_length (gdbarch); 475796c8dcSSimon Schubert gdb_byte *buf = xmalloc (len); 485796c8dcSSimon Schubert 495796c8dcSSimon Schubert read_memory (from, buf, len); 505796c8dcSSimon Schubert write_memory (to, buf, len); 515796c8dcSSimon Schubert 525796c8dcSSimon Schubert if (debug_displaced) 535796c8dcSSimon Schubert { 545796c8dcSSimon Schubert fprintf_unfiltered (gdb_stdlog, "displaced: copy %s->%s: ", 555796c8dcSSimon Schubert paddress (gdbarch, from), paddress (gdbarch, to)); 565796c8dcSSimon Schubert displaced_step_dump_bytes (gdb_stdlog, buf, len); 575796c8dcSSimon Schubert } 585796c8dcSSimon Schubert 595796c8dcSSimon Schubert return (struct displaced_step_closure *) buf; 605796c8dcSSimon Schubert } 615796c8dcSSimon Schubert 625796c8dcSSimon Schubert 635796c8dcSSimon Schubert void 645796c8dcSSimon Schubert simple_displaced_step_free_closure (struct gdbarch *gdbarch, 655796c8dcSSimon Schubert struct displaced_step_closure *closure) 665796c8dcSSimon Schubert { 675796c8dcSSimon Schubert xfree (closure); 685796c8dcSSimon Schubert } 695796c8dcSSimon Schubert 705796c8dcSSimon Schubert int 715796c8dcSSimon Schubert default_displaced_step_hw_singlestep (struct gdbarch *gdbarch, 725796c8dcSSimon Schubert struct displaced_step_closure *closure) 735796c8dcSSimon Schubert { 745796c8dcSSimon Schubert return !gdbarch_software_single_step_p (gdbarch); 755796c8dcSSimon Schubert } 765796c8dcSSimon Schubert 775796c8dcSSimon Schubert CORE_ADDR 785796c8dcSSimon Schubert displaced_step_at_entry_point (struct gdbarch *gdbarch) 795796c8dcSSimon Schubert { 805796c8dcSSimon Schubert CORE_ADDR addr; 815796c8dcSSimon Schubert int bp_len; 825796c8dcSSimon Schubert 835796c8dcSSimon Schubert addr = entry_point_address (); 845796c8dcSSimon Schubert 855796c8dcSSimon Schubert /* Inferior calls also use the entry point as a breakpoint location. 865796c8dcSSimon Schubert We don't want displaced stepping to interfere with those 875796c8dcSSimon Schubert breakpoints, so leave space. */ 885796c8dcSSimon Schubert gdbarch_breakpoint_from_pc (gdbarch, &addr, &bp_len); 895796c8dcSSimon Schubert addr += bp_len * 2; 905796c8dcSSimon Schubert 915796c8dcSSimon Schubert return addr; 925796c8dcSSimon Schubert } 935796c8dcSSimon Schubert 945796c8dcSSimon Schubert int 955796c8dcSSimon Schubert legacy_register_sim_regno (struct gdbarch *gdbarch, int regnum) 965796c8dcSSimon Schubert { 975796c8dcSSimon Schubert /* Only makes sense to supply raw registers. */ 985796c8dcSSimon Schubert gdb_assert (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch)); 995796c8dcSSimon Schubert /* NOTE: cagney/2002-05-13: The old code did it this way and it is 1005796c8dcSSimon Schubert suspected that some GDB/SIM combinations may rely on this 1015796c8dcSSimon Schubert behavour. The default should be one2one_register_sim_regno 1025796c8dcSSimon Schubert (below). */ 1035796c8dcSSimon Schubert if (gdbarch_register_name (gdbarch, regnum) != NULL 1045796c8dcSSimon Schubert && gdbarch_register_name (gdbarch, regnum)[0] != '\0') 1055796c8dcSSimon Schubert return regnum; 1065796c8dcSSimon Schubert else 1075796c8dcSSimon Schubert return LEGACY_SIM_REGNO_IGNORE; 1085796c8dcSSimon Schubert } 1095796c8dcSSimon Schubert 1105796c8dcSSimon Schubert CORE_ADDR 1115796c8dcSSimon Schubert generic_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) 1125796c8dcSSimon Schubert { 1135796c8dcSSimon Schubert return 0; 1145796c8dcSSimon Schubert } 1155796c8dcSSimon Schubert 1165796c8dcSSimon Schubert CORE_ADDR 1175796c8dcSSimon Schubert generic_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc) 1185796c8dcSSimon Schubert { 1195796c8dcSSimon Schubert return 0; 1205796c8dcSSimon Schubert } 1215796c8dcSSimon Schubert 1225796c8dcSSimon Schubert int 1235796c8dcSSimon Schubert generic_in_solib_return_trampoline (struct gdbarch *gdbarch, 1245796c8dcSSimon Schubert CORE_ADDR pc, char *name) 1255796c8dcSSimon Schubert { 1265796c8dcSSimon Schubert return 0; 1275796c8dcSSimon Schubert } 1285796c8dcSSimon Schubert 1295796c8dcSSimon Schubert int 1305796c8dcSSimon Schubert generic_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc) 1315796c8dcSSimon Schubert { 1325796c8dcSSimon Schubert return 0; 1335796c8dcSSimon Schubert } 1345796c8dcSSimon Schubert 1355796c8dcSSimon Schubert /* Helper functions for gdbarch_inner_than */ 1365796c8dcSSimon Schubert 1375796c8dcSSimon Schubert int 1385796c8dcSSimon Schubert core_addr_lessthan (CORE_ADDR lhs, CORE_ADDR rhs) 1395796c8dcSSimon Schubert { 1405796c8dcSSimon Schubert return (lhs < rhs); 1415796c8dcSSimon Schubert } 1425796c8dcSSimon Schubert 1435796c8dcSSimon Schubert int 1445796c8dcSSimon Schubert core_addr_greaterthan (CORE_ADDR lhs, CORE_ADDR rhs) 1455796c8dcSSimon Schubert { 1465796c8dcSSimon Schubert return (lhs > rhs); 1475796c8dcSSimon Schubert } 1485796c8dcSSimon Schubert 1495796c8dcSSimon Schubert /* Misc helper functions for targets. */ 1505796c8dcSSimon Schubert 1515796c8dcSSimon Schubert CORE_ADDR 1525796c8dcSSimon Schubert core_addr_identity (struct gdbarch *gdbarch, CORE_ADDR addr) 1535796c8dcSSimon Schubert { 1545796c8dcSSimon Schubert return addr; 1555796c8dcSSimon Schubert } 1565796c8dcSSimon Schubert 1575796c8dcSSimon Schubert CORE_ADDR 1585796c8dcSSimon Schubert convert_from_func_ptr_addr_identity (struct gdbarch *gdbarch, CORE_ADDR addr, 1595796c8dcSSimon Schubert struct target_ops *targ) 1605796c8dcSSimon Schubert { 1615796c8dcSSimon Schubert return addr; 1625796c8dcSSimon Schubert } 1635796c8dcSSimon Schubert 1645796c8dcSSimon Schubert int 1655796c8dcSSimon Schubert no_op_reg_to_regnum (struct gdbarch *gdbarch, int reg) 1665796c8dcSSimon Schubert { 1675796c8dcSSimon Schubert return reg; 1685796c8dcSSimon Schubert } 1695796c8dcSSimon Schubert 1705796c8dcSSimon Schubert void 1715796c8dcSSimon Schubert default_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym) 1725796c8dcSSimon Schubert { 1735796c8dcSSimon Schubert return; 1745796c8dcSSimon Schubert } 1755796c8dcSSimon Schubert 1765796c8dcSSimon Schubert void 1775796c8dcSSimon Schubert default_coff_make_msymbol_special (int val, struct minimal_symbol *msym) 1785796c8dcSSimon Schubert { 1795796c8dcSSimon Schubert return; 1805796c8dcSSimon Schubert } 1815796c8dcSSimon Schubert 1825796c8dcSSimon Schubert int 1835796c8dcSSimon Schubert cannot_register_not (struct gdbarch *gdbarch, int regnum) 1845796c8dcSSimon Schubert { 1855796c8dcSSimon Schubert return 0; 1865796c8dcSSimon Schubert } 1875796c8dcSSimon Schubert 1885796c8dcSSimon Schubert /* Legacy version of target_virtual_frame_pointer(). Assumes that 1895796c8dcSSimon Schubert there is an gdbarch_deprecated_fp_regnum and that it is the same, cooked or 1905796c8dcSSimon Schubert raw. */ 1915796c8dcSSimon Schubert 1925796c8dcSSimon Schubert void 1935796c8dcSSimon Schubert legacy_virtual_frame_pointer (struct gdbarch *gdbarch, 1945796c8dcSSimon Schubert CORE_ADDR pc, 1955796c8dcSSimon Schubert int *frame_regnum, 1965796c8dcSSimon Schubert LONGEST *frame_offset) 1975796c8dcSSimon Schubert { 1985796c8dcSSimon Schubert /* FIXME: cagney/2002-09-13: This code is used when identifying the 1995796c8dcSSimon Schubert frame pointer of the current PC. It is assuming that a single 2005796c8dcSSimon Schubert register and an offset can determine this. I think it should 2015796c8dcSSimon Schubert instead generate a byte code expression as that would work better 2025796c8dcSSimon Schubert with things like Dwarf2's CFI. */ 2035796c8dcSSimon Schubert if (gdbarch_deprecated_fp_regnum (gdbarch) >= 0 2045796c8dcSSimon Schubert && gdbarch_deprecated_fp_regnum (gdbarch) 2055796c8dcSSimon Schubert < gdbarch_num_regs (gdbarch)) 2065796c8dcSSimon Schubert *frame_regnum = gdbarch_deprecated_fp_regnum (gdbarch); 2075796c8dcSSimon Schubert else if (gdbarch_sp_regnum (gdbarch) >= 0 2085796c8dcSSimon Schubert && gdbarch_sp_regnum (gdbarch) 2095796c8dcSSimon Schubert < gdbarch_num_regs (gdbarch)) 2105796c8dcSSimon Schubert *frame_regnum = gdbarch_sp_regnum (gdbarch); 2115796c8dcSSimon Schubert else 2125796c8dcSSimon Schubert /* Should this be an internal error? I guess so, it is reflecting 2135796c8dcSSimon Schubert an architectural limitation in the current design. */ 2145796c8dcSSimon Schubert internal_error (__FILE__, __LINE__, _("No virtual frame pointer available")); 2155796c8dcSSimon Schubert *frame_offset = 0; 2165796c8dcSSimon Schubert } 2175796c8dcSSimon Schubert 2185796c8dcSSimon Schubert 2195796c8dcSSimon Schubert int 2205796c8dcSSimon Schubert generic_convert_register_p (struct gdbarch *gdbarch, int regnum, 2215796c8dcSSimon Schubert struct type *type) 2225796c8dcSSimon Schubert { 2235796c8dcSSimon Schubert return 0; 2245796c8dcSSimon Schubert } 2255796c8dcSSimon Schubert 2265796c8dcSSimon Schubert int 2275796c8dcSSimon Schubert default_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type) 2285796c8dcSSimon Schubert { 2295796c8dcSSimon Schubert return 0; 2305796c8dcSSimon Schubert } 2315796c8dcSSimon Schubert 2325796c8dcSSimon Schubert int 2335796c8dcSSimon Schubert generic_instruction_nullified (struct gdbarch *gdbarch, 2345796c8dcSSimon Schubert struct regcache *regcache) 2355796c8dcSSimon Schubert { 2365796c8dcSSimon Schubert return 0; 2375796c8dcSSimon Schubert } 2385796c8dcSSimon Schubert 2395796c8dcSSimon Schubert int 2405796c8dcSSimon Schubert default_remote_register_number (struct gdbarch *gdbarch, 2415796c8dcSSimon Schubert int regno) 2425796c8dcSSimon Schubert { 2435796c8dcSSimon Schubert return regno; 2445796c8dcSSimon Schubert } 2455796c8dcSSimon Schubert 2465796c8dcSSimon Schubert 2475796c8dcSSimon Schubert /* Functions to manipulate the endianness of the target. */ 2485796c8dcSSimon Schubert 2495796c8dcSSimon Schubert static int target_byte_order_user = BFD_ENDIAN_UNKNOWN; 2505796c8dcSSimon Schubert 2515796c8dcSSimon Schubert static const char endian_big[] = "big"; 2525796c8dcSSimon Schubert static const char endian_little[] = "little"; 2535796c8dcSSimon Schubert static const char endian_auto[] = "auto"; 2545796c8dcSSimon Schubert static const char *endian_enum[] = 2555796c8dcSSimon Schubert { 2565796c8dcSSimon Schubert endian_big, 2575796c8dcSSimon Schubert endian_little, 2585796c8dcSSimon Schubert endian_auto, 2595796c8dcSSimon Schubert NULL, 2605796c8dcSSimon Schubert }; 2615796c8dcSSimon Schubert static const char *set_endian_string; 2625796c8dcSSimon Schubert 2635796c8dcSSimon Schubert enum bfd_endian 2645796c8dcSSimon Schubert selected_byte_order (void) 2655796c8dcSSimon Schubert { 2665796c8dcSSimon Schubert return target_byte_order_user; 2675796c8dcSSimon Schubert } 2685796c8dcSSimon Schubert 2695796c8dcSSimon Schubert /* Called by ``show endian''. */ 2705796c8dcSSimon Schubert 2715796c8dcSSimon Schubert static void 2725796c8dcSSimon Schubert show_endian (struct ui_file *file, int from_tty, struct cmd_list_element *c, 2735796c8dcSSimon Schubert const char *value) 2745796c8dcSSimon Schubert { 2755796c8dcSSimon Schubert if (target_byte_order_user == BFD_ENDIAN_UNKNOWN) 2765796c8dcSSimon Schubert if (gdbarch_byte_order (get_current_arch ()) == BFD_ENDIAN_BIG) 2775796c8dcSSimon Schubert fprintf_unfiltered (file, _("The target endianness is set automatically " 2785796c8dcSSimon Schubert "(currently big endian)\n")); 2795796c8dcSSimon Schubert else 2805796c8dcSSimon Schubert fprintf_unfiltered (file, _("The target endianness is set automatically " 2815796c8dcSSimon Schubert "(currently little endian)\n")); 2825796c8dcSSimon Schubert else 2835796c8dcSSimon Schubert if (target_byte_order_user == BFD_ENDIAN_BIG) 2845796c8dcSSimon Schubert fprintf_unfiltered (file, 2855796c8dcSSimon Schubert _("The target is assumed to be big endian\n")); 2865796c8dcSSimon Schubert else 2875796c8dcSSimon Schubert fprintf_unfiltered (file, 2885796c8dcSSimon Schubert _("The target is assumed to be little endian\n")); 2895796c8dcSSimon Schubert } 2905796c8dcSSimon Schubert 2915796c8dcSSimon Schubert static void 2925796c8dcSSimon Schubert set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c) 2935796c8dcSSimon Schubert { 2945796c8dcSSimon Schubert struct gdbarch_info info; 2955796c8dcSSimon Schubert 2965796c8dcSSimon Schubert gdbarch_info_init (&info); 2975796c8dcSSimon Schubert 2985796c8dcSSimon Schubert if (set_endian_string == endian_auto) 2995796c8dcSSimon Schubert { 3005796c8dcSSimon Schubert target_byte_order_user = BFD_ENDIAN_UNKNOWN; 3015796c8dcSSimon Schubert if (! gdbarch_update_p (info)) 3025796c8dcSSimon Schubert internal_error (__FILE__, __LINE__, 3035796c8dcSSimon Schubert _("set_endian: architecture update failed")); 3045796c8dcSSimon Schubert } 3055796c8dcSSimon Schubert else if (set_endian_string == endian_little) 3065796c8dcSSimon Schubert { 3075796c8dcSSimon Schubert info.byte_order = BFD_ENDIAN_LITTLE; 3085796c8dcSSimon Schubert if (! gdbarch_update_p (info)) 3095796c8dcSSimon Schubert printf_unfiltered (_("Little endian target not supported by GDB\n")); 3105796c8dcSSimon Schubert else 3115796c8dcSSimon Schubert target_byte_order_user = BFD_ENDIAN_LITTLE; 3125796c8dcSSimon Schubert } 3135796c8dcSSimon Schubert else if (set_endian_string == endian_big) 3145796c8dcSSimon Schubert { 3155796c8dcSSimon Schubert info.byte_order = BFD_ENDIAN_BIG; 3165796c8dcSSimon Schubert if (! gdbarch_update_p (info)) 3175796c8dcSSimon Schubert printf_unfiltered (_("Big endian target not supported by GDB\n")); 3185796c8dcSSimon Schubert else 3195796c8dcSSimon Schubert target_byte_order_user = BFD_ENDIAN_BIG; 3205796c8dcSSimon Schubert } 3215796c8dcSSimon Schubert else 3225796c8dcSSimon Schubert internal_error (__FILE__, __LINE__, 3235796c8dcSSimon Schubert _("set_endian: bad value")); 3245796c8dcSSimon Schubert 3255796c8dcSSimon Schubert show_endian (gdb_stdout, from_tty, NULL, NULL); 3265796c8dcSSimon Schubert } 3275796c8dcSSimon Schubert 3285796c8dcSSimon Schubert /* Given SELECTED, a currently selected BFD architecture, and 3295796c8dcSSimon Schubert TARGET_DESC, the current target description, return what 3305796c8dcSSimon Schubert architecture to use. 3315796c8dcSSimon Schubert 3325796c8dcSSimon Schubert SELECTED may be NULL, in which case we return the architecture 3335796c8dcSSimon Schubert associated with TARGET_DESC. If SELECTED specifies a variant 3345796c8dcSSimon Schubert of the architecture associtated with TARGET_DESC, return the 3355796c8dcSSimon Schubert more specific of the two. 3365796c8dcSSimon Schubert 3375796c8dcSSimon Schubert If SELECTED is a different architecture, but it is accepted as 3385796c8dcSSimon Schubert compatible by the target, we can use the target architecture. 3395796c8dcSSimon Schubert 3405796c8dcSSimon Schubert If SELECTED is obviously incompatible, warn the user. */ 3415796c8dcSSimon Schubert 3425796c8dcSSimon Schubert static const struct bfd_arch_info * 3435796c8dcSSimon Schubert choose_architecture_for_target (const struct target_desc *target_desc, 3445796c8dcSSimon Schubert const struct bfd_arch_info *selected) 3455796c8dcSSimon Schubert { 3465796c8dcSSimon Schubert const struct bfd_arch_info *from_target = tdesc_architecture (target_desc); 3475796c8dcSSimon Schubert const struct bfd_arch_info *compat1, *compat2; 3485796c8dcSSimon Schubert 3495796c8dcSSimon Schubert if (selected == NULL) 3505796c8dcSSimon Schubert return from_target; 3515796c8dcSSimon Schubert 3525796c8dcSSimon Schubert if (from_target == NULL) 3535796c8dcSSimon Schubert return selected; 3545796c8dcSSimon Schubert 3555796c8dcSSimon Schubert /* struct bfd_arch_info objects are singletons: that is, there's 3565796c8dcSSimon Schubert supposed to be exactly one instance for a given machine. So you 3575796c8dcSSimon Schubert can tell whether two are equivalent by comparing pointers. */ 3585796c8dcSSimon Schubert if (from_target == selected) 3595796c8dcSSimon Schubert return selected; 3605796c8dcSSimon Schubert 3615796c8dcSSimon Schubert /* BFD's 'A->compatible (A, B)' functions return zero if A and B are 3625796c8dcSSimon Schubert incompatible. But if they are compatible, it returns the 'more 3635796c8dcSSimon Schubert featureful' of the two arches. That is, if A can run code 3645796c8dcSSimon Schubert written for B, but B can't run code written for A, then it'll 3655796c8dcSSimon Schubert return A. 3665796c8dcSSimon Schubert 3675796c8dcSSimon Schubert Some targets (e.g. MIPS as of 2006-12-04) don't fully 3685796c8dcSSimon Schubert implement this, instead always returning NULL or the first 3695796c8dcSSimon Schubert argument. We detect that case by checking both directions. */ 3705796c8dcSSimon Schubert 3715796c8dcSSimon Schubert compat1 = selected->compatible (selected, from_target); 3725796c8dcSSimon Schubert compat2 = from_target->compatible (from_target, selected); 3735796c8dcSSimon Schubert 3745796c8dcSSimon Schubert if (compat1 == NULL && compat2 == NULL) 3755796c8dcSSimon Schubert { 3765796c8dcSSimon Schubert /* BFD considers the architectures incompatible. Check our target 3775796c8dcSSimon Schubert description whether it accepts SELECTED as compatible anyway. */ 3785796c8dcSSimon Schubert if (tdesc_compatible_p (target_desc, selected)) 3795796c8dcSSimon Schubert return from_target; 3805796c8dcSSimon Schubert 3815796c8dcSSimon Schubert warning (_("Selected architecture %s is not compatible " 3825796c8dcSSimon Schubert "with reported target architecture %s"), 3835796c8dcSSimon Schubert selected->printable_name, from_target->printable_name); 3845796c8dcSSimon Schubert return selected; 3855796c8dcSSimon Schubert } 3865796c8dcSSimon Schubert 3875796c8dcSSimon Schubert if (compat1 == NULL) 3885796c8dcSSimon Schubert return compat2; 3895796c8dcSSimon Schubert if (compat2 == NULL) 3905796c8dcSSimon Schubert return compat1; 3915796c8dcSSimon Schubert if (compat1 == compat2) 3925796c8dcSSimon Schubert return compat1; 3935796c8dcSSimon Schubert 3945796c8dcSSimon Schubert /* If the two didn't match, but one of them was a default architecture, 3955796c8dcSSimon Schubert assume the more specific one is correct. This handles the case 3965796c8dcSSimon Schubert where an executable or target description just says "mips", but 3975796c8dcSSimon Schubert the other knows which MIPS variant. */ 3985796c8dcSSimon Schubert if (compat1->the_default) 3995796c8dcSSimon Schubert return compat2; 4005796c8dcSSimon Schubert if (compat2->the_default) 4015796c8dcSSimon Schubert return compat1; 4025796c8dcSSimon Schubert 4035796c8dcSSimon Schubert /* We have no idea which one is better. This is a bug, but not 4045796c8dcSSimon Schubert a critical problem; warn the user. */ 4055796c8dcSSimon Schubert warning (_("Selected architecture %s is ambiguous with " 4065796c8dcSSimon Schubert "reported target architecture %s"), 4075796c8dcSSimon Schubert selected->printable_name, from_target->printable_name); 4085796c8dcSSimon Schubert return selected; 4095796c8dcSSimon Schubert } 4105796c8dcSSimon Schubert 4115796c8dcSSimon Schubert /* Functions to manipulate the architecture of the target */ 4125796c8dcSSimon Schubert 4135796c8dcSSimon Schubert enum set_arch { set_arch_auto, set_arch_manual }; 4145796c8dcSSimon Schubert 4155796c8dcSSimon Schubert static const struct bfd_arch_info *target_architecture_user; 4165796c8dcSSimon Schubert 4175796c8dcSSimon Schubert static const char *set_architecture_string; 4185796c8dcSSimon Schubert 4195796c8dcSSimon Schubert const char * 4205796c8dcSSimon Schubert selected_architecture_name (void) 4215796c8dcSSimon Schubert { 4225796c8dcSSimon Schubert if (target_architecture_user == NULL) 4235796c8dcSSimon Schubert return NULL; 4245796c8dcSSimon Schubert else 4255796c8dcSSimon Schubert return set_architecture_string; 4265796c8dcSSimon Schubert } 4275796c8dcSSimon Schubert 4285796c8dcSSimon Schubert /* Called if the user enters ``show architecture'' without an 4295796c8dcSSimon Schubert argument. */ 4305796c8dcSSimon Schubert 4315796c8dcSSimon Schubert static void 4325796c8dcSSimon Schubert show_architecture (struct ui_file *file, int from_tty, 4335796c8dcSSimon Schubert struct cmd_list_element *c, const char *value) 4345796c8dcSSimon Schubert { 4355796c8dcSSimon Schubert if (target_architecture_user == NULL) 4365796c8dcSSimon Schubert fprintf_filtered (file, _("\ 4375796c8dcSSimon Schubert The target architecture is set automatically (currently %s)\n"), 4385796c8dcSSimon Schubert gdbarch_bfd_arch_info (get_current_arch ())->printable_name); 4395796c8dcSSimon Schubert else 4405796c8dcSSimon Schubert fprintf_filtered (file, _("\ 4415796c8dcSSimon Schubert The target architecture is assumed to be %s\n"), set_architecture_string); 4425796c8dcSSimon Schubert } 4435796c8dcSSimon Schubert 4445796c8dcSSimon Schubert 4455796c8dcSSimon Schubert /* Called if the user enters ``set architecture'' with or without an 4465796c8dcSSimon Schubert argument. */ 4475796c8dcSSimon Schubert 4485796c8dcSSimon Schubert static void 4495796c8dcSSimon Schubert set_architecture (char *ignore_args, int from_tty, struct cmd_list_element *c) 4505796c8dcSSimon Schubert { 4515796c8dcSSimon Schubert struct gdbarch_info info; 4525796c8dcSSimon Schubert 4535796c8dcSSimon Schubert gdbarch_info_init (&info); 4545796c8dcSSimon Schubert 4555796c8dcSSimon Schubert if (strcmp (set_architecture_string, "auto") == 0) 4565796c8dcSSimon Schubert { 4575796c8dcSSimon Schubert target_architecture_user = NULL; 4585796c8dcSSimon Schubert if (!gdbarch_update_p (info)) 4595796c8dcSSimon Schubert internal_error (__FILE__, __LINE__, 4605796c8dcSSimon Schubert _("could not select an architecture automatically")); 4615796c8dcSSimon Schubert } 4625796c8dcSSimon Schubert else 4635796c8dcSSimon Schubert { 4645796c8dcSSimon Schubert info.bfd_arch_info = bfd_scan_arch (set_architecture_string); 4655796c8dcSSimon Schubert if (info.bfd_arch_info == NULL) 4665796c8dcSSimon Schubert internal_error (__FILE__, __LINE__, 4675796c8dcSSimon Schubert _("set_architecture: bfd_scan_arch failed")); 4685796c8dcSSimon Schubert if (gdbarch_update_p (info)) 4695796c8dcSSimon Schubert target_architecture_user = info.bfd_arch_info; 4705796c8dcSSimon Schubert else 4715796c8dcSSimon Schubert printf_unfiltered (_("Architecture `%s' not recognized.\n"), 4725796c8dcSSimon Schubert set_architecture_string); 4735796c8dcSSimon Schubert } 4745796c8dcSSimon Schubert show_architecture (gdb_stdout, from_tty, NULL, NULL); 4755796c8dcSSimon Schubert } 4765796c8dcSSimon Schubert 4775796c8dcSSimon Schubert /* Try to select a global architecture that matches "info". Return 4785796c8dcSSimon Schubert non-zero if the attempt succeds. */ 4795796c8dcSSimon Schubert int 4805796c8dcSSimon Schubert gdbarch_update_p (struct gdbarch_info info) 4815796c8dcSSimon Schubert { 4825796c8dcSSimon Schubert struct gdbarch *new_gdbarch; 4835796c8dcSSimon Schubert 4845796c8dcSSimon Schubert /* Check for the current file. */ 4855796c8dcSSimon Schubert if (info.abfd == NULL) 4865796c8dcSSimon Schubert info.abfd = exec_bfd; 4875796c8dcSSimon Schubert if (info.abfd == NULL) 4885796c8dcSSimon Schubert info.abfd = core_bfd; 4895796c8dcSSimon Schubert 4905796c8dcSSimon Schubert /* Check for the current target description. */ 4915796c8dcSSimon Schubert if (info.target_desc == NULL) 4925796c8dcSSimon Schubert info.target_desc = target_current_description (); 4935796c8dcSSimon Schubert 4945796c8dcSSimon Schubert new_gdbarch = gdbarch_find_by_info (info); 4955796c8dcSSimon Schubert 4965796c8dcSSimon Schubert /* If there no architecture by that name, reject the request. */ 4975796c8dcSSimon Schubert if (new_gdbarch == NULL) 4985796c8dcSSimon Schubert { 4995796c8dcSSimon Schubert if (gdbarch_debug) 5005796c8dcSSimon Schubert fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: " 5015796c8dcSSimon Schubert "Architecture not found\n"); 5025796c8dcSSimon Schubert return 0; 5035796c8dcSSimon Schubert } 5045796c8dcSSimon Schubert 5055796c8dcSSimon Schubert /* If it is the same old architecture, accept the request (but don't 5065796c8dcSSimon Schubert swap anything). */ 5075796c8dcSSimon Schubert if (new_gdbarch == target_gdbarch) 5085796c8dcSSimon Schubert { 5095796c8dcSSimon Schubert if (gdbarch_debug) 5105796c8dcSSimon Schubert fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: " 5115796c8dcSSimon Schubert "Architecture %s (%s) unchanged\n", 5125796c8dcSSimon Schubert host_address_to_string (new_gdbarch), 5135796c8dcSSimon Schubert gdbarch_bfd_arch_info (new_gdbarch)->printable_name); 5145796c8dcSSimon Schubert return 1; 5155796c8dcSSimon Schubert } 5165796c8dcSSimon Schubert 5175796c8dcSSimon Schubert /* It's a new architecture, swap it in. */ 5185796c8dcSSimon Schubert if (gdbarch_debug) 5195796c8dcSSimon Schubert fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: " 5205796c8dcSSimon Schubert "New architecture %s (%s) selected\n", 5215796c8dcSSimon Schubert host_address_to_string (new_gdbarch), 5225796c8dcSSimon Schubert gdbarch_bfd_arch_info (new_gdbarch)->printable_name); 5235796c8dcSSimon Schubert deprecated_target_gdbarch_select_hack (new_gdbarch); 5245796c8dcSSimon Schubert 5255796c8dcSSimon Schubert return 1; 5265796c8dcSSimon Schubert } 5275796c8dcSSimon Schubert 5285796c8dcSSimon Schubert /* Return the architecture for ABFD. If no suitable architecture 5295796c8dcSSimon Schubert could be find, return NULL. */ 5305796c8dcSSimon Schubert 5315796c8dcSSimon Schubert struct gdbarch * 5325796c8dcSSimon Schubert gdbarch_from_bfd (bfd *abfd) 5335796c8dcSSimon Schubert { 5345796c8dcSSimon Schubert struct gdbarch_info info; 5355796c8dcSSimon Schubert gdbarch_info_init (&info); 536*cf7f2e2dSJohn Marino 5375796c8dcSSimon Schubert info.abfd = abfd; 5385796c8dcSSimon Schubert return gdbarch_find_by_info (info); 5395796c8dcSSimon Schubert } 5405796c8dcSSimon Schubert 5415796c8dcSSimon Schubert /* Set the dynamic target-system-dependent parameters (architecture, 5425796c8dcSSimon Schubert byte-order) using information found in the BFD */ 5435796c8dcSSimon Schubert 5445796c8dcSSimon Schubert void 5455796c8dcSSimon Schubert set_gdbarch_from_file (bfd *abfd) 5465796c8dcSSimon Schubert { 5475796c8dcSSimon Schubert struct gdbarch_info info; 5485796c8dcSSimon Schubert struct gdbarch *gdbarch; 5495796c8dcSSimon Schubert 5505796c8dcSSimon Schubert gdbarch_info_init (&info); 5515796c8dcSSimon Schubert info.abfd = abfd; 5525796c8dcSSimon Schubert info.target_desc = target_current_description (); 5535796c8dcSSimon Schubert gdbarch = gdbarch_find_by_info (info); 5545796c8dcSSimon Schubert 5555796c8dcSSimon Schubert if (gdbarch == NULL) 5565796c8dcSSimon Schubert error (_("Architecture of file not recognized.")); 5575796c8dcSSimon Schubert deprecated_target_gdbarch_select_hack (gdbarch); 5585796c8dcSSimon Schubert } 5595796c8dcSSimon Schubert 5605796c8dcSSimon Schubert /* Initialize the current architecture. Update the ``set 5615796c8dcSSimon Schubert architecture'' command so that it specifies a list of valid 5625796c8dcSSimon Schubert architectures. */ 5635796c8dcSSimon Schubert 5645796c8dcSSimon Schubert #ifdef DEFAULT_BFD_ARCH 5655796c8dcSSimon Schubert extern const bfd_arch_info_type DEFAULT_BFD_ARCH; 5665796c8dcSSimon Schubert static const bfd_arch_info_type *default_bfd_arch = &DEFAULT_BFD_ARCH; 5675796c8dcSSimon Schubert #else 5685796c8dcSSimon Schubert static const bfd_arch_info_type *default_bfd_arch; 5695796c8dcSSimon Schubert #endif 5705796c8dcSSimon Schubert 5715796c8dcSSimon Schubert #ifdef DEFAULT_BFD_VEC 5725796c8dcSSimon Schubert extern const bfd_target DEFAULT_BFD_VEC; 5735796c8dcSSimon Schubert static const bfd_target *default_bfd_vec = &DEFAULT_BFD_VEC; 5745796c8dcSSimon Schubert #else 5755796c8dcSSimon Schubert static const bfd_target *default_bfd_vec; 5765796c8dcSSimon Schubert #endif 5775796c8dcSSimon Schubert 5785796c8dcSSimon Schubert static int default_byte_order = BFD_ENDIAN_UNKNOWN; 5795796c8dcSSimon Schubert 5805796c8dcSSimon Schubert void 5815796c8dcSSimon Schubert initialize_current_architecture (void) 5825796c8dcSSimon Schubert { 5835796c8dcSSimon Schubert const char **arches = gdbarch_printable_names (); 584*cf7f2e2dSJohn Marino struct gdbarch_info info; 5855796c8dcSSimon Schubert 5865796c8dcSSimon Schubert /* determine a default architecture and byte order. */ 5875796c8dcSSimon Schubert gdbarch_info_init (&info); 5885796c8dcSSimon Schubert 5895796c8dcSSimon Schubert /* Find a default architecture. */ 5905796c8dcSSimon Schubert if (default_bfd_arch == NULL) 5915796c8dcSSimon Schubert { 5925796c8dcSSimon Schubert /* Choose the architecture by taking the first one 5935796c8dcSSimon Schubert alphabetically. */ 5945796c8dcSSimon Schubert const char *chosen = arches[0]; 5955796c8dcSSimon Schubert const char **arch; 5965796c8dcSSimon Schubert for (arch = arches; *arch != NULL; arch++) 5975796c8dcSSimon Schubert { 5985796c8dcSSimon Schubert if (strcmp (*arch, chosen) < 0) 5995796c8dcSSimon Schubert chosen = *arch; 6005796c8dcSSimon Schubert } 6015796c8dcSSimon Schubert if (chosen == NULL) 6025796c8dcSSimon Schubert internal_error (__FILE__, __LINE__, 6035796c8dcSSimon Schubert _("initialize_current_architecture: No arch")); 6045796c8dcSSimon Schubert default_bfd_arch = bfd_scan_arch (chosen); 6055796c8dcSSimon Schubert if (default_bfd_arch == NULL) 6065796c8dcSSimon Schubert internal_error (__FILE__, __LINE__, 6075796c8dcSSimon Schubert _("initialize_current_architecture: Arch not found")); 6085796c8dcSSimon Schubert } 6095796c8dcSSimon Schubert 6105796c8dcSSimon Schubert info.bfd_arch_info = default_bfd_arch; 6115796c8dcSSimon Schubert 6125796c8dcSSimon Schubert /* Take several guesses at a byte order. */ 6135796c8dcSSimon Schubert if (default_byte_order == BFD_ENDIAN_UNKNOWN 6145796c8dcSSimon Schubert && default_bfd_vec != NULL) 6155796c8dcSSimon Schubert { 6165796c8dcSSimon Schubert /* Extract BFD's default vector's byte order. */ 6175796c8dcSSimon Schubert switch (default_bfd_vec->byteorder) 6185796c8dcSSimon Schubert { 6195796c8dcSSimon Schubert case BFD_ENDIAN_BIG: 6205796c8dcSSimon Schubert default_byte_order = BFD_ENDIAN_BIG; 6215796c8dcSSimon Schubert break; 6225796c8dcSSimon Schubert case BFD_ENDIAN_LITTLE: 6235796c8dcSSimon Schubert default_byte_order = BFD_ENDIAN_LITTLE; 6245796c8dcSSimon Schubert break; 6255796c8dcSSimon Schubert default: 6265796c8dcSSimon Schubert break; 6275796c8dcSSimon Schubert } 6285796c8dcSSimon Schubert } 6295796c8dcSSimon Schubert if (default_byte_order == BFD_ENDIAN_UNKNOWN) 6305796c8dcSSimon Schubert { 6315796c8dcSSimon Schubert /* look for ``*el-*'' in the target name. */ 6325796c8dcSSimon Schubert const char *chp; 6335796c8dcSSimon Schubert chp = strchr (target_name, '-'); 6345796c8dcSSimon Schubert if (chp != NULL 6355796c8dcSSimon Schubert && chp - 2 >= target_name 6365796c8dcSSimon Schubert && strncmp (chp - 2, "el", 2) == 0) 6375796c8dcSSimon Schubert default_byte_order = BFD_ENDIAN_LITTLE; 6385796c8dcSSimon Schubert } 6395796c8dcSSimon Schubert if (default_byte_order == BFD_ENDIAN_UNKNOWN) 6405796c8dcSSimon Schubert { 6415796c8dcSSimon Schubert /* Wire it to big-endian!!! */ 6425796c8dcSSimon Schubert default_byte_order = BFD_ENDIAN_BIG; 6435796c8dcSSimon Schubert } 6445796c8dcSSimon Schubert 6455796c8dcSSimon Schubert info.byte_order = default_byte_order; 6465796c8dcSSimon Schubert info.byte_order_for_code = info.byte_order; 6475796c8dcSSimon Schubert 6485796c8dcSSimon Schubert if (! gdbarch_update_p (info)) 6495796c8dcSSimon Schubert internal_error (__FILE__, __LINE__, 6505796c8dcSSimon Schubert _("initialize_current_architecture: Selection of " 6515796c8dcSSimon Schubert "initial architecture failed")); 6525796c8dcSSimon Schubert 6535796c8dcSSimon Schubert /* Create the ``set architecture'' command appending ``auto'' to the 6545796c8dcSSimon Schubert list of architectures. */ 6555796c8dcSSimon Schubert { 6565796c8dcSSimon Schubert /* Append ``auto''. */ 6575796c8dcSSimon Schubert int nr; 6585796c8dcSSimon Schubert for (nr = 0; arches[nr] != NULL; nr++); 6595796c8dcSSimon Schubert arches = xrealloc (arches, sizeof (char*) * (nr + 2)); 6605796c8dcSSimon Schubert arches[nr + 0] = "auto"; 6615796c8dcSSimon Schubert arches[nr + 1] = NULL; 6625796c8dcSSimon Schubert add_setshow_enum_cmd ("architecture", class_support, 6635796c8dcSSimon Schubert arches, &set_architecture_string, _("\ 6645796c8dcSSimon Schubert Set architecture of target."), _("\ 6655796c8dcSSimon Schubert Show architecture of target."), NULL, 6665796c8dcSSimon Schubert set_architecture, show_architecture, 6675796c8dcSSimon Schubert &setlist, &showlist); 6685796c8dcSSimon Schubert add_alias_cmd ("processor", "architecture", class_support, 1, &setlist); 6695796c8dcSSimon Schubert } 6705796c8dcSSimon Schubert } 6715796c8dcSSimon Schubert 6725796c8dcSSimon Schubert 6735796c8dcSSimon Schubert /* Initialize a gdbarch info to values that will be automatically 6745796c8dcSSimon Schubert overridden. Note: Originally, this ``struct info'' was initialized 6755796c8dcSSimon Schubert using memset(0). Unfortunately, that ran into problems, namely 6765796c8dcSSimon Schubert BFD_ENDIAN_BIG is zero. An explicit initialization function that 6775796c8dcSSimon Schubert can explicitly set each field to a well defined value is used. */ 6785796c8dcSSimon Schubert 6795796c8dcSSimon Schubert void 6805796c8dcSSimon Schubert gdbarch_info_init (struct gdbarch_info *info) 6815796c8dcSSimon Schubert { 6825796c8dcSSimon Schubert memset (info, 0, sizeof (struct gdbarch_info)); 6835796c8dcSSimon Schubert info->byte_order = BFD_ENDIAN_UNKNOWN; 6845796c8dcSSimon Schubert info->byte_order_for_code = info->byte_order; 6855796c8dcSSimon Schubert info->osabi = GDB_OSABI_UNINITIALIZED; 6865796c8dcSSimon Schubert } 6875796c8dcSSimon Schubert 6885796c8dcSSimon Schubert /* Similar to init, but this time fill in the blanks. Information is 6895796c8dcSSimon Schubert obtained from the global "set ..." options and explicitly 6905796c8dcSSimon Schubert initialized INFO fields. */ 6915796c8dcSSimon Schubert 6925796c8dcSSimon Schubert void 6935796c8dcSSimon Schubert gdbarch_info_fill (struct gdbarch_info *info) 6945796c8dcSSimon Schubert { 6955796c8dcSSimon Schubert /* "(gdb) set architecture ...". */ 6965796c8dcSSimon Schubert if (info->bfd_arch_info == NULL 6975796c8dcSSimon Schubert && target_architecture_user) 6985796c8dcSSimon Schubert info->bfd_arch_info = target_architecture_user; 6995796c8dcSSimon Schubert /* From the file. */ 7005796c8dcSSimon Schubert if (info->bfd_arch_info == NULL 7015796c8dcSSimon Schubert && info->abfd != NULL 7025796c8dcSSimon Schubert && bfd_get_arch (info->abfd) != bfd_arch_unknown 7035796c8dcSSimon Schubert && bfd_get_arch (info->abfd) != bfd_arch_obscure) 7045796c8dcSSimon Schubert info->bfd_arch_info = bfd_get_arch_info (info->abfd); 7055796c8dcSSimon Schubert /* From the target. */ 7065796c8dcSSimon Schubert if (info->target_desc != NULL) 7075796c8dcSSimon Schubert info->bfd_arch_info = choose_architecture_for_target 7085796c8dcSSimon Schubert (info->target_desc, info->bfd_arch_info); 7095796c8dcSSimon Schubert /* From the default. */ 7105796c8dcSSimon Schubert if (info->bfd_arch_info == NULL) 7115796c8dcSSimon Schubert info->bfd_arch_info = default_bfd_arch; 7125796c8dcSSimon Schubert 7135796c8dcSSimon Schubert /* "(gdb) set byte-order ...". */ 7145796c8dcSSimon Schubert if (info->byte_order == BFD_ENDIAN_UNKNOWN 7155796c8dcSSimon Schubert && target_byte_order_user != BFD_ENDIAN_UNKNOWN) 7165796c8dcSSimon Schubert info->byte_order = target_byte_order_user; 7175796c8dcSSimon Schubert /* From the INFO struct. */ 7185796c8dcSSimon Schubert if (info->byte_order == BFD_ENDIAN_UNKNOWN 7195796c8dcSSimon Schubert && info->abfd != NULL) 7205796c8dcSSimon Schubert info->byte_order = (bfd_big_endian (info->abfd) ? BFD_ENDIAN_BIG 7215796c8dcSSimon Schubert : bfd_little_endian (info->abfd) ? BFD_ENDIAN_LITTLE 7225796c8dcSSimon Schubert : BFD_ENDIAN_UNKNOWN); 7235796c8dcSSimon Schubert /* From the default. */ 7245796c8dcSSimon Schubert if (info->byte_order == BFD_ENDIAN_UNKNOWN) 7255796c8dcSSimon Schubert info->byte_order = default_byte_order; 7265796c8dcSSimon Schubert info->byte_order_for_code = info->byte_order; 7275796c8dcSSimon Schubert 7285796c8dcSSimon Schubert /* "(gdb) set osabi ...". Handled by gdbarch_lookup_osabi. */ 7295796c8dcSSimon Schubert /* From the manual override, or from file. */ 7305796c8dcSSimon Schubert if (info->osabi == GDB_OSABI_UNINITIALIZED) 7315796c8dcSSimon Schubert info->osabi = gdbarch_lookup_osabi (info->abfd); 7325796c8dcSSimon Schubert /* From the target. */ 7335796c8dcSSimon Schubert if (info->osabi == GDB_OSABI_UNKNOWN && info->target_desc != NULL) 7345796c8dcSSimon Schubert info->osabi = tdesc_osabi (info->target_desc); 7355796c8dcSSimon Schubert /* From the configured default. */ 7365796c8dcSSimon Schubert #ifdef GDB_OSABI_DEFAULT 7375796c8dcSSimon Schubert if (info->osabi == GDB_OSABI_UNKNOWN) 7385796c8dcSSimon Schubert info->osabi = GDB_OSABI_DEFAULT; 7395796c8dcSSimon Schubert #endif 7405796c8dcSSimon Schubert 7415796c8dcSSimon Schubert /* Must have at least filled in the architecture. */ 7425796c8dcSSimon Schubert gdb_assert (info->bfd_arch_info != NULL); 7435796c8dcSSimon Schubert } 7445796c8dcSSimon Schubert 7455796c8dcSSimon Schubert /* Return "current" architecture. If the target is running, this is the 7465796c8dcSSimon Schubert architecture of the selected frame. Otherwise, the "current" architecture 7475796c8dcSSimon Schubert defaults to the target architecture. 7485796c8dcSSimon Schubert 7495796c8dcSSimon Schubert This function should normally be called solely by the command interpreter 7505796c8dcSSimon Schubert routines to determine the architecture to execute a command in. */ 7515796c8dcSSimon Schubert struct gdbarch * 7525796c8dcSSimon Schubert get_current_arch (void) 7535796c8dcSSimon Schubert { 7545796c8dcSSimon Schubert if (has_stack_frames ()) 7555796c8dcSSimon Schubert return get_frame_arch (get_selected_frame (NULL)); 7565796c8dcSSimon Schubert else 7575796c8dcSSimon Schubert return target_gdbarch; 7585796c8dcSSimon Schubert } 7595796c8dcSSimon Schubert 760*cf7f2e2dSJohn Marino int 761*cf7f2e2dSJohn Marino default_has_shared_address_space (struct gdbarch *gdbarch) 762*cf7f2e2dSJohn Marino { 763*cf7f2e2dSJohn Marino /* Simply say no. In most unix-like targets each inferior/process 764*cf7f2e2dSJohn Marino has its own address space. */ 765*cf7f2e2dSJohn Marino return 0; 766*cf7f2e2dSJohn Marino } 767*cf7f2e2dSJohn Marino 768*cf7f2e2dSJohn Marino int 769*cf7f2e2dSJohn Marino default_fast_tracepoint_valid_at (struct gdbarch *gdbarch, 770*cf7f2e2dSJohn Marino CORE_ADDR addr, int *isize, char **msg) 771*cf7f2e2dSJohn Marino { 772*cf7f2e2dSJohn Marino /* We don't know if maybe the target has some way to do fast 773*cf7f2e2dSJohn Marino tracepoints that doesn't need gdbarch, so always say yes. */ 774*cf7f2e2dSJohn Marino if (msg) 775*cf7f2e2dSJohn Marino *msg = NULL; 776*cf7f2e2dSJohn Marino return 1; 777*cf7f2e2dSJohn Marino } 778*cf7f2e2dSJohn Marino 779*cf7f2e2dSJohn Marino void 780*cf7f2e2dSJohn Marino default_remote_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, 781*cf7f2e2dSJohn Marino int *kindptr) 782*cf7f2e2dSJohn Marino { 783*cf7f2e2dSJohn Marino gdbarch_breakpoint_from_pc (gdbarch, pcptr, kindptr); 784*cf7f2e2dSJohn Marino } 785*cf7f2e2dSJohn Marino 7865796c8dcSSimon Schubert /* */ 7875796c8dcSSimon Schubert 7885796c8dcSSimon Schubert extern initialize_file_ftype _initialize_gdbarch_utils; /* -Wmissing-prototypes */ 7895796c8dcSSimon Schubert 7905796c8dcSSimon Schubert void 7915796c8dcSSimon Schubert _initialize_gdbarch_utils (void) 7925796c8dcSSimon Schubert { 7935796c8dcSSimon Schubert add_setshow_enum_cmd ("endian", class_support, 7945796c8dcSSimon Schubert endian_enum, &set_endian_string, _("\ 7955796c8dcSSimon Schubert Set endianness of target."), _("\ 7965796c8dcSSimon Schubert Show endianness of target."), NULL, 7975796c8dcSSimon Schubert set_endian, show_endian, 7985796c8dcSSimon Schubert &setlist, &showlist); 7995796c8dcSSimon Schubert } 800