mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-07-18 20:12:16 +08:00
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) <error_type, error_value, error_traceback>: 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.
This commit is contained in:
@ -79,6 +79,7 @@ struct python_env
|
||||
PyGILState_STATE state;
|
||||
struct gdbarch *gdbarch;
|
||||
const struct language_defn *language;
|
||||
PyObject *error_type, *error_value, *error_traceback;
|
||||
};
|
||||
|
||||
static void
|
||||
@ -86,6 +87,16 @@ restore_python_env (void *p)
|
||||
{
|
||||
struct python_env *env = (struct python_env *)p;
|
||||
|
||||
/* Leftover Python error is forbidden by Python Exception Handling. */
|
||||
if (PyErr_Occurred ())
|
||||
{
|
||||
/* This order is similar to the one calling error afterwards. */
|
||||
gdbpy_print_stack ();
|
||||
warning (_("internal error: Unhandled Python exception"));
|
||||
}
|
||||
|
||||
PyErr_Restore (env->error_type, env->error_value, env->error_traceback);
|
||||
|
||||
PyGILState_Release (env->state);
|
||||
python_gdbarch = env->gdbarch;
|
||||
python_language = env->language;
|
||||
@ -108,6 +119,9 @@ ensure_python_env (struct gdbarch *gdbarch,
|
||||
python_gdbarch = gdbarch;
|
||||
python_language = language;
|
||||
|
||||
/* Save it and ensure ! PyErr_Occurred () afterwards. */
|
||||
PyErr_Fetch (&env->error_type, &env->error_value, &env->error_traceback);
|
||||
|
||||
return make_cleanup (restore_python_env, env);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user