aboutsummaryrefslogtreecommitdiff
path: root/gdb/varobj.c
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@vmware.com>2010-05-17 18:48:52 +0000
committerMichael Snyder <msnyder@vmware.com>2010-05-17 18:48:52 +0000
commita109c7c1042127edfe32cbc50f315c3dc40f8607 (patch)
tree0322616410678495af3fd4898e49a5b3116fda2c /gdb/varobj.c
parent0cce5bd9dd8b740485b4ce847a0bd09a23097076 (diff)
downloadgdb-a109c7c1042127edfe32cbc50f315c3dc40f8607.zip
gdb-a109c7c1042127edfe32cbc50f315c3dc40f8607.tar.gz
gdb-a109c7c1042127edfe32cbc50f315c3dc40f8607.tar.bz2
2010-05-17 Michael Snyder <msnyder@vmware.com>
* valarith.c: White space. * valops.c: White space. * valprint.c: White space. * value.c: White space. * varobj.c: White space. * xcoffread.c: White space. * xml-support.c: White space. * xml-tdesc.c: White space.
Diffstat (limited to 'gdb/varobj.c')
-rw-r--r--gdb/varobj.c45
1 files changed, 40 insertions, 5 deletions
diff --git a/gdb/varobj.c b/gdb/varobj.c
index a6e9df3..b9b8e91b 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -512,6 +512,7 @@ find_frame_addr_in_frame_chain (CORE_ADDR frame_addr)
comparing it against our argument. */
CORE_ADDR frame_base = get_frame_base_address (frame);
int addr_bit = gdbarch_addr_bit (get_frame_arch (frame));
+
if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
frame_base &= ((CORE_ADDR) 1 << addr_bit) - 1;
@@ -622,6 +623,7 @@ varobj_create (char *objname,
/* Error getting the value. Try to at least get the
right type. */
struct value *type_only_value = evaluate_type (var->root->exp);
+
var->type = value_type (type_only_value);
}
else
@@ -924,6 +926,7 @@ install_dynamic_child (struct varobj *var,
{
/* There's no child yet. */
struct varobj *child = varobj_add_child (var, name, value);
+
if (new)
{
VEC_safe_push (varobj_p, *new, child);
@@ -933,6 +936,7 @@ install_dynamic_child (struct varobj *var,
else
{
varobj_p existing = VEC_index (varobj_p, var->children, index);
+
if (install_new_value (existing, value, 0))
{
if (changed)
@@ -1068,6 +1072,7 @@ update_dynamic_varobj_children (struct varobj *var,
if (i < VEC_length (varobj_p, var->children))
{
int j;
+
*cchanged = 1;
for (j = i; j < VEC_length (varobj_p, var->children); ++j)
varobj_delete (VEC_index (varobj_p, var->children, j), NULL, 0);
@@ -1171,6 +1176,7 @@ varobj_add_child (struct varobj *var, const char *name, struct value *value)
varobj_p v = create_child_with_value (var,
VEC_length (varobj_p, var->children),
name, value);
+
VEC_safe_push (varobj_p, var->children, v);
return v;
}
@@ -1486,6 +1492,7 @@ install_new_value (struct varobj *var, struct value *value, int initial)
{
struct varobj *parent = var->parent;
int frozen = var->frozen;
+
for (; !frozen && parent; parent = parent->parent)
frozen |= parent->frozen;
@@ -1694,6 +1701,7 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit)
if (!(*varp)->root->is_valid)
{
varobj_update_result r = {0};
+
r.varobj = *varp;
r.status = VAROBJ_INVALID;
VEC_safe_push (varobj_update_result, result, &r);
@@ -1703,6 +1711,7 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit)
if ((*varp)->root->rootvar == *varp)
{
varobj_update_result r = {0};
+
r.varobj = *varp;
r.status = VAROBJ_IN_SCOPE;
@@ -1734,6 +1743,7 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit)
else
{
varobj_update_result r = {0};
+
r.varobj = *varp;
VEC_safe_push (varobj_update_result, stack, &r);
}
@@ -1812,6 +1822,7 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit)
{
varobj_p tmp = VEC_index (varobj_p, changed, i);
varobj_update_result r = {0};
+
r.varobj = tmp;
r.changed = 1;
r.value_installed = 1;
@@ -1820,9 +1831,11 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit)
for (i = VEC_length (varobj_p, unchanged) - 1; i >= 0; --i)
{
varobj_p tmp = VEC_index (varobj_p, unchanged, i);
+
if (!tmp->frozen)
{
varobj_update_result r = {0};
+
r.varobj = tmp;
r.value_installed = 1;
VEC_safe_push (varobj_update_result, stack, &r);
@@ -1847,10 +1860,12 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit)
for (i = VEC_length (varobj_p, v->children)-1; i >= 0; --i)
{
varobj_p c = VEC_index (varobj_p, v->children, i);
+
/* Child may be NULL if explicitly deleted by -var-delete. */
if (c != NULL && !c->frozen)
{
varobj_update_result r = {0};
+
r.varobj = c;
VEC_safe_push (varobj_update_result, stack, &r);
}
@@ -1899,6 +1914,7 @@ delete_variable_1 (struct cpstack **resultp, int *delcountp,
for (i = 0; i < VEC_length (varobj_p, var->children); ++i)
{
varobj_p child = VEC_index (varobj_p, var->children, i);
+
if (!child)
continue;
if (!remove_from_parent_p)
@@ -2139,6 +2155,7 @@ static struct varobj *
new_root_variable (void)
{
struct varobj *var = new_variable ();
+
var->root = (struct varobj_root *) xmalloc (sizeof (struct varobj_root));;
var->root->lang = NULL;
var->root->exp = NULL;
@@ -2204,8 +2221,8 @@ static struct type *
get_type (struct varobj *var)
{
struct type *type;
- type = var->type;
+ type = var->type;
if (type != NULL)
type = check_typedef (type);
@@ -2400,6 +2417,7 @@ value_of_root (struct varobj **var_handle, int *type_changed)
correct in other frames, so update the expression. */
struct expression *tmp_exp = var->root->exp;
+
var->root->exp = tmp_var->root->exp;
tmp_var->root->exp = tmp_exp;
@@ -2512,9 +2530,11 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
{
PyObject *py_str
= python_string_to_target_python_string (output);
+
if (py_str)
{
char *s = PyString_AsString (py_str);
+
len = PyString_Size (py_str);
thevalue = xmemdup (s, len + 1, len + 1);
type = builtin_type (gdbarch)->builtin_char;
@@ -2671,7 +2691,8 @@ adjust_value_for_child_access (struct value **value,
{
if (value && *value)
{
- int success = gdb_value_ind (*value, value);
+ int success = gdb_value_ind (*value, value);
+
if (!success)
*value = NULL;
}
@@ -2754,8 +2775,8 @@ value_struct_element_index (struct value *value, int type_index)
{
struct value *result = NULL;
volatile struct gdb_exception e;
-
struct type *type = value_type (value);
+
type = check_typedef (type);
gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT
@@ -2822,6 +2843,7 @@ c_describe_child (struct varobj *parent, int index,
if (cvalue && value)
{
int real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
+
gdb_value_subscript (value, real_index, cvalue);
}
@@ -2855,6 +2877,7 @@ c_describe_child (struct varobj *parent, int index,
if (cfull_expression)
{
char *join = was_ptr ? "->" : ".";
+
*cfull_expression = xstrprintf ("(%s)%s%s", parent_expression, join,
TYPE_FIELD_NAME (type, index));
}
@@ -2868,6 +2891,7 @@ c_describe_child (struct varobj *parent, int index,
if (cvalue && value)
{
int success = gdb_value_ind (value, cvalue);
+
if (!success)
*cvalue = NULL;
}
@@ -2897,6 +2921,7 @@ static char *
c_name_of_child (struct varobj *parent, int index)
{
char *name;
+
c_describe_child (parent, index, &name, NULL, NULL, NULL);
return name;
}
@@ -2923,6 +2948,7 @@ check_scope (struct varobj *var)
if (fi)
{
CORE_ADDR pc = get_frame_pc (fi);
+
if (pc < BLOCK_START (var->root->valid_block) ||
pc >= BLOCK_END (var->root->valid_block))
scope = 0;
@@ -2985,8 +3011,8 @@ static struct value *
c_value_of_child (struct varobj *parent, int index)
{
struct value *value = NULL;
- c_describe_child (parent, index, NULL, &value, NULL, NULL);
+ c_describe_child (parent, index, NULL, &value, NULL, NULL);
return value;
}
@@ -2994,6 +3020,7 @@ static struct type *
c_type_of_child (struct varobj *parent, int index)
{
struct type *type = NULL;
+
c_describe_child (parent, index, NULL, NULL, &type, NULL);
return type;
}
@@ -3025,6 +3052,7 @@ c_value_of_variable (struct varobj *var, enum varobj_display_formats format)
case TYPE_CODE_ARRAY:
{
char *number;
+
number = xstrprintf ("[%d]", var->num_children);
return (number);
}
@@ -3217,6 +3245,7 @@ cplus_describe_child (struct varobj *parent, int index,
|| TYPE_CODE (type) == TYPE_CODE_UNION)
{
char *join = was_ptr ? "->" : ".";
+
if (CPLUS_FAKE_CHILD (parent))
{
/* The fields of the class type are ordered as they
@@ -3278,6 +3307,7 @@ cplus_describe_child (struct varobj *parent, int index,
if (cfull_expression)
{
char *ptr = was_ptr ? "*" : "";
+
/* Cast the parent to the base' type. Note that in gdb,
expression like
(Base1)d
@@ -3296,6 +3326,7 @@ cplus_describe_child (struct varobj *parent, int index,
{
char *access = NULL;
int children[3];
+
cplus_class_num_children (type, children);
/* Everything beyond the baseclasses can
@@ -3351,6 +3382,7 @@ static char *
cplus_name_of_child (struct varobj *parent, int index)
{
char *name = NULL;
+
cplus_describe_child (parent, index, &name, NULL, NULL, NULL);
return name;
}
@@ -3373,6 +3405,7 @@ static struct value *
cplus_value_of_child (struct varobj *parent, int index)
{
struct value *value = NULL;
+
cplus_describe_child (parent, index, NULL, &value, NULL, NULL);
return value;
}
@@ -3381,12 +3414,14 @@ static struct type *
cplus_type_of_child (struct varobj *parent, int index)
{
struct type *type = NULL;
+
cplus_describe_child (parent, index, NULL, NULL, &type, NULL);
return type;
}
static char *
-cplus_value_of_variable (struct varobj *var, enum varobj_display_formats format)
+cplus_value_of_variable (struct varobj *var,
+ enum varobj_display_formats format)
{
/* If we have one of our special types, don't print out