gdb/varobj.h - gdb

Global variables defined

Data types defined

Macros defined

Source code

  1. /* GDB variable objects API.
  2.    Copyright (C) 1999-2015 Free Software Foundation, Inc.

  3.    This program is free software; you can redistribute it and/or modify
  4.    it under the terms of the GNU General Public License as published by
  5.    the Free Software Foundation; either version 3 of the License, or
  6.    (at your option) any later version.

  7.    This program is distributed in the hope that it will be useful,
  8.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.    GNU General Public License for more details.

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

  13. #ifndef VAROBJ_H
  14. #define VAROBJ_H 1

  15. #include "symtab.h"
  16. #include "gdbtypes.h"
  17. #include "vec.h"

  18. /* Enumeration for the format types */
  19. enum varobj_display_formats
  20.   {
  21.     FORMAT_NATURAL,                /* What gdb actually calls 'natural' */
  22.     FORMAT_BINARY,                /* Binary display                    */
  23.     FORMAT_DECIMAL,                /* Decimal display                   */
  24.     FORMAT_HEXADECIMAL,                /* Hex display                       */
  25.     FORMAT_OCTAL                /* Octal display                     */
  26.   };

  27. enum varobj_type
  28.   {
  29.     USE_SPECIFIED_FRAME,        /* Use the frame passed to varobj_create.  */
  30.     USE_CURRENT_FRAME,          /* Use the current frame.  */
  31.     USE_SELECTED_FRAME          /* Always reevaluate in selected frame.  */
  32.   };

  33. /* Enumerator describing if a variable object is in scope.  */
  34. enum varobj_scope_status
  35.   {
  36.     VAROBJ_IN_SCOPE = 0,        /* Varobj is scope, value available.  */
  37.     VAROBJ_NOT_IN_SCOPE = 1,    /* Varobj is not in scope, value not
  38.                                    available, but varobj can become in
  39.                                    scope later.  */
  40.     VAROBJ_INVALID = 2,         /* Varobj no longer has any value, and never
  41.                                    will.  */
  42.   };

  43. /* String representations of gdb's format codes (defined in varobj.c).  */
  44. extern char *varobj_format_string[];

  45. /* Struct thar describes a variable object instance.  */

  46. struct varobj;

  47. typedef struct varobj *varobj_p;
  48. DEF_VEC_P (varobj_p);

  49. typedef struct varobj_update_result_t
  50. {
  51.   struct varobj *varobj;
  52.   int type_changed;
  53.   int children_changed;
  54.   int changed;
  55.   enum varobj_scope_status status;
  56.   /* This variable is used internally by varobj_update to indicate if the
  57.      new value of varobj is already computed and installed, or has to
  58.      be yet installed.  Don't use this outside varobj.c.  */
  59.   int value_installed;

  60.   /* This will be non-NULL when new children were added to the varobj.
  61.      It lists the new children (which must necessarily come at the end
  62.      of the child list) added during an update.  The caller is
  63.      responsible for freeing this vector.  */
  64.   VEC (varobj_p) *new;
  65. } varobj_update_result;

  66. DEF_VEC_O (varobj_update_result);

  67. struct varobj_root;
  68. struct varobj_dynamic;

  69. /* Every variable in the system has a structure of this type defined
  70.    for it.  This structure holds all information necessary to manipulate
  71.    a particular object variable.  Members which must be freed are noted.  */
  72. struct varobj
  73. {
  74.   /* Alloc'd name of the variable for this object.  If this variable is a
  75.      child, then this name will be the child's source name.
  76.      (bar, not foo.bar).  */
  77.   /* NOTE: This is the "expression".  */
  78.   char *name;

  79.   /* Alloc'd expression for this child.  Can be used to create a
  80.      root variable corresponding to this child.  */
  81.   char *path_expr;

  82.   /* The alloc'd name for this variable's object.  This is here for
  83.      convenience when constructing this object's children.  */
  84.   char *obj_name;

  85.   /* Index of this variable in its parent or -1.  */
  86.   int index;

  87.   /* The type of this variable.  This can be NULL
  88.      for artifial variable objects -- currently, the "accessibility"
  89.      variable objects in C++.  */
  90.   struct type *type;

  91.   /* The value of this expression or subexpression.  A NULL value
  92.      indicates there was an error getting this value.
  93.      Invariant: if varobj_value_is_changeable_p (this) is non-zero,
  94.      the value is either NULL, or not lazy.  */
  95.   struct value *value;

  96.   /* The number of (immediate) children this variable has.  */
  97.   int num_children;

  98.   /* If this object is a child, this points to its immediate parent.  */
  99.   struct varobj *parent;

  100.   /* Children of this object.  */
  101.   VEC (varobj_p) *children;

  102.   /* Description of the root variable.  Points to root variable for
  103.      children.  */
  104.   struct varobj_root *root;

  105.   /* The format of the output for this object.  */
  106.   enum varobj_display_formats format;

  107.   /* Was this variable updated via a varobj_set_value operation.  */
  108.   int updated;

  109.   /* Last print value.  */
  110.   char *print_value;

  111.   /* Is this variable frozen.  Frozen variables are never implicitly
  112.      updated by -var-update *
  113.      or -var-update <direct-or-indirect-parent>.  */
  114.   int frozen;

  115.   /* Is the value of this variable intentionally not fetched?  It is
  116.      not fetched if either the variable is frozen, or any parents is
  117.      frozen.  */
  118.   int not_fetched;

  119.   /* Sub-range of children which the MI consumer has requested.  If
  120.      FROM < 0 or TO < 0, means that all children have been
  121.      requested.  */
  122.   int from;
  123.   int to;

  124.   /* Dynamic part of varobj.  */
  125.   struct varobj_dynamic *dynamic;
  126. };

  127. /* Is the variable X one of our "fake" children?  */
  128. #define CPLUS_FAKE_CHILD(x) \
  129. ((x) != NULL && (x)->type == NULL && (x)->value == NULL)

  130. /* The language specific vector */

  131. struct lang_varobj_ops
  132. {
  133.   /* The number of children of PARENT.  */
  134.   int (*number_of_children) (struct varobj *parent);

  135.   /* The name (expression) of a root varobj.  */
  136.   char *(*name_of_variable) (struct varobj *parent);

  137.   /* The name of the INDEX'th child of PARENT.  */
  138.   char *(*name_of_child) (struct varobj *parent, int index);

  139.   /* Returns the rooted expression of CHILD, which is a variable
  140.      obtain that has some parent.  */
  141.   char *(*path_expr_of_child) (struct varobj *child);

  142.   /* The ``struct value *'' of the INDEX'th child of PARENT.  */
  143.   struct value *(*value_of_child) (struct varobj *parent, int index);

  144.   /* The type of the INDEX'th child of PARENT.  */
  145.   struct type *(*type_of_child) (struct varobj *parent, int index);

  146.   /* The current value of VAR.  */
  147.   char *(*value_of_variable) (struct varobj *var,
  148.                               enum varobj_display_formats format);

  149.   /* Return non-zero if changes in value of VAR must be detected and
  150.      reported by -var-update.  Return zero if -var-update should never
  151.      report changes of such values.  This makes sense for structures
  152.      (since the changes in children values will be reported separately),
  153.      or for artifical objects (like 'public' pseudo-field in C++).

  154.      Return value of 0 means that gdb need not call value_fetch_lazy
  155.      for the value of this variable object.  */
  156.   int (*value_is_changeable_p) (struct varobj *var);

  157.   /* Return nonzero if the type of VAR has mutated.

  158.      VAR's value is still the varobj's previous value, while NEW_VALUE
  159.      is VAR's new value and NEW_TYPE is the var's new type.  NEW_VALUE
  160.      may be NULL indicating that there is no value available (the varobj
  161.      may be out of scope, of may be the child of a null pointer, for
  162.      instance).  NEW_TYPE, on the other hand, must never be NULL.

  163.      This function should also be able to assume that var's number of
  164.      children is set (not < 0).

  165.      Languages where types do not mutate can set this to NULL.  */
  166.   int (*value_has_mutated) (struct varobj *var, struct value *new_value,
  167.                             struct type *new_type);

  168.   /* Return nonzero if VAR is a suitable path expression parent.

  169.      For C like languages with anonymous structures and unions an anonymous
  170.      structure or union is not a suitable parent.  */
  171.   int (*is_path_expr_parent) (struct varobj *var);
  172. };

  173. extern const struct lang_varobj_ops c_varobj_ops;
  174. extern const struct lang_varobj_ops cplus_varobj_ops;
  175. extern const struct lang_varobj_ops java_varobj_ops;
  176. extern const struct lang_varobj_ops ada_varobj_ops;

  177. #define default_varobj_ops c_varobj_ops
  178. /* API functions */

  179. extern struct varobj *varobj_create (char *objname,
  180.                                      char *expression, CORE_ADDR frame,
  181.                                      enum varobj_type type);

  182. extern char *varobj_gen_name (void);

  183. extern struct varobj *varobj_get_handle (char *name);

  184. extern char *varobj_get_objname (struct varobj *var);

  185. extern char *varobj_get_expression (struct varobj *var);

  186. extern int varobj_delete (struct varobj *var, char ***dellist,
  187.                           int only_children);

  188. extern enum varobj_display_formats varobj_set_display_format (
  189.                                                          struct varobj *var,
  190.                                         enum varobj_display_formats format);

  191. extern enum varobj_display_formats varobj_get_display_format (
  192.                                                         struct varobj *var);

  193. extern int varobj_get_thread_id (struct varobj *var);

  194. extern void varobj_set_frozen (struct varobj *var, int frozen);

  195. extern int varobj_get_frozen (struct varobj *var);

  196. extern void varobj_get_child_range (struct varobj *var, int *from, int *to);

  197. extern void varobj_set_child_range (struct varobj *var, int from, int to);

  198. extern char *varobj_get_display_hint (struct varobj *var);

  199. extern int varobj_get_num_children (struct varobj *var);

  200. /* Return the list of children of VAR.  The returned vector should not
  201.    be modified in any way.  FROM and TO are in/out parameters
  202.    indicating the range of children to return.  If either *FROM or *TO
  203.    is less than zero on entry, then all children will be returned.  On
  204.    return, *FROM and *TO will be updated to indicate the real range
  205.    that was returned.  The resulting VEC will contain at least the
  206.    children from *FROM to just before *TO; it might contain more
  207.    children, depending on whether any more were available.  */
  208. extern VEC (varobj_p)* varobj_list_children (struct varobj *var,
  209.                                              int *from, int *to);

  210. extern char *varobj_get_type (struct varobj *var);

  211. extern struct type *varobj_get_gdb_type (struct varobj *var);

  212. extern char *varobj_get_path_expr (struct varobj *var);

  213. extern const struct language_defn *varobj_get_language (struct varobj *var);

  214. extern int varobj_get_attributes (struct varobj *var);

  215. extern char *varobj_get_formatted_value (struct varobj *var,
  216.                                          enum varobj_display_formats format);

  217. extern char *varobj_get_value (struct varobj *var);

  218. extern int varobj_set_value (struct varobj *var, char *expression);

  219. extern void all_root_varobjs (void (*func) (struct varobj *var, void *data),
  220.                               void *data);

  221. extern VEC(varobj_update_result) *varobj_update (struct varobj **varp,
  222.                                                  int explicit);

  223. extern void varobj_invalidate (void);

  224. extern int varobj_editable_p (struct varobj *var);

  225. extern int varobj_floating_p (struct varobj *var);

  226. extern void varobj_set_visualizer (struct varobj *var,
  227.                                    const char *visualizer);

  228. extern void varobj_enable_pretty_printing (void);

  229. extern int varobj_has_more (struct varobj *var, int to);

  230. extern int varobj_is_dynamic_p (struct varobj *var);

  231. extern struct cleanup *varobj_ensure_python_env (struct varobj *var);

  232. extern int varobj_default_value_is_changeable_p (struct varobj *var);
  233. extern int varobj_value_is_changeable_p (struct varobj *var);

  234. extern struct type *varobj_get_value_type (struct varobj *var);

  235. extern int varobj_is_anonymous_child (struct varobj *child);

  236. extern struct varobj *varobj_get_path_expr_parent (struct varobj *var);

  237. extern char *varobj_value_get_print_value (struct value *value,
  238.                                            enum varobj_display_formats format,
  239.                                            struct varobj *var);

  240. extern void varobj_formatted_print_options (struct value_print_options *opts,
  241.                                             enum varobj_display_formats format);

  242. extern void varobj_restrict_range (VEC (varobj_p) *children, int *from,
  243.                                    int *to);

  244. extern int varobj_default_is_path_expr_parent (struct varobj *var);

  245. #endif /* VAROBJ_H */