GDB (xrefs)
Loading...
Searching...
No Matches
arm-pikeos-tdep.c
Go to the documentation of this file.
1/* Copyright (C) 2016-2023 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
26static void
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
37static enum gdb_osabi
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
85void
87{
88 /* Register the sniffer for the PikeOS targets. */
89 gdbarch_register_osabi_sniffer (bfd_arch_arm, bfd_target_elf_flavour,
93}
const char *const name
void * xmalloc(YYSIZE_T)
static void arm_pikeos_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
static enum gdb_osabi arm_pikeos_osabi_sniffer(bfd *abfd)
void _initialize_arm_pikeos_tdep()
std::vector< CORE_ADDR > arm_software_single_step(struct regcache *regcache)
Definition arm-tdep.c:7283
void set_gdbarch_software_single_step(struct gdbarch *gdbarch, gdbarch_software_single_step_ftype *software_single_step)
void gdbarch_register_osabi(enum bfd_architecture arch, unsigned long machine, enum gdb_osabi osabi, void(*init_osabi)(struct gdbarch_info, struct gdbarch *))
Definition osabi.c:146
void gdbarch_register_osabi_sniffer(enum bfd_architecture arch, enum bfd_flavour flavour, enum gdb_osabi(*sniffer_fn)(bfd *))
Definition osabi.c:220
gdb_osabi
Definition osabi.h:25
@ GDB_OSABI_UNKNOWN
Definition osabi.h:26
@ GDB_OSABI_PIKEOS
Definition osabi.h:48