diff options
author | Yao Qi <yao@codesourcery.com> | 2013-10-17 13:28:37 +0000 |
---|---|---|
committer | Yao Qi <yao@codesourcery.com> | 2013-10-17 13:28:37 +0000 |
commit | 99ad94278d293fb7f5a823caf92221ff4419e556 (patch) | |
tree | 13f05185c64b72b3b3f2809c64549463c6c4c676 /gdb/ada-varobj.c | |
parent | c8a62302a53ba460e181f0c7cf03a5facc346d57 (diff) | |
download | fsf-binutils-gdb-99ad94278d293fb7f5a823caf92221ff4419e556.zip fsf-binutils-gdb-99ad94278d293fb7f5a823caf92221ff4419e556.tar.gz fsf-binutils-gdb-99ad94278d293fb7f5a823caf92221ff4419e556.tar.bz2 |
gdb/
* Makefile.in (SFILES): Add c-varobj.c and jv-varobj.c.
(COMMON_OBS): Add c-varobj.o and jv-varobj.o.
* ada-varobj.c: Include "varobj.h".
(ada_number_of_children): New. Moved from varobj.c.
(ada_name_of_variable, ada_name_of_child): Likewise.
(ada_path_expr_of_child, ada_value_of_child): Likewise.
(ada_type_of_child, ada_value_of_variable): Likewise.
(ada_value_is_changeable_p, ada_value_has_mutated): Likewise.
(ada_varobj_ops): New.
* c-varobj.c, jv-varobj.c: New file. Moved from varobj.c.
* gdbtypes.c (get_target_type): New. Moved from varobj.c.
* gdbtypes.h (get_target_type): Declare.
* varobj.c: Remove the inclusion of "ada-varobj.h" and
"ada-lang.h".
(ANONYMOUS_STRUCT_NAME): Move it to c-varobj.c.
(ANONYMOUS_UNION_NAME): Likewise.
(get_type, get_value_type, get_target_type): Remove declarations.
(value_get_print_value, varobj_value_get_print_value): Likewise.
(c_number_of_children, c_name_of_variable): Likewise.
(c_name_of_child, c_path_expr_of_child): Likewise.
(c_value_of_child, c_type_of_child): Likewise.
(c_value_of_variable, cplus_number_of_children): Likewise.
(cplus_class_num_children, cplus_name_of_variable): Likewise.
(cplus_name_of_child, cplus_path_expr_of_child): Likewise.
(cplus_value_of_child, cplus_type_of_child): Likewise.
(cplus_value_of_variable, java_number_of_children): Likewise.
(java_name_of_variable, java_name_of_child): Likewise.
(java_path_expr_of_child, java_value_of_child): Likewise.
(java_type_of_child, java_value_of_variable): Likewise.
(ada_number_of_children, ada_name_of_variable): Likewise.
(ada_name_of_child, ada_path_expr_of_child): Likewise.
(ada_value_of_child, ada_type_of_child): Likewise.
(ada_value_of_variable, ada_value_is_changeable_p): Likewise.
(ada_value_has_mutated): Likewise.
(struct language_specific): Move it to varobj.h.
(CPLUS_FAKE_CHILD): Move it to varobj.h.
(restrict_range): Rename it varobj_restrict_range. Make it extern.
Callers update.
(get_path_expr_parent): Rename it to varobj_get_path_expr_parent.
Make it extern.
(is_anonymous_child): Move it to c-varobj.c and rename to
varobj_is_anonymous_child. Caller update.
(get_type): Move it to c-varobj.c.
(get_value_type): Rename it varobj_get_value_type. Make it
extern.
(get_target_type): Move it gdbtypes.c.
(varobj_formatted_print_options): New function.
(value_get_print_value): Rename it to
varobj_value_get_print_value and make it extern.
(varobj_value_is_changeable_p): Make it extern.
(adjust_value_for_child_access): Move it to c-varobj.c.
(default_value_is_changeable_p): Rename it to
varobj_default_value_is_changeable_p. Make it extern.
(c_number_of_children, c_name_of_variable): Move it to c-varobj.c
(c_name_of_child, c_path_expr_of_child): Likewise.
(c_value_of_child, c_type_of_child): Likewise.
(c_value_of_variable, cplus_number_of_children): Likewise.
(cplus_class_num_children, cplus_name_of_variable): Likewise.
(cplus_name_of_child, cplus_path_expr_of_child): Likewise.
(cplus_value_of_child, cplus_type_of_child): Likewise.
(cplus_value_of_variable): Likewise.
(java_number_of_children, java_name_of_variable): Move it to jv-varobj.c.
(java_name_of_child, java_path_expr_of_child): Likewise.
(java_value_of_child, java_type_of_child): Likewise.
(java_value_of_variable): Likewise.
(ada_number_of_children, ada_name_of_variable): Move it to ada-varobj.c.
(ada_name_of_child, ada_path_expr_of_child): Likewise.
(ada_value_of_child, ada_type_of_child): Likewise.
(ada_value_of_variable, ada_value_is_changeable_p): Likewise.
(ada_value_has_mutated): Likewise.
* varobj.h (CPLUS_FAKE_CHILD): New macro, moved from varobj.c.
(struct lang_varobj_ops): New. Renamed by 'struct language_specific'.
(c_varobj_ops, cplus_varobj_ops): Declare.
(java_varobj_ops, ada_varobj_ops): Declare.
(varobj_default_value_is_changeable_p): Declare.
(varobj_value_is_changeable_p): Declare.
(varobj_get_value_type, varobj_is_anonymous_child): Declare.
(varobj_get_path_expr_parent): Declare.
(varobj_value_get_print_value): Declare.
(varobj_formatted_print_options): Declare.
(varobj_restrict_range): Declare.
Diffstat (limited to 'gdb/ada-varobj.c')
-rw-r--r-- | gdb/ada-varobj.c | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/gdb/ada-varobj.c b/gdb/ada-varobj.c index 53d8a9c..52c76875 100644 --- a/gdb/ada-varobj.c +++ b/gdb/ada-varobj.c @@ -20,6 +20,7 @@ #include "defs.h" #include "ada-varobj.h" #include "ada-lang.h" +#include "varobj.h" #include "language.h" #include "valprint.h" @@ -885,4 +886,140 @@ ada_varobj_get_value_of_variable (struct value *value, return result; } +/* Ada specific callbacks for VAROBJs. */ +static int +ada_number_of_children (struct varobj *var) +{ + return ada_varobj_get_number_of_children (var->value, var->type); +} + +static char * +ada_name_of_variable (struct varobj *parent) +{ + return c_varobj_ops.name_of_variable (parent); +} + +static char * +ada_name_of_child (struct varobj *parent, int index) +{ + return ada_varobj_get_name_of_child (parent->value, parent->type, + parent->name, index); +} + +static char* +ada_path_expr_of_child (struct varobj *child) +{ + struct varobj *parent = child->parent; + const char *parent_path_expr = varobj_get_path_expr (parent); + + return ada_varobj_get_path_expr_of_child (parent->value, + parent->type, + parent->name, + parent_path_expr, + child->index); +} + +static struct value * +ada_value_of_child (struct varobj *parent, int index) +{ + return ada_varobj_get_value_of_child (parent->value, parent->type, + parent->name, index); +} + +static struct type * +ada_type_of_child (struct varobj *parent, int index) +{ + return ada_varobj_get_type_of_child (parent->value, parent->type, + index); +} + +static char * +ada_value_of_variable (struct varobj *var, enum varobj_display_formats format) +{ + struct value_print_options opts; + + varobj_formatted_print_options (&opts, format); + + return ada_varobj_get_value_of_variable (var->value, var->type, &opts); +} + +/* Implement the "value_is_changeable_p" routine for Ada. */ + +static int +ada_value_is_changeable_p (struct varobj *var) +{ + struct type *type = var->value ? value_type (var->value) : var->type; + + if (ada_is_array_descriptor_type (type) + && TYPE_CODE (type) == TYPE_CODE_TYPEDEF) + { + /* This is in reality a pointer to an unconstrained array. + its value is changeable. */ + return 1; + } + + if (ada_is_string_type (type)) + { + /* We display the contents of the string in the array's + "value" field. The contents can change, so consider + that the array is changeable. */ + return 1; + } + + return varobj_default_value_is_changeable_p (var); +} + +/* Implement the "value_has_mutated" routine for Ada. */ + +static int +ada_value_has_mutated (struct varobj *var, struct value *new_val, + struct type *new_type) +{ + int i; + int from = -1; + int to = -1; + + /* If the number of fields have changed, then for sure the type + has mutated. */ + if (ada_varobj_get_number_of_children (new_val, new_type) + != var->num_children) + return 1; + + /* If the number of fields have remained the same, then we need + to check the name of each field. If they remain the same, + then chances are the type hasn't mutated. This is technically + an incomplete test, as the child's type might have changed + despite the fact that the name remains the same. But we'll + handle this situation by saying that the child has mutated, + not this value. + + If only part (or none!) of the children have been fetched, + then only check the ones we fetched. It does not matter + to the frontend whether a child that it has not fetched yet + has mutated or not. So just assume it hasn't. */ + + varobj_restrict_range (var->children, &from, &to); + for (i = from; i < to; i++) + if (strcmp (ada_varobj_get_name_of_child (new_val, new_type, + var->name, i), + VEC_index (varobj_p, var->children, i)->name) != 0) + return 1; + + return 0; +} + +/* varobj operations for ada. */ + +const struct lang_varobj_ops ada_varobj_ops = +{ + ada_number_of_children, + ada_name_of_variable, + ada_name_of_child, + ada_path_expr_of_child, + ada_value_of_child, + ada_type_of_child, + ada_value_of_variable, + ada_value_is_changeable_p, + ada_value_has_mutated +}; |