From 6ef2312a177ebdfa841e82b515c144975073a501 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 25 Dec 2018 11:44:58 -0700 Subject: Consolidate some Python exception-printing functions A few places in the Python code would either call gdbpy_print_stack, or throw a gdb "quit", depending on the pending exception. This patch consolidates these into a helper function. gdb/ChangeLog 2018-12-27 Tom Tromey * python/python-internal.h (gdbpy_print_stack_or_quit): Declare. * python/py-unwind.c (pyuw_sniffer): Use gdbpy_print_stack_or_quit. * python/py-framefilter.c (throw_quit_or_print_exception): Remove. (gdbpy_apply_frame_filter): Use gdbpy_print_stack_or_quit. * python/python.c (gdbpy_print_stack_or_quit): New function. --- gdb/python/python.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gdb/python/python.c') diff --git a/gdb/python/python.c b/gdb/python/python.c index f790d48..3d0b0a0 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -1268,6 +1268,20 @@ gdbpy_print_stack (void) } } +/* Like gdbpy_print_stack, but if the exception is a + KeyboardException, throw a gdb "quit" instead. */ + +void +gdbpy_print_stack_or_quit () +{ + if (PyErr_ExceptionMatches (PyExc_KeyboardInterrupt)) + { + PyErr_Clear (); + throw_quit ("Quit"); + } + gdbpy_print_stack (); +} + /* Return a sequence holding all the Progspaces. */ -- cgit v1.1