]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/target-descriptions.h
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / target-descriptions.h
CommitLineData
424163ea
DJ
1/* Target description support for GDB.
2
e2882c85 3 Copyright (C) 2006-2018 Free Software Foundation, Inc.
424163ea
DJ
4
5 Contributed by CodeSourcery.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
a9762ec7 11 the Free Software Foundation; either version 3 of the License, or
424163ea
DJ
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
a9762ec7 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
424163ea
DJ
21
22#ifndef TARGET_DESCRIPTIONS_H
23#define TARGET_DESCRIPTIONS_H 1
f49ff000 24#include "arch/tdesc.h"
424163ea 25
123dc839 26struct tdesc_arch_data;
123dc839 27struct target_ops;
6ecd4729
PA
28/* An inferior's target description info is stored in this opaque
29 object. There's one such object per inferior. */
30struct target_desc_info;
31struct inferior;
424163ea 32
6ecd4729 33/* Fetch the current inferior's description, and switch its current
424163ea
DJ
34 architecture to one which incorporates that description. */
35
36void target_find_description (void);
37
6ecd4729
PA
38/* Discard any description fetched from the target for the current
39 inferior, and switch the current architecture to one with no target
40 description. */
424163ea
DJ
41
42void target_clear_description (void);
43
6ecd4729
PA
44/* Return the current inferior's target description. This should only
45 be used by gdbarch initialization code; most access should be
46 through an existing gdbarch. */
424163ea
DJ
47
48const struct target_desc *target_current_description (void);
49
6ecd4729
PA
50/* Copy inferior target description data. Used for example when
51 handling (v)forks, where child's description is the same as the
52 parent's, since the child really is a copy of the parent. */
53
54void copy_inferior_target_desc_info (struct inferior *destinf,
55 struct inferior *srcinf);
56
57/* Free a target_desc_info object. */
58
59void target_desc_info_free (struct target_desc_info *tdesc_info);
60
61/* Returns true if INFO indicates the target description had been
62 supplied by the user. */
63
64int target_desc_info_from_user_p (struct target_desc_info *info);
65
123dc839 66/* Record architecture-specific functions to call for pseudo-register
f57d151a 67 support. If tdesc_use_registers is called and gdbarch_num_pseudo_regs
123dc839
DJ
68 is greater than zero, then these should be called as well.
69 They are equivalent to the gdbarch methods with similar names,
70 except that they will only be called for pseudo registers. */
71
72void set_tdesc_pseudo_register_name
73 (struct gdbarch *gdbarch, gdbarch_register_name_ftype *pseudo_name);
74
75void set_tdesc_pseudo_register_type
76 (struct gdbarch *gdbarch, gdbarch_register_type_ftype *pseudo_type);
77
78void set_tdesc_pseudo_register_reggroup_p
79 (struct gdbarch *gdbarch,
80 gdbarch_register_reggroup_p_ftype *pseudo_reggroup_p);
81
7cc46491
DJ
82/* Update GDBARCH to use the TARGET_DESC for registers. TARGET_DESC
83 may be GDBARCH's target description or (if GDBARCH does not have
84 one which describes registers) another target description
85 constructed by the gdbarch initialization routine.
86
87 Fixed register assignments are taken from EARLY_DATA, which is freed.
123dc839 88 All registers which have not been assigned fixed numbers are given
f57d151a
UW
89 numbers above the current value of gdbarch_num_regs.
90 gdbarch_num_regs and various register-related predicates are updated to
91 refer to the target description. This function should only be called from
92 the architecture's gdbarch initialization routine, and only after
123dc839
DJ
93 successfully validating the required registers. */
94
95void tdesc_use_registers (struct gdbarch *gdbarch,
7cc46491 96 const struct target_desc *target_desc,
123dc839
DJ
97 struct tdesc_arch_data *early_data);
98
99/* Allocate initial data for validation of a target description during
100 gdbarch initialization. */
101
102struct tdesc_arch_data *tdesc_data_alloc (void);
103
104/* Clean up data allocated by tdesc_data_alloc. This should only
105 be called to discard the data; tdesc_use_registers takes ownership
106 of its EARLY_DATA argument. */
107
108void tdesc_data_cleanup (void *data_untyped);
109
110/* Search FEATURE for a register named NAME. Record REGNO and the
111 register in DATA; when tdesc_use_registers is called, REGNO will be
112 assigned to the register. 1 is returned if the register was found,
113 0 if it was not. */
114
115int tdesc_numbered_register (const struct tdesc_feature *feature,
116 struct tdesc_arch_data *data,
117 int regno, const char *name);
118
58d6951d
DJ
119/* Search FEATURE for a register named NAME, but do not assign a fixed
120 register number to it. */
121
122int tdesc_unnumbered_register (const struct tdesc_feature *feature,
123 const char *name);
124
7cc46491
DJ
125/* Search FEATURE for a register named NAME, and return its size in
126 bits. The register must exist. */
127
128int tdesc_register_size (const struct tdesc_feature *feature,
129 const char *name);
130
123dc839
DJ
131/* Search FEATURE for a register with any of the names from NAMES
132 (NULL-terminated). Record REGNO and the register in DATA; when
133 tdesc_use_registers is called, REGNO will be assigned to the
134 register. 1 is returned if the register was found, 0 if it was
135 not. */
136
137int tdesc_numbered_register_choices (const struct tdesc_feature *feature,
138 struct tdesc_arch_data *data,
139 int regno, const char *const names[]);
140
141
424163ea
DJ
142/* Accessors for target descriptions. */
143
23181151
DJ
144/* Return the BFD architecture associated with this target
145 description, or NULL if no architecture was specified. */
146
147const struct bfd_arch_info *tdesc_architecture
148 (const struct target_desc *);
149
08d16641
PA
150/* Return the OSABI associated with this target description, or
151 GDB_OSABI_UNKNOWN if no osabi was specified. */
152
153enum gdb_osabi tdesc_osabi (const struct target_desc *);
154
e35359c5
UW
155/* Return non-zero if this target description is compatible
156 with the given BFD architecture. */
157
158int tdesc_compatible_p (const struct target_desc *,
159 const struct bfd_arch_info *);
160
29709017
DJ
161/* Return the string value of a property named KEY, or NULL if the
162 property was not specified. */
163
164const char *tdesc_property (const struct target_desc *,
165 const char *key);
166
123dc839
DJ
167/* Return 1 if this target description describes any registers. */
168
169int tdesc_has_registers (const struct target_desc *);
170
171/* Return the feature with the given name, if present, or NULL if
172 the named feature is not found. */
173
174const struct tdesc_feature *tdesc_find_feature (const struct target_desc *,
175 const char *name);
176
177/* Return the name of FEATURE. */
178
179const char *tdesc_feature_name (const struct tdesc_feature *feature);
180
f8b73d13
DJ
181/* Return the name of register REGNO, from the target description or
182 from an architecture-provided pseudo_register_name method. */
183
d93859e2 184const char *tdesc_register_name (struct gdbarch *gdbarch, int regno);
f8b73d13 185
58d6951d
DJ
186/* Return the type of register REGNO, from the target description or
187 from an architecture-provided pseudo_register_type method. */
188
189struct type *tdesc_register_type (struct gdbarch *gdbarch, int regno);
190
c378eb4e 191/* Return the type associated with ID, from the target description. */
9fd3625f
L
192
193struct type *tdesc_find_type (struct gdbarch *gdbarch, const char *id);
194
f8b73d13
DJ
195/* Check whether REGNUM is a member of REGGROUP using the target
196 description. Return -1 if the target description does not
197 specify a group. */
198
199int tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno,
200 struct reggroup *reggroup);
201
424163ea
DJ
202/* Methods for constructing a target description. */
203
23181151
DJ
204struct cleanup *make_cleanup_free_target_description (struct target_desc *);
205void set_tdesc_architecture (struct target_desc *,
206 const struct bfd_arch_info *);
08d16641 207void set_tdesc_osabi (struct target_desc *, enum gdb_osabi osabi);
29709017
DJ
208void set_tdesc_property (struct target_desc *,
209 const char *key, const char *value);
e35359c5
UW
210void tdesc_add_compatible (struct target_desc *,
211 const struct bfd_arch_info *);
d4a0e8b5
SM
212tdesc_type_with_fields *tdesc_create_enum (struct tdesc_feature *feature,
213 const char *name,
214 int size);
215void tdesc_add_typed_bitfield (tdesc_type_with_fields *type, const char *field_name,
81516450
DE
216 int start, int end,
217 struct tdesc_type *field_type);
d4a0e8b5 218void tdesc_add_enum_value (tdesc_type_with_fields *type, int value,
81516450 219 const char *name);
123dc839 220
27d41eac
YQ
221#if GDB_SELF_TEST
222namespace selftests {
223
224/* Record that XML_FILE should generate a target description that equals
225 TDESC, to be verified by the "maintenance check xml-descriptions"
226 command. */
227
228void record_xml_tdesc (const char *xml_file,
229 const struct target_desc *tdesc);
230}
231#endif
232
424163ea 233#endif /* TARGET_DESCRIPTIONS_H */