New varobj language callback: value_is_changeable_p.
This patch introduces a new language-specific callback for varobj objects, allowing us to move the language-specific bits of the varobj_value_is_changeable_p routine to language-specific functions. This is more elegant than testing for the varobj's language... gdb/ChangeLog: * varobj.c (default_value_is_changeable_p): New function, extracted from varobj_value_is_changeable_p. Add declaration. (ada_value_is_changeable_p): New function, extracted from varobj_value_is_changeable_p. Add declaration. (struct language_specific): New field "value_is_changeable_p". (languages): Add entries for new field. (varobj_create): Set language before calling install_new_value. (varobj_value_is_changeable_p): Reimplement to call the varobj's "value_is_changeable_p" language callback.
This commit is contained in:
parent
181875a4ab
commit
d32cafc7d5
|
@ -1,3 +1,15 @@
|
||||||
|
2012-03-28 Joel Brobecker <brobecker@adacore.com>
|
||||||
|
|
||||||
|
* varobj.c (default_value_is_changeable_p): New function,
|
||||||
|
extracted from varobj_value_is_changeable_p. Add declaration.
|
||||||
|
(ada_value_is_changeable_p): New function, extracted from
|
||||||
|
varobj_value_is_changeable_p. Add declaration.
|
||||||
|
(struct language_specific): New field "value_is_changeable_p".
|
||||||
|
(languages): Add entries for new field.
|
||||||
|
(varobj_create): Set language before calling install_new_value.
|
||||||
|
(varobj_value_is_changeable_p): Reimplement to call the varobj's
|
||||||
|
"value_is_changeable_p" language callback.
|
||||||
|
|
||||||
2012-03-28 Joel Brobecker <brobecker@adacore.com>
|
2012-03-28 Joel Brobecker <brobecker@adacore.com>
|
||||||
|
|
||||||
* ada-varobj.h, ada-varobj.c: New files.
|
* ada-varobj.h, ada-varobj.c: New files.
|
||||||
|
|
133
gdb/varobj.c
133
gdb/varobj.c
|
@ -306,6 +306,8 @@ static struct varobj *varobj_add_child (struct varobj *var,
|
||||||
|
|
||||||
#endif /* HAVE_PYTHON */
|
#endif /* HAVE_PYTHON */
|
||||||
|
|
||||||
|
static int default_value_is_changeable_p (struct varobj *var);
|
||||||
|
|
||||||
/* C implementation */
|
/* C implementation */
|
||||||
|
|
||||||
static int c_number_of_children (struct varobj *var);
|
static int c_number_of_children (struct varobj *var);
|
||||||
|
@ -384,6 +386,8 @@ static struct type *ada_type_of_child (struct varobj *parent, int index);
|
||||||
static char *ada_value_of_variable (struct varobj *var,
|
static char *ada_value_of_variable (struct varobj *var,
|
||||||
enum varobj_display_formats format);
|
enum varobj_display_formats format);
|
||||||
|
|
||||||
|
static int ada_value_is_changeable_p (struct varobj *var);
|
||||||
|
|
||||||
static int ada_value_has_mutated (struct varobj *var, struct value *new_val,
|
static int ada_value_has_mutated (struct varobj *var, struct value *new_val,
|
||||||
struct type *new_type);
|
struct type *new_type);
|
||||||
|
|
||||||
|
@ -421,6 +425,16 @@ struct language_specific
|
||||||
char *(*value_of_variable) (struct varobj * var,
|
char *(*value_of_variable) (struct varobj * var,
|
||||||
enum varobj_display_formats format);
|
enum varobj_display_formats format);
|
||||||
|
|
||||||
|
/* Return non-zero if changes in value of VAR must be detected and
|
||||||
|
reported by -var-update. Return zero if -var-update should never
|
||||||
|
report changes of such values. This makes sense for structures
|
||||||
|
(since the changes in children values will be reported separately),
|
||||||
|
or for artifical objects (like 'public' pseudo-field in C++).
|
||||||
|
|
||||||
|
Return value of 0 means that gdb need not call value_fetch_lazy
|
||||||
|
for the value of this variable object. */
|
||||||
|
int (*value_is_changeable_p) (struct varobj *var);
|
||||||
|
|
||||||
/* Return nonzero if the type of VAR has mutated.
|
/* Return nonzero if the type of VAR has mutated.
|
||||||
|
|
||||||
VAR's value is still the varobj's previous value, while NEW_VALUE
|
VAR's value is still the varobj's previous value, while NEW_VALUE
|
||||||
|
@ -450,6 +464,7 @@ static struct language_specific languages[vlang_end] = {
|
||||||
c_value_of_child,
|
c_value_of_child,
|
||||||
c_type_of_child,
|
c_type_of_child,
|
||||||
c_value_of_variable,
|
c_value_of_variable,
|
||||||
|
default_value_is_changeable_p,
|
||||||
NULL /* value_has_mutated */}
|
NULL /* value_has_mutated */}
|
||||||
,
|
,
|
||||||
/* C */
|
/* C */
|
||||||
|
@ -463,6 +478,7 @@ static struct language_specific languages[vlang_end] = {
|
||||||
c_value_of_child,
|
c_value_of_child,
|
||||||
c_type_of_child,
|
c_type_of_child,
|
||||||
c_value_of_variable,
|
c_value_of_variable,
|
||||||
|
default_value_is_changeable_p,
|
||||||
NULL /* value_has_mutated */}
|
NULL /* value_has_mutated */}
|
||||||
,
|
,
|
||||||
/* C++ */
|
/* C++ */
|
||||||
|
@ -476,6 +492,7 @@ static struct language_specific languages[vlang_end] = {
|
||||||
cplus_value_of_child,
|
cplus_value_of_child,
|
||||||
cplus_type_of_child,
|
cplus_type_of_child,
|
||||||
cplus_value_of_variable,
|
cplus_value_of_variable,
|
||||||
|
default_value_is_changeable_p,
|
||||||
NULL /* value_has_mutated */}
|
NULL /* value_has_mutated */}
|
||||||
,
|
,
|
||||||
/* Java */
|
/* Java */
|
||||||
|
@ -489,6 +506,7 @@ static struct language_specific languages[vlang_end] = {
|
||||||
java_value_of_child,
|
java_value_of_child,
|
||||||
java_type_of_child,
|
java_type_of_child,
|
||||||
java_value_of_variable,
|
java_value_of_variable,
|
||||||
|
default_value_is_changeable_p,
|
||||||
NULL /* value_has_mutated */},
|
NULL /* value_has_mutated */},
|
||||||
/* Ada */
|
/* Ada */
|
||||||
{
|
{
|
||||||
|
@ -501,6 +519,7 @@ static struct language_specific languages[vlang_end] = {
|
||||||
ada_value_of_child,
|
ada_value_of_child,
|
||||||
ada_type_of_child,
|
ada_type_of_child,
|
||||||
ada_value_of_variable,
|
ada_value_of_variable,
|
||||||
|
ada_value_is_changeable_p,
|
||||||
ada_value_has_mutated}
|
ada_value_has_mutated}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -700,12 +719,12 @@ varobj_create (char *objname,
|
||||||
else
|
else
|
||||||
var->type = value_type (value);
|
var->type = value_type (value);
|
||||||
|
|
||||||
install_new_value (var, value, 1 /* Initial assignment */);
|
|
||||||
|
|
||||||
/* Set language info */
|
/* Set language info */
|
||||||
lang = variable_language (var);
|
lang = variable_language (var);
|
||||||
var->root->lang = &languages[lang];
|
var->root->lang = &languages[lang];
|
||||||
|
|
||||||
|
install_new_value (var, value, 1 /* Initial assignment */);
|
||||||
|
|
||||||
/* Set ourselves as our root. */
|
/* Set ourselves as our root. */
|
||||||
var->root->rootvar = var;
|
var->root->rootvar = var;
|
||||||
|
|
||||||
|
@ -2905,62 +2924,12 @@ varobj_editable_p (struct varobj *var)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return non-zero if changes in value of VAR
|
/* Call VAR's value_is_changeable_p language-specific callback. */
|
||||||
must be detected and reported by -var-update.
|
|
||||||
Return zero is -var-update should never report
|
|
||||||
changes of such values. This makes sense for structures
|
|
||||||
(since the changes in children values will be reported separately),
|
|
||||||
or for artifical objects (like 'public' pseudo-field in C++).
|
|
||||||
|
|
||||||
Return value of 0 means that gdb need not call value_fetch_lazy
|
|
||||||
for the value of this variable object. */
|
|
||||||
static int
|
static int
|
||||||
varobj_value_is_changeable_p (struct varobj *var)
|
varobj_value_is_changeable_p (struct varobj *var)
|
||||||
{
|
{
|
||||||
int r;
|
return var->root->lang->value_is_changeable_p (var);
|
||||||
struct type *type;
|
|
||||||
|
|
||||||
if (CPLUS_FAKE_CHILD (var))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* FIXME: This, and the check above, show that this routine
|
|
||||||
should be language-specific. */
|
|
||||||
if (variable_language (var) == vlang_ada)
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type = get_value_type (var);
|
|
||||||
|
|
||||||
switch (TYPE_CODE (type))
|
|
||||||
{
|
|
||||||
case TYPE_CODE_STRUCT:
|
|
||||||
case TYPE_CODE_UNION:
|
|
||||||
case TYPE_CODE_ARRAY:
|
|
||||||
r = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
r = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return 1 if that varobj is floating, that is is always evaluated in the
|
/* Return 1 if that varobj is floating, that is is always evaluated in the
|
||||||
|
@ -3037,7 +3006,37 @@ adjust_value_for_child_access (struct value **value,
|
||||||
need to call check_typedef here. */
|
need to call check_typedef here. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Implement the "value_is_changeable_p" varobj callback for most
|
||||||
|
languages. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
default_value_is_changeable_p (struct varobj *var)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
struct type *type;
|
||||||
|
|
||||||
|
if (CPLUS_FAKE_CHILD (var))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
type = get_value_type (var);
|
||||||
|
|
||||||
|
switch (TYPE_CODE (type))
|
||||||
|
{
|
||||||
|
case TYPE_CODE_STRUCT:
|
||||||
|
case TYPE_CODE_UNION:
|
||||||
|
case TYPE_CODE_ARRAY:
|
||||||
|
r = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
r = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
/* C */
|
/* C */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
c_number_of_children (struct varobj *var)
|
c_number_of_children (struct varobj *var)
|
||||||
{
|
{
|
||||||
|
@ -3967,6 +3966,32 @@ ada_value_of_variable (struct varobj *var, enum varobj_display_formats format)
|
||||||
return ada_varobj_get_value_of_variable (var->value, var->type, &opts);
|
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 default_value_is_changeable_p (var);
|
||||||
|
}
|
||||||
|
|
||||||
/* Implement the "value_has_mutated" routine for Ada. */
|
/* Implement the "value_has_mutated" routine for Ada. */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in New Issue