aboutsummaryrefslogtreecommitdiff
path: root/gdb/varobj.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-11-12 11:51:59 -0700
committerTom Tromey <tom@tromey.com>2017-01-10 19:13:56 -0700
commit68cdc55720bbe34d9d844ef2a0c4d75fcab4bc99 (patch)
treed445d8a973e416a562577406b9f2f5aba6501ae0 /gdb/varobj.c
parent1eba63835ea23cbae6059c076db985a47e39ce24 (diff)
downloadgdb-68cdc55720bbe34d9d844ef2a0c4d75fcab4bc99.zip
gdb-68cdc55720bbe34d9d844ef2a0c4d75fcab4bc99.tar.gz
gdb-68cdc55720bbe34d9d844ef2a0c4d75fcab4bc99.tar.bz2
Use gdbpy_enter_varobj in varobj_value_get_print_value
This changes the last function in varobj.c to use gdbpy_enter_varobj. 2017-01-10 Tom Tromey <tom@tromey.com> * varobj.c (varobj_value_get_print_value): Use gdbpy_enter_varobj.
Diffstat (limited to 'gdb/varobj.c')
-rw-r--r--gdb/varobj.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/gdb/varobj.c b/gdb/varobj.c
index d75c9b8..f93e930 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -2431,7 +2431,7 @@ varobj_value_get_print_value (struct value *value,
{
PyObject *value_formatter = var->dynamic->pretty_printer;
- varobj_ensure_python_env (var);
+ gdbpy_enter_varobj enter_py (var);
if (value_formatter)
{
@@ -2446,24 +2446,21 @@ varobj_value_get_print_value (struct value *value,
if (PyObject_HasAttr (value_formatter, gdbpy_to_string_cst))
{
struct value *replacement;
- PyObject *output = NULL;
- output = apply_varobj_pretty_printer (value_formatter,
- &replacement,
- stb);
+ gdbpy_ref output (apply_varobj_pretty_printer (value_formatter,
+ &replacement,
+ stb));
/* If we have string like output ... */
- if (output)
+ if (output != NULL)
{
- make_cleanup_py_decref (output);
-
/* If this is a lazy string, extract it. For lazy
strings we always print as a string, so set
string_print. */
- if (gdbpy_is_lazy_string (output))
+ if (gdbpy_is_lazy_string (output.get ()))
{
- gdbpy_extract_lazy_string (output, &str_addr, &type,
- &len, &encoding);
+ gdbpy_extract_lazy_string (output.get (), &str_addr,
+ &type, &len, &encoding);
string_print = 1;
}
else
@@ -2475,7 +2472,7 @@ varobj_value_get_print_value (struct value *value,
string as a value. */
gdb::unique_xmalloc_ptr<char> s
- = python_string_to_target_string (output);
+ = python_string_to_target_string (output.get ());
if (s)
{