gdb/target-descriptions.h - gdb

Macros defined

Source code

  1. /* Target description support for GDB.

  2.    Copyright (C) 2006-2015 Free Software Foundation, Inc.

  3.    Contributed by CodeSourcery.

  4.    This file is part of GDB.

  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.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.

  13.    You should have received a copy of the GNU General Public License
  14.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  15. #ifndef TARGET_DESCRIPTIONS_H
  16. #define TARGET_DESCRIPTIONS_H 1

  17. struct tdesc_feature;
  18. struct tdesc_arch_data;
  19. struct tdesc_type;
  20. struct tdesc_reg;
  21. struct target_desc;
  22. struct target_ops;
  23. struct target_desc;
  24. /* An inferior's target description info is stored in this opaque
  25.    object.  There's one such object per inferior.  */
  26. struct target_desc_info;
  27. struct inferior;

  28. /* Fetch the current inferior's description, and switch its current
  29.    architecture to one which incorporates that description.  */

  30. void target_find_description (void);

  31. /* Discard any description fetched from the target for the current
  32.    inferior, and switch the current architecture to one with no target
  33.    description.  */

  34. void target_clear_description (void);

  35. /* Return the current inferior's target description.  This should only
  36.    be used by gdbarch initialization code; most access should be
  37.    through an existing gdbarch.  */

  38. const struct target_desc *target_current_description (void);

  39. /* Copy inferior target description data.  Used for example when
  40.    handling (v)forks, where child's description is the same as the
  41.    parent's, since the child really is a copy of the parent.  */

  42. void copy_inferior_target_desc_info (struct inferior *destinf,
  43.                                      struct inferior *srcinf);

  44. /* Free a target_desc_info object.  */

  45. void target_desc_info_free (struct target_desc_info *tdesc_info);

  46. /* Returns true if INFO indicates the target description had been
  47.    supplied by the user.  */

  48. int target_desc_info_from_user_p (struct target_desc_info *info);

  49. /* Record architecture-specific functions to call for pseudo-register
  50.    support.  If tdesc_use_registers is called and gdbarch_num_pseudo_regs
  51.    is greater than zero, then these should be called as well.
  52.    They are equivalent to the gdbarch methods with similar names,
  53.    except that they will only be called for pseudo registers.  */

  54. void set_tdesc_pseudo_register_name
  55.   (struct gdbarch *gdbarch, gdbarch_register_name_ftype *pseudo_name);

  56. void set_tdesc_pseudo_register_type
  57.   (struct gdbarch *gdbarch, gdbarch_register_type_ftype *pseudo_type);

  58. void set_tdesc_pseudo_register_reggroup_p
  59.   (struct gdbarch *gdbarch,
  60.    gdbarch_register_reggroup_p_ftype *pseudo_reggroup_p);

  61. /* Update GDBARCH to use the TARGET_DESC for registers.  TARGET_DESC
  62.    may be GDBARCH's target description or (if GDBARCH does not have
  63.    one which describes registers) another target description
  64.    constructed by the gdbarch initialization routine.

  65.    Fixed register assignments are taken from EARLY_DATA, which is freed.
  66.    All registers which have not been assigned fixed numbers are given
  67.    numbers above the current value of gdbarch_num_regs.
  68.    gdbarch_num_regs and various  register-related predicates are updated to
  69.    refer to the target description.  This function should only be called from
  70.    the architecture's gdbarch initialization routine, and only after
  71.    successfully validating the required registers.  */

  72. void tdesc_use_registers (struct gdbarch *gdbarch,
  73.                           const struct target_desc *target_desc,
  74.                           struct tdesc_arch_data *early_data);

  75. /* Allocate initial data for validation of a target description during
  76.    gdbarch initialization.  */

  77. struct tdesc_arch_data *tdesc_data_alloc (void);

  78. /* Clean up data allocated by tdesc_data_alloc.  This should only
  79.    be called to discard the data; tdesc_use_registers takes ownership
  80.    of its EARLY_DATA argument.  */

  81. void tdesc_data_cleanup (void *data_untyped);

  82. /* Search FEATURE for a register named NAME.  Record REGNO and the
  83.    register in DATA; when tdesc_use_registers is called, REGNO will be
  84.    assigned to the register.  1 is returned if the register was found,
  85.    0 if it was not.  */

  86. int tdesc_numbered_register (const struct tdesc_feature *feature,
  87.                              struct tdesc_arch_data *data,
  88.                              int regno, const char *name);

  89. /* Search FEATURE for a register named NAME, but do not assign a fixed
  90.    register number to it.  */

  91. int tdesc_unnumbered_register (const struct tdesc_feature *feature,
  92.                                const char *name);

  93. /* Search FEATURE for a register named NAME, and return its size in
  94.    bits.  The register must exist.  */

  95. int tdesc_register_size (const struct tdesc_feature *feature,
  96.                          const char *name);

  97. /* Search FEATURE for a register with any of the names from NAMES
  98.    (NULL-terminated).  Record REGNO and the register in DATA; when
  99.    tdesc_use_registers is called, REGNO will be assigned to the
  100.    register.  1 is returned if the register was found, 0 if it was
  101.    not.  */

  102. int tdesc_numbered_register_choices (const struct tdesc_feature *feature,
  103.                                      struct tdesc_arch_data *data,
  104.                                      int regno, const char *const names[]);


  105. /* Accessors for target descriptions.  */

  106. /* Return the BFD architecture associated with this target
  107.    description, or NULL if no architecture was specified.  */

  108. const struct bfd_arch_info *tdesc_architecture
  109.   (const struct target_desc *);

  110. /* Return the OSABI associated with this target description, or
  111.    GDB_OSABI_UNKNOWN if no osabi was specified.  */

  112. enum gdb_osabi tdesc_osabi (const struct target_desc *);

  113. /* Return non-zero if this target description is compatible
  114.    with the given BFD architecture.  */

  115. int tdesc_compatible_p (const struct target_desc *,
  116.                         const struct bfd_arch_info *);

  117. /* Return the string value of a property named KEY, or NULL if the
  118.    property was not specified.  */

  119. const char *tdesc_property (const struct target_desc *,
  120.                             const char *key);

  121. /* Return 1 if this target description describes any registers.  */

  122. int tdesc_has_registers (const struct target_desc *);

  123. /* Return the feature with the given name, if present, or NULL if
  124.    the named feature is not found.  */

  125. const struct tdesc_feature *tdesc_find_feature (const struct target_desc *,
  126.                                                 const char *name);

  127. /* Return the name of FEATURE.  */

  128. const char *tdesc_feature_name (const struct tdesc_feature *feature);

  129. /* Return the type associated with ID in the context of FEATURE, or
  130.    NULL if none.  */

  131. struct tdesc_type *tdesc_named_type (const struct tdesc_feature *feature,
  132.                                      const char *id);

  133. /* Return the name of register REGNO, from the target description or
  134.    from an architecture-provided pseudo_register_name method.  */

  135. const char *tdesc_register_name (struct gdbarch *gdbarch, int regno);

  136. /* Return the type of register REGNO, from the target description or
  137.    from an architecture-provided pseudo_register_type method.  */

  138. struct type *tdesc_register_type (struct gdbarch *gdbarch, int regno);

  139. /* Return the type associated with ID, from the target description.  */

  140. struct type *tdesc_find_type (struct gdbarch *gdbarch, const char *id);

  141. /* Check whether REGNUM is a member of REGGROUP using the target
  142.    description.  Return -1 if the target description does not
  143.    specify a group.  */

  144. int tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno,
  145.                                   struct reggroup *reggroup);

  146. /* Methods for constructing a target description.  */

  147. struct target_desc *allocate_target_description (void);
  148. struct cleanup *make_cleanup_free_target_description (struct target_desc *);
  149. void set_tdesc_architecture (struct target_desc *,
  150.                              const struct bfd_arch_info *);
  151. void set_tdesc_osabi (struct target_desc *, enum gdb_osabi osabi);
  152. void set_tdesc_property (struct target_desc *,
  153.                          const char *key, const char *value);
  154. void tdesc_add_compatible (struct target_desc *,
  155.                            const struct bfd_arch_info *);

  156. struct tdesc_feature *tdesc_create_feature (struct target_desc *tdesc,
  157.                                             const char *name);
  158. struct tdesc_type *tdesc_create_vector (struct tdesc_feature *feature,
  159.                                         const char *name,
  160.                                         struct tdesc_type *field_type,
  161.                                         int count);
  162. struct tdesc_type *tdesc_create_struct (struct tdesc_feature *feature,
  163.                                         const char *name);
  164. void tdesc_set_struct_size (struct tdesc_type *type, LONGEST size);
  165. struct tdesc_type *tdesc_create_union (struct tdesc_feature *feature,
  166.                                        const char *name);
  167. struct tdesc_type *tdesc_create_flags (struct tdesc_feature *feature,
  168.                                        const char *name,
  169.                                        LONGEST size);
  170. void tdesc_add_field (struct tdesc_type *type, const char *field_name,
  171.                       struct tdesc_type *field_type);
  172. void tdesc_add_bitfield (struct tdesc_type *type, const char *field_name,
  173.                          int start, int end);
  174. void tdesc_add_flag (struct tdesc_type *type, int start,
  175.                      const char *flag_name);
  176. void tdesc_create_reg (struct tdesc_feature *feature, const char *name,
  177.                        int regnum, int save_restore, const char *group,
  178.                        int bitsize, const char *type);

  179. #endif /* TARGET_DESCRIPTIONS_H */