This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
[python][rfc] convert_value_from_python changes in pretty-printing
- From: Thiago Jung Bauermann <bauerman at br dot ibm dot com>
- To: archer ml <archer at sourceware dot org>
- Date: Wed, 04 Feb 2009 11:25:35 -0200
- Subject: [python][rfc] convert_value_from_python changes in pretty-printing
Hi,
As a result of review comments in gdb-patches, I changed
convert_value_from_python from throwing a GDB exception on error to
throwing a Python exception. Most callers were easy to adapt, but I'm
not sure about the changes I made in pretty_print_one_value and
print_children, could you take a look?
The former I probably got right, it doesn't error out or throw an
exception if convert_value_from_python fails. But the latter is less
clear to me. It seems to me it expects a GDB exception to be thrown on
error, so that's what I do. But maybe it would be better to just call
gdbpy_print_stack and move on?
--
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center
diff --git a/gdb/python/python.c b/gdb/python/python.c
index a3a8bdf..5fe8f8d 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -955,7 +955,11 @@ pretty_print_one_value (PyObject *printer, struct value **out_value)
*out_value = value_copy (v);
}
else
- *out_value = convert_value_from_python (result);
+ {
+ *out_value = convert_value_from_python (result);
+ if (*out_value == NULL)
+ gdbpy_print_stack ();
+ }
Py_DECREF (result);
}
else
@@ -1252,7 +1256,14 @@ print_children (PyObject *printer, const char *hint,
else
{
struct value *value = convert_value_from_python (py_v);
- common_val_print (value, stream, recurse + 1, options, language);
+
+ if (value == NULL)
+ {
+ gdbpy_print_stack ();
+ error(_("Error while executing Python code."));
+ }
+ else
+ common_val_print (value, stream, recurse + 1, options, language);
}
if (is_map && i % 2 == 0)