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;
char *expression, CORE_ADDR frame, enum varobj_type type)
{
struct varobj *var;
- struct frame_info *fi;
- struct frame_info *old_fi = NULL;
- struct block *block;
struct cleanup *old_chain;
/* Fill out a varobj structure for the (root) variable being constructed. */
if (expression != NULL)
{
+ struct frame_info *fi;
+ struct frame_id old_id = null_frame_id;
+ struct block *block;
char *p;
enum varobj_languages lang;
struct value *value = NULL;
var->root->frame = get_frame_id (fi);
var->root->thread_id = pid_to_thread_id (inferior_ptid);
- old_fi = get_selected_frame (NULL);
+ old_id = get_frame_id (get_selected_frame (NULL));
select_frame (fi);
}
/* 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
var->root->rootvar = var;
/* Reset the selected frame */
- if (old_fi != NULL)
- select_frame (old_fi);
+ if (frame_id_p (old_id))
+ select_frame (frame_find_by_id (old_id));
}
/* If the variable object name is null, that means this
{
/* There's no child yet. */
struct varobj *child = varobj_add_child (var, name, value);
+
if (new)
{
VEC_safe_push (varobj_p, *new, child);
else
{
varobj_p existing = VEC_index (varobj_p, var->children, index);
+
if (install_new_value (existing, value, 0))
{
if (changed)
error (_("Invalid item from the child list"));
v = convert_value_from_python (py_v);
+ if (v == NULL)
+ gdbpy_print_stack ();
install_dynamic_child (var, can_mention ? changed : NULL,
can_mention ? new : NULL,
can_mention ? unchanged : NULL,
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);
VEC (varobj_p)*
varobj_list_children (struct varobj *var, int *from, int *to)
{
- struct varobj *child;
char *name;
int i, children_changed;
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;
}
varobj_set_value (struct varobj *var, char *expression)
{
struct value *val;
- int offset = 0;
- int error = 0;
/* The argument "expression" contains the variable's new value.
We need to first construct a legal expression for this -- ugh! */
struct value *value;
int saved_input_radix = input_radix;
char *s = expression;
- int i;
gdb_assert (varobj_editable_p (var));
if (var->constructor != Py_None && var->value)
{
struct cleanup *cleanup;
- PyObject *pretty_printer = NULL;
cleanup = varobj_ensure_python_env (var);
{
struct varobj *parent = var->parent;
int frozen = var->frozen;
+
for (; !frozen && parent; parent = parent->parent)
frozen |= parent->frozen;
{
xfree (print_value);
print_value = value_get_print_value (var->value, var->format, var);
- if (!var->print_value || strcmp (var->print_value, print_value) != 0)
+ if ((var->print_value == NULL && print_value != NULL)
+ || (var->print_value != NULL && print_value == NULL)
+ || (var->print_value != NULL && print_value != NULL
+ && strcmp (var->print_value, print_value) != 0))
changed = 1;
}
if (var->print_value)
varobj_set_visualizer (struct varobj *var, const char *visualizer)
{
#if HAVE_PYTHON
- PyObject *mainmod, *globals, *pretty_printer, *constructor;
- struct cleanup *back_to, *value;
+ PyObject *mainmod, *globals, *constructor;
+ struct cleanup *back_to;
back_to = varobj_ensure_python_env (var);
int changed = 0;
int type_changed = 0;
int i;
- int vleft;
- struct varobj *v;
- struct varobj **cv;
- struct varobj **templist = NULL;
struct value *new;
VEC (varobj_update_result) *stack = NULL;
VEC (varobj_update_result) *result = NULL;
- struct frame_info *fi;
/* Frozen means frozen -- we don't check for any change in
this varobj, including its going out of scope, or
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);
if ((*varp)->root->rootvar == *varp)
{
varobj_update_result r = {0};
+
r.varobj = *varp;
r.status = VAROBJ_IN_SCOPE;
else
{
varobj_update_result r = {0};
+
r.varobj = *varp;
VEC_safe_push (varobj_update_result, stack, &r);
}
{
varobj_p tmp = VEC_index (varobj_p, changed, i);
varobj_update_result r = {0};
+
r.varobj = tmp;
r.changed = 1;
r.value_installed = 1;
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);
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);
}
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)
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;
get_type (struct varobj *var)
{
struct type *type;
- type = var->type;
+ type = var->type;
if (type != NULL)
type = check_typedef (type);
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;
long len = 0;
char *encoding = NULL;
struct gdbarch *gdbarch = NULL;
+ /* Initialize it just to avoid a GCC false warning. */
+ CORE_ADDR str_addr = 0;
+ int string_print = 0;
if (value == NULL)
return NULL;
+ stb = mem_fileopen ();
+ old_chain = make_cleanup_ui_file_delete (stb);
+
gdbarch = get_type_arch (value_type (value));
#if HAVE_PYTHON
{
- struct cleanup *back_to = varobj_ensure_python_env (var);
PyObject *value_formatter = var->pretty_printer;
+ varobj_ensure_python_env (var);
+
if (value_formatter)
{
/* First check to see if we have any children at all. If so,
we simply return {...}. */
if (dynamic_varobj_has_child_method (var))
- return xstrdup ("{...}");
+ {
+ do_cleanups (old_chain);
+ return xstrdup ("{...}");
+ }
if (PyObject_HasAttr (value_formatter, gdbpy_to_string_cst))
{
char *hint;
struct value *replacement;
- int string_print = 0;
PyObject *output = NULL;
hint = gdbpy_get_display_hint (value_formatter);
}
output = apply_varobj_pretty_printer (value_formatter,
- &replacement);
+ &replacement,
+ stb);
if (output)
{
+ make_cleanup_py_decref (output);
+
if (gdbpy_is_lazy_string (output))
{
- thevalue = gdbpy_extract_lazy_string (output, &type,
- &len, &encoding);
+ gdbpy_extract_lazy_string (output, &str_addr, &type,
+ &len, &encoding);
+ make_cleanup (free_current_contents, &encoding);
string_print = 1;
}
else
{
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;
Py_DECREF (py_str);
+
+ if (!string_print)
+ {
+ do_cleanups (old_chain);
+ return thevalue;
+ }
+
+ make_cleanup (xfree, thevalue);
}
+ else
+ gdbpy_print_stack ();
}
- Py_DECREF (output);
- }
- if (thevalue && !string_print)
- {
- do_cleanups (back_to);
- xfree (encoding);
- return thevalue;
}
if (replacement)
value = replacement;
}
}
- do_cleanups (back_to);
}
#endif
- stb = mem_fileopen ();
- old_chain = make_cleanup_ui_file_delete (stb);
-
get_formatted_print_options (&opts, format_code[(int) format]);
opts.deref_ref = 0;
opts.raw = 1;
if (thevalue)
- {
- make_cleanup (xfree, thevalue);
- make_cleanup (xfree, encoding);
- LA_PRINT_STRING (stb, type, thevalue, len, encoding, 0, &opts);
- }
+ LA_PRINT_STRING (stb, type, thevalue, len, encoding, 0, &opts);
+ else if (string_print)
+ val_print_string (type, encoding, str_addr, len, stb, &opts);
else
common_val_print (value, stb, 0, &opts, current_language);
thevalue = ui_file_xstrdup (stb, NULL);
varobj_editable_p (struct varobj *var)
{
struct type *type;
- struct value *value;
if (!(var->root->is_valid && var->value && VALUE_LVAL (var->value)))
return 0;
{
if (value && *value)
{
- int success = gdb_value_ind (*value, value);
+ int success = gdb_value_ind (*value, value);
+
if (!success)
*value = NULL;
}
{
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
if (cvalue && value)
{
int real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
+
gdb_value_subscript (value, real_index, cvalue);
}
if (cfull_expression)
{
char *join = was_ptr ? "->" : ".";
+
*cfull_expression = xstrprintf ("(%s)%s%s", parent_expression, join,
TYPE_FIELD_NAME (type, index));
}
if (cvalue && value)
{
int success = gdb_value_ind (value, cvalue);
+
if (!success)
*cvalue = NULL;
}
c_name_of_child (struct varobj *parent, int index)
{
char *name;
+
c_describe_child (parent, index, &name, NULL, NULL, NULL);
return name;
}
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;
{
struct value *new_val = NULL;
struct varobj *var = *var_handle;
- struct frame_info *fi;
int within_scope = 0;
struct cleanup *back_to;
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;
}
c_type_of_child (struct varobj *parent, int index)
{
struct type *type = NULL;
+
c_describe_child (parent, index, NULL, NULL, &type, NULL);
return type;
}
case TYPE_CODE_ARRAY:
{
char *number;
+
number = xstrprintf ("[%d]", var->num_children);
return (number);
}
char **cname, struct value **cvalue, struct type **ctype,
char **cfull_expression)
{
- char *name = NULL;
struct value *value;
struct type *type;
int was_ptr;
|| 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
if (cfull_expression)
{
char *ptr = was_ptr ? "*" : "";
+
/* Cast the parent to the base' type. Note that in gdb,
expression like
(Base1)d
{
char *access = NULL;
int children[3];
+
cplus_class_num_children (type, children);
/* Everything beyond the baseclasses can
cplus_name_of_child (struct varobj *parent, int index)
{
char *name = NULL;
+
cplus_describe_child (parent, index, &name, NULL, NULL, NULL);
return name;
}
cplus_value_of_child (struct varobj *parent, int index)
{
struct value *value = NULL;
+
cplus_describe_child (parent, index, NULL, &value, NULL, NULL);
return value;
}
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