dictionary that carries the same information as an MI "*stopped"
event.
+ ** New function gdb.interrupt(), that interrupts GDB as if the user
+ typed control-c.
+
* Debugger Adapter Protocol changes
** GDB now emits the "process" event.
work well in @value{GDBN}.
@end deftp
+@defun gdb.interrupt ()
+This causes @value{GDBN} to react as if the user had typed a control-C
+character at the terminal. That is, if the inferior is running, it is
+interrupted; if a @value{GDBN} command is executing, it is stopped;
+and if a Python command is running, @code{KeyboardInterrupt} will be
+raised.
+
+Unlike most Python APIs in @value{GDBN}, @code{interrupt} is
+thread-safe.
+@end defun
+
@defun gdb.post_event (event)
Put @var{event}, a callable object taking no arguments, into
@value{GDBN}'s internal event queue. This callable will be invoked at
Py_RETURN_NONE;
}
+/* Interrupt the current operation on the main thread. */
+static PyObject *
+gdbpy_interrupt (PyObject *self, PyObject *args)
+{
+ {
+ /* Make sure the interrupt isn't delivered immediately somehow.
+ This probably is not truly needed, but at the same time it
+ seems more clear to be explicit about the intent. */
+ gdbpy_allow_threads temporarily_exit_python;
+ scoped_disable_cooperative_sigint_handling no_python_sigint;
+
+ set_quit_flag ();
+ }
+
+ Py_RETURN_NONE;
+}
+
\f
/* This is the extension_language_ops.before_prompt "method". */
{ "post_event", gdbpy_post_event, METH_VARARGS,
"Post an event into gdb's event loop." },
+ { "interrupt", gdbpy_interrupt, METH_NOARGS,
+ "Interrupt gdb's current operation." },
{ "target_charset", gdbpy_target_charset, METH_NOARGS,
"target_charset () -> string.\n\