This is the mail archive of the archer@sourceware.org mailing list for the Archer 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]

[python] fix snafu in value refc patch


I'm checking this in on the python branch.

My earlier value reference counting patch caused some test suite
failures.  This fixes the fixable ones -- there are still a couple of
varobj failures, but those require a deeper change (which I will start
soon).

Tom

2009-06-29  Tom Tromey  <tromey@redhat.com>

	* python/python.c (pretty_print_one_value): Update comment.
	(print_string_repr): Don't make a cleanup.
	* python/python-value.c (convert_value_from_python): Use
	value_copy again.

diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c
index 8c4361e..b7e634c 100644
--- a/gdb/python/python-value.c
+++ b/gdb/python/python-value.c
@@ -923,7 +923,12 @@ convert_value_from_python (PyObject *obj)
 	    }
 	}
       else if (PyObject_TypeCheck (obj, &value_object_type))
-	value = ((value_object *) obj)->value;
+	{
+	  /* This lets callers freely decref the Value wrapper object
+	     and not worry about whether or not the value will
+	     disappear.  */
+	  value = value_copy (((value_object *) obj)->value);
+	}
       else
 	PyErr_Format (PyExc_TypeError, _("Could not convert Python object: %s"),
 		      PyString_AsString (PyObject_Str (obj)));
diff --git a/gdb/python/python.c b/gdb/python/python.c
index f1f25ee..dc49409 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -829,8 +829,8 @@ find_pretty_printer (PyObject *value)
 /* Pretty-print a single value, via the printer object PRINTER.
    If the function returns a string, a PyObject containing the string
    is returned.  Otherwise, if the function returns a value,
-   *OUT_VALUE is set to the value, and NULL is returned.  On error,
-   *OUT_VALUE is set to NULL, and NULL is returned.  */
+   the value (still on the all_values chain), and NULL is returned.
+   On error, *OUT_VALUE is set to NULL and NULL is returned.  */
 static PyObject *
 pretty_print_one_value (PyObject *printer, struct value **out_value)
 {
@@ -907,7 +907,6 @@ print_string_repr (PyObject *printer, const char *hint,
 {
   struct value *replacement = NULL;
   PyObject *py_str = NULL;
-  struct cleanup *cleanups = make_cleanup (null_cleanup, 0);
 
   py_str = pretty_print_one_value (printer, &replacement);
   if (py_str)
@@ -930,13 +929,9 @@ print_string_repr (PyObject *printer, const char *hint,
       Py_DECREF (py_str);
     }
   else if (replacement)
-    {
-      make_cleanup (value_free_cleanup, replacement);
-      common_val_print (replacement, stream, recurse, options, language);
-    }
+    common_val_print (replacement, stream, recurse, options, language);
   else
     gdbpy_print_stack ();
-  do_cleanups (cleanups);
 }
 
 static void


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