GDB (xrefs)
/tmp/gdb-7.10/gdb/arch-utils.c
Go to the documentation of this file.
1 /* Dynamic architecture support for GDB, the GNU debugger.
2 
3  Copyright (C) 1998-2015 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 "buildsym.h"
24 #include "gdbcmd.h"
25 #include "inferior.h" /* enum CALL_DUMMY_LOCATION et al. */
26 #include "infrun.h"
27 #include "regcache.h"
28 #include "sim-regno.h"
29 #include "gdbcore.h"
30 #include "osabi.h"
31 #include "target-descriptions.h"
32 #include "objfiles.h"
33 #include "language.h"
34 #include "symtab.h"
35 
36 #include "version.h"
37 
38 #include "floatformat.h"
39 
40 
44  struct regcache *regs)
45 {
46  size_t len = gdbarch_max_insn_length (gdbarch);
47  gdb_byte *buf = xmalloc (len);
48 
49  read_memory (from, buf, len);
50  write_memory (to, buf, len);
51 
52  if (debug_displaced)
53  {
54  fprintf_unfiltered (gdb_stdlog, "displaced: copy %s->%s: ",
55  paddress (gdbarch, from), paddress (gdbarch, to));
57  }
58 
59  return (struct displaced_step_closure *) buf;
60 }
61 
62 
63 void
65  struct displaced_step_closure *closure)
66 {
67  xfree (closure);
68 }
69 
70 int
72  struct displaced_step_closure *closure)
73 {
74  return !gdbarch_software_single_step_p (gdbarch);
75 }
76 
79 {
80  CORE_ADDR addr;
81  int bp_len;
82 
83  addr = entry_point_address ();
84 
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);
89  addr += bp_len * 2;
90 
91  return addr;
92 }
93 
94 int
96 {
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
102  (below). */
103  if (gdbarch_register_name (gdbarch, regnum) != NULL
104  && gdbarch_register_name (gdbarch, regnum)[0] != '\0')
105  return regnum;
106  else
108 }
109 
110 CORE_ADDR
112 {
113  return 0;
114 }
115 
116 CORE_ADDR
118 {
119  return 0;
120 }
121 
122 int
124  CORE_ADDR pc, const char *name)
125 {
126  return 0;
127 }
128 
129 int
131 {
132  return 0;
133 }
134 
135 /* Helper functions for gdbarch_inner_than */
136 
137 int
139 {
140  return (lhs < rhs);
141 }
142 
143 int
145 {
146  return (lhs > rhs);
147 }
148 
149 /* Misc helper functions for targets. */
150 
151 CORE_ADDR
153 {
154  return addr;
155 }
156 
157 CORE_ADDR
159  struct target_ops *targ)
160 {
161  return addr;
162 }
163 
164 int
166 {
167  return reg;
168 }
169 
170 void
172 {
173  return;
174 }
175 
176 /* See arch-utils.h. */
177 
178 void
180 {
181  return;
182 }
183 
184 /* See arch-utils.h. */
185 
186 CORE_ADDR
188 {
189  return pc;
190 }
191 
192 /* See arch-utils.h. */
193 
194 CORE_ADDR
196 {
197  return addr;
198 }
199 
200 int
202 {
203  return 0;
204 }
205 
206 /* Legacy version of target_virtual_frame_pointer(). Assumes that
207  there is an gdbarch_deprecated_fp_regnum and that it is the same,
208  cooked or raw. */
209 
210 void
212  CORE_ADDR pc,
213  int *frame_regnum,
214  LONGEST *frame_offset)
215 {
216  /* FIXME: cagney/2002-09-13: This code is used when identifying the
217  frame pointer of the current PC. It is assuming that a single
218  register and an offset can determine this. I think it should
219  instead generate a byte code expression as that would work better
220  with things like Dwarf2's CFI. */
221  if (gdbarch_deprecated_fp_regnum (gdbarch) >= 0
222  && gdbarch_deprecated_fp_regnum (gdbarch)
223  < gdbarch_num_regs (gdbarch))
224  *frame_regnum = gdbarch_deprecated_fp_regnum (gdbarch);
225  else if (gdbarch_sp_regnum (gdbarch) >= 0
226  && gdbarch_sp_regnum (gdbarch)
227  < gdbarch_num_regs (gdbarch))
228  *frame_regnum = gdbarch_sp_regnum (gdbarch);
229  else
230  /* Should this be an internal error? I guess so, it is reflecting
231  an architectural limitation in the current design. */
232  internal_error (__FILE__, __LINE__,
233  _("No virtual frame pointer available"));
234  *frame_offset = 0;
235 }
236 
237 
238 int
240  struct type *type)
241 {
242  return 0;
243 }
244 
245 int
247 {
248  return 0;
249 }
250 
251 int
253  struct regcache *regcache)
254 {
255  return 0;
256 }
257 
258 int
260  int regno)
261 {
262  return regno;
263 }
264 
265 /* See arch-utils.h. */
266 
267 int
269 {
270  return 0;
271 }
272 
273 
274 /* Functions to manipulate the endianness of the target. */
275 
276 static int target_byte_order_user = BFD_ENDIAN_UNKNOWN;
277 
278 static const char endian_big[] = "big";
279 static const char endian_little[] = "little";
280 static const char endian_auto[] = "auto";
281 static const char *const endian_enum[] =
282 {
283  endian_big,
285  endian_auto,
286  NULL,
287 };
288 static const char *set_endian_string;
289 
290 enum bfd_endian
292 {
293  return target_byte_order_user;
294 }
295 
296 /* Called by ``show endian''. */
297 
298 static void
299 show_endian (struct ui_file *file, int from_tty, struct cmd_list_element *c,
300  const char *value)
301 {
302  if (target_byte_order_user == BFD_ENDIAN_UNKNOWN)
303  if (gdbarch_byte_order (get_current_arch ()) == BFD_ENDIAN_BIG)
304  fprintf_unfiltered (file, _("The target endianness is set automatically "
305  "(currently big endian)\n"));
306  else
307  fprintf_unfiltered (file, _("The target endianness is set automatically "
308  "(currently little endian)\n"));
309  else
310  if (target_byte_order_user == BFD_ENDIAN_BIG)
311  fprintf_unfiltered (file,
312  _("The target is assumed to be big endian\n"));
313  else
314  fprintf_unfiltered (file,
315  _("The target is assumed to be little endian\n"));
316 }
317 
318 static void
319 set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c)
320 {
321  struct gdbarch_info info;
322 
323  gdbarch_info_init (&info);
324 
326  {
327  target_byte_order_user = BFD_ENDIAN_UNKNOWN;
328  if (! gdbarch_update_p (info))
329  internal_error (__FILE__, __LINE__,
330  _("set_endian: architecture update failed"));
331  }
332  else if (set_endian_string == endian_little)
333  {
334  info.byte_order = BFD_ENDIAN_LITTLE;
335  if (! gdbarch_update_p (info))
336  printf_unfiltered (_("Little endian target not supported by GDB\n"));
337  else
338  target_byte_order_user = BFD_ENDIAN_LITTLE;
339  }
340  else if (set_endian_string == endian_big)
341  {
342  info.byte_order = BFD_ENDIAN_BIG;
343  if (! gdbarch_update_p (info))
344  printf_unfiltered (_("Big endian target not supported by GDB\n"));
345  else
346  target_byte_order_user = BFD_ENDIAN_BIG;
347  }
348  else
349  internal_error (__FILE__, __LINE__,
350  _("set_endian: bad value"));
351 
352  show_endian (gdb_stdout, from_tty, NULL, NULL);
353 }
354 
355 /* Given SELECTED, a currently selected BFD architecture, and
356  TARGET_DESC, the current target description, return what
357  architecture to use.
358 
359  SELECTED may be NULL, in which case we return the architecture
360  associated with TARGET_DESC. If SELECTED specifies a variant
361  of the architecture associtated with TARGET_DESC, return the
362  more specific of the two.
363 
364  If SELECTED is a different architecture, but it is accepted as
365  compatible by the target, we can use the target architecture.
366 
367  If SELECTED is obviously incompatible, warn the user. */
368 
369 static const struct bfd_arch_info *
371  const struct bfd_arch_info *selected)
372 {
373  const struct bfd_arch_info *from_target = tdesc_architecture (target_desc);
374  const struct bfd_arch_info *compat1, *compat2;
375 
376  if (selected == NULL)
377  return from_target;
378 
379  if (from_target == NULL)
380  return selected;
381 
382  /* struct bfd_arch_info objects are singletons: that is, there's
383  supposed to be exactly one instance for a given machine. So you
384  can tell whether two are equivalent by comparing pointers. */
385  if (from_target == selected)
386  return selected;
387 
388  /* BFD's 'A->compatible (A, B)' functions return zero if A and B are
389  incompatible. But if they are compatible, it returns the 'more
390  featureful' of the two arches. That is, if A can run code
391  written for B, but B can't run code written for A, then it'll
392  return A.
393 
394  Some targets (e.g. MIPS as of 2006-12-04) don't fully
395  implement this, instead always returning NULL or the first
396  argument. We detect that case by checking both directions. */
397 
398  compat1 = selected->compatible (selected, from_target);
399  compat2 = from_target->compatible (from_target, selected);
400 
401  if (compat1 == NULL && compat2 == NULL)
402  {
403  /* BFD considers the architectures incompatible. Check our
404  target description whether it accepts SELECTED as compatible
405  anyway. */
406  if (tdesc_compatible_p (target_desc, selected))
407  return from_target;
408 
409  warning (_("Selected architecture %s is not compatible "
410  "with reported target architecture %s"),
411  selected->printable_name, from_target->printable_name);
412  return selected;
413  }
414 
415  if (compat1 == NULL)
416  return compat2;
417  if (compat2 == NULL)
418  return compat1;
419  if (compat1 == compat2)
420  return compat1;
421 
422  /* If the two didn't match, but one of them was a default
423  architecture, assume the more specific one is correct. This
424  handles the case where an executable or target description just
425  says "mips", but the other knows which MIPS variant. */
426  if (compat1->the_default)
427  return compat2;
428  if (compat2->the_default)
429  return compat1;
430 
431  /* We have no idea which one is better. This is a bug, but not
432  a critical problem; warn the user. */
433  warning (_("Selected architecture %s is ambiguous with "
434  "reported target architecture %s"),
435  selected->printable_name, from_target->printable_name);
436  return selected;
437 }
438 
439 /* Functions to manipulate the architecture of the target. */
440 
442 
443 static const struct bfd_arch_info *target_architecture_user;
444 
445 static const char *set_architecture_string;
446 
447 const char *
449 {
450  if (target_architecture_user == NULL)
451  return NULL;
452  else
454 }
455 
456 /* Called if the user enters ``show architecture'' without an
457  argument. */
458 
459 static void
460 show_architecture (struct ui_file *file, int from_tty,
461  struct cmd_list_element *c, const char *value)
462 {
463  if (target_architecture_user == NULL)
464  fprintf_filtered (file, _("The target architecture is set "
465  "automatically (currently %s)\n"),
466  gdbarch_bfd_arch_info (get_current_arch ())->printable_name);
467  else
468  fprintf_filtered (file, _("The target architecture is assumed to be %s\n"),
470 }
471 
472 
473 /* Called if the user enters ``set architecture'' with or without an
474  argument. */
475 
476 static void
477 set_architecture (char *ignore_args, int from_tty, struct cmd_list_element *c)
478 {
479  struct gdbarch_info info;
480 
481  gdbarch_info_init (&info);
482 
483  if (strcmp (set_architecture_string, "auto") == 0)
484  {
486  if (!gdbarch_update_p (info))
487  internal_error (__FILE__, __LINE__,
488  _("could not select an architecture automatically"));
489  }
490  else
491  {
492  info.bfd_arch_info = bfd_scan_arch (set_architecture_string);
493  if (info.bfd_arch_info == NULL)
494  internal_error (__FILE__, __LINE__,
495  _("set_architecture: bfd_scan_arch failed"));
496  if (gdbarch_update_p (info))
498  else
499  printf_unfiltered (_("Architecture `%s' not recognized.\n"),
501  }
502  show_architecture (gdb_stdout, from_tty, NULL, NULL);
503 }
504 
505 /* Try to select a global architecture that matches "info". Return
506  non-zero if the attempt succeeds. */
507 int
509 {
510  struct gdbarch *new_gdbarch;
511 
512  /* Check for the current file. */
513  if (info.abfd == NULL)
514  info.abfd = exec_bfd;
515  if (info.abfd == NULL)
516  info.abfd = core_bfd;
517 
518  /* Check for the current target description. */
519  if (info.target_desc == NULL)
521 
522  new_gdbarch = gdbarch_find_by_info (info);
523 
524  /* If there no architecture by that name, reject the request. */
525  if (new_gdbarch == NULL)
526  {
527  if (gdbarch_debug)
528  fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: "
529  "Architecture not found\n");
530  return 0;
531  }
532 
533  /* If it is the same old architecture, accept the request (but don't
534  swap anything). */
535  if (new_gdbarch == target_gdbarch ())
536  {
537  if (gdbarch_debug)
538  fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: "
539  "Architecture %s (%s) unchanged\n",
540  host_address_to_string (new_gdbarch),
541  gdbarch_bfd_arch_info (new_gdbarch)->printable_name);
542  return 1;
543  }
544 
545  /* It's a new architecture, swap it in. */
546  if (gdbarch_debug)
547  fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: "
548  "New architecture %s (%s) selected\n",
549  host_address_to_string (new_gdbarch),
550  gdbarch_bfd_arch_info (new_gdbarch)->printable_name);
551  set_target_gdbarch (new_gdbarch);
552 
553  return 1;
554 }
555 
556 /* Return the architecture for ABFD. If no suitable architecture
557  could be find, return NULL. */
558 
559 struct gdbarch *
560 gdbarch_from_bfd (bfd *abfd)
561 {
562  struct gdbarch_info info;
563  gdbarch_info_init (&info);
564 
565  info.abfd = abfd;
566  return gdbarch_find_by_info (info);
567 }
568 
569 /* Set the dynamic target-system-dependent parameters (architecture,
570  byte-order) using information found in the BFD */
571 
572 void
574 {
575  struct gdbarch_info info;
576  struct gdbarch *gdbarch;
577 
578  gdbarch_info_init (&info);
579  info.abfd = abfd;
581  gdbarch = gdbarch_find_by_info (info);
582 
583  if (gdbarch == NULL)
584  error (_("Architecture of file not recognized."));
585  set_target_gdbarch (gdbarch);
586 }
587 
588 /* Initialize the current architecture. Update the ``set
589  architecture'' command so that it specifies a list of valid
590  architectures. */
591 
592 #ifdef DEFAULT_BFD_ARCH
593 extern const bfd_arch_info_type DEFAULT_BFD_ARCH;
594 static const bfd_arch_info_type *default_bfd_arch = &DEFAULT_BFD_ARCH;
595 #else
596 static const bfd_arch_info_type *default_bfd_arch;
597 #endif
598 
599 #ifdef DEFAULT_BFD_VEC
600 extern const bfd_target DEFAULT_BFD_VEC;
601 static const bfd_target *default_bfd_vec = &DEFAULT_BFD_VEC;
602 #else
603 static const bfd_target *default_bfd_vec;
604 #endif
605 
606 static int default_byte_order = BFD_ENDIAN_UNKNOWN;
607 
608 void
610 {
611  const char **arches = gdbarch_printable_names ();
612  struct gdbarch_info info;
613 
614  /* determine a default architecture and byte order. */
615  gdbarch_info_init (&info);
616 
617  /* Find a default architecture. */
618  if (default_bfd_arch == NULL)
619  {
620  /* Choose the architecture by taking the first one
621  alphabetically. */
622  const char *chosen = arches[0];
623  const char **arch;
624  for (arch = arches; *arch != NULL; arch++)
625  {
626  if (strcmp (*arch, chosen) < 0)
627  chosen = *arch;
628  }
629  if (chosen == NULL)
630  internal_error (__FILE__, __LINE__,
631  _("initialize_current_architecture: No arch"));
632  default_bfd_arch = bfd_scan_arch (chosen);
633  if (default_bfd_arch == NULL)
634  internal_error (__FILE__, __LINE__,
635  _("initialize_current_architecture: Arch not found"));
636  }
637 
639 
640  /* Take several guesses at a byte order. */
641  if (default_byte_order == BFD_ENDIAN_UNKNOWN
642  && default_bfd_vec != NULL)
643  {
644  /* Extract BFD's default vector's byte order. */
645  switch (default_bfd_vec->byteorder)
646  {
647  case BFD_ENDIAN_BIG:
648  default_byte_order = BFD_ENDIAN_BIG;
649  break;
650  case BFD_ENDIAN_LITTLE:
651  default_byte_order = BFD_ENDIAN_LITTLE;
652  break;
653  default:
654  break;
655  }
656  }
657  if (default_byte_order == BFD_ENDIAN_UNKNOWN)
658  {
659  /* look for ``*el-*'' in the target name. */
660  const char *chp;
661  chp = strchr (target_name, '-');
662  if (chp != NULL
663  && chp - 2 >= target_name
664  && startswith (chp - 2, "el"))
665  default_byte_order = BFD_ENDIAN_LITTLE;
666  }
667  if (default_byte_order == BFD_ENDIAN_UNKNOWN)
668  {
669  /* Wire it to big-endian!!! */
670  default_byte_order = BFD_ENDIAN_BIG;
671  }
672 
674  info.byte_order_for_code = info.byte_order;
675 
676  if (! gdbarch_update_p (info))
677  internal_error (__FILE__, __LINE__,
678  _("initialize_current_architecture: Selection of "
679  "initial architecture failed"));
680 
681  /* Create the ``set architecture'' command appending ``auto'' to the
682  list of architectures. */
683  {
684  /* Append ``auto''. */
685  int nr;
686  for (nr = 0; arches[nr] != NULL; nr++);
687  arches = xrealloc (arches, sizeof (char*) * (nr + 2));
688  arches[nr + 0] = "auto";
689  arches[nr + 1] = NULL;
690  add_setshow_enum_cmd ("architecture", class_support,
691  arches, &set_architecture_string,
692  _("Set architecture of target."),
693  _("Show architecture of target."), NULL,
695  &setlist, &showlist);
696  add_alias_cmd ("processor", "architecture", class_support, 1, &setlist);
697  }
698 }
699 
700 
701 /* Initialize a gdbarch info to values that will be automatically
702  overridden. Note: Originally, this ``struct info'' was initialized
703  using memset(0). Unfortunately, that ran into problems, namely
704  BFD_ENDIAN_BIG is zero. An explicit initialization function that
705  can explicitly set each field to a well defined value is used. */
706 
707 void
709 {
710  memset (info, 0, sizeof (struct gdbarch_info));
711  info->byte_order = BFD_ENDIAN_UNKNOWN;
712  info->byte_order_for_code = info->byte_order;
714 }
715 
716 /* Similar to init, but this time fill in the blanks. Information is
717  obtained from the global "set ..." options and explicitly
718  initialized INFO fields. */
719 
720 void
722 {
723  /* "(gdb) set architecture ...". */
724  if (info->bfd_arch_info == NULL
727  /* From the file. */
728  if (info->bfd_arch_info == NULL
729  && info->abfd != NULL
730  && bfd_get_arch (info->abfd) != bfd_arch_unknown
731  && bfd_get_arch (info->abfd) != bfd_arch_obscure)
732  info->bfd_arch_info = bfd_get_arch_info (info->abfd);
733  /* From the target. */
734  if (info->target_desc != NULL)
736  (info->target_desc, info->bfd_arch_info);
737  /* From the default. */
738  if (info->bfd_arch_info == NULL)
740 
741  /* "(gdb) set byte-order ...". */
742  if (info->byte_order == BFD_ENDIAN_UNKNOWN
743  && target_byte_order_user != BFD_ENDIAN_UNKNOWN)
745  /* From the INFO struct. */
746  if (info->byte_order == BFD_ENDIAN_UNKNOWN
747  && info->abfd != NULL)
748  info->byte_order = (bfd_big_endian (info->abfd) ? BFD_ENDIAN_BIG
749  : bfd_little_endian (info->abfd) ? BFD_ENDIAN_LITTLE
750  : BFD_ENDIAN_UNKNOWN);
751  /* From the default. */
752  if (info->byte_order == BFD_ENDIAN_UNKNOWN)
754  info->byte_order_for_code = info->byte_order;
755 
756  /* "(gdb) set osabi ...". Handled by gdbarch_lookup_osabi. */
757  /* From the manual override, or from file. */
758  if (info->osabi == GDB_OSABI_UNINITIALIZED)
759  info->osabi = gdbarch_lookup_osabi (info->abfd);
760  /* From the target. */
761  if (info->osabi == GDB_OSABI_UNKNOWN && info->target_desc != NULL)
762  info->osabi = tdesc_osabi (info->target_desc);
763  /* From the configured default. */
764 #ifdef GDB_OSABI_DEFAULT
765  if (info->osabi == GDB_OSABI_UNKNOWN)
766  info->osabi = GDB_OSABI_DEFAULT;
767 #endif
768 
769  /* Must have at least filled in the architecture. */
770  gdb_assert (info->bfd_arch_info != NULL);
771 }
772 
773 /* Return "current" architecture. If the target is running, this is
774  the architecture of the selected frame. Otherwise, the "current"
775  architecture defaults to the target architecture.
776 
777  This function should normally be called solely by the command
778  interpreter routines to determine the architecture to execute a
779  command in. */
780 struct gdbarch *
782 {
783  if (has_stack_frames ())
784  return get_frame_arch (get_selected_frame (NULL));
785  else
786  return target_gdbarch ();
787 }
788 
789 int
791 {
792  /* Simply say no. In most unix-like targets each inferior/process
793  has its own address space. */
794  return 0;
795 }
796 
797 int
799  CORE_ADDR addr, int *isize, char **msg)
800 {
801  /* We don't know if maybe the target has some way to do fast
802  tracepoints that doesn't need gdbarch, so always say yes. */
803  if (msg)
804  *msg = NULL;
805  return 1;
806 }
807 
808 void
810  int *kindptr)
811 {
812  gdbarch_breakpoint_from_pc (gdbarch, pcptr, kindptr);
813 }
814 
815 void
817  struct agent_expr *ax, struct axs_value *value,
818  CORE_ADDR scope)
819 {
820  error (_("This architecture has no method to collect a return address."));
821 }
822 
823 int
825  struct type *type)
826 {
827  /* Usually, the return value's address is stored the in the "first hidden"
828  parameter if the return value should be passed by reference, as
829  specified in ABI. */
830  return language_pass_by_reference (type);
831 }
832 
834 {
835  return 0;
836 }
837 
839 {
840  return 0;
841 }
842 
844 {
845  return 0;
846 }
847 
848 void
850 {
851  struct gdbarch *gdbarch = get_regcache_arch (regcache);
852  CORE_ADDR current_pc = regcache_read_pc (regcache);
853  const gdb_byte *bp_insn;
854  int bp_len;
855 
856  bp_insn = gdbarch_breakpoint_from_pc (gdbarch, &current_pc, &bp_len);
857  current_pc += bp_len;
858  regcache_write_pc (regcache, current_pc);
859 }
860 
861 CORE_ADDR
863 {
864  error (_("This target does not support inferior memory allocation by mmap."));
865 }
866 
867 void
869 {
870  /* Memory reserved by inferior mmap is kept leaked. */
871 }
872 
873 /* -mcmodel=large is used so that no GOT (Global Offset Table) is needed to be
874  created in inferior memory by GDB (normally it is set by ld.so). */
875 
876 char *
878 {
879  return xstrprintf ("-m%d%s", gdbarch_ptr_bit (gdbarch),
880  gdbarch_ptr_bit (gdbarch) == 64 ? " -mcmodel=large" : "");
881 }
882 
883 /* gdbarch gnu_triplet_regexp method. */
884 
885 const char *
887 {
888  return gdbarch_bfd_arch_info (gdbarch)->arch_name;
889 }
890 
891 /* Default method for gdbarch_addressable_memory_unit_size. By default, a memory byte has
892  a size of 1 octet. */
893 
894 int
896 {
897  return 1;
898 }
899 
900 /* -Wmissing-prototypes */
902 
903 void
905 {
908  _("Set endianness of target."),
909  _("Show endianness of target."),
910  NULL, set_endian, show_endian,
911  &setlist, &showlist);
912 }
struct gdbarch * target_gdbarch(void)
Definition: gdbarch.c:5143
int gdbarch_software_single_step_p(struct gdbarch *gdbarch)
Definition: gdbarch.c:3009
struct frame_info * get_selected_frame(const char *message)
Definition: frame.c:1535
const bfd_target DEFAULT_BFD_VEC
bfd_vma CORE_ADDR
Definition: common-types.h:41
const char * default_gnu_triplet_regexp(struct gdbarch *gdbarch)
Definition: arch-utils.c:886
void displaced_step_dump_bytes(struct ui_file *file, const gdb_byte *buf, size_t len)
Definition: infrun.c:1615
void xfree(void *)
Definition: common-utils.c:97
struct gdbarch * get_regcache_arch(const struct regcache *regcache)
Definition: regcache.c:297
void 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_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition: cli-decode.c:487
void gdbarch_info_fill(struct gdbarch_info *info)
Definition: arch-utils.c:721
void warning(const char *fmt,...)
Definition: errors.c:26
int default_insn_is_jump(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition: arch-utils.c:843
int tdesc_compatible_p(const struct target_desc *target_desc, const struct bfd_arch_info *arch)
int generic_instruction_nullified(struct gdbarch *gdbarch, struct regcache *regcache)
Definition: arch-utils.c:252
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
Definition: gdbarch.c:1690
int gdbarch_deprecated_fp_regnum(struct gdbarch *gdbarch)
Definition: gdbarch.c:2182
struct ui_file * gdb_stdout
Definition: main.c:71
struct gdbarch * gdbarch_find_by_info(struct gdbarch_info info)
Definition: gdbarch.c:5008
void default_infcall_munmap(CORE_ADDR addr, CORE_ADDR size)
Definition: arch-utils.c:868
enum bfd_endian selected_byte_order(void)
Definition: arch-utils.c:291
void internal_error(const char *file, int line, const char *fmt,...)
Definition: errors.c:50
int gdbarch_update_p(struct gdbarch_info info)
Definition: arch-utils.c:508
const char ** gdbarch_printable_names(void)
Definition: gdbarch.c:4903
struct displaced_step_closure * simple_displaced_step_copy_insn(struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs)
Definition: arch-utils.c:42
Definition: ax.h:95
void default_make_symbol_special(struct symbol *sym, struct objfile *objfile)
Definition: arch-utils.c:179
void default_gen_return_address(struct gdbarch *gdbarch, struct agent_expr *ax, struct axs_value *value, CORE_ADDR scope)
Definition: arch-utils.c:816
int gdbarch_num_regs(struct gdbarch *gdbarch)
Definition: gdbarch.c:1898
#define _(String)
Definition: gdb_locale.h:40
const struct bfd_arch_info * bfd_arch_info
Definition: gdbarch.h:1549
void regcache_write_pc(struct regcache *regcache, CORE_ADDR pc)
Definition: regcache.c:1201
static int default_byte_order
Definition: arch-utils.c:606
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition: utils.c:2743
CORE_ADDR default_adjust_dwarf2_line(CORE_ADDR addr, int rel)
Definition: arch-utils.c:195
const char * selected_architecture_name(void)
Definition: arch-utils.c:448
const bfd_arch_info_type DEFAULT_BFD_ARCH
CORE_ADDR core_addr_identity(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition: arch-utils.c:152
struct cmd_list_element * setlist
Definition: cli-cmds.c:135
const char *const name
Definition: aarch64-tdep.c:68
int * from
Definition: varobj.h:282
int generic_convert_register_p(struct gdbarch *gdbarch, int regnum, struct type *type)
Definition: arch-utils.c:239
int default_insn_is_call(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition: arch-utils.c:833
ULONGEST gdbarch_max_insn_length(struct gdbarch *gdbarch)
Definition: gdbarch.c:3632
void initialize_file_ftype(void)
Definition: defs.h:281
void set_gdbarch_from_file(bfd *abfd)
Definition: arch-utils.c:573
int gdbarch_sp_regnum(struct gdbarch *gdbarch)
Definition: gdbarch.c:1981
int generic_stack_frame_destroyed_p(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: arch-utils.c:130
#define exec_bfd
Definition: exec.h:32
void fprintf_filtered(struct ui_file *stream, const char *format,...)
Definition: utils.c:2351
int generic_in_solib_return_trampoline(struct gdbarch *gdbarch, CORE_ADDR pc, const char *name)
Definition: arch-utils.c:123
int default_has_shared_address_space(struct gdbarch *gdbarch)
Definition: arch-utils.c:790
int debug_displaced
Definition: infrun.c:132
bfd * abfd
Definition: gdbarch.h:1557
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
Definition: utils.c:2361
int no_op_reg_to_regnum(struct gdbarch *gdbarch, int reg)
Definition: arch-utils.c:165
struct cmd_list_element * showlist
Definition: cli-cmds.c:143
int legacy_register_sim_regno(struct gdbarch *gdbarch, int regnum)
Definition: arch-utils.c:95
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition: gdbarch.c:1420
void legacy_virtual_frame_pointer(struct gdbarch *gdbarch, CORE_ADDR pc, int *frame_regnum, LONGEST *frame_offset)
Definition: arch-utils.c:211
static const char * set_architecture_string
Definition: arch-utils.c:445
enum gdb_osabi osabi
Definition: gdbarch.h:1563
Definition: gdbtypes.h:749
int default_displaced_step_hw_singlestep(struct gdbarch *gdbarch, struct displaced_step_closure *closure)
Definition: arch-utils.c:71
int default_vsyscall_range(struct gdbarch *gdbarch, struct mem_range *range)
Definition: arch-utils.c:268
unsigned int gdbarch_debug
Definition: gdbarch.c:60
struct gdbarch * get_current_arch(void)
Definition: arch-utils.c:781
#define gdb_assert(expr)
Definition: gdb_assert.h:33
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
Definition: gdbarch.c:2117
static int startswith(const char *string, const char *pattern)
Definition: common-utils.h:75
CORE_ADDR default_adjust_dwarf2_addr(CORE_ADDR pc)
Definition: arch-utils.c:187
struct cmd_list_element * add_alias_cmd(const char *name, const char *oldname, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
Definition: cli-decode.c:286
static const char endian_auto[]
Definition: arch-utils.c:280
Definition: value.c:65
char * xstrprintf(const char *format,...)
Definition: common-utils.c:107
int default_addressable_memory_unit_size(struct gdbarch *gdbarch)
Definition: arch-utils.c:895
int regnum
Definition: aarch64-tdep.c:69
void printf_unfiltered(const char *format,...)
Definition: utils.c:2399
CORE_ADDR generic_skip_trampoline_code(struct frame_info *frame, CORE_ADDR pc)
Definition: arch-utils.c:111
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: corefile.c:244
int default_insn_is_ret(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition: arch-utils.c:838
CORE_ADDR displaced_step_at_entry_point(struct gdbarch *gdbarch)
Definition: arch-utils.c:78
void * xmalloc(YYSIZE_T)
struct ui_file * gdb_stdlog
Definition: main.c:73
static const char endian_little[]
Definition: arch-utils.c:279
#define GDB_OSABI_DEFAULT
Definition: config.h:67
int default_fast_tracepoint_valid_at(struct gdbarch *gdbarch, CORE_ADDR addr, int *isize, char **msg)
Definition: arch-utils.c:798
const struct target_desc * target_current_description(void)
void default_skip_permanent_breakpoint(struct regcache *regcache)
Definition: arch-utils.c:849
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:370
Definition: regdef.h:22
const struct target_desc * target_desc
Definition: gdbarch.h:1566
Definition: value.c:172
PTR xrealloc(PTR ptr, size_t size)
Definition: common-utils.c:51
static const bfd_arch_info_type * default_bfd_arch
Definition: arch-utils.c:594
static void set_endian(char *ignore_args, int from_tty, struct cmd_list_element *c)
Definition: arch-utils.c:319
static int target_byte_order_user
Definition: arch-utils.c:276
int core_addr_lessthan(CORE_ADDR lhs, CORE_ADDR rhs)
Definition: arch-utils.c:138
bfd_byte gdb_byte
Definition: common-types.h:38
struct gdbarch * gdbarch_from_bfd(bfd *abfd)
Definition: arch-utils.c:560
int default_remote_register_number(struct gdbarch *gdbarch, int regno)
Definition: arch-utils.c:259
CORE_ADDR entry_point_address(void)
Definition: objfiles.c:392
CORE_ADDR generic_skip_solib_resolver(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: arch-utils.c:117
enum gdb_osabi tdesc_osabi(const struct target_desc *target_desc)
static const char endian_big[]
Definition: arch-utils.c:278
const gdb_byte * gdbarch_breakpoint_from_pc(struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
Definition: gdbarch.c:2662
void gdbarch_info_init(struct gdbarch_info *info)
Definition: arch-utils.c:708
CORE_ADDR regcache_read_pc(struct regcache *regcache)
Definition: regcache.c:1174
static const struct bfd_arch_info * target_architecture_user
Definition: arch-utils.c:443
static const char * set_endian_string
Definition: arch-utils.c:288
const struct bfd_arch_info * tdesc_architecture(const struct target_desc *target_desc)
void default_coff_make_msymbol_special(int val, struct minimal_symbol *msym)
Definition: arch-utils.c:171
const char target_name[]
Definition: version.c:4
CORE_ADDR default_infcall_mmap(CORE_ADDR size, unsigned prot)
Definition: arch-utils.c:862
enum bfd_endian byte_order_for_code
Definition: gdbarch.h:1554
Definition: symtab.h:703
const struct bfd_arch_info * gdbarch_bfd_arch_info(struct gdbarch *gdbarch)
Definition: gdbarch.c:1411
int default_stabs_argument_has_addr(struct gdbarch *gdbarch, struct type *type)
Definition: arch-utils.c:246
bfd * core_bfd
Definition: corefile.c:58
int core_addr_greaterthan(CORE_ADDR lhs, CORE_ADDR rhs)
Definition: arch-utils.c:144
int int * to
Definition: varobj.h:282
static const bfd_target * default_bfd_vec
Definition: arch-utils.c:601
void initialize_current_architecture(void)
Definition: arch-utils.c:609
static void show_architecture(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition: arch-utils.c:460
char * default_gcc_target_options(struct gdbarch *gdbarch)
Definition: arch-utils.c:877
static void show_endian(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition: arch-utils.c:299
void default_remote_breakpoint_from_pc(struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *kindptr)
Definition: arch-utils.c:809
enum gdb_osabi gdbarch_lookup_osabi(bfd *abfd)
Definition: osabi.c:243
void write_memory(CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len)
Definition: corefile.c:389
CORE_ADDR convert_from_func_ptr_addr_identity(struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ)
Definition: arch-utils.c:158
static const char *const endian_enum[]
Definition: arch-utils.c:281
static void set_architecture(char *ignore_args, int from_tty, struct cmd_list_element *c)
Definition: arch-utils.c:477
enum bfd_endian byte_order
Definition: gdbarch.h:1552
void set_target_gdbarch(struct gdbarch *new_gdbarch)
Definition: gdbarch.c:5131
int default_return_in_first_hidden_param_p(struct gdbarch *gdbarch, struct type *type)
Definition: arch-utils.c:824
initialize_file_ftype _initialize_gdbarch_utils
int has_stack_frames(void)
Definition: frame.c:1506
void error(const char *fmt,...)
Definition: errors.c:38
size_t size
Definition: go32-nat.c:242
int cannot_register_not(struct gdbarch *gdbarch, int regnum)
Definition: arch-utils.c:201
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
Definition: frame.c:2535
set_arch
Definition: arch-utils.c:441
long long LONGEST
Definition: common-types.h:52
int language_pass_by_reference(struct type *type)
Definition: language.c:650
const ULONGEST const LONGEST len
Definition: target.h:309
void simple_displaced_step_free_closure(struct gdbarch *gdbarch, struct displaced_step_closure *closure)
Definition: arch-utils.c:64