diff options
author | Tom Tromey <tromey@redhat.com> | 2010-11-12 20:49:43 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2010-11-12 20:49:43 +0000 |
commit | 621c83642d17cf523c20f55f2ed945a7ec95ea6a (patch) | |
tree | 231cb6bb882e72fb68d6a5eb189060af43bb0dad /gdb/python/python-internal.h | |
parent | f1b9e6e7ee6f55dd82194417e8f4d1713783ef39 (diff) |
gdb
* varobj.c (value_get_print_value): Rearrange. Pass stream to
apply_varobj_pretty_printer.
* c-lang.c: Include exceptions.h.
(c_get_string): Throw MEMORY_ERROR when appropriate.
* python/py-prettyprint.c (enum string_repr_result): New.
(print_stack_unless_memory_error): New function.
(print_string_repr): Change return type. Use
print_stack_unless_memory_error.
(print_children): Use print_stack_unless_memory_error.
(apply_val_pretty_printer): Update. Don't print children if
string representation threw an exception.
(apply_varobj_pretty_printer): Add 'stream' argument. Use
print_stack_unless_memory_error.
* python/python.c (gdbpy_gdb_error, gdbpy_gdb_memory_error): New
globals.
(_initialize_python): Initialize them.
* python/python-internal.h (GDB_PY_HANDLE_EXCEPTION): Use
gdbpy_convert_exception.
(GDB_PY_SET_HANDLE_EXCEPTION): Likewise.
(gdbpy_gdb_error, gdbpy_gdb_memory_error): Declare.
(gdbpy_convert_exception): Declare.
(apply_varobj_pretty_printer): Update.
* python/py-utils.c (gdbpy_convert_exception): New function.
gdb/doc
* gdb.texinfo (Basic Python): Update. Add xref.
(Exception Handling): Document new exception classes.
(Types In Python): Update.
(Frames In Python): Update.
gdb/testsuite
* gdb.python/py-prettyprint.c (main): Add new 'ns2' local.
* gdb.python/py-prettyprint.exp (run_lang_tests): Add test for
MemoryError.
* gdb.python/python.exp (gdb_py_test_multiple): Update exception
type.
* gdb.python/py-value.exp (test_value_in_inferior): Add test for
MemoryError.
(test_subscript_regression): Update exception type.
Diffstat (limited to 'gdb/python/python-internal.h')
-rw-r--r-- | gdb/python/python-internal.h | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 67de6223a1..30d75336a4 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -80,6 +80,8 @@ typedef int Py_ssize_t; /* Also needed to parse enum var_types. */ #include "command.h" +#include "exceptions.h" + struct block; struct value; struct language_defn; @@ -179,9 +181,7 @@ extern const struct language_defn *python_language; #define GDB_PY_HANDLE_EXCEPTION(Exception) \ do { \ if (Exception.reason < 0) \ - return PyErr_Format (Exception.reason == RETURN_QUIT \ - ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, \ - "%s", Exception.message); \ + return gdbpy_convert_exception (Exception); \ } while (0) /* Use this after a TRY_EXCEPT to throw the appropriate Python @@ -190,9 +190,7 @@ extern const struct language_defn *python_language; do { \ if (Exception.reason < 0) \ { \ - PyErr_Format (Exception.reason == RETURN_QUIT \ - ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, \ - "%s", Exception.message); \ + gdbpy_convert_exception (Exception); \ return -1; \ } \ } while (0) @@ -222,7 +220,8 @@ int gdbpy_is_value_object (PyObject *obj); /* 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 value **replacement, + struct ui_file *stream); PyObject *gdbpy_get_varobj_pretty_printer (struct value *value); char *gdbpy_get_display_hint (PyObject *printer); PyObject *gdbpy_default_visualizer (PyObject *self, PyObject *args); @@ -233,8 +232,13 @@ extern PyObject *gdbpy_to_string_cst; extern PyObject *gdbpy_display_hint_cst; extern PyObject *gdbpy_enabled_cst; +/* Exception types. */ +extern PyObject *gdbpy_gdb_error; +extern PyObject *gdbpy_gdb_memory_error; extern PyObject *gdbpy_gdberror_exc; +extern PyObject *gdbpy_convert_exception (struct gdb_exception); + int get_addr_from_python (PyObject *obj, CORE_ADDR *addr); #endif /* GDB_PYTHON_INTERNAL_H */ |