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