1 /* Dynamic architecture support for GDB, the GNU debugger.
3 Copyright (C) 1998-2016 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
)
208 cannot_register_not (struct gdbarch
*gdbarch
, int regnum
)
213 /* Legacy version of target_virtual_frame_pointer(). Assumes that
214 there is an gdbarch_deprecated_fp_regnum and that it is the same,
218 legacy_virtual_frame_pointer (struct gdbarch
*gdbarch
,
221 LONGEST
*frame_offset
)
223 /* FIXME: cagney/2002-09-13: This code is used when identifying the
224 frame pointer of the current PC. It is assuming that a single
225 register and an offset can determine this. I think it should
226 instead generate a byte code expression as that would work better
227 with things like Dwarf2's CFI. */
228 if (gdbarch_deprecated_fp_regnum (gdbarch
) >= 0
229 && gdbarch_deprecated_fp_regnum (gdbarch
)
230 < gdbarch_num_regs (gdbarch
))
231 *frame_regnum
= gdbarch_deprecated_fp_regnum (gdbarch
);
232 else if (gdbarch_sp_regnum (gdbarch
) >= 0
233 && gdbarch_sp_regnum (gdbarch
)
234 < gdbarch_num_regs (gdbarch
))
235 *frame_regnum
= gdbarch_sp_regnum (gdbarch
);
237 /* Should this be an internal error? I guess so, it is reflecting
238 an architectural limitation in the current design. */
239 internal_error (__FILE__
, __LINE__
,
240 _("No virtual frame pointer available"));
246 generic_convert_register_p (struct gdbarch
*gdbarch
, int regnum
,
253 default_stabs_argument_has_addr (struct gdbarch
*gdbarch
, struct type
*type
)
259 generic_instruction_nullified (struct gdbarch
*gdbarch
,
260 struct regcache
*regcache
)
266 default_remote_register_number (struct gdbarch
*gdbarch
,
272 /* See arch-utils.h. */
275 default_vsyscall_range (struct gdbarch
*gdbarch
, struct mem_range
*range
)
281 /* Functions to manipulate the endianness of the target. */
283 static enum bfd_endian target_byte_order_user
= BFD_ENDIAN_UNKNOWN
;
285 static const char endian_big
[] = "big";
286 static const char endian_little
[] = "little";
287 static const char endian_auto
[] = "auto";
288 static const char *const endian_enum
[] =
295 static const char *set_endian_string
;
298 selected_byte_order (void)
300 return target_byte_order_user
;
303 /* Called by ``show endian''. */
306 show_endian (struct ui_file
*file
, int from_tty
, struct cmd_list_element
*c
,
309 if (target_byte_order_user
== BFD_ENDIAN_UNKNOWN
)
310 if (gdbarch_byte_order (get_current_arch ()) == BFD_ENDIAN_BIG
)
311 fprintf_unfiltered (file
, _("The target endianness is set automatically "
312 "(currently big endian)\n"));
314 fprintf_unfiltered (file
, _("The target endianness is set automatically "
315 "(currently little endian)\n"));
317 if (target_byte_order_user
== BFD_ENDIAN_BIG
)
318 fprintf_unfiltered (file
,
319 _("The target is assumed to be big endian\n"));
321 fprintf_unfiltered (file
,
322 _("The target is assumed to be little endian\n"));
326 set_endian (char *ignore_args
, int from_tty
, struct cmd_list_element
*c
)
328 struct gdbarch_info info
;
330 gdbarch_info_init (&info
);
332 if (set_endian_string
== endian_auto
)
334 target_byte_order_user
= BFD_ENDIAN_UNKNOWN
;
335 if (! gdbarch_update_p (info
))
336 internal_error (__FILE__
, __LINE__
,
337 _("set_endian: architecture update failed"));
339 else if (set_endian_string
== endian_little
)
341 info
.byte_order
= BFD_ENDIAN_LITTLE
;
342 if (! gdbarch_update_p (info
))
343 printf_unfiltered (_("Little endian target not supported by GDB\n"));
345 target_byte_order_user
= BFD_ENDIAN_LITTLE
;
347 else if (set_endian_string
== endian_big
)
349 info
.byte_order
= BFD_ENDIAN_BIG
;
350 if (! gdbarch_update_p (info
))
351 printf_unfiltered (_("Big endian target not supported by GDB\n"));
353 target_byte_order_user
= BFD_ENDIAN_BIG
;
356 internal_error (__FILE__
, __LINE__
,
357 _("set_endian: bad value"));
359 show_endian (gdb_stdout
, from_tty
, NULL
, NULL
);
362 /* Given SELECTED, a currently selected BFD architecture, and
363 TARGET_DESC, the current target description, return what
366 SELECTED may be NULL, in which case we return the architecture
367 associated with TARGET_DESC. If SELECTED specifies a variant
368 of the architecture associtated with TARGET_DESC, return the
369 more specific of the two.
371 If SELECTED is a different architecture, but it is accepted as
372 compatible by the target, we can use the target architecture.
374 If SELECTED is obviously incompatible, warn the user. */
376 static const struct bfd_arch_info
*
377 choose_architecture_for_target (const struct target_desc
*target_desc
,
378 const struct bfd_arch_info
*selected
)
380 const struct bfd_arch_info
*from_target
= tdesc_architecture (target_desc
);
381 const struct bfd_arch_info
*compat1
, *compat2
;
383 if (selected
== NULL
)
386 if (from_target
== NULL
)
389 /* struct bfd_arch_info objects are singletons: that is, there's
390 supposed to be exactly one instance for a given machine. So you
391 can tell whether two are equivalent by comparing pointers. */
392 if (from_target
== selected
)
395 /* BFD's 'A->compatible (A, B)' functions return zero if A and B are
396 incompatible. But if they are compatible, it returns the 'more
397 featureful' of the two arches. That is, if A can run code
398 written for B, but B can't run code written for A, then it'll
401 Some targets (e.g. MIPS as of 2006-12-04) don't fully
402 implement this, instead always returning NULL or the first
403 argument. We detect that case by checking both directions. */
405 compat1
= selected
->compatible (selected
, from_target
);
406 compat2
= from_target
->compatible (from_target
, selected
);
408 if (compat1
== NULL
&& compat2
== NULL
)
410 /* BFD considers the architectures incompatible. Check our
411 target description whether it accepts SELECTED as compatible
413 if (tdesc_compatible_p (target_desc
, selected
))
416 warning (_("Selected architecture %s is not compatible "
417 "with reported target architecture %s"),
418 selected
->printable_name
, from_target
->printable_name
);
426 if (compat1
== compat2
)
429 /* If the two didn't match, but one of them was a default
430 architecture, assume the more specific one is correct. This
431 handles the case where an executable or target description just
432 says "mips", but the other knows which MIPS variant. */
433 if (compat1
->the_default
)
435 if (compat2
->the_default
)
438 /* We have no idea which one is better. This is a bug, but not
439 a critical problem; warn the user. */
440 warning (_("Selected architecture %s is ambiguous with "
441 "reported target architecture %s"),
442 selected
->printable_name
, from_target
->printable_name
);
446 /* Functions to manipulate the architecture of the target. */
448 enum set_arch
{ set_arch_auto
, set_arch_manual
};
450 static const struct bfd_arch_info
*target_architecture_user
;
452 static const char *set_architecture_string
;
455 selected_architecture_name (void)
457 if (target_architecture_user
== NULL
)
460 return set_architecture_string
;
463 /* Called if the user enters ``show architecture'' without an
467 show_architecture (struct ui_file
*file
, int from_tty
,
468 struct cmd_list_element
*c
, const char *value
)
470 if (target_architecture_user
== NULL
)
471 fprintf_filtered (file
, _("The target architecture is set "
472 "automatically (currently %s)\n"),
473 gdbarch_bfd_arch_info (get_current_arch ())->printable_name
);
475 fprintf_filtered (file
, _("The target architecture is assumed to be %s\n"),
476 set_architecture_string
);
480 /* Called if the user enters ``set architecture'' with or without an
484 set_architecture (char *ignore_args
, int from_tty
, struct cmd_list_element
*c
)
486 struct gdbarch_info info
;
488 gdbarch_info_init (&info
);
490 if (strcmp (set_architecture_string
, "auto") == 0)
492 target_architecture_user
= NULL
;
493 if (!gdbarch_update_p (info
))
494 internal_error (__FILE__
, __LINE__
,
495 _("could not select an architecture automatically"));
499 info
.bfd_arch_info
= bfd_scan_arch (set_architecture_string
);
500 if (info
.bfd_arch_info
== NULL
)
501 internal_error (__FILE__
, __LINE__
,
502 _("set_architecture: bfd_scan_arch failed"));
503 if (gdbarch_update_p (info
))
504 target_architecture_user
= info
.bfd_arch_info
;
506 printf_unfiltered (_("Architecture `%s' not recognized.\n"),
507 set_architecture_string
);
509 show_architecture (gdb_stdout
, from_tty
, NULL
, NULL
);
512 /* Try to select a global architecture that matches "info". Return
513 non-zero if the attempt succeeds. */
515 gdbarch_update_p (struct gdbarch_info info
)
517 struct gdbarch
*new_gdbarch
;
519 /* Check for the current file. */
520 if (info
.abfd
== NULL
)
521 info
.abfd
= exec_bfd
;
522 if (info
.abfd
== NULL
)
523 info
.abfd
= core_bfd
;
525 /* Check for the current target description. */
526 if (info
.target_desc
== NULL
)
527 info
.target_desc
= target_current_description ();
529 new_gdbarch
= gdbarch_find_by_info (info
);
531 /* If there no architecture by that name, reject the request. */
532 if (new_gdbarch
== NULL
)
535 fprintf_unfiltered (gdb_stdlog
, "gdbarch_update_p: "
536 "Architecture not found\n");
540 /* If it is the same old architecture, accept the request (but don't
542 if (new_gdbarch
== target_gdbarch ())
545 fprintf_unfiltered (gdb_stdlog
, "gdbarch_update_p: "
546 "Architecture %s (%s) unchanged\n",
547 host_address_to_string (new_gdbarch
),
548 gdbarch_bfd_arch_info (new_gdbarch
)->printable_name
);
552 /* It's a new architecture, swap it in. */
554 fprintf_unfiltered (gdb_stdlog
, "gdbarch_update_p: "
555 "New architecture %s (%s) selected\n",
556 host_address_to_string (new_gdbarch
),
557 gdbarch_bfd_arch_info (new_gdbarch
)->printable_name
);
558 set_target_gdbarch (new_gdbarch
);
563 /* Return the architecture for ABFD. If no suitable architecture
564 could be find, return NULL. */
567 gdbarch_from_bfd (bfd
*abfd
)
569 struct gdbarch_info info
;
570 gdbarch_info_init (&info
);
573 return gdbarch_find_by_info (info
);
576 /* Set the dynamic target-system-dependent parameters (architecture,
577 byte-order) using information found in the BFD */
580 set_gdbarch_from_file (bfd
*abfd
)
582 struct gdbarch_info info
;
583 struct gdbarch
*gdbarch
;
585 gdbarch_info_init (&info
);
587 info
.target_desc
= target_current_description ();
588 gdbarch
= gdbarch_find_by_info (info
);
591 error (_("Architecture of file not recognized."));
592 set_target_gdbarch (gdbarch
);
595 /* Initialize the current architecture. Update the ``set
596 architecture'' command so that it specifies a list of valid
599 #ifdef DEFAULT_BFD_ARCH
600 extern const bfd_arch_info_type DEFAULT_BFD_ARCH
;
601 static const bfd_arch_info_type
*default_bfd_arch
= &DEFAULT_BFD_ARCH
;
603 static const bfd_arch_info_type
*default_bfd_arch
;
606 #ifdef DEFAULT_BFD_VEC
607 extern const bfd_target DEFAULT_BFD_VEC
;
608 static const bfd_target
*default_bfd_vec
= &DEFAULT_BFD_VEC
;
610 static const bfd_target
*default_bfd_vec
;
613 static enum bfd_endian default_byte_order
= BFD_ENDIAN_UNKNOWN
;
616 initialize_current_architecture (void)
618 const char **arches
= gdbarch_printable_names ();
619 struct gdbarch_info info
;
621 /* determine a default architecture and byte order. */
622 gdbarch_info_init (&info
);
624 /* Find a default architecture. */
625 if (default_bfd_arch
== NULL
)
627 /* Choose the architecture by taking the first one
629 const char *chosen
= arches
[0];
631 for (arch
= arches
; *arch
!= NULL
; arch
++)
633 if (strcmp (*arch
, chosen
) < 0)
637 internal_error (__FILE__
, __LINE__
,
638 _("initialize_current_architecture: No arch"));
639 default_bfd_arch
= bfd_scan_arch (chosen
);
640 if (default_bfd_arch
== NULL
)
641 internal_error (__FILE__
, __LINE__
,
642 _("initialize_current_architecture: Arch not found"));
645 info
.bfd_arch_info
= default_bfd_arch
;
647 /* Take several guesses at a byte order. */
648 if (default_byte_order
== BFD_ENDIAN_UNKNOWN
649 && default_bfd_vec
!= NULL
)
651 /* Extract BFD's default vector's byte order. */
652 switch (default_bfd_vec
->byteorder
)
655 default_byte_order
= BFD_ENDIAN_BIG
;
657 case BFD_ENDIAN_LITTLE
:
658 default_byte_order
= BFD_ENDIAN_LITTLE
;
664 if (default_byte_order
== BFD_ENDIAN_UNKNOWN
)
666 /* look for ``*el-*'' in the target name. */
668 chp
= strchr (target_name
, '-');
670 && chp
- 2 >= target_name
671 && startswith (chp
- 2, "el"))
672 default_byte_order
= BFD_ENDIAN_LITTLE
;
674 if (default_byte_order
== BFD_ENDIAN_UNKNOWN
)
676 /* Wire it to big-endian!!! */
677 default_byte_order
= BFD_ENDIAN_BIG
;
680 info
.byte_order
= default_byte_order
;
681 info
.byte_order_for_code
= info
.byte_order
;
683 if (! gdbarch_update_p (info
))
684 internal_error (__FILE__
, __LINE__
,
685 _("initialize_current_architecture: Selection of "
686 "initial architecture failed"));
688 /* Create the ``set architecture'' command appending ``auto'' to the
689 list of architectures. */
691 /* Append ``auto''. */
693 for (nr
= 0; arches
[nr
] != NULL
; nr
++);
694 arches
= XRESIZEVEC (const char *, arches
, nr
+ 2);
695 arches
[nr
+ 0] = "auto";
696 arches
[nr
+ 1] = NULL
;
697 add_setshow_enum_cmd ("architecture", class_support
,
698 arches
, &set_architecture_string
,
699 _("Set architecture of target."),
700 _("Show architecture of target."), NULL
,
701 set_architecture
, show_architecture
,
702 &setlist
, &showlist
);
703 add_alias_cmd ("processor", "architecture", class_support
, 1, &setlist
);
708 /* Initialize a gdbarch info to values that will be automatically
709 overridden. Note: Originally, this ``struct info'' was initialized
710 using memset(0). Unfortunately, that ran into problems, namely
711 BFD_ENDIAN_BIG is zero. An explicit initialization function that
712 can explicitly set each field to a well defined value is used. */
715 gdbarch_info_init (struct gdbarch_info
*info
)
717 memset (info
, 0, sizeof (struct gdbarch_info
));
718 info
->byte_order
= BFD_ENDIAN_UNKNOWN
;
719 info
->byte_order_for_code
= info
->byte_order
;
720 info
->osabi
= GDB_OSABI_UNINITIALIZED
;
723 /* Similar to init, but this time fill in the blanks. Information is
724 obtained from the global "set ..." options and explicitly
725 initialized INFO fields. */
728 gdbarch_info_fill (struct gdbarch_info
*info
)
730 /* "(gdb) set architecture ...". */
731 if (info
->bfd_arch_info
== NULL
732 && target_architecture_user
)
733 info
->bfd_arch_info
= target_architecture_user
;
735 if (info
->bfd_arch_info
== NULL
736 && info
->abfd
!= NULL
737 && bfd_get_arch (info
->abfd
) != bfd_arch_unknown
738 && bfd_get_arch (info
->abfd
) != bfd_arch_obscure
)
739 info
->bfd_arch_info
= bfd_get_arch_info (info
->abfd
);
740 /* From the target. */
741 if (info
->target_desc
!= NULL
)
742 info
->bfd_arch_info
= choose_architecture_for_target
743 (info
->target_desc
, info
->bfd_arch_info
);
744 /* From the default. */
745 if (info
->bfd_arch_info
== NULL
)
746 info
->bfd_arch_info
= default_bfd_arch
;
748 /* "(gdb) set byte-order ...". */
749 if (info
->byte_order
== BFD_ENDIAN_UNKNOWN
750 && target_byte_order_user
!= BFD_ENDIAN_UNKNOWN
)
751 info
->byte_order
= target_byte_order_user
;
752 /* From the INFO struct. */
753 if (info
->byte_order
== BFD_ENDIAN_UNKNOWN
754 && info
->abfd
!= NULL
)
755 info
->byte_order
= (bfd_big_endian (info
->abfd
) ? BFD_ENDIAN_BIG
756 : bfd_little_endian (info
->abfd
) ? BFD_ENDIAN_LITTLE
757 : BFD_ENDIAN_UNKNOWN
);
758 /* From the default. */
759 if (info
->byte_order
== BFD_ENDIAN_UNKNOWN
)
760 info
->byte_order
= default_byte_order
;
761 info
->byte_order_for_code
= info
->byte_order
;
763 /* "(gdb) set osabi ...". Handled by gdbarch_lookup_osabi. */
764 /* From the manual override, or from file. */
765 if (info
->osabi
== GDB_OSABI_UNINITIALIZED
)
766 info
->osabi
= gdbarch_lookup_osabi (info
->abfd
);
767 /* From the target. */
768 if (info
->osabi
== GDB_OSABI_UNKNOWN
&& info
->target_desc
!= NULL
)
769 info
->osabi
= tdesc_osabi (info
->target_desc
);
770 /* From the configured default. */
771 #ifdef GDB_OSABI_DEFAULT
772 if (info
->osabi
== GDB_OSABI_UNKNOWN
)
773 info
->osabi
= GDB_OSABI_DEFAULT
;
776 /* Must have at least filled in the architecture. */
777 gdb_assert (info
->bfd_arch_info
!= NULL
);
780 /* Return "current" architecture. If the target is running, this is
781 the architecture of the selected frame. Otherwise, the "current"
782 architecture defaults to the target architecture.
784 This function should normally be called solely by the command
785 interpreter routines to determine the architecture to execute a
788 get_current_arch (void)
790 if (has_stack_frames ())
791 return get_frame_arch (get_selected_frame (NULL
));
793 return target_gdbarch ();
797 default_has_shared_address_space (struct gdbarch
*gdbarch
)
799 /* Simply say no. In most unix-like targets each inferior/process
800 has its own address space. */
805 default_fast_tracepoint_valid_at (struct gdbarch
*gdbarch
, CORE_ADDR addr
,
808 /* We don't know if maybe the target has some way to do fast
809 tracepoints that doesn't need gdbarch, so always say yes. */
816 default_remote_breakpoint_from_pc (struct gdbarch
*gdbarch
, CORE_ADDR
*pcptr
,
819 gdbarch_breakpoint_from_pc (gdbarch
, pcptr
, kindptr
);
823 default_gen_return_address (struct gdbarch
*gdbarch
,
824 struct agent_expr
*ax
, struct axs_value
*value
,
827 error (_("This architecture has no method to collect a return address."));
831 default_return_in_first_hidden_param_p (struct gdbarch
*gdbarch
,
834 /* Usually, the return value's address is stored the in the "first hidden"
835 parameter if the return value should be passed by reference, as
837 return language_pass_by_reference (type
);
840 int default_insn_is_call (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
845 int default_insn_is_ret (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
850 int default_insn_is_jump (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
856 default_skip_permanent_breakpoint (struct regcache
*regcache
)
858 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
859 CORE_ADDR current_pc
= regcache_read_pc (regcache
);
862 gdbarch_breakpoint_from_pc (gdbarch
, ¤t_pc
, &bp_len
);
863 current_pc
+= bp_len
;
864 regcache_write_pc (regcache
, current_pc
);
868 default_infcall_mmap (CORE_ADDR size
, unsigned prot
)
870 error (_("This target does not support inferior memory allocation by mmap."));
874 default_infcall_munmap (CORE_ADDR addr
, CORE_ADDR size
)
876 /* Memory reserved by inferior mmap is kept leaked. */
879 /* -mcmodel=large is used so that no GOT (Global Offset Table) is needed to be
880 created in inferior memory by GDB (normally it is set by ld.so). */
883 default_gcc_target_options (struct gdbarch
*gdbarch
)
885 return xstrprintf ("-m%d%s", gdbarch_ptr_bit (gdbarch
),
886 gdbarch_ptr_bit (gdbarch
) == 64 ? " -mcmodel=large" : "");
889 /* gdbarch gnu_triplet_regexp method. */
892 default_gnu_triplet_regexp (struct gdbarch
*gdbarch
)
894 return gdbarch_bfd_arch_info (gdbarch
)->arch_name
;
897 /* Default method for gdbarch_addressable_memory_unit_size. By default, a memory byte has
898 a size of 1 octet. */
901 default_addressable_memory_unit_size (struct gdbarch
*gdbarch
)
907 default_guess_tracepoint_registers (struct gdbarch
*gdbarch
,
908 struct regcache
*regcache
,
911 int pc_regno
= gdbarch_pc_regnum (gdbarch
);
914 /* This guessing code below only works if the PC register isn't
915 a pseudo-register. The value of a pseudo-register isn't stored
916 in the (non-readonly) regcache -- instead it's recomputed
917 (probably from some other cached raw register) whenever the
918 register is read. In this case, a custom method implementation
919 should be used by the architecture. */
920 if (pc_regno
< 0 || pc_regno
>= gdbarch_num_regs (gdbarch
))
923 regs
= (gdb_byte
*) alloca (register_size (gdbarch
, pc_regno
));
924 store_unsigned_integer (regs
, register_size (gdbarch
, pc_regno
),
925 gdbarch_byte_order (gdbarch
), addr
);
926 regcache_raw_supply (regcache
, pc_regno
, regs
);
929 /* -Wmissing-prototypes */
930 extern initialize_file_ftype _initialize_gdbarch_utils
;
933 _initialize_gdbarch_utils (void)
935 add_setshow_enum_cmd ("endian", class_support
,
936 endian_enum
, &set_endian_string
,
937 _("Set endianness of target."),
938 _("Show endianness of target."),
939 NULL
, set_endian
, show_endian
,
940 &setlist
, &showlist
);