/* Implementation of the GDB variable objects API.
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
- 2009 Free Software Foundation, Inc.
+ 2009, 2010 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
static int is_root_p (struct varobj *var);
+#if HAVE_PYTHON
+
static struct varobj *
varobj_add_child (struct varobj *var, const char *name, struct value *value);
+#endif /* HAVE_PYTHON */
+
/* C implementation */
static int c_number_of_children (struct varobj *var);
return delcount;
}
+#if HAVE_PYTHON
+
/* Convenience function for varobj_set_visualizer. Instantiate a
pretty-printer for a given value. */
static PyObject *
instantiate_pretty_printer (PyObject *constructor, struct value *value)
{
-#if HAVE_PYTHON
PyObject *val_obj = NULL;
PyObject *printer;
printer = PyObject_CallFunctionObjArgs (constructor, val_obj, NULL);
Py_DECREF (val_obj);
return printer;
-#endif
return NULL;
}
+#endif
+
/* Set/Get variable object display format */
enum varobj_display_formats
}
}
+#if HAVE_PYTHON
+
/* A helper for update_dynamic_varobj_children that installs a new
child when needed. */
}
}
-#if HAVE_PYTHON
-
static int
dynamic_varobj_has_child_method (struct varobj *var)
{
return var->children;
}
+#if HAVE_PYTHON
+
static struct varobj *
varobj_add_child (struct varobj *var, const char *name, struct value *value)
{
return v;
}
+#endif /* HAVE_PYTHON */
+
/* Obtain the type of an object Variable as a string similar to the one gdb
prints on the console */
struct cleanup *old_chain;
gdb_byte *thevalue = NULL;
struct value_print_options opts;
- int len = 0;
+ struct type *type = NULL;
+ long len = 0;
+ char *encoding = NULL;
+ struct gdbarch *gdbarch = NULL;
if (value == NULL)
return NULL;
+ gdbarch = get_type_arch (value_type (value));
#if HAVE_PYTHON
{
struct cleanup *back_to = varobj_ensure_python_env (var);
&replacement);
if (output)
{
- PyObject *py_str
- = python_string_to_target_python_string (output);
- if (py_str)
+ if (gdbpy_is_lazy_string (output))
+ {
+ thevalue = gdbpy_extract_lazy_string (output, &type,
+ &len, &encoding);
+ string_print = 1;
+ }
+ else
{
- char *s = PyString_AsString (py_str);
- len = PyString_Size (py_str);
- thevalue = xmemdup (s, len + 1, len + 1);
- Py_DECREF (py_str);
+ 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);
+ }
}
Py_DECREF (output);
}
if (thevalue && !string_print)
{
do_cleanups (back_to);
+ xfree (encoding);
return thevalue;
}
if (replacement)
opts.raw = 1;
if (thevalue)
{
- struct gdbarch *gdbarch = get_type_arch (value_type (value));
make_cleanup (xfree, thevalue);
- LA_PRINT_STRING (stb, builtin_type (gdbarch)->builtin_char,
- thevalue, len, 0, &opts);
+ make_cleanup (xfree, encoding);
+ LA_PRINT_STRING (stb, type, thevalue, len, encoding, 0, &opts);
}
else
common_val_print (value, stb, 0, &opts, current_language);