+2018-09-09 Simon Marchi <simon.marchi@ericsson.com>
+
+ * python/py-prettyprint.c (pretty_print_one_value): Return
+ gdbpy_ref<>.
+ (print_string_repr): Adjust.
+ (apply_varobj_pretty_printer): Return gdbpy_ref<>.
+ * python/python-internal.h (apply_varobj_pretty_printer): Return
+ gdbpy_ref<>.
+ * varobj.c (varobj_value_get_print_value): Adjust.
+
2018-09-08 Tom Tromey <tom@tromey.com>
PR python/16047:
is returned. On error, *OUT_VALUE is set to NULL, NULL is
returned, with a python exception set. */
-static PyObject *
+static gdbpy_ref<>
pretty_print_one_value (PyObject *printer, struct value **out_value)
{
gdbpy_ref<> result;
}
END_CATCH
- return result.release ();
+ return result;
}
/* Return the display hint for the object printer, PRINTER. Return
struct value *replacement = NULL;
enum string_repr_result result = string_repr_ok;
- gdbpy_ref<> py_str (pretty_print_one_value (printer, &replacement));
+ gdbpy_ref<> py_str = pretty_print_one_value (printer, &replacement);
if (py_str != NULL)
{
if (py_str == Py_None)
set to the replacement value and this function returns NULL. On
error, *REPLACEMENT is set to NULL and this function also returns
NULL. */
-PyObject *
+gdbpy_ref<>
apply_varobj_pretty_printer (PyObject *printer_obj,
struct value **replacement,
struct ui_file *stream)
{
- PyObject *py_str = NULL;
-
*replacement = NULL;
- py_str = pretty_print_one_value (printer_obj, replacement);
+ gdbpy_ref<> py_str = pretty_print_one_value (printer_obj, replacement);
if (*replacement == NULL && py_str == NULL)
print_stack_unless_memory_error (stream);
from including our python/python.h header file. */
#include <Python.h>
#include <frameobject.h>
+#include "py-ref.h"
#if PY_MAJOR_VERSION >= 3
#define IS_PY3K 1
/* Note that these are declared here, and not in python.h with the
other pretty-printer functions, because they refer to PyObject. */
-PyObject *apply_varobj_pretty_printer (PyObject *print_obj,
- struct value **replacement,
- struct ui_file *stream);
+gdbpy_ref<> apply_varobj_pretty_printer (PyObject *print_obj,
+ struct value **replacement,
+ struct ui_file *stream);
PyObject *gdbpy_get_varobj_pretty_printer (struct value *value);
gdb::unique_xmalloc_ptr<char> gdbpy_get_display_hint (PyObject *printer);
PyObject *gdbpy_default_visualizer (PyObject *self, PyObject *args);
{
struct value *replacement;
- gdbpy_ref<> 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 != NULL)