GDB (xrefs)

/tmp/gdb-8.1/gdb/target-descriptions.h
Go to the documentation of this file.
1 /* Target description support for GDB.
2
3 Copyright (C) 2006-2018 Free Software Foundation, Inc.
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
11 the Free Software Foundation; either version 3 of the License, or
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
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22 #ifndef TARGET_DESCRIPTIONS_H
23 #define TARGET_DESCRIPTIONS_H 1
24 #include "arch/tdesc.h"
25
26 struct tdesc_arch_data;
27 struct target_ops;
28 /* An inferior's target description info is stored in this opaque
29 object. There's one such object per inferior. */
30 struct target_desc_info;
31 struct inferior;
32
33 /* Fetch the current inferior's description, and switch its current
34 architecture to one which incorporates that description. */
35
36 void target_find_description (void);
37
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. */
41
42 void target_clear_description (void);
43
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. */
47
48 const struct target_desc *target_current_description (void);
49
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
54 void copy_inferior_target_desc_info (struct inferior *destinf,
55 struct inferior *srcinf);
56
57 /* Free a target_desc_info object. */
58
59 void 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
64 int target_desc_info_from_user_p (struct target_desc_info *info);
65
66 /* Record architecture-specific functions to call for pseudo-register
67 support. If tdesc_use_registers is called and gdbarch_num_pseudo_regs
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
72 void set_tdesc_pseudo_register_name
73 (struct gdbarch *gdbarch, gdbarch_register_name_ftype *pseudo_name);
74
75 void set_tdesc_pseudo_register_type
76 (struct gdbarch *gdbarch, gdbarch_register_type_ftype *pseudo_type);
77
78 void set_tdesc_pseudo_register_reggroup_p
79 (struct gdbarch *gdbarch,
80 gdbarch_register_reggroup_p_ftype *pseudo_reggroup_p);
81
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.
88 All registers which have not been assigned fixed numbers are given
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
93 successfully validating the required registers. */
94
95 void tdesc_use_registers (struct gdbarch *gdbarch,
96 const struct target_desc *target_desc,
97 struct tdesc_arch_data *early_data);
98
99 /* Allocate initial data for validation of a target description during
100 gdbarch initialization. */
101
102 struct 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
108 void 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
115 int tdesc_numbered_register (const struct tdesc_feature *feature,
116 struct tdesc_arch_data *data,
117 int regno, const char *name);
118
119 /* Search FEATURE for a register named NAME, but do not assign a fixed
120 register number to it. */
121
122 int tdesc_unnumbered_register (const struct tdesc_feature *feature,
123 const char *name);
124
125 /* Search FEATURE for a register named NAME, and return its size in
126 bits. The register must exist. */
127
128 int tdesc_register_size (const struct tdesc_feature *feature,
129 const char *name);
130
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
137 int tdesc_numbered_register_choices (const struct tdesc_feature *feature,
138 struct tdesc_arch_data *data,
139 int regno, const char *const names[]);
140
141
142 /* Accessors for target descriptions. */
143
144 /* Return the BFD architecture associated with this target
145 description, or NULL if no architecture was specified. */
146
147 const struct bfd_arch_info *tdesc_architecture
148 (const struct target_desc *);
149
150 /* Return the OSABI associated with this target description, or
151 GDB_OSABI_UNKNOWN if no osabi was specified. */
152
153 enum gdb_osabi tdesc_osabi (const struct target_desc *);
154
155 /* Return non-zero if this target description is compatible
156 with the given BFD architecture. */
157
158 int tdesc_compatible_p (const struct target_desc *,
159 const struct bfd_arch_info *);
160
161 /* Return the string value of a property named KEY, or NULL if the
162 property was not specified. */
163
164 const char *tdesc_property (const struct target_desc *,
165 const char *key);
166
167 /* Return 1 if this target description describes any registers. */
168
169 int 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
174 const struct tdesc_feature *tdesc_find_feature (const struct target_desc *,
175 const char *name);
176
177 /* Return the name of FEATURE. */
178
179 const char *tdesc_feature_name (const struct tdesc_feature *feature);
180
181 /* Return the name of register REGNO, from the target description or
182 from an architecture-provided pseudo_register_name method. */
183
184 const char *tdesc_register_name (struct gdbarch *gdbarch, int regno);
185
186 /* Return the type of register REGNO, from the target description or
187 from an architecture-provided pseudo_register_type method. */
188
189 struct type *tdesc_register_type (struct gdbarch *gdbarch, int regno);
190
191 /* Return the type associated with ID, from the target description. */
192
193 struct type *tdesc_find_type (struct gdbarch *gdbarch, const char *id);
194
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
199 int tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno,
200 struct reggroup *reggroup);
201
202 /* Methods for constructing a target description. */
203
204 struct cleanup *make_cleanup_free_target_description (struct target_desc *);
205 void set_tdesc_architecture (struct target_desc *,
206 const struct bfd_arch_info *);
207 void set_tdesc_osabi (struct target_desc *, enum gdb_osabi osabi);
208 void set_tdesc_property (struct target_desc *,
209 const char *key, const char *value);
210 void tdesc_add_compatible (struct target_desc *,
211 const struct bfd_arch_info *);
212 tdesc_type_with_fields *tdesc_create_enum (struct tdesc_feature *feature,
213 const char *name,
214 int size);
215 void tdesc_add_typed_bitfield (tdesc_type_with_fields *type, const char *field_name,
216 int start, int end,
217 struct tdesc_type *field_type);
218 void tdesc_add_enum_value (tdesc_type_with_fields *type, int value,
219 const char *name);
220
221 #if GDB_SELF_TEST
222 namespace 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
228 void record_xml_tdesc (const char *xml_file,
229 const struct target_desc *tdesc);
230 }
231 #endif
232
233 #endif /* TARGET_DESCRIPTIONS_H */
gdbarch
Definition: gdbarch.c:127
tdesc_add_enum_value
void tdesc_add_enum_value(tdesc_type_with_fields *type, int value, const char *name)
Definition: target-descriptions.c:1590
make_cleanup_free_target_description
struct cleanup * make_cleanup_free_target_description(struct target_desc *)
Definition: target-descriptions.c:1627
tdesc_data_cleanup
void tdesc_data_cleanup(void *data_untyped)
Definition: target-descriptions.c:1061
tdesc_type_with_fields
Definition: target-descriptions.c:355
tdesc_register_size
int tdesc_register_size(const struct tdesc_feature *feature, const char *name)
Definition: target-descriptions.c:1138
copy_inferior_target_desc_info
void copy_inferior_target_desc_info(struct inferior *destinf, struct inferior *srcinf)
Definition: target-descriptions.c:738
set_tdesc_pseudo_register_reggroup_p
void set_tdesc_pseudo_register_reggroup_p(struct gdbarch *gdbarch, gdbarch_register_reggroup_p_ftype *pseudo_reggroup_p)
Definition: target-descriptions.c:1362
tdesc_numbered_register
int tdesc_numbered_register(const struct tdesc_feature *feature, struct tdesc_arch_data *data, int regno, const char *name)
Definition: target-descriptions.c:1084
inferior
Definition: inferior.h:310
tdesc_numbered_register_choices
int tdesc_numbered_register_choices(const struct tdesc_feature *feature, struct tdesc_arch_data *data, int regno, const char *const names[])
Definition: target-descriptions.c:1121
cleanup
Definition: cleanups.c:38
target_desc_info_from_user_p
int target_desc_info_from_user_p(struct target_desc_info *info)
Definition: target-descriptions.c:730
target_clear_description
void target_clear_description(void)
Definition: target-descriptions.c:840
reggroup
Definition: reggroups.c:33
tdesc_find_type
struct type * tdesc_find_type(struct gdbarch *gdbarch, const char *id)
Definition: target-descriptions.c:1015
selftests
Definition: selftest.c:25
tdesc_register_name
const char * tdesc_register_name(struct gdbarch *gdbarch, int regno)
Definition: target-descriptions.c:1173
name
const char *const name
Definition: aarch64-tdep.c:76
tdesc_type
Definition: target-descriptions.c:201
set_tdesc_property
void set_tdesc_property(struct target_desc *, const char *key, const char *value)
Definition: target-descriptions.c:1653
tdesc_has_registers
int tdesc_has_registers(const struct target_desc *)
Definition: target-descriptions.c:926
target_ops
Definition: target.h:412
set_tdesc_pseudo_register_name
void set_tdesc_pseudo_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype *pseudo_name)
Definition: target-descriptions.c:1341
type
Definition: gdbtypes.h:749
tdesc_osabi
enum gdb_osabi tdesc_osabi(const struct target_desc *)
Definition: target-descriptions.c:916
tdesc_compatible_p
int tdesc_compatible_p(const struct target_desc *, const struct bfd_arch_info *)
Definition: target-descriptions.c:873
target_find_description
void target_find_description(void)
Definition: target-descriptions.c:777
tdesc_feature_name
const char * tdesc_feature_name(const struct tdesc_feature *feature)
Definition: target-descriptions.c:955
tdesc_feature
Definition: target-descriptions.c:516
tdesc_find_feature
const struct tdesc_feature * tdesc_find_feature(const struct target_desc *, const char *name)
Definition: target-descriptions.c:942
tdesc_create_enum
tdesc_type_with_fields * tdesc_create_enum(struct tdesc_feature *feature, const char *name, int size)
Definition: target-descriptions.c:1520
value
Definition: value.c:169
tdesc_register_in_reggroup_p
int tdesc_register_in_reggroup_p(struct gdbarch *gdbarch, int regno, struct reggroup *reggroup)
Definition: target-descriptions.c:1292
gdbarch_register_type_ftype
struct type *() gdbarch_register_type_ftype(struct gdbarch *gdbarch, int reg_nr)
Definition: gdbarch.h:382
tdesc_add_compatible
void tdesc_add_compatible(struct target_desc *, const struct bfd_arch_info *)
Definition: target-descriptions.c:1633
gdbarch_register_reggroup_p_ftype
int() gdbarch_register_reggroup_p_ftype(struct gdbarch *gdbarch, int regnum, struct reggroup *reggroup)
Definition: gdbarch.h:852
tdesc_data_alloc
struct tdesc_arch_data * tdesc_data_alloc(void)
Definition: target-descriptions.c:1051
set_tdesc_osabi
void set_tdesc_osabi(struct target_desc *, enum gdb_osabi osabi)
Definition: target-descriptions.c:1690
target_desc
Definition: target-descriptions.c:591
target_desc_info_free
void target_desc_info_free(struct target_desc_info *tdesc_info)
Definition: target-descriptions.c:751
target_current_description
const struct target_desc * target_current_description(void)
Definition: target-descriptions.c:861
tdesc_property
const char * tdesc_property(const struct target_desc *, const char *key)
Definition: target-descriptions.c:894
tdesc_architecture
const struct bfd_arch_info * tdesc_architecture(const struct target_desc *)
Definition: target-descriptions.c:907
target_desc_info
Definition: target-descriptions.c:690
tdesc_register_type
struct type * tdesc_register_type(struct gdbarch *gdbarch, int regno)
Definition: target-descriptions.c:1195
tdesc_use_registers
void tdesc_use_registers(struct gdbarch *gdbarch, const struct target_desc *target_desc, struct tdesc_arch_data *early_data)
Definition: target-descriptions.c:1374
set_tdesc_architecture
void set_tdesc_architecture(struct target_desc *, const struct bfd_arch_info *)
Definition: target-descriptions.c:1675
field_name
static PyObject * field_name(struct type *type, int field)
Definition: py-type.c:267
tdesc_arch_data
Definition: target-descriptions.c:670
tdesc_unnumbered_register
int tdesc_unnumbered_register(const struct tdesc_feature *feature, const char *name)
Definition: target-descriptions.c:1106
tdesc_add_typed_bitfield
void tdesc_add_typed_bitfield(tdesc_type_with_fields *type, const char *field_name, int start, int end, struct tdesc_type *field_type)
Definition: target-descriptions.c:1547
gdbarch_register_name_ftype
const char *() gdbarch_register_name_ftype(struct gdbarch *gdbarch, int regnr)
Definition: gdbarch.h:372
set_tdesc_pseudo_register_type
void set_tdesc_pseudo_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype *pseudo_type)
Definition: target-descriptions.c:1351
size
size_t size
Definition: go32-nat.c:242
gdb_osabi
gdb_osabi
Definition: defs.h:508
tdesc.h