1 /* Dynamic architecture support for GDB, the GNU debugger.
3 Copyright (C) 1998-2019 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"
24 #include "inferior.h" /* enum CALL_DUMMY_LOCATION et al. */
27 #include "sim-regno.h"
30 #include "target-descriptions.h"
35 #include "gdbsupport/version.h"
37 #include "floatformat.h"
42 default_displaced_step_hw_singlestep (struct gdbarch
*gdbarch
,
43 struct displaced_step_closure
*closure
)
45 return !gdbarch_software_single_step_p (gdbarch
);
49 displaced_step_at_entry_point (struct gdbarch
*gdbarch
)
54 addr
= entry_point_address ();
56 /* Inferior calls also use the entry point as a breakpoint location.
57 We don't want displaced stepping to interfere with those
58 breakpoints, so leave space. */
59 gdbarch_breakpoint_from_pc (gdbarch
, &addr
, &bp_len
);
66 legacy_register_sim_regno (struct gdbarch
*gdbarch
, int regnum
)
68 /* Only makes sense to supply raw registers. */
69 gdb_assert (regnum
>= 0 && regnum
< gdbarch_num_regs (gdbarch
));
70 /* NOTE: cagney/2002-05-13: The old code did it this way and it is
71 suspected that some GDB/SIM combinations may rely on this
72 behaviour. The default should be one2one_register_sim_regno
74 if (gdbarch_register_name (gdbarch
, regnum
) != NULL
75 && gdbarch_register_name (gdbarch
, regnum
)[0] != '\0')
78 return LEGACY_SIM_REGNO_IGNORE
;
82 generic_skip_trampoline_code (struct frame_info
*frame
, CORE_ADDR pc
)
88 generic_skip_solib_resolver (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
94 generic_in_solib_return_trampoline (struct gdbarch
*gdbarch
,
95 CORE_ADDR pc
, const char *name
)
101 generic_stack_frame_destroyed_p (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
107 default_code_of_frame_writable (struct gdbarch
*gdbarch
,
108 struct frame_info
*frame
)
113 /* Helper functions for gdbarch_inner_than */
116 core_addr_lessthan (CORE_ADDR lhs
, CORE_ADDR rhs
)
122 core_addr_greaterthan (CORE_ADDR lhs
, CORE_ADDR rhs
)
127 /* Misc helper functions for targets. */
130 core_addr_identity (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
136 convert_from_func_ptr_addr_identity (struct gdbarch
*gdbarch
, CORE_ADDR addr
,
137 struct target_ops
*targ
)
143 no_op_reg_to_regnum (struct gdbarch
*gdbarch
, int reg
)
149 default_coff_make_msymbol_special (int val
, struct minimal_symbol
*msym
)
154 /* See arch-utils.h. */
157 default_make_symbol_special (struct symbol
*sym
, struct objfile
*objfile
)
162 /* See arch-utils.h. */
165 default_adjust_dwarf2_addr (CORE_ADDR pc
)
170 /* See arch-utils.h. */
173 default_adjust_dwarf2_line (CORE_ADDR addr
, int rel
)
178 /* See arch-utils.h. */
181 default_execute_dwarf_cfa_vendor_op (struct gdbarch
*gdbarch
, gdb_byte op
,
182 struct dwarf2_frame_state
*fs
)
188 cannot_register_not (struct gdbarch
*gdbarch
, int regnum
)
193 /* Legacy version of target_virtual_frame_pointer(). Assumes that
194 there is an gdbarch_deprecated_fp_regnum and that it is the same,
198 legacy_virtual_frame_pointer (struct gdbarch
*gdbarch
,
201 LONGEST
*frame_offset
)
203 /* FIXME: cagney/2002-09-13: This code is used when identifying the
204 frame pointer of the current PC. It is assuming that a single
205 register and an offset can determine this. I think it should
206 instead generate a byte code expression as that would work better
207 with things like Dwarf2's CFI. */
208 if (gdbarch_deprecated_fp_regnum (gdbarch
) >= 0
209 && gdbarch_deprecated_fp_regnum (gdbarch
)
210 < gdbarch_num_regs (gdbarch
))
211 *frame_regnum
= gdbarch_deprecated_fp_regnum (gdbarch
);
212 else if (gdbarch_sp_regnum (gdbarch
) >= 0
213 && gdbarch_sp_regnum (gdbarch
)
214 < gdbarch_num_regs (gdbarch
))
215 *frame_regnum
= gdbarch_sp_regnum (gdbarch
);
217 /* Should this be an internal error? I guess so, it is reflecting
218 an architectural limitation in the current design. */
219 internal_error (__FILE__
, __LINE__
,
220 _("No virtual frame pointer available"));
224 /* Return a floating-point format for a floating-point variable of
225 length LEN in bits. If non-NULL, NAME is the name of its type.
226 If no suitable type is found, return NULL. */
228 const struct floatformat
**
229 default_floatformat_for_type (struct gdbarch
*gdbarch
,
230 const char *name
, int len
)
232 const struct floatformat
**format
= NULL
;
234 if (len
== gdbarch_half_bit (gdbarch
))
235 format
= gdbarch_half_format (gdbarch
);
236 else if (len
== gdbarch_float_bit (gdbarch
))
237 format
= gdbarch_float_format (gdbarch
);
238 else if (len
== gdbarch_double_bit (gdbarch
))
239 format
= gdbarch_double_format (gdbarch
);
240 else if (len
== gdbarch_long_double_bit (gdbarch
))
241 format
= gdbarch_long_double_format (gdbarch
);
242 /* On i386 the 'long double' type takes 96 bits,
243 while the real number of used bits is only 80,
244 both in processor and in memory.
245 The code below accepts the real bit size. */
246 else if (gdbarch_long_double_format (gdbarch
) != NULL
247 && len
== gdbarch_long_double_format (gdbarch
)[0]->totalsize
)
248 format
= gdbarch_long_double_format (gdbarch
);
254 generic_convert_register_p (struct gdbarch
*gdbarch
, int regnum
,
261 default_stabs_argument_has_addr (struct gdbarch
*gdbarch
, struct type
*type
)
267 generic_instruction_nullified (struct gdbarch
*gdbarch
,
268 struct regcache
*regcache
)
274 default_remote_register_number (struct gdbarch
*gdbarch
,
280 /* See arch-utils.h. */
283 default_vsyscall_range (struct gdbarch
*gdbarch
, struct mem_range
*range
)
289 /* Functions to manipulate the endianness of the target. */
291 static enum bfd_endian target_byte_order_user
= BFD_ENDIAN_UNKNOWN
;
293 static const char endian_big
[] = "big";
294 static const char endian_little
[] = "little";
295 static const char endian_auto
[] = "auto";
296 static const char *const endian_enum
[] =
303 static const char *set_endian_string
;
306 selected_byte_order (void)
308 return target_byte_order_user
;
311 /* Called by ``show endian''. */
314 show_endian (struct ui_file
*file
, int from_tty
, struct cmd_list_element
*c
,
317 if (target_byte_order_user
== BFD_ENDIAN_UNKNOWN
)
318 if (gdbarch_byte_order (get_current_arch ()) == BFD_ENDIAN_BIG
)
319 fprintf_unfiltered (file
, _("The target endianness is set automatically "
320 "(currently big endian)\n"));
322 fprintf_unfiltered (file
, _("The target endianness is set automatically "
323 "(currently little endian)\n"));
325 if (target_byte_order_user
== BFD_ENDIAN_BIG
)
326 fprintf_unfiltered (file
,
327 _("The target is assumed to be big endian\n"));
329 fprintf_unfiltered (file
,
330 _("The target is assumed to be little endian\n"));
334 set_endian (const char *ignore_args
, int from_tty
, struct cmd_list_element
*c
)
336 struct gdbarch_info info
;
338 gdbarch_info_init (&info
);
340 if (set_endian_string
== endian_auto
)
342 target_byte_order_user
= BFD_ENDIAN_UNKNOWN
;
343 if (! gdbarch_update_p (info
))
344 internal_error (__FILE__
, __LINE__
,
345 _("set_endian: architecture update failed"));
347 else if (set_endian_string
== endian_little
)
349 info
.byte_order
= BFD_ENDIAN_LITTLE
;
350 if (! gdbarch_update_p (info
))
351 printf_unfiltered (_("Little endian target not supported by GDB\n"));
353 target_byte_order_user
= BFD_ENDIAN_LITTLE
;
355 else if (set_endian_string
== endian_big
)
357 info
.byte_order
= BFD_ENDIAN_BIG
;
358 if (! gdbarch_update_p (info
))
359 printf_unfiltered (_("Big endian target not supported by GDB\n"));
361 target_byte_order_user
= BFD_ENDIAN_BIG
;
364 internal_error (__FILE__
, __LINE__
,
365 _("set_endian: bad value"));
367 show_endian (gdb_stdout
, from_tty
, NULL
, NULL
);
370 /* Given SELECTED, a currently selected BFD architecture, and
371 TARGET_DESC, the current target description, return what
374 SELECTED may be NULL, in which case we return the architecture
375 associated with TARGET_DESC. If SELECTED specifies a variant
376 of the architecture associated with TARGET_DESC, return the
377 more specific of the two.
379 If SELECTED is a different architecture, but it is accepted as
380 compatible by the target, we can use the target architecture.
382 If SELECTED is obviously incompatible, warn the user. */
384 static const struct bfd_arch_info
*
385 choose_architecture_for_target (const struct target_desc
*target_desc
,
386 const struct bfd_arch_info
*selected
)
388 const struct bfd_arch_info
*from_target
= tdesc_architecture (target_desc
);
389 const struct bfd_arch_info
*compat1
, *compat2
;
391 if (selected
== NULL
)
394 if (from_target
== NULL
)
397 /* struct bfd_arch_info objects are singletons: that is, there's
398 supposed to be exactly one instance for a given machine. So you
399 can tell whether two are equivalent by comparing pointers. */
400 if (from_target
== selected
)
403 /* BFD's 'A->compatible (A, B)' functions return zero if A and B are
404 incompatible. But if they are compatible, it returns the 'more
405 featureful' of the two arches. That is, if A can run code
406 written for B, but B can't run code written for A, then it'll
409 Some targets (e.g. MIPS as of 2006-12-04) don't fully
410 implement this, instead always returning NULL or the first
411 argument. We detect that case by checking both directions. */
413 compat1
= selected
->compatible (selected
, from_target
);
414 compat2
= from_target
->compatible (from_target
, selected
);
416 if (compat1
== NULL
&& compat2
== NULL
)
418 /* BFD considers the architectures incompatible. Check our
419 target description whether it accepts SELECTED as compatible
421 if (tdesc_compatible_p (target_desc
, selected
))
424 warning (_("Selected architecture %s is not compatible "
425 "with reported target architecture %s"),
426 selected
->printable_name
, from_target
->printable_name
);
434 if (compat1
== compat2
)
437 /* If the two didn't match, but one of them was a default
438 architecture, assume the more specific one is correct. This
439 handles the case where an executable or target description just
440 says "mips", but the other knows which MIPS variant. */
441 if (compat1
->the_default
)
443 if (compat2
->the_default
)
446 /* We have no idea which one is better. This is a bug, but not
447 a critical problem; warn the user. */
448 warning (_("Selected architecture %s is ambiguous with "
449 "reported target architecture %s"),
450 selected
->printable_name
, from_target
->printable_name
);
454 /* Functions to manipulate the architecture of the target. */
456 enum set_arch
{ set_arch_auto
, set_arch_manual
};
458 static const struct bfd_arch_info
*target_architecture_user
;
460 static const char *set_architecture_string
;
463 selected_architecture_name (void)
465 if (target_architecture_user
== NULL
)
468 return set_architecture_string
;
471 /* Called if the user enters ``show architecture'' without an
475 show_architecture (struct ui_file
*file
, int from_tty
,
476 struct cmd_list_element
*c
, const char *value
)
478 if (target_architecture_user
== NULL
)
479 fprintf_filtered (file
, _("The target architecture is set "
480 "automatically (currently %s)\n"),
481 gdbarch_bfd_arch_info (get_current_arch ())->printable_name
);
483 fprintf_filtered (file
, _("The target architecture is assumed to be %s\n"),
484 set_architecture_string
);
488 /* Called if the user enters ``set architecture'' with or without an
492 set_architecture (const char *ignore_args
,
493 int from_tty
, struct cmd_list_element
*c
)
495 struct gdbarch_info info
;
497 gdbarch_info_init (&info
);
499 if (strcmp (set_architecture_string
, "auto") == 0)
501 target_architecture_user
= NULL
;
502 if (!gdbarch_update_p (info
))
503 internal_error (__FILE__
, __LINE__
,
504 _("could not select an architecture automatically"));
508 info
.bfd_arch_info
= bfd_scan_arch (set_architecture_string
);
509 if (info
.bfd_arch_info
== NULL
)
510 internal_error (__FILE__
, __LINE__
,
511 _("set_architecture: bfd_scan_arch failed"));
512 if (gdbarch_update_p (info
))
513 target_architecture_user
= info
.bfd_arch_info
;
515 printf_unfiltered (_("Architecture `%s' not recognized.\n"),
516 set_architecture_string
);
518 show_architecture (gdb_stdout
, from_tty
, NULL
, NULL
);
521 /* Try to select a global architecture that matches "info". Return
522 non-zero if the attempt succeeds. */
524 gdbarch_update_p (struct gdbarch_info info
)
526 struct gdbarch
*new_gdbarch
;
528 /* Check for the current file. */
529 if (info
.abfd
== NULL
)
530 info
.abfd
= exec_bfd
;
531 if (info
.abfd
== NULL
)
532 info
.abfd
= core_bfd
;
534 /* Check for the current target description. */
535 if (info
.target_desc
== NULL
)
536 info
.target_desc
= target_current_description ();
538 new_gdbarch
= gdbarch_find_by_info (info
);
540 /* If there no architecture by that name, reject the request. */
541 if (new_gdbarch
== NULL
)
544 fprintf_unfiltered (gdb_stdlog
, "gdbarch_update_p: "
545 "Architecture not found\n");
549 /* If it is the same old architecture, accept the request (but don't
551 if (new_gdbarch
== target_gdbarch ())
554 fprintf_unfiltered (gdb_stdlog
, "gdbarch_update_p: "
555 "Architecture %s (%s) unchanged\n",
556 host_address_to_string (new_gdbarch
),
557 gdbarch_bfd_arch_info (new_gdbarch
)->printable_name
);
561 /* It's a new architecture, swap it in. */
563 fprintf_unfiltered (gdb_stdlog
, "gdbarch_update_p: "
564 "New architecture %s (%s) selected\n",
565 host_address_to_string (new_gdbarch
),
566 gdbarch_bfd_arch_info (new_gdbarch
)->printable_name
);
567 set_target_gdbarch (new_gdbarch
);
572 /* Return the architecture for ABFD. If no suitable architecture
573 could be find, return NULL. */
576 gdbarch_from_bfd (bfd
*abfd
)
578 struct gdbarch_info info
;
579 gdbarch_info_init (&info
);
582 return gdbarch_find_by_info (info
);
585 /* Set the dynamic target-system-dependent parameters (architecture,
586 byte-order) using information found in the BFD */
589 set_gdbarch_from_file (bfd
*abfd
)
591 struct gdbarch_info info
;
592 struct gdbarch
*gdbarch
;
594 gdbarch_info_init (&info
);
596 info
.target_desc
= target_current_description ();
597 gdbarch
= gdbarch_find_by_info (info
);
600 error (_("Architecture of file not recognized."));
601 set_target_gdbarch (gdbarch
);
604 /* Initialize the current architecture. Update the ``set
605 architecture'' command so that it specifies a list of valid
608 #ifdef DEFAULT_BFD_ARCH
609 extern const bfd_arch_info_type DEFAULT_BFD_ARCH
;
610 static const bfd_arch_info_type
*default_bfd_arch
= &DEFAULT_BFD_ARCH
;
612 static const bfd_arch_info_type
*default_bfd_arch
;
615 #ifdef DEFAULT_BFD_VEC
616 extern const bfd_target DEFAULT_BFD_VEC
;
617 static const bfd_target
*default_bfd_vec
= &DEFAULT_BFD_VEC
;
619 static const bfd_target
*default_bfd_vec
;
622 static enum bfd_endian default_byte_order
= BFD_ENDIAN_UNKNOWN
;
625 initialize_current_architecture (void)
627 const char **arches
= gdbarch_printable_names ();
628 struct gdbarch_info info
;
630 /* determine a default architecture and byte order. */
631 gdbarch_info_init (&info
);
633 /* Find a default architecture. */
634 if (default_bfd_arch
== NULL
)
636 /* Choose the architecture by taking the first one
638 const char *chosen
= arches
[0];
640 for (arch
= arches
; *arch
!= NULL
; arch
++)
642 if (strcmp (*arch
, chosen
) < 0)
646 internal_error (__FILE__
, __LINE__
,
647 _("initialize_current_architecture: No arch"));
648 default_bfd_arch
= bfd_scan_arch (chosen
);
649 if (default_bfd_arch
== NULL
)
650 internal_error (__FILE__
, __LINE__
,
651 _("initialize_current_architecture: Arch not found"));
654 info
.bfd_arch_info
= default_bfd_arch
;
656 /* Take several guesses at a byte order. */
657 if (default_byte_order
== BFD_ENDIAN_UNKNOWN
658 && default_bfd_vec
!= NULL
)
660 /* Extract BFD's default vector's byte order. */
661 switch (default_bfd_vec
->byteorder
)
664 default_byte_order
= BFD_ENDIAN_BIG
;
666 case BFD_ENDIAN_LITTLE
:
667 default_byte_order
= BFD_ENDIAN_LITTLE
;
673 if (default_byte_order
== BFD_ENDIAN_UNKNOWN
)
675 /* look for ``*el-*'' in the target name. */
677 chp
= strchr (target_name
, '-');
679 && chp
- 2 >= target_name
680 && startswith (chp
- 2, "el"))
681 default_byte_order
= BFD_ENDIAN_LITTLE
;
683 if (default_byte_order
== BFD_ENDIAN_UNKNOWN
)
685 /* Wire it to big-endian!!! */
686 default_byte_order
= BFD_ENDIAN_BIG
;
689 info
.byte_order
= default_byte_order
;
690 info
.byte_order_for_code
= info
.byte_order
;
692 if (! gdbarch_update_p (info
))
693 internal_error (__FILE__
, __LINE__
,
694 _("initialize_current_architecture: Selection of "
695 "initial architecture failed"));
697 /* Create the ``set architecture'' command appending ``auto'' to the
698 list of architectures. */
700 /* Append ``auto''. */
702 for (nr
= 0; arches
[nr
] != NULL
; nr
++);
703 arches
= XRESIZEVEC (const char *, arches
, nr
+ 2);
704 arches
[nr
+ 0] = "auto";
705 arches
[nr
+ 1] = NULL
;
706 add_setshow_enum_cmd ("architecture", class_support
,
707 arches
, &set_architecture_string
,
708 _("Set architecture of target."),
709 _("Show architecture of target."), NULL
,
710 set_architecture
, show_architecture
,
711 &setlist
, &showlist
);
712 add_alias_cmd ("processor", "architecture", class_support
, 1, &setlist
);
717 /* Initialize a gdbarch info to values that will be automatically
718 overridden. Note: Originally, this ``struct info'' was initialized
719 using memset(0). Unfortunately, that ran into problems, namely
720 BFD_ENDIAN_BIG is zero. An explicit initialization function that
721 can explicitly set each field to a well defined value is used. */
724 gdbarch_info_init (struct gdbarch_info
*info
)
726 memset (info
, 0, sizeof (struct gdbarch_info
));
727 info
->byte_order
= BFD_ENDIAN_UNKNOWN
;
728 info
->byte_order_for_code
= info
->byte_order
;
731 /* Similar to init, but this time fill in the blanks. Information is
732 obtained from the global "set ..." options and explicitly
733 initialized INFO fields. */
736 gdbarch_info_fill (struct gdbarch_info
*info
)
738 /* "(gdb) set architecture ...". */
739 if (info
->bfd_arch_info
== NULL
740 && target_architecture_user
)
741 info
->bfd_arch_info
= target_architecture_user
;
743 if (info
->bfd_arch_info
== NULL
744 && info
->abfd
!= NULL
745 && bfd_get_arch (info
->abfd
) != bfd_arch_unknown
746 && bfd_get_arch (info
->abfd
) != bfd_arch_obscure
)
747 info
->bfd_arch_info
= bfd_get_arch_info (info
->abfd
);
748 /* From the target. */
749 if (info
->target_desc
!= NULL
)
750 info
->bfd_arch_info
= choose_architecture_for_target
751 (info
->target_desc
, info
->bfd_arch_info
);
752 /* From the default. */
753 if (info
->bfd_arch_info
== NULL
)
754 info
->bfd_arch_info
= default_bfd_arch
;
756 /* "(gdb) set byte-order ...". */
757 if (info
->byte_order
== BFD_ENDIAN_UNKNOWN
758 && target_byte_order_user
!= BFD_ENDIAN_UNKNOWN
)
759 info
->byte_order
= target_byte_order_user
;
760 /* From the INFO struct. */
761 if (info
->byte_order
== BFD_ENDIAN_UNKNOWN
762 && info
->abfd
!= NULL
)
763 info
->byte_order
= (bfd_big_endian (info
->abfd
) ? BFD_ENDIAN_BIG
764 : bfd_little_endian (info
->abfd
) ? BFD_ENDIAN_LITTLE
765 : BFD_ENDIAN_UNKNOWN
);
766 /* From the default. */
767 if (info
->byte_order
== BFD_ENDIAN_UNKNOWN
)
768 info
->byte_order
= default_byte_order
;
769 info
->byte_order_for_code
= info
->byte_order
;
770 /* Wire the default to the last selected byte order. */
771 default_byte_order
= info
->byte_order
;
773 /* "(gdb) set osabi ...". Handled by gdbarch_lookup_osabi. */
774 /* From the manual override, or from file. */
775 if (info
->osabi
== GDB_OSABI_UNKNOWN
)
776 info
->osabi
= gdbarch_lookup_osabi (info
->abfd
);
777 /* From the target. */
779 if (info
->osabi
== GDB_OSABI_UNKNOWN
&& info
->target_desc
!= NULL
)
780 info
->osabi
= tdesc_osabi (info
->target_desc
);
781 /* From the configured default. */
782 #ifdef GDB_OSABI_DEFAULT
783 if (info
->osabi
== GDB_OSABI_UNKNOWN
)
784 info
->osabi
= GDB_OSABI_DEFAULT
;
786 /* If we still don't know which osabi to pick, pick none. */
787 if (info
->osabi
== GDB_OSABI_UNKNOWN
)
788 info
->osabi
= GDB_OSABI_NONE
;
790 /* Must have at least filled in the architecture. */
791 gdb_assert (info
->bfd_arch_info
!= NULL
);
794 /* Return "current" architecture. If the target is running, this is
795 the architecture of the selected frame. Otherwise, the "current"
796 architecture defaults to the target architecture.
798 This function should normally be called solely by the command
799 interpreter routines to determine the architecture to execute a
802 get_current_arch (void)
804 if (has_stack_frames ())
805 return get_frame_arch (get_selected_frame (NULL
));
807 return target_gdbarch ();
811 default_has_shared_address_space (struct gdbarch
*gdbarch
)
813 /* Simply say no. In most unix-like targets each inferior/process
814 has its own address space. */
819 default_fast_tracepoint_valid_at (struct gdbarch
*gdbarch
, CORE_ADDR addr
,
822 /* We don't know if maybe the target has some way to do fast
823 tracepoints that doesn't need gdbarch, so always say yes. */
830 default_breakpoint_from_pc (struct gdbarch
*gdbarch
, CORE_ADDR
*pcptr
,
833 int kind
= gdbarch_breakpoint_kind_from_pc (gdbarch
, pcptr
);
835 return gdbarch_sw_breakpoint_from_kind (gdbarch
, kind
, lenptr
);
838 default_breakpoint_kind_from_current_state (struct gdbarch
*gdbarch
,
839 struct regcache
*regcache
,
842 return gdbarch_breakpoint_kind_from_pc (gdbarch
, pcptr
);
847 default_gen_return_address (struct gdbarch
*gdbarch
,
848 struct agent_expr
*ax
, struct axs_value
*value
,
851 error (_("This architecture has no method to collect a return address."));
855 default_return_in_first_hidden_param_p (struct gdbarch
*gdbarch
,
858 /* Usually, the return value's address is stored the in the "first hidden"
859 parameter if the return value should be passed by reference, as
861 return !(language_pass_by_reference (type
).trivially_copyable
);
864 int default_insn_is_call (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
869 int default_insn_is_ret (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
874 int default_insn_is_jump (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
880 default_skip_permanent_breakpoint (struct regcache
*regcache
)
882 struct gdbarch
*gdbarch
= regcache
->arch ();
883 CORE_ADDR current_pc
= regcache_read_pc (regcache
);
886 gdbarch_breakpoint_from_pc (gdbarch
, ¤t_pc
, &bp_len
);
887 current_pc
+= bp_len
;
888 regcache_write_pc (regcache
, current_pc
);
892 default_infcall_mmap (CORE_ADDR size
, unsigned prot
)
894 error (_("This target does not support inferior memory allocation by mmap."));
898 default_infcall_munmap (CORE_ADDR addr
, CORE_ADDR size
)
900 /* Memory reserved by inferior mmap is kept leaked. */
903 /* -mcmodel=large is used so that no GOT (Global Offset Table) is needed to be
904 created in inferior memory by GDB (normally it is set by ld.so). */
907 default_gcc_target_options (struct gdbarch
*gdbarch
)
909 return string_printf ("-m%d%s", gdbarch_ptr_bit (gdbarch
),
910 (gdbarch_ptr_bit (gdbarch
) == 64
911 ? " -mcmodel=large" : ""));
914 /* gdbarch gnu_triplet_regexp method. */
917 default_gnu_triplet_regexp (struct gdbarch
*gdbarch
)
919 return gdbarch_bfd_arch_info (gdbarch
)->arch_name
;
922 /* Default method for gdbarch_addressable_memory_unit_size. By default, a memory byte has
923 a size of 1 octet. */
926 default_addressable_memory_unit_size (struct gdbarch
*gdbarch
)
932 default_guess_tracepoint_registers (struct gdbarch
*gdbarch
,
933 struct regcache
*regcache
,
936 int pc_regno
= gdbarch_pc_regnum (gdbarch
);
939 /* This guessing code below only works if the PC register isn't
940 a pseudo-register. The value of a pseudo-register isn't stored
941 in the (non-readonly) regcache -- instead it's recomputed
942 (probably from some other cached raw register) whenever the
943 register is read. In this case, a custom method implementation
944 should be used by the architecture. */
945 if (pc_regno
< 0 || pc_regno
>= gdbarch_num_regs (gdbarch
))
948 regs
= (gdb_byte
*) alloca (register_size (gdbarch
, pc_regno
));
949 store_unsigned_integer (regs
, register_size (gdbarch
, pc_regno
),
950 gdbarch_byte_order (gdbarch
), addr
);
951 regcache
->raw_supply (pc_regno
, regs
);
955 default_print_insn (bfd_vma memaddr
, disassemble_info
*info
)
957 disassembler_ftype disassemble_fn
;
959 disassemble_fn
= disassembler (info
->arch
, info
->endian
== BFD_ENDIAN_BIG
,
960 info
->mach
, exec_bfd
);
962 gdb_assert (disassemble_fn
!= NULL
);
963 return (*disassemble_fn
) (memaddr
, info
);
966 /* See arch-utils.h. */
969 gdbarch_skip_prologue_noexcept (gdbarch
*gdbarch
, CORE_ADDR pc
) noexcept
971 CORE_ADDR new_pc
= pc
;
975 new_pc
= gdbarch_skip_prologue (gdbarch
, pc
);
977 catch (const gdb_exception
&ex
)
983 /* See arch-utils.h. */
986 default_in_indirect_branch_thunk (gdbarch
*gdbarch
, CORE_ADDR pc
)
991 /* See arch-utils.h. */
994 default_type_align (struct gdbarch
*gdbarch
, struct type
*type
)
999 /* See arch-utils.h. */
1002 default_get_pc_address_flags (frame_info
*frame
, CORE_ADDR pc
)
1008 _initialize_gdbarch_utils (void)
1010 add_setshow_enum_cmd ("endian", class_support
,
1011 endian_enum
, &set_endian_string
,
1012 _("Set endianness of target."),
1013 _("Show endianness of target."),
1014 NULL
, set_endian
, show_endian
,
1015 &setlist
, &showlist
);