This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA 07/11] Use gdbpy_enter_varobj in varobj_value_get_print_value


This changes the last function in varobj.c to use gdbpy_enter_varobj.

2016-11-12  Tom Tromey  <tom@tromey.com>

	* varobj.c (varobj_value_get_print_value): Use
	gdbpy_enter_varobj.
---
 gdb/ChangeLog |  5 +++++
 gdb/varobj.c  | 21 +++++++++------------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index db5e029..be7ce38 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2016-11-12  Tom Tromey  <tom@tromey.com>
 
+	* varobj.c (varobj_value_get_print_value): Use
+	gdbpy_enter_varobj.
+
+2016-11-12  Tom Tromey  <tom@tromey.com>
+
 	* python/py-prettyprint.c (print_string_repr, print_children):
 	Update.
 	* python/py-lazy-string.c (gdbpy_extract_lazy_string): Change type
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 25c5019..deebe08 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)
 			{
-- 
2.7.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]