GDB (API)
|
00001 /* Target description support for GDB. 00002 00003 Copyright (C) 2006-2013 Free Software Foundation, Inc. 00004 00005 Contributed by CodeSourcery. 00006 00007 This file is part of GDB. 00008 00009 This program is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00021 00022 #ifndef TARGET_DESCRIPTIONS_H 00023 #define TARGET_DESCRIPTIONS_H 1 00024 00025 struct tdesc_feature; 00026 struct tdesc_arch_data; 00027 struct tdesc_type; 00028 struct tdesc_reg; 00029 struct target_desc; 00030 struct target_ops; 00031 struct target_desc; 00032 /* An inferior's target description info is stored in this opaque 00033 object. There's one such object per inferior. */ 00034 struct target_desc_info; 00035 struct inferior; 00036 00037 /* Fetch the current inferior's description, and switch its current 00038 architecture to one which incorporates that description. */ 00039 00040 void target_find_description (void); 00041 00042 /* Discard any description fetched from the target for the current 00043 inferior, and switch the current architecture to one with no target 00044 description. */ 00045 00046 void target_clear_description (void); 00047 00048 /* Return the current inferior's target description. This should only 00049 be used by gdbarch initialization code; most access should be 00050 through an existing gdbarch. */ 00051 00052 const struct target_desc *target_current_description (void); 00053 00054 /* Copy inferior target description data. Used for example when 00055 handling (v)forks, where child's description is the same as the 00056 parent's, since the child really is a copy of the parent. */ 00057 00058 void copy_inferior_target_desc_info (struct inferior *destinf, 00059 struct inferior *srcinf); 00060 00061 /* Free a target_desc_info object. */ 00062 00063 void target_desc_info_free (struct target_desc_info *tdesc_info); 00064 00065 /* Returns true if INFO indicates the target description had been 00066 supplied by the user. */ 00067 00068 int target_desc_info_from_user_p (struct target_desc_info *info); 00069 00070 /* Record architecture-specific functions to call for pseudo-register 00071 support. If tdesc_use_registers is called and gdbarch_num_pseudo_regs 00072 is greater than zero, then these should be called as well. 00073 They are equivalent to the gdbarch methods with similar names, 00074 except that they will only be called for pseudo registers. */ 00075 00076 void set_tdesc_pseudo_register_name 00077 (struct gdbarch *gdbarch, gdbarch_register_name_ftype *pseudo_name); 00078 00079 void set_tdesc_pseudo_register_type 00080 (struct gdbarch *gdbarch, gdbarch_register_type_ftype *pseudo_type); 00081 00082 void set_tdesc_pseudo_register_reggroup_p 00083 (struct gdbarch *gdbarch, 00084 gdbarch_register_reggroup_p_ftype *pseudo_reggroup_p); 00085 00086 /* Update GDBARCH to use the TARGET_DESC for registers. TARGET_DESC 00087 may be GDBARCH's target description or (if GDBARCH does not have 00088 one which describes registers) another target description 00089 constructed by the gdbarch initialization routine. 00090 00091 Fixed register assignments are taken from EARLY_DATA, which is freed. 00092 All registers which have not been assigned fixed numbers are given 00093 numbers above the current value of gdbarch_num_regs. 00094 gdbarch_num_regs and various register-related predicates are updated to 00095 refer to the target description. This function should only be called from 00096 the architecture's gdbarch initialization routine, and only after 00097 successfully validating the required registers. */ 00098 00099 void tdesc_use_registers (struct gdbarch *gdbarch, 00100 const struct target_desc *target_desc, 00101 struct tdesc_arch_data *early_data); 00102 00103 /* Allocate initial data for validation of a target description during 00104 gdbarch initialization. */ 00105 00106 struct tdesc_arch_data *tdesc_data_alloc (void); 00107 00108 /* Clean up data allocated by tdesc_data_alloc. This should only 00109 be called to discard the data; tdesc_use_registers takes ownership 00110 of its EARLY_DATA argument. */ 00111 00112 void tdesc_data_cleanup (void *data_untyped); 00113 00114 /* Search FEATURE for a register named NAME. Record REGNO and the 00115 register in DATA; when tdesc_use_registers is called, REGNO will be 00116 assigned to the register. 1 is returned if the register was found, 00117 0 if it was not. */ 00118 00119 int tdesc_numbered_register (const struct tdesc_feature *feature, 00120 struct tdesc_arch_data *data, 00121 int regno, const char *name); 00122 00123 /* Search FEATURE for a register named NAME, but do not assign a fixed 00124 register number to it. */ 00125 00126 int tdesc_unnumbered_register (const struct tdesc_feature *feature, 00127 const char *name); 00128 00129 /* Search FEATURE for a register named NAME, and return its size in 00130 bits. The register must exist. */ 00131 00132 int tdesc_register_size (const struct tdesc_feature *feature, 00133 const char *name); 00134 00135 /* Search FEATURE for a register with any of the names from NAMES 00136 (NULL-terminated). Record REGNO and the register in DATA; when 00137 tdesc_use_registers is called, REGNO will be assigned to the 00138 register. 1 is returned if the register was found, 0 if it was 00139 not. */ 00140 00141 int tdesc_numbered_register_choices (const struct tdesc_feature *feature, 00142 struct tdesc_arch_data *data, 00143 int regno, const char *const names[]); 00144 00145 00146 /* Accessors for target descriptions. */ 00147 00148 /* Return the BFD architecture associated with this target 00149 description, or NULL if no architecture was specified. */ 00150 00151 const struct bfd_arch_info *tdesc_architecture 00152 (const struct target_desc *); 00153 00154 /* Return the OSABI associated with this target description, or 00155 GDB_OSABI_UNKNOWN if no osabi was specified. */ 00156 00157 enum gdb_osabi tdesc_osabi (const struct target_desc *); 00158 00159 /* Return non-zero if this target description is compatible 00160 with the given BFD architecture. */ 00161 00162 int tdesc_compatible_p (const struct target_desc *, 00163 const struct bfd_arch_info *); 00164 00165 /* Return the string value of a property named KEY, or NULL if the 00166 property was not specified. */ 00167 00168 const char *tdesc_property (const struct target_desc *, 00169 const char *key); 00170 00171 /* Return 1 if this target description describes any registers. */ 00172 00173 int tdesc_has_registers (const struct target_desc *); 00174 00175 /* Return the feature with the given name, if present, or NULL if 00176 the named feature is not found. */ 00177 00178 const struct tdesc_feature *tdesc_find_feature (const struct target_desc *, 00179 const char *name); 00180 00181 /* Return the name of FEATURE. */ 00182 00183 const char *tdesc_feature_name (const struct tdesc_feature *feature); 00184 00185 /* Return the type associated with ID in the context of FEATURE, or 00186 NULL if none. */ 00187 00188 struct tdesc_type *tdesc_named_type (const struct tdesc_feature *feature, 00189 const char *id); 00190 00191 /* Return the name of register REGNO, from the target description or 00192 from an architecture-provided pseudo_register_name method. */ 00193 00194 const char *tdesc_register_name (struct gdbarch *gdbarch, int regno); 00195 00196 /* Return the type of register REGNO, from the target description or 00197 from an architecture-provided pseudo_register_type method. */ 00198 00199 struct type *tdesc_register_type (struct gdbarch *gdbarch, int regno); 00200 00201 /* Return the type associated with ID, from the target description. */ 00202 00203 struct type *tdesc_find_type (struct gdbarch *gdbarch, const char *id); 00204 00205 /* Check whether REGNUM is a member of REGGROUP using the target 00206 description. Return -1 if the target description does not 00207 specify a group. */ 00208 00209 int tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno, 00210 struct reggroup *reggroup); 00211 00212 /* Methods for constructing a target description. */ 00213 00214 struct target_desc *allocate_target_description (void); 00215 struct cleanup *make_cleanup_free_target_description (struct target_desc *); 00216 void set_tdesc_architecture (struct target_desc *, 00217 const struct bfd_arch_info *); 00218 void set_tdesc_osabi (struct target_desc *, enum gdb_osabi osabi); 00219 void set_tdesc_property (struct target_desc *, 00220 const char *key, const char *value); 00221 void tdesc_add_compatible (struct target_desc *, 00222 const struct bfd_arch_info *); 00223 00224 struct tdesc_feature *tdesc_create_feature (struct target_desc *tdesc, 00225 const char *name); 00226 struct tdesc_type *tdesc_create_vector (struct tdesc_feature *feature, 00227 const char *name, 00228 struct tdesc_type *field_type, 00229 int count); 00230 struct tdesc_type *tdesc_create_struct (struct tdesc_feature *feature, 00231 const char *name); 00232 void tdesc_set_struct_size (struct tdesc_type *type, LONGEST size); 00233 struct tdesc_type *tdesc_create_union (struct tdesc_feature *feature, 00234 const char *name); 00235 struct tdesc_type *tdesc_create_flags (struct tdesc_feature *feature, 00236 const char *name, 00237 LONGEST size); 00238 void tdesc_add_field (struct tdesc_type *type, const char *field_name, 00239 struct tdesc_type *field_type); 00240 void tdesc_add_bitfield (struct tdesc_type *type, const char *field_name, 00241 int start, int end); 00242 void tdesc_add_flag (struct tdesc_type *type, int start, 00243 const char *flag_name); 00244 void tdesc_create_reg (struct tdesc_feature *feature, const char *name, 00245 int regnum, int save_restore, const char *group, 00246 int bitsize, const char *type); 00247 00248 #endif /* TARGET_DESCRIPTIONS_H */