From 8dc785338e94086138ebe94b9cae2dc5194a3d5e Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Wed, 13 Oct 2010 13:24:40 +0000 Subject: gdb/ * python/py-breakpoint.c (bppy_set_condition): New comment. * python/py-cmd.c (cmdpy_function): Call also gdbpy_print_stack for failed PyUnicode_Decode. (cmdpy_completer): Skip element for failed python_string_to_host_string. (cmdpy_init): Return -1 on failed python_string_to_host_string. * python/py-frame.c (frapy_read_var): Extend the function comment. * python/py-function.c (fnpy_init): Return -1 on failed python_string_to_host_string. * python/py-inferior.c (infpy_read_memory, infpy_write_memory): Extend the function comment. (infpy_search_memory): Extend the function comment. Remove the PyErr_SetString call on already set error state. * python/py-param.c (set_parameter_value): Extend the function comment. Return -1 on failed python_string_to_host_string, twice. (set_attr): Extend the function comment. (compute_enum_values): Extend the function comment. New variable back_to. Protect self->enumeration by BACK_TO cleanups. Return 0 on failed python_string_to_host_string. (get_doc_string): Call gdbpy_print_stack on failed python_string_to_host_string. (parmpy_init): Extend the function comment. * python/py-prettyprint.c (pretty_print_one_value): Likewise. (gdbpy_get_display_hint, print_children): Call gdbpy_print_stack on failed python_string_to_host_string. * python/py-value.c (valpy_new, valpy_getitem, valpy_call) (valpy_binop, valpy_richcompare): Extend the function comment. * python/python.c (struct python_env) : New fields. (restore_python_env): Handle PyErr_Occurred. Call PyErr_Restore. (ensure_python_env): Call PyErr_Fetch. * varobj.c (update_dynamic_varobj_children): Call gdbpy_print_stack on failed convert_value_from_python. (value_get_print_value): Call gdbpy_print_stack on failed python_string_to_target_python_string. gdb/testsuite/ * gdb.python/py-error.exp: New file. * gdb.python/py-error.py: New file. --- gdb/python/py-prettyprint.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'gdb/python/py-prettyprint.c') diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index 7aa83bc..cc6a346 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -196,8 +196,8 @@ find_pretty_printer (PyObject *value) is returned. If the function returns Py_NONE that means the pretty printer returned the Python None as a value. 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. */ + is returned. On error, *OUT_VALUE is set to NULL, NULL is + returned, with a python exception set. */ static PyObject * pretty_print_one_value (PyObject *printer, struct value **out_value) @@ -243,7 +243,11 @@ gdbpy_get_display_hint (PyObject *printer) if (hint) { if (gdbpy_is_string (hint)) - result = python_string_to_host_string (hint); + { + result = python_string_to_host_string (hint); + if (result == NULL) + gdbpy_print_stack (); + } Py_DECREF (hint); } else @@ -566,7 +570,10 @@ print_children (PyObject *printer, const char *hint, else { output = python_string_to_host_string (py_v); - fputs_filtered (output, stream); + if (!output) + gdbpy_print_stack (); + else + fputs_filtered (output, stream); xfree (output); } } -- cgit v1.1