+2018-03-26 Tom Tromey <tom@tromey.com>
+
+ * python/py-framefilter.c (throw_quit_or_print_exception): New
+ function.
+ (gdbpy_apply_frame_filter): Use it.
+
2018-03-26 Tom Tromey <tom@tromey.com>
PR cli/17716:
return iterable.release ();
}
+/* A helper function that will either print an exception or, if it is
+ a KeyboardException, throw a quit. This can only be called when
+ the Python exception is set. */
+
+static void
+throw_quit_or_print_exception ()
+{
+ if (PyErr_ExceptionMatches (PyExc_KeyboardInterrupt))
+ {
+ PyErr_Clear ();
+ throw_quit ("Quit");
+ }
+ gdbpy_print_stack ();
+}
+
/* This is the only publicly exported function in this file. FRAME
is the source frame to start frame-filter invocation. FLAGS is an
integer holding the flags for printing. The following elements of
initialization error. This return code will trigger a
default backtrace. */
- gdbpy_print_stack ();
+ throw_quit_or_print_exception ();
return EXT_LANG_BT_NO_FILTERS;
}
{
if (PyErr_Occurred ())
{
- gdbpy_print_stack ();
+ throw_quit_or_print_exception ();
return EXT_LANG_BT_ERROR;
}
break;
/* Do not exit on error printing a single frame. Print the
error and continue with other frames. */
if (success == EXT_LANG_BT_ERROR)
- gdbpy_print_stack ();
+ throw_quit_or_print_exception ();
}
return success;
+2018-03-26 Tom Tromey <tom@tromey.com>
+
+ * gdb.python/py-framefilter.exp: Add test for KeyboardInterrupt.
+ * gdb.python/py-framefilter.py (name_error): New global.
+ (ErrorInName.function): Use name_error.
+
2018-03-26 Tom Tromey <tom@tromey.com>
PR backtrace/15582:
}
}
+# Now verify that we can see a quit.
+gdb_test_no_output "python name_error = KeyboardInterrupt" \
+ "Change ErrorFilter to throw KeyboardInterrupt"
+gdb_test "bt 1" "Quit" "bt 1 with KeyboardInterrupt"
+
+
# Test with no debuginfo
# We cannot use prepare_for_testing as we have to set the safe-patch
def filter (self, frame_iter):
return ElidingIterator (frame_iter)
+# This is here so the test can change the kind of error that is
+# thrown.
+name_error = RuntimeError
+
# A simple decorator that gives an error when computing the function.
class ErrorInName(FrameDecorator):
def __init__(self, frame):
FrameDecorator.__init__(self, frame)
def function(self):
- raise RuntimeError('whoops')
+ raise name_error('whoops')
# A filter that supplies buggy frames. Disabled by default.
class ErrorFilter():