aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2015-02-10 10:46:12 -0500
committerSimon Marchi <simon.marchi@ericsson.com>2015-02-10 12:57:47 -0500
commitc1cc6152620563bbe861cfc2fa0a796e71ca87b5 (patch)
treee4f79bb5c6f7e33e255ac0d6648bc567156ef34c
parent834f871cdc6e5d9f5bda9ce607fd3c47f41a2ade (diff)
downloadgdb-c1cc6152620563bbe861cfc2fa0a796e71ca87b5.zip
gdb-c1cc6152620563bbe861cfc2fa0a796e71ca87b5.tar.gz
gdb-c1cc6152620563bbe861cfc2fa0a796e71ca87b5.tar.bz2
Finish constification of varobj interface
This completes the constification of the struct varobj pointers in the lang_varobj_ops interface partially done in b09e2c591f9221d865bfe8425990a6bf9fab24e3. As suggested by Pedro, varobj_get_path_expr casts away the const to assign the "mutable" struct member. gdb/ChangeLog: * ada-varobj.c (ada_name_of_child): Constify parent. (ada_path_expr_of_child): Same. (ada_value_of_child): Same. (ada_type_of_child): Same. * c-varobj.c (c_is_path_expr_parent): Same. (c_describe_child): Same. (c_name_of_child): Same. (c_value_of_child): Same. (c_type_of_child): Same. (cplus_number_of_children): Same. (cplus_describe_child): Constify var. (cplus_name_of_child): Constify parent. (cplus_value_of_child): Same. (cplus_type_of_child): Same. * jv-varobj.c (java_name_of_child): Same. (java_value_of_child): Same. (java_type_of_child): Same. * varobj.c (value_of_child): Same. (varobj_default_is_path_expr_parent): Constify var, parent and return value. (varobj_get_path_expr): Constify var, modify path_expr through mutable_var. (install_new_value): Constify parent. (value_of_child): Constify parent. * varobj.h (struct varobj): Constify parent. (struct lang_varobj_ops): Constify name_of_child, value_of_child and type_of_child. (varobj_get_path_expr): Constify var. (varobj_get_path_expr_parent): Constify var and return value.
-rw-r--r--gdb/ChangeLog32
-rw-r--r--gdb/ada-varobj.c8
-rw-r--r--gdb/c-varobj.c22
-rw-r--r--gdb/jv-varobj.c6
-rw-r--r--gdb/varobj.c17
-rw-r--r--gdb/varobj.h13
6 files changed, 66 insertions, 32 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9941dba..6b9adf0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,35 @@
+2015-02-10 Simon Marchi <simon.marchi@ericsson.com>
+
+ * ada-varobj.c (ada_name_of_child): Constify parent.
+ (ada_path_expr_of_child): Same.
+ (ada_value_of_child): Same.
+ (ada_type_of_child): Same.
+ * c-varobj.c (c_is_path_expr_parent): Same.
+ (c_describe_child): Same.
+ (c_name_of_child): Same.
+ (c_value_of_child): Same.
+ (c_type_of_child): Same.
+ (cplus_number_of_children): Same.
+ (cplus_describe_child): Constify var.
+ (cplus_name_of_child): Constify parent.
+ (cplus_value_of_child): Same.
+ (cplus_type_of_child): Same.
+ * jv-varobj.c (java_name_of_child): Same.
+ (java_value_of_child): Same.
+ (java_type_of_child): Same.
+ * varobj.c (value_of_child): Same.
+ (varobj_default_is_path_expr_parent): Constify var, parent and return
+ value.
+ (varobj_get_path_expr): Constify var, modify path_expr through
+ mutable_var.
+ (install_new_value): Constify parent.
+ (value_of_child): Constify parent.
+ * varobj.h (struct varobj): Constify parent.
+ (struct lang_varobj_ops): Constify name_of_child, value_of_child and
+ type_of_child.
+ (varobj_get_path_expr): Constify var.
+ (varobj_get_path_expr_parent): Constify var and return value.
+
2015-02-10 Luis Machado <lgustavo@codesourcery.com>
* arm-tdep.c (arm_prologue_unwind_stop_reason): New function.
diff --git a/gdb/ada-varobj.c b/gdb/ada-varobj.c
index 7407af4..83d0707 100644
--- a/gdb/ada-varobj.c
+++ b/gdb/ada-varobj.c
@@ -918,7 +918,7 @@ ada_name_of_variable (const struct varobj *parent)
}
static char *
-ada_name_of_child (struct varobj *parent, int index)
+ada_name_of_child (const struct varobj *parent, int index)
{
return ada_varobj_get_name_of_child (parent->value, parent->type,
parent->name, index);
@@ -927,7 +927,7 @@ ada_name_of_child (struct varobj *parent, int index)
static char*
ada_path_expr_of_child (const struct varobj *child)
{
- struct varobj *parent = child->parent;
+ const 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,
@@ -938,14 +938,14 @@ ada_path_expr_of_child (const struct varobj *child)
}
static struct value *
-ada_value_of_child (struct varobj *parent, int index)
+ada_value_of_child (const 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)
+ada_type_of_child (const struct varobj *parent, int index)
{
return ada_varobj_get_type_of_child (parent->value, parent->type,
index);
diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c
index 9394d7c..363a356 100644
--- a/gdb/c-varobj.c
+++ b/gdb/c-varobj.c
@@ -146,7 +146,7 @@ c_is_path_expr_parent (const struct varobj *var)
&& TYPE_NAME (type) == NULL
&& TYPE_TAG_NAME (type) == NULL)
{
- struct varobj *parent = var->parent;
+ const struct varobj *parent = var->parent;
while (parent != NULL && CPLUS_FAKE_CHILD (parent))
parent = parent->parent;
@@ -282,7 +282,7 @@ value_struct_element_index (struct value *value, int type_index)
to NULL. */
static void
-c_describe_child (struct varobj *parent, int index,
+c_describe_child (const struct varobj *parent, int index,
char **cname, struct value **cvalue, struct type **ctype,
char **cfull_expression)
{
@@ -422,7 +422,7 @@ c_describe_child (struct varobj *parent, int index,
}
static char *
-c_name_of_child (struct varobj *parent, int index)
+c_name_of_child (const struct varobj *parent, int index)
{
char *name;
@@ -441,7 +441,7 @@ c_path_expr_of_child (const struct varobj *child)
}
static struct value *
-c_value_of_child (struct varobj *parent, int index)
+c_value_of_child (const struct varobj *parent, int index)
{
struct value *value = NULL;
@@ -450,7 +450,7 @@ c_value_of_child (struct varobj *parent, int index)
}
static struct type *
-c_type_of_child (struct varobj *parent, int index)
+c_type_of_child (const struct varobj *parent, int index)
{
struct type *type = NULL;
@@ -614,7 +614,7 @@ cplus_number_of_children (const struct varobj *var)
/* It is necessary to access a real type (via RTTI). */
if (opts.objectprint)
{
- struct varobj *parent = var->parent;
+ const struct varobj *parent = var->parent;
value = parent->value;
lookup_actual_type = (TYPE_CODE (parent->type) == TYPE_CODE_REF
@@ -697,7 +697,7 @@ match_accessibility (struct type *type, int index, enum accessibility acc)
}
static void
-cplus_describe_child (struct varobj *parent, int index,
+cplus_describe_child (const struct varobj *parent, int index,
char **cname, struct value **cvalue, struct type **ctype,
char **cfull_expression)
{
@@ -706,7 +706,7 @@ cplus_describe_child (struct varobj *parent, int index,
int was_ptr;
int lookup_actual_type = 0;
char *parent_expression = NULL;
- struct varobj *var;
+ const struct varobj *var;
struct value_print_options opts;
if (cname)
@@ -898,7 +898,7 @@ cplus_describe_child (struct varobj *parent, int index,
}
static char *
-cplus_name_of_child (struct varobj *parent, int index)
+cplus_name_of_child (const struct varobj *parent, int index)
{
char *name = NULL;
@@ -917,7 +917,7 @@ cplus_path_expr_of_child (const struct varobj *child)
}
static struct value *
-cplus_value_of_child (struct varobj *parent, int index)
+cplus_value_of_child (const struct varobj *parent, int index)
{
struct value *value = NULL;
@@ -926,7 +926,7 @@ cplus_value_of_child (struct varobj *parent, int index)
}
static struct type *
-cplus_type_of_child (struct varobj *parent, int index)
+cplus_type_of_child (const struct varobj *parent, int index)
{
struct type *type = NULL;
diff --git a/gdb/jv-varobj.c b/gdb/jv-varobj.c
index dbd92a6..69e88fb 100644
--- a/gdb/jv-varobj.c
+++ b/gdb/jv-varobj.c
@@ -47,7 +47,7 @@ java_name_of_variable (const struct varobj *parent)
}
static char *
-java_name_of_child (struct varobj *parent, int index)
+java_name_of_child (const struct varobj *parent, int index)
{
char *name, *p;
@@ -72,13 +72,13 @@ java_path_expr_of_child (const struct varobj *child)
}
static struct value *
-java_value_of_child (struct varobj *parent, int index)
+java_value_of_child (const struct varobj *parent, int index)
{
return cplus_varobj_ops.value_of_child (parent, index);
}
static struct type *
-java_type_of_child (struct varobj *parent, int index)
+java_type_of_child (const struct varobj *parent, int index)
{
return cplus_varobj_ops.type_of_child (parent, index);
}
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 268ba3c..43ea96f 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -201,7 +201,7 @@ static char *name_of_child (struct varobj *, int);
static struct value *value_of_root (struct varobj **var_handle, int *);
-static struct value *value_of_child (struct varobj *parent, int index);
+static struct value *value_of_child (const struct varobj *parent, int index);
static char *my_value_of_variable (struct varobj *var,
enum varobj_display_formats format);
@@ -1019,10 +1019,10 @@ varobj_default_is_path_expr_parent (const struct varobj *var)
/* Return the path expression parent for VAR. */
-struct varobj *
-varobj_get_path_expr_parent (struct varobj *var)
+const struct varobj *
+varobj_get_path_expr_parent (const struct varobj *var)
{
- struct varobj *parent = var;
+ const struct varobj *parent = var;
while (!is_root_p (parent) && !is_path_expr_parent (parent))
parent = parent->parent;
@@ -1033,16 +1033,17 @@ varobj_get_path_expr_parent (struct varobj *var)
/* Return a pointer to the full rooted expression of varobj VAR.
If it has not been computed yet, compute it. */
char *
-varobj_get_path_expr (struct varobj *var)
+varobj_get_path_expr (const struct varobj *var)
{
if (var->path_expr == NULL)
{
/* For root varobjs, we initialize path_expr
when creating varobj, so here it should be
child varobj. */
+ struct varobj *mutable_var = (struct varobj *) var;
gdb_assert (!is_root_p (var));
- var->path_expr = (*var->root->lang_ops->path_expr_of_child) (var);
+ mutable_var->path_expr = (*var->root->lang_ops->path_expr_of_child) (var);
}
return var->path_expr;
@@ -1378,7 +1379,7 @@ install_new_value (struct varobj *var, struct value *value, int initial)
will be lazy, which means we've lost that old value. */
if (need_to_fetch && value && value_lazy (value))
{
- struct varobj *parent = var->parent;
+ const struct varobj *parent = var->parent;
int frozen = var->frozen;
for (; !frozen && parent; parent = parent->parent)
@@ -2483,7 +2484,7 @@ value_of_root (struct varobj **var_handle, int *type_changed)
/* What is the ``struct value *'' for the INDEX'th child of PARENT? */
static struct value *
-value_of_child (struct varobj *parent, int index)
+value_of_child (const struct varobj *parent, int index)
{
struct value *value;
diff --git a/gdb/varobj.h b/gdb/varobj.h
index 30c31ef..6fe7009 100644
--- a/gdb/varobj.h
+++ b/gdb/varobj.h
@@ -120,7 +120,7 @@ struct varobj
int num_children;
/* If this object is a child, this points to its immediate parent. */
- struct varobj *parent;
+ const struct varobj *parent;
/* Children of this object. */
VEC (varobj_p) *children;
@@ -175,7 +175,7 @@ struct lang_varobj_ops
/* The name of the INDEX'th child of PARENT. The returned value must be
freed by the caller. */
- char *(*name_of_child) (struct varobj *parent, int index);
+ char *(*name_of_child) (const struct varobj *parent, int index);
/* Returns the rooted expression of CHILD, which is a variable
obtain that has some parent. The returned value must be freed by the
@@ -183,10 +183,10 @@ struct lang_varobj_ops
char *(*path_expr_of_child) (const struct varobj *child);
/* The ``struct value *'' of the INDEX'th child of PARENT. */
- struct value *(*value_of_child) (struct varobj *parent, int index);
+ struct value *(*value_of_child) (const struct varobj *parent, int index);
/* The type of the INDEX'th child of PARENT. */
- struct type *(*type_of_child) (struct varobj *parent, int index);
+ struct type *(*type_of_child) (const struct varobj *parent, int index);
/* The current value of VAR. The returned value must be freed by the
caller. */
@@ -285,7 +285,7 @@ extern char *varobj_get_type (struct varobj *var);
extern struct type *varobj_get_gdb_type (const struct varobj *var);
-extern char *varobj_get_path_expr (struct varobj *var);
+extern char *varobj_get_path_expr (const struct varobj *var);
extern const struct language_defn *
varobj_get_language (const struct varobj *var);
@@ -329,7 +329,8 @@ extern struct type *varobj_get_value_type (const struct varobj *var);
extern int varobj_is_anonymous_child (const struct varobj *child);
-extern struct varobj *varobj_get_path_expr_parent (struct varobj *var);
+extern const struct varobj *
+ varobj_get_path_expr_parent (const struct varobj *var);
extern char *varobj_value_get_print_value (struct value *value,
enum varobj_display_formats format,