Refresh regs window in display_registers_from
[deliverable/binutils-gdb.git] / gdb / arm-pikeos-tdep.c
1 /* Copyright (C) 2016-2021 Free Software Foundation, Inc.
2
3 This file is part of GDB.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18 #include "defs.h"
19 #include "objfiles.h"
20 #include "arm-tdep.h"
21 #include "osabi.h"
22
23 /* The gdbarch_register_osabi handler for ARM PikeOS; it performs
24 the gdbarch initialization for that platform. */
25
26 static void
27 arm_pikeos_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
28 {
29 /* Single stepping. */
30 set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
31 }
32
33 /* The ARM PikeOS OSABI sniffer (see gdbarch_register_osabi_sniffer).
34 Returns GDB_OSABI_PIKEOS if the given BFD is a PikeOS binary,
35 GDB_OSABI_UNKNOWN otherwise. */
36
37 static enum gdb_osabi
38 arm_pikeos_osabi_sniffer (bfd *abfd)
39 {
40 long number_of_symbols;
41 long i;
42 int pikeos_stack_found = 0;
43 int pikeos_stack_size_found = 0;
44
45 /* The BFD target of PikeOS is really just standard elf, so we
46 cannot use it to detect this variant. The only common thing that
47 may be found in PikeOS modules are symbols _vm_stack/__p4_stack and
48 _vm_stack_size/__p4_stack_end. They are used to specify the stack
49 location and size; and defined by the default linker script.
50
51 OS ABI sniffers are called before the minimal symtabs are
52 created. So inspect the symbol table using BFD. */
53
54 long storage_needed = bfd_get_symtab_upper_bound (abfd);
55 if (storage_needed <= 0)
56 return GDB_OSABI_UNKNOWN;
57
58 gdb::unique_xmalloc_ptr<asymbol *> symbol_table
59 ((asymbol **) xmalloc (storage_needed));
60 number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table.get ());
61
62 if (number_of_symbols <= 0)
63 return GDB_OSABI_UNKNOWN;
64
65 for (i = 0; i < number_of_symbols; i++)
66 {
67 const char *name = bfd_asymbol_name (symbol_table.get ()[i]);
68
69 if (strcmp (name, "_vm_stack") == 0
70 || strcmp (name, "__p4_stack") == 0)
71 pikeos_stack_found = 1;
72
73 if (strcmp (name, "_vm_stack_size") == 0
74 || strcmp (name, "__p4_stack_end") == 0)
75 pikeos_stack_size_found = 1;
76 }
77
78 if (pikeos_stack_found && pikeos_stack_size_found)
79 return GDB_OSABI_PIKEOS;
80 else
81 return GDB_OSABI_UNKNOWN;
82 }
83
84 void _initialize_arm_pikeos_tdep ();
85 void
86 _initialize_arm_pikeos_tdep ()
87 {
88 /* Register the sniffer for the PikeOS targets. */
89 gdbarch_register_osabi_sniffer (bfd_arch_arm, bfd_target_elf_flavour,
90 arm_pikeos_osabi_sniffer);
91 gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_PIKEOS,
92 arm_pikeos_init_abi);
93 }
This page took 0.046815 seconds and 4 git commands to generate.