GDB (xrefs)

/tmp/gdb-8.1/gdb/dicos-tdep.c
Go to the documentation of this file.
1 /* Target-dependent, architecture-independent code for DICOS, for GDB.
2
3 Copyright (C) 2009-2018 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 #include "osabi.h"
22 #include "solib.h"
23 #include "solib-target.h"
24 #include "inferior.h"
25 #include "dicos-tdep.h"
26
27 void
28 dicos_init_abi (struct gdbarch *gdbarch)
29 {
30 set_solib_ops (gdbarch, &solib_target_so_ops);
31
32 /* Every process, although has its own address space, sees the same
33 list of shared libraries. There's no "main executable" in DICOS,
34 so this accounts for all code. */
35 set_gdbarch_has_global_solist (gdbarch, 1);
36
37 /* The DICOS breakpoint API takes care of magically making
38 breakpoints visible to all inferiors. */
39 set_gdbarch_has_global_breakpoints (gdbarch, 1);
40
41 /* There's no (standard definition of) entry point or a guaranteed
42 text location with a symbol where to place the call dummy, so we
43 need it on the stack. Rely on i386_gdbarch_init used also for
44 amd64 to set up ON_STACK inferior calls. */
45
46 /* DICOS rewinds the PC itself. */
47 set_gdbarch_decr_pc_after_break (gdbarch, 0);
48 }
49
50 /* Return true if ABFD is a dicos load module. HEADER_SIZE is the
51 expected size of the "header" section in bytes. */
52
53 int
54 dicos_load_module_p (bfd *abfd, int header_size)
55 {
56 long storage_needed;
57 int ret = 0;
58 asymbol **symbol_table = NULL;
59 const char *symname = "Dicos_loadModuleInfo";
60 asection *section;
61
62 /* DICOS files don't have a .note.ABI-tag marker or something
63 similar. We do know there's always a "header" section of
64 HEADER_SIZE bytes (size depends on architecture), and there's
65 always a "Dicos_loadModuleInfo" symbol defined. Look for the
66 section first, as that should be cheaper. */
67
68 section = bfd_get_section_by_name (abfd, "header");
69 if (!section)
70 return 0;
71
72 if (bfd_section_size (abfd, section) != header_size)
73 return 0;
74
75 /* Dicos LMs always have a "Dicos_loadModuleInfo" symbol
76 defined. Look for it. */
77
78 storage_needed = bfd_get_symtab_upper_bound (abfd);
79 if (storage_needed < 0)
80 {
81 warning (_("Can't read elf symbols from %s: %s"),
82 bfd_get_filename (abfd),
83 bfd_errmsg (bfd_get_error ()));
84 return 0;
85 }
86
87 if (storage_needed > 0)
88 {
89 long i, symcount;
90
91 symbol_table = (asymbol **) xmalloc (storage_needed);
92 symcount = bfd_canonicalize_symtab (abfd, symbol_table);
93
94 if (symcount < 0)
95 warning (_("Can't read elf symbols from %s: %s"),
96 bfd_get_filename (abfd),
97 bfd_errmsg (bfd_get_error ()));
98 else
99 {
100 for (i = 0; i < symcount; i++)
101 {
102 asymbol *sym = symbol_table[i];
103 if (sym->name != NULL
104 && symname[0] == sym->name[0]
105 && strcmp (symname + 1, sym->name + 1) == 0)
106 {
107 ret = 1;
108 break;
109 }
110 }
111 }
112 }
113
114 xfree (symbol_table);
115 return ret;
116 }
gdbarch
Definition: gdbarch.c:127
xfree
void xfree(void *)
set_solib_ops
void set_solib_ops(struct gdbarch *gdbarch, const struct target_so_ops *new_ops)
Definition: solib.c:77
warning
void warning(const char *fmt,...)
Definition: errors.c:26
set_gdbarch_has_global_solist
void set_gdbarch_has_global_solist(struct gdbarch *gdbarch, int has_global_solist)
Definition: gdbarch.c:4612
_
#define _(String)
Definition: gdb_locale.h:35
defs.h
solib_target_so_ops
struct target_so_ops solib_target_so_ops
Definition: solib-target.c:462
dicos_init_abi
void dicos_init_abi(struct gdbarch *gdbarch)
Definition: dicos-tdep.c:28
osabi.h
set_gdbarch_decr_pc_after_break
void set_gdbarch_decr_pc_after_break(struct gdbarch *gdbarch, CORE_ADDR decr_pc_after_break)
Definition: gdbarch.c:2980
inferior.h
solib.h
set_gdbarch_has_global_breakpoints
void set_gdbarch_has_global_breakpoints(struct gdbarch *gdbarch, int has_global_breakpoints)
Definition: gdbarch.c:4629
xmalloc
void * xmalloc(YYSIZE_T)
solib-target.h
dicos-tdep.h
dicos_load_module_p
int dicos_load_module_p(bfd *abfd, int header_size)
Definition: dicos-tdep.c:54