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"
41 struct displaced_step_closure
*
42 simple_displaced_step_copy_insn (struct gdbarch
*gdbarch
,
43 CORE_ADDR from
, CORE_ADDR to
,
44 struct regcache
*regs
)
46 size_t len
= gdbarch_max_insn_length (gdbarch
);
47 gdb_byte
*buf
= (gdb_byte
*) xmalloc (len
);
49 read_memory (from
, buf
, len
);
50 write_memory (to
, buf
, len
);
54 fprintf_unfiltered (gdb_stdlog
, "displaced: copy %s->%s: ",
55 paddress (gdbarch
, from
), paddress (gdbarch
, to
));
56 displaced_step_dump_bytes (gdb_stdlog
, buf
, len
);
59 return (struct displaced_step_closure
*) buf
;
64 simple_displaced_step_free_closure (struct gdbarch
*gdbarch
,
65 struct displaced_step_closure
*closure
)
71 default_displaced_step_hw_singlestep (struct gdbarch
*gdbarch
,
72 struct displaced_step_closure
*closure
)
74 return !gdbarch_software_single_step_p (gdbarch
);
78 displaced_step_at_entry_point (struct gdbarch
*gdbarch
)
83 addr
= entry_point_address ();
85 /* Inferior calls also use the entry point as a breakpoint location.
86 We don't want displaced stepping to interfere with those
87 breakpoints, so leave space. */
88 gdbarch_breakpoint_from_pc (gdbarch
, &addr
, &bp_len
);
95 legacy_register_sim_regno (struct gdbarch
*gdbarch
, int regnum
)
97 /* Only makes sense to supply raw registers. */
98 gdb_assert (regnum
>= 0 && regnum
< gdbarch_num_regs (gdbarch
));
99 /* NOTE: cagney/2002-05-13: The old code did it this way and it is
100 suspected that some GDB/SIM combinations may rely on this
101 behavour. The default should be one2one_register_sim_regno
103 if (gdbarch_register_name (gdbarch
, regnum
) != NULL
104 && gdbarch_register_name (gdbarch
, regnum
)[0] != '\0')
107 return LEGACY_SIM_REGNO_IGNORE
;
111 generic_skip_trampoline_code (struct frame_info
*frame
, CORE_ADDR pc
)
117 generic_skip_solib_resolver (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
123 generic_in_solib_return_trampoline (struct gdbarch
*gdbarch
,
124 CORE_ADDR pc
, const char *name
)
130 generic_stack_frame_destroyed_p (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
136 default_code_of_frame_writable (struct gdbarch
*gdbarch
,
137 struct frame_info
*frame
)
142 /* Helper functions for gdbarch_inner_than */
145 core_addr_lessthan (CORE_ADDR lhs
, CORE_ADDR rhs
)
151 core_addr_greaterthan (CORE_ADDR lhs
, CORE_ADDR rhs
)
156 /* Misc helper functions for targets. */
159 core_addr_identity (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
165 convert_from_func_ptr_addr_identity (struct gdbarch
*gdbarch
, CORE_ADDR addr
,
166 struct target_ops
*targ
)
172 no_op_reg_to_regnum (struct gdbarch
*gdbarch
, int reg
)
178 default_coff_make_msymbol_special (int val
, struct minimal_symbol
*msym
)
183 /* See arch-utils.h. */
186 default_make_symbol_special (struct symbol
*sym
, struct objfile
*objfile
)
191 /* See arch-utils.h. */
194 default_adjust_dwarf2_addr (CORE_ADDR pc
)
199 /* See arch-utils.h. */
202 default_adjust_dwarf2_line (CORE_ADDR addr
, int rel
)
207 /* See arch-utils.h. */
210 default_execute_dwarf_cfa_vendor_op (struct gdbarch
*gdbarch
, gdb_byte op
,
211 struct dwarf2_frame_state
*fs
)
217 cannot_register_not (struct gdbarch
*gdbarch
, int regnum
)
222 /* Legacy version of target_virtual_frame_pointer(). Assumes that
223 there is an gdbarch_deprecated_fp_regnum and that it is the same,
227 legacy_virtual_frame_pointer (struct gdbarch
*gdbarch
,
230 LONGEST
*frame_offset
)
232 /* FIXME: cagney/2002-09-13: This code is used when identifying the
233 frame pointer of the current PC. It is assuming that a single
234 register and an offset can determine this. I think it should
235 instead generate a byte code expression as that would work better
236 with things like Dwarf2's CFI. */
237 if (gdbarch_deprecated_fp_regnum (gdbarch
) >= 0
238 && gdbarch_deprecated_fp_regnum (gdbarch
)
239 < gdbarch_num_regs (gdbarch
))
240 *frame_regnum
= gdbarch_deprecated_fp_regnum (gdbarch
);
241 else if (gdbarch_sp_regnum (gdbarch
) >= 0
242 && gdbarch_sp_regnum (gdbarch
)
243 < gdbarch_num_regs (gdbarch
))
244 *frame_regnum
= gdbarch_sp_regnum (gdbarch
);
246 /* Should this be an internal error? I guess so, it is reflecting
247 an architectural limitation in the current design. */
248 internal_error (__FILE__
, __LINE__
,
249 _("No virtual frame pointer available"));
253 /* Return a floating-point format for a floating-point variable of
254 length LEN in bits. If non-NULL, NAME is the name of its type.
255 If no suitable type is found, return NULL. */
257 const struct floatformat
**
258 default_floatformat_for_type (struct gdbarch
*gdbarch
,
259 const char *name
, int len
)
261 const struct floatformat
**format
= NULL
;
263 if (len
== gdbarch_half_bit (gdbarch
))
264 format
= gdbarch_half_format (gdbarch
);
265 else if (len
== gdbarch_float_bit (gdbarch
))
266 format
= gdbarch_float_format (gdbarch
);
267 else if (len
== gdbarch_double_bit (gdbarch
))
268 format
= gdbarch_double_format (gdbarch
);
269 else if (len
== gdbarch_long_double_bit (gdbarch
))
270 format
= gdbarch_long_double_format (gdbarch
);
271 /* On i386 the 'long double' type takes 96 bits,
272 while the real number of used bits is only 80,
273 both in processor and in memory.
274 The code below accepts the real bit size. */
275 else if (gdbarch_long_double_format (gdbarch
) != NULL
276 && len
== gdbarch_long_double_format (gdbarch
)[0]->totalsize
)
277 format
= gdbarch_long_double_format (gdbarch
);
283 generic_convert_register_p (struct gdbarch
*gdbarch
, int regnum
,
290 default_stabs_argument_has_addr (struct gdbarch
*gdbarch
, struct type
*type
)
296 generic_instruction_nullified (struct gdbarch
*gdbarch
,
297 struct regcache
*regcache
)
303 default_remote_register_number (struct gdbarch
*gdbarch
,
309 /* See arch-utils.h. */
312 default_vsyscall_range (struct gdbarch
*gdbarch
, struct mem_range
*range
)
318 /* Functions to manipulate the endianness of the target. */
320 static enum bfd_endian target_byte_order_user
= BFD_ENDIAN_UNKNOWN
;
322 static const char endian_big
[] = "big";
323 static const char endian_little
[] = "little";
324 static const char endian_auto
[] = "auto";
325 static const char *const endian_enum
[] =
332 static const char *set_endian_string
;
335 selected_byte_order (void)
337 return target_byte_order_user
;
340 /* Called by ``show endian''. */
343 show_endian (struct ui_file
*file
, int from_tty
, struct cmd_list_element
*c
,
346 if (target_byte_order_user
== BFD_ENDIAN_UNKNOWN
)
347 if (gdbarch_byte_order (get_current_arch ()) == BFD_ENDIAN_BIG
)
348 fprintf_unfiltered (file
, _("The target endianness is set automatically "
349 "(currently big endian)\n"));
351 fprintf_unfiltered (file
, _("The target endianness is set automatically "
352 "(currently little endian)\n"));
354 if (target_byte_order_user
== BFD_ENDIAN_BIG
)
355 fprintf_unfiltered (file
,
356 _("The target is assumed to be big endian\n"));
358 fprintf_unfiltered (file
,
359 _("The target is assumed to be little endian\n"));
363 set_endian (char *ignore_args
, int from_tty
, struct cmd_list_element
*c
)
365 struct gdbarch_info info
;
367 gdbarch_info_init (&info
);
369 if (set_endian_string
== endian_auto
)
371 target_byte_order_user
= BFD_ENDIAN_UNKNOWN
;
372 if (! gdbarch_update_p (info
))
373 internal_error (__FILE__
, __LINE__
,
374 _("set_endian: architecture update failed"));
376 else if (set_endian_string
== endian_little
)
378 info
.byte_order
= BFD_ENDIAN_LITTLE
;
379 if (! gdbarch_update_p (info
))
380 printf_unfiltered (_("Little endian target not supported by GDB\n"));
382 target_byte_order_user
= BFD_ENDIAN_LITTLE
;
384 else if (set_endian_string
== endian_big
)
386 info
.byte_order
= BFD_ENDIAN_BIG
;
387 if (! gdbarch_update_p (info
))
388 printf_unfiltered (_("Big endian target not supported by GDB\n"));
390 target_byte_order_user
= BFD_ENDIAN_BIG
;
393 internal_error (__FILE__
, __LINE__
,
394 _("set_endian: bad value"));
396 show_endian (gdb_stdout
, from_tty
, NULL
, NULL
);
399 /* Given SELECTED, a currently selected BFD architecture, and
400 TARGET_DESC, the current target description, return what
403 SELECTED may be NULL, in which case we return the architecture
404 associated with TARGET_DESC. If SELECTED specifies a variant
405 of the architecture associtated with TARGET_DESC, return the
406 more specific of the two.
408 If SELECTED is a different architecture, but it is accepted as
409 compatible by the target, we can use the target architecture.
411 If SELECTED is obviously incompatible, warn the user. */
413 static const struct bfd_arch_info
*
414 choose_architecture_for_target (const struct target_desc
*target_desc
,
415 const struct bfd_arch_info
*selected
)
417 const struct bfd_arch_info
*from_target
= tdesc_architecture (target_desc
);
418 const struct bfd_arch_info
*compat1
, *compat2
;
420 if (selected
== NULL
)
423 if (from_target
== NULL
)
426 /* struct bfd_arch_info objects are singletons: that is, there's
427 supposed to be exactly one instance for a given machine. So you
428 can tell whether two are equivalent by comparing pointers. */
429 if (from_target
== selected
)
432 /* BFD's 'A->compatible (A, B)' functions return zero if A and B are
433 incompatible. But if they are compatible, it returns the 'more
434 featureful' of the two arches. That is, if A can run code
435 written for B, but B can't run code written for A, then it'll
438 Some targets (e.g. MIPS as of 2006-12-04) don't fully
439 implement this, instead always returning NULL or the first
440 argument. We detect that case by checking both directions. */
442 compat1
= selected
->compatible (selected
, from_target
);
443 compat2
= from_target
->compatible (from_target
, selected
);
445 if (compat1
== NULL
&& compat2
== NULL
)
447 /* BFD considers the architectures incompatible. Check our
448 target description whether it accepts SELECTED as compatible
450 if (tdesc_compatible_p (target_desc
, selected
))
453 warning (_("Selected architecture %s is not compatible "
454 "with reported target architecture %s"),
455 selected
->printable_name
, from_target
->printable_name
);
463 if (compat1
== compat2
)
466 /* If the two didn't match, but one of them was a default
467 architecture, assume the more specific one is correct. This
468 handles the case where an executable or target description just
469 says "mips", but the other knows which MIPS variant. */
470 if (compat1
->the_default
)
472 if (compat2
->the_default
)
475 /* We have no idea which one is better. This is a bug, but not
476 a critical problem; warn the user. */
477 warning (_("Selected architecture %s is ambiguous with "
478 "reported target architecture %s"),
479 selected
->printable_name
, from_target
->printable_name
);
483 /* Functions to manipulate the architecture of the target. */
485 enum set_arch
{ set_arch_auto
, set_arch_manual
};
487 static const struct bfd_arch_info
*target_architecture_user
;
489 static const char *set_architecture_string
;
492 selected_architecture_name (void)
494 if (target_architecture_user
== NULL
)
497 return set_architecture_string
;
500 /* Called if the user enters ``show architecture'' without an
504 show_architecture (struct ui_file
*file
, int from_tty
,
505 struct cmd_list_element
*c
, const char *value
)
507 if (target_architecture_user
== NULL
)
508 fprintf_filtered (file
, _("The target architecture is set "
509 "automatically (currently %s)\n"),
510 gdbarch_bfd_arch_info (get_current_arch ())->printable_name
);
512 fprintf_filtered (file
, _("The target architecture is assumed to be %s\n"),
513 set_architecture_string
);
517 /* Called if the user enters ``set architecture'' with or without an
521 set_architecture (char *ignore_args
, int from_tty
, struct cmd_list_element
*c
)
523 struct gdbarch_info info
;
525 gdbarch_info_init (&info
);
527 if (strcmp (set_architecture_string
, "auto") == 0)
529 target_architecture_user
= NULL
;
530 if (!gdbarch_update_p (info
))
531 internal_error (__FILE__
, __LINE__
,
532 _("could not select an architecture automatically"));
536 info
.bfd_arch_info
= bfd_scan_arch (set_architecture_string
);
537 if (info
.bfd_arch_info
== NULL
)
538 internal_error (__FILE__
, __LINE__
,
539 _("set_architecture: bfd_scan_arch failed"));
540 if (gdbarch_update_p (info
))
541 target_architecture_user
= info
.bfd_arch_info
;
543 printf_unfiltered (_("Architecture `%s' not recognized.\n"),
544 set_architecture_string
);
546 show_architecture (gdb_stdout
, from_tty
, NULL
, NULL
);
549 /* Try to select a global architecture that matches "info". Return
550 non-zero if the attempt succeeds. */
552 gdbarch_update_p (struct gdbarch_info info
)
554 struct gdbarch
*new_gdbarch
;
556 /* Check for the current file. */
557 if (info
.abfd
== NULL
)
558 info
.abfd
= exec_bfd
;
559 if (info
.abfd
== NULL
)
560 info
.abfd
= core_bfd
;
562 /* Check for the current target description. */
563 if (info
.target_desc
== NULL
)
564 info
.target_desc
= target_current_description ();
566 new_gdbarch
= gdbarch_find_by_info (info
);
568 /* If there no architecture by that name, reject the request. */
569 if (new_gdbarch
== NULL
)
572 fprintf_unfiltered (gdb_stdlog
, "gdbarch_update_p: "
573 "Architecture not found\n");
577 /* If it is the same old architecture, accept the request (but don't
579 if (new_gdbarch
== target_gdbarch ())
582 fprintf_unfiltered (gdb_stdlog
, "gdbarch_update_p: "
583 "Architecture %s (%s) unchanged\n",
584 host_address_to_string (new_gdbarch
),
585 gdbarch_bfd_arch_info (new_gdbarch
)->printable_name
);
589 /* It's a new architecture, swap it in. */
591 fprintf_unfiltered (gdb_stdlog
, "gdbarch_update_p: "
592 "New architecture %s (%s) selected\n",
593 host_address_to_string (new_gdbarch
),
594 gdbarch_bfd_arch_info (new_gdbarch
)->printable_name
);
595 set_target_gdbarch (new_gdbarch
);
600 /* Return the architecture for ABFD. If no suitable architecture
601 could be find, return NULL. */
604 gdbarch_from_bfd (bfd
*abfd
)
606 struct gdbarch_info info
;
607 gdbarch_info_init (&info
);
610 return gdbarch_find_by_info (info
);
613 /* Set the dynamic target-system-dependent parameters (architecture,
614 byte-order) using information found in the BFD */
617 set_gdbarch_from_file (bfd
*abfd
)
619 struct gdbarch_info info
;
620 struct gdbarch
*gdbarch
;
622 gdbarch_info_init (&info
);
624 info
.target_desc
= target_current_description ();
625 gdbarch
= gdbarch_find_by_info (info
);
628 error (_("Architecture of file not recognized."));
629 set_target_gdbarch (gdbarch
);
632 /* Initialize the current architecture. Update the ``set
633 architecture'' command so that it specifies a list of valid
636 #ifdef DEFAULT_BFD_ARCH
637 extern const bfd_arch_info_type DEFAULT_BFD_ARCH
;
638 static const bfd_arch_info_type
*default_bfd_arch
= &DEFAULT_BFD_ARCH
;
640 static const bfd_arch_info_type
*default_bfd_arch
;
643 #ifdef DEFAULT_BFD_VEC
644 extern const bfd_target DEFAULT_BFD_VEC
;
645 static const bfd_target
*default_bfd_vec
= &DEFAULT_BFD_VEC
;
647 static const bfd_target
*default_bfd_vec
;
650 static enum bfd_endian default_byte_order
= BFD_ENDIAN_UNKNOWN
;
653 initialize_current_architecture (void)
655 const char **arches
= gdbarch_printable_names ();
656 struct gdbarch_info info
;
658 /* determine a default architecture and byte order. */
659 gdbarch_info_init (&info
);
661 /* Find a default architecture. */
662 if (default_bfd_arch
== NULL
)
664 /* Choose the architecture by taking the first one
666 const char *chosen
= arches
[0];
668 for (arch
= arches
; *arch
!= NULL
; arch
++)
670 if (strcmp (*arch
, chosen
) < 0)
674 internal_error (__FILE__
, __LINE__
,
675 _("initialize_current_architecture: No arch"));
676 default_bfd_arch
= bfd_scan_arch (chosen
);
677 if (default_bfd_arch
== NULL
)
678 internal_error (__FILE__
, __LINE__
,
679 _("initialize_current_architecture: Arch not found"));
682 info
.bfd_arch_info
= default_bfd_arch
;
684 /* Take several guesses at a byte order. */
685 if (default_byte_order
== BFD_ENDIAN_UNKNOWN
686 && default_bfd_vec
!= NULL
)
688 /* Extract BFD's default vector's byte order. */
689 switch (default_bfd_vec
->byteorder
)
692 default_byte_order
= BFD_ENDIAN_BIG
;
694 case BFD_ENDIAN_LITTLE
:
695 default_byte_order
= BFD_ENDIAN_LITTLE
;
701 if (default_byte_order
== BFD_ENDIAN_UNKNOWN
)
703 /* look for ``*el-*'' in the target name. */
705 chp
= strchr (target_name
, '-');
707 && chp
- 2 >= target_name
708 && startswith (chp
- 2, "el"))
709 default_byte_order
= BFD_ENDIAN_LITTLE
;
711 if (default_byte_order
== BFD_ENDIAN_UNKNOWN
)
713 /* Wire it to big-endian!!! */
714 default_byte_order
= BFD_ENDIAN_BIG
;
717 info
.byte_order
= default_byte_order
;
718 info
.byte_order_for_code
= info
.byte_order
;
720 if (! gdbarch_update_p (info
))
721 internal_error (__FILE__
, __LINE__
,
722 _("initialize_current_architecture: Selection of "
723 "initial architecture failed"));
725 /* Create the ``set architecture'' command appending ``auto'' to the
726 list of architectures. */
728 /* Append ``auto''. */
730 for (nr
= 0; arches
[nr
] != NULL
; nr
++);
731 arches
= XRESIZEVEC (const char *, arches
, nr
+ 2);
732 arches
[nr
+ 0] = "auto";
733 arches
[nr
+ 1] = NULL
;
734 add_setshow_enum_cmd ("architecture", class_support
,
735 arches
, &set_architecture_string
,
736 _("Set architecture of target."),
737 _("Show architecture of target."), NULL
,
738 set_architecture
, show_architecture
,
739 &setlist
, &showlist
);
740 add_alias_cmd ("processor", "architecture", class_support
, 1, &setlist
);
745 /* Initialize a gdbarch info to values that will be automatically
746 overridden. Note: Originally, this ``struct info'' was initialized
747 using memset(0). Unfortunately, that ran into problems, namely
748 BFD_ENDIAN_BIG is zero. An explicit initialization function that
749 can explicitly set each field to a well defined value is used. */
752 gdbarch_info_init (struct gdbarch_info
*info
)
754 memset (info
, 0, sizeof (struct gdbarch_info
));
755 info
->byte_order
= BFD_ENDIAN_UNKNOWN
;
756 info
->byte_order_for_code
= info
->byte_order
;
757 info
->osabi
= GDB_OSABI_UNINITIALIZED
;
760 /* Similar to init, but this time fill in the blanks. Information is
761 obtained from the global "set ..." options and explicitly
762 initialized INFO fields. */
765 gdbarch_info_fill (struct gdbarch_info
*info
)
767 /* "(gdb) set architecture ...". */
768 if (info
->bfd_arch_info
== NULL
769 && target_architecture_user
)
770 info
->bfd_arch_info
= target_architecture_user
;
772 if (info
->bfd_arch_info
== NULL
773 && info
->abfd
!= NULL
774 && bfd_get_arch (info
->abfd
) != bfd_arch_unknown
775 && bfd_get_arch (info
->abfd
) != bfd_arch_obscure
)
776 info
->bfd_arch_info
= bfd_get_arch_info (info
->abfd
);
777 /* From the target. */
778 if (info
->target_desc
!= NULL
)
779 info
->bfd_arch_info
= choose_architecture_for_target
780 (info
->target_desc
, info
->bfd_arch_info
);
781 /* From the default. */
782 if (info
->bfd_arch_info
== NULL
)
783 info
->bfd_arch_info
= default_bfd_arch
;
785 /* "(gdb) set byte-order ...". */
786 if (info
->byte_order
== BFD_ENDIAN_UNKNOWN
787 && target_byte_order_user
!= BFD_ENDIAN_UNKNOWN
)
788 info
->byte_order
= target_byte_order_user
;
789 /* From the INFO struct. */
790 if (info
->byte_order
== BFD_ENDIAN_UNKNOWN
791 && info
->abfd
!= NULL
)
792 info
->byte_order
= (bfd_big_endian (info
->abfd
) ? BFD_ENDIAN_BIG
793 : bfd_little_endian (info
->abfd
) ? BFD_ENDIAN_LITTLE
794 : BFD_ENDIAN_UNKNOWN
);
795 /* From the default. */
796 if (info
->byte_order
== BFD_ENDIAN_UNKNOWN
)
797 info
->byte_order
= default_byte_order
;
798 info
->byte_order_for_code
= info
->byte_order
;
800 /* "(gdb) set osabi ...". Handled by gdbarch_lookup_osabi. */
801 /* From the manual override, or from file. */
802 if (info
->osabi
== GDB_OSABI_UNINITIALIZED
)
803 info
->osabi
= gdbarch_lookup_osabi (info
->abfd
);
804 /* From the target. */
805 if (info
->osabi
== GDB_OSABI_UNKNOWN
&& info
->target_desc
!= NULL
)
806 info
->osabi
= tdesc_osabi (info
->target_desc
);
807 /* From the configured default. */
808 #ifdef GDB_OSABI_DEFAULT
809 if (info
->osabi
== GDB_OSABI_UNKNOWN
)
810 info
->osabi
= GDB_OSABI_DEFAULT
;
813 /* Must have at least filled in the architecture. */
814 gdb_assert (info
->bfd_arch_info
!= NULL
);
817 /* Return "current" architecture. If the target is running, this is
818 the architecture of the selected frame. Otherwise, the "current"
819 architecture defaults to the target architecture.
821 This function should normally be called solely by the command
822 interpreter routines to determine the architecture to execute a
825 get_current_arch (void)
827 if (has_stack_frames ())
828 return get_frame_arch (get_selected_frame (NULL
));
830 return target_gdbarch ();
834 default_has_shared_address_space (struct gdbarch
*gdbarch
)
836 /* Simply say no. In most unix-like targets each inferior/process
837 has its own address space. */
842 default_fast_tracepoint_valid_at (struct gdbarch
*gdbarch
, CORE_ADDR addr
,
845 /* We don't know if maybe the target has some way to do fast
846 tracepoints that doesn't need gdbarch, so always say yes. */
853 default_breakpoint_from_pc (struct gdbarch
*gdbarch
, CORE_ADDR
*pcptr
,
856 int kind
= gdbarch_breakpoint_kind_from_pc (gdbarch
, pcptr
);
858 return gdbarch_sw_breakpoint_from_kind (gdbarch
, kind
, lenptr
);
861 default_breakpoint_kind_from_current_state (struct gdbarch
*gdbarch
,
862 struct regcache
*regcache
,
865 return gdbarch_breakpoint_kind_from_pc (gdbarch
, pcptr
);
870 default_gen_return_address (struct gdbarch
*gdbarch
,
871 struct agent_expr
*ax
, struct axs_value
*value
,
874 error (_("This architecture has no method to collect a return address."));
878 default_return_in_first_hidden_param_p (struct gdbarch
*gdbarch
,
881 /* Usually, the return value's address is stored the in the "first hidden"
882 parameter if the return value should be passed by reference, as
884 return language_pass_by_reference (type
);
887 int default_insn_is_call (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
892 int default_insn_is_ret (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
897 int default_insn_is_jump (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
903 default_skip_permanent_breakpoint (struct regcache
*regcache
)
905 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
906 CORE_ADDR current_pc
= regcache_read_pc (regcache
);
909 gdbarch_breakpoint_from_pc (gdbarch
, ¤t_pc
, &bp_len
);
910 current_pc
+= bp_len
;
911 regcache_write_pc (regcache
, current_pc
);
915 default_infcall_mmap (CORE_ADDR size
, unsigned prot
)
917 error (_("This target does not support inferior memory allocation by mmap."));
921 default_infcall_munmap (CORE_ADDR addr
, CORE_ADDR size
)
923 /* Memory reserved by inferior mmap is kept leaked. */
926 /* -mcmodel=large is used so that no GOT (Global Offset Table) is needed to be
927 created in inferior memory by GDB (normally it is set by ld.so). */
930 default_gcc_target_options (struct gdbarch
*gdbarch
)
932 return xstrprintf ("-m%d%s", gdbarch_ptr_bit (gdbarch
),
933 gdbarch_ptr_bit (gdbarch
) == 64 ? " -mcmodel=large" : "");
936 /* gdbarch gnu_triplet_regexp method. */
939 default_gnu_triplet_regexp (struct gdbarch
*gdbarch
)
941 return gdbarch_bfd_arch_info (gdbarch
)->arch_name
;
944 /* Default method for gdbarch_addressable_memory_unit_size. By default, a memory byte has
945 a size of 1 octet. */
948 default_addressable_memory_unit_size (struct gdbarch
*gdbarch
)
954 default_guess_tracepoint_registers (struct gdbarch
*gdbarch
,
955 struct regcache
*regcache
,
958 int pc_regno
= gdbarch_pc_regnum (gdbarch
);
961 /* This guessing code below only works if the PC register isn't
962 a pseudo-register. The value of a pseudo-register isn't stored
963 in the (non-readonly) regcache -- instead it's recomputed
964 (probably from some other cached raw register) whenever the
965 register is read. In this case, a custom method implementation
966 should be used by the architecture. */
967 if (pc_regno
< 0 || pc_regno
>= gdbarch_num_regs (gdbarch
))
970 regs
= (gdb_byte
*) alloca (register_size (gdbarch
, pc_regno
));
971 store_unsigned_integer (regs
, register_size (gdbarch
, pc_regno
),
972 gdbarch_byte_order (gdbarch
), addr
);
973 regcache_raw_supply (regcache
, pc_regno
, regs
);
976 /* -Wmissing-prototypes */
977 extern initialize_file_ftype _initialize_gdbarch_utils
;
980 _initialize_gdbarch_utils (void)
982 add_setshow_enum_cmd ("endian", class_support
,
983 endian_enum
, &set_endian_string
,
984 _("Set endianness of target."),
985 _("Show endianness of target."),
986 NULL
, set_endian
, show_endian
,
987 &setlist
, &showlist
);