GDB (xrefs)
Loading...
Searching...
No Matches
arch-utils.c
Go to the documentation of this file.
1/* Dynamic architecture support for GDB, the GNU debugger.
2
3 Copyright (C) 1998-2023 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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.
11
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.
16
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/>. */
19
20#include "defs.h"
21
22#include "arch-utils.h"
23#include "gdbcmd.h"
24#include "inferior.h"
25#include "infrun.h"
26#include "regcache.h"
27#include "sim-regno.h"
28#include "gdbcore.h"
29#include "osabi.h"
30#include "target-descriptions.h"
31#include "objfiles.h"
32#include "language.h"
33#include "symtab.h"
34#include "dummy-frame.h"
35#include "frame-unwind.h"
36#include "reggroups.h"
37#include "auxv.h"
38#include "observable.h"
39#include "solib-target.h"
40
41#include "gdbsupport/version.h"
42
43#include "floatformat.h"
44
45#include "dis-asm.h"
46
47bool
52
53CORE_ADDR
55{
56 CORE_ADDR addr;
57 int bp_len;
58
59 addr = entry_point_address ();
60
61 /* Inferior calls also use the entry point as a breakpoint location.
62 We don't want displaced stepping to interfere with those
63 breakpoints, so leave space. */
64 gdbarch_breakpoint_from_pc (gdbarch, &addr, &bp_len);
65 addr += bp_len * 2;
66
67 return addr;
68}
69
70int
72{
73 /* Only makes sense to supply raw registers. */
74 gdb_assert (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch));
75 /* NOTE: cagney/2002-05-13: The old code did it this way and it is
76 suspected that some GDB/SIM combinations may rely on this
77 behaviour. The default should be one2one_register_sim_regno
78 (below). */
79 if (gdbarch_register_name (gdbarch, regnum)[0] != '\0')
80 return regnum;
81 else
83}
84
85/* See arch-utils.h */
86
87CORE_ADDR
89{
90 /* By default, just return the pointer value. */
91 return pointer;
92}
93
94/* See arch-utils.h */
95
96std::string
98{
99 error (_("This architecture has no method to convert a memory tag to"
100 " a string."));
101}
102
103/* See arch-utils.h */
104
105bool
107{
108 /* By default, assume the address is untagged. */
109 return false;
110}
111
112/* See arch-utils.h */
113
114bool
116{
117 /* By default, assume the tags match. */
118 return true;
119}
120
121/* See arch-utils.h */
122
123bool
124default_set_memtags (struct gdbarch *gdbarch, struct value *address,
125 size_t length, const gdb::byte_vector &tags,
126 memtag_type tag_type)
127{
128 /* By default, return true (successful); */
129 return true;
130}
131
132/* See arch-utils.h */
133
134struct value *
136 memtag_type tag_type)
137{
138 /* By default, return no tag. */
139 return nullptr;
140}
141
142CORE_ADDR
144{
145 return 0;
146}
147
148CORE_ADDR
150{
151 return 0;
152}
153
154int
156 CORE_ADDR pc, const char *name)
157{
158 return 0;
159}
160
161int
163{
164 return 0;
165}
166
167int
169 frame_info_ptr frame)
170{
171 return 1;
172}
173
174/* Helper functions for gdbarch_inner_than */
175
176int
177core_addr_lessthan (CORE_ADDR lhs, CORE_ADDR rhs)
178{
179 return (lhs < rhs);
180}
181
182int
183core_addr_greaterthan (CORE_ADDR lhs, CORE_ADDR rhs)
184{
185 return (lhs > rhs);
186}
187
188/* Misc helper functions for targets. */
189
190CORE_ADDR
191core_addr_identity (struct gdbarch *gdbarch, CORE_ADDR addr)
192{
193 return addr;
194}
195
196CORE_ADDR
198 struct target_ops *targ)
199{
200 return addr;
201}
202
203int
205{
206 return reg;
207}
208
209void
211{
212 return;
213}
214
215/* See arch-utils.h. */
216
217void
219{
220 return;
221}
222
223/* See arch-utils.h. */
224
225CORE_ADDR
227{
228 return pc;
229}
230
231/* See arch-utils.h. */
232
233CORE_ADDR
234default_adjust_dwarf2_line (CORE_ADDR addr, int rel)
235{
236 return addr;
237}
238
239/* See arch-utils.h. */
240
241bool
243 struct dwarf2_frame_state *fs)
244{
245 return false;
246}
247
248int
250{
251 return 0;
252}
253
254/* Legacy version of target_virtual_frame_pointer(). Assumes that
255 there is an gdbarch_deprecated_fp_regnum and that it is the same,
256 cooked or raw. */
257
258void
260 CORE_ADDR pc,
261 int *frame_regnum,
262 LONGEST *frame_offset)
263{
264 /* FIXME: cagney/2002-09-13: This code is used when identifying the
265 frame pointer of the current PC. It is assuming that a single
266 register and an offset can determine this. I think it should
267 instead generate a byte code expression as that would work better
268 with things like Dwarf2's CFI. */
272 *frame_regnum = gdbarch_deprecated_fp_regnum (gdbarch);
273 else if (gdbarch_sp_regnum (gdbarch) >= 0
276 *frame_regnum = gdbarch_sp_regnum (gdbarch);
277 else
278 /* Should this be an internal error? I guess so, it is reflecting
279 an architectural limitation in the current design. */
280 internal_error (_("No virtual frame pointer available"));
281 *frame_offset = 0;
282}
283
284/* Return a floating-point format for a floating-point variable of
285 length LEN in bits. If non-NULL, NAME is the name of its type.
286 If no suitable type is found, return NULL. */
287
288const struct floatformat **
290 const char *name, int len)
291{
292 const struct floatformat **format = NULL;
293
294 /* Check if this is a bfloat16 type. It has the same size as the
295 IEEE half float type, so we use the base type name to tell them
296 apart. */
297 if (name != nullptr && strcmp (name, "__bf16") == 0
298 && len == gdbarch_bfloat16_bit (gdbarch))
300 else if (len == gdbarch_half_bit (gdbarch))
301 format = gdbarch_half_format (gdbarch);
302 else if (len == gdbarch_float_bit (gdbarch))
303 format = gdbarch_float_format (gdbarch);
304 else if (len == gdbarch_double_bit (gdbarch))
306 else if (len == gdbarch_long_double_bit (gdbarch))
308 /* On i386 the 'long double' type takes 96 bits,
309 while the real number of used bits is only 80,
310 both in processor and in memory.
311 The code below accepts the real bit size. */
312 else if (gdbarch_long_double_format (gdbarch) != NULL
313 && len == gdbarch_long_double_format (gdbarch)[0]->totalsize)
315
316 return format;
317}
318
319int
321 struct type *type)
322{
323 return 0;
324}
325
326int
328{
329 return 0;
330}
331
332int
334 struct regcache *regcache)
335{
336 return 0;
337}
338
339int
341 int regno)
342{
343 return regno;
344}
345
346/* See arch-utils.h. */
347
348int
350{
351 return 0;
352}
353
354
355/* Functions to manipulate the endianness of the target. */
356
357static enum bfd_endian target_byte_order_user = BFD_ENDIAN_UNKNOWN;
358
359static const char endian_big[] = "big";
360static const char endian_little[] = "little";
361static const char endian_auto[] = "auto";
362static const char *const endian_enum[] =
363{
367 NULL,
368};
369static const char *set_endian_string = endian_auto;
370
371enum bfd_endian
373{
375}
376
377/* Called by ``show endian''. */
378
379static void
380show_endian (struct ui_file *file, int from_tty, struct cmd_list_element *c,
381 const char *value)
382{
383 if (target_byte_order_user == BFD_ENDIAN_UNKNOWN)
384 if (gdbarch_byte_order (get_current_arch ()) == BFD_ENDIAN_BIG)
385 gdb_printf (file, _("The target endianness is set automatically "
386 "(currently big endian).\n"));
387 else
388 gdb_printf (file, _("The target endianness is set automatically "
389 "(currently little endian).\n"));
390 else
391 if (target_byte_order_user == BFD_ENDIAN_BIG)
392 gdb_printf (file,
393 _("The target is set to big endian.\n"));
394 else
395 gdb_printf (file,
396 _("The target is set to little endian.\n"));
397}
398
399static void
400set_endian (const char *ignore_args, int from_tty, struct cmd_list_element *c)
401{
402 struct gdbarch_info info;
403
405 {
406 target_byte_order_user = BFD_ENDIAN_UNKNOWN;
407 if (! gdbarch_update_p (info))
408 internal_error (_("set_endian: architecture update failed"));
409 }
411 {
412 info.byte_order = BFD_ENDIAN_LITTLE;
413 if (! gdbarch_update_p (info))
415 _("Little endian target not supported by GDB\n"));
416 else
417 target_byte_order_user = BFD_ENDIAN_LITTLE;
418 }
419 else if (set_endian_string == endian_big)
420 {
421 info.byte_order = BFD_ENDIAN_BIG;
422 if (! gdbarch_update_p (info))
424 _("Big endian target not supported by GDB\n"));
425 else
426 target_byte_order_user = BFD_ENDIAN_BIG;
427 }
428 else
429 internal_error (_("set_endian: bad value"));
430
431 show_endian (gdb_stdout, from_tty, NULL, NULL);
432}
433
434/* Given SELECTED, a currently selected BFD architecture, and
435 TARGET_DESC, the current target description, return what
436 architecture to use.
437
438 SELECTED may be NULL, in which case we return the architecture
439 associated with TARGET_DESC. If SELECTED specifies a variant
440 of the architecture associated with TARGET_DESC, return the
441 more specific of the two.
442
443 If SELECTED is a different architecture, but it is accepted as
444 compatible by the target, we can use the target architecture.
445
446 If SELECTED is obviously incompatible, warn the user. */
447
448static const struct bfd_arch_info *
450 const struct bfd_arch_info *selected)
451{
452 const struct bfd_arch_info *from_target = tdesc_architecture (target_desc);
453 const struct bfd_arch_info *compat1, *compat2;
454
455 if (selected == NULL)
456 return from_target;
457
458 if (from_target == NULL)
459 return selected;
460
461 /* struct bfd_arch_info objects are singletons: that is, there's
462 supposed to be exactly one instance for a given machine. So you
463 can tell whether two are equivalent by comparing pointers. */
464 if (from_target == selected)
465 return selected;
466
467 /* BFD's 'A->compatible (A, B)' functions return zero if A and B are
468 incompatible. But if they are compatible, it returns the 'more
469 featureful' of the two arches. That is, if A can run code
470 written for B, but B can't run code written for A, then it'll
471 return A.
472
473 Some targets (e.g. MIPS as of 2006-12-04) don't fully
474 implement this, instead always returning NULL or the first
475 argument. We detect that case by checking both directions. */
476
477 compat1 = selected->compatible (selected, from_target);
478 compat2 = from_target->compatible (from_target, selected);
479
480 if (compat1 == NULL && compat2 == NULL)
481 {
482 /* BFD considers the architectures incompatible. Check our
483 target description whether it accepts SELECTED as compatible
484 anyway. */
485 if (tdesc_compatible_p (target_desc, selected))
486 return from_target;
487
488 warning (_("Selected architecture %s is not compatible "
489 "with reported target architecture %s"),
490 selected->printable_name, from_target->printable_name);
491 return selected;
492 }
493
494 if (compat1 == NULL)
495 return compat2;
496 if (compat2 == NULL)
497 return compat1;
498 if (compat1 == compat2)
499 return compat1;
500
501 /* If the two didn't match, but one of them was a default
502 architecture, assume the more specific one is correct. This
503 handles the case where an executable or target description just
504 says "mips", but the other knows which MIPS variant. */
505 if (compat1->the_default)
506 return compat2;
507 if (compat2->the_default)
508 return compat1;
509
510 /* We have no idea which one is better. This is a bug, but not
511 a critical problem; warn the user. */
512 warning (_("Selected architecture %s is ambiguous with "
513 "reported target architecture %s"),
514 selected->printable_name, from_target->printable_name);
515 return selected;
516}
517
518/* Functions to manipulate the architecture of the target. */
519
521
522static const struct bfd_arch_info *target_architecture_user;
523
524static const char *set_architecture_string;
525
526const char *
528{
529 if (target_architecture_user == NULL)
530 return NULL;
531 else
533}
534
535/* Called if the user enters ``show architecture'' without an
536 argument. */
537
538static void
539show_architecture (struct ui_file *file, int from_tty,
540 struct cmd_list_element *c, const char *value)
541{
542 if (target_architecture_user == NULL)
543 gdb_printf (file, _("The target architecture is set to "
544 "\"auto\" (currently \"%s\").\n"),
545 gdbarch_bfd_arch_info (get_current_arch ())->printable_name);
546 else
547 gdb_printf (file, _("The target architecture is set to \"%s\".\n"),
549}
550
551
552/* Called if the user enters ``set architecture'' with or without an
553 argument. */
554
555static void
556set_architecture (const char *ignore_args,
557 int from_tty, struct cmd_list_element *c)
558{
559 struct gdbarch_info info;
560
561 if (strcmp (set_architecture_string, "auto") == 0)
562 {
564 if (!gdbarch_update_p (info))
565 internal_error (_("could not select an architecture automatically"));
566 }
567 else
568 {
569 info.bfd_arch_info = bfd_scan_arch (set_architecture_string);
570 if (info.bfd_arch_info == NULL)
571 internal_error (_("set_architecture: bfd_scan_arch failed"));
572 if (gdbarch_update_p (info))
573 target_architecture_user = info.bfd_arch_info;
574 else
576 _("Architecture `%s' not recognized.\n"),
578 }
579 show_architecture (gdb_stdout, from_tty, NULL, NULL);
580}
581
582/* Try to select a global architecture that matches "info". Return
583 non-zero if the attempt succeeds. */
584int
586{
587 struct gdbarch *new_gdbarch;
588
589 /* Check for the current file. */
590 if (info.abfd == NULL)
592 if (info.abfd == NULL)
593 info.abfd = core_bfd;
594
595 /* Check for the current target description. */
596 if (info.target_desc == NULL)
597 info.target_desc = target_current_description ();
598
599 new_gdbarch = gdbarch_find_by_info (info);
600
601 /* If there no architecture by that name, reject the request. */
602 if (new_gdbarch == NULL)
603 {
604 if (gdbarch_debug)
605 gdb_printf (gdb_stdlog, "gdbarch_update_p: "
606 "Architecture not found\n");
607 return 0;
608 }
609
610 /* If it is the same old architecture, accept the request (but don't
611 swap anything). */
612 if (new_gdbarch == target_gdbarch ())
613 {
614 if (gdbarch_debug)
615 gdb_printf (gdb_stdlog, "gdbarch_update_p: "
616 "Architecture %s (%s) unchanged\n",
617 host_address_to_string (new_gdbarch),
618 gdbarch_bfd_arch_info (new_gdbarch)->printable_name);
619 return 1;
620 }
621
622 /* It's a new architecture, swap it in. */
623 if (gdbarch_debug)
624 gdb_printf (gdb_stdlog, "gdbarch_update_p: "
625 "New architecture %s (%s) selected\n",
626 host_address_to_string (new_gdbarch),
627 gdbarch_bfd_arch_info (new_gdbarch)->printable_name);
628 set_target_gdbarch (new_gdbarch);
629
630 return 1;
631}
632
633/* Return the architecture for ABFD. If no suitable architecture
634 could be find, return NULL. */
635
636struct gdbarch *
638{
639 struct gdbarch_info info;
640
641 info.abfd = abfd;
642 return gdbarch_find_by_info (info);
643}
644
645/* Set the dynamic target-system-dependent parameters (architecture,
646 byte-order) using information found in the BFD */
647
648void
650{
651 struct gdbarch_info info;
652 struct gdbarch *gdbarch;
653
654 info.abfd = abfd;
655 info.target_desc = target_current_description ();
657
658 if (gdbarch == NULL)
659 error (_("Architecture of file not recognized."));
661}
662
663/* Initialize the current architecture. Update the ``set
664 architecture'' command so that it specifies a list of valid
665 architectures. */
666
667#ifdef DEFAULT_BFD_ARCH
668extern const bfd_arch_info_type DEFAULT_BFD_ARCH;
669static const bfd_arch_info_type *default_bfd_arch = &DEFAULT_BFD_ARCH;
670#else
671static const bfd_arch_info_type *default_bfd_arch;
672#endif
673
674#ifdef DEFAULT_BFD_VEC
675extern const bfd_target DEFAULT_BFD_VEC;
676static const bfd_target *default_bfd_vec = &DEFAULT_BFD_VEC;
677#else
678static const bfd_target *default_bfd_vec;
679#endif
680
681static enum bfd_endian default_byte_order = BFD_ENDIAN_UNKNOWN;
682
683/* Printable names of architectures. Used as the enum list of the
684 "set arch" command. */
685static std::vector<const char *> arches;
686
687void
689{
691
692 /* Find a default architecture. */
693 if (default_bfd_arch == NULL)
694 {
695 /* Choose the architecture by taking the first one
696 alphabetically. */
697 const char *chosen = arches[0];
698
699 for (const char *arch : arches)
700 {
701 if (strcmp (arch, chosen) < 0)
702 chosen = arch;
703 }
704
705 if (chosen == NULL)
706 internal_error (_("initialize_current_architecture: No arch"));
707
708 default_bfd_arch = bfd_scan_arch (chosen);
709 if (default_bfd_arch == NULL)
710 internal_error (_("initialize_current_architecture: Arch not found"));
711 }
712
715
716 /* Take several guesses at a byte order. */
717 if (default_byte_order == BFD_ENDIAN_UNKNOWN
718 && default_bfd_vec != NULL)
719 {
720 /* Extract BFD's default vector's byte order. */
721 switch (default_bfd_vec->byteorder)
722 {
723 case BFD_ENDIAN_BIG:
724 default_byte_order = BFD_ENDIAN_BIG;
725 break;
726 case BFD_ENDIAN_LITTLE:
727 default_byte_order = BFD_ENDIAN_LITTLE;
728 break;
729 default:
730 break;
731 }
732 }
733 if (default_byte_order == BFD_ENDIAN_UNKNOWN)
734 {
735 /* look for ``*el-*'' in the target name. */
736 const char *chp;
737 chp = strchr (target_name, '-');
738 if (chp != NULL
739 && chp - 2 >= target_name
740 && startswith (chp - 2, "el"))
741 default_byte_order = BFD_ENDIAN_LITTLE;
742 }
743 if (default_byte_order == BFD_ENDIAN_UNKNOWN)
744 {
745 /* Wire it to big-endian!!! */
746 default_byte_order = BFD_ENDIAN_BIG;
747 }
748
749 info.byte_order = default_byte_order;
750 info.byte_order_for_code = info.byte_order;
751
752 if (! gdbarch_update_p (info))
753 internal_error (_("initialize_current_architecture: Selection of "
754 "initial architecture failed"));
755
756 /* Create the ``set architecture'' command appending ``auto'' to the
757 list of architectures. */
758 {
759 /* Append ``auto''. */
762 arches.push_back (nullptr);
763 set_show_commands architecture_cmds
764 = add_setshow_enum_cmd ("architecture", class_support,
766 _("Set architecture of target."),
767 _("Show architecture of target."), NULL,
769 &setlist, &showlist);
770 add_alias_cmd ("processor", architecture_cmds.set, class_support, 1,
771 &setlist);
772 }
773}
774
775/* Similar to init, but this time fill in the blanks. Information is
776 obtained from the global "set ..." options and explicitly
777 initialized INFO fields. */
778
779void
781{
782 /* "(gdb) set architecture ...". */
783 if (info->bfd_arch_info == NULL
785 info->bfd_arch_info = target_architecture_user;
786 /* From the file. */
787 if (info->bfd_arch_info == NULL
788 && info->abfd != NULL
789 && bfd_get_arch (info->abfd) != bfd_arch_unknown
790 && bfd_get_arch (info->abfd) != bfd_arch_obscure)
791 info->bfd_arch_info = bfd_get_arch_info (info->abfd);
792 /* From the target. */
793 if (info->target_desc != NULL)
794 info->bfd_arch_info = choose_architecture_for_target
795 (info->target_desc, info->bfd_arch_info);
796 /* From the default. */
797 if (info->bfd_arch_info == NULL)
798 info->bfd_arch_info = default_bfd_arch;
799
800 /* "(gdb) set byte-order ...". */
801 if (info->byte_order == BFD_ENDIAN_UNKNOWN
802 && target_byte_order_user != BFD_ENDIAN_UNKNOWN)
803 info->byte_order = target_byte_order_user;
804 /* From the INFO struct. */
805 if (info->byte_order == BFD_ENDIAN_UNKNOWN
806 && info->abfd != NULL)
807 info->byte_order = (bfd_big_endian (info->abfd) ? BFD_ENDIAN_BIG
808 : bfd_little_endian (info->abfd) ? BFD_ENDIAN_LITTLE
809 : BFD_ENDIAN_UNKNOWN);
810 /* From the default. */
811 if (info->byte_order == BFD_ENDIAN_UNKNOWN)
812 info->byte_order = default_byte_order;
813 info->byte_order_for_code = info->byte_order;
814 /* Wire the default to the last selected byte order. */
815 default_byte_order = info->byte_order;
816
817 /* "(gdb) set osabi ...". Handled by gdbarch_lookup_osabi. */
818 /* From the manual override, or from file. */
819 if (info->osabi == GDB_OSABI_UNKNOWN)
820 info->osabi = gdbarch_lookup_osabi (info->abfd);
821 /* From the target. */
822
823 if (info->osabi == GDB_OSABI_UNKNOWN && info->target_desc != NULL)
824 info->osabi = tdesc_osabi (info->target_desc);
825 /* From the configured default. */
826#ifdef GDB_OSABI_DEFAULT
827 if (info->osabi == GDB_OSABI_UNKNOWN)
828 info->osabi = GDB_OSABI_DEFAULT;
829#endif
830 /* If we still don't know which osabi to pick, pick none. */
831 if (info->osabi == GDB_OSABI_UNKNOWN)
832 info->osabi = GDB_OSABI_NONE;
833
834 /* Must have at least filled in the architecture. */
835 gdb_assert (info->bfd_arch_info != NULL);
836}
837
838/* Return "current" architecture. If the target is running, this is
839 the architecture of the selected frame. Otherwise, the "current"
840 architecture defaults to the target architecture.
841
842 This function should normally be called solely by the command
843 interpreter routines to determine the architecture to execute a
844 command in. */
845struct gdbarch *
847{
848 if (has_stack_frames ())
849 return get_frame_arch (get_selected_frame (NULL));
850 else
851 return target_gdbarch ();
852}
853
854int
856{
857 /* Simply say no. In most unix-like targets each inferior/process
858 has its own address space. */
859 return 0;
860}
861
862int
864 std::string *msg)
865{
866 /* We don't know if maybe the target has some way to do fast
867 tracepoints that doesn't need gdbarch, so always say yes. */
868 if (msg)
869 msg->clear ();
870 return 1;
871}
872
873const gdb_byte *
874default_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
875 int *lenptr)
876{
877 int kind = gdbarch_breakpoint_kind_from_pc (gdbarch, pcptr);
878
879 return gdbarch_sw_breakpoint_from_kind (gdbarch, kind, lenptr);
880}
881int
883 struct regcache *regcache,
884 CORE_ADDR *pcptr)
885{
887}
888
889
890void
892 struct agent_expr *ax, struct axs_value *value,
893 CORE_ADDR scope)
894{
895 error (_("This architecture has no method to collect a return address."));
896}
897
898int
900 struct type *type)
901{
902 /* Usually, the return value's address is stored the in the "first hidden"
903 parameter if the return value should be passed by reference, as
904 specified in ABI. */
906}
907
908int default_insn_is_call (struct gdbarch *gdbarch, CORE_ADDR addr)
909{
910 return 0;
911}
912
913int default_insn_is_ret (struct gdbarch *gdbarch, CORE_ADDR addr)
914{
915 return 0;
916}
917
918int default_insn_is_jump (struct gdbarch *gdbarch, CORE_ADDR addr)
919{
920 return 0;
921}
922
923/* See arch-utils.h. */
924
925bool
927 CORE_ADDR address)
928{
929 int len;
930 const gdb_byte *bpoint = gdbarch_breakpoint_from_pc (gdbarch, &address, &len);
931
932 /* Software breakpoints unsupported? */
933 if (bpoint == nullptr)
934 return false;
935
936 gdb_byte *target_mem = (gdb_byte *) alloca (len);
937
938 /* Enable the automatic memory restoration from breakpoints while
939 we read the memory. Otherwise we may find temporary breakpoints, ones
940 inserted by GDB, and flag them as permanent breakpoints. */
941 scoped_restore restore_memory
943
944 if (target_read_memory (address, target_mem, len) == 0)
945 {
946 /* Check if this is a breakpoint instruction for this architecture,
947 including ones used by GDB. */
948 if (memcmp (target_mem, bpoint, len) == 0)
949 return true;
950 }
951
952 return false;
953}
954
955void
957{
958 struct gdbarch *gdbarch = regcache->arch ();
959 CORE_ADDR current_pc = regcache_read_pc (regcache);
960 int bp_len;
961
962 gdbarch_breakpoint_from_pc (gdbarch, &current_pc, &bp_len);
963 current_pc += bp_len;
964 regcache_write_pc (regcache, current_pc);
965}
966
967CORE_ADDR
968default_infcall_mmap (CORE_ADDR size, unsigned prot)
969{
970 error (_("This target does not support inferior memory allocation by mmap."));
971}
972
973void
974default_infcall_munmap (CORE_ADDR addr, CORE_ADDR size)
975{
976 /* Memory reserved by inferior mmap is kept leaked. */
977}
978
979/* -mcmodel=large is used so that no GOT (Global Offset Table) is needed to be
980 created in inferior memory by GDB (normally it is set by ld.so). */
981
982std::string
984{
985 return string_printf ("-m%d%s", gdbarch_ptr_bit (gdbarch),
986 (gdbarch_ptr_bit (gdbarch) == 64
987 ? " -mcmodel=large" : ""));
988}
989
990/* gdbarch gnu_triplet_regexp method. */
991
992const char *
994{
995 return gdbarch_bfd_arch_info (gdbarch)->arch_name;
996}
997
998/* Default method for gdbarch_addressable_memory_unit_size. The default is
999 based on the bits_per_byte defined in the bfd library for the current
1000 architecture, this is usually 8-bits, and so this function will usually
1001 return 1 indicating 1 byte is 1 octet. */
1002
1003int
1005{
1006 return gdbarch_bfd_arch_info (gdbarch)->bits_per_byte / 8;
1007}
1008
1009void
1011 struct regcache *regcache,
1012 CORE_ADDR addr)
1013{
1014 int pc_regno = gdbarch_pc_regnum (gdbarch);
1015 gdb_byte *regs;
1016
1017 /* This guessing code below only works if the PC register isn't
1018 a pseudo-register. The value of a pseudo-register isn't stored
1019 in the (non-readonly) regcache -- instead it's recomputed
1020 (probably from some other cached raw register) whenever the
1021 register is read. In this case, a custom method implementation
1022 should be used by the architecture. */
1023 if (pc_regno < 0 || pc_regno >= gdbarch_num_regs (gdbarch))
1024 return;
1025
1026 regs = (gdb_byte *) alloca (register_size (gdbarch, pc_regno));
1027 store_unsigned_integer (regs, register_size (gdbarch, pc_regno),
1028 gdbarch_byte_order (gdbarch), addr);
1029 regcache->raw_supply (pc_regno, regs);
1030}
1031
1032int
1033default_print_insn (bfd_vma memaddr, disassemble_info *info)
1034{
1035 disassembler_ftype disassemble_fn;
1036
1037 disassemble_fn = disassembler (info->arch, info->endian == BFD_ENDIAN_BIG,
1039
1040 gdb_assert (disassemble_fn != NULL);
1041 return (*disassemble_fn) (memaddr, info);
1042}
1043
1044/* See arch-utils.h. */
1045
1046CORE_ADDR
1048{
1049 CORE_ADDR new_pc = pc;
1050
1051 try
1052 {
1053 new_pc = gdbarch_skip_prologue (gdbarch, pc);
1054 }
1055 catch (const gdb_exception &ex)
1056 {}
1057
1058 return new_pc;
1059}
1060
1061/* See arch-utils.h. */
1062
1063bool
1065{
1066 return false;
1067}
1068
1069/* See arch-utils.h. */
1070
1071ULONGEST
1073{
1074 return 0;
1075}
1076
1077/* See arch-utils.h. */
1078
1079std::string
1081{
1082 return "";
1083}
1084
1085/* See arch-utils.h. */
1086void
1088 (struct gdbarch *gdbarch,
1089 struct bfd *cbfd,
1092{
1093}
1094
1095/* See arch-utils.h. */
1096bool
1098 struct bfd *corefile_bfd)
1099{
1100 /* Always trust the corefile target description contained in the target
1101 description note. */
1102 return true;
1103}
1104
1105CORE_ADDR
1107{
1108 return 0;
1109}
1110
1111bool
1112default_dwarf2_omit_typedef_p (struct type *target_type, const char *producer,
1113 const char *name)
1114{
1115 return false;
1116}
1117
1118static CORE_ADDR
1120{
1121 return pc;
1122}
1123
1124/* Non-zero if we want to trace architecture code. */
1125
1126#ifndef GDBARCH_DEBUG
1127#define GDBARCH_DEBUG 0
1128#endif
1130static void
1131show_gdbarch_debug (struct ui_file *file, int from_tty,
1132 struct cmd_list_element *c, const char *value)
1133{
1134 gdb_printf (file, _("Architecture debugging is %s.\n"), value);
1135}
1136
1137static const char *
1138pformat (struct gdbarch *gdbarch, const struct floatformat **format)
1139{
1140 if (format == NULL)
1141 return "(null)";
1142
1143 int format_index = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE ? 1 : 0;
1144 return format[format_index]->name;
1145}
1146
1147static const char *
1148pstring (const char *string)
1149{
1150 if (string == NULL)
1151 return "(null)";
1152 return string;
1153}
1154
1155static const char *
1156pstring_ptr (char **string)
1157{
1158 if (string == NULL || *string == NULL)
1159 return "(null)";
1160 return *string;
1161}
1162
1163/* Helper function to print a list of strings, represented as "const
1164 char *const *". The list is printed comma-separated. */
1165
1166static const char *
1167pstring_list (const char *const *list)
1168{
1169 static char ret[100];
1170 const char *const *p;
1171 size_t offset = 0;
1172
1173 if (list == NULL)
1174 return "(null)";
1175
1176 ret[0] = '\0';
1177 for (p = list; *p != NULL && offset < sizeof (ret); ++p)
1178 {
1179 size_t s = xsnprintf (ret + offset, sizeof (ret) - offset, "%s, ", *p);
1180 offset += 2 + s;
1181 }
1182
1183 if (offset > 0)
1184 {
1185 gdb_assert (offset - 2 < sizeof (ret));
1186 ret[offset - 2] = '\0';
1187 }
1188
1189 return ret;
1190}
1191
1192#include "gdbarch.c"
1193
1196 (struct gdbarch *gdbarch, struct value *function, struct type *valtype,
1197 struct regcache *regcache, struct value **read_value,
1198 const gdb_byte *writebuf)
1199{
1200 gdb_byte *readbuf = nullptr;
1201
1202 if (read_value != nullptr)
1203 {
1204 *read_value = value::allocate (valtype);
1205 readbuf = (*read_value)->contents_raw ().data ();
1206 }
1207
1208 return gdbarch->return_value (gdbarch, function, valtype, regcache,
1209 readbuf, writebuf);
1210}
1211
1212obstack *gdbarch_obstack (gdbarch *arch)
1213{
1214 return &arch->obstack;
1215}
1216
1217/* See gdbarch.h. */
1218
1219char *
1220gdbarch_obstack_strdup (struct gdbarch *arch, const char *string)
1221{
1222 return obstack_strdup (&arch->obstack, string);
1223}
1224
1225
1226/* Free a gdbarch struct. This should never happen in normal
1227 operation --- once you've created a gdbarch, you keep it around.
1228 However, if an architecture's init function encounters an error
1229 building the structure, it may need to clean up a partially
1230 constructed gdbarch. */
1231
1232void
1233gdbarch_free (struct gdbarch *arch)
1234{
1235 gdb_assert (arch != NULL);
1236 gdb_assert (!arch->initialized_p);
1237 delete arch;
1238}
1239
1240/* See gdbarch.h. */
1241
1242struct gdbarch_tdep_base *
1244{
1245 if (gdbarch_debug >= 2)
1246 gdb_printf (gdb_stdlog, "gdbarch_tdep_1 called\n");
1247 return gdbarch->tdep.get ();
1248}
1249
1252{
1253 return &arch->registry_fields;
1254}
1255
1256/* Keep a registry of the architectures known by GDB. */
1257
1267
1269
1270std::vector<const char *>
1272{
1273 /* Accumulate a list of names based on the registered list of
1274 architectures. */
1275 std::vector<const char *> arches;
1276
1278 rego != nullptr;
1279 rego = rego->next)
1280 {
1281 const struct bfd_arch_info *ap
1282 = bfd_lookup_arch (rego->bfd_architecture, 0);
1283 if (ap == nullptr)
1284 internal_error (_("gdbarch_architecture_names: multi-arch unknown"));
1285 do
1286 {
1287 if (rego->supports_arch_info == nullptr
1288 || rego->supports_arch_info (ap))
1289 arches.push_back (ap->printable_name);
1290 ap = ap->next;
1291 }
1292 while (ap != NULL);
1293 }
1294
1295 return arches;
1296}
1297
1298
1299void
1300gdbarch_register (enum bfd_architecture bfd_architecture,
1301 gdbarch_init_ftype *init,
1302 gdbarch_dump_tdep_ftype *dump_tdep,
1303 gdbarch_supports_arch_info_ftype *supports_arch_info)
1304{
1305 struct gdbarch_registration **curr;
1306 const struct bfd_arch_info *bfd_arch_info;
1307
1308 /* Check that BFD recognizes this architecture */
1309 bfd_arch_info = bfd_lookup_arch (bfd_architecture, 0);
1310 if (bfd_arch_info == NULL)
1311 {
1312 internal_error (_("gdbarch: Attempt to register "
1313 "unknown architecture (%d)"),
1314 bfd_architecture);
1315 }
1316 /* Check that we haven't seen this architecture before. */
1317 for (curr = &gdbarch_registry;
1318 (*curr) != NULL;
1319 curr = &(*curr)->next)
1320 {
1321 if (bfd_architecture == (*curr)->bfd_architecture)
1322 internal_error (_("gdbarch: Duplicate registration "
1323 "of architecture (%s)"),
1324 bfd_arch_info->printable_name);
1325 }
1326 /* log it */
1327 if (gdbarch_debug)
1328 gdb_printf (gdb_stdlog, "gdbarch_register (%s, %s)\n",
1329 bfd_arch_info->printable_name,
1330 host_address_to_string (init));
1331 /* Append it */
1332 (*curr) = XNEW (struct gdbarch_registration);
1333 (*curr)->bfd_architecture = bfd_architecture;
1334 (*curr)->init = init;
1335 (*curr)->dump_tdep = dump_tdep;
1336 (*curr)->supports_arch_info = supports_arch_info;
1337 (*curr)->arches = NULL;
1338 (*curr)->next = NULL;
1339}
1340
1341/* Look for an architecture using gdbarch_info. */
1342
1343struct gdbarch_list *
1345 const struct gdbarch_info *info)
1346{
1347 for (; arches != NULL; arches = arches->next)
1348 {
1349 if (info->bfd_arch_info != arches->gdbarch->bfd_arch_info)
1350 continue;
1351 if (info->byte_order != arches->gdbarch->byte_order)
1352 continue;
1353 if (info->osabi != arches->gdbarch->osabi)
1354 continue;
1355 if (info->target_desc != arches->gdbarch->target_desc)
1356 continue;
1357 return arches;
1358 }
1359 return NULL;
1360}
1361
1362
1363/* Find an architecture that matches the specified INFO. Create a new
1364 architecture if needed. Return that new architecture. */
1365
1366struct gdbarch *
1368{
1369 struct gdbarch *new_gdbarch;
1370 struct gdbarch_registration *rego;
1371
1372 /* Fill in missing parts of the INFO struct using a number of
1373 sources: "set ..."; INFOabfd supplied; and the global
1374 defaults. */
1375 gdbarch_info_fill (&info);
1376
1377 /* Must have found some sort of architecture. */
1378 gdb_assert (info.bfd_arch_info != nullptr);
1379
1380 if (gdbarch_debug)
1381 {
1383 "gdbarch_find_by_info: info.bfd_arch_info %s\n",
1384 (info.bfd_arch_info != nullptr
1385 ? info.bfd_arch_info->printable_name
1386 : "(null)"));
1388 "gdbarch_find_by_info: info.byte_order %d (%s)\n",
1389 info.byte_order,
1390 (info.byte_order == BFD_ENDIAN_BIG ? "big"
1391 : info.byte_order == BFD_ENDIAN_LITTLE ? "little"
1392 : "default"));
1394 "gdbarch_find_by_info: info.osabi %d (%s)\n",
1395 info.osabi, gdbarch_osabi_name (info.osabi));
1397 "gdbarch_find_by_info: info.abfd %s\n",
1398 host_address_to_string (info.abfd));
1399 }
1400
1401 /* Find the tdep code that knows about this architecture. */
1402 for (rego = gdbarch_registry;
1403 rego != nullptr;
1404 rego = rego->next)
1405 if (rego->bfd_architecture == info.bfd_arch_info->arch)
1406 break;
1407 if (rego == nullptr)
1408 {
1409 if (gdbarch_debug)
1410 gdb_printf (gdb_stdlog, "gdbarch_find_by_info: "
1411 "No matching architecture\n");
1412 return nullptr;
1413 }
1414
1415 /* Ask the tdep code for an architecture that matches "info". */
1416 new_gdbarch = rego->init (info, rego->arches);
1417
1418 /* Did the tdep code like it? No. Reject the change and revert to
1419 the old architecture. */
1420 if (new_gdbarch == nullptr)
1421 {
1422 if (gdbarch_debug)
1423 gdb_printf (gdb_stdlog, "gdbarch_find_by_info: "
1424 "Target rejected architecture\n");
1425 return nullptr;
1426 }
1427
1428 /* Is this a pre-existing architecture (as determined by already
1429 being initialized)? Move it to the front of the architecture
1430 list (keeping the list sorted Most Recently Used). */
1431 if (new_gdbarch->initialized_p)
1432 {
1433 struct gdbarch_list **list;
1434 struct gdbarch_list *self;
1435 if (gdbarch_debug)
1436 gdb_printf (gdb_stdlog, "gdbarch_find_by_info: "
1437 "Previous architecture %s (%s) selected\n",
1438 host_address_to_string (new_gdbarch),
1439 new_gdbarch->bfd_arch_info->printable_name);
1440 /* Find the existing arch in the list. */
1441 for (list = &rego->arches;
1442 (*list) != nullptr && (*list)->gdbarch != new_gdbarch;
1443 list = &(*list)->next);
1444 /* It had better be in the list of architectures. */
1445 gdb_assert ((*list) != nullptr && (*list)->gdbarch == new_gdbarch);
1446 /* Unlink SELF. */
1447 self = (*list);
1448 (*list) = self->next;
1449 /* Insert SELF at the front. */
1450 self->next = rego->arches;
1451 rego->arches = self;
1452 /* Return it. */
1453 return new_gdbarch;
1454 }
1455
1456 /* It's a new architecture. */
1457 if (gdbarch_debug)
1458 gdb_printf (gdb_stdlog, "gdbarch_find_by_info: "
1459 "New architecture %s (%s) selected\n",
1460 host_address_to_string (new_gdbarch),
1461 new_gdbarch->bfd_arch_info->printable_name);
1462
1463 /* Insert the new architecture into the front of the architecture
1464 list (keep the list sorted Most Recently Used). */
1465 {
1466 struct gdbarch_list *self = XNEW (struct gdbarch_list);
1467 self->next = rego->arches;
1468 self->gdbarch = new_gdbarch;
1469 rego->arches = self;
1470 }
1471
1472 /* Check that the newly installed architecture is valid. Plug in
1473 any post init values. */
1474 new_gdbarch->dump_tdep = rego->dump_tdep;
1475 verify_gdbarch (new_gdbarch);
1476 new_gdbarch->initialized_p = true;
1477
1478 if (gdbarch_debug)
1479 gdbarch_dump (new_gdbarch, gdb_stdlog);
1480
1481 return new_gdbarch;
1482}
1483
1484/* Make the specified architecture current. */
1485
1486void
1487set_target_gdbarch (struct gdbarch *new_gdbarch)
1488{
1489 gdb_assert (new_gdbarch != NULL);
1490 gdb_assert (new_gdbarch->initialized_p);
1491 current_inferior ()->gdbarch = new_gdbarch;
1492 gdb::observers::architecture_changed.notify (new_gdbarch);
1494}
1495
1496/* Return the current inferior's arch. */
1497
1498struct gdbarch *
1500{
1501 return current_inferior ()->gdbarch;
1502}
1503
1505void
1507{
1510 _("Set endianness of target."),
1511 _("Show endianness of target."),
1512 NULL, set_endian, show_endian,
1513 &setlist, &showlist);
1515Set architecture debugging."), _("\
1516Show architecture debugging."), _("\
1517When non-zero, architecture debugging is enabled."),
1518 NULL,
1521}
int regnum
const char *const name
std::string default_get_pc_address_flags(frame_info_ptr frame, CORE_ADDR pc)
void gdbarch_register(enum bfd_architecture bfd_architecture, gdbarch_init_ftype *init, gdbarch_dump_tdep_ftype *dump_tdep, gdbarch_supports_arch_info_ftype *supports_arch_info)
void gdbarch_free(struct gdbarch *arch)
ULONGEST default_type_align(struct gdbarch *gdbarch, struct type *type)
static const char * pstring_list(const char *const *list)
struct gdbarch * gdbarch_from_bfd(bfd *abfd)
Definition arch-utils.c:637
unsigned int gdbarch_debug
static const char * set_architecture_string
Definition arch-utils.c:524
bool default_execute_dwarf_cfa_vendor_op(struct gdbarch *gdbarch, gdb_byte op, struct dwarf2_frame_state *fs)
Definition arch-utils.c:242
static const char * pstring_ptr(char **string)
int generic_in_solib_return_trampoline(struct gdbarch *gdbarch, CORE_ADDR pc, const char *name)
Definition arch-utils.c:155
#define GDBARCH_DEBUG
int default_insn_is_ret(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition arch-utils.c:913
static const char endian_little[]
Definition arch-utils.c:360
static void show_gdbarch_debug(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static const bfd_arch_info_type * default_bfd_arch
Definition arch-utils.c:671
int default_print_insn(bfd_vma memaddr, disassemble_info *info)
const struct floatformat ** default_floatformat_for_type(struct gdbarch *gdbarch, const char *name, int len)
Definition arch-utils.c:289
void set_target_gdbarch(struct gdbarch *new_gdbarch)
static const char * pformat(struct gdbarch *gdbarch, const struct floatformat **format)
CORE_ADDR generic_skip_trampoline_code(frame_info_ptr frame, CORE_ADDR pc)
Definition arch-utils.c:143
int gdbarch_update_p(struct gdbarch_info info)
Definition arch-utils.c:585
void default_skip_permanent_breakpoint(struct regcache *regcache)
Definition arch-utils.c:956
CORE_ADDR displaced_step_at_entry_point(struct gdbarch *gdbarch)
Definition arch-utils.c:54
void gdbarch_info_fill(struct gdbarch_info *info)
Definition arch-utils.c:780
static const char * set_endian_string
Definition arch-utils.c:369
int default_insn_is_jump(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition arch-utils.c:918
void default_guess_tracepoint_registers(struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr)
struct gdbarch * get_current_arch(void)
Definition arch-utils.c:846
void set_gdbarch_from_file(bfd *abfd)
Definition arch-utils.c:649
bool default_use_target_description_from_corefile_notes(struct gdbarch *gdbarch, struct bfd *corefile_bfd)
static const char endian_auto[]
Definition arch-utils.c:361
int default_addressable_memory_unit_size(struct gdbarch *gdbarch)
void default_read_core_file_mappings(struct gdbarch *gdbarch, struct bfd *cbfd, read_core_file_mappings_pre_loop_ftype pre_loop_cb, read_core_file_mappings_loop_ftype loop_cb)
int generic_instruction_nullified(struct gdbarch *gdbarch, struct regcache *regcache)
Definition arch-utils.c:333
CORE_ADDR default_adjust_dwarf2_line(CORE_ADDR addr, int rel)
Definition arch-utils.c:234
struct gdbarch * target_gdbarch(void)
static enum bfd_endian default_byte_order
Definition arch-utils.c:681
static const char *const endian_enum[]
Definition arch-utils.c:362
struct value * default_get_memtag(struct gdbarch *gdbarch, struct value *address, memtag_type tag_type)
Definition arch-utils.c:135
static void set_architecture(const char *ignore_args, int from_tty, struct cmd_list_element *c)
Definition arch-utils.c:556
static std::vector< const char * > arches
Definition arch-utils.c:685
static const bfd_target * default_bfd_vec
Definition arch-utils.c:678
CORE_ADDR default_get_return_buf_addr(struct type *val_type, frame_info_ptr cur_frame)
CORE_ADDR default_remove_non_address_bits(struct gdbarch *gdbarch, CORE_ADDR pointer)
Definition arch-utils.c:88
int default_breakpoint_kind_from_current_state(struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR *pcptr)
Definition arch-utils.c:882
char * gdbarch_obstack_strdup(struct gdbarch *arch, const char *string)
static const char * pstring(const char *string)
int default_fast_tracepoint_valid_at(struct gdbarch *gdbarch, CORE_ADDR addr, std::string *msg)
Definition arch-utils.c:863
void initialize_current_architecture(void)
Definition arch-utils.c:688
const char * default_gnu_triplet_regexp(struct gdbarch *gdbarch)
Definition arch-utils.c:993
int legacy_register_sim_regno(struct gdbarch *gdbarch, int regnum)
Definition arch-utils.c:71
CORE_ADDR gdbarch_skip_prologue_noexcept(gdbarch *gdbarch, CORE_ADDR pc) noexcept
int generic_stack_frame_destroyed_p(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition arch-utils.c:162
void default_infcall_munmap(CORE_ADDR addr, CORE_ADDR size)
Definition arch-utils.c:974
void default_make_symbol_special(struct symbol *sym, struct objfile *objfile)
Definition arch-utils.c:218
bool default_tagged_address_p(struct gdbarch *gdbarch, struct value *address)
Definition arch-utils.c:106
set_arch
Definition arch-utils.c:520
@ set_arch_manual
Definition arch-utils.c:520
@ set_arch_auto
Definition arch-utils.c:520
int core_addr_greaterthan(CORE_ADDR lhs, CORE_ADDR rhs)
Definition arch-utils.c:183
bool default_memtag_matches_p(struct gdbarch *gdbarch, struct value *address)
Definition arch-utils.c:115
CORE_ADDR core_addr_identity(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition arch-utils.c:191
static const struct bfd_arch_info * target_architecture_user
Definition arch-utils.c:522
static void set_endian(const char *ignore_args, int from_tty, struct cmd_list_element *c)
Definition arch-utils.c:400
static const struct bfd_arch_info * choose_architecture_for_target(const struct target_desc *target_desc, const struct bfd_arch_info *selected)
Definition arch-utils.c:449
obstack * gdbarch_obstack(gdbarch *arch)
static enum bfd_endian target_byte_order_user
Definition arch-utils.c:357
const gdb_byte * default_breakpoint_from_pc(struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
Definition arch-utils.c:874
bool default_dwarf2_omit_typedef_p(struct type *target_type, const char *producer, const char *name)
int core_addr_lessthan(CORE_ADDR lhs, CORE_ADDR rhs)
Definition arch-utils.c:177
enum bfd_endian selected_byte_order(void)
Definition arch-utils.c:372
void _initialize_gdbarch_utils()
std::string default_memtag_to_string(struct gdbarch *gdbarch, struct value *tag)
Definition arch-utils.c:97
std::vector< const char * > gdbarch_printable_names()
int generic_convert_register_p(struct gdbarch *gdbarch, int regnum, struct type *type)
Definition arch-utils.c:320
bool default_displaced_step_hw_singlestep(struct gdbarch *gdbarch)
Definition arch-utils.c:48
int no_op_reg_to_regnum(struct gdbarch *gdbarch, int reg)
Definition arch-utils.c:204
static const char endian_big[]
Definition arch-utils.c:359
struct gdbarch_tdep_base * gdbarch_tdep_1(struct gdbarch *gdbarch)
int default_has_shared_address_space(struct gdbarch *gdbarch)
Definition arch-utils.c:855
int default_stabs_argument_has_addr(struct gdbarch *gdbarch, struct type *type)
Definition arch-utils.c:327
std::string default_gcc_target_options(struct gdbarch *gdbarch)
Definition arch-utils.c:983
bool default_set_memtags(struct gdbarch *gdbarch, struct value *address, size_t length, const gdb::byte_vector &tags, memtag_type tag_type)
Definition arch-utils.c:124
const char * selected_architecture_name(void)
Definition arch-utils.c:527
int default_vsyscall_range(struct gdbarch *gdbarch, struct mem_range *range)
Definition arch-utils.c:349
void default_coff_make_msymbol_special(int val, struct minimal_symbol *msym)
Definition arch-utils.c:210
int cannot_register_not(struct gdbarch *gdbarch, int regnum)
Definition arch-utils.c:249
static CORE_ADDR default_update_call_site_pc(struct gdbarch *gdbarch, CORE_ADDR pc)
bool default_in_indirect_branch_thunk(gdbarch *gdbarch, CORE_ADDR pc)
void default_gen_return_address(struct gdbarch *gdbarch, struct agent_expr *ax, struct axs_value *value, CORE_ADDR scope)
Definition arch-utils.c:891
int default_return_in_first_hidden_param_p(struct gdbarch *gdbarch, struct type *type)
Definition arch-utils.c:899
bool default_program_breakpoint_here_p(struct gdbarch *gdbarch, CORE_ADDR address)
Definition arch-utils.c:926
static void show_architecture(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition arch-utils.c:539
int default_code_of_frame_writable(struct gdbarch *gdbarch, frame_info_ptr frame)
Definition arch-utils.c:168
CORE_ADDR generic_skip_solib_resolver(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition arch-utils.c:149
static struct gdbarch_registration * gdbarch_registry
struct gdbarch_list * gdbarch_list_lookup_by_info(struct gdbarch_list *arches, const struct gdbarch_info *info)
static void show_endian(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition arch-utils.c:380
enum return_value_convention default_gdbarch_return_value(struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, struct value **read_value, const gdb_byte *writebuf)
int default_remote_register_number(struct gdbarch *gdbarch, int regno)
Definition arch-utils.c:340
int default_insn_is_call(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition arch-utils.c:908
CORE_ADDR default_adjust_dwarf2_addr(CORE_ADDR pc)
Definition arch-utils.c:226
CORE_ADDR default_infcall_mmap(CORE_ADDR size, unsigned prot)
Definition arch-utils.c:968
struct gdbarch * gdbarch_find_by_info(struct gdbarch_info info)
gdbarch_virtual_frame_pointer_ftype legacy_virtual_frame_pointer
gdbarch_convert_from_func_ptr_addr_ftype convert_from_func_ptr_addr_identity
struct gdbarch * gdbarch
Definition inferior.h:661
gdbarch * arch() const
Definition regcache.c:231
void raw_supply(int regnum, const void *buf) override
Definition regcache.c:1062
struct cmd_list_element * showlist
Definition cli-cmds.c:127
struct cmd_list_element * setlist
Definition cli-cmds.c:119
struct cmd_list_element * showdebuglist
Definition cli-cmds.c:167
struct cmd_list_element * setdebuglist
Definition cli-cmds.c:165
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *target, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
Definition cli-decode.c:294
set_show_commands add_setshow_enum_cmd(const char *name, enum command_class theclass, const char *const *enumlist, const char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:688
set_show_commands add_setshow_zuinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
@ class_maintenance
Definition command.h:65
@ class_support
Definition command.h:58
#define DEFAULT_BFD_ARCH
Definition config.h:38
#define DEFAULT_BFD_VEC
Definition config.h:41
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
Definition defs.h:515
return_value_convention
Definition defs.h:257
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
Definition frame.c:3027
bool has_stack_frames()
Definition frame.c:1859
frame_info_ptr get_selected_frame(const char *message)
Definition frame.c:1888
int gdbarch_pc_regnum(struct gdbarch *gdbarch)
Definition gdbarch.c:2054
int gdbarch_half_bit(struct gdbarch *gdbarch)
Definition gdbarch.c:1534
const gdb_byte * gdbarch_breakpoint_from_pc(struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
Definition gdbarch.c:2777
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition gdbarch.c:1396
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
Definition gdbarch.c:2173
const struct floatformat ** gdbarch_half_format(struct gdbarch *gdbarch)
Definition gdbarch.c:1551
const struct floatformat ** gdbarch_bfloat16_format(struct gdbarch *gdbarch)
Definition gdbarch.c:1517
CORE_ADDR gdbarch_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR ip)
Definition gdbarch.c:2695
int gdbarch_num_regs(struct gdbarch *gdbarch)
Definition gdbarch.c:1930
int gdbarch_float_bit(struct gdbarch *gdbarch)
Definition gdbarch.c:1568
int gdbarch_deprecated_fp_regnum(struct gdbarch *gdbarch)
Definition gdbarch.c:2228
int gdbarch_sp_regnum(struct gdbarch *gdbarch)
Definition gdbarch.c:2037
const struct floatformat ** gdbarch_double_format(struct gdbarch *gdbarch)
Definition gdbarch.c:1619
int gdbarch_long_double_bit(struct gdbarch *gdbarch)
Definition gdbarch.c:1636
int gdbarch_bfloat16_bit(struct gdbarch *gdbarch)
Definition gdbarch.c:1500
const gdb_byte * gdbarch_sw_breakpoint_from_kind(struct gdbarch *gdbarch, int kind, int *size)
Definition gdbarch.c:2811
const struct floatformat ** gdbarch_float_format(struct gdbarch *gdbarch)
Definition gdbarch.c:1585
const struct floatformat ** gdbarch_long_double_format(struct gdbarch *gdbarch)
Definition gdbarch.c:1653
const struct bfd_arch_info * gdbarch_bfd_arch_info(struct gdbarch *gdbarch)
Definition gdbarch.c:1387
bool gdbarch_software_single_step_p(struct gdbarch *gdbarch)
Definition gdbarch.c:3288
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
Definition gdbarch.c:1722
int gdbarch_double_bit(struct gdbarch *gdbarch)
Definition gdbarch.c:1602
int gdbarch_breakpoint_kind_from_pc(struct gdbarch *gdbarch, CORE_ADDR *pcptr)
Definition gdbarch.c:2794
void gdbarch_dump(struct gdbarch *gdbarch, struct ui_file *file)
Definition gdbarch.c:537
static void verify_gdbarch(struct gdbarch *gdbarch)
Definition gdbarch.c:289
gdb::function_view< void(ULONGEST count)> read_core_file_mappings_pre_loop_ftype
Definition gdbarch.h:143
bool gdbarch_supports_arch_info_ftype(const struct bfd_arch_info *)
Definition gdbarch.h:273
struct gdbarch * gdbarch_init_ftype(struct gdbarch_info info, struct gdbarch_list *arches)
Definition gdbarch.h:271
memtag_type
Definition gdbarch.h:130
void gdbarch_dump_tdep_ftype(struct gdbarch *gdbarch, struct ui_file *file)
Definition gdbarch.h:272
gdb::function_view< void(int num, ULONGEST start, ULONGEST end, ULONGEST file_ofs, const char *filename, const bfd_build_id *build_id)> read_core_file_mappings_loop_ftype
Definition gdbarch.h:146
#define core_bfd
Definition gdbcore.h:130
size_t size
Definition go32-nat.c:239
struct inferior * current_inferior(void)
Definition inferior.c:55
struct language_pass_by_ref_info language_pass_by_reference(struct type *type)
Definition language.c:543
observable< struct gdbarch * > architecture_changed
info(Component c)
Definition gdbarch.py:41
CORE_ADDR entry_point_address(void)
Definition objfiles.c:371
#define GDB_OSABI_DEFAULT
Definition osabi.c:31
enum gdb_osabi gdbarch_lookup_osabi(bfd *abfd)
Definition osabi.c:237
const char * gdbarch_osabi_name(enum gdb_osabi osabi)
Definition osabi.c:90
@ GDB_OSABI_NONE
Definition osabi.h:27
@ GDB_OSABI_UNKNOWN
Definition osabi.h:26
struct program_space * current_program_space
Definition progspace.c:40
CORE_ADDR regcache_read_pc(struct regcache *regcache)
Definition regcache.c:1333
int register_size(struct gdbarch *gdbarch, int regnum)
Definition regcache.c:170
void regcache_write_pc(struct regcache *regcache, CORE_ADDR pc)
Definition regcache.c:1377
void registers_changed(void)
Definition regcache.c:580
@ LEGACY_SIM_REGNO_IGNORE
Definition sim-regno.h:36
bfd * abfd
Definition gdbarch.h:261
const struct bfd_arch_info * bfd_arch_info
Definition gdbarch.h:255
struct gdbarch * gdbarch
Definition gdbarch.h:243
struct gdbarch_list * next
Definition gdbarch.h:244
struct gdbarch_list * arches
gdbarch_dump_tdep_ftype * dump_tdep
gdbarch_init_ftype * init
enum bfd_architecture bfd_architecture
gdbarch_supports_arch_info_ftype * supports_arch_info
struct gdbarch_registration * next
gdbarch_dump_tdep_ftype * dump_tdep
Definition gdbarch.c:49
registry< gdbarch > registry_fields
Definition gdbarch.c:38
const struct bfd_arch_info * bfd_arch_info
Definition gdbarch.c:41
bool initialized_p
Definition gdbarch.c:33
auto_obstack obstack
Definition gdbarch.c:36
bfd * exec_bfd() const
Definition progspace.h:268
Definition value.h:90
static registry< T > * get(T *obj)
Definition registry.h:41
cmd_list_element * set
Definition command.h:422
Definition value.h:130
static struct value * allocate(struct type *type)
Definition value.c:957
struct value::@203::@204 reg
CORE_ADDR address
Definition value.h:658
const struct bfd_arch_info * tdesc_architecture(const struct target_desc *target_desc)
const struct target_desc * target_current_description(void)
enum gdb_osabi tdesc_osabi(const struct target_desc *target_desc)
int tdesc_compatible_p(const struct target_desc *target_desc, const struct bfd_arch_info *arch)
scoped_restore_tmpl< int > make_scoped_restore_show_memory_breakpoints(int show)
Definition target.c:1667
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition target.c:1785
void gdb_printf(struct ui_file *stream, const char *format,...)
Definition utils.c:1886
#define gdb_stderr
Definition utils.h:187
#define gdb_stdlog
Definition utils.h:190
#define gdb_stdout
Definition utils.h:182
const char target_name[]
Definition version.c:4