1 /* Dynamic architecture support for GDB, the GNU debugger.
3 Copyright (C) 1998-2017 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 #include "arch-utils.h"
25 #include "inferior.h" /* enum CALL_DUMMY_LOCATION et al. */
28 #include "sim-regno.h"
31 #include "target-descriptions.h"
38 #include "floatformat.h"
42 struct displaced_step_closure *
43 simple_displaced_step_copy_insn (struct gdbarch *gdbarch,
44 CORE_ADDR from, CORE_ADDR to,
45 struct regcache *regs)
47 size_t len = gdbarch_max_insn_length (gdbarch);
48 gdb_byte *buf = (gdb_byte *) xmalloc (len);
50 read_memory (from, buf, len);
51 write_memory (to, buf, len);
55 fprintf_unfiltered (gdb_stdlog, "displaced: copy %s->%s: ",
56 paddress (gdbarch, from), paddress (gdbarch, to));
57 displaced_step_dump_bytes (gdb_stdlog, buf, len);
60 return (struct displaced_step_closure *) buf;
64 default_displaced_step_hw_singlestep (struct gdbarch *gdbarch,
65 struct displaced_step_closure *closure)
67 return !gdbarch_software_single_step_p (gdbarch);
71 displaced_step_at_entry_point (struct gdbarch *gdbarch)
76 addr = entry_point_address ();
78 /* Inferior calls also use the entry point as a breakpoint location.
79 We don't want displaced stepping to interfere with those
80 breakpoints, so leave space. */
81 gdbarch_breakpoint_from_pc (gdbarch, &addr, &bp_len);
88 legacy_register_sim_regno (struct gdbarch *gdbarch, int regnum)
90 /* Only makes sense to supply raw registers. */
91 gdb_assert (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch));
92 /* NOTE: cagney/2002-05-13: The old code did it this way and it is
93 suspected that some GDB/SIM combinations may rely on this
94 behavour. The default should be one2one_register_sim_regno
96 if (gdbarch_register_name (gdbarch, regnum) != NULL
97 && gdbarch_register_name (gdbarch, regnum)[0] != '\0')
100 return LEGACY_SIM_REGNO_IGNORE;
104 generic_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
110 generic_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc)
116 generic_in_solib_return_trampoline (struct gdbarch *gdbarch,
117 CORE_ADDR pc, const char *name)
123 generic_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
129 default_code_of_frame_writable (struct gdbarch *gdbarch,
130 struct frame_info *frame)
135 /* Helper functions for gdbarch_inner_than */
138 core_addr_lessthan (CORE_ADDR lhs, CORE_ADDR rhs)
144 core_addr_greaterthan (CORE_ADDR lhs, CORE_ADDR rhs)
149 /* Misc helper functions for targets. */
152 core_addr_identity (struct gdbarch *gdbarch, CORE_ADDR addr)
158 convert_from_func_ptr_addr_identity (struct gdbarch *gdbarch, CORE_ADDR addr,
159 struct target_ops *targ)
165 no_op_reg_to_regnum (struct gdbarch *gdbarch, int reg)
171 default_coff_make_msymbol_special (int val, struct minimal_symbol *msym)
176 /* See arch-utils.h. */
179 default_make_symbol_special (struct symbol *sym, struct objfile *objfile)
184 /* See arch-utils.h. */
187 default_adjust_dwarf2_addr (CORE_ADDR pc)
192 /* See arch-utils.h. */
195 default_adjust_dwarf2_line (CORE_ADDR addr, int rel)
200 /* See arch-utils.h. */
203 default_execute_dwarf_cfa_vendor_op (struct gdbarch *gdbarch, gdb_byte op,
204 struct dwarf2_frame_state *fs)
210 cannot_register_not (struct gdbarch *gdbarch, int regnum)
215 /* Legacy version of target_virtual_frame_pointer(). Assumes that
216 there is an gdbarch_deprecated_fp_regnum and that it is the same,
220 legacy_virtual_frame_pointer (struct gdbarch *gdbarch,
223 LONGEST *frame_offset)
225 /* FIXME: cagney/2002-09-13: This code is used when identifying the
226 frame pointer of the current PC. It is assuming that a single
227 register and an offset can determine this. I think it should
228 instead generate a byte code expression as that would work better
229 with things like Dwarf2's CFI. */
230 if (gdbarch_deprecated_fp_regnum (gdbarch) >= 0
231 && gdbarch_deprecated_fp_regnum (gdbarch)
232 < gdbarch_num_regs (gdbarch))
233 *frame_regnum = gdbarch_deprecated_fp_regnum (gdbarch);
234 else if (gdbarch_sp_regnum (gdbarch) >= 0
235 && gdbarch_sp_regnum (gdbarch)
236 < gdbarch_num_regs (gdbarch))
237 *frame_regnum = gdbarch_sp_regnum (gdbarch);
239 /* Should this be an internal error? I guess so, it is reflecting
240 an architectural limitation in the current design. */
241 internal_error (__FILE__, __LINE__,
242 _("No virtual frame pointer available"));
246 /* Return a floating-point format for a floating-point variable of
247 length LEN in bits. If non-NULL, NAME is the name of its type.
248 If no suitable type is found, return NULL. */
250 const struct floatformat **
251 default_floatformat_for_type (struct gdbarch *gdbarch,
252 const char *name, int len)
254 const struct floatformat **format = NULL;
256 if (len == gdbarch_half_bit (gdbarch))
257 format = gdbarch_half_format (gdbarch);
258 else if (len == gdbarch_float_bit (gdbarch))
259 format = gdbarch_float_format (gdbarch);
260 else if (len == gdbarch_double_bit (gdbarch))
261 format = gdbarch_double_format (gdbarch);
262 else if (len == gdbarch_long_double_bit (gdbarch))
263 format = gdbarch_long_double_format (gdbarch);
264 /* On i386 the 'long double' type takes 96 bits,
265 while the real number of used bits is only 80,
266 both in processor and in memory.
267 The code below accepts the real bit size. */
268 else if (gdbarch_long_double_format (gdbarch) != NULL
269 && len == gdbarch_long_double_format (gdbarch)[0]->totalsize)
270 format = gdbarch_long_double_format (gdbarch);
276 generic_convert_register_p (struct gdbarch *gdbarch, int regnum,
283 default_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type)
289 generic_instruction_nullified (struct gdbarch *gdbarch,
290 struct regcache *regcache)
296 default_remote_register_number (struct gdbarch *gdbarch,
302 /* See arch-utils.h. */
305 default_vsyscall_range (struct gdbarch *gdbarch, struct mem_range *range)
311 /* Functions to manipulate the endianness of the target. */
313 static enum bfd_endian target_byte_order_user = BFD_ENDIAN_UNKNOWN;
315 static const char endian_big[] = "big";
316 static const char endian_little[] = "little";
317 static const char endian_auto[] = "auto";
318 static const char *const endian_enum[] =
325 static const char *set_endian_string;
328 selected_byte_order (void)
330 return target_byte_order_user;
333 /* Called by ``show endian''. */
336 show_endian (struct ui_file *file, int from_tty, struct cmd_list_element *c,
339 if (target_byte_order_user == BFD_ENDIAN_UNKNOWN)
340 if (gdbarch_byte_order (get_current_arch ()) == BFD_ENDIAN_BIG)
341 fprintf_unfiltered (file, _("The target endianness is set automatically "
342 "(currently big endian)\n"));
344 fprintf_unfiltered (file, _("The target endianness is set automatically "
345 "(currently little endian)\n"));
347 if (target_byte_order_user == BFD_ENDIAN_BIG)
348 fprintf_unfiltered (file,
349 _("The target is assumed to be big endian\n"));
351 fprintf_unfiltered (file,
352 _("The target is assumed to be little endian\n"));
356 set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c)
358 struct gdbarch_info info;
360 gdbarch_info_init (&info);
362 if (set_endian_string == endian_auto)
364 target_byte_order_user = BFD_ENDIAN_UNKNOWN;
365 if (! gdbarch_update_p (info))
366 internal_error (__FILE__, __LINE__,
367 _("set_endian: architecture update failed"));
369 else if (set_endian_string == endian_little)
371 info.byte_order = BFD_ENDIAN_LITTLE;
372 if (! gdbarch_update_p (info))
373 printf_unfiltered (_("Little endian target not supported by GDB\n"));
375 target_byte_order_user = BFD_ENDIAN_LITTLE;
377 else if (set_endian_string == endian_big)
379 info.byte_order = BFD_ENDIAN_BIG;
380 if (! gdbarch_update_p (info))
381 printf_unfiltered (_("Big endian target not supported by GDB\n"));
383 target_byte_order_user = BFD_ENDIAN_BIG;
386 internal_error (__FILE__, __LINE__,
387 _("set_endian: bad value"));
389 show_endian (gdb_stdout, from_tty, NULL, NULL);
392 /* Given SELECTED, a currently selected BFD architecture, and
393 TARGET_DESC, the current target description, return what
396 SELECTED may be NULL, in which case we return the architecture
397 associated with TARGET_DESC. If SELECTED specifies a variant
398 of the architecture associtated with TARGET_DESC, return the
399 more specific of the two.
401 If SELECTED is a different architecture, but it is accepted as
402 compatible by the target, we can use the target architecture.
404 If SELECTED is obviously incompatible, warn the user. */
406 static const struct bfd_arch_info *
407 choose_architecture_for_target (const struct target_desc *target_desc,
408 const struct bfd_arch_info *selected)
410 const struct bfd_arch_info *from_target = tdesc_architecture (target_desc);
411 const struct bfd_arch_info *compat1, *compat2;
413 if (selected == NULL)
416 if (from_target == NULL)
419 /* struct bfd_arch_info objects are singletons: that is, there's
420 supposed to be exactly one instance for a given machine. So you
421 can tell whether two are equivalent by comparing pointers. */
422 if (from_target == selected)
425 /* BFD's 'A->compatible (A, B)' functions return zero if A and B are
426 incompatible. But if they are compatible, it returns the 'more
427 featureful' of the two arches. That is, if A can run code
428 written for B, but B can't run code written for A, then it'll
431 Some targets (e.g. MIPS as of 2006-12-04) don't fully
432 implement this, instead always returning NULL or the first
433 argument. We detect that case by checking both directions. */
435 compat1 = selected->compatible (selected, from_target);
436 compat2 = from_target->compatible (from_target, selected);
438 if (compat1 == NULL && compat2 == NULL)
440 /* BFD considers the architectures incompatible. Check our
441 target description whether it accepts SELECTED as compatible
443 if (tdesc_compatible_p (target_desc, selected))
446 warning (_("Selected architecture %s is not compatible "
447 "with reported target architecture %s"),
448 selected->printable_name, from_target->printable_name);
456 if (compat1 == compat2)
459 /* If the two didn't match, but one of them was a default
460 architecture, assume the more specific one is correct. This
461 handles the case where an executable or target description just
462 says "mips", but the other knows which MIPS variant. */
463 if (compat1->the_default)
465 if (compat2->the_default)
468 /* We have no idea which one is better. This is a bug, but not
469 a critical problem; warn the user. */
470 warning (_("Selected architecture %s is ambiguous with "
471 "reported target architecture %s"),
472 selected->printable_name, from_target->printable_name);
476 /* Functions to manipulate the architecture of the target. */
478 enum set_arch { set_arch_auto, set_arch_manual };
480 static const struct bfd_arch_info *target_architecture_user;
482 static const char *set_architecture_string;
485 selected_architecture_name (void)
487 if (target_architecture_user == NULL)
490 return set_architecture_string;
493 /* Called if the user enters ``show architecture'' without an
497 show_architecture (struct ui_file *file, int from_tty,
498 struct cmd_list_element *c, const char *value)
500 if (target_architecture_user == NULL)
501 fprintf_filtered (file, _("The target architecture is set "
502 "automatically (currently %s)\n"),
503 gdbarch_bfd_arch_info (get_current_arch ())->printable_name);
505 fprintf_filtered (file, _("The target architecture is assumed to be %s\n"),
506 set_architecture_string);
510 /* Called if the user enters ``set architecture'' with or without an
514 set_architecture (char *ignore_args, int from_tty, struct cmd_list_element *c)
516 struct gdbarch_info info;
518 gdbarch_info_init (&info);
520 if (strcmp (set_architecture_string, "auto") == 0)
522 target_architecture_user = NULL;
523 if (!gdbarch_update_p (info))
524 internal_error (__FILE__, __LINE__,
525 _("could not select an architecture automatically"));
529 info.bfd_arch_info = bfd_scan_arch (set_architecture_string);
530 if (info.bfd_arch_info == NULL)
531 internal_error (__FILE__, __LINE__,
532 _("set_architecture: bfd_scan_arch failed"));
533 if (gdbarch_update_p (info))
534 target_architecture_user = info.bfd_arch_info;
536 printf_unfiltered (_("Architecture `%s' not recognized.\n"),
537 set_architecture_string);
539 show_architecture (gdb_stdout, from_tty, NULL, NULL);
542 /* Try to select a global architecture that matches "info". Return
543 non-zero if the attempt succeeds. */
545 gdbarch_update_p (struct gdbarch_info info)
547 struct gdbarch *new_gdbarch;
549 /* Check for the current file. */
550 if (info.abfd == NULL)
551 info.abfd = exec_bfd;
552 if (info.abfd == NULL)
553 info.abfd = core_bfd;
555 /* Check for the current target description. */
556 if (info.target_desc == NULL)
557 info.target_desc = target_current_description ();
559 new_gdbarch = gdbarch_find_by_info (info);
561 /* If there no architecture by that name, reject the request. */
562 if (new_gdbarch == NULL)
565 fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: "
566 "Architecture not found\n");
570 /* If it is the same old architecture, accept the request (but don't
572 if (new_gdbarch == target_gdbarch ())
575 fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: "
576 "Architecture %s (%s) unchanged\n",
577 host_address_to_string (new_gdbarch),
578 gdbarch_bfd_arch_info (new_gdbarch)->printable_name);
582 /* It's a new architecture, swap it in. */
584 fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: "
585 "New architecture %s (%s) selected\n",
586 host_address_to_string (new_gdbarch),
587 gdbarch_bfd_arch_info (new_gdbarch)->printable_name);
588 set_target_gdbarch (new_gdbarch);
593 /* Return the architecture for ABFD. If no suitable architecture
594 could be find, return NULL. */
597 gdbarch_from_bfd (bfd *abfd)
599 struct gdbarch_info info;
600 gdbarch_info_init (&info);
603 return gdbarch_find_by_info (info);
606 /* Set the dynamic target-system-dependent parameters (architecture,
607 byte-order) using information found in the BFD */
610 set_gdbarch_from_file (bfd *abfd)
612 struct gdbarch_info info;
613 struct gdbarch *gdbarch;
615 gdbarch_info_init (&info);
617 info.target_desc = target_current_description ();
618 gdbarch = gdbarch_find_by_info (info);
621 error (_("Architecture of file not recognized."));
622 set_target_gdbarch (gdbarch);
625 /* Initialize the current architecture. Update the ``set
626 architecture'' command so that it specifies a list of valid
629 #ifdef DEFAULT_BFD_ARCH
630 extern const bfd_arch_info_type DEFAULT_BFD_ARCH;
631 static const bfd_arch_info_type *default_bfd_arch = &DEFAULT_BFD_ARCH;
633 static const bfd_arch_info_type *default_bfd_arch;
636 #ifdef DEFAULT_BFD_VEC
637 extern const bfd_target DEFAULT_BFD_VEC;
638 static const bfd_target *default_bfd_vec = &DEFAULT_BFD_VEC;
640 static const bfd_target *default_bfd_vec;
643 static enum bfd_endian default_byte_order = BFD_ENDIAN_UNKNOWN;
646 initialize_current_architecture (void)
648 const char **arches = gdbarch_printable_names ();
649 struct gdbarch_info info;
651 /* determine a default architecture and byte order. */
652 gdbarch_info_init (&info);
654 /* Find a default architecture. */
655 if (default_bfd_arch == NULL)
657 /* Choose the architecture by taking the first one
659 const char *chosen = arches[0];
661 for (arch = arches; *arch != NULL; arch++)
663 if (strcmp (*arch, chosen) < 0)
667 internal_error (__FILE__, __LINE__,
668 _("initialize_current_architecture: No arch"));
669 default_bfd_arch = bfd_scan_arch (chosen);
670 if (default_bfd_arch == NULL)
671 internal_error (__FILE__, __LINE__,
672 _("initialize_current_architecture: Arch not found"));
675 info.bfd_arch_info = default_bfd_arch;
677 /* Take several guesses at a byte order. */
678 if (default_byte_order == BFD_ENDIAN_UNKNOWN
679 && default_bfd_vec != NULL)
681 /* Extract BFD's default vector's byte order. */
682 switch (default_bfd_vec->byteorder)
685 default_byte_order = BFD_ENDIAN_BIG;
687 case BFD_ENDIAN_LITTLE:
688 default_byte_order = BFD_ENDIAN_LITTLE;
694 if (default_byte_order == BFD_ENDIAN_UNKNOWN)
696 /* look for ``*el-*'' in the target name. */
698 chp = strchr (target_name, '-');
700 && chp - 2 >= target_name
701 && startswith (chp - 2, "el"))
702 default_byte_order = BFD_ENDIAN_LITTLE;
704 if (default_byte_order == BFD_ENDIAN_UNKNOWN)
706 /* Wire it to big-endian!!! */
707 default_byte_order = BFD_ENDIAN_BIG;
710 info.byte_order = default_byte_order;
711 info.byte_order_for_code = info.byte_order;
713 if (! gdbarch_update_p (info))
714 internal_error (__FILE__, __LINE__,
715 _("initialize_current_architecture: Selection of "
716 "initial architecture failed"));
718 /* Create the ``set architecture'' command appending ``auto'' to the
719 list of architectures. */
721 /* Append ``auto''. */
723 for (nr = 0; arches[nr] != NULL; nr++);
724 arches = XRESIZEVEC (const char *, arches, nr + 2);
725 arches[nr + 0] = "auto";
726 arches[nr + 1] = NULL;
727 add_setshow_enum_cmd ("architecture", class_support,
728 arches, &set_architecture_string,
729 _("Set architecture of target."),
730 _("Show architecture of target."), NULL,
731 set_architecture, show_architecture,
732 &setlist, &showlist);
733 add_alias_cmd ("processor", "architecture", class_support, 1, &setlist);
738 /* Initialize a gdbarch info to values that will be automatically
739 overridden. Note: Originally, this ``struct info'' was initialized
740 using memset(0). Unfortunately, that ran into problems, namely
741 BFD_ENDIAN_BIG is zero. An explicit initialization function that
742 can explicitly set each field to a well defined value is used. */
745 gdbarch_info_init (struct gdbarch_info *info)
747 memset (info, 0, sizeof (struct gdbarch_info));
748 info->byte_order = BFD_ENDIAN_UNKNOWN;
749 info->byte_order_for_code = info->byte_order;
750 info->osabi = GDB_OSABI_UNINITIALIZED;
753 /* Similar to init, but this time fill in the blanks. Information is
754 obtained from the global "set ..." options and explicitly
755 initialized INFO fields. */
758 gdbarch_info_fill (struct gdbarch_info *info)
760 /* "(gdb) set architecture ...". */
761 if (info->bfd_arch_info == NULL
762 && target_architecture_user)
763 info->bfd_arch_info = target_architecture_user;
765 if (info->bfd_arch_info == NULL
766 && info->abfd != NULL
767 && bfd_get_arch (info->abfd) != bfd_arch_unknown
768 && bfd_get_arch (info->abfd) != bfd_arch_obscure)
769 info->bfd_arch_info = bfd_get_arch_info (info->abfd);
770 /* From the target. */
771 if (info->target_desc != NULL)
772 info->bfd_arch_info = choose_architecture_for_target
773 (info->target_desc, info->bfd_arch_info);
774 /* From the default. */
775 if (info->bfd_arch_info == NULL)
776 info->bfd_arch_info = default_bfd_arch;
778 /* "(gdb) set byte-order ...". */
779 if (info->byte_order == BFD_ENDIAN_UNKNOWN
780 && target_byte_order_user != BFD_ENDIAN_UNKNOWN)
781 info->byte_order = target_byte_order_user;
782 /* From the INFO struct. */
783 if (info->byte_order == BFD_ENDIAN_UNKNOWN
784 && info->abfd != NULL)
785 info->byte_order = (bfd_big_endian (info->abfd) ? BFD_ENDIAN_BIG
786 : bfd_little_endian (info->abfd) ? BFD_ENDIAN_LITTLE
787 : BFD_ENDIAN_UNKNOWN);
788 /* From the default. */
789 if (info->byte_order == BFD_ENDIAN_UNKNOWN)
790 info->byte_order = default_byte_order;
791 info->byte_order_for_code = info->byte_order;
793 /* "(gdb) set osabi ...". Handled by gdbarch_lookup_osabi. */
794 /* From the manual override, or from file. */
795 if (info->osabi == GDB_OSABI_UNINITIALIZED)
796 info->osabi = gdbarch_lookup_osabi (info->abfd);
797 /* From the target. */
798 if (info->osabi == GDB_OSABI_UNKNOWN && info->target_desc != NULL)
799 info->osabi = tdesc_osabi (info->target_desc);
800 /* From the configured default. */
801 #ifdef GDB_OSABI_DEFAULT
802 if (info->osabi == GDB_OSABI_UNKNOWN)
803 info->osabi = GDB_OSABI_DEFAULT;
806 /* Must have at least filled in the architecture. */
807 gdb_assert (info->bfd_arch_info != NULL);
810 /* Return "current" architecture. If the target is running, this is
811 the architecture of the selected frame. Otherwise, the "current"
812 architecture defaults to the target architecture.
814 This function should normally be called solely by the command
815 interpreter routines to determine the architecture to execute a
818 get_current_arch (void)
820 if (has_stack_frames ())
821 return get_frame_arch (get_selected_frame (NULL));
823 return target_gdbarch ();
827 default_has_shared_address_space (struct gdbarch *gdbarch)
829 /* Simply say no. In most unix-like targets each inferior/process
830 has its own address space. */
835 default_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr,
838 /* We don't know if maybe the target has some way to do fast
839 tracepoints that doesn't need gdbarch, so always say yes. */
846 default_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
849 int kind = gdbarch_breakpoint_kind_from_pc (gdbarch, pcptr);
851 return gdbarch_sw_breakpoint_from_kind (gdbarch, kind, lenptr);
854 default_breakpoint_kind_from_current_state (struct gdbarch *gdbarch,
855 struct regcache *regcache,
858 return gdbarch_breakpoint_kind_from_pc (gdbarch, pcptr);
863 default_gen_return_address (struct gdbarch *gdbarch,
864 struct agent_expr *ax, struct axs_value *value,
867 error (_("This architecture has no method to collect a return address."));
871 default_return_in_first_hidden_param_p (struct gdbarch *gdbarch,
874 /* Usually, the return value's address is stored the in the "first hidden"
875 parameter if the return value should be passed by reference, as
877 return language_pass_by_reference (type);
880 int default_insn_is_call (struct gdbarch *gdbarch, CORE_ADDR addr)
885 int default_insn_is_ret (struct gdbarch *gdbarch, CORE_ADDR addr)
890 int default_insn_is_jump (struct gdbarch *gdbarch, CORE_ADDR addr)
896 default_skip_permanent_breakpoint (struct regcache *regcache)
898 struct gdbarch *gdbarch = get_regcache_arch (regcache);
899 CORE_ADDR current_pc = regcache_read_pc (regcache);
902 gdbarch_breakpoint_from_pc (gdbarch, ¤t_pc, &bp_len);
903 current_pc += bp_len;
904 regcache_write_pc (regcache, current_pc);
908 default_infcall_mmap (CORE_ADDR size, unsigned prot)
910 error (_("This target does not support inferior memory allocation by mmap."));
914 default_infcall_munmap (CORE_ADDR addr, CORE_ADDR size)
916 /* Memory reserved by inferior mmap is kept leaked. */
919 /* -mcmodel=large is used so that no GOT (Global Offset Table) is needed to be
920 created in inferior memory by GDB (normally it is set by ld.so). */
923 default_gcc_target_options (struct gdbarch *gdbarch)
925 return xstrprintf ("-m%d%s", gdbarch_ptr_bit (gdbarch),
926 gdbarch_ptr_bit (gdbarch) == 64 ? " -mcmodel=large" : "");
929 /* gdbarch gnu_triplet_regexp method. */
932 default_gnu_triplet_regexp (struct gdbarch *gdbarch)
934 return gdbarch_bfd_arch_info (gdbarch)->arch_name;
937 /* Default method for gdbarch_addressable_memory_unit_size. By default, a memory byte has
938 a size of 1 octet. */
941 default_addressable_memory_unit_size (struct gdbarch *gdbarch)
947 default_guess_tracepoint_registers (struct gdbarch *gdbarch,
948 struct regcache *regcache,
951 int pc_regno = gdbarch_pc_regnum (gdbarch);
954 /* This guessing code below only works if the PC register isn't
955 a pseudo-register. The value of a pseudo-register isn't stored
956 in the (non-readonly) regcache -- instead it's recomputed
957 (probably from some other cached raw register) whenever the
958 register is read. In this case, a custom method implementation
959 should be used by the architecture. */
960 if (pc_regno < 0 || pc_regno >= gdbarch_num_regs (gdbarch))
963 regs = (gdb_byte *) alloca (register_size (gdbarch, pc_regno));
964 store_unsigned_integer (regs, register_size (gdbarch, pc_regno),
965 gdbarch_byte_order (gdbarch), addr);
966 regcache_raw_supply (regcache, pc_regno, regs);
970 default_print_insn (bfd_vma memaddr, disassemble_info *info)
972 disassembler_ftype disassemble_fn;
974 if (exec_bfd != NULL)
976 gdb_assert (info->arch == bfd_get_arch (exec_bfd));
977 gdb_assert (info->endian == (bfd_big_endian (exec_bfd)
978 ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE));
979 gdb_assert (info->mach == bfd_get_mach (exec_bfd));
981 disassemble_fn = disassembler (info->arch, info->endian == BFD_ENDIAN_BIG,
982 info->mach, exec_bfd);
984 gdb_assert (disassemble_fn != NULL);
985 return (*disassemble_fn) (memaddr, info);
988 /* -Wmissing-prototypes */
989 extern initialize_file_ftype _initialize_gdbarch_utils;
992 _initialize_gdbarch_utils (void)
994 add_setshow_enum_cmd ("endian", class_support,
995 endian_enum, &set_endian_string,
996 _("Set endianness of target."),
997 _("Show endianness of target."),
998 NULL, set_endian, show_endian,
999 &setlist, &showlist);