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 /* Local non-gdb includes. */
23 #include "arch-utils.h"
24 #include "common/version.h"
26 #include "floatformat.h"
35 #include "sim-regno.h"
37 #include "target-descriptions.h"
40 default_displaced_step_hw_singlestep (struct gdbarch
*gdbarch
,
41 struct displaced_step_closure
*closure
)
43 return !gdbarch_software_single_step_p (gdbarch
);
47 displaced_step_at_entry_point (struct gdbarch
*gdbarch
)
52 addr
= entry_point_address ();
54 /* Inferior calls also use the entry point as a breakpoint location.
55 We don't want displaced stepping to interfere with those
56 breakpoints, so leave space. */
57 gdbarch_breakpoint_from_pc (gdbarch
, &addr
, &bp_len
);
64 legacy_register_sim_regno (struct gdbarch
*gdbarch
, int regnum
)
66 /* Only makes sense to supply raw registers. */
67 gdb_assert (regnum
>= 0 && regnum
< gdbarch_num_regs (gdbarch
));
68 /* NOTE: cagney/2002-05-13: The old code did it this way and it is
69 suspected that some GDB/SIM combinations may rely on this
70 behavour. The default should be one2one_register_sim_regno
72 if (gdbarch_register_name (gdbarch
, regnum
) != NULL
73 && gdbarch_register_name (gdbarch
, regnum
)[0] != '\0')
76 return LEGACY_SIM_REGNO_IGNORE
;
80 generic_skip_trampoline_code (struct frame_info
*frame
, CORE_ADDR pc
)
86 generic_skip_solib_resolver (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
92 generic_in_solib_return_trampoline (struct gdbarch
*gdbarch
,
93 CORE_ADDR pc
, const char *name
)
99 generic_stack_frame_destroyed_p (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
105 default_code_of_frame_writable (struct gdbarch
*gdbarch
,
106 struct frame_info
*frame
)
111 /* Helper functions for gdbarch_inner_than */
114 core_addr_lessthan (CORE_ADDR lhs
, CORE_ADDR rhs
)
120 core_addr_greaterthan (CORE_ADDR lhs
, CORE_ADDR rhs
)
125 /* Misc helper functions for targets. */
128 core_addr_identity (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
134 convert_from_func_ptr_addr_identity (struct gdbarch
*gdbarch
, CORE_ADDR addr
,
135 struct target_ops
*targ
)
141 no_op_reg_to_regnum (struct gdbarch
*gdbarch
, int reg
)
147 default_coff_make_msymbol_special (int val
, struct minimal_symbol
*msym
)
152 /* See arch-utils.h. */
155 default_make_symbol_special (struct symbol
*sym
, struct objfile
*objfile
)
160 /* See arch-utils.h. */
163 default_adjust_dwarf2_addr (CORE_ADDR pc
)
168 /* See arch-utils.h. */
171 default_adjust_dwarf2_line (CORE_ADDR addr
, int rel
)
176 /* See arch-utils.h. */
179 default_execute_dwarf_cfa_vendor_op (struct gdbarch
*gdbarch
, gdb_byte op
,
180 struct dwarf2_frame_state
*fs
)
186 cannot_register_not (struct gdbarch
*gdbarch
, int regnum
)
191 /* Legacy version of target_virtual_frame_pointer(). Assumes that
192 there is an gdbarch_deprecated_fp_regnum and that it is the same,
196 legacy_virtual_frame_pointer (struct gdbarch
*gdbarch
,
199 LONGEST
*frame_offset
)
201 /* FIXME: cagney/2002-09-13: This code is used when identifying the
202 frame pointer of the current PC. It is assuming that a single
203 register and an offset can determine this. I think it should
204 instead generate a byte code expression as that would work better
205 with things like Dwarf2's CFI. */
206 if (gdbarch_deprecated_fp_regnum (gdbarch
) >= 0
207 && gdbarch_deprecated_fp_regnum (gdbarch
)
208 < gdbarch_num_regs (gdbarch
))
209 *frame_regnum
= gdbarch_deprecated_fp_regnum (gdbarch
);
210 else if (gdbarch_sp_regnum (gdbarch
) >= 0
211 && gdbarch_sp_regnum (gdbarch
)
212 < gdbarch_num_regs (gdbarch
))
213 *frame_regnum
= gdbarch_sp_regnum (gdbarch
);
215 /* Should this be an internal error? I guess so, it is reflecting
216 an architectural limitation in the current design. */
217 internal_error (__FILE__
, __LINE__
,
218 _("No virtual frame pointer available"));
222 /* Return a floating-point format for a floating-point variable of
223 length LEN in bits. If non-NULL, NAME is the name of its type.
224 If no suitable type is found, return NULL. */
226 const struct floatformat
**
227 default_floatformat_for_type (struct gdbarch
*gdbarch
,
228 const char *name
, int len
)
230 const struct floatformat
**format
= NULL
;
232 if (len
== gdbarch_half_bit (gdbarch
))
233 format
= gdbarch_half_format (gdbarch
);
234 else if (len
== gdbarch_float_bit (gdbarch
))
235 format
= gdbarch_float_format (gdbarch
);
236 else if (len
== gdbarch_double_bit (gdbarch
))
237 format
= gdbarch_double_format (gdbarch
);
238 else if (len
== gdbarch_long_double_bit (gdbarch
))
239 format
= gdbarch_long_double_format (gdbarch
);
240 /* On i386 the 'long double' type takes 96 bits,
241 while the real number of used bits is only 80,
242 both in processor and in memory.
243 The code below accepts the real bit size. */
244 else if (gdbarch_long_double_format (gdbarch
) != NULL
245 && len
== gdbarch_long_double_format (gdbarch
)[0]->totalsize
)
246 format
= gdbarch_long_double_format (gdbarch
);
252 generic_convert_register_p (struct gdbarch
*gdbarch
, int regnum
,
259 default_stabs_argument_has_addr (struct gdbarch
*gdbarch
, struct type
*type
)
265 generic_instruction_nullified (struct gdbarch
*gdbarch
,
266 struct regcache
*regcache
)
272 default_remote_register_number (struct gdbarch
*gdbarch
,
278 /* See arch-utils.h. */
281 default_vsyscall_range (struct gdbarch
*gdbarch
, struct mem_range
*range
)
287 /* Functions to manipulate the endianness of the target. */
289 static enum bfd_endian target_byte_order_user
= BFD_ENDIAN_UNKNOWN
;
291 static const char endian_big
[] = "big";
292 static const char endian_little
[] = "little";
293 static const char endian_auto
[] = "auto";
294 static const char *const endian_enum
[] =
301 static const char *set_endian_string
;
304 selected_byte_order (void)
306 return target_byte_order_user
;
309 /* Called by ``show endian''. */
312 show_endian (struct ui_file
*file
, int from_tty
, struct cmd_list_element
*c
,
315 if (target_byte_order_user
== BFD_ENDIAN_UNKNOWN
)
316 if (gdbarch_byte_order (get_current_arch ()) == BFD_ENDIAN_BIG
)
317 fprintf_unfiltered (file
, _("The target endianness is set automatically "
318 "(currently big endian)\n"));
320 fprintf_unfiltered (file
, _("The target endianness is set automatically "
321 "(currently little endian)\n"));
323 if (target_byte_order_user
== BFD_ENDIAN_BIG
)
324 fprintf_unfiltered (file
,
325 _("The target is assumed to be big endian\n"));
327 fprintf_unfiltered (file
,
328 _("The target is assumed to be little endian\n"));
332 set_endian (const char *ignore_args
, int from_tty
, struct cmd_list_element
*c
)
334 struct gdbarch_info info
;
336 gdbarch_info_init (&info
);
338 if (set_endian_string
== endian_auto
)
340 target_byte_order_user
= BFD_ENDIAN_UNKNOWN
;
341 if (! gdbarch_update_p (info
))
342 internal_error (__FILE__
, __LINE__
,
343 _("set_endian: architecture update failed"));
345 else if (set_endian_string
== endian_little
)
347 info
.byte_order
= BFD_ENDIAN_LITTLE
;
348 if (! gdbarch_update_p (info
))
349 printf_unfiltered (_("Little endian target not supported by GDB\n"));
351 target_byte_order_user
= BFD_ENDIAN_LITTLE
;
353 else if (set_endian_string
== endian_big
)
355 info
.byte_order
= BFD_ENDIAN_BIG
;
356 if (! gdbarch_update_p (info
))
357 printf_unfiltered (_("Big endian target not supported by GDB\n"));
359 target_byte_order_user
= BFD_ENDIAN_BIG
;
362 internal_error (__FILE__
, __LINE__
,
363 _("set_endian: bad value"));
365 show_endian (gdb_stdout
, from_tty
, NULL
, NULL
);
368 /* Given SELECTED, a currently selected BFD architecture, and
369 TARGET_DESC, the current target description, return what
372 SELECTED may be NULL, in which case we return the architecture
373 associated with TARGET_DESC. If SELECTED specifies a variant
374 of the architecture associtated with TARGET_DESC, return the
375 more specific of the two.
377 If SELECTED is a different architecture, but it is accepted as
378 compatible by the target, we can use the target architecture.
380 If SELECTED is obviously incompatible, warn the user. */
382 static const struct bfd_arch_info
*
383 choose_architecture_for_target (const struct target_desc
*target_desc
,
384 const struct bfd_arch_info
*selected
)
386 const struct bfd_arch_info
*from_target
= tdesc_architecture (target_desc
);
387 const struct bfd_arch_info
*compat1
, *compat2
;
389 if (selected
== NULL
)
392 if (from_target
== NULL
)
395 /* struct bfd_arch_info objects are singletons: that is, there's
396 supposed to be exactly one instance for a given machine. So you
397 can tell whether two are equivalent by comparing pointers. */
398 if (from_target
== selected
)
401 /* BFD's 'A->compatible (A, B)' functions return zero if A and B are
402 incompatible. But if they are compatible, it returns the 'more
403 featureful' of the two arches. That is, if A can run code
404 written for B, but B can't run code written for A, then it'll
407 Some targets (e.g. MIPS as of 2006-12-04) don't fully
408 implement this, instead always returning NULL or the first
409 argument. We detect that case by checking both directions. */
411 compat1
= selected
->compatible (selected
, from_target
);
412 compat2
= from_target
->compatible (from_target
, selected
);
414 if (compat1
== NULL
&& compat2
== NULL
)
416 /* BFD considers the architectures incompatible. Check our
417 target description whether it accepts SELECTED as compatible
419 if (tdesc_compatible_p (target_desc
, selected
))
422 warning (_("Selected architecture %s is not compatible "
423 "with reported target architecture %s"),
424 selected
->printable_name
, from_target
->printable_name
);
432 if (compat1
== compat2
)
435 /* If the two didn't match, but one of them was a default
436 architecture, assume the more specific one is correct. This
437 handles the case where an executable or target description just
438 says "mips", but the other knows which MIPS variant. */
439 if (compat1
->the_default
)
441 if (compat2
->the_default
)
444 /* We have no idea which one is better. This is a bug, but not
445 a critical problem; warn the user. */
446 warning (_("Selected architecture %s is ambiguous with "
447 "reported target architecture %s"),
448 selected
->printable_name
, from_target
->printable_name
);
452 /* Functions to manipulate the architecture of the target. */
454 enum set_arch
{ set_arch_auto
, set_arch_manual
};
456 static const struct bfd_arch_info
*target_architecture_user
;
458 static const char *set_architecture_string
;
461 selected_architecture_name (void)
463 if (target_architecture_user
== NULL
)
466 return set_architecture_string
;
469 /* Called if the user enters ``show architecture'' without an
473 show_architecture (struct ui_file
*file
, int from_tty
,
474 struct cmd_list_element
*c
, const char *value
)
476 if (target_architecture_user
== NULL
)
477 fprintf_filtered (file
, _("The target architecture is set "
478 "automatically (currently %s)\n"),
479 gdbarch_bfd_arch_info (get_current_arch ())->printable_name
);
481 fprintf_filtered (file
, _("The target architecture is assumed to be %s\n"),
482 set_architecture_string
);
486 /* Called if the user enters ``set architecture'' with or without an
490 set_architecture (const char *ignore_args
,
491 int from_tty
, struct cmd_list_element
*c
)
493 struct gdbarch_info info
;
495 gdbarch_info_init (&info
);
497 if (strcmp (set_architecture_string
, "auto") == 0)
499 target_architecture_user
= NULL
;
500 if (!gdbarch_update_p (info
))
501 internal_error (__FILE__
, __LINE__
,
502 _("could not select an architecture automatically"));
506 info
.bfd_arch_info
= bfd_scan_arch (set_architecture_string
);
507 if (info
.bfd_arch_info
== NULL
)
508 internal_error (__FILE__
, __LINE__
,
509 _("set_architecture: bfd_scan_arch failed"));
510 if (gdbarch_update_p (info
))
511 target_architecture_user
= info
.bfd_arch_info
;
513 printf_unfiltered (_("Architecture `%s' not recognized.\n"),
514 set_architecture_string
);
516 show_architecture (gdb_stdout
, from_tty
, NULL
, NULL
);
519 /* Try to select a global architecture that matches "info". Return
520 non-zero if the attempt succeeds. */
522 gdbarch_update_p (struct gdbarch_info info
)
524 struct gdbarch
*new_gdbarch
;
526 /* Check for the current file. */
527 if (info
.abfd
== NULL
)
528 info
.abfd
= exec_bfd
;
529 if (info
.abfd
== NULL
)
530 info
.abfd
= core_bfd
;
532 /* Check for the current target description. */
533 if (info
.target_desc
== NULL
)
534 info
.target_desc
= target_current_description ();
536 new_gdbarch
= gdbarch_find_by_info (info
);
538 /* If there no architecture by that name, reject the request. */
539 if (new_gdbarch
== NULL
)
542 fprintf_unfiltered (gdb_stdlog
, "gdbarch_update_p: "
543 "Architecture not found\n");
547 /* If it is the same old architecture, accept the request (but don't
549 if (new_gdbarch
== target_gdbarch ())
552 fprintf_unfiltered (gdb_stdlog
, "gdbarch_update_p: "
553 "Architecture %s (%s) unchanged\n",
554 host_address_to_string (new_gdbarch
),
555 gdbarch_bfd_arch_info (new_gdbarch
)->printable_name
);
559 /* It's a new architecture, swap it in. */
561 fprintf_unfiltered (gdb_stdlog
, "gdbarch_update_p: "
562 "New architecture %s (%s) selected\n",
563 host_address_to_string (new_gdbarch
),
564 gdbarch_bfd_arch_info (new_gdbarch
)->printable_name
);
565 set_target_gdbarch (new_gdbarch
);
570 /* Return the architecture for ABFD. If no suitable architecture
571 could be find, return NULL. */
574 gdbarch_from_bfd (bfd
*abfd
)
576 struct gdbarch_info info
;
577 gdbarch_info_init (&info
);
580 return gdbarch_find_by_info (info
);
583 /* Set the dynamic target-system-dependent parameters (architecture,
584 byte-order) using information found in the BFD */
587 set_gdbarch_from_file (bfd
*abfd
)
589 struct gdbarch_info info
;
590 struct gdbarch
*gdbarch
;
592 gdbarch_info_init (&info
);
594 info
.target_desc
= target_current_description ();
595 gdbarch
= gdbarch_find_by_info (info
);
598 error (_("Architecture of file not recognized."));
599 set_target_gdbarch (gdbarch
);
602 /* Initialize the current architecture. Update the ``set
603 architecture'' command so that it specifies a list of valid
606 #ifdef DEFAULT_BFD_ARCH
607 extern const bfd_arch_info_type DEFAULT_BFD_ARCH
;
608 static const bfd_arch_info_type
*default_bfd_arch
= &DEFAULT_BFD_ARCH
;
610 static const bfd_arch_info_type
*default_bfd_arch
;
613 #ifdef DEFAULT_BFD_VEC
614 extern const bfd_target DEFAULT_BFD_VEC
;
615 static const bfd_target
*default_bfd_vec
= &DEFAULT_BFD_VEC
;
617 static const bfd_target
*default_bfd_vec
;
620 static enum bfd_endian default_byte_order
= BFD_ENDIAN_UNKNOWN
;
623 initialize_current_architecture (void)
625 const char **arches
= gdbarch_printable_names ();
626 struct gdbarch_info info
;
628 /* determine a default architecture and byte order. */
629 gdbarch_info_init (&info
);
631 /* Find a default architecture. */
632 if (default_bfd_arch
== NULL
)
634 /* Choose the architecture by taking the first one
636 const char *chosen
= arches
[0];
638 for (arch
= arches
; *arch
!= NULL
; arch
++)
640 if (strcmp (*arch
, chosen
) < 0)
644 internal_error (__FILE__
, __LINE__
,
645 _("initialize_current_architecture: No arch"));
646 default_bfd_arch
= bfd_scan_arch (chosen
);
647 if (default_bfd_arch
== NULL
)
648 internal_error (__FILE__
, __LINE__
,
649 _("initialize_current_architecture: Arch not found"));
652 info
.bfd_arch_info
= default_bfd_arch
;
654 /* Take several guesses at a byte order. */
655 if (default_byte_order
== BFD_ENDIAN_UNKNOWN
656 && default_bfd_vec
!= NULL
)
658 /* Extract BFD's default vector's byte order. */
659 switch (default_bfd_vec
->byteorder
)
662 default_byte_order
= BFD_ENDIAN_BIG
;
664 case BFD_ENDIAN_LITTLE
:
665 default_byte_order
= BFD_ENDIAN_LITTLE
;
671 if (default_byte_order
== BFD_ENDIAN_UNKNOWN
)
673 /* look for ``*el-*'' in the target name. */
675 chp
= strchr (target_name
, '-');
677 && chp
- 2 >= target_name
678 && startswith (chp
- 2, "el"))
679 default_byte_order
= BFD_ENDIAN_LITTLE
;
681 if (default_byte_order
== BFD_ENDIAN_UNKNOWN
)
683 /* Wire it to big-endian!!! */
684 default_byte_order
= BFD_ENDIAN_BIG
;
687 info
.byte_order
= default_byte_order
;
688 info
.byte_order_for_code
= info
.byte_order
;
690 if (! gdbarch_update_p (info
))
691 internal_error (__FILE__
, __LINE__
,
692 _("initialize_current_architecture: Selection of "
693 "initial architecture failed"));
695 /* Create the ``set architecture'' command appending ``auto'' to the
696 list of architectures. */
698 /* Append ``auto''. */
700 for (nr
= 0; arches
[nr
] != NULL
; nr
++);
701 arches
= XRESIZEVEC (const char *, arches
, nr
+ 2);
702 arches
[nr
+ 0] = "auto";
703 arches
[nr
+ 1] = NULL
;
704 add_setshow_enum_cmd ("architecture", class_support
,
705 arches
, &set_architecture_string
,
706 _("Set architecture of target."),
707 _("Show architecture of target."), NULL
,
708 set_architecture
, show_architecture
,
709 &setlist
, &showlist
);
710 add_alias_cmd ("processor", "architecture", class_support
, 1, &setlist
);
715 /* Initialize a gdbarch info to values that will be automatically
716 overridden. Note: Originally, this ``struct info'' was initialized
717 using memset(0). Unfortunately, that ran into problems, namely
718 BFD_ENDIAN_BIG is zero. An explicit initialization function that
719 can explicitly set each field to a well defined value is used. */
722 gdbarch_info_init (struct gdbarch_info
*info
)
724 memset (info
, 0, sizeof (struct gdbarch_info
));
725 info
->byte_order
= BFD_ENDIAN_UNKNOWN
;
726 info
->byte_order_for_code
= info
->byte_order
;
729 /* Similar to init, but this time fill in the blanks. Information is
730 obtained from the global "set ..." options and explicitly
731 initialized INFO fields. */
734 gdbarch_info_fill (struct gdbarch_info
*info
)
736 /* "(gdb) set architecture ...". */
737 if (info
->bfd_arch_info
== NULL
738 && target_architecture_user
)
739 info
->bfd_arch_info
= target_architecture_user
;
741 if (info
->bfd_arch_info
== NULL
742 && info
->abfd
!= NULL
743 && bfd_get_arch (info
->abfd
) != bfd_arch_unknown
744 && bfd_get_arch (info
->abfd
) != bfd_arch_obscure
)
745 info
->bfd_arch_info
= bfd_get_arch_info (info
->abfd
);
746 /* From the target. */
747 if (info
->target_desc
!= NULL
)
748 info
->bfd_arch_info
= choose_architecture_for_target
749 (info
->target_desc
, info
->bfd_arch_info
);
750 /* From the default. */
751 if (info
->bfd_arch_info
== NULL
)
752 info
->bfd_arch_info
= default_bfd_arch
;
754 /* "(gdb) set byte-order ...". */
755 if (info
->byte_order
== BFD_ENDIAN_UNKNOWN
756 && target_byte_order_user
!= BFD_ENDIAN_UNKNOWN
)
757 info
->byte_order
= target_byte_order_user
;
758 /* From the INFO struct. */
759 if (info
->byte_order
== BFD_ENDIAN_UNKNOWN
760 && info
->abfd
!= NULL
)
761 info
->byte_order
= (bfd_big_endian (info
->abfd
) ? BFD_ENDIAN_BIG
762 : bfd_little_endian (info
->abfd
) ? BFD_ENDIAN_LITTLE
763 : BFD_ENDIAN_UNKNOWN
);
764 /* From the default. */
765 if (info
->byte_order
== BFD_ENDIAN_UNKNOWN
)
766 info
->byte_order
= default_byte_order
;
767 info
->byte_order_for_code
= info
->byte_order
;
768 /* Wire the default to the last selected byte order. */
769 default_byte_order
= info
->byte_order
;
771 /* "(gdb) set osabi ...". Handled by gdbarch_lookup_osabi. */
772 /* From the manual override, or from file. */
773 if (info
->osabi
== GDB_OSABI_UNKNOWN
)
774 info
->osabi
= gdbarch_lookup_osabi (info
->abfd
);
775 /* From the target. */
777 if (info
->osabi
== GDB_OSABI_UNKNOWN
&& info
->target_desc
!= NULL
)
778 info
->osabi
= tdesc_osabi (info
->target_desc
);
779 /* From the configured default. */
780 #ifdef GDB_OSABI_DEFAULT
781 if (info
->osabi
== GDB_OSABI_UNKNOWN
)
782 info
->osabi
= GDB_OSABI_DEFAULT
;
784 /* If we still don't know which osabi to pick, pick none. */
785 if (info
->osabi
== GDB_OSABI_UNKNOWN
)
786 info
->osabi
= GDB_OSABI_NONE
;
788 /* Must have at least filled in the architecture. */
789 gdb_assert (info
->bfd_arch_info
!= NULL
);
792 /* Return "current" architecture. If the target is running, this is
793 the architecture of the selected frame. Otherwise, the "current"
794 architecture defaults to the target architecture.
796 This function should normally be called solely by the command
797 interpreter routines to determine the architecture to execute a
800 get_current_arch (void)
802 if (has_stack_frames ())
803 return get_frame_arch (get_selected_frame (NULL
));
805 return target_gdbarch ();
809 default_has_shared_address_space (struct gdbarch
*gdbarch
)
811 /* Simply say no. In most unix-like targets each inferior/process
812 has its own address space. */
817 default_fast_tracepoint_valid_at (struct gdbarch
*gdbarch
, CORE_ADDR addr
,
820 /* We don't know if maybe the target has some way to do fast
821 tracepoints that doesn't need gdbarch, so always say yes. */
828 default_breakpoint_from_pc (struct gdbarch
*gdbarch
, CORE_ADDR
*pcptr
,
831 int kind
= gdbarch_breakpoint_kind_from_pc (gdbarch
, pcptr
);
833 return gdbarch_sw_breakpoint_from_kind (gdbarch
, kind
, lenptr
);
836 default_breakpoint_kind_from_current_state (struct gdbarch
*gdbarch
,
837 struct regcache
*regcache
,
840 return gdbarch_breakpoint_kind_from_pc (gdbarch
, pcptr
);
845 default_gen_return_address (struct gdbarch
*gdbarch
,
846 struct agent_expr
*ax
, struct axs_value
*value
,
849 error (_("This architecture has no method to collect a return address."));
853 default_return_in_first_hidden_param_p (struct gdbarch
*gdbarch
,
856 /* Usually, the return value's address is stored the in the "first hidden"
857 parameter if the return value should be passed by reference, as
859 return language_pass_by_reference (type
);
862 int default_insn_is_call (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
867 int default_insn_is_ret (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
872 int default_insn_is_jump (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
878 default_skip_permanent_breakpoint (struct regcache
*regcache
)
880 struct gdbarch
*gdbarch
= regcache
->arch ();
881 CORE_ADDR current_pc
= regcache_read_pc (regcache
);
884 gdbarch_breakpoint_from_pc (gdbarch
, ¤t_pc
, &bp_len
);
885 current_pc
+= bp_len
;
886 regcache_write_pc (regcache
, current_pc
);
890 default_infcall_mmap (CORE_ADDR size
, unsigned prot
)
892 error (_("This target does not support inferior memory allocation by mmap."));
896 default_infcall_munmap (CORE_ADDR addr
, CORE_ADDR size
)
898 /* Memory reserved by inferior mmap is kept leaked. */
901 /* -mcmodel=large is used so that no GOT (Global Offset Table) is needed to be
902 created in inferior memory by GDB (normally it is set by ld.so). */
905 default_gcc_target_options (struct gdbarch
*gdbarch
)
907 return xstrprintf ("-m%d%s", gdbarch_ptr_bit (gdbarch
),
908 gdbarch_ptr_bit (gdbarch
) == 64 ? " -mcmodel=large" : "");
911 /* gdbarch gnu_triplet_regexp method. */
914 default_gnu_triplet_regexp (struct gdbarch
*gdbarch
)
916 return gdbarch_bfd_arch_info (gdbarch
)->arch_name
;
919 /* Default method for gdbarch_addressable_memory_unit_size. By default, a memory byte has
920 a size of 1 octet. */
923 default_addressable_memory_unit_size (struct gdbarch
*gdbarch
)
929 default_guess_tracepoint_registers (struct gdbarch
*gdbarch
,
930 struct regcache
*regcache
,
933 int pc_regno
= gdbarch_pc_regnum (gdbarch
);
936 /* This guessing code below only works if the PC register isn't
937 a pseudo-register. The value of a pseudo-register isn't stored
938 in the (non-readonly) regcache -- instead it's recomputed
939 (probably from some other cached raw register) whenever the
940 register is read. In this case, a custom method implementation
941 should be used by the architecture. */
942 if (pc_regno
< 0 || pc_regno
>= gdbarch_num_regs (gdbarch
))
945 regs
= (gdb_byte
*) alloca (register_size (gdbarch
, pc_regno
));
946 store_unsigned_integer (regs
, register_size (gdbarch
, pc_regno
),
947 gdbarch_byte_order (gdbarch
), addr
);
948 regcache
->raw_supply (pc_regno
, regs
);
952 default_print_insn (bfd_vma memaddr
, disassemble_info
*info
)
954 disassembler_ftype disassemble_fn
;
956 disassemble_fn
= disassembler (info
->arch
, info
->endian
== BFD_ENDIAN_BIG
,
957 info
->mach
, exec_bfd
);
959 gdb_assert (disassemble_fn
!= NULL
);
960 return (*disassemble_fn
) (memaddr
, info
);
963 /* See arch-utils.h. */
966 gdbarch_skip_prologue_noexcept (gdbarch
*gdbarch
, CORE_ADDR pc
) noexcept
968 CORE_ADDR new_pc
= pc
;
972 new_pc
= gdbarch_skip_prologue (gdbarch
, pc
);
974 CATCH (ex
, RETURN_MASK_ALL
)
981 /* See arch-utils.h. */
984 default_in_indirect_branch_thunk (gdbarch
*gdbarch
, CORE_ADDR pc
)
989 /* See arch-utils.h. */
992 default_type_align (struct gdbarch
*gdbarch
, struct type
*type
)
998 _initialize_gdbarch_utils (void)
1000 add_setshow_enum_cmd ("endian", class_support
,
1001 endian_enum
, &set_endian_string
,
1002 _("Set endianness of target."),
1003 _("Show endianness of target."),
1004 NULL
, set_endian
, show_endian
,
1005 &setlist
, &showlist
);