/* Implementation of the GDB variable objects API.
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
- 2009, 2010 Free Software Foundation, Inc.
+ 2009, 2010, 2011 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#if HAVE_PYTHON
#include "python/python.h"
#include "python/python-internal.h"
+#else
+typedef int PyObject;
#endif
/* Non-zero if we want to see trace of varobj level stuff. */
}
/* Deletes a varobj and all its children if only_children == 0,
- otherwise deletes only the children; returns a malloc'ed list of all the
- (malloc'ed) names of the variables that have been deleted (NULL terminated) */
+ otherwise deletes only the children; returns a malloc'ed list of
+ all the (malloc'ed) names of the variables that have been deleted
+ (NULL terminated) */
int
varobj_delete (struct varobj *var, char ***dellist, int only_children)
char *print_value = NULL;
/* We need to know the varobj's type to decide if the value should
- be fetched or not. C++ fake children (public/protected/private) don't have
- a type. */
+ be fetched or not. C++ fake children (public/protected/private)
+ don't have a type. */
gdb_assert (var->type || CPLUS_FAKE_CHILD (var));
changeable = varobj_value_is_changeable_p (var);
to compare with. */
if (!initial && changeable)
{
- /* If the value of the varobj was changed by -var-set-value, then the
- value in the varobj and in the target is the same. However, that value
- is different from the value that the varobj had after the previous
- -var-update. So need to the varobj as changed. */
+ /* If the value of the varobj was changed by -var-set-value,
+ then the value in the varobj and in the target is the same.
+ However, that value is different from the value that the
+ varobj had after the previous -var-update. So need to the
+ varobj as changed. */
if (var->updated)
{
changed = 1;
}
if (cr == NULL)
{
- warning
- ("Assertion failed: Could not find varobj \"%s\" in root list",
- var->obj_name);
+ warning (_("Assertion failed: Could not find "
+ "varobj \"%s\" in root list"),
+ var->obj_name);
return;
}
if (prer == NULL)
{
struct varobj *var = new_variable ();
- var->root = (struct varobj_root *) xmalloc (sizeof (struct varobj_root));;
+ var->root = (struct varobj_root *) xmalloc (sizeof (struct varobj_root));
var->root->lang = NULL;
var->root->exp = NULL;
var->root->valid_block = NULL;
return (*var->root->lang->number_of_children) (var);;
}
-/* What is the expression for the root varobj VAR? Returns a malloc'd string. */
+/* What is the expression for the root varobj VAR? Returns a malloc'd
+ string. */
static char *
name_of_variable (struct varobj *var)
{
return (*var->root->lang->name_of_variable) (var);
}
-/* What is the name of the INDEX'th child of VAR? Returns a malloc'd string. */
+/* What is the name of the INDEX'th child of VAR? Returns a malloc'd
+ string. */
static char *
name_of_child (struct varobj *var, int index)
{
struct varobj *var)
{
struct ui_file *stb;
- struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
+ struct cleanup *old_chain;
gdb_byte *thevalue = NULL;
struct value_print_options opts;
struct type *type = NULL;
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
{
/* 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))
{
}
output = apply_varobj_pretty_printer (value_formatter,
- &replacement);
+ &replacement,
+ stb);
if (output)
{
make_cleanup_py_decref (output);
}
#endif
- stb = mem_fileopen ();
- make_cleanup_ui_file_delete (stb);
-
get_formatted_print_options (&opts, format_code[(int) format]);
opts.deref_ref = 0;
opts.raw = 1;
{
case TYPE_CODE_ARRAY:
if (cname)
- *cname = xstrdup (int_string (index
- + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)),
- 10, 1, 0, 0));
+ *cname
+ = xstrdup (int_string (index
+ + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)),
+ 10, 1, 0, 0));
if (cvalue && value)
{
*ctype = TYPE_FIELD_TYPE (type, type_index);
if (cfull_expression)
- *cfull_expression = xstrprintf ("((%s)%s%s)", parent_expression,
- join,
- TYPE_FIELD_NAME (type, type_index));
+ *cfull_expression
+ = xstrprintf ("((%s)%s%s)", parent_expression,
+ join,
+ TYPE_FIELD_NAME (type, type_index));
}
else if (index < TYPE_N_BASECLASSES (type))
{
memset (varobj_table, 0, sizeof_table);
add_setshow_zinteger_cmd ("debugvarobj", class_maintenance,
- &varobjdebug, _("\
-Set varobj debugging."), _("\
-Show varobj debugging."), _("\
-When non-zero, varobj debugging is enabled."),
- NULL,
- show_varobjdebug,
+ &varobjdebug,
+ _("Set varobj debugging."),
+ _("Show varobj debugging."),
+ _("When non-zero, varobj debugging is enabled."),
+ NULL, show_varobjdebug,
&setlist, &showlist);
}