From bc543c902f9891f732be68817e16ff379b69566e Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 25 Dec 2018 12:38:01 -0700 Subject: Translate PyExc_KeyboardInterrupt to gdb "quit" A while back I typed "info pretty-printers" with a large number of printers installed, and I typed "q" to stop the pagination. I noticed that gdb printed a Python exception in this case. It seems to me that, instead, quitting pagination (or control-c'ing a Python command generally) should be handled the same way that gdb normally handles a quit. This patch implements this idea by changing gdbpy_handle_exception to treat PyExc_KeyboardInterrupt specially. gdb/ChangeLog 2018-12-27 Tom Tromey * python/py-utils.c (gdbpy_handle_exception): Translate PyExc_KeyboardInterrupt to quit. gdb/testsuite/ChangeLog 2018-12-27 Tom Tromey * gdb.python/py-cmd.exp (test_python_inline_or_multiline): Add pagination test. --- gdb/python/py-utils.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gdb/python') diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index e0aedb5..a587644 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -422,7 +422,9 @@ gdbpy_handle_exception () for user errors. However, a missing message for gdb.GdbError exceptions is arguably a bug, so we flag it as such. */ - if (! PyErr_GivenExceptionMatches (ptype, gdbpy_gdberror_exc) + if (PyErr_GivenExceptionMatches (ptype, PyExc_KeyboardInterrupt)) + throw_quit ("Quit"); + else if (! PyErr_GivenExceptionMatches (ptype, gdbpy_gdberror_exc) || msg == NULL || *msg == '\0') { PyErr_Restore (ptype, pvalue, ptraceback); -- cgit v1.1